PostgreSQL Source Code  git master
lsyscache.h File Reference
#include "access/attnum.h"
#include "access/htup.h"
#include "nodes/pg_list.h"
Include dependency graph for lsyscache.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  OpBtreeInterpretation
 
struct  AttStatsSlot
 

Macros

#define ATTSTATSSLOT_VALUES   0x01
 
#define ATTSTATSSLOT_NUMBERS   0x02
 
#define type_is_array(typid)   (get_element_type(typid) != InvalidOid)
 
#define type_is_array_domain(typid)   (get_base_element_type(typid) != InvalidOid)
 
#define TypeIsToastable(typid)   (get_typstorage(typid) != TYPSTORAGE_PLAIN)
 

Typedefs

typedef struct OpBtreeInterpretation OpBtreeInterpretation
 
typedef enum IOFuncSelector IOFuncSelector
 
typedef struct AttStatsSlot AttStatsSlot
 
typedef int32(* get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum)
 

Enumerations

enum  IOFuncSelector { IOFunc_input, IOFunc_output, IOFunc_receive, IOFunc_send }
 

Functions

bool op_in_opfamily (Oid opno, Oid opfamily)
 
int get_op_opfamily_strategy (Oid opno, Oid opfamily)
 
Oid get_op_opfamily_sortfamily (Oid opno, Oid opfamily)
 
void get_op_opfamily_properties (Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
 
Oid get_opfamily_member (Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
 
bool get_ordering_op_properties (Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
 
Oid get_equality_op_for_ordering_op (Oid opno, bool *reverse)
 
Oid get_ordering_op_for_equality_op (Oid opno, bool use_lhs_type)
 
Listget_mergejoin_opfamilies (Oid opno)
 
bool get_compatible_hash_operators (Oid opno, Oid *lhs_opno, Oid *rhs_opno)
 
bool get_op_hash_functions (Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
 
Listget_op_btree_interpretation (Oid opno)
 
bool equality_ops_are_compatible (Oid opno1, Oid opno2)
 
bool comparison_ops_are_compatible (Oid opno1, Oid opno2)
 
Oid get_opfamily_proc (Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
 
char * get_attname (Oid relid, AttrNumber attnum, bool missing_ok)
 
AttrNumber get_attnum (Oid relid, const char *attname)
 
char get_attgenerated (Oid relid, AttrNumber attnum)
 
Oid get_atttype (Oid relid, AttrNumber attnum)
 
void get_atttypetypmodcoll (Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
 
Datum get_attoptions (Oid relid, int16 attnum)
 
Oid get_cast_oid (Oid sourcetypeid, Oid targettypeid, bool missing_ok)
 
char * get_collation_name (Oid colloid)
 
bool get_collation_isdeterministic (Oid colloid)
 
char * get_constraint_name (Oid conoid)
 
Oid get_constraint_index (Oid conoid)
 
char * get_language_name (Oid langoid, bool missing_ok)
 
Oid get_opclass_family (Oid opclass)
 
Oid get_opclass_input_type (Oid opclass)
 
bool get_opclass_opfamily_and_input_type (Oid opclass, Oid *opfamily, Oid *opcintype)
 
RegProcedure get_opcode (Oid opno)
 
char * get_opname (Oid opno)
 
Oid get_op_rettype (Oid opno)
 
void op_input_types (Oid opno, Oid *lefttype, Oid *righttype)
 
bool op_mergejoinable (Oid opno, Oid inputtype)
 
bool op_hashjoinable (Oid opno, Oid inputtype)
 
bool op_strict (Oid opno)
 
char op_volatile (Oid opno)
 
Oid get_commutator (Oid opno)
 
Oid get_negator (Oid opno)
 
RegProcedure get_oprrest (Oid opno)
 
RegProcedure get_oprjoin (Oid opno)
 
char * get_func_name (Oid funcid)
 
Oid get_func_namespace (Oid funcid)
 
Oid get_func_rettype (Oid funcid)
 
int get_func_nargs (Oid funcid)
 
Oid get_func_signature (Oid funcid, Oid **argtypes, int *nargs)
 
Oid get_func_variadictype (Oid funcid)
 
bool get_func_retset (Oid funcid)
 
bool func_strict (Oid funcid)
 
char func_volatile (Oid funcid)
 
char func_parallel (Oid funcid)
 
char get_func_prokind (Oid funcid)
 
bool get_func_leakproof (Oid funcid)
 
RegProcedure get_func_support (Oid funcid)
 
Oid get_relname_relid (const char *relname, Oid relnamespace)
 
char * get_rel_name (Oid relid)
 
Oid get_rel_namespace (Oid relid)
 
Oid get_rel_type_id (Oid relid)
 
char get_rel_relkind (Oid relid)
 
bool get_rel_relispartition (Oid relid)
 
Oid get_rel_tablespace (Oid relid)
 
char get_rel_persistence (Oid relid)
 
Oid get_transform_fromsql (Oid typid, Oid langid, List *trftypes)
 
Oid get_transform_tosql (Oid typid, Oid langid, List *trftypes)
 
bool get_typisdefined (Oid typid)
 
int16 get_typlen (Oid typid)
 
bool get_typbyval (Oid typid)
 
void get_typlenbyval (Oid typid, int16 *typlen, bool *typbyval)
 
void get_typlenbyvalalign (Oid typid, int16 *typlen, bool *typbyval, char *typalign)
 
Oid getTypeIOParam (HeapTuple typeTuple)
 
void get_type_io_data (Oid typid, IOFuncSelector which_func, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *func)
 
char get_typstorage (Oid typid)
 
Nodeget_typdefault (Oid typid)
 
char get_typtype (Oid typid)
 
bool type_is_rowtype (Oid typid)
 
bool type_is_enum (Oid typid)
 
bool type_is_range (Oid typid)
 
bool type_is_multirange (Oid typid)
 
void get_type_category_preferred (Oid typid, char *typcategory, bool *typispreferred)
 
Oid get_typ_typrelid (Oid typid)
 
Oid get_element_type (Oid typid)
 
Oid get_array_type (Oid typid)
 
Oid get_promoted_array_type (Oid typid)
 
Oid get_base_element_type (Oid typid)
 
void getTypeInputInfo (Oid type, Oid *typInput, Oid *typIOParam)
 
void getTypeOutputInfo (Oid type, Oid *typOutput, bool *typIsVarlena)
 
void getTypeBinaryInputInfo (Oid type, Oid *typReceive, Oid *typIOParam)
 
void getTypeBinaryOutputInfo (Oid type, Oid *typSend, bool *typIsVarlena)
 
Oid get_typmodin (Oid typid)
 
Oid get_typcollation (Oid typid)
 
bool type_is_collatable (Oid typid)
 
RegProcedure get_typsubscript (Oid typid, Oid *typelemp)
 
const struct SubscriptRoutinesgetSubscriptingRoutines (Oid typid, Oid *typelemp)
 
Oid getBaseType (Oid typid)
 
Oid getBaseTypeAndTypmod (Oid typid, int32 *typmod)
 
int32 get_typavgwidth (Oid typid, int32 typmod)
 
int32 get_attavgwidth (Oid relid, AttrNumber attnum)
 
bool get_attstatsslot (AttStatsSlot *sslot, HeapTuple statstuple, int reqkind, Oid reqop, int flags)
 
void free_attstatsslot (AttStatsSlot *sslot)
 
char * get_namespace_name (Oid nspid)
 
char * get_namespace_name_or_temp (Oid nspid)
 
Oid get_range_subtype (Oid rangeOid)
 
Oid get_range_collation (Oid rangeOid)
 
Oid get_range_multirange (Oid rangeOid)
 
Oid get_multirange_range (Oid multirangeOid)
 
Oid get_index_column_opclass (Oid index_oid, int attno)
 
bool get_index_isreplident (Oid index_oid)
 
bool get_index_isvalid (Oid index_oid)
 
bool get_index_isclustered (Oid index_oid)
 

Variables

PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook
 

Macro Definition Documentation

◆ ATTSTATSSLOT_NUMBERS

◆ ATTSTATSSLOT_VALUES

◆ type_is_array

#define type_is_array (   typid)    (get_element_type(typid) != InvalidOid)

Definition at line 201 of file lsyscache.h.

Referenced by IsBinaryCoercible(), make_partition_op_expr(), and transformArrayExpr().

◆ type_is_array_domain

#define type_is_array_domain (   typid)    (get_base_element_type(typid) != InvalidOid)

◆ TypeIsToastable

#define TypeIsToastable (   typid)    (get_typstorage(typid) != TYPSTORAGE_PLAIN)

Definition at line 205 of file lsyscache.h.

Referenced by ATExecSetStorage(), and ExecIndexBuildScanKeys().

Typedef Documentation

◆ AttStatsSlot

typedef struct AttStatsSlot AttStatsSlot

◆ get_attavgwidth_hook_type

typedef int32(* get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum)

Definition at line 65 of file lsyscache.h.

◆ IOFuncSelector

◆ OpBtreeInterpretation

Enumeration Type Documentation

◆ IOFuncSelector

Enumerator
IOFunc_input 
IOFunc_output 
IOFunc_receive 
IOFunc_send 

Definition at line 33 of file lsyscache.h.

Function Documentation

◆ comparison_ops_are_compatible()

bool comparison_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 747 of file lsyscache.c.

References AMOPOPID, GETSTRUCT, i, catclist::members, catclist::n_members, ObjectIdGetDatum, op_in_opfamily(), ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by ineq_histogram_selectivity().

748 {
749  bool result;
750  CatCList *catlist;
751  int i;
752 
753  /* Easy if they're the same operator */
754  if (opno1 == opno2)
755  return true;
756 
757  /*
758  * We search through all the pg_amop entries for opno1.
759  */
760  catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
761 
762  result = false;
763  for (i = 0; i < catlist->n_members; i++)
764  {
765  HeapTuple op_tuple = &catlist->members[i]->tuple;
766  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
767 
768  if (op_form->amopmethod == BTREE_AM_OID)
769  {
770  if (op_in_opfamily(opno2, op_form->amopfamily))
771  {
772  result = true;
773  break;
774  }
775  }
776  }
777 
778  ReleaseSysCacheList(catlist);
779 
780  return result;
781 }
bool op_in_opfamily(Oid opno, Oid opfamily)
Definition: lsyscache.c:64
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121

◆ equality_ops_are_compatible()

bool equality_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 696 of file lsyscache.c.

References AMOPOPID, GETSTRUCT, i, catclist::members, catclist::n_members, ObjectIdGetDatum, op_in_opfamily(), ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by query_is_distinct_for().

697 {
698  bool result;
699  CatCList *catlist;
700  int i;
701 
702  /* Easy if they're the same operator */
703  if (opno1 == opno2)
704  return true;
705 
706  /*
707  * We search through all the pg_amop entries for opno1.
708  */
709  catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
710 
711  result = false;
712  for (i = 0; i < catlist->n_members; i++)
713  {
714  HeapTuple op_tuple = &catlist->members[i]->tuple;
715  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
716 
717  /* must be btree or hash */
718  if (op_form->amopmethod == BTREE_AM_OID ||
719  op_form->amopmethod == HASH_AM_OID)
720  {
721  if (op_in_opfamily(opno2, op_form->amopfamily))
722  {
723  result = true;
724  break;
725  }
726  }
727  }
728 
729  ReleaseSysCacheList(catlist);
730 
731  return result;
732 }
bool op_in_opfamily(Oid opno, Oid opfamily)
Definition: lsyscache.c:64
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121

◆ free_attstatsslot()

void free_attstatsslot ( AttStatsSlot sslot)

Definition at line 3267 of file lsyscache.c.

References AttStatsSlot::numbers_arr, pfree(), AttStatsSlot::values, and AttStatsSlot::values_arr.

Referenced by _int_matchsel(), booltestsel(), brincostestimate(), btcostestimate(), calc_arraycontsel(), calc_hist_selectivity(), calc_multirangesel(), calc_rangesel(), eqjoinsel(), estimate_hash_bucket_stats(), ExecHashBuildSkewHash(), get_variable_range(), histogram_selectivity(), ineq_histogram_selectivity(), mcv_selectivity(), networkjoinsel_inner(), networkjoinsel_semi(), networksel(), scalararraysel_containment(), tsquerysel(), var_eq_const(), and var_eq_non_const().

3268 {
3269  /* The values[] array was separately palloc'd by deconstruct_array */
3270  if (sslot->values)
3271  pfree(sslot->values);
3272  /* The numbers[] array points into numbers_arr, do not pfree it */
3273  /* Free the detoasted array objects, if any */
3274  if (sslot->values_arr)
3275  pfree(sslot->values_arr);
3276  if (sslot->numbers_arr)
3277  pfree(sslot->numbers_arr);
3278 }
void pfree(void *pointer)
Definition: mcxt.c:1057
void * values_arr
Definition: lsyscache.h:60
Datum * values
Definition: lsyscache.h:53
void * numbers_arr
Definition: lsyscache.h:61

◆ func_parallel()

char func_parallel ( Oid  funcid)

Definition at line 1743 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by max_parallel_hazard_checker(), and set_rel_consider_parallel().

1744 {
1745  HeapTuple tp;
1746  char result;
1747 
1748  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1749  if (!HeapTupleIsValid(tp))
1750  elog(ERROR, "cache lookup failed for function %u", funcid);
1751 
1752  result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1753  ReleaseSysCache(tp);
1754  return result;
1755 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228

◆ func_strict()

bool func_strict ( Oid  funcid)

Definition at line 1705 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by AggregateCreate(), clause_is_strict_for(), contain_nonstrict_functions_checker(), find_nonnullable_rels_walker(), find_nonnullable_vars_walker(), hash_ok_operator(), is_strict_saop(), op_strict(), and process_equivalence().

1706 {
1707  HeapTuple tp;
1708  bool result;
1709 
1710  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1711  if (!HeapTupleIsValid(tp))
1712  elog(ERROR, "cache lookup failed for function %u", funcid);
1713 
1714  result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
1715  ReleaseSysCache(tp);
1716  return result;
1717 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228

◆ func_volatile()

char func_volatile ( Oid  funcid)

Definition at line 1724 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by contain_mutable_functions_checker(), contain_volatile_functions_checker(), contain_volatile_functions_not_nextval_checker(), ece_function_is_safe(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), findTypeInputFunction(), findTypeOutputFunction(), findTypeReceiveFunction(), findTypeSendFunction(), findTypeTypmodinFunction(), findTypeTypmodoutFunction(), and op_volatile().

1725 {
1726  HeapTuple tp;
1727  char result;
1728 
1729  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1730  if (!HeapTupleIsValid(tp))
1731  elog(ERROR, "cache lookup failed for function %u", funcid);
1732 
1733  result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile;
1734  ReleaseSysCache(tp);
1735  return result;
1736 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228

◆ get_array_type()

Oid get_array_type ( Oid  typid)

Definition at line 2707 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by AlterTypeNamespace_oid(), enforce_generic_type_consistency(), get_promoted_array_type(), initArrayResultAny(), LookupTypeNameExtended(), make_partition_op_expr(), make_scalar_array_op(), moveArrayTypeName(), ParseFuncOrColumn(), resolve_anyarray_from_others(), transformAExprIn(), and transformArrayExpr().

2708 {
2709  HeapTuple tp;
2710  Oid result = InvalidOid;
2711 
2713  if (HeapTupleIsValid(tp))
2714  {
2715  result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
2716  ReleaseSysCache(tp);
2717  }
2718  return result;
2719 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 3078 of file lsyscache.c.

References attnum, BoolGetDatum, get_attavgwidth_hook, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache3(), and STATRELATTINH.

Referenced by get_rel_data_width(), and set_rel_width().

3079 {
3080  HeapTuple tp;
3081  int32 stawidth;
3082 
3084  {
3085  stawidth = (*get_attavgwidth_hook) (relid, attnum);
3086  if (stawidth > 0)
3087  return stawidth;
3088  }
3090  ObjectIdGetDatum(relid),
3092  BoolGetDatum(false));
3093  if (HeapTupleIsValid(tp))
3094  {
3095  stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3096  ReleaseSysCache(tp);
3097  if (stawidth > 0)
3098  return stawidth;
3099  }
3100  return 0;
3101 }
get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:51
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:134
signed int int32
Definition: c.h:417
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1149
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define BoolGetDatum(X)
Definition: postgres.h:402
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_attgenerated()

char get_attgenerated ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 886 of file lsyscache.c.

References ATTNUM, elog, ERROR, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache2().

Referenced by ATExecAlterColumnType(), and check_nested_generated_walker().

887 {
888  HeapTuple tp;
889  Form_pg_attribute att_tup;
890  char result;
891 
892  tp = SearchSysCache2(ATTNUM,
893  ObjectIdGetDatum(relid),
895  if (!HeapTupleIsValid(tp))
896  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
897  attnum, relid);
898  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
899  result = att_tup->attgenerated;
900  ReleaseSysCache(tp);
901  return result;
902 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138
#define elog(elevel,...)
Definition: elog.h:228

◆ get_attname()

char* get_attname ( Oid  relid,
AttrNumber  attnum,
bool  missing_ok 
)

Definition at line 825 of file lsyscache.c.

References ATTNUM, elog, ERROR, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), and SearchSysCache2().

Referenced by AddRelationNewConstraints(), ATExecAlterColumnType(), check_nested_generated_walker(), ComputePartitionAttrs(), conversion_error_callback(), decompile_column_index_array(), deparseColumnRef(), errtablecol(), fixup_inherited_columns(), generateClonedExtStatsStmt(), generateClonedIndexStmt(), get_insert_query_def(), get_rte_attribute_name(), get_update_query_targetlist_def(), getObjectDescription(), getObjectIdentityParts(), pg_get_constraintdef_worker(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsobj_worker(), pg_get_triggerdef_worker(), processIndirection(), transformPartitionBound(), and transformPartitionRangeBounds().

826 {
827  HeapTuple tp;
828 
829  tp = SearchSysCache2(ATTNUM,
831  if (HeapTupleIsValid(tp))
832  {
834  char *result;
835 
836  result = pstrdup(NameStr(att_tup->attname));
837  ReleaseSysCache(tp);
838  return result;
839  }
840 
841  if (!missing_ok)
842  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
843  attnum, relid);
844  return NULL;
845 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138
#define elog(elevel,...)
Definition: elog.h:228
#define NameStr(name)
Definition: c.h:669

◆ get_attnum()

AttrNumber get_attnum ( Oid  relid,
const char *  attname 
)

Definition at line 856 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidAttrNumber, ReleaseSysCache(), and SearchSysCacheAttName().

Referenced by ATExecColumnDefault(), ATExecDropNotNull(), expand_col_privileges(), fixup_inherited_columns(), get_object_address_attrdef(), get_object_address_attribute(), LookupTypeNameExtended(), pg_get_serial_sequence(), process_owned_by(), transformAlterTableStmt(), and transformAssignmentIndirection().

857 {
858  HeapTuple tp;
859 
860  tp = SearchSysCacheAttName(relid, attname);
861  if (HeapTupleIsValid(tp))
862  {
864  AttrNumber result;
865 
866  result = att_tup->attnum;
867  ReleaseSysCache(tp);
868  return result;
869  }
870  else
871  return InvalidAttrNumber;
872 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
NameData attname
Definition: pg_attribute.h:40
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1268
#define InvalidAttrNumber
Definition: attnum.h:23
int16 AttrNumber
Definition: attnum.h:21

◆ get_attoptions()

Datum get_attoptions ( Oid  relid,
int16  attnum 
)

Definition at line 968 of file lsyscache.c.

References ATTNAME, ATTNUM, datumCopy(), elog, ERROR, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache2(), and SysCacheGetAttr().

Referenced by generateClonedIndexStmt(), pg_get_indexdef_worker(), RelationGetIndexAttOptions(), RelationGetIndexRawAttOptions(), and transformIndexConstraint().

969 {
970  HeapTuple tuple;
971  Datum attopts;
972  Datum result;
973  bool isnull;
974 
975  tuple = SearchSysCache2(ATTNUM,
976  ObjectIdGetDatum(relid),
978 
979  if (!HeapTupleIsValid(tuple))
980  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
981  attnum, relid);
982 
983  attopts = SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions,
984  &isnull);
985 
986  if (isnull)
987  result = (Datum) 0;
988  else
989  result = datumCopy(attopts, false, -1); /* text[] */
990 
991  ReleaseSysCache(tuple);
992 
993  return result;
994 }
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition: datum.c:131
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1388
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138
#define elog(elevel,...)
Definition: elog.h:228

◆ get_attstatsslot()

bool get_attstatsslot ( AttStatsSlot sslot,
HeapTuple  statstuple,
int  reqkind,
Oid  reqop,
int  flags 
)

Definition at line 3150 of file lsyscache.c.

References ARR_DATA_PTR, ARR_DIMS, ARR_ELEMTYPE, ARR_HASNULL, ARR_NDIM, ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, DatumGetArrayTypePCopy, deconstruct_array(), elog, ERROR, GETSTRUCT, HeapTupleIsValid, i, InvalidOid, AttStatsSlot::nnumbers, AttStatsSlot::numbers, AttStatsSlot::numbers_arr, AttStatsSlot::nvalues, ObjectIdGetDatum, pfree(), ReleaseSysCache(), SearchSysCache1(), AttStatsSlot::stacoll, AttStatsSlot::staop, STATISTIC_NUM_SLOTS, STATRELATTINH, SysCacheGetAttr(), TYPEOID, val, AttStatsSlot::values, AttStatsSlot::values_arr, and AttStatsSlot::valuetype.

Referenced by _int_matchsel(), booltestsel(), brincostestimate(), btcostestimate(), calc_arraycontsel(), calc_hist_selectivity(), calc_multirangesel(), calc_rangesel(), eqjoinsel(), estimate_hash_bucket_stats(), ExecHashBuildSkewHash(), get_variable_range(), histogram_selectivity(), ineq_histogram_selectivity(), mcv_selectivity(), networkjoinsel_inner(), networkjoinsel_semi(), networksel(), scalararraysel_containment(), tsquerysel(), var_eq_const(), and var_eq_non_const().

3152 {
3153  Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
3154  int i;
3155  Datum val;
3156  bool isnull;
3157  ArrayType *statarray;
3158  Oid arrayelemtype;
3159  int narrayelem;
3160  HeapTuple typeTuple;
3161  Form_pg_type typeForm;
3162 
3163  /* initialize *sslot properly */
3164  memset(sslot, 0, sizeof(AttStatsSlot));
3165 
3166  for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
3167  {
3168  if ((&stats->stakind1)[i] == reqkind &&
3169  (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
3170  break;
3171  }
3172  if (i >= STATISTIC_NUM_SLOTS)
3173  return false; /* not there */
3174 
3175  sslot->staop = (&stats->staop1)[i];
3176  sslot->stacoll = (&stats->stacoll1)[i];
3177 
3178  if (flags & ATTSTATSSLOT_VALUES)
3179  {
3180  val = SysCacheGetAttr(STATRELATTINH, statstuple,
3181  Anum_pg_statistic_stavalues1 + i,
3182  &isnull);
3183  if (isnull)
3184  elog(ERROR, "stavalues is null");
3185 
3186  /*
3187  * Detoast the array if needed, and in any case make a copy that's
3188  * under control of this AttStatsSlot.
3189  */
3190  statarray = DatumGetArrayTypePCopy(val);
3191 
3192  /*
3193  * Extract the actual array element type, and pass it back in case the
3194  * caller needs it.
3195  */
3196  sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3197 
3198  /* Need info about element type */
3199  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
3200  if (!HeapTupleIsValid(typeTuple))
3201  elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3202  typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
3203 
3204  /* Deconstruct array into Datum elements; NULLs not expected */
3205  deconstruct_array(statarray,
3206  arrayelemtype,
3207  typeForm->typlen,
3208  typeForm->typbyval,
3209  typeForm->typalign,
3210  &sslot->values, NULL, &sslot->nvalues);
3211 
3212  /*
3213  * If the element type is pass-by-reference, we now have a bunch of
3214  * Datums that are pointers into the statarray, so we need to keep
3215  * that until free_attstatsslot. Otherwise, all the useful info is in
3216  * sslot->values[], so we can free the array object immediately.
3217  */
3218  if (!typeForm->typbyval)
3219  sslot->values_arr = statarray;
3220  else
3221  pfree(statarray);
3222 
3223  ReleaseSysCache(typeTuple);
3224  }
3225 
3226  if (flags & ATTSTATSSLOT_NUMBERS)
3227  {
3228  val = SysCacheGetAttr(STATRELATTINH, statstuple,
3229  Anum_pg_statistic_stanumbers1 + i,
3230  &isnull);
3231  if (isnull)
3232  elog(ERROR, "stanumbers is null");
3233 
3234  /*
3235  * Detoast the array if needed, and in any case make a copy that's
3236  * under control of this AttStatsSlot.
3237  */
3238  statarray = DatumGetArrayTypePCopy(val);
3239 
3240  /*
3241  * We expect the array to be a 1-D float4 array; verify that. We don't
3242  * need to use deconstruct_array() since the array data is just going
3243  * to look like a C array of float4 values.
3244  */
3245  narrayelem = ARR_DIMS(statarray)[0];
3246  if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3247  ARR_HASNULL(statarray) ||
3248  ARR_ELEMTYPE(statarray) != FLOAT4OID)
3249  elog(ERROR, "stanumbers is not a 1-D float4 array");
3250 
3251  /* Give caller a pointer directly into the statarray */
3252  sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3253  sslot->nnumbers = narrayelem;
3254 
3255  /* We'll free the statarray in free_attstatsslot */
3256  sslot->numbers_arr = statarray;
3257  }
3258 
3259  return true;
3260 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ATTSTATSSLOT_VALUES
Definition: lsyscache.h:42
int nnumbers
Definition: lsyscache.h:57
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:134
void pfree(void *pointer)
Definition: mcxt.c:1057
#define ATTSTATSSLOT_NUMBERS
Definition: lsyscache.h:43
void * values_arr
Definition: lsyscache.h:60
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
#define ARR_DIMS(a)
Definition: array.h:287
#define ARR_DATA_PTR(a)
Definition: array.h:315
float4 * numbers
Definition: lsyscache.h:56
#define ARR_HASNULL(a)
Definition: array.h:284
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
float float4
Definition: c.h:552
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1388
#define DatumGetArrayTypePCopy(X)
Definition: array.h:255
#define InvalidOid
Definition: postgres_ext.h:36
#define STATISTIC_NUM_SLOTS
Definition: pg_statistic.h:126
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
Datum * values
Definition: lsyscache.h:53
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define ARR_NDIM(a)
Definition: array.h:283
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3488
#define elog(elevel,...)
Definition: elog.h:228
int i
void * numbers_arr
Definition: lsyscache.h:61
Oid valuetype
Definition: lsyscache.h:52
#define ARR_ELEMTYPE(a)
Definition: array.h:285
long val
Definition: informix.c:664

◆ get_atttype()

Oid get_atttype ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 911 of file lsyscache.c.

References ATTNUM, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache2().

Referenced by generateClonedIndexStmt(), LookupTypeNameExtended(), slot_store_error_callback(), and transformAlterTableStmt().

912 {
913  HeapTuple tp;
914 
915  tp = SearchSysCache2(ATTNUM,
916  ObjectIdGetDatum(relid),
918  if (HeapTupleIsValid(tp))
919  {
921  Oid result;
922 
923  result = att_tup->atttypid;
924  ReleaseSysCache(tp);
925  return result;
926  }
927  else
928  return InvalidOid;
929 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138

◆ get_atttypetypmodcoll()

void get_atttypetypmodcoll ( Oid  relid,
AttrNumber  attnum,
Oid typid,
int32 typmod,
Oid collid 
)

Definition at line 941 of file lsyscache.c.

References ATTNUM, elog, ERROR, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache2().

Referenced by pg_get_indexdef_worker(), pg_get_partkeydef_worker(), and transformAssignmentIndirection().

943 {
944  HeapTuple tp;
945  Form_pg_attribute att_tup;
946 
947  tp = SearchSysCache2(ATTNUM,
948  ObjectIdGetDatum(relid),
950  if (!HeapTupleIsValid(tp))
951  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
952  attnum, relid);
953  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
954 
955  *typid = att_tup->atttypid;
956  *typmod = att_tup->atttypmod;
957  *collid = att_tup->attcollation;
958  ReleaseSysCache(tp);
959 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138
#define elog(elevel,...)
Definition: elog.h:228

◆ get_base_element_type()

Oid get_base_element_type ( Oid  typid)

Definition at line 2752 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by array_typanalyze(), arraycontsel(), build_datatype(), cache_array_element_properties(), concat_internal(), ConstructTupleDescriptor(), count_nulls(), CreateFunction(), get_call_expr_argtype(), get_rule_expr(), make_scalar_array_op(), ParseFuncOrColumn(), plperl_hash_from_tuple(), scalararraysel(), and text_format().

2753 {
2754  /*
2755  * We loop to find the bottom base type in a stack of domains.
2756  */
2757  for (;;)
2758  {
2759  HeapTuple tup;
2760  Form_pg_type typTup;
2761 
2762  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2763  if (!HeapTupleIsValid(tup))
2764  break;
2765  typTup = (Form_pg_type) GETSTRUCT(tup);
2766  if (typTup->typtype != TYPTYPE_DOMAIN)
2767  {
2768  /* Not a domain, so stop descending */
2769  Oid result;
2770 
2771  /* This test must match get_element_type */
2772  if (IsTrueArrayType(typTup))
2773  result = typTup->typelem;
2774  else
2775  result = InvalidOid;
2776  ReleaseSysCache(tup);
2777  return result;
2778  }
2779 
2780  typid = typTup->typbasetype;
2781  ReleaseSysCache(tup);
2782  }
2783 
2784  /* Like get_element_type, silently return InvalidOid for bogus input */
2785  return InvalidOid;
2786 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_cast_oid()

Oid get_cast_oid ( Oid  sourcetypeid,
Oid  targettypeid,
bool  missing_ok 
)

Definition at line 1005 of file lsyscache.c.

References CASTSOURCETARGET, ereport, errcode(), errmsg(), ERROR, format_type_be(), GetSysCacheOid2, ObjectIdGetDatum, and OidIsValid.

Referenced by get_object_address().

1006 {
1007  Oid oid;
1008 
1009  oid = GetSysCacheOid2(CASTSOURCETARGET, Anum_pg_cast_oid,
1010  ObjectIdGetDatum(sourcetypeid),
1011  ObjectIdGetDatum(targettypeid));
1012  if (!OidIsValid(oid) && !missing_ok)
1013  ereport(ERROR,
1014  (errcode(ERRCODE_UNDEFINED_OBJECT),
1015  errmsg("cast from type %s to type %s does not exist",
1016  format_type_be(sourcetypeid),
1017  format_type_be(targettypeid))));
1018  return oid;
1019 }
int errcode(int sqlerrcode)
Definition: elog.c:704
char * format_type_be(Oid type_oid)
Definition: format_type.c:339
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:698
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
#define ereport(elevel,...)
Definition: elog.h:155
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
Definition: syscache.h:195
int errmsg(const char *fmt,...)
Definition: elog.c:915

◆ get_collation_isdeterministic()

bool get_collation_isdeterministic ( Oid  colloid)

Definition at line 1052 of file lsyscache.c.

References COLLOID, elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1().

Referenced by btvarstrequalimage(), index_create(), match_pattern_prefix(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), ri_restrict(), and ri_set().

1053 {
1054  HeapTuple tp;
1055  Form_pg_collation colltup;
1056  bool result;
1057 
1058  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1059  if (!HeapTupleIsValid(tp))
1060  elog(ERROR, "cache lookup failed for collation %u", colloid);
1061  colltup = (Form_pg_collation) GETSTRUCT(tp);
1062  result = colltup->collisdeterministic;
1063  ReleaseSysCache(tp);
1064  return result;
1065 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:47
#define elog(elevel,...)
Definition: elog.h:228

◆ get_collation_name()

char* get_collation_name ( Oid  colloid)

Definition at line 1033 of file lsyscache.c.

References COLLOID, GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), and SearchSysCache1().

Referenced by analyzeCTE(), assign_collations_walker(), assign_hypothetical_collations(), ATExecAddColumn(), do_collation_version_check(), merge_collation_state(), MergeAttributes(), select_common_collation(), and show_sortorder_options().

1034 {
1035  HeapTuple tp;
1036 
1037  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1038  if (HeapTupleIsValid(tp))
1039  {
1041  char *result;
1042 
1043  result = pstrdup(NameStr(colltup->collname));
1044  ReleaseSysCache(tp);
1045  return result;
1046  }
1047  else
1048  return NULL;
1049 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:47
#define NameStr(name)
Definition: c.h:669

◆ get_commutator()

Oid get_commutator ( Oid  opno)

Definition at line 1453 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1().

Referenced by CommuteOpExpr(), compute_semijoin_info(), ComputeIndexAttrs(), convert_EXISTS_to_ANY(), eqjoinsel(), expand_indexqual_rowcompare(), match_clause_to_ordering_op(), match_clause_to_partition_key(), match_foreign_keys_to_quals(), match_opclause_to_indexcol(), match_rowcompare_to_indexcol(), multirangesel(), networkjoinsel(), operator_predicate_proof(), rangesel(), scalarineqsel_wrapper(), and targetIsInSortList().

1454 {
1455  HeapTuple tp;
1456 
1458  if (HeapTupleIsValid(tp))
1459  {
1461  Oid result;
1462 
1463  result = optup->oprcom;
1464  ReleaseSysCache(tp);
1465  return result;
1466  }
1467  else
1468  return InvalidOid;
1469 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_compatible_hash_operators()

bool get_compatible_hash_operators ( Oid  opno,
Oid lhs_opno,
Oid rhs_opno 
)

Definition at line 408 of file lsyscache.c.

References AMOPOPID, get_opfamily_member(), GETSTRUCT, HTEqualStrategyNumber, i, InvalidOid, catclist::members, catclist::n_members, ObjectIdGetDatum, OidIsValid, ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by create_unique_plan(), and ExecInitSubPlan().

410 {
411  bool result = false;
412  CatCList *catlist;
413  int i;
414 
415  /* Ensure output args are initialized on failure */
416  if (lhs_opno)
417  *lhs_opno = InvalidOid;
418  if (rhs_opno)
419  *rhs_opno = InvalidOid;
420 
421  /*
422  * Search pg_amop to see if the target operator is registered as the "="
423  * operator of any hash opfamily. If the operator is registered in
424  * multiple opfamilies, assume we can use any one.
425  */
427 
428  for (i = 0; i < catlist->n_members; i++)
429  {
430  HeapTuple tuple = &catlist->members[i]->tuple;
431  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
432 
433  if (aform->amopmethod == HASH_AM_OID &&
434  aform->amopstrategy == HTEqualStrategyNumber)
435  {
436  /* No extra lookup needed if given operator is single-type */
437  if (aform->amoplefttype == aform->amoprighttype)
438  {
439  if (lhs_opno)
440  *lhs_opno = opno;
441  if (rhs_opno)
442  *rhs_opno = opno;
443  result = true;
444  break;
445  }
446 
447  /*
448  * Get the matching single-type operator(s). Failure probably
449  * shouldn't happen --- it implies a bogus opfamily --- but
450  * continue looking if so.
451  */
452  if (lhs_opno)
453  {
454  *lhs_opno = get_opfamily_member(aform->amopfamily,
455  aform->amoplefttype,
456  aform->amoplefttype,
458  if (!OidIsValid(*lhs_opno))
459  continue;
460  /* Matching LHS found, done if caller doesn't want RHS */
461  if (!rhs_opno)
462  {
463  result = true;
464  break;
465  }
466  }
467  if (rhs_opno)
468  {
469  *rhs_opno = get_opfamily_member(aform->amopfamily,
470  aform->amoprighttype,
471  aform->amoprighttype,
473  if (!OidIsValid(*rhs_opno))
474  {
475  /* Forget any LHS operator from this opfamily */
476  if (lhs_opno)
477  *lhs_opno = InvalidOid;
478  continue;
479  }
480  /* Matching RHS found, so done */
481  result = true;
482  break;
483  }
484  }
485  }
486 
487  ReleaseSysCacheList(catlist);
488 
489  return result;
490 }
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define OidIsValid(objectId)
Definition: c.h:698
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define HTEqualStrategyNumber
Definition: stratnum.h:41
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:164
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
#define InvalidOid
Definition: postgres_ext.h:36
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121

◆ get_constraint_index()

Oid get_constraint_index ( Oid  conoid)

Definition at line 1106 of file lsyscache.c.

References CONSTROID, GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1().

Referenced by ATPostAlterTypeParse(), infer_arbiter_indexes(), and RememberConstraintForRebuilding().

1107 {
1108  HeapTuple tp;
1109 
1111  if (HeapTupleIsValid(tp))
1112  {
1114  Oid result;
1115 
1116  result = contup->conindid;
1117  ReleaseSysCache(tp);
1118  return result;
1119  }
1120  else
1121  return InvalidOid;
1122 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
FormData_pg_constraint * Form_pg_constraint
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_constraint_name()

char* get_constraint_name ( Oid  conoid)

Definition at line 1079 of file lsyscache.c.

References CONSTROID, GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), and SearchSysCache1().

Referenced by addFkRecurseReferencing(), get_insert_query_def(), and report_triggers().

1080 {
1081  HeapTuple tp;
1082 
1084  if (HeapTupleIsValid(tp))
1085  {
1087  char *result;
1088 
1089  result = pstrdup(NameStr(contup->conname));
1090  ReleaseSysCache(tp);
1091  return result;
1092  }
1093  else
1094  return NULL;
1095 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_constraint * Form_pg_constraint
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:669

◆ get_element_type()

Oid get_element_type ( Oid  typid)

Definition at line 2679 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by aclcheck_error_type(), AlterTypeNamespace_oid(), build_coercion_expression(), check_generic_type_consistency(), CheckAttributeType(), CreateCast(), enforce_generic_type_consistency(), exec_stmt_foreach_a(), ExecInitExprRec(), fetch_array_arg_replace_nulls(), find_coercion_pathway(), get_promoted_array_type(), initArrayResultAny(), initArrayResultArr(), interpret_function_parameter_list(), is_complex_array(), json_categorize_type(), jsonb_categorize_type(), moveArrayTypeName(), plperl_array_to_datum(), ProcedureCreate(), resolve_anyelement_from_others(), transformArrayExpr(), and transformTypeCast().

2680 {
2681  HeapTuple tp;
2682 
2684  if (HeapTupleIsValid(tp))
2685  {
2686  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2687  Oid result;
2688 
2689  if (IsTrueArrayType(typtup))
2690  result = typtup->typelem;
2691  else
2692  result = InvalidOid;
2693  ReleaseSysCache(tp);
2694  return result;
2695  }
2696  else
2697  return InvalidOid;
2698 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_equality_op_for_ordering_op()

Oid get_equality_op_for_ordering_op ( Oid  opno,
bool reverse 
)

Definition at line 265 of file lsyscache.c.

References BTEqualStrategyNumber, BTGreaterStrategyNumber, get_opfamily_member(), get_ordering_op_properties(), and InvalidOid.

Referenced by addTargetToSortList(), create_unique_plan(), preparePresortedCols(), preprocess_minmax_aggregates(), and show_sortorder_options().

266 {
267  Oid result = InvalidOid;
268  Oid opfamily;
269  Oid opcintype;
270  int16 strategy;
271 
272  /* Find the operator in pg_amop */
274  &opfamily, &opcintype, &strategy))
275  {
276  /* Found a suitable opfamily, get matching equality operator */
277  result = get_opfamily_member(opfamily,
278  opcintype,
279  opcintype,
281  if (reverse)
282  *reverse = (strategy == BTGreaterStrategyNumber);
283  }
284 
285  return result;
286 }
signed short int16
Definition: c.h:416
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
unsigned int Oid
Definition: postgres_ext.h:31
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:164
#define InvalidOid
Definition: postgres_ext.h:36
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
Definition: lsyscache.c:205
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_func_leakproof()

bool get_func_leakproof ( Oid  funcid)

Definition at line 1781 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by contain_leaked_vars_checker(), contain_leaked_vars_walker(), select_equality_operator(), statext_is_compatible_clause_internal(), and statistic_proc_security_check().

1782 {
1783  HeapTuple tp;
1784  bool result;
1785 
1786  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1787  if (!HeapTupleIsValid(tp))
1788  elog(ERROR, "cache lookup failed for function %u", funcid);
1789 
1790  result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
1791  ReleaseSysCache(tp);
1792  return result;
1793 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228

◆ get_func_name()

char* get_func_name ( Oid  funcid)

Definition at line 1552 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, PROCOID, pstrdup(), ReleaseSysCache(), and SearchSysCache1().

Referenced by AlterOpFamilyAdd(), DefineOpClass(), ExecBuildGroupingEqual(), ExecInitAgg(), ExecInitExprRec(), ExecInitFunc(), ExecInitWindowAgg(), ExecuteCallStmt(), ExplainTargetRel(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), HandleFunctionRequest(), init_sexpr(), initialize_peragg(), lookup_agg_function(), lookup_am_handler_func(), print_expr(), show_tablesample(), and statistic_proc_security_check().

1553 {
1554  HeapTuple tp;
1555 
1556  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1557  if (HeapTupleIsValid(tp))
1558  {
1559  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1560  char *result;
1561 
1562  result = pstrdup(NameStr(functup->proname));
1563  ReleaseSysCache(tp);
1564  return result;
1565  }
1566  else
1567  return NULL;
1568 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:669

◆ get_func_namespace()

Oid get_func_namespace ( Oid  funcid)

Definition at line 1576 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by sepgsql_proc_drop(), and unaccent_dict().

1577 {
1578  HeapTuple tp;
1579 
1580  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1581  if (HeapTupleIsValid(tp))
1582  {
1583  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1584  Oid result;
1585 
1586  result = functup->pronamespace;
1587  ReleaseSysCache(tp);
1588  return result;
1589  }
1590  else
1591  return InvalidOid;
1592 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_func_nargs()

int get_func_nargs ( Oid  funcid)

Definition at line 1618 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, pronargs, ReleaseSysCache(), and SearchSysCache1().

1619 {
1620  HeapTuple tp;
1621  int result;
1622 
1623  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1624  if (!HeapTupleIsValid(tp))
1625  elog(ERROR, "cache lookup failed for function %u", funcid);
1626 
1627  result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1628  ReleaseSysCache(tp);
1629  return result;
1630 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
int16 pronargs
Definition: pg_proc.h:81
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228

◆ get_func_prokind()

char get_func_prokind ( Oid  funcid)

Definition at line 1762 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by LookupFuncWithArgs(), and RemoveObjects().

1763 {
1764  HeapTuple tp;
1765  char result;
1766 
1767  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1768  if (!HeapTupleIsValid(tp))
1769  elog(ERROR, "cache lookup failed for function %u", funcid);
1770 
1771  result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
1772  ReleaseSysCache(tp);
1773  return result;
1774 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228

◆ get_func_retset()

bool get_func_retset ( Oid  funcid)

Definition at line 1686 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by make_op(), and make_scalar_array_op().

1687 {
1688  HeapTuple tp;
1689  bool result;
1690 
1691  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1692  if (!HeapTupleIsValid(tp))
1693  elog(ERROR, "cache lookup failed for function %u", funcid);
1694 
1695  result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
1696  ReleaseSysCache(tp);
1697  return result;
1698 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228

◆ get_func_rettype()

Oid get_func_rettype ( Oid  funcid)

Definition at line 1599 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by CreateConversionCommand(), CreateEventTrigger(), CreateProceduralLanguage(), CreateTrigger(), DefineOperator(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), findTypeAnalyzeFunction(), findTypeInputFunction(), findTypeOutputFunction(), findTypeReceiveFunction(), findTypeSendFunction(), findTypeSubscriptingFunction(), findTypeTypmodinFunction(), findTypeTypmodoutFunction(), get_ts_parser_func(), get_ts_template_func(), gistrescan(), interpret_func_support(), lookup_am_handler_func(), lookup_fdw_handler_func(), OperatorCreate(), spgrescan(), transformRangeTableSample(), ValidateJoinEstimator(), and ValidateRestrictionEstimator().

1600 {
1601  HeapTuple tp;
1602  Oid result;
1603 
1604  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1605  if (!HeapTupleIsValid(tp))
1606  elog(ERROR, "cache lookup failed for function %u", funcid);
1607 
1608  result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype;
1609  ReleaseSysCache(tp);
1610  return result;
1611 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228

◆ get_func_signature()

Oid get_func_signature ( Oid  funcid,
Oid **  argtypes,
int *  nargs 
)

Definition at line 1640 of file lsyscache.c.

References Assert, elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, palloc(), PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by plperl_call_perl_func(), and resolve_aggregate_transtype().

1641 {
1642  HeapTuple tp;
1643  Form_pg_proc procstruct;
1644  Oid result;
1645 
1646  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1647  if (!HeapTupleIsValid(tp))
1648  elog(ERROR, "cache lookup failed for function %u", funcid);
1649 
1650  procstruct = (Form_pg_proc) GETSTRUCT(tp);
1651 
1652  result = procstruct->prorettype;
1653  *nargs = (int) procstruct->pronargs;
1654  Assert(*nargs == procstruct->proargtypes.dim1);
1655  *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1656  memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1657 
1658  ReleaseSysCache(tp);
1659  return result;
1660 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:792
void * palloc(Size size)
Definition: mcxt.c:950
#define elog(elevel,...)
Definition: elog.h:228

◆ get_func_support()

RegProcedure get_func_support ( Oid  funcid)

Definition at line 1802 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by function_selectivity(), and get_index_clause_from_support().

1803 {
1804  HeapTuple tp;
1805 
1806  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1807  if (HeapTupleIsValid(tp))
1808  {
1809  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1810  RegProcedure result;
1811 
1812  result = functup->prosupport;
1813  ReleaseSysCache(tp);
1814  return result;
1815  }
1816  else
1817  return (RegProcedure) InvalidOid;
1818 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:573
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_func_variadictype()

Oid get_func_variadictype ( Oid  funcid)

Definition at line 1667 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1().

Referenced by assign_hypothetical_collations(), and assign_ordered_set_collations().

1668 {
1669  HeapTuple tp;
1670  Oid result;
1671 
1672  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1673  if (!HeapTupleIsValid(tp))
1674  elog(ERROR, "cache lookup failed for function %u", funcid);
1675 
1676  result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
1677  ReleaseSysCache(tp);
1678  return result;
1679 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228

◆ get_index_column_opclass()

Oid get_index_column_opclass ( Oid  index_oid,
int  attno 
)

Definition at line 3435 of file lsyscache.c.

References Assert, DatumGetPointer, GETSTRUCT, HeapTupleIsValid, INDEXRELID, InvalidOid, ObjectIdGetDatum, PG_USED_FOR_ASSERTS_ONLY, ReleaseSysCache(), SearchSysCache1(), SysCacheGetAttr(), and oidvector::values.

Referenced by gistproperty(), and spgproperty().

3436 {
3437  HeapTuple tuple;
3439  Datum datum;
3440  bool isnull;
3441  oidvector *indclass;
3442  Oid opclass;
3443 
3444  /* First we need to know the column's opclass. */
3445 
3446  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3447  if (!HeapTupleIsValid(tuple))
3448  return InvalidOid;
3449 
3450  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3451 
3452  /* caller is supposed to guarantee this */
3453  Assert(attno > 0 && attno <= rd_index->indnatts);
3454 
3455  /* Non-key attributes don't have an opclass */
3456  if (attno > rd_index->indnkeyatts)
3457  {
3458  ReleaseSysCache(tuple);
3459  return InvalidOid;
3460  }
3461 
3462  datum = SysCacheGetAttr(INDEXRELID, tuple,
3463  Anum_pg_index_indclass, &isnull);
3464  Assert(!isnull);
3465 
3466  indclass = ((oidvector *) DatumGetPointer(datum));
3467 
3468  Assert(attno <= indclass->dim1);
3469  opclass = indclass->values[attno - 1];
3470 
3471  ReleaseSysCache(tuple);
3472 
3473  return opclass;
3474 }
Definition: c.h:648
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition: c.h:656
FormData_pg_index * Form_pg_index
Definition: pg_index.h:68
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1388
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:792
#define DatumGetPointer(X)
Definition: postgres.h:549
#define PG_USED_FOR_ASSERTS_ONLY
Definition: c.h:143

◆ get_index_isclustered()

bool get_index_isclustered ( Oid  index_oid)

Definition at line 3528 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, INDEXRELID, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1().

Referenced by cluster(), cluster_rel(), mark_index_clustered(), and RememberClusterOnForRebuilding().

3529 {
3530  bool isclustered;
3531  HeapTuple tuple;
3532  Form_pg_index rd_index;
3533 
3534  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3535  if (!HeapTupleIsValid(tuple))
3536  elog(ERROR, "cache lookup failed for index %u", index_oid);
3537 
3538  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3539  isclustered = rd_index->indisclustered;
3540  ReleaseSysCache(tuple);
3541 
3542  return isclustered;
3543 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
FormData_pg_index * Form_pg_index
Definition: pg_index.h:68
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228

◆ get_index_isreplident()

bool get_index_isreplident ( Oid  index_oid)

Definition at line 3482 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, INDEXRELID, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1().

Referenced by RememberReplicaIdentityForRebuilding().

3483 {
3484  HeapTuple tuple;
3485  Form_pg_index rd_index;
3486  bool result;
3487 
3488  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3489  if (!HeapTupleIsValid(tuple))
3490  return false;
3491 
3492  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3493  result = rd_index->indisreplident;
3494  ReleaseSysCache(tuple);
3495 
3496  return result;
3497 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
FormData_pg_index * Form_pg_index
Definition: pg_index.h:68
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3505 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, INDEXRELID, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1().

Referenced by reindex_index(), reindex_relation(), and ReindexRelationConcurrently().

3506 {
3507  bool isvalid;
3508  HeapTuple tuple;
3509  Form_pg_index rd_index;
3510 
3511  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3512  if (!HeapTupleIsValid(tuple))
3513  elog(ERROR, "cache lookup failed for index %u", index_oid);
3514 
3515  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3516  isvalid = rd_index->indisvalid;
3517  ReleaseSysCache(tuple);
3518 
3519  return isvalid;
3520 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
FormData_pg_index * Form_pg_index
Definition: pg_index.h:68
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228

◆ get_language_name()

char* get_language_name ( Oid  langoid,
bool  missing_ok 
)

Definition at line 1127 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, LANGOID, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), and SearchSysCache1().

Referenced by get_transform_oid(), getObjectDescription(), getObjectIdentityParts(), and pg_get_functiondef().

1128 {
1129  HeapTuple tp;
1130 
1131  tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
1132  if (HeapTupleIsValid(tp))
1133  {
1135  char *result;
1136 
1137  result = pstrdup(NameStr(lantup->lanname));
1138  ReleaseSysCache(tp);
1139  return result;
1140  }
1141 
1142  if (!missing_ok)
1143  elog(ERROR, "cache lookup failed for language %u",
1144  langoid);
1145  return NULL;
1146 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_language * Form_pg_language
Definition: pg_language.h:65
#define elog(elevel,...)
Definition: elog.h:228
#define NameStr(name)
Definition: c.h:669

◆ get_mergejoin_opfamilies()

List* get_mergejoin_opfamilies ( Oid  opno)

Definition at line 364 of file lsyscache.c.

References AMOPOPID, BTEqualStrategyNumber, GETSTRUCT, i, lappend_oid(), catclist::members, catclist::n_members, NIL, ObjectIdGetDatum, ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by check_mergejoinable(), compute_semijoin_info(), make_pathkey_from_sortinfo(), and match_eclasses_to_foreign_key_col().

365 {
366  List *result = NIL;
367  CatCList *catlist;
368  int i;
369 
370  /*
371  * Search pg_amop to see if the target operator is registered as the "="
372  * operator of any btree opfamily.
373  */
375 
376  for (i = 0; i < catlist->n_members; i++)
377  {
378  HeapTuple tuple = &catlist->members[i]->tuple;
379  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
380 
381  /* must be btree equality */
382  if (aform->amopmethod == BTREE_AM_OID &&
383  aform->amopstrategy == BTEqualStrategyNumber)
384  result = lappend_oid(result, aform->amopfamily);
385  }
386 
387  ReleaseSysCacheList(catlist);
388 
389  return result;
390 }
#define NIL
Definition: pg_list.h:65
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
List * lappend_oid(List *list, Oid datum)
Definition: list.c:357
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121
Definition: pg_list.h:50
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_multirange_range()

Oid get_multirange_range ( Oid  multirangeOid)

Definition at line 3406 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, RANGEMULTIRANGE, ReleaseSysCache(), and SearchSysCache1().

Referenced by check_generic_type_consistency(), enforce_generic_type_consistency(), load_multirangetype_info(), resolve_anyelement_from_others(), and resolve_anyrange_from_others().

3407 {
3408  HeapTuple tp;
3409 
3410  tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
3411  if (HeapTupleIsValid(tp))
3412  {
3413  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3414  Oid result;
3415 
3416  result = rngtup->rngtypid;
3417  ReleaseSysCache(tp);
3418  return result;
3419  }
3420  else
3421  return InvalidOid;
3422 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:58
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_namespace_name()

char* get_namespace_name ( Oid  nspid)

Definition at line 3289 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, NAMESPACEOID, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), and SearchSysCache1().

Referenced by acquire_inherited_sample_rows(), add_cast_to(), AlterExtensionNamespace(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterRelationNamespaceInternal(), AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), appendFunctionName(), ApplyExtensionUpdates(), ATExecChangeOwner(), ATParseTransformCmd(), BuildRelationExtStatistics(), check_TSCurrentConfig(), compute_return_type(), copy_table(), copy_table_data(), CreateConversionCommand(), CreateExtensionInternal(), CreateFunction(), current_schema(), current_schemas(), currtid_internal(), DefineAggregate(), DefineCollation(), DefineDomain(), DefineEnum(), DefineIndex(), DefineOpClass(), DefineOperator(), DefineOpFamily(), DefineRange(), DefineTSConfiguration(), DefineTSDictionary(), DefineType(), deparseOperatorName(), deparseRelation(), do_analyze_rel(), do_autovacuum(), DoCopy(), errdatatype(), errtable(), EventTriggerSQLDropAddObject(), exec_object_restorecon(), ExecAlterExtensionContentsStmt(), ExecBRInsertTriggers(), ExecBRUpdateTriggers(), ExecRefreshMatView(), execute_extension_script(), ExplainTargetRel(), fetch_statentries_for_relation(), format_operator_extended(), format_procedure_extended(), generate_collation_name(), generate_function_name(), generate_operator_clause(), generate_operator_name(), generate_qualified_relation_name(), generate_qualified_type_name(), generate_relation_name(), generateClonedIndexStmt(), generateSerialExtraStmts(), get_collation(), get_namespace_name_or_temp(), get_opclass(), get_opclass_name(), get_other_operator(), getObjectDescription(), getOpFamilyDescription(), getRelationDescription(), GetTempNamespaceBackendId(), HandleFunctionRequest(), heap_create(), heap_vacuum_rel(), isAnyTempNamespace(), IsThereCollationInNamespace(), IsThereFunctionInNamespace(), IsThereOpClassInNamespace(), IsThereOpFamilyInNamespace(), logicalrep_write_namespace(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), parallel_vacuum_main(), perform_work_item(), pg_decode_change(), pg_decode_truncate(), pg_event_trigger_ddl_commands(), pg_get_functiondef(), pg_get_statisticsobj_worker(), pg_identify_object(), plpgsql_fulfill_promise(), postgresExplainForeignScan(), quoteRelationName(), RangeVarCallbackForAlterRelation(), RangeVarGetAndCheckCreationNamespace(), RebuildConstraintComment(), refresh_by_match_merge(), regclassout(), regcollationout(), regconfigout(), regdictionaryout(), regnamespaceout(), regoperout(), regprocout(), reindex_index(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), report_namespace_conflict(), ri_GenerateQualCollation(), schema_to_xml_internal(), sepgsql_proc_post_create(), sepgsql_relation_post_create(), SPI_getnspname(), transformAlterTableStmt(), transformCreateStmt(), and unaccent_dict().

3290 {
3291  HeapTuple tp;
3292 
3294  if (HeapTupleIsValid(tp))
3295  {
3297  char *result;
3298 
3299  result = pstrdup(NameStr(nsptup->nspname));
3300  ReleaseSysCache(tp);
3301  return result;
3302  }
3303  else
3304  return NULL;
3305 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
FormData_pg_namespace * Form_pg_namespace
Definition: pg_namespace.h:52
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:669

◆ get_namespace_name_or_temp()

char* get_namespace_name_or_temp ( Oid  nspid)

Definition at line 3313 of file lsyscache.c.

References get_namespace_name(), and isTempNamespace().

Referenced by format_operator_parts(), format_procedure_parts(), format_type_extended(), getObjectIdentityParts(), getOpFamilyIdentity(), and getRelationIdentity().

3314 {
3315  if (isTempNamespace(nspid))
3316  return "pg_temp";
3317  else
3318  return get_namespace_name(nspid);
3319 }
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3289
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3156

◆ get_negator()

Oid get_negator ( Oid  opno)

Definition at line 1477 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1().

Referenced by eqsel_internal(), get_op_btree_interpretation(), lookup_proof_cache(), match_clause_to_partition_key(), negate_clause(), neqjoinsel(), operator_same_subexprs_proof(), patternsel(), and scalararraysel().

1478 {
1479  HeapTuple tp;
1480 
1482  if (HeapTupleIsValid(tp))
1483  {
1485  Oid result;
1486 
1487  result = optup->oprnegate;
1488  ReleaseSysCache(tp);
1489  return result;
1490  }
1491  else
1492  return InvalidOid;
1493 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_op_btree_interpretation()

List* get_op_btree_interpretation ( Oid  opno)

Definition at line 599 of file lsyscache.c.

References AMOPOPID, Assert, BTEqualStrategyNumber, get_negator(), GETSTRUCT, i, lappend(), catclist::members, catclist::n_members, NIL, ObjectIdGetDatum, OidIsValid, OpBtreeInterpretation::opfamily_id, OpBtreeInterpretation::oplefttype, OpBtreeInterpretation::oprighttype, palloc(), ReleaseSysCacheList, ROWCOMPARE_NE, SearchSysCacheList1, OpBtreeInterpretation::strategy, and catctup::tuple.

Referenced by lookup_proof_cache(), and make_row_comparison_op().

600 {
601  List *result = NIL;
602  OpBtreeInterpretation *thisresult;
603  CatCList *catlist;
604  int i;
605 
606  /*
607  * Find all the pg_amop entries containing the operator.
608  */
610 
611  for (i = 0; i < catlist->n_members; i++)
612  {
613  HeapTuple op_tuple = &catlist->members[i]->tuple;
614  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
615  StrategyNumber op_strategy;
616 
617  /* must be btree */
618  if (op_form->amopmethod != BTREE_AM_OID)
619  continue;
620 
621  /* Get the operator's btree strategy number */
622  op_strategy = (StrategyNumber) op_form->amopstrategy;
623  Assert(op_strategy >= 1 && op_strategy <= 5);
624 
625  thisresult = (OpBtreeInterpretation *)
626  palloc(sizeof(OpBtreeInterpretation));
627  thisresult->opfamily_id = op_form->amopfamily;
628  thisresult->strategy = op_strategy;
629  thisresult->oplefttype = op_form->amoplefttype;
630  thisresult->oprighttype = op_form->amoprighttype;
631  result = lappend(result, thisresult);
632  }
633 
634  ReleaseSysCacheList(catlist);
635 
636  /*
637  * If we didn't find any btree opfamily containing the operator, perhaps
638  * it is a <> operator. See if it has a negator that is in an opfamily.
639  */
640  if (result == NIL)
641  {
642  Oid op_negator = get_negator(opno);
643 
644  if (OidIsValid(op_negator))
645  {
646  catlist = SearchSysCacheList1(AMOPOPID,
647  ObjectIdGetDatum(op_negator));
648 
649  for (i = 0; i < catlist->n_members; i++)
650  {
651  HeapTuple op_tuple = &catlist->members[i]->tuple;
652  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
653  StrategyNumber op_strategy;
654 
655  /* must be btree */
656  if (op_form->amopmethod != BTREE_AM_OID)
657  continue;
658 
659  /* Get the operator's btree strategy number */
660  op_strategy = (StrategyNumber) op_form->amopstrategy;
661  Assert(op_strategy >= 1 && op_strategy <= 5);
662 
663  /* Only consider negators that are = */
664  if (op_strategy != BTEqualStrategyNumber)
665  continue;
666 
667  /* OK, report it with "strategy" ROWCOMPARE_NE */
668  thisresult = (OpBtreeInterpretation *)
669  palloc(sizeof(OpBtreeInterpretation));
670  thisresult->opfamily_id = op_form->amopfamily;
671  thisresult->strategy = ROWCOMPARE_NE;
672  thisresult->oplefttype = op_form->amoplefttype;
673  thisresult->oprighttype = op_form->amoprighttype;
674  result = lappend(result, thisresult);
675  }
676 
677  ReleaseSysCacheList(catlist);
678  }
679  }
680 
681  return result;
682 }
#define NIL
Definition: pg_list.h:65
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
uint16 StrategyNumber
Definition: stratnum.h:22
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:698
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
List * lappend(List *list, void *datum)
Definition: list.c:321
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
#define Assert(condition)
Definition: c.h:792
void * palloc(Size size)
Definition: mcxt.c:950
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121
Oid get_negator(Oid opno)
Definition: lsyscache.c:1477
Definition: pg_list.h:50
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_op_hash_functions()

bool get_op_hash_functions ( Oid  opno,
RegProcedure lhs_procno,
RegProcedure rhs_procno 
)

Definition at line 508 of file lsyscache.c.

References AMOPOPID, get_opfamily_proc(), GETSTRUCT, HASHSTANDARD_PROC, HTEqualStrategyNumber, i, InvalidOid, catclist::members, catclist::n_members, ObjectIdGetDatum, OidIsValid, ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by ExecHashTableCreate(), ExecInitSubPlan(), and execTuplesHashPrepare().

510 {
511  bool result = false;
512  CatCList *catlist;
513  int i;
514 
515  /* Ensure output args are initialized on failure */
516  if (lhs_procno)
517  *lhs_procno = InvalidOid;
518  if (rhs_procno)
519  *rhs_procno = InvalidOid;
520 
521  /*
522  * Search pg_amop to see if the target operator is registered as the "="
523  * operator of any hash opfamily. If the operator is registered in
524  * multiple opfamilies, assume we can use any one.
525  */
527 
528  for (i = 0; i < catlist->n_members; i++)
529  {
530  HeapTuple tuple = &catlist->members[i]->tuple;
531  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
532 
533  if (aform->amopmethod == HASH_AM_OID &&
534  aform->amopstrategy == HTEqualStrategyNumber)
535  {
536  /*
537  * Get the matching support function(s). Failure probably
538  * shouldn't happen --- it implies a bogus opfamily --- but
539  * continue looking if so.
540  */
541  if (lhs_procno)
542  {
543  *lhs_procno = get_opfamily_proc(aform->amopfamily,
544  aform->amoplefttype,
545  aform->amoplefttype,
547  if (!OidIsValid(*lhs_procno))
548  continue;
549  /* Matching LHS found, done if caller doesn't want RHS */
550  if (!rhs_procno)
551  {
552  result = true;
553  break;
554  }
555  /* Only one lookup needed if given operator is single-type */
556  if (aform->amoplefttype == aform->amoprighttype)
557  {
558  *rhs_procno = *lhs_procno;
559  result = true;
560  break;
561  }
562  }
563  if (rhs_procno)
564  {
565  *rhs_procno = get_opfamily_proc(aform->amopfamily,
566  aform->amoprighttype,
567  aform->amoprighttype,
569  if (!OidIsValid(*rhs_procno))
570  {
571  /* Forget any LHS function from this opfamily */
572  if (lhs_procno)
573  *lhs_procno = InvalidOid;
574  continue;
575  }
576  /* Matching RHS found, so done */
577  result = true;
578  break;
579  }
580  }
581  }
582 
583  ReleaseSysCacheList(catlist);
584 
585  return result;
586 }
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define OidIsValid(objectId)
Definition: c.h:698
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define HTEqualStrategyNumber
Definition: stratnum.h:41
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define HASHSTANDARD_PROC
Definition: hash.h:353
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
#define InvalidOid
Definition: postgres_ext.h:36
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
Definition: lsyscache.c:794
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121

◆ get_op_opfamily_properties()

void get_op_opfamily_properties ( Oid  opno,
Oid  opfamily,
bool  ordering_op,
int *  strategy,
Oid lefttype,
Oid righttype 
)

Definition at line 134 of file lsyscache.c.

References AMOPOPID, CharGetDatum, elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache3().

Referenced by ExecIndexBuildScanKeys(), ExecInitExprRec(), expand_indexqual_rowcompare(), gen_prune_steps_from_opexps(), gincost_pattern(), match_clause_to_partition_key(), mergejoinscansel(), and MJExamineQuals().

138 {
139  HeapTuple tp;
140  Form_pg_amop amop_tup;
141 
143  ObjectIdGetDatum(opno),
144  CharGetDatum(ordering_op ? AMOP_ORDER : AMOP_SEARCH),
145  ObjectIdGetDatum(opfamily));
146  if (!HeapTupleIsValid(tp))
147  elog(ERROR, "operator %u is not a member of opfamily %u",
148  opno, opfamily);
149  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
150  *strategy = amop_tup->amopstrategy;
151  *lefttype = amop_tup->amoplefttype;
152  *righttype = amop_tup->amoprighttype;
153  ReleaseSysCache(tp);
154 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1149
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:416
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
#define elog(elevel,...)
Definition: elog.h:228

◆ get_op_opfamily_sortfamily()

Oid get_op_opfamily_sortfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 106 of file lsyscache.c.

References AMOPOPID, CharGetDatum, GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache3().

Referenced by match_clause_to_ordering_op().

107 {
108  HeapTuple tp;
109  Form_pg_amop amop_tup;
110  Oid result;
111 
113  ObjectIdGetDatum(opno),
114  CharGetDatum(AMOP_ORDER),
115  ObjectIdGetDatum(opfamily));
116  if (!HeapTupleIsValid(tp))
117  return InvalidOid;
118  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
119  result = amop_tup->amopsortfamily;
120  ReleaseSysCache(tp);
121  return result;
122 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1149
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:416
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88

◆ get_op_opfamily_strategy()

int get_op_opfamily_strategy ( Oid  opno,
Oid  opfamily 
)

Definition at line 81 of file lsyscache.c.

References AMOPOPID, CharGetDatum, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache3().

Referenced by btcostestimate(), ComputeIndexAttrs(), expand_indexqual_rowcompare(), get_actual_variable_range(), match_rowcompare_to_indexcol(), and RelationGetExclusionInfo().

82 {
83  HeapTuple tp;
84  Form_pg_amop amop_tup;
85  int result;
86 
88  ObjectIdGetDatum(opno),
89  CharGetDatum(AMOP_SEARCH),
90  ObjectIdGetDatum(opfamily));
91  if (!HeapTupleIsValid(tp))
92  return 0;
93  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
94  result = amop_tup->amopstrategy;
95  ReleaseSysCache(tp);
96  return result;
97 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1149
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:416
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88

◆ get_op_rettype()

Oid get_op_rettype ( Oid  opno)

Definition at line 1277 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1().

Referenced by gistvalidate(), spgproperty(), and spgvalidate().

1278 {
1279  HeapTuple tp;
1280 
1282  if (HeapTupleIsValid(tp))
1283  {
1285  Oid result;
1286 
1287  result = optup->oprresult;
1288  ReleaseSysCache(tp);
1289  return result;
1290  }
1291  else
1292  return InvalidOid;
1293 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_opclass_family()

Oid get_opclass_family ( Oid  opclass)

Definition at line 1156 of file lsyscache.c.

References CLAOID, elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1().

Referenced by build_replindex_scan_key(), ComputeIndexAttrs(), DefineIndex(), infer_collation_opclass_match(), load_rangetype_info(), and lookup_type_cache().

1157 {
1158  HeapTuple tp;
1159  Form_pg_opclass cla_tup;
1160  Oid result;
1161 
1162  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1163  if (!HeapTupleIsValid(tp))
1164  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1165  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1166 
1167  result = cla_tup->opcfamily;
1168  ReleaseSysCache(tp);
1169  return result;
1170 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83

◆ get_opclass_input_type()

Oid get_opclass_input_type ( Oid  opclass)

Definition at line 1178 of file lsyscache.c.

References CLAOID, elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1().

Referenced by btadjustmembers(), build_replindex_scan_key(), CheckIndexCompatible(), findRangeSubOpclass(), get_rule_expr(), hashadjustmembers(), infer_collation_opclass_match(), load_rangetype_info(), and lookup_type_cache().

1179 {
1180  HeapTuple tp;
1181  Form_pg_opclass cla_tup;
1182  Oid result;
1183 
1184  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1185  if (!HeapTupleIsValid(tp))
1186  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1187  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1188 
1189  result = cla_tup->opcintype;
1190  ReleaseSysCache(tp);
1191  return result;
1192 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:228
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83

◆ get_opclass_opfamily_and_input_type()

bool get_opclass_opfamily_and_input_type ( Oid  opclass,
Oid opfamily,
Oid opcintype 
)

Definition at line 1201 of file lsyscache.c.

References CLAOID, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1().

Referenced by DefineIndex(), gistproperty(), and spgproperty().

1202 {
1203  HeapTuple tp;
1204  Form_pg_opclass cla_tup;
1205 
1206  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1207  if (!HeapTupleIsValid(tp))
1208  return false;
1209 
1210  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1211 
1212  *opfamily = cla_tup->opcfamily;
1213  *opcintype = cla_tup->opcintype;
1214 
1215  ReleaseSysCache(tp);
1216 
1217  return true;
1218 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1229 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1().

Referenced by _bt_compare_scankey_args(), _bt_find_extreme_element(), AlterOpFamilyAdd(), build_pertrans_for_aggref(), build_replindex_scan_key(), BuildSpeculativeIndexInfo(), check_functions_in_node(), ComputeIndexAttrs(), contain_leaked_vars_walker(), cost_qual_eval_walker(), DefineOpClass(), eqjoinsel(), ExecInitSubPlan(), execTuplesHashPrepare(), execTuplesMatchPrepare(), generic_restriction_selectivity(), get_expr_result_type(), get_variable_range(), inclusion_get_strategy_procinfo(), inet_mcv_join_sel(), lookup_type_cache(), make_partition_op_expr(), match_pattern_prefix(), mcv_get_match_bitmap(), minmax_get_strategy_procinfo(), mode_final(), networkjoinsel_semi(), networksel(), op_strict(), op_volatile(), OperatorLookup(), patternsel_common(), prefix_selectivity(), preparePresortedCols(), RelationGetExclusionInfo(), ri_HashCompareOp(), scalarineqsel(), select_equality_operator(), set_opfuncid(), set_sa_opfuncid(), statext_is_compatible_clause_internal(), std_typanalyze(), and var_eq_const().

1230 {
1231  HeapTuple tp;
1232 
1234  if (HeapTupleIsValid(tp))
1235  {
1237  RegProcedure result;
1238 
1239  result = optup->oprcode;
1240  ReleaseSysCache(tp);
1241  return result;
1242  }
1243  else
1244  return (RegProcedure) InvalidOid;
1245 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:573
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_opfamily_member()

Oid get_opfamily_member ( Oid  opfamily,
Oid  lefttype,
Oid  righttype,
int16  strategy 
)

Definition at line 164 of file lsyscache.c.

References AMOPSTRATEGY, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache4().

Referenced by _bt_compare_scankey_args(), _bt_find_extreme_element(), ATAddForeignKeyConstraint(), btcostestimate(), build_replindex_scan_key(), BuildSpeculativeIndexInfo(), create_indexscan_plan(), DefineIndex(), expand_indexqual_rowcompare(), get_compatible_hash_operators(), get_equality_op_for_ordering_op(), get_ordering_op_for_equality_op(), get_partition_operator(), get_relation_info(), lookup_proof_cache(), lookup_type_cache(), make_pathkey_from_sortinfo(), make_unique_from_pathkeys(), match_network_subset(), mergejoinscansel(), prepare_sort_from_pathkeys(), refresh_by_match_merge(), and select_equality_operator().

166 {
167  HeapTuple tp;
168  Form_pg_amop amop_tup;
169  Oid result;
170 
172  ObjectIdGetDatum(opfamily),
173  ObjectIdGetDatum(lefttype),
174  ObjectIdGetDatum(righttype),
175  Int16GetDatum(strategy));
176  if (!HeapTupleIsValid(tp))
177  return InvalidOid;
178  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
179  result = amop_tup->amopopr;
180  ReleaseSysCache(tp);
181  return result;
182 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1160
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88

◆ get_opfamily_proc()

Oid get_opfamily_proc ( Oid  opfamily,
Oid  lefttype,
Oid  righttype,
int16  procnum 
)

Definition at line 794 of file lsyscache.c.

References AMPROCNUM, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache4().

Referenced by _bt_allequalimage(), _bt_first(), _bt_sort_array_elements(), _hash_datum2hashkey_type(), ExecIndexBuildScanKeys(), ExecInitExprRec(), FinishSortSupportFunction(), get_op_hash_functions(), gincost_pattern(), gistvalidate(), load_rangetype_info(), lookup_type_cache(), match_clause_to_partition_key(), MJExamineQuals(), PrepareSortSupportFromGistIndexRel(), and RelationBuildPartitionKey().

795 {
796  HeapTuple tp;
797  Form_pg_amproc amproc_tup;
798  RegProcedure result;
799 
801  ObjectIdGetDatum(opfamily),
802  ObjectIdGetDatum(lefttype),
803  ObjectIdGetDatum(righttype),
804  Int16GetDatum(procnum));
805  if (!HeapTupleIsValid(tp))
806  return InvalidOid;
807  amproc_tup = (Form_pg_amproc) GETSTRUCT(tp);
808  result = amproc_tup->amproc;
809  ReleaseSysCache(tp);
810  return result;
811 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
FormData_pg_amproc * Form_pg_amproc
Definition: pg_amproc.h:68
regproc RegProcedure
Definition: c.h:573
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1160
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_opname()

char* get_opname ( Oid  opno)

Definition at line 1254 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, OPEROID, pstrdup(), ReleaseSysCache(), and SearchSysCache1().

Referenced by AlterOpFamilyAdd(), DefineOpClass(), print_expr(), and show_sortorder_options().

1255 {
1256  HeapTuple tp;
1257 
1259  if (HeapTupleIsValid(tp))
1260  {
1262  char *result;
1263 
1264  result = pstrdup(NameStr(optup->oprname));
1265  ReleaseSysCache(tp);
1266  return result;
1267  }
1268  else
1269  return NULL;
1270 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83
#define NameStr(name)
Definition: c.h:669

◆ get_oprjoin()

RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1525 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1().

Referenced by join_selectivity(), and scalararraysel().

1526 {
1527  HeapTuple tp;
1528 
1530  if (HeapTupleIsValid(tp))
1531  {
1533  RegProcedure result;
1534 
1535  result = optup->oprjoin;
1536  ReleaseSysCache(tp);
1537  return result;
1538  }
1539  else
1540  return (RegProcedure) InvalidOid;
1541 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:573
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1501 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1().

Referenced by clauselist_selectivity_ext(), dependency_is_compatible_clause(), restriction_selectivity(), scalararraysel(), and statext_is_compatible_clause_internal().

1502 {
1503  HeapTuple tp;
1504 
1506  if (HeapTupleIsValid(tp))
1507  {
1509  RegProcedure result;
1510 
1511  result = optup->oprrest;
1512  ReleaseSysCache(tp);
1513  return result;
1514  }
1515  else
1516  return (RegProcedure) InvalidOid;
1517 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:573
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_ordering_op_for_equality_op()

Oid get_ordering_op_for_equality_op ( Oid  opno,
bool  use_lhs_type 
)

Definition at line 303 of file lsyscache.c.

References AMOPOPID, BTEqualStrategyNumber, BTLessStrategyNumber, get_opfamily_member(), GETSTRUCT, i, InvalidOid, catclist::members, catclist::n_members, ObjectIdGetDatum, OidIsValid, ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by create_unique_plan().

304 {
305  Oid result = InvalidOid;
306  CatCList *catlist;
307  int i;
308 
309  /*
310  * Search pg_amop to see if the target operator is registered as the "="
311  * operator of any btree opfamily.
312  */
314 
315  for (i = 0; i < catlist->n_members; i++)
316  {
317  HeapTuple tuple = &catlist->members[i]->tuple;
318  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
319 
320  /* must be btree */
321  if (aform->amopmethod != BTREE_AM_OID)
322  continue;
323 
324  if (aform->amopstrategy == BTEqualStrategyNumber)
325  {
326  /* Found a suitable opfamily, get matching ordering operator */
327  Oid typid;
328 
329  typid = use_lhs_type ? aform->amoplefttype : aform->amoprighttype;
330  result = get_opfamily_member(aform->amopfamily,
331  typid, typid,
333  if (OidIsValid(result))
334  break;
335  /* failure probably shouldn't happen, but keep looking if so */
336  }
337  }
338 
339  ReleaseSysCacheList(catlist);
340 
341  return result;
342 }
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:698
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:164
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
#define InvalidOid
Definition: postgres_ext.h:36
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121
#define BTLessStrategyNumber
Definition: stratnum.h:29
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_ordering_op_properties()

bool get_ordering_op_properties ( Oid  opno,
Oid opfamily,
Oid opcintype,
int16 strategy 
)

Definition at line 205 of file lsyscache.c.

References AMOPOPID, BTGreaterStrategyNumber, BTLessStrategyNumber, GETSTRUCT, i, InvalidOid, catclist::members, catclist::n_members, ObjectIdGetDatum, ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by build_expression_pathkey(), get_equality_op_for_ordering_op(), get_relation_info(), make_pathkey_from_sortop(), PrepareSortSupportFromOrderingOp(), and transformWindowDefinitions().

207 {
208  bool result = false;
209  CatCList *catlist;
210  int i;
211 
212  /* ensure outputs are initialized on failure */
213  *opfamily = InvalidOid;
214  *opcintype = InvalidOid;
215  *strategy = 0;
216 
217  /*
218  * Search pg_amop to see if the target operator is registered as the "<"
219  * or ">" operator of any btree opfamily.
220  */
222 
223  for (i = 0; i < catlist->n_members; i++)
224  {
225  HeapTuple tuple = &catlist->members[i]->tuple;
226  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
227 
228  /* must be btree */
229  if (aform->amopmethod != BTREE_AM_OID)
230  continue;
231 
232  if (aform->amopstrategy == BTLessStrategyNumber ||
233  aform->amopstrategy == BTGreaterStrategyNumber)
234  {
235  /* Found it ... should have consistent input types */
236  if (aform->amoplefttype == aform->amoprighttype)
237  {
238  /* Found a suitable opfamily, return info */
239  *opfamily = aform->amopfamily;
240  *opcintype = aform->amoplefttype;
241  *strategy = aform->amopstrategy;
242  result = true;
243  break;
244  }
245  }
246  }
247 
248  ReleaseSysCacheList(catlist);
249 
250  return result;
251 }
int n_members
Definition: catcache.h:176
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
#define InvalidOid
Definition: postgres_ext.h:36
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121
#define BTLessStrategyNumber
Definition: stratnum.h:29

◆ get_promoted_array_type()

Oid get_promoted_array_type ( Oid  typid)

Definition at line 2731 of file lsyscache.c.

References get_array_type(), get_element_type(), InvalidOid, and OidIsValid.

Referenced by build_subplan(), and exprType().

2732 {
2733  Oid array_type = get_array_type(typid);
2734 
2735  if (OidIsValid(array_type))
2736  return array_type;
2737  if (OidIsValid(get_element_type(typid)))
2738  return typid;
2739  return InvalidOid;
2740 }
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2679
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2707
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:698
#define InvalidOid
Definition: postgres_ext.h:36

◆ get_range_collation()

Oid get_range_collation ( Oid  rangeOid)

Definition at line 3356 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, RANGETYPE, ReleaseSysCache(), and SearchSysCache1().

Referenced by CheckAttributeType().

3357 {
3358  HeapTuple tp;
3359 
3360  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3361  if (HeapTupleIsValid(tp))
3362  {
3363  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3364  Oid result;
3365 
3366  result = rngtup->rngcollation;
3367  ReleaseSysCache(tp);
3368  return result;
3369  }
3370  else
3371  return InvalidOid;
3372 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:58
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

Definition at line 3381 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, RANGETYPE, ReleaseSysCache(), and SearchSysCache1().

Referenced by enforce_generic_type_consistency(), and resolve_anymultirange_from_others().

3382 {
3383  HeapTuple tp;
3384 
3385  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3386  if (HeapTupleIsValid(tp))
3387  {
3388  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3389  Oid result;
3390 
3391  result = rngtup->rngmultitypid;
3392  ReleaseSysCache(tp);
3393  return result;
3394  }
3395  else
3396  return InvalidOid;
3397 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:58
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_range_subtype()

Oid get_range_subtype ( Oid  rangeOid)

Definition at line 3330 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, RANGETYPE, ReleaseSysCache(), and SearchSysCache1().

Referenced by check_generic_type_consistency(), CheckAttributeType(), enforce_generic_type_consistency(), GetTypeCollations(), and resolve_anyelement_from_others().

3331 {
3332  HeapTuple tp;
3333 
3334  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3335  if (HeapTupleIsValid(tp))
3336  {
3337  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3338  Oid result;
3339 
3340  result = rngtup->rngsubtype;
3341  ReleaseSysCache(tp);
3342  return result;
3343  }
3344  else
3345  return InvalidOid;
3346 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:58
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_rel_name()

char* get_rel_name ( Oid  relid)

Definition at line 1872 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), RELOID, and SearchSysCache1().

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_tlist(), AlterSubscription_refresh(), AlterTableNamespace(), ApplyWorkerMain(), ATExecChangeOwner(), check_enable_rls(), check_new_partition_bound(), conversion_error_callback(), convert_column_name(), CreateTrigger(), DefineRelation(), do_autovacuum(), do_collation_version_check(), EnableDisableRule(), exec_object_restorecon(), ExecCheckRTPerms(), execCurrentOf(), expand_col_privileges(), explain_get_index_name(), ExplainTargetRel(), get_relation_constraint_attnos(), get_relation_constraint_oid(), get_relation_name(), get_relation_policy_oid(), get_rewrite_oid(), get_trigger_oid(), gincost_pattern(), has_sequence_privilege_id(), has_sequence_privilege_id_id(), has_sequence_privilege_name_id(), heap_truncate_check_FKs(), InsertRule(), LockTableRecurse(), LockViewRecurse_walker(), makeWholeRowVar(), map_sql_schema_to_xmlschema_types(), perform_work_item(), pg_attribute_noreturn(), pg_decode_change(), pg_extension_config_dump(), pg_get_expr(), pg_get_expr_ext(), pg_prewarm(), pg_sequence_parameters(), postgresExplainForeignScan(), process_owned_by(), reindex_index(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), RememberClusterOnForRebuilding(), RememberReplicaIdentityForRebuilding(), RenameConstraintById(), satisfies_hash_partition(), set_rtable_names(), show_modifytable_info(), table_to_xml_internal(), and transformAlterTableStmt().

1873 {
1874  HeapTuple tp;
1875 
1876  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1877  if (HeapTupleIsValid(tp))
1878  {
1879  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1880  char *result;
1881 
1882  result = pstrdup(NameStr(reltup->relname));
1883  ReleaseSysCache(tp);
1884  return result;
1885  }
1886  else
1887  return NULL;
1888 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
#define NameStr(name)
Definition: c.h:669

◆ get_rel_namespace()

Oid get_rel_namespace ( Oid  relid)

Definition at line 1896 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), RELOID, and SearchSysCache1().

Referenced by AlterSubscription_refresh(), do_autovacuum(), exec_object_restorecon(), ExecCheckXactReadOnly(), perform_work_item(), pg_decode_change(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), sepgsql_relation_drop(), and transformAlterTableStmt().

1897 {
1898  HeapTuple tp;
1899 
1900  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1901  if (HeapTupleIsValid(tp))
1902  {
1903  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1904  Oid result;
1905 
1906  result = reltup->relnamespace;
1907  ReleaseSysCache(tp);
1908  return result;
1909  }
1910  else
1911  return InvalidOid;
1912 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153

◆ get_rel_persistence()

char get_rel_persistence ( Oid  relid)

Definition at line 2022 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), RELOID, and SearchSysCache1().

Referenced by DefineIndex(), index_drop(), RangeVarCallbackForLockTable(), ReindexIndex(), ReindexMultipleInternal(), ReindexTable(), RemoveRelations(), and set_rel_consider_parallel().

2023 {
2024  HeapTuple tp;
2025  Form_pg_class reltup;
2026  char result;
2027 
2028  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2029  if (!HeapTupleIsValid(tp))
2030  elog(ERROR, "cache lookup failed for relation %u", relid);
2031  reltup = (Form_pg_class) GETSTRUCT(tp);
2032  result = reltup->relpersistence;
2033  ReleaseSysCache(tp);
2034 
2035  return result;
2036 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
#define elog(elevel,...)
Definition: elog.h:228

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

Definition at line 1971 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), RELOID, and SearchSysCache1().

Referenced by check_rel_can_be_partition(), get_partition_qual_relid(), get_rel_sync_entry(), and index_concurrently_swap().

1972 {
1973  HeapTuple tp;
1974 
1975  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1976  if (HeapTupleIsValid(tp))
1977  {
1978  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1979  bool result;
1980 
1981  result = reltup->relispartition;
1982  ReleaseSysCache(tp);
1983  return result;
1984  }
1985  else
1986  return false;
1987 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153

◆ get_rel_relkind()

char get_rel_relkind ( Oid  relid)

Definition at line 1947 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), RELOID, and SearchSysCache1().

Referenced by AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), ATExecAlterColumnType(), ATExecChangeOwner(), check_rel_can_be_partition(), check_relation_privileges(), CreateSubscription(), CreateTrigger(), doDeletion(), EnableDisableRule(), exec_object_restorecon(), ExecCheckRTPerms(), get_object_type(), get_rel_sync_entry(), getOwnedSequences_internal(), GetPublicationRelations(), has_sequence_privilege_id(), has_sequence_privilege_id_id(), has_sequence_privilege_id_name(), has_sequence_privilege_name(), has_sequence_privilege_name_id(), has_sequence_privilege_name_name(), LockTableCommand(), pg_get_serial_sequence(), pg_get_triggerdef_worker(), pg_partition_tree(), ProcessUtilitySlow(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForDropRelation(), RangeVarCallbackForLockTable(), RangeVarCallbackForPolicy(), RangeVarCallbackForReindexIndex(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackOwnsRelation(), RangeVarCallbackOwnsTable(), RangeVarGetAndCheckCreationNamespace(), ReindexIndex(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), ReindexTable(), RelationBuildPartitionDesc(), RemoveRelations(), renameatt_check(), RenameType(), sepgsql_attribute_drop(), sepgsql_attribute_post_create(), sepgsql_attribute_relabel(), sepgsql_attribute_setattr(), sepgsql_relation_drop(), sepgsql_relation_relabel(), sepgsql_relation_setattr(), and sepgsql_relation_truncate().

1948 {
1949  HeapTuple tp;
1950 
1951  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1952  if (HeapTupleIsValid(tp))
1953  {
1954  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1955  char result;
1956 
1957  result = reltup->relkind;
1958  ReleaseSysCache(tp);
1959  return result;
1960  }
1961  else
1962  return '\0';
1963 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153

◆ get_rel_tablespace()

Oid get_rel_tablespace ( Oid  relid)

Definition at line 1998 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), RELOID, and SearchSysCache1().

Referenced by DefineRelation(), pg_get_constraintdef_worker(), and pg_get_indexdef_worker().

1999 {
2000  HeapTuple tp;
2001 
2002  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2003  if (HeapTupleIsValid(tp))
2004  {
2005  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2006  Oid result;
2007 
2008  result = reltup->reltablespace;
2009  ReleaseSysCache(tp);
2010  return result;
2011  }
2012  else
2013  return InvalidOid;
2014 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153

◆ get_rel_type_id()

Oid get_rel_type_id ( Oid  relid)

Definition at line 1923 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), RELOID, and SearchSysCache1().

Referenced by makeWholeRowVar(), plpgsql_parse_cwordrowtype(), and plpgsql_parse_wordrowtype().

1924 {
1925  HeapTuple tp;
1926 
1927  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1928  if (HeapTupleIsValid(tp))
1929  {
1930  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1931  Oid result;
1932 
1933  result = reltup->reltype;
1934  ReleaseSysCache(tp);
1935  return result;
1936  }
1937  else
1938  return InvalidOid;
1939 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153

◆ get_relname_relid()

◆ get_transform_fromsql()

Oid get_transform_fromsql ( Oid  typid,
Oid  langid,
List trftypes 
)

Definition at line 2042 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, list_member_oid(), ReleaseSysCache(), SearchSysCache2(), and TRFTYPELANG.

Referenced by plperl_call_perl_func(), plperl_hash_from_tuple(), plperl_ref_from_pg_array(), and PLy_input_setup_func().

2043 {
2044  HeapTuple tup;
2045 
2046  if (!list_member_oid(trftypes, typid))
2047  return InvalidOid;
2048 
2049  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
2050  if (HeapTupleIsValid(tup))
2051  {
2052  Oid funcid;
2053 
2054  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2055  ReleaseSysCache(tup);
2056  return funcid;
2057  }
2058  else
2059  return InvalidOid;
2060 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:674
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138

◆ get_transform_tosql()

Oid get_transform_tosql ( Oid  typid,
Oid  langid,
List trftypes 
)

Definition at line 2063 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, list_member_oid(), ReleaseSysCache(), SearchSysCache2(), and TRFTYPELANG.

Referenced by plperl_sv_to_datum(), and PLy_output_setup_func().

2064 {
2065  HeapTuple tup;
2066 
2067  if (!list_member_oid(trftypes, typid))
2068  return InvalidOid;
2069 
2070  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
2071  if (HeapTupleIsValid(tup))
2072  {
2073  Oid funcid;
2074 
2075  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
2076  ReleaseSysCache(tup);
2077  return funcid;
2078  }
2079  else
2080  return InvalidOid;
2081 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:674
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138

◆ get_typ_typrelid()

Oid get_typ_typrelid ( Oid  typid)

Definition at line 2651 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by ATPostAlterTypeCleanup(), CheckAttributeType(), find_expr_references_walker(), and processIndirection().

2652 {
2653  HeapTuple tp;
2654 
2656  if (HeapTupleIsValid(tp))
2657  {
2658  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2659  Oid result;
2660 
2661  result = typtup->typrelid;
2662  ReleaseSysCache(tp);
2663  return result;
2664  }
2665  else
2666  return InvalidOid;
2667 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typavgwidth()

int32 get_typavgwidth ( Oid  typid,
int32  typmod 
)

Definition at line 2498 of file lsyscache.c.

References get_typlen(), and type_maximum_size().

Referenced by create_one_window_path(), find_placeholder_info(), get_agg_clause_costs(), get_rel_data_width(), set_append_rel_size(), set_pathtarget_cost_width(), and set_rel_width().

2499 {
2500  int typlen = get_typlen(typid);
2501  int32 maxwidth;
2502 
2503  /*
2504  * Easy if it's a fixed-width type
2505  */
2506  if (typlen > 0)
2507  return typlen;
2508 
2509  /*
2510  * type_maximum_size knows the encoding of typmod for some datatypes;
2511  * don't duplicate that knowledge here.
2512  */
2513  maxwidth = type_maximum_size(typid, typmod);
2514  if (maxwidth > 0)
2515  {
2516  /*
2517  * For BPCHAR, the max width is also the only width. Otherwise we
2518  * need to guess about the typical data width given the max. A sliding
2519  * scale for percentage of max width seems reasonable.
2520  */
2521  if (typid == BPCHAROID)
2522  return maxwidth;
2523  if (maxwidth <= 32)
2524  return maxwidth; /* assume full width */
2525  if (maxwidth < 1000)
2526  return 32 + (maxwidth - 32) / 2; /* assume 50% */
2527 
2528  /*
2529  * Beyond 1000, assume we're looking at something like
2530  * "varchar(10000)" where the limit isn't actually reached often, and
2531  * use a fixed estimate.
2532  */
2533  return 32 + (1000 - 32) / 2;
2534  }
2535 
2536  /*
2537  * Oops, we have no idea ... wild guess time.
2538  */
2539  return 32;
2540 }
signed int int32
Definition: c.h:417
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:408
int16 get_typlen(Oid typid)
Definition: lsyscache.c:2117

◆ get_typbyval()

bool get_typbyval ( Oid  typid)

Definition at line 2142 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

2143 {
2144  HeapTuple tp;
2145 
2147  if (HeapTupleIsValid(tp))
2148  {
2149  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2150  bool result;
2151 
2152  result = typtup->typbyval;
2153  ReleaseSysCache(tp);
2154  return result;
2155  }
2156  else
2157  return false;
2158 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typcollation()

Oid get_typcollation ( Oid  typid)

Definition at line 2976 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by assign_collations_walker(), ATExecAddColumn(), DefineRange(), domainAddConstraint(), fixed_paramref_hook(), get_cast_hashentry(), get_collation(), get_const_collation(), get_from_clause_coldeflist(), GetColumnDefCollation(), paramlist_param_ref(), resolve_polymorphic_tupdesc(), show_sortorder_options(), sql_fn_make_param(), transformAssignmentSubscripts(), transformRangeTableFunc(), type_is_collatable(), variable_coerce_param_hook(), and variable_paramref_hook().

2977 {
2978  HeapTuple tp;
2979 
2981  if (HeapTupleIsValid(tp))
2982  {
2983  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2984  Oid result;
2985 
2986  result = typtup->typcollation;
2987  ReleaseSysCache(tp);
2988  return result;
2989  }
2990  else
2991  return InvalidOid;
2992 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typdefault()

Node* get_typdefault ( Oid  typid)

Definition at line 2368 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, getTypeIOParam(), HeapTupleIsValid, makeConst(), ObjectIdGetDatum, OidInputFunctionCall(), pfree(), ReleaseSysCache(), SearchSysCache1(), stringToNode(), SysCacheGetAttr(), TextDatumGetCString, generate_unaccent_rules::type, and TYPEOID.

Referenced by build_column_default().

2369 {
2370  HeapTuple typeTuple;
2372  Datum datum;
2373  bool isNull;
2374  Node *expr;
2375 
2376  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2377  if (!HeapTupleIsValid(typeTuple))
2378  elog(ERROR, "cache lookup failed for type %u", typid);
2379  type = (Form_pg_type) GETSTRUCT(typeTuple);
2380 
2381  /*
2382  * typdefault and typdefaultbin are potentially null, so don't try to
2383  * access 'em as struct fields. Must do it the hard way with
2384  * SysCacheGetAttr.
2385  */
2386  datum = SysCacheGetAttr(TYPEOID,
2387  typeTuple,
2388  Anum_pg_type_typdefaultbin,
2389  &isNull);
2390 
2391  if (!isNull)
2392  {
2393  /* We have an expression default */
2394  expr = stringToNode(TextDatumGetCString(datum));
2395  }
2396  else
2397  {
2398  /* Perhaps we have a plain literal default */
2399  datum = SysCacheGetAttr(TYPEOID,
2400  typeTuple,
2401  Anum_pg_type_typdefault,
2402  &isNull);
2403 
2404  if (!isNull)
2405  {
2406  char *strDefaultVal;
2407 
2408  /* Convert text datum to C string */
2409  strDefaultVal = TextDatumGetCString(datum);
2410  /* Convert C string to a value of the given type */
2411  datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2412  getTypeIOParam(typeTuple), -1);
2413  /* Build a Const node containing the value */
2414  expr = (Node *) makeConst(typid,
2415  -1,
2416  type->typcollation,
2417  type->typlen,
2418  datum,
2419  false,
2420  type->typbyval);
2421  pfree(strDefaultVal);
2422  }
2423  else
2424  {
2425  /* No default */
2426  expr = NULL;
2427  }
2428  }
2429 
2430  ReleaseSysCache(typeTuple);
2431 
2432  return expr;
2433 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
Definition: nodes.h:528
void * stringToNode(const char *str)
Definition: read.c:89
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:299
void pfree(void *pointer)
Definition: mcxt.c:1057
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
#define TextDatumGetCString(d)
Definition: builtins.h:83
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1388
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define elog(elevel,...)
Definition: elog.h:228
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2223
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1647

◆ get_type_category_preferred()

void get_type_category_preferred ( Oid  typid,
char *  typcategory,
bool typispreferred 
)

Definition at line 2630 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by func_select_candidate(), IsPreferredType(), select_common_type(), select_common_type_from_oids(), TypeCategory(), and XmlTableGetValue().

2631 {
2632  HeapTuple tp;
2633  Form_pg_type typtup;
2634 
2636  if (!HeapTupleIsValid(tp))
2637  elog(ERROR, "cache lookup failed for type %u", typid);
2638  typtup = (Form_pg_type) GETSTRUCT(tp);
2639  *typcategory = typtup->typcategory;
2640  *typispreferred = typtup->typispreferred;
2641  ReleaseSysCache(tp);
2642 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define elog(elevel,...)
Definition: elog.h:228

◆ get_type_io_data()

void get_type_io_data ( Oid  typid,
IOFuncSelector  which_func,
int16 typlen,
bool typbyval,
char *  typalign,
char *  typdelim,
Oid typioparam,
Oid func 
)

Definition at line 2245 of file lsyscache.c.

References boot_get_type_io_data(), elog, ERROR, GETSTRUCT, getTypeIOParam(), HeapTupleIsValid, IOFunc_input, IOFunc_output, IOFunc_receive, IOFunc_send, IsBootstrapProcessingMode, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by array_in(), array_out(), array_recv(), array_send(), array_to_text_internal(), get_multirange_io_data(), get_range_io_data(), and plperl_ref_from_pg_array().

2253 {
2254  HeapTuple typeTuple;
2255  Form_pg_type typeStruct;
2256 
2257  /*
2258  * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2259  * use array_in and array_out during bootstrap.
2260  */
2262  {
2263  Oid typinput;
2264  Oid typoutput;
2265 
2266  boot_get_type_io_data(typid,
2267  typlen,
2268  typbyval,
2269  typalign,
2270  typdelim,
2271  typioparam,
2272  &typinput,
2273  &typoutput);
2274  switch (which_func)
2275  {
2276  case IOFunc_input:
2277  *func = typinput;
2278  break;
2279  case IOFunc_output:
2280  *func = typoutput;
2281  break;
2282  default:
2283  elog(ERROR, "binary I/O not supported during bootstrap");
2284  break;
2285  }
2286  return;
2287  }
2288 
2289  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2290  if (!HeapTupleIsValid(typeTuple))
2291  elog(ERROR, "cache lookup failed for type %u", typid);
2292  typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2293 
2294  *typlen = typeStruct->typlen;
2295  *typbyval = typeStruct->typbyval;
2296  *typalign = typeStruct->typalign;
2297  *typdelim = typeStruct->typdelim;
2298  *typioparam = getTypeIOParam(typeTuple);
2299  switch (which_func)
2300  {
2301  case IOFunc_input:
2302  *func = typeStruct->typinput;
2303  break;
2304  case IOFunc_output:
2305  *func = typeStruct->typoutput;
2306  break;
2307  case IOFunc_receive:
2308  *func = typeStruct->typreceive;
2309  break;
2310  case IOFunc_send:
2311  *func = typeStruct->typsend;
2312  break;
2313  }
2314  ReleaseSysCache(typeTuple);
2315 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
char typalign
Definition: pg_type.h:176
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:394
#define elog(elevel,...)
Definition: elog.h:228
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2223
void boot_get_type_io_data(Oid typid, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *typinput, Oid *typoutput)
Definition: bootstrap.c:971

◆ get_typisdefined()

bool get_typisdefined ( Oid  typid)

Definition at line 2093 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by DefineRange(), DefineType(), logicalrep_typmap_gettypname(), moveArrayTypeName(), and RenameTypeInternal().

2094 {
2095  HeapTuple tp;
2096 
2098  if (HeapTupleIsValid(tp))
2099  {
2100  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2101  bool result;
2102 
2103  result = typtup->typisdefined;
2104  ReleaseSysCache(tp);
2105  return result;
2106  }
2107  else
2108  return false;
2109 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2117 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by array_exec_setup(), DefineType(), ExecBuildProjectionInfo(), ExecInitCoerceToDomain(), ExecInitExprRec(), get_typavgwidth(), and pg_column_size().

2118 {
2119  HeapTuple tp;
2120 
2122  if (HeapTupleIsValid(tp))
2123  {
2124  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2125  int16 result;
2126 
2127  result = typtup->typlen;
2128  ReleaseSysCache(tp);
2129  return result;
2130  }
2131  else
2132  return 0;
2133 }
signed short int16
Definition: c.h:416
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typlenbyval()

void get_typlenbyval ( Oid  typid,
int16 typlen,
bool typbyval 
)

Definition at line 2171 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by build_pertrans_for_aggref(), copyParamList(), EstimateParamExecSpace(), EstimateParamListSpace(), eval_const_expressions_mutator(), evaluate_expr(), exec_eval_using_params(), exec_stmt_block(), ExecInitAgg(), ExecInitIndexScan(), ExecInitWindowAgg(), ExecWindowAgg(), fillTypeDesc(), get_actual_variable_range(), get_variable_range(), init_sql_fcache(), initialize_peragg(), makeNullConst(), preprocess_aggref(), scalararraysel(), SerializeParamExecParams(), SerializeParamList(), and tuplesort_begin_datum().

2172 {
2173  HeapTuple tp;
2174  Form_pg_type typtup;
2175 
2177  if (!HeapTupleIsValid(tp))
2178  elog(ERROR, "cache lookup failed for type %u", typid);
2179  typtup = (Form_pg_type) GETSTRUCT(tp);
2180  *typlen = typtup->typlen;
2181  *typbyval = typtup->typbyval;
2182  ReleaseSysCache(tp);
2183 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define elog(elevel,...)
Definition: elog.h:228

◆ get_typlenbyvalalign()

void get_typlenbyvalalign ( Oid  typid,
int16 typlen,
bool typbyval,
char *  typalign 
)

Definition at line 2191 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by _bt_preprocess_array_keys(), array_create_iterator(), array_exec_setup(), array_fill_internal(), array_map(), array_position_common(), array_positions(), array_to_json_internal(), array_to_jsonb_internal(), array_unnest(), arrayconst_startup_fn(), CreateCast(), DefineRange(), ExecEvalScalarArrayOp(), ExecIndexEvalArrayKeys(), ExecInitExprRec(), expand_array(), extract_variadic_args(), get_text_array_contents(), ginarrayextract(), gincost_scalararrayopexpr(), ginqueryarrayextract(), initArrayResult(), map_sql_value_to_xml_value(), match_clause_to_partition_key(), mcv_get_match_bitmap(), ordered_set_startup(), RelationBuildPartitionKey(), satisfies_hash_partition(), scalararraysel(), and text_format().

2193 {
2194  HeapTuple tp;
2195  Form_pg_type typtup;
2196 
2198  if (!HeapTupleIsValid(tp))
2199  elog(ERROR, "cache lookup failed for type %u", typid);
2200  typtup = (Form_pg_type) GETSTRUCT(tp);
2201  *typlen = typtup->typlen;
2202  *typbyval = typtup->typbyval;
2203  *typalign = typtup->typalign;
2204  ReleaseSysCache(tp);
2205 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char typalign
Definition: pg_type.h:176
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define elog(elevel,...)
Definition: elog.h:228

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 2926 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

2927 {
2928  HeapTuple tp;
2929 
2931  if (HeapTupleIsValid(tp))
2932  {
2933  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2934  Oid result;
2935 
2936  result = typtup->typmodin;
2937  ReleaseSysCache(tp);
2938  return result;
2939  }
2940  else
2941  return InvalidOid;
2942 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2339 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

2340 {
2341  HeapTuple tp;
2342 
2344  if (HeapTupleIsValid(tp))
2345  {
2346  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2347  char result;
2348 
2349  result = typtup->typstorage;
2350  ReleaseSysCache(tp);
2351  return result;
2352  }
2353  else
2354  return TYPSTORAGE_PLAIN;
2355 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3017 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by exec_check_rw_parameter(), and getSubscriptingRoutines().

3018 {
3019  HeapTuple tp;
3020 
3022  if (HeapTupleIsValid(tp))
3023  {
3024  Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
3025  RegProcedure handler = typform->typsubscript;
3026 
3027  if (typelemp)
3028  *typelemp = typform->typelem;
3029  ReleaseSysCache(tp);
3030  return handler;
3031  }
3032  else
3033  {
3034  if (typelemp)
3035  *typelemp = InvalidOid;
3036  return InvalidOid;
3037  }
3038 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:573
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typtype()

char get_typtype ( Oid  typid)

Definition at line 2549 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by AlterTypeNamespace(), check_sql_fn_retval(), CheckAttributeType(), CreateCast(), CreateTransform(), DefineAggregate(), DefineRange(), DefineType(), fmgr_sql_validator(), get_rels_with_domain(), get_type_func_class(), map_sql_type_to_xmlschema_type(), plperl_validator(), plpgsql_validator(), prepare_column_cache(), type_is_enum(), type_is_multirange(), type_is_range(), and type_is_rowtype().

2550 {
2551  HeapTuple tp;
2552 
2554  if (HeapTupleIsValid(tp))
2555  {
2556  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2557  char result;
2558 
2559  result = typtup->typtype;
2560  ReleaseSysCache(tp);
2561  return result;
2562  }
2563  else
2564  return '\0';
2565 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2458 of file lsyscache.c.

References Assert, elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1(), and TYPEOID.

Referenced by ATExecAddColumn(), build_coercion_expression(), cache_record_field_properties(), coerce_record_to_complex(), coerce_to_domain(), coerce_type(), getBaseType(), lookup_type_cache(), map_sql_type_to_xmlschema_type(), prepare_column_cache(), SendRowDescriptionCols_2(), SendRowDescriptionCols_3(), transformAssignmentIndirection(), transformContainerType(), and transformTypeCast().

2459 {
2460  /*
2461  * We loop to find the bottom base type in a stack of domains.
2462  */
2463  for (;;)
2464  {
2465  HeapTuple tup;
2466  Form_pg_type typTup;
2467 
2468  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2469  if (!HeapTupleIsValid(tup))
2470  elog(ERROR, "cache lookup failed for type %u", typid);
2471  typTup = (Form_pg_type) GETSTRUCT(tup);
2472  if (typTup->typtype != TYPTYPE_DOMAIN)
2473  {
2474  /* Not a domain, so done */
2475  ReleaseSysCache(tup);
2476  break;
2477  }
2478 
2479  Assert(*typmod == -1);
2480  typid = typTup->typbasetype;
2481  *typmod = typTup->typtypmod;
2482 
2483  ReleaseSysCache(tup);
2484  }
2485 
2486  return typid;
2487 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:792
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define elog(elevel,...)
Definition: elog.h:228

◆ getSubscriptingRoutines()

const struct SubscriptRoutines* getSubscriptingRoutines ( Oid  typid,
Oid typelemp 
)

Definition at line 3050 of file lsyscache.c.

References DatumGetPointer, get_typsubscript(), OidFunctionCall0, and OidIsValid.

Referenced by contain_leaked_vars_walker(), contain_nonstrict_functions_walker(), ExecInitSubscriptingRef(), and transformContainerSubscripts().

3051 {
3052  RegProcedure typsubscript = get_typsubscript(typid, typelemp);
3053 
3054  if (!OidIsValid(typsubscript))
3055  return NULL;
3056 
3057  return (const struct SubscriptRoutines *)
3058  DatumGetPointer(OidFunctionCall0(typsubscript));
3059 }
regproc RegProcedure
Definition: c.h:573
#define OidIsValid(objectId)
Definition: c.h:698
#define OidFunctionCall0(functionId)
Definition: fmgr.h:662
#define DatumGetPointer(X)
Definition: postgres.h:549
RegProcedure get_typsubscript(Oid typid, Oid *typelemp)
Definition: lsyscache.c:3017

◆ getTypeBinaryInputInfo()

void getTypeBinaryInputInfo ( Oid  type,