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)
 
int get_attstattarget (Oid relid, AttrNumber attnum)
 
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)
 
Oid get_publication_oid (const char *pubname, bool missing_ok)
 
char * get_publication_name (Oid pubid, bool missing_ok)
 
Oid get_subscription_oid (const char *subname, bool missing_ok)
 
char * get_subscription_name (Oid subid, bool missing_ok)
 

Variables

PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook
 

Macro Definition Documentation

◆ ATTSTATSSLOT_NUMBERS

#define ATTSTATSSLOT_NUMBERS   0x02

Definition at line 43 of file lsyscache.h.

◆ ATTSTATSSLOT_VALUES

#define ATTSTATSSLOT_VALUES   0x01

Definition at line 42 of file lsyscache.h.

◆ type_is_array

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

Definition at line 206 of file lsyscache.h.

◆ type_is_array_domain

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

Definition at line 208 of file lsyscache.h.

◆ TypeIsToastable

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

Definition at line 210 of file lsyscache.h.

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.

34 {
IOFuncSelector
Definition: lsyscache.h:34
@ IOFunc_output
Definition: lsyscache.h:36
@ IOFunc_input
Definition: lsyscache.h:35
@ IOFunc_send
Definition: lsyscache.h:38
@ IOFunc_receive
Definition: lsyscache.h:37

Function Documentation

◆ comparison_ops_are_compatible()

bool comparison_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 748 of file lsyscache.c.

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

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

Referenced by ineq_histogram_selectivity().

◆ equality_ops_are_compatible()

bool equality_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 697 of file lsyscache.c.

698 {
699  bool result;
700  CatCList *catlist;
701  int i;
702 
703  /* Easy if they're the same operator */
704  if (opno1 == opno2)
705  return true;
706 
707  /*
708  * We search through all the pg_amop entries for opno1.
709  */
710  catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
711 
712  result = false;
713  for (i = 0; i < catlist->n_members; i++)
714  {
715  HeapTuple op_tuple = &catlist->members[i]->tuple;
716  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
717 
718  /* must be btree or hash */
719  if (op_form->amopmethod == BTREE_AM_OID ||
720  op_form->amopmethod == HASH_AM_OID)
721  {
722  if (op_in_opfamily(opno2, op_form->amopfamily))
723  {
724  result = true;
725  break;
726  }
727  }
728  }
729 
730  ReleaseSysCacheList(catlist);
731 
732  return result;
733 }

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

Referenced by query_is_distinct_for().

◆ free_attstatsslot()

void free_attstatsslot ( AttStatsSlot sslot)

Definition at line 3302 of file lsyscache.c.

3303 {
3304  /* The values[] array was separately palloc'd by deconstruct_array */
3305  if (sslot->values)
3306  pfree(sslot->values);
3307  /* The numbers[] array points into numbers_arr, do not pfree it */
3308  /* Free the detoasted array objects, if any */
3309  if (sslot->values_arr)
3310  pfree(sslot->values_arr);
3311  if (sslot->numbers_arr)
3312  pfree(sslot->numbers_arr);
3313 }
void pfree(void *pointer)
Definition: mcxt.c:1436
Datum * values
Definition: lsyscache.h:53
void * numbers_arr
Definition: lsyscache.h:61
void * values_arr
Definition: lsyscache.h:60

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().

◆ func_parallel()

char func_parallel ( Oid  funcid)

Definition at line 1781 of file lsyscache.c.

1782 {
1783  HeapTuple tp;
1784  char 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))->proparallel;
1791  ReleaseSysCache(tp);
1792  return result;
1793 }
#define ERROR
Definition: elog.h:39
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:866
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:818
@ PROCOID
Definition: syscache.h:79

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

Referenced by max_parallel_hazard_checker(), and set_rel_consider_parallel().

◆ func_strict()

bool func_strict ( Oid  funcid)

Definition at line 1743 of file lsyscache.c.

1744 {
1745  HeapTuple tp;
1746  bool 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))->proisstrict;
1753  ReleaseSysCache(tp);
1754  return result;
1755 }

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

Referenced by AggregateCreate(), check_and_push_window_quals(), 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().

◆ func_volatile()

◆ get_array_type()

Oid get_array_type ( Oid  typid)

Definition at line 2745 of file lsyscache.c.

2746 {
2747  HeapTuple tp;
2748  Oid result = InvalidOid;
2749 
2751  if (HeapTupleIsValid(tp))
2752  {
2753  result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
2754  ReleaseSysCache(tp);
2755  }
2756  return result;
2757 }
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define InvalidOid
Definition: postgres_ext.h:36
unsigned int Oid
Definition: postgres_ext.h:31
@ TYPEOID
Definition: syscache.h:114

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().

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 3116 of file lsyscache.c.

3117 {
3118  HeapTuple tp;
3119  int32 stawidth;
3120 
3122  {
3123  stawidth = (*get_attavgwidth_hook) (relid, attnum);
3124  if (stawidth > 0)
3125  return stawidth;
3126  }
3128  ObjectIdGetDatum(relid),
3130  BoolGetDatum(false));
3131  if (HeapTupleIsValid(tp))
3132  {
3133  stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3134  ReleaseSysCache(tp);
3135  if (stawidth > 0)
3136  return stawidth;
3137  }
3138  return 0;
3139 }
signed int int32
Definition: c.h:478
get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:52
int16 attnum
Definition: pg_attribute.h:74
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:135
static Datum Int16GetDatum(int16 X)
Definition: postgres.h:172
static Datum BoolGetDatum(bool X)
Definition: postgres.h:102
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:840
@ STATRELATTINH
Definition: syscache.h:97

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

Referenced by get_rel_data_width(), and set_rel_width().

◆ get_attgenerated()

char get_attgenerated ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 914 of file lsyscache.c.

915 {
916  HeapTuple tp;
917  Form_pg_attribute att_tup;
918  char result;
919 
920  tp = SearchSysCache2(ATTNUM,
921  ObjectIdGetDatum(relid),
923  if (!HeapTupleIsValid(tp))
924  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
925  attnum, relid);
926  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
927  result = att_tup->attgenerated;
928  ReleaseSysCache(tp);
929  return result;
930 }
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:209
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:829
@ ATTNUM
Definition: syscache.h:41

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

Referenced by check_nested_generated_walker().

◆ get_attname()

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

Definition at line 826 of file lsyscache.c.

827 {
828  HeapTuple tp;
829 
830  tp = SearchSysCache2(ATTNUM,
832  if (HeapTupleIsValid(tp))
833  {
835  char *result;
836 
837  result = pstrdup(NameStr(att_tup->attname));
838  ReleaseSysCache(tp);
839  return result;
840  }
841 
842  if (!missing_ok)
843  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
844  attnum, relid);
845  return NULL;
846 }
#define NameStr(name)
Definition: c.h:730
char * pstrdup(const char *in)
Definition: mcxt.c:1624

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

Referenced by AddRelationNewConstraints(), ATExecAlterColumnType(), check_nested_generated_walker(), ComputePartitionAttrs(), contain_invalid_rfcolumn_walker(), CreateStatistics(), 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(), pub_collist_contains_invalid_column(), transformPartitionBound(), and transformPartitionRangeBounds().

◆ get_attnum()

AttrNumber get_attnum ( Oid  relid,
const char *  attname 
)

Definition at line 857 of file lsyscache.c.

858 {
859  HeapTuple tp;
860 
861  tp = SearchSysCacheAttName(relid, attname);
862  if (HeapTupleIsValid(tp))
863  {
865  AttrNumber result;
866 
867  result = att_tup->attnum;
868  ReleaseSysCache(tp);
869  return result;
870  }
871  else
872  return InvalidAttrNumber;
873 }
int16 AttrNumber
Definition: attnum.h:21
#define InvalidAttrNumber
Definition: attnum.h:23
NameData attname
Definition: pg_attribute.h:41
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:959

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

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

◆ get_attoptions()

Datum get_attoptions ( Oid  relid,
int16  attnum 
)

Definition at line 996 of file lsyscache.c.

997 {
998  HeapTuple tuple;
999  Datum attopts;
1000  Datum result;
1001  bool isnull;
1002 
1003  tuple = SearchSysCache2(ATTNUM,
1004  ObjectIdGetDatum(relid),
1006 
1007  if (!HeapTupleIsValid(tuple))
1008  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1009  attnum, relid);
1010 
1011  attopts = SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions,
1012  &isnull);
1013 
1014  if (isnull)
1015  result = (Datum) 0;
1016  else
1017  result = datumCopy(attopts, false, -1); /* text[] */
1018 
1019  ReleaseSysCache(tuple);
1020 
1021  return result;
1022 }
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition: datum.c:132
uintptr_t Datum
Definition: postgres.h:64
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1079
@ ATTNAME
Definition: syscache.h:40

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

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

◆ get_attstatsslot()

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

Definition at line 3192 of file lsyscache.c.

3194 {
3195  Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
3196  int i;
3197  Datum val;
3198  ArrayType *statarray;
3199  Oid arrayelemtype;
3200  int narrayelem;
3201  HeapTuple typeTuple;
3202  Form_pg_type typeForm;
3203 
3204  /* initialize *sslot properly */
3205  memset(sslot, 0, sizeof(AttStatsSlot));
3206 
3207  for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
3208  {
3209  if ((&stats->stakind1)[i] == reqkind &&
3210  (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
3211  break;
3212  }
3213  if (i >= STATISTIC_NUM_SLOTS)
3214  return false; /* not there */
3215 
3216  sslot->staop = (&stats->staop1)[i];
3217  sslot->stacoll = (&stats->stacoll1)[i];
3218 
3219  if (flags & ATTSTATSSLOT_VALUES)
3220  {
3222  Anum_pg_statistic_stavalues1 + i);
3223 
3224  /*
3225  * Detoast the array if needed, and in any case make a copy that's
3226  * under control of this AttStatsSlot.
3227  */
3228  statarray = DatumGetArrayTypePCopy(val);
3229 
3230  /*
3231  * Extract the actual array element type, and pass it back in case the
3232  * caller needs it.
3233  */
3234  sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3235 
3236  /* Need info about element type */
3237  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
3238  if (!HeapTupleIsValid(typeTuple))
3239  elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3240  typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
3241 
3242  /* Deconstruct array into Datum elements; NULLs not expected */
3243  deconstruct_array(statarray,
3244  arrayelemtype,
3245  typeForm->typlen,
3246  typeForm->typbyval,
3247  typeForm->typalign,
3248  &sslot->values, NULL, &sslot->nvalues);
3249 
3250  /*
3251  * If the element type is pass-by-reference, we now have a bunch of
3252  * Datums that are pointers into the statarray, so we need to keep
3253  * that until free_attstatsslot. Otherwise, all the useful info is in
3254  * sslot->values[], so we can free the array object immediately.
3255  */
3256  if (!typeForm->typbyval)
3257  sslot->values_arr = statarray;
3258  else
3259  pfree(statarray);
3260 
3261  ReleaseSysCache(typeTuple);
3262  }
3263 
3264  if (flags & ATTSTATSSLOT_NUMBERS)
3265  {
3267  Anum_pg_statistic_stanumbers1 + i);
3268 
3269  /*
3270  * Detoast the array if needed, and in any case make a copy that's
3271  * under control of this AttStatsSlot.
3272  */
3273  statarray = DatumGetArrayTypePCopy(val);
3274 
3275  /*
3276  * We expect the array to be a 1-D float4 array; verify that. We don't
3277  * need to use deconstruct_array() since the array data is just going
3278  * to look like a C array of float4 values.
3279  */
3280  narrayelem = ARR_DIMS(statarray)[0];
3281  if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3282  ARR_HASNULL(statarray) ||
3283  ARR_ELEMTYPE(statarray) != FLOAT4OID)
3284  elog(ERROR, "stanumbers is not a 1-D float4 array");
3285 
3286  /* Give caller a pointer directly into the statarray */
3287  sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3288  sslot->nnumbers = narrayelem;
3289 
3290  /* We'll free the statarray in free_attstatsslot */
3291  sslot->numbers_arr = statarray;
3292  }
3293 
3294  return true;
3295 }
#define DatumGetArrayTypePCopy(X)
Definition: array.h:255
#define ARR_NDIM(a)
Definition: array.h:283
#define ARR_DATA_PTR(a)
Definition: array.h:315
#define ARR_ELEMTYPE(a)
Definition: array.h:285
#define ARR_DIMS(a)
Definition: array.h:287
#define ARR_HASNULL(a)
Definition: array.h:284
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3600
float float4
Definition: c.h:613
long val
Definition: informix.c:664
#define ATTSTATSSLOT_NUMBERS
Definition: lsyscache.h:43
#define ATTSTATSSLOT_VALUES
Definition: lsyscache.h:42
#define STATISTIC_NUM_SLOTS
Definition: pg_statistic.h:127
Oid valuetype
Definition: lsyscache.h:52
float4 * numbers
Definition: lsyscache.h:56
int nnumbers
Definition: lsyscache.h:57
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
Definition: syscache.c:1110

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, SysCacheGetAttrNotNull(), 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().

◆ get_attstattarget()

int get_attstattarget ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 884 of file lsyscache.c.

885 {
886  HeapTuple tp;
887  Form_pg_attribute att_tup;
888  int result;
889 
890  tp = SearchSysCache2(ATTNUM,
891  ObjectIdGetDatum(relid),
893  if (!HeapTupleIsValid(tp))
894  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
895  attnum, relid);
896  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
897  result = att_tup->attstattarget;
898  ReleaseSysCache(tp);
899  return result;
900 }

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

Referenced by index_concurrently_swap().

◆ get_atttype()

Oid get_atttype ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 939 of file lsyscache.c.

940 {
941  HeapTuple tp;
942 
943  tp = SearchSysCache2(ATTNUM,
944  ObjectIdGetDatum(relid),
946  if (HeapTupleIsValid(tp))
947  {
949  Oid result;
950 
951  result = att_tup->atttypid;
952  ReleaseSysCache(tp);
953  return result;
954  }
955  else
956  return InvalidOid;
957 }

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

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

◆ get_atttypetypmodcoll()

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

Definition at line 969 of file lsyscache.c.

971 {
972  HeapTuple tp;
973  Form_pg_attribute att_tup;
974 
975  tp = SearchSysCache2(ATTNUM,
976  ObjectIdGetDatum(relid),
978  if (!HeapTupleIsValid(tp))
979  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
980  attnum, relid);
981  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
982 
983  *typid = att_tup->atttypid;
984  *typmod = att_tup->atttypmod;
985  *collid = att_tup->attcollation;
986  ReleaseSysCache(tp);
987 }
Oid collid

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

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

◆ get_base_element_type()

Oid get_base_element_type ( Oid  typid)

Definition at line 2790 of file lsyscache.c.

2791 {
2792  /*
2793  * We loop to find the bottom base type in a stack of domains.
2794  */
2795  for (;;)
2796  {
2797  HeapTuple tup;
2798  Form_pg_type typTup;
2799 
2800  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2801  if (!HeapTupleIsValid(tup))
2802  break;
2803  typTup = (Form_pg_type) GETSTRUCT(tup);
2804  if (typTup->typtype != TYPTYPE_DOMAIN)
2805  {
2806  /* Not a domain, so stop descending */
2807  Oid result;
2808 
2809  /* This test must match get_element_type */
2810  if (IsTrueArrayType(typTup))
2811  result = typTup->typelem;
2812  else
2813  result = InvalidOid;
2814  ReleaseSysCache(tup);
2815  return result;
2816  }
2817 
2818  typid = typTup->typbasetype;
2819  ReleaseSysCache(tup);
2820  }
2821 
2822  /* Like get_element_type, silently return InvalidOid for bogus input */
2823  return InvalidOid;
2824 }

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().

◆ get_cast_oid()

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

Definition at line 1033 of file lsyscache.c.

1034 {
1035  Oid oid;
1036 
1037  oid = GetSysCacheOid2(CASTSOURCETARGET, Anum_pg_cast_oid,
1038  ObjectIdGetDatum(sourcetypeid),
1039  ObjectIdGetDatum(targettypeid));
1040  if (!OidIsValid(oid) && !missing_ok)
1041  ereport(ERROR,
1042  (errcode(ERRCODE_UNDEFINED_OBJECT),
1043  errmsg("cast from type %s to type %s does not exist",
1044  format_type_be(sourcetypeid),
1045  format_type_be(targettypeid))));
1046  return oid;
1047 }
#define OidIsValid(objectId)
Definition: c.h:759
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ereport(elevel,...)
Definition: elog.h:149
char * format_type_be(Oid type_oid)
Definition: format_type.c:339
@ CASTSOURCETARGET
Definition: syscache.h:46
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
Definition: syscache.h:202

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

Referenced by get_object_address().

◆ get_collation_isdeterministic()

bool get_collation_isdeterministic ( Oid  colloid)

Definition at line 1080 of file lsyscache.c.

1081 {
1082  HeapTuple tp;
1083  Form_pg_collation colltup;
1084  bool result;
1085 
1086  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1087  if (!HeapTupleIsValid(tp))
1088  elog(ERROR, "cache lookup failed for collation %u", colloid);
1089  colltup = (Form_pg_collation) GETSTRUCT(tp);
1090  result = colltup->collisdeterministic;
1091  ReleaseSysCache(tp);
1092  return result;
1093 }
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:58
@ COLLOID
Definition: syscache.h:50

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().

◆ get_collation_name()

char* get_collation_name ( Oid  colloid)

Definition at line 1061 of file lsyscache.c.

1062 {
1063  HeapTuple tp;
1064 
1065  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1066  if (HeapTupleIsValid(tp))
1067  {
1069  char *result;
1070 
1071  result = pstrdup(NameStr(colltup->collname));
1072  ReleaseSysCache(tp);
1073  return result;
1074  }
1075  else
1076  return NULL;
1077 }

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

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

◆ get_commutator()

◆ get_compatible_hash_operators()

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

Definition at line 409 of file lsyscache.c.

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

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().

◆ get_constraint_index()

Oid get_constraint_index ( Oid  conoid)

Definition at line 1139 of file lsyscache.c.

1140 {
1141  HeapTuple tp;
1142 
1144  if (HeapTupleIsValid(tp))
1145  {
1147  Oid result;
1148 
1149  if (contup->contype == CONSTRAINT_UNIQUE ||
1150  contup->contype == CONSTRAINT_PRIMARY ||
1151  contup->contype == CONSTRAINT_EXCLUSION)
1152  result = contup->conindid;
1153  else
1154  result = InvalidOid;
1155  ReleaseSysCache(tp);
1156  return result;
1157  }
1158  else
1159  return InvalidOid;
1160 }
FormData_pg_constraint * Form_pg_constraint
@ CONSTROID
Definition: syscache.h:53

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

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

◆ get_constraint_name()

char* get_constraint_name ( Oid  conoid)

Definition at line 1107 of file lsyscache.c.

1108 {
1109  HeapTuple tp;
1110 
1112  if (HeapTupleIsValid(tp))
1113  {
1115  char *result;
1116 
1117  result = pstrdup(NameStr(contup->conname));
1118  ReleaseSysCache(tp);
1119  return result;
1120  }
1121  else
1122  return NULL;
1123 }

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

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

◆ get_element_type()

◆ get_equality_op_for_ordering_op()

Oid get_equality_op_for_ordering_op ( Oid  opno,
bool reverse 
)

Definition at line 266 of file lsyscache.c.

267 {
268  Oid result = InvalidOid;
269  Oid opfamily;
270  Oid opcintype;
271  int16 strategy;
272 
273  /* Find the operator in pg_amop */
275  &opfamily, &opcintype, &strategy))
276  {
277  /* Found a suitable opfamily, get matching equality operator */
278  result = get_opfamily_member(opfamily,
279  opcintype,
280  opcintype,
282  if (reverse)
283  *reverse = (strategy == BTGreaterStrategyNumber);
284  }
285 
286  return result;
287 }
signed short int16
Definition: c.h:477
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
Definition: lsyscache.c:206
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
#define BTEqualStrategyNumber
Definition: stratnum.h:31

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().

◆ get_func_leakproof()

bool get_func_leakproof ( Oid  funcid)

Definition at line 1819 of file lsyscache.c.

1820 {
1821  HeapTuple tp;
1822  bool result;
1823 
1824  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1825  if (!HeapTupleIsValid(tp))
1826  elog(ERROR, "cache lookup failed for function %u", funcid);
1827 
1828  result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
1829  ReleaseSysCache(tp);
1830  return result;
1831 }

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().

◆ get_func_name()

◆ get_func_namespace()

Oid get_func_namespace ( Oid  funcid)

Definition at line 1614 of file lsyscache.c.

1615 {
1616  HeapTuple tp;
1617 
1618  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1619  if (HeapTupleIsValid(tp))
1620  {
1621  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1622  Oid result;
1623 
1624  result = functup->pronamespace;
1625  ReleaseSysCache(tp);
1626  return result;
1627  }
1628  else
1629  return InvalidOid;
1630 }

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

Referenced by ExplainTargetRel(), sepgsql_proc_drop(), and unaccent_dict().

◆ get_func_nargs()

int get_func_nargs ( Oid  funcid)

Definition at line 1656 of file lsyscache.c.

1657 {
1658  HeapTuple tp;
1659  int result;
1660 
1661  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1662  if (!HeapTupleIsValid(tp))
1663  elog(ERROR, "cache lookup failed for function %u", funcid);
1664 
1665  result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1666  ReleaseSysCache(tp);
1667  return result;
1668 }
int16 pronargs
Definition: pg_proc.h:81

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

◆ get_func_prokind()

char get_func_prokind ( Oid  funcid)

Definition at line 1800 of file lsyscache.c.

1801 {
1802  HeapTuple tp;
1803  char result;
1804 
1805  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1806  if (!HeapTupleIsValid(tp))
1807  elog(ERROR, "cache lookup failed for function %u", funcid);
1808 
1809  result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
1810  ReleaseSysCache(tp);
1811  return result;
1812 }

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

Referenced by LookupFuncNameInternal(), LookupFuncWithArgs(), and RemoveObjects().

◆ get_func_retset()

bool get_func_retset ( Oid  funcid)

Definition at line 1724 of file lsyscache.c.

1725 {
1726  HeapTuple tp;
1727  bool 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))->proretset;
1734  ReleaseSysCache(tp);
1735  return result;
1736 }

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

Referenced by make_op(), and make_scalar_array_op().

◆ get_func_rettype()

◆ get_func_signature()

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

Definition at line 1678 of file lsyscache.c.

1679 {
1680  HeapTuple tp;
1681  Form_pg_proc procstruct;
1682  Oid result;
1683 
1684  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1685  if (!HeapTupleIsValid(tp))
1686  elog(ERROR, "cache lookup failed for function %u", funcid);
1687 
1688  procstruct = (Form_pg_proc) GETSTRUCT(tp);
1689 
1690  result = procstruct->prorettype;
1691  *nargs = (int) procstruct->pronargs;
1692  Assert(*nargs == procstruct->proargtypes.dim1);
1693  *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1694  memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1695 
1696  ReleaseSysCache(tp);
1697  return result;
1698 }
Assert(fmt[strlen(fmt) - 1] !='\n')
void * palloc(Size size)
Definition: mcxt.c:1210

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

Referenced by plperl_call_perl_func(), and resolve_aggregate_transtype().

◆ get_func_support()

RegProcedure get_func_support ( Oid  funcid)

Definition at line 1840 of file lsyscache.c.

1841 {
1842  HeapTuple tp;
1843 
1844  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1845  if (HeapTupleIsValid(tp))
1846  {
1847  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1848  RegProcedure result;
1849 
1850  result = functup->prosupport;
1851  ReleaseSysCache(tp);
1852  return result;
1853  }
1854  else
1855  return (RegProcedure) InvalidOid;
1856 }
regproc RegProcedure
Definition: c.h:634

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

Referenced by find_window_run_conditions(), function_selectivity(), get_index_clause_from_support(), and optimize_window_clauses().

◆ get_func_variadictype()

Oid get_func_variadictype ( Oid  funcid)

Definition at line 1705 of file lsyscache.c.

1706 {
1707  HeapTuple tp;
1708  Oid 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))->provariadic;
1715  ReleaseSysCache(tp);
1716  return result;
1717 }

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

Referenced by assign_hypothetical_collations(), and assign_ordered_set_collations().

◆ get_index_column_opclass()

Oid get_index_column_opclass ( Oid  index_oid,
int  attno 
)

Definition at line 3470 of file lsyscache.c.

3471 {
3472  HeapTuple tuple;
3473  Form_pg_index rd_index;
3474  Datum datum;
3475  oidvector *indclass;
3476  Oid opclass;
3477 
3478  /* First we need to know the column's opclass. */
3479 
3480  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3481  if (!HeapTupleIsValid(tuple))
3482  return InvalidOid;
3483 
3484  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3485 
3486  /* caller is supposed to guarantee this */
3487  Assert(attno > 0 && attno <= rd_index->indnatts);
3488 
3489  /* Non-key attributes don't have an opclass */
3490  if (attno > rd_index->indnkeyatts)
3491  {
3492  ReleaseSysCache(tuple);
3493  return InvalidOid;
3494  }
3495 
3496  datum = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
3497  indclass = ((oidvector *) DatumGetPointer(datum));
3498 
3499  Assert(attno <= indclass->dim1);
3500  opclass = indclass->values[attno - 1];
3501 
3502  ReleaseSysCache(tuple);
3503 
3504  return opclass;
3505 }
FormData_pg_index * Form_pg_index
Definition: pg_index.h:70
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:312
Definition: c.h:710
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition: c.h:717
@ INDEXRELID
Definition: syscache.h:66

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

Referenced by gistproperty(), and spgproperty().

◆ get_index_isclustered()

bool get_index_isclustered ( Oid  index_oid)

Definition at line 3559 of file lsyscache.c.

3560 {
3561  bool isclustered;
3562  HeapTuple tuple;
3563  Form_pg_index rd_index;
3564 
3565  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3566  if (!HeapTupleIsValid(tuple))
3567  elog(ERROR, "cache lookup failed for index %u", index_oid);
3568 
3569  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3570  isclustered = rd_index->indisclustered;
3571  ReleaseSysCache(tuple);
3572 
3573  return isclustered;
3574 }

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

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

◆ get_index_isreplident()

bool get_index_isreplident ( Oid  index_oid)

Definition at line 3513 of file lsyscache.c.

3514 {
3515  HeapTuple tuple;
3516  Form_pg_index rd_index;
3517  bool result;
3518 
3519  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3520  if (!HeapTupleIsValid(tuple))
3521  return false;
3522 
3523  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3524  result = rd_index->indisreplident;
3525  ReleaseSysCache(tuple);
3526 
3527  return result;
3528 }

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

Referenced by RememberReplicaIdentityForRebuilding().

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3536 of file lsyscache.c.

3537 {
3538  bool isvalid;
3539  HeapTuple tuple;
3540  Form_pg_index rd_index;
3541 
3542  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3543  if (!HeapTupleIsValid(tuple))
3544  elog(ERROR, "cache lookup failed for index %u", index_oid);
3545 
3546  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3547  isvalid = rd_index->indisvalid;
3548  ReleaseSysCache(tuple);
3549 
3550  return isvalid;
3551 }

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

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

◆ get_language_name()

char* get_language_name ( Oid  langoid,
bool  missing_ok 
)

Definition at line 1165 of file lsyscache.c.

1166 {
1167  HeapTuple tp;
1168 
1169  tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
1170  if (HeapTupleIsValid(tp))
1171  {
1173  char *result;
1174 
1175  result = pstrdup(NameStr(lantup->lanname));
1176  ReleaseSysCache(tp);
1177  return result;
1178  }
1179 
1180  if (!missing_ok)
1181  elog(ERROR, "cache lookup failed for language %u",
1182  langoid);
1183  return NULL;
1184 }
FormData_pg_language * Form_pg_language
Definition: pg_language.h:65
@ LANGOID
Definition: syscache.h:68

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

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

◆ get_mergejoin_opfamilies()

List* get_mergejoin_opfamilies ( Oid  opno)

Definition at line 365 of file lsyscache.c.

366 {
367  List *result = NIL;
368  CatCList *catlist;
369  int i;
370 
371  /*
372  * Search pg_amop to see if the target operator is registered as the "="
373  * operator of any btree opfamily.
374  */
376 
377  for (i = 0; i < catlist->n_members; i++)
378  {
379  HeapTuple tuple = &catlist->members[i]->tuple;
380  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
381 
382  /* must be btree equality */
383  if (aform->amopmethod == BTREE_AM_OID &&
384  aform->amopstrategy == BTEqualStrategyNumber)
385  result = lappend_oid(result, aform->amopfamily);
386  }
387 
388  ReleaseSysCacheList(catlist);
389 
390  return result;
391 }
List * lappend_oid(List *list, Oid datum)
Definition: list.c:374
#define NIL
Definition: pg_list.h:68
Definition: pg_list.h:54

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().

◆ get_multirange_range()

Oid get_multirange_range ( Oid  multirangeOid)

Definition at line 3441 of file lsyscache.c.

3442 {
3443  HeapTuple tp;
3444 
3445  tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
3446  if (HeapTupleIsValid(tp))
3447  {
3448  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3449  Oid result;
3450 
3451  result = rngtup->rngtypid;
3452  ReleaseSysCache(tp);
3453  return result;
3454  }
3455  else
3456  return InvalidOid;
3457 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:58
@ RANGEMULTIRANGE
Definition: syscache.h:86

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().

◆ get_namespace_name()

char* get_namespace_name ( Oid  nspid)

Definition at line 3324 of file lsyscache.c.

3325 {
3326  HeapTuple tp;
3327 
3329  if (HeapTupleIsValid(tp))
3330  {
3332  char *result;
3333 
3334  result = pstrdup(NameStr(nsptup->nspname));
3335  ReleaseSysCache(tp);
3336  return result;
3337  }
3338  else
3339  return NULL;
3340 }
int nspid
FormData_pg_namespace * Form_pg_namespace
Definition: pg_namespace.h:52
@ NAMESPACEOID
Definition: syscache.h:70

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

Referenced by acquire_inherited_sample_rows(), AlterExtensionNamespace(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterRelationNamespaceInternal(), AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), appendFunctionName(), apply_handle_tuple_routing(), ApplyExtensionUpdates(), ATExecChangeOwner(), ATParseTransformCmd(), BuildRelationExtStatistics(), check_default_text_search_config(), check_publication_add_schema(), check_publications_origin(), CheckPubRelationColumnList(), 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(), ExecRefreshMatView(), execute_extension_script(), fetch_statentries_for_relation(), format_operator_extended(), format_procedure_extended(), generate_operator_clause(), generate_relation_name(), generateClonedIndexStmt(), generateSerialExtraStmts(), get_collation(), get_namespace_name_or_temp(), get_opclass(), get_other_operator(), getObjectDescription(), getOpFamilyDescription(), getPublicationSchemaInfo(), 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(), MarkInheritDetached(), parallel_vacuum_main(), perform_work_item(), pg_decode_change(), pg_decode_truncate(), pg_identify_object(), pg_newlocale_from_collation(), pgoutput_column_list_init(), pgoutput_row_filter(), plpgsql_fulfill_promise(), publication_add_schema(), PublicationDropSchemas(), 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().

◆ get_namespace_name_or_temp()

◆ get_negator()

Oid get_negator ( Oid  opno)

Definition at line 1515 of file lsyscache.c.

1516 {
1517  HeapTuple tp;
1518 
1520  if (HeapTupleIsValid(tp))
1521  {
1523  Oid result;
1524 
1525  result = optup->oprnegate;
1526  ReleaseSysCache(tp);
1527  return result;
1528  }
1529  else
1530  return InvalidOid;
1531 }

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

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

◆ get_op_btree_interpretation()

List* get_op_btree_interpretation ( Oid  opno)

Definition at line 600 of file lsyscache.c.

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

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 find_window_run_conditions(), lookup_proof_cache(), and make_row_comparison_op().

◆ get_op_hash_functions()

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

Definition at line 509 of file lsyscache.c.

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

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 convert_saop_to_hashed_saop_walker(), ExecHashTableCreate(), ExecInitMemoize(), ExecInitSubPlan(), and execTuplesHashPrepare().

◆ 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 135 of file lsyscache.c.

139 {
140  HeapTuple tp;
141  Form_pg_amop amop_tup;
142 
144  ObjectIdGetDatum(opno),
145  CharGetDatum(ordering_op ? AMOP_ORDER : AMOP_SEARCH),
146  ObjectIdGetDatum(opfamily));
147  if (!HeapTupleIsValid(tp))
148  elog(ERROR, "operator %u is not a member of opfamily %u",
149  opno, opfamily);
150  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
151  *strategy = amop_tup->amopstrategy;
152  *lefttype = amop_tup->amoplefttype;
153  *righttype = amop_tup->amoprighttype;
154  ReleaseSysCache(tp);
155 }
static Datum CharGetDatum(char X)
Definition: postgres.h:122

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().

◆ get_op_opfamily_sortfamily()

Oid get_op_opfamily_sortfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 107 of file lsyscache.c.

108 {
109  HeapTuple tp;
110  Form_pg_amop amop_tup;
111  Oid result;
112 
114  ObjectIdGetDatum(opno),
115  CharGetDatum(AMOP_ORDER),
116  ObjectIdGetDatum(opfamily));
117  if (!HeapTupleIsValid(tp))
118  return InvalidOid;
119  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
120  result = amop_tup->amopsortfamily;
121  ReleaseSysCache(tp);
122  return result;
123 }

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

Referenced by match_clause_to_ordering_op().

◆ get_op_opfamily_strategy()

int get_op_opfamily_strategy ( Oid  opno,
Oid  opfamily 
)

Definition at line 82 of file lsyscache.c.

83 {
84  HeapTuple tp;
85  Form_pg_amop amop_tup;
86  int result;
87 
89  ObjectIdGetDatum(opno),
90  CharGetDatum(AMOP_SEARCH),
91  ObjectIdGetDatum(opfamily));
92  if (!HeapTupleIsValid(tp))
93  return 0;
94  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
95  result = amop_tup->amopstrategy;
96  ReleaseSysCache(tp);
97  return result;
98 }

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().

◆ get_op_rettype()

Oid get_op_rettype ( Oid  opno)

Definition at line 1315 of file lsyscache.c.

1316 {
1317  HeapTuple tp;
1318 
1320  if (HeapTupleIsValid(tp))
1321  {
1323  Oid result;
1324 
1325  result = optup->oprresult;
1326  ReleaseSysCache(tp);
1327  return result;
1328  }
1329  else
1330  return InvalidOid;
1331 }

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

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

◆ get_opclass_family()

Oid get_opclass_family ( Oid  opclass)

Definition at line 1194 of file lsyscache.c.

1195 {
1196  HeapTuple tp;
1197  Form_pg_opclass cla_tup;
1198  Oid result;
1199 
1200  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1201  if (!HeapTupleIsValid(tp))
1202  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1203  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1204 
1205  result = cla_tup->opcfamily;
1206  ReleaseSysCache(tp);
1207  return result;
1208 }
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83
@ CLAOID
Definition: syscache.h:48

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

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

◆ get_opclass_input_type()

Oid get_opclass_input_type ( Oid  opclass)

Definition at line 1216 of file lsyscache.c.

1217 {
1218  HeapTuple tp;
1219  Form_pg_opclass cla_tup;
1220  Oid result;
1221 
1222  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1223  if (!HeapTupleIsValid(tp))
1224  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1225  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1226 
1227  result = cla_tup->opcintype;
1228  ReleaseSysCache(tp);
1229  return result;
1230 }

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().

◆ get_opclass_opfamily_and_input_type()

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

Definition at line 1239 of file lsyscache.c.

1240 {
1241  HeapTuple tp;
1242  Form_pg_opclass cla_tup;
1243 
1244  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1245  if (!HeapTupleIsValid(tp))
1246  return false;
1247 
1248  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1249 
1250  *opfamily = cla_tup->opcfamily;
1251  *opcintype = cla_tup->opcintype;
1252 
1253  ReleaseSysCache(tp);
1254 
1255  return true;
1256 }

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

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

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1267 of file lsyscache.c.

1268 {
1269  HeapTuple tp;
1270 
1272  if (HeapTupleIsValid(tp))
1273  {
1275  RegProcedure result;
1276 
1277  result = optup->oprcode;
1278  ReleaseSysCache(tp);
1279  return result;
1280  }
1281  else
1282  return (RegProcedure) InvalidOid;
1283 }

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(), convert_saop_to_hashed_saop_walker(), cost_qual_eval_walker(), DefineOpClass(), eqjoinsel(), ExecInitMemoize(), 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(), minmax_multi_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().

◆ get_opfamily_member()

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

Definition at line 165 of file lsyscache.c.

167 {
168  HeapTuple tp;
169  Form_pg_amop amop_tup;
170  Oid result;
171 
173  ObjectIdGetDatum(opfamily),
174  ObjectIdGetDatum(lefttype),
175  ObjectIdGetDatum(righttype),
176  Int16GetDatum(strategy));
177  if (!HeapTupleIsValid(tp))
178  return InvalidOid;
179  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
180  result = amop_tup->amopopr;
181  ReleaseSysCache(tp);
182  return result;
183 }
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:851
@ AMOPSTRATEGY
Definition: syscache.h:38

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

Referenced by _bt_compare_scankey_args(), _bt_find_extreme_element(), appendOrderByClause(), ATAddForeignKeyConstraint(), btcostestimate(), build_replindex_scan_key(), BuildSpeculativeIndexInfo(), create_indexscan_plan(), DefineIndex(), expand_indexqual_rowcompare(), find_window_run_conditions(), 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().

◆ get_opfamily_proc()

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

◆ get_opname()

char* get_opname ( Oid  opno)

Definition at line 1292 of file lsyscache.c.

1293 {
1294  HeapTuple tp;
1295 
1297  if (HeapTupleIsValid(tp))
1298  {
1300  char *result;
1301 
1302  result = pstrdup(NameStr(optup->oprname));
1303  ReleaseSysCache(tp);
1304  return result;
1305  }
1306  else
1307  return NULL;
1308 }

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

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

◆ get_oprjoin()

RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1563 of file lsyscache.c.

1564 {
1565  HeapTuple tp;
1566 
1568  if (HeapTupleIsValid(tp))
1569  {
1571  RegProcedure result;
1572 
1573  result = optup->oprjoin;
1574  ReleaseSysCache(tp);
1575  return result;
1576  }
1577  else
1578  return (RegProcedure) InvalidOid;
1579 }

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

Referenced by join_selectivity(), and scalararraysel().

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1539 of file lsyscache.c.

1540 {
1541  HeapTuple tp;
1542 
1544  if (HeapTupleIsValid(tp))
1545  {
1547  RegProcedure result;
1548 
1549  result = optup->oprrest;
1550  ReleaseSysCache(tp);
1551  return result;
1552  }
1553  else
1554  return (RegProcedure) InvalidOid;
1555 }

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

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

◆ get_ordering_op_for_equality_op()

Oid get_ordering_op_for_equality_op ( Oid  opno,
bool  use_lhs_type 
)

Definition at line 304 of file lsyscache.c.

305 {
306  Oid result = InvalidOid;
307  CatCList *catlist;
308  int i;
309 
310  /*
311  * Search pg_amop to see if the target operator is registered as the "="
312  * operator of any btree opfamily.
313  */
315 
316  for (i = 0; i < catlist->n_members; i++)
317  {
318  HeapTuple tuple = &catlist->members[i]->tuple;
319  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
320 
321  /* must be btree */
322  if (aform->amopmethod != BTREE_AM_OID)
323  continue;
324 
325  if (aform->amopstrategy == BTEqualStrategyNumber)
326  {
327  /* Found a suitable opfamily, get matching ordering operator */
328  Oid typid;
329 
330  typid = use_lhs_type ? aform->amoplefttype : aform->amoprighttype;
331  result = get_opfamily_member(aform->amopfamily,
332  typid, typid,
334  if (OidIsValid(result))
335  break;
336  /* failure probably shouldn't happen, but keep looking if so */
337  }
338  }
339 
340  ReleaseSysCacheList(catlist);
341 
342  return result;
343 }
#define BTLessStrategyNumber
Definition: stratnum.h:29

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().

◆ get_ordering_op_properties()

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

Definition at line 206 of file lsyscache.c.

208 {
209  bool result = false;
210  CatCList *catlist;
211  int i;
212 
213  /* ensure outputs are initialized on failure */
214  *opfamily = InvalidOid;
215  *opcintype = InvalidOid;
216  *strategy = 0;
217 
218  /*
219  * Search pg_amop to see if the target operator is registered as the "<"
220  * or ">" operator of any btree opfamily.
221  */
223 
224  for (i = 0; i < catlist->n_members; i++)
225  {
226  HeapTuple tuple = &catlist->members[i]->tuple;
227  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
228 
229  /* must be btree */
230  if (aform->amopmethod != BTREE_AM_OID)
231  continue;
232 
233  if (aform->amopstrategy == BTLessStrategyNumber ||
234  aform->amopstrategy == BTGreaterStrategyNumber)
235  {
236  /* Found it ... should have consistent input types */
237  if (aform->amoplefttype == aform->amoprighttype)
238  {
239  /* Found a suitable opfamily, return info */
240  *opfamily = aform->amopfamily;
241  *opcintype = aform->amoplefttype;
242  *strategy = aform->amopstrategy;
243  result = true;
244  break;
245  }
246  }
247  }
248 
249  ReleaseSysCacheList(catlist);
250 
251  return result;
252 }

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().

◆ get_promoted_array_type()

Oid get_promoted_array_type ( Oid  typid)

Definition at line 2769 of file lsyscache.c.

2770 {
2771  Oid array_type = get_array_type(typid);
2772 
2773  if (OidIsValid(array_type))
2774  return array_type;
2775  if (OidIsValid(get_element_type(typid)))
2776  return typid;
2777  return InvalidOid;
2778 }
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2717
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2745

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

Referenced by build_subplan(), and exprType().

◆ get_publication_name()

char* get_publication_name ( Oid  pubid,
bool  missing_ok 
)

Definition at line 3603 of file lsyscache.c.

3604 {
3605  HeapTuple tup;
3606  char *pubname;
3607  Form_pg_publication pubform;
3608 
3610 
3611  if (!HeapTupleIsValid(tup))
3612  {
3613  if (!missing_ok)
3614  elog(ERROR, "cache lookup failed for publication %u", pubid);
3615  return NULL;
3616  }
3617 
3618  pubform = (Form_pg_publication) GETSTRUCT(tup);
3619  pubname = pstrdup(NameStr(pubform->pubname));
3620 
3621  ReleaseSysCache(tup);
3622 
3623  return pubname;
3624 }
FormData_pg_publication * Form_pg_publication
@ PUBLICATIONOID
Definition: syscache.h:83

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

Referenced by getObjectDescription(), getObjectIdentityParts(), and getPublicationSchemaInfo().

◆ get_publication_oid()

Oid get_publication_oid ( const char *  pubname,
bool  missing_ok 
)

Definition at line 3583 of file lsyscache.c.

3584 {
3585  Oid oid;
3586 
3587  oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
3588  CStringGetDatum(pubname));
3589  if (!OidIsValid(oid) && !missing_ok)
3590  ereport(ERROR,
3591  (errcode(ERRCODE_UNDEFINED_OBJECT),
3592  errmsg("publication \"%s\" does not exist", pubname)));
3593  return oid;
3594 }
static Datum CStringGetDatum(const char *X)
Definition: postgres.h:350
@ PUBLICATIONNAME
Definition: syscache.h:80
#define GetSysCacheOid1(cacheId, oidcol, key1)
Definition: syscache.h:200

References CStringGetDatum(), ereport, errcode(), errmsg(), ERROR, GetSysCacheOid1, OidIsValid, and PUBLICATIONNAME.

Referenced by get_object_address_unqualified(), and GetPublicationByName().

◆ get_range_collation()

Oid get_range_collation ( Oid  rangeOid)

Definition at line 3391 of file lsyscache.c.

3392 {
3393  HeapTuple tp;
3394 
3395  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3396  if (HeapTupleIsValid(tp))
3397  {
3398  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3399  Oid result;
3400 
3401  result = rngtup->rngcollation;
3402  ReleaseSysCache(tp);
3403  return result;
3404  }
3405  else
3406  return InvalidOid;
3407 }
@ RANGETYPE
Definition: syscache.h:87

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

Referenced by CheckAttributeType().

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

Definition at line 3416 of file lsyscache.c.

3417 {
3418  HeapTuple tp;
3419 
3420  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3421  if (HeapTupleIsValid(tp))
3422  {
3423  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3424  Oid result;
3425 
3426  result = rngtup->rngmultitypid;
3427  ReleaseSysCache(tp);
3428  return result;
3429  }
3430  else
3431  return InvalidOid;
3432 }

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

Referenced by enforce_generic_type_consistency(), and resolve_anymultirange_from_others().

◆ get_range_subtype()

Oid get_range_subtype ( Oid  rangeOid)

Definition at line 3365 of file lsyscache.c.

3366 {
3367  HeapTuple tp;
3368 
3369  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3370  if (HeapTupleIsValid(tp))
3371  {
3372  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3373  Oid result;
3374 
3375  result = rngtup->rngsubtype;
3376  ReleaseSysCache(tp);
3377  return result;
3378  }
3379  else
3380  return InvalidOid;
3381 }

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

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

◆ get_rel_name()

char* get_rel_name ( Oid  relid)

Definition at line 1910 of file lsyscache.c.

1911 {
1912  HeapTuple tp;
1913 
1914  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1915  if (HeapTupleIsValid(tp))
1916  {
1917  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1918  char *result;
1919 
1920  result = pstrdup(NameStr(reltup->relname));
1921  ReleaseSysCache(tp);
1922  return result;
1923  }
1924  else
1925  return NULL;
1926 }
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
@ RELOID
Definition: syscache.h:89

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

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_attnums(), AlterPublicationOptions(), AlterSubscription_refresh(), AlterTableNamespace(), ATExecAlterConstraint(), ATExecChangeOwner(), check_enable_rls(), check_new_partition_bound(), check_publications_origin(), cluster_is_permitted_for_relation(), convert_column_name(), CreateTriggerFiringOn(), DefineRelation(), do_autovacuum(), EnableDisableRule(), exec_object_restorecon(), ExecCheckPermissions(), 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(), InitializeApplyWorker(), InsertRule(), LockTableRecurse(), LockViewRecurse_walker(), make_modifytable(), makeWholeRowVar(), map_sql_schema_to_xmlschema_types(), MarkInheritDetached(), 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(), RemoveSubscriptionRel(), RenameConstraintById(), renametrig(), satisfies_hash_partition(), set_rtable_names(), show_modifytable_info(), SysCacheGetAttrNotNull(), table_to_xml_internal(), TargetPrivilegesCheck(), and transformAlterTableStmt().

◆ get_rel_namespace()

◆ get_rel_persistence()

char get_rel_persistence ( Oid  relid)

Definition at line 2060 of file lsyscache.c.

2061 {
2062  HeapTuple tp;
2063  Form_pg_class reltup;
2064  char result;
2065 
2066  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2067  if (!HeapTupleIsValid(tp))
2068  elog(ERROR, "cache lookup failed for relation %u", relid);
2069  reltup = (Form_pg_class) GETSTRUCT(tp);
2070  result = reltup->relpersistence;
2071  ReleaseSysCache(tp);
2072 
2073  return result;
2074 }

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

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

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

Definition at line 2009 of file lsyscache.c.

2010 {
2011  HeapTuple tp;
2012 
2013  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2014  if (HeapTupleIsValid(tp))
2015  {
2016  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2017  bool result;
2018 
2019  result = reltup->relispartition;
2020  ReleaseSysCache(tp);
2021  return result;
2022  }
2023  else
2024  return false;
2025 }

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

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

◆ get_rel_relkind()

char get_rel_relkind ( Oid  relid)

Definition at line 1985 of file lsyscache.c.

1986 {
1987  HeapTuple tp;
1988 
1989  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1990  if (HeapTupleIsValid(tp))
1991  {
1992  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1993  char result;
1994 
1995  result = reltup->relkind;
1996  ReleaseSysCache(tp);
1997  return result;
1998  }
1999  else
2000  return '\0';
2001 }

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

Referenced by AlterPublicationOptions(), AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), ATExecAlterColumnType(), ATExecAlterConstrRecurse(), ATExecChangeOwner(), check_rel_can_be_partition(), check_relation_privileges(), CreateSubscription(), CreateTriggerFiringOn(), doDeletion(), EnableDisableRule(), exec_object_restorecon(), ExecCheckPermissions(), get_object_type(), get_rel_sync_entry(), get_tables_to_cluster_partitioned(), getOwnedSequences_internal(), GetPubPartitionOptionRelations(), GetSchemaPublicationRelations(), 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(), RangeVarCallbackForLockTable(), RangeVarCallbackForPolicy(), RangeVarCallbackForReindexIndex(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackMaintainsTable(), RangeVarCallbackOwnsRelation(), RangeVarGetAndCheckCreationNamespace(), ReindexIndex(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), ReindexTable(), RelationBuildPartitionDesc(), renameatt_check(), RenameRelation(), 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().

◆ get_rel_tablespace()

Oid get_rel_tablespace ( Oid  relid)

Definition at line 2036 of file lsyscache.c.

2037 {
2038  HeapTuple tp;
2039 
2040  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2041  if (HeapTupleIsValid(tp))
2042  {
2043  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2044  Oid result;
2045 
2046  result = reltup->reltablespace;
2047  ReleaseSysCache(tp);
2048  return result;
2049  }
2050  else
2051  return InvalidOid;
2052 }

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

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

◆ get_rel_type_id()

Oid get_rel_type_id ( Oid  relid)

Definition at line 1961 of file lsyscache.c.

1962 {
1963  HeapTuple tp;
1964 
1965  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1966  if (HeapTupleIsValid(tp))
1967  {
1968  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1969  Oid result;
1970 
1971  result = reltup->reltype;
1972  ReleaseSysCache(tp);
1973  return result;
1974  }
1975  else
1976  return InvalidOid;
1977 }

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

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

◆ get_relname_relid()

◆ get_subscription_name()

char* get_subscription_name ( Oid  subid,
bool  missing_ok 
)

Definition at line 3653 of file lsyscache.c.

3654 {
3655  HeapTuple tup;
3656  char* subname;
3657  Form_pg_subscription subform;
3658 
3660 
3661  if (!HeapTupleIsValid(tup))
3662  {
3663  if (!missing_ok)
3664  elog(ERROR, "cache lookup failed for subscription %u", subid);
3665  return NULL;
3666  }
3667 
3668  subform = (Form_pg_subscription) GETSTRUCT(tup);
3669  subname = pstrdup(NameStr(subform->subname));
3670 
3671  ReleaseSysCache(tup);
3672 
3673  return subname;
3674 }
NameData subname
FormData_pg_subscription * Form_pg_subscription
@ SUBSCRIPTIONOID
Definition: syscache.h:99

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

Referenced by getObjectDescription(), getObjectIdentityParts(), and RemoveSubscriptionRel().

◆ get_subscription_oid()

Oid get_subscription_oid ( const char *  subname,
bool  missing_ok 
)

Definition at line 3633 of file lsyscache.c.

3634 {
3635  Oid oid;
3636 
3637  oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
3639  if (!OidIsValid(oid) && !missing_ok)
3640  ereport(ERROR,
3641  (errcode(ERRCODE_UNDEFINED_OBJECT),
3642  errmsg("subscription \"%s\" does not exist", subname)));
3643  return oid;
3644 }
Oid MyDatabaseId
Definition: globals.c:89
@ SUBSCRIPTIONNAME
Definition: syscache.h:98

References CStringGetDatum(), ereport, errcode(), errmsg(), ERROR, GetSysCacheOid2, MyDatabaseId, OidIsValid, subname, and SUBSCRIPTIONNAME.

Referenced by get_object_address_unqualified().

◆ get_transform_fromsql()

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

Definition at line 2080 of file lsyscache.c.

2081 {
2082  HeapTuple tup;
2083 
2084  if (!list_member_oid(trftypes, typid))
2085  return InvalidOid;
2086 
2087  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
2088  if (HeapTupleIsValid(tup))
2089  {
2090  Oid funcid;
2091 
2092  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2093  ReleaseSysCache(tup);
2094  return funcid;
2095  }
2096  else
2097  return InvalidOid;
2098 }
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:721
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:43
@ TRFTYPELANG
Definition: syscache.h:103

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().

◆ get_transform_tosql()

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

Definition at line 2101 of file lsyscache.c.

2102 {
2103  HeapTuple tup;
2104 
2105  if (!list_member_oid(trftypes, typid))
2106  return InvalidOid;
2107 
2108  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
2109  if (HeapTupleIsValid(tup))
2110  {
2111  Oid funcid;
2112 
2113  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
2114  ReleaseSysCache(tup);
2115  return funcid;
2116  }
2117  else
2118  return InvalidOid;
2119 }

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

Referenced by plperl_sv_to_datum(), and PLy_output_setup_func().

◆ get_typ_typrelid()

Oid get_typ_typrelid ( Oid  typid)

Definition at line 2689 of file lsyscache.c.

2690 {
2691  HeapTuple tp;
2692 
2694  if (HeapTupleIsValid(tp))
2695  {
2696  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2697  Oid result;
2698 
2699  result = typtup->typrelid;
2700  ReleaseSysCache(tp);
2701  return result;
2702  }
2703  else
2704  return InvalidOid;
2705 }

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

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

◆ get_typavgwidth()

int32 get_typavgwidth ( Oid  typid,
int32  typmod 
)

Definition at line 2536 of file lsyscache.c.

2537 {
2538  int typlen = get_typlen(typid);
2539  int32 maxwidth;
2540 
2541  /*
2542  * Easy if it's a fixed-width type
2543  */
2544  if (typlen > 0)
2545  return typlen;
2546 
2547  /*
2548  * type_maximum_size knows the encoding of typmod for some datatypes;
2549  * don't duplicate that knowledge here.
2550  */
2551  maxwidth = type_maximum_size(typid, typmod);
2552  if (maxwidth > 0)
2553  {
2554  /*
2555  * For BPCHAR, the max width is also the only width. Otherwise we
2556  * need to guess about the typical data width given the max. A sliding
2557  * scale for percentage of max width seems reasonable.
2558  */
2559  if (typid == BPCHAROID)
2560  return maxwidth;
2561  if (maxwidth <= 32)
2562  return maxwidth; /* assume full width */
2563  if (maxwidth < 1000)
2564  return 32 + (maxwidth - 32) / 2; /* assume 50% */
2565 
2566  /*
2567  * Beyond 1000, assume we're looking at something like
2568  * "varchar(10000)" where the limit isn't actually reached often, and
2569  * use a fixed estimate.
2570  */
2571  return 32 + (1000 - 32) / 2;
2572  }
2573 
2574  /*
2575  * Oops, we have no idea ... wild guess time.
2576  */
2577  return 32;
2578 }
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:408
int16 get_typlen(Oid typid)
Definition: lsyscache.c:2155

References get_typlen(), and type_maximum_size().

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

◆ get_typbyval()

bool get_typbyval ( Oid  typid)

Definition at line 2180 of file lsyscache.c.

2181 {
2182  HeapTuple tp;
2183 
2185  if (HeapTupleIsValid(tp))
2186  {
2187  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2188  bool result;
2189 
2190  result = typtup->typbyval;
2191  ReleaseSysCache(tp);
2192  return result;
2193  }
2194  else
2195  return false;
2196 }

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

Referenced by brin_range_deserialize(), and brin_range_serialize().

◆ get_typcollation()

◆ get_typdefault()

Node* get_typdefault ( Oid  typid)

Definition at line 2406 of file lsyscache.c.

2407 {
2408  HeapTuple typeTuple;
2410  Datum datum;
2411  bool isNull;
2412  Node *expr;
2413 
2414  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2415  if (!HeapTupleIsValid(typeTuple))
2416  elog(ERROR, "cache lookup failed for type %u", typid);
2417  type = (Form_pg_type) GETSTRUCT(typeTuple);
2418 
2419  /*
2420  * typdefault and typdefaultbin are potentially null, so don't try to
2421  * access 'em as struct fields. Must do it the hard way with
2422  * SysCacheGetAttr.
2423  */
2424  datum = SysCacheGetAttr(TYPEOID,
2425  typeTuple,
2426  Anum_pg_type_typdefaultbin,
2427  &isNull);
2428 
2429  if (!isNull)
2430  {
2431  /* We have an expression default */
2432  expr = stringToNode(TextDatumGetCString(datum));
2433  }
2434  else
2435  {
2436  /* Perhaps we have a plain literal default */
2437  datum = SysCacheGetAttr(TYPEOID,
2438  typeTuple,
2439  Anum_pg_type_typdefault,
2440  &isNull);
2441 
2442  if (!isNull)
2443  {
2444  char *strDefaultVal;
2445 
2446  /* Convert text datum to C string */
2447  strDefaultVal = TextDatumGetCString(datum);
2448  /* Convert C string to a value of the given type */
2449  datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2450  getTypeIOParam(typeTuple), -1);
2451  /* Build a Const node containing the value */
2452  expr = (Node *) makeConst(typid,
2453  -1,
2454  type->typcollation,
2455  type->typlen,
2456  datum,
2457  false,
2458  type->typbyval);
2459  pfree(strDefaultVal);
2460  }
2461  else
2462  {
2463  /* No default */
2464  expr = NULL;
2465  }
2466  }
2467 
2468  ReleaseSysCache(typeTuple);
2469 
2470  return expr;
2471 }
#define TextDatumGetCString(d)
Definition: builtins.h:95
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1726
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2261
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:302
void * stringToNode(const char *str)
Definition: read.c:90
Definition: nodes.h:129

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().

◆ get_type_category_preferred()

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

Definition at line 2668 of file lsyscache.c.

2669 {
2670  HeapTuple tp;
2671  Form_pg_type typtup;
2672 
2674  if (!HeapTupleIsValid(tp))
2675  elog(ERROR, "cache lookup failed for type %u", typid);
2676  typtup = (Form_pg_type) GETSTRUCT(tp);
2677  *typcategory = typtup->typcategory;
2678  *typispreferred = typtup->typispreferred;
2679  ReleaseSysCache(tp);
2680 }

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

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

◆ 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 2283 of file lsyscache.c.

2291 {
2292  HeapTuple typeTuple;
2293  Form_pg_type typeStruct;
2294 
2295  /*
2296  * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2297  * use array_in and array_out during bootstrap.
2298  */
2300  {
2301  Oid typinput;
2302  Oid typoutput;
2303 
2304  boot_get_type_io_data(typid,
2305  typlen,
2306  typbyval,
2307  typalign,
2308  typdelim,
2309  typioparam,
2310  &typinput,
2311  &typoutput);
2312  switch (which_func)
2313  {
2314  case IOFunc_input:
2315  *func = typinput;
2316  break;
2317  case IOFunc_output:
2318  *func = typoutput;
2319  break;
2320  default:
2321  elog(ERROR, "binary I/O not supported during bootstrap");
2322  break;
2323  }
2324  return;
2325  }
2326 
2327  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2328  if (!HeapTupleIsValid(typeTuple))
2329  elog(ERROR, "cache lookup failed for type %u", typid);
2330  typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2331 
2332  *typlen = typeStruct->typlen;
2333  *typbyval = typeStruct->typbyval;
2334  *typalign = typeStruct->typalign;
2335  *typdelim = typeStruct->typdelim;
2336  *typioparam = getTypeIOParam(typeTuple);
2337  switch (which_func)
2338  {
2339  case IOFunc_input:
2340  *func = typeStruct->typinput;
2341  break;
2342  case IOFunc_output:
2343  *func = typeStruct->typoutput;
2344  break;
2345  case IOFunc_receive:
2346  *func = typeStruct->typreceive;
2347  break;
2348  case IOFunc_send:
2349  *func = typeStruct->typsend;
2350  break;
2351  }
2352  ReleaseSysCache(typeTuple);
2353 }
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:820
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:405
char typalign
Definition: pg_type.h:176

References boot_get_type_io_data(), elog(), ERROR, GETSTRUCT, getTypeIOParam(), HeapTupleIsValid, IOFunc_input, IOFunc_output, IOFunc_receive, IOFunc_send, IsBootstrapProcessingMode, ObjectIdGetDatum(), ReleaseSysCache(), SearchSysCache1(), typalign, 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().

◆ get_typisdefined()

bool get_typisdefined ( Oid  typid)

Definition at line 2131 of file lsyscache.c.

2132 {
2133  HeapTuple tp;
2134 
2136  if (HeapTupleIsValid(tp))
2137  {
2138  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2139  bool result;
2140 
2141  result = typtup->typisdefined;
2142  ReleaseSysCache(tp);
2143  return result;
2144  }
2145  else
2146  return false;
2147 }

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

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

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2155 of file lsyscache.c.

2156 {
2157  HeapTuple tp;
2158 
2160  if (HeapTupleIsValid(tp))
2161  {
2162  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2163  int16 result;
2164 
2165  result = typtup->typlen;
2166  ReleaseSysCache(tp);
2167  return result;
2168  }
2169  else
2170  return 0;
2171 }

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

Referenced by array_exec_setup(), brin_range_deserialize(), brin_range_serialize(), build_sorted_items(), DefineType(), ExecBuildProjectionInfo(), ExecInitCoerceToDomain(), ExecInitExprRec(), get_typavgwidth(), pg_column_compression(), pg_column_size(), and postquel_sub_params().

◆ get_typlenbyval()

◆ get_typlenbyvalalign()

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 2964 of file lsyscache.c.

2965 {
2966  HeapTuple tp;
2967 
2969  if (HeapTupleIsValid(tp))
2970  {
2971  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2972  Oid result;
2973 
2974  result = typtup->typmodin;
2975  ReleaseSysCache(tp);
2976  return result;
2977  }
2978  else
2979  return InvalidOid;
2980 }

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2377 of file lsyscache.c.

2378 {
2379  HeapTuple tp;
2380 
2382  if (HeapTupleIsValid(tp))
2383  {
2384  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2385  char result;
2386 
2387  result = typtup->typstorage;
2388  ReleaseSysCache(tp);
2389  return result;
2390  }
2391  else
2392  return TYPSTORAGE_PLAIN;
2393 }

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

Referenced by GetAttributeStorage().

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3055 of file lsyscache.c.

3056 {
3057  HeapTuple tp;
3058 
3060  if (HeapTupleIsValid(tp))
3061  {
3062  Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
3063  RegProcedure handler = typform->typsubscript;
3064 
3065  if (typelemp)
3066  *typelemp = typform->typelem;
3067  ReleaseSysCache(tp);
3068  return handler;
3069  }
3070  else
3071  {
3072  if (typelemp)
3073  *typelemp = InvalidOid;
3074  return InvalidOid;
3075  }
3076 }

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

Referenced by exec_check_rw_parameter(), and getSubscriptingRoutines().

◆ get_typtype()

char get_typtype ( Oid  typid)

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2496 of file lsyscache.c.

2497 {
2498  /*
2499  * We loop to find the bottom base type in a stack of domains.
2500  */
2501  for (;;)
2502  {
2503  HeapTuple tup;
2504  Form_pg_type typTup;
2505 
2506  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2507  if (!HeapTupleIsValid(tup))
2508  elog(ERROR, "cache lookup failed for type %u", typid);
2509  typTup = (Form_pg_type) GETSTRUCT(tup);
2510  if (typTup->typtype != TYPTYPE_DOMAIN)
2511  {
2512  /* Not a domain, so done */
2513  ReleaseSysCache(tup);
2514  break;
2515  }
2516 
2517  Assert(*typmod == -1);
2518  typid = typTup->typbasetype;
2519  *typmod = typTup->typtypmod;
2520 
2521  ReleaseSysCache(tup);
2522  }
2523 
2524  return typid;
2525 }

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(), SendRowDescriptionMessage(), transformAssignmentIndirection(), transformContainerType(), and transformTypeCast().

◆ getSubscriptingRoutines()

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

Definition at line 3088 of file lsyscache.c.

3089 {
3090  RegProcedure typsubscript = get_typsubscript(typid, typelemp);
3091 
3092  if (!OidIsValid(typsubscript))
3093  return NULL;
3094 
3095  return (const struct SubscriptRoutines *)
3096  DatumGetPointer(OidFunctionCall0(typsubscript));
3097 }
#define OidFunctionCall0(functionId)
Definition: fmgr.h:678
RegProcedure get_typsubscript(Oid typid, Oid *typelemp)
Definition: lsyscache.c:3055

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

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

◆ getTypeBinaryInputInfo()

void getTypeBinaryInputInfo ( Oid  type,
Oid typReceive,
Oid typIOParam 
)

Definition at line 2898 of file lsyscache.c.

2899 {
2900  HeapTuple typeTuple;
2901  Form_pg_type pt;
2902 
2904  if (!HeapTupleIsValid(typeTuple))
2905  elog(ERROR, "cache lookup failed for type %u", type);
2906  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2907 
2908  if (!pt->typisdefined)
2909  ereport(ERROR,
2910  (errcode(ERRCODE_UNDEFINED_OBJECT),
2911  errmsg("type %s is only a shell",
2912  format_type_be(type))));
2913  if (!OidIsValid(pt->typreceive))
2914  ereport(ERROR,
2915  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2916  errmsg("no binary input function available for type %s",
2917  format_type_be(type))));
2918 
2919  *typReceive = pt->typreceive;
2920  *typIOParam = getTypeIOParam(typeTuple);
2921 
2922  ReleaseSysCache(typeTuple);
2923 }

References elog(), ereport, errcode(), errmsg(), ERROR, format_type_be(), GETSTRUCT, getTypeIOParam(), HeapTupleIsValid, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), SearchSysCache1(), generate_unaccent_rules::type, and TYPEOID.

Referenced by array_agg_deserialize(), BeginCopyFrom(), domain_state_setup(), exec_bind_message(), parse_fcall_arguments(), record_recv(), slot_modify_data(), and slot_store_data().

◆ getTypeBinaryOutputInfo()

void getTypeBinaryOutputInfo ( Oid  type,
Oid typSend,
bool typIsVarlena 
)

Definition at line 2931 of file lsyscache.c.

2932 {
2933  HeapTuple typeTuple;
2934  Form_pg_type pt;
2935 
2937  if (!HeapTupleIsValid(typeTuple))
2938  elog(ERROR, "cache lookup failed for type %u", type);
2939  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2940 
2941  if (!pt->typisdefined)
2942  ereport(ERROR,
2943  (errcode(ERRCODE_UNDEFINED_OBJECT),
2944  errmsg("type %s is only a shell",
2945  format_type_be(type))));
2946  if (!OidIsValid(pt->typsend))
2947  ereport(ERROR,
2948  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2949  errmsg("no binary output function available for type %s",
2950  format_type_be(type))));
2951 
2952  *typSend = pt->typsend;
2953  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2954 
2955  ReleaseSysCache(typeTuple);
2956 }

References elog(), ereport, errcode(), errmsg(), ERROR, format_type_be(), GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), SearchSysCache1(), generate_unaccent_rules::type, and TYPEOID.

Referenced by array_agg_serialize(), DoCopyTo(), printtup_prepare_info(), record_send(), and SendFunctionResult().

◆ getTypeInputInfo()

void getTypeInputInfo ( Oid  type,
Oid typInput,
Oid typIOParam 
)

Definition at line 2832 of file lsyscache.c.

2833 {
2834  HeapTuple typeTuple;
2835  Form_pg_type pt;
2836 
2838  if (!HeapTupleIsValid(typeTuple))
2839  elog(ERROR, "cache lookup failed for type %u", type);
2840  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2841 
2842  if (!pt->typisdefined)
2843  ereport(ERROR,
2844  (errcode(ERRCODE_UNDEFINED_OBJECT),
2845  errmsg("type %s is only a shell",
2846  format_type_be(type))));
2847  if (!OidIsValid(pt->typinput))
2848  ereport(ERROR,
2849  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2850  errmsg("no input function available for type %s",
2851  format_type_be(type))));
2852 
2853  *typInput = pt->typinput;
2854  *typIOParam = getTypeIOParam(typeTuple);
2855 
2856  ReleaseSysCache(typeTuple);
2857 }

References elog(), ereport, errcode(), errmsg(), ERROR, format_type_be(), GETSTRUCT, getTypeIOParam(), HeapTupleIsValid, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), SearchSysCache1(), generate_unaccent_rules::type, and TYPEOID.

Referenced by _sv_to_datum_finfo(), BeginCopyFrom(), check_functions_in_node(), cost_qual_eval_walker(), DefineAggregate(), domain_state_setup(), eval_const_expressions_mutator(), exec_bind_message(), ExecInitExprRec(), ExecInitTableFuncScan(), GetAggInitVal(), hstore_populate_record(), parse_fcall_arguments(), pg_input_is_valid_common(), plperl_spi_prepare(), pltcl_SPI_prepare(), PLy_output_setup_func(), prepare_column_cache(), record_in(), slot_modify_data(), slot_store_data(), and TupleDescGetAttInMetadata().

◆ getTypeIOParam()

Oid getTypeIOParam ( HeapTuple  typeTuple)

Definition at line 2261 of file lsyscache.c.

2262 {
2263  Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2264 
2265  /*
2266  * Array types get their typelem as parameter; everybody else gets their
2267  * own type OID as parameter.
2268  */
2269  if (OidIsValid(typeStruct->typelem))
2270  return typeStruct->typelem;
2271  else
2272  return typeStruct->oid;
2273 }

References GETSTRUCT, and OidIsValid.

Referenced by compile_plperl_function(), compile_pltcl_function(), get_typdefault(), get_type_io_data(), getTypeBinaryInputInfo(), getTypeInputInfo(), plsample_func_handler(), and stringTypeDatum().

◆ getTypeOutputInfo()

void getTypeOutputInfo ( Oid  type,
Oid typOutput,
bool typIsVarlena 
)

Definition at line 2865 of file lsyscache.c.

2866 {
2867  HeapTuple typeTuple;
2868  Form_pg_type pt;
2869 
2871  if (!HeapTupleIsValid(typeTuple))
2872  elog(ERROR, "cache lookup failed for type %u", type);
2873  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2874 
2875  if (!pt->typisdefined)
2876  ereport(ERROR,
2877  (errcode(ERRCODE_UNDEFINED_OBJECT),
2878  errmsg("type %s is only a shell",
2879  format_type_be(type))));
2880  if (!OidIsValid(pt->typoutput))
2881  ereport(ERROR,
2882  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2883  errmsg("no output function available for type %s",
2884  format_type_be(type))));
2885 
2886  *typOutput = pt->typoutput;
2887  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2888 
2889  ReleaseSysCache(typeTuple);
2890 }

References elog(), ereport, errcode(), errmsg(), ERROR, format_type_be(), GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), SearchSysCache1(), generate_unaccent_rules::type, and TYPEOID.

Referenced by brin_minmax_multi_summary_out(), brin_page_items(), build_concat_foutcache(), BuildIndexValueDescription(), BuildParamLogString(), check_functions_in_node(), convert_value_to_string(), cost_qual_eval_walker(), create_foreign_modify(), debugtup(), deparseConst(), DoCopyTo(), eval_const_expressions_mutator(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), ExecInitExprRec(), get_const_expr(), hstore_from_record(), json_categorize_type(), jsonb_categorize_type(), map_sql_value_to_xml_value(), pg_stats_ext_mcvlist_items(), plperl_hash_from_tuple(), plperl_sv_to_literal(), pltcl_build_tuple_argument(), pltcl_set_tuple_values(), PLy_input_setup_func(), prepare_query_params(), print_expr(), printtup_prepare_info(), record_out(), ri_ReportViolation(), SendFunctionResult(), set_limit(), SPI_getvalue(), text_format(), and tuple_to_stringinfo().

◆ op_hashjoinable()

bool op_hashjoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1419 of file lsyscache.c.

1420 {
1421  bool result = false;
1422  HeapTuple tp;
1423  TypeCacheEntry *typentry;
1424 
1425  /* As in op_mergejoinable, let the typcache handle the hard cases */
1426  if (opno == ARRAY_EQ_OP)
1427  {
1428  typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1429  if (typentry->hash_proc == F_HASH_ARRAY)
1430  result = true;
1431  }
1432  else if (opno == RECORD_EQ_OP)
1433  {
1434  typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1435  if (typentry->hash_proc == F_HASH_RECORD)
1436  result = true;
1437  }
1438  else
1439  {
1440  /* For all other operators, rely on pg_operator.oprcanhash */
1442  if (HeapTupleIsValid(tp))
1443  {
1445 
1446  result = optup->oprcanhash;
1447  ReleaseSysCache(tp);
1448  }
1449  }
1450  return result;
1451 }
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:339
#define TYPECACHE_HASH_PROC
Definition: typcache.h:140

References GETSTRUCT, TypeCacheEntry::hash_proc, HeapTupleIsValid, lookup_type_cache(), ObjectIdGetDatum(), OPEROID, ReleaseSysCache(), SearchSysCache1(), and TYPECACHE_HASH_PROC.

Referenced by addTargetToSortList(), check_hashjoinable(), compute_semijoin_info(), generate_join_implied_equalities_normal(), and hash_ok_operator().

◆ op_in_opfamily()

◆ op_input_types()

void op_input_types ( Oid  opno,
Oid lefttype,
Oid righttype 
)

Definition at line 1340 of file lsyscache.c.

1341 {
1342  HeapTuple tp;
1343  Form_pg_operator optup;
1344 
1346  if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1347  elog(ERROR, "cache lookup failed for operator %u", opno);
1348  optup = (Form_pg_operator) GETSTRUCT(tp);
1349  *lefttype = optup->oprleft;
1350  *righttype = optup->oprright;
1351  ReleaseSysCache(tp);
1352 }

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

Referenced by CheckIndexCompatible(), initialize_mergeclause_eclasses(), process_equivalence(), reconsider_full_join_clause(), reconsider_outer_join_clause(), and ri_HashCompareOp().

◆ op_mergejoinable()

bool op_mergejoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1368 of file lsyscache.c.

1369 {
1370  bool result = false;
1371  HeapTuple tp;
1372  TypeCacheEntry *typentry;
1373 
1374  /*
1375  * For array_eq or record_eq, we can sort if the element or field types
1376  * are all sortable. We could implement all the checks for that here, but
1377  * the typcache already does that and caches the results too, so let's
1378  * rely on the typcache.
1379  */
1380  if (opno == ARRAY_EQ_OP)
1381  {
1382  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1383  if (typentry->cmp_proc == F_BTARRAYCMP)
1384  result = true;
1385  }
1386  else if (opno == RECORD_EQ_OP)
1387  {
1388  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1389  if (typentry->cmp_proc == F_BTRECORDCMP)
1390  result = true;
1391  }
1392  else
1393  {
1394  /* For all other operators, rely on pg_operator.oprcanmerge */
1396  if (HeapTupleIsValid(tp))
1397  {
1399 
1400  result = optup->oprcanmerge;
1401  ReleaseSysCache(tp);
1402  }
1403  }
1404  return result;
1405 }
#define TYPECACHE_CMP_PROC
Definition: typcache.h:139

References TypeCacheEntry::cmp_proc, GETSTRUCT, HeapTupleIsValid, lookup_type_cache(), ObjectIdGetDatum(), OPEROID, ReleaseSysCache(), SearchSysCache1(), and TYPECACHE_CMP_PROC.

Referenced by check_mergejoinable(), and compute_semijoin_info().

◆ op_strict()

bool op_strict ( Oid  opno)

Definition at line 1459 of file lsyscache.c.

1460 {
1461  RegProcedure funcid = get_opcode(opno);
1462 
1463  if (funcid == (RegProcedure) InvalidOid)
1464  elog(ERROR, "operator %u does not exist", opno);
1465 
1466  return func_strict((Oid) funcid);
1467 }
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1267
bool func_strict(Oid funcid)
Definition: lsyscache.c:1743

References elog(), ERROR, func_strict(), get_opcode(), and InvalidOid.

Referenced by clause_is_strict_for(), ExecHashTableCreate(), have_partkey_equi_join(), match_clause_to_partition_key(), and operator_predicate_proof().

◆ op_volatile()

char op_volatile ( Oid  opno)

Definition at line 1475 of file lsyscache.c.

1476 {
1477  RegProcedure funcid = get_opcode(opno);
1478 
1479  if (funcid == (RegProcedure) InvalidOid)
1480  elog(ERROR, "operator %u does not exist", opno);
1481 
1482  return func_volatile((Oid) funcid);
1483 }
char func_volatile(Oid funcid)
Definition: lsyscache.c:1762

References elog(), ERROR, func_volatile(), get_opcode(), and InvalidOid.

Referenced by lookup_proof_cache(), and match_clause_to_partition_key().

◆ type_is_collatable()

◆ type_is_enum()

bool type_is_enum ( Oid  typid)

Definition at line 2636 of file lsyscache.c.

2637 {
2638  return (get_typtype(typid) == TYPTYPE_ENUM);
2639 }
char get_typtype(Oid typid)
Definition: lsyscache.c:2587

References get_typtype().

Referenced by check_generic_type_consistency(), enforce_generic_type_consistency(), and IsBinaryCoercibleWithCast().

◆ type_is_multirange()

bool type_is_multirange ( Oid  typid)

Definition at line 2656 of file lsyscache.c.

2657 {
2658  return (get_typtype(typid) == TYPTYPE_MULTIRANGE);
2659 }

References get_typtype().

Referenced by IsBinaryCoercibleWithCast(), multirange_agg_transfn(), and multirange_intersect_agg_transfn().

◆ type_is_range()

bool type_is_range ( Oid  typid)

Definition at line 2646 of file lsyscache.c.

2647 {
2648  return (get_typtype(typid) == TYPTYPE_RANGE);
2649 }

References get_typtype().

Referenced by IsBinaryCoercibleWithCast(), range_agg_transfn(), and range_intersect_agg_transfn().

◆ type_is_rowtype()

bool type_is_rowtype ( Oid  typid)

Definition at line 2613 of file lsyscache.c.

2614 {
2615  if (typid == RECORDOID)
2616  return true; /* easy case */
2617  switch (get_typtype(typid))
2618  {
2619  case TYPTYPE_COMPOSITE:
2620  return true;
2621  case TYPTYPE_DOMAIN:
2622  if (get_typtype(getBaseType(typid)) == TYPTYPE_COMPOSITE)
2623  return true;
2624  break;
2625  default:
2626  break;
2627  }
2628  return false;
2629 }
Oid getBaseType(Oid typid)
Definition: lsyscache.c:2479

References get_typtype(), and getBaseType().

Referenced by build_datatype(), can_minmax_aggs(), coerce_function_result_tuple(), compile_plperl_function(), compile_pltcl_function(), deparseNullTest(), do_compile(), exec_assign_value(), exec_stmt_return(), exec_stmt_return_next(), ExecMakeTableFunctionResult(), get_rule_expr(), hstore_populate_record(), init_sql_fcache(), json_categorize_type(), jsonb_categorize_type(), makeWholeRowVar(), plperl_hash_from_tuple(), plperl_ref_from_pg_array(), plperl_sv_to_datum(), plpgsql_exec_trigger(), and transformExprRecurse().

Variable Documentation

◆ get_attavgwidth_hook

PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook
extern

Definition at line 52 of file lsyscache.c.

Referenced by get_attavgwidth().