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

Go to the source code of this file.

Data Structures

struct  OpBtreeInterpretation
 
struct  AttStatsSlot
 

Macros

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

Typedefs

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

Enumerations

enum  IOFuncSelector { IOFunc_input , IOFunc_output , IOFunc_receive , IOFunc_send }
 

Functions

bool op_in_opfamily (Oid opno, Oid opfamily)
 
int get_op_opfamily_strategy (Oid opno, Oid opfamily)
 
Oid get_op_opfamily_sortfamily (Oid opno, Oid opfamily)
 
void get_op_opfamily_properties (Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
 
Oid get_opfamily_member (Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
 
bool get_ordering_op_properties (Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
 
Oid get_equality_op_for_ordering_op (Oid opno, bool *reverse)
 
Oid get_ordering_op_for_equality_op (Oid opno, bool use_lhs_type)
 
Listget_mergejoin_opfamilies (Oid opno)
 
bool get_compatible_hash_operators (Oid opno, Oid *lhs_opno, Oid *rhs_opno)
 
bool get_op_hash_functions (Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
 
Listget_op_btree_interpretation (Oid opno)
 
bool equality_ops_are_compatible (Oid opno1, Oid opno2)
 
bool comparison_ops_are_compatible (Oid opno1, Oid opno2)
 
Oid get_opfamily_proc (Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
 
char * get_attname (Oid relid, AttrNumber attnum, bool missing_ok)
 
AttrNumber get_attnum (Oid relid, const char *attname)
 
char get_attgenerated (Oid relid, AttrNumber attnum)
 
Oid get_atttype (Oid relid, AttrNumber attnum)
 
void get_atttypetypmodcoll (Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
 
Datum get_attoptions (Oid relid, int16 attnum)
 
Oid get_cast_oid (Oid sourcetypeid, Oid targettypeid, bool missing_ok)
 
char * get_collation_name (Oid colloid)
 
bool get_collation_isdeterministic (Oid colloid)
 
char * get_constraint_name (Oid conoid)
 
Oid get_constraint_index (Oid conoid)
 
char * get_language_name (Oid langoid, bool missing_ok)
 
Oid get_opclass_family (Oid opclass)
 
Oid get_opclass_input_type (Oid opclass)
 
bool get_opclass_opfamily_and_input_type (Oid opclass, Oid *opfamily, Oid *opcintype)
 
Oid get_opclass_method (Oid opclass)
 
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 749 of file lsyscache.c.

750 {
751  bool result;
752  CatCList *catlist;
753  int i;
754 
755  /* Easy if they're the same operator */
756  if (opno1 == opno2)
757  return true;
758 
759  /*
760  * We search through all the pg_amop entries for opno1.
761  */
762  catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
763 
764  result = false;
765  for (i = 0; i < catlist->n_members; i++)
766  {
767  HeapTuple op_tuple = &catlist->members[i]->tuple;
768  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
769 
770  if (op_form->amopmethod == BTREE_AM_OID)
771  {
772  if (op_in_opfamily(opno2, op_form->amopfamily))
773  {
774  result = true;
775  break;
776  }
777  }
778  }
779 
780  ReleaseSysCacheList(catlist);
781 
782  return result;
783 }
#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:66
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
#define ReleaseSysCacheList(x)
Definition: syscache.h:129
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:122

References 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 698 of file lsyscache.c.

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

References 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 3300 of file lsyscache.c.

3301 {
3302  /* The values[] array was separately palloc'd by deconstruct_array */
3303  if (sslot->values)
3304  pfree(sslot->values);
3305  /* The numbers[] array points into numbers_arr, do not pfree it */
3306  /* Free the detoasted array objects, if any */
3307  if (sslot->values_arr)
3308  pfree(sslot->values_arr);
3309  if (sslot->numbers_arr)
3310  pfree(sslot->numbers_arr);
3311 }
void pfree(void *pointer)
Definition: mcxt.c:1401
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_array_length(), 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 1777 of file lsyscache.c.

1778 {
1779  HeapTuple tp;
1780  char result;
1781 
1782  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1783  if (!HeapTupleIsValid(tp))
1784  elog(ERROR, "cache lookup failed for function %u", funcid);
1785 
1786  result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1787  ReleaseSysCache(tp);
1788  return result;
1789 }
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:224
#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:266
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:218

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

Referenced by max_parallel_hazard_checker(), and set_rel_consider_parallel().

◆ func_strict()

bool func_strict ( Oid  funcid)

Definition at line 1739 of file lsyscache.c.

1740 {
1741  HeapTuple tp;
1742  bool result;
1743 
1744  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1745  if (!HeapTupleIsValid(tp))
1746  elog(ERROR, "cache lookup failed for function %u", funcid);
1747 
1748  result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
1749  ReleaseSysCache(tp);
1750  return result;
1751 }

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum(), 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 2743 of file lsyscache.c.

2744 {
2745  HeapTuple tp;
2746  Oid result = InvalidOid;
2747 
2748  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2749  if (HeapTupleIsValid(tp))
2750  {
2751  result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
2752  ReleaseSysCache(tp);
2753  }
2754  return result;
2755 }
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

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

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

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 3114 of file lsyscache.c.

3115 {
3116  HeapTuple tp;
3117  int32 stawidth;
3118 
3120  {
3121  stawidth = (*get_attavgwidth_hook) (relid, attnum);
3122  if (stawidth > 0)
3123  return stawidth;
3124  }
3125  tp = SearchSysCache3(STATRELATTINH,
3126  ObjectIdGetDatum(relid),
3128  BoolGetDatum(false));
3129  if (HeapTupleIsValid(tp))
3130  {
3131  stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3132  ReleaseSysCache(tp);
3133  if (stawidth > 0)
3134  return stawidth;
3135  }
3136  return 0;
3137 }
signed int int32
Definition: c.h:481
get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:53
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:240

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

Referenced by get_rel_data_width(), and set_rel_width().

◆ get_attgenerated()

char get_attgenerated ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 888 of file lsyscache.c.

889 {
890  HeapTuple tp;
891  Form_pg_attribute att_tup;
892  char result;
893 
894  tp = SearchSysCache2(ATTNUM,
895  ObjectIdGetDatum(relid),
897  if (!HeapTupleIsValid(tp))
898  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
899  attnum, relid);
900  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
901  result = att_tup->attgenerated;
902  ReleaseSysCache(tp);
903  return result;
904 }
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:209
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:229

References 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 827 of file lsyscache.c.

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

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

Referenced by AddRelationNewConstraints(), AddRelationNotNullConstraints(), AdjustNotNullInheritance(), AttachPartitionEnsureIndexes(), check_nested_generated_walker(), ComputePartitionAttrs(), contain_invalid_rfcolumn_walker(), CreateStatistics(), decompile_column_index_array(), deparseColumnRef(), dropconstraint_internal(), errtablecol(), fixup_inherited_columns(), generateClonedExtStatsStmt(), generateClonedIndexStmt(), get_insert_query_def(), get_merge_query_def(), get_rte_attribute_name(), get_update_query_targetlist_def(), getObjectDescription(), getObjectIdentityParts(), MergeConstraintsIntoExisting(), 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(), RelationGetNotNullConstraints(), RememberAllDependentForRebuilding(), set_attnotnull(), transformPartitionBound(), and transformPartitionRangeBounds().

◆ get_attnum()

◆ get_attoptions()

Datum get_attoptions ( Oid  relid,
int16  attnum 
)

Definition at line 970 of file lsyscache.c.

971 {
972  HeapTuple tuple;
973  Datum attopts;
974  Datum result;
975  bool isnull;
976 
977  tuple = SearchSysCache2(ATTNUM,
978  ObjectIdGetDatum(relid),
980 
981  if (!HeapTupleIsValid(tuple))
982  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
983  attnum, relid);
984 
985  attopts = SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions,
986  &isnull);
987 
988  if (isnull)
989  result = (Datum) 0;
990  else
991  result = datumCopy(attopts, false, -1); /* text[] */
992 
993  ReleaseSysCache(tuple);
994 
995  return result;
996 }
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:479

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

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

◆ get_attstatsslot()

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

Definition at line 3190 of file lsyscache.c.

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

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

Oid get_atttype ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 913 of file lsyscache.c.

914 {
915  HeapTuple tp;
916 
917  tp = SearchSysCache2(ATTNUM,
918  ObjectIdGetDatum(relid),
920  if (HeapTupleIsValid(tp))
921  {
923  Oid result;
924 
925  result = att_tup->atttypid;
926  ReleaseSysCache(tp);
927  return result;
928  }
929  else
930  return InvalidOid;
931 }

References 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 943 of file lsyscache.c.

945 {
946  HeapTuple tp;
947  Form_pg_attribute att_tup;
948 
949  tp = SearchSysCache2(ATTNUM,
950  ObjectIdGetDatum(relid),
952  if (!HeapTupleIsValid(tp))
953  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
954  attnum, relid);
955  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
956 
957  *typid = att_tup->atttypid;
958  *typmod = att_tup->atttypmod;
959  *collid = att_tup->attcollation;
960  ReleaseSysCache(tp);
961 }
Oid collid

References 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 2788 of file lsyscache.c.

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

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

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

1008 {
1009  Oid oid;
1010 
1011  oid = GetSysCacheOid2(CASTSOURCETARGET, Anum_pg_cast_oid,
1012  ObjectIdGetDatum(sourcetypeid),
1013  ObjectIdGetDatum(targettypeid));
1014  if (!OidIsValid(oid) && !missing_ok)
1015  ereport(ERROR,
1016  (errcode(ERRCODE_UNDEFINED_OBJECT),
1017  errmsg("cast from type %s to type %s does not exist",
1018  format_type_be(sourcetypeid),
1019  format_type_be(targettypeid))));
1020  return oid;
1021 }
#define OidIsValid(objectId)
Definition: c.h:762
int errcode(int sqlerrcode)
Definition: elog.c:859
int errmsg(const char *fmt,...)
Definition: elog.c:1072
#define ereport(elevel,...)
Definition: elog.h:149
char * format_type_be(Oid type_oid)
Definition: format_type.c:343
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
Definition: syscache.h:106

References 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 1054 of file lsyscache.c.

1055 {
1056  HeapTuple tp;
1057  Form_pg_collation colltup;
1058  bool result;
1059 
1060  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1061  if (!HeapTupleIsValid(tp))
1062  elog(ERROR, "cache lookup failed for collation %u", colloid);
1063  colltup = (Form_pg_collation) GETSTRUCT(tp);
1064  result = colltup->collisdeterministic;
1065  ReleaseSysCache(tp);
1066  return result;
1067 }
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:58

References 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 1035 of file lsyscache.c.

1036 {
1037  HeapTuple tp;
1038 
1039  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1040  if (HeapTupleIsValid(tp))
1041  {
1043  char *result;
1044 
1045  result = pstrdup(NameStr(colltup->collname));
1046  ReleaseSysCache(tp);
1047  return result;
1048  }
1049  else
1050  return NULL;
1051 }

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

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

◆ get_commutator()

Oid get_commutator ( Oid  opno)

◆ get_compatible_hash_operators()

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

Definition at line 410 of file lsyscache.c.

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

References 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 1113 of file lsyscache.c.

1114 {
1115  HeapTuple tp;
1116 
1117  tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
1118  if (HeapTupleIsValid(tp))
1119  {
1121  Oid result;
1122 
1123  if (contup->contype == CONSTRAINT_UNIQUE ||
1124  contup->contype == CONSTRAINT_PRIMARY ||
1125  contup->contype == CONSTRAINT_EXCLUSION)
1126  result = contup->conindid;
1127  else
1128  result = InvalidOid;
1129  ReleaseSysCache(tp);
1130  return result;
1131  }
1132  else
1133  return InvalidOid;
1134 }
FormData_pg_constraint * Form_pg_constraint

References 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 1081 of file lsyscache.c.

1082 {
1083  HeapTuple tp;
1084 
1085  tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
1086  if (HeapTupleIsValid(tp))
1087  {
1089  char *result;
1090 
1091  result = pstrdup(NameStr(contup->conname));
1092  ReleaseSysCache(tp);
1093  return result;
1094  }
1095  else
1096  return NULL;
1097 }

References 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 267 of file lsyscache.c.

268 {
269  Oid result = InvalidOid;
270  Oid opfamily;
271  Oid opcintype;
272  int16 strategy;
273 
274  /* Find the operator in pg_amop */
276  &opfamily, &opcintype, &strategy))
277  {
278  /* Found a suitable opfamily, get matching equality operator */
279  result = get_opfamily_member(opfamily,
280  opcintype,
281  opcintype,
283  if (reverse)
284  *reverse = (strategy == BTGreaterStrategyNumber);
285  }
286 
287  return result;
288 }
signed short int16
Definition: c.h:480
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
Definition: lsyscache.c:207
#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 1815 of file lsyscache.c.

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

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum(), 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 1610 of file lsyscache.c.

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

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

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

◆ get_func_nargs()

int get_func_nargs ( Oid  funcid)

Definition at line 1652 of file lsyscache.c.

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

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

◆ get_func_prokind()

char get_func_prokind ( Oid  funcid)

Definition at line 1796 of file lsyscache.c.

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

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

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

◆ get_func_retset()

bool get_func_retset ( Oid  funcid)

Definition at line 1720 of file lsyscache.c.

1721 {
1722  HeapTuple tp;
1723  bool result;
1724 
1725  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1726  if (!HeapTupleIsValid(tp))
1727  elog(ERROR, "cache lookup failed for function %u", funcid);
1728 
1729  result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
1730  ReleaseSysCache(tp);
1731  return result;
1732 }

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum(), 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 1674 of file lsyscache.c.

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

References Assert(), elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum(), palloc(), 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 1836 of file lsyscache.c.

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

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), 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 1701 of file lsyscache.c.

1702 {
1703  HeapTuple tp;
1704  Oid result;
1705 
1706  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1707  if (!HeapTupleIsValid(tp))
1708  elog(ERROR, "cache lookup failed for function %u", funcid);
1709 
1710  result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
1711  ReleaseSysCache(tp);
1712  return result;
1713 }

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum(), 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 3468 of file lsyscache.c.

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

References Assert(), DatumGetPointer(), GETSTRUCT, HeapTupleIsValid, 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 3557 of file lsyscache.c.

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

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, 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 3511 of file lsyscache.c.

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

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

Referenced by RememberReplicaIdentityForRebuilding().

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3534 of file lsyscache.c.

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

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

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

◆ get_language_name()

char* get_language_name ( Oid  langoid,
bool  missing_ok 
)

Definition at line 1139 of file lsyscache.c.

1140 {
1141  HeapTuple tp;
1142 
1143  tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
1144  if (HeapTupleIsValid(tp))
1145  {
1147  char *result;
1148 
1149  result = pstrdup(NameStr(lantup->lanname));
1150  ReleaseSysCache(tp);
1151  return result;
1152  }
1153 
1154  if (!missing_ok)
1155  elog(ERROR, "cache lookup failed for language %u",
1156  langoid);
1157  return NULL;
1158 }
FormData_pg_language * Form_pg_language
Definition: pg_language.h:65

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, 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 366 of file lsyscache.c.

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

References 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 3439 of file lsyscache.c.

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

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

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

◆ get_namespace_name()

char* get_namespace_name ( Oid  nspid)

Definition at line 3322 of file lsyscache.c.

3323 {
3324  HeapTuple tp;
3325 
3326  tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid));
3327  if (HeapTupleIsValid(tp))
3328  {
3330  char *result;
3331 
3332  result = pstrdup(NameStr(nsptup->nspname));
3333  ReleaseSysCache(tp);
3334  return result;
3335  }
3336  else
3337  return NULL;
3338 }
int nspid
FormData_pg_namespace * Form_pg_namespace
Definition: pg_namespace.h:52

References GETSTRUCT, HeapTupleIsValid, 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(), GetTempNamespaceProcNumber(), 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(), swap_relation_files(), transformAlterTableStmt(), transformCreateStmt(), and unaccent_dict().

◆ get_namespace_name_or_temp()

◆ get_negator()

Oid get_negator ( Oid  opno)

Definition at line 1511 of file lsyscache.c.

1512 {
1513  HeapTuple tp;
1514 
1515  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1516  if (HeapTupleIsValid(tp))
1517  {
1519  Oid result;
1520 
1521  result = optup->oprnegate;
1522  ReleaseSysCache(tp);
1523  return result;
1524  }
1525  else
1526  return InvalidOid;
1527 }

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), 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 601 of file lsyscache.c.

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

References 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 510 of file lsyscache.c.

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

References 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 136 of file lsyscache.c.

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

References 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 108 of file lsyscache.c.

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

References 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 83 of file lsyscache.c.

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

References 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 1311 of file lsyscache.c.

1312 {
1313  HeapTuple tp;
1314 
1315  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1316  if (HeapTupleIsValid(tp))
1317  {
1319  Oid result;
1320 
1321  result = optup->oprresult;
1322  ReleaseSysCache(tp);
1323  return result;
1324  }
1325  else
1326  return InvalidOid;
1327 }

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

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

◆ get_opclass_family()

Oid get_opclass_family ( Oid  opclass)

Definition at line 1168 of file lsyscache.c.

1169 {
1170  HeapTuple tp;
1171  Form_pg_opclass cla_tup;
1172  Oid result;
1173 
1174  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1175  if (!HeapTupleIsValid(tp))
1176  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1177  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1178 
1179  result = cla_tup->opcfamily;
1180  ReleaseSysCache(tp);
1181  return result;
1182 }
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83

References 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 1190 of file lsyscache.c.

1191 {
1192  HeapTuple tp;
1193  Form_pg_opclass cla_tup;
1194  Oid result;
1195 
1196  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1197  if (!HeapTupleIsValid(tp))
1198  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1199  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1200 
1201  result = cla_tup->opcintype;
1202  ReleaseSysCache(tp);
1203  return result;
1204 }

References 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_method()

Oid get_opclass_method ( Oid  opclass)

Definition at line 1238 of file lsyscache.c.

1239 {
1240  HeapTuple tp;
1241  Form_pg_opclass cla_tup;
1242  Oid result;
1243 
1244  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1245  if (!HeapTupleIsValid(tp))
1246  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1247  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1248 
1249  result = cla_tup->opcmethod;
1250  ReleaseSysCache(tp);
1251  return result;
1252 }

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

Referenced by get_equal_strategy_number().

◆ get_opclass_opfamily_and_input_type()

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

Definition at line 1213 of file lsyscache.c.

1214 {
1215  HeapTuple tp;
1216  Form_pg_opclass cla_tup;
1217 
1218  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1219  if (!HeapTupleIsValid(tp))
1220  return false;
1221 
1222  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1223 
1224  *opfamily = cla_tup->opcfamily;
1225  *opcintype = cla_tup->opcintype;
1226 
1227  ReleaseSysCache(tp);
1228 
1229  return true;
1230 }

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

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

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1263 of file lsyscache.c.

1264 {
1265  HeapTuple tp;
1266 
1267  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1268  if (HeapTupleIsValid(tp))
1269  {
1271  RegProcedure result;
1272 
1273  result = optup->oprcode;
1274  ReleaseSysCache(tp);
1275  return result;
1276  }
1277  else
1278  return (RegProcedure) InvalidOid;
1279 }

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), 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 
)

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

1289 {
1290  HeapTuple tp;
1291 
1292  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1293  if (HeapTupleIsValid(tp))
1294  {
1296  char *result;
1297 
1298  result = pstrdup(NameStr(optup->oprname));
1299  ReleaseSysCache(tp);
1300  return result;
1301  }
1302  else
1303  return NULL;
1304 }

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

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

◆ get_oprjoin()

RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1559 of file lsyscache.c.

1560 {
1561  HeapTuple tp;
1562 
1563  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1564  if (HeapTupleIsValid(tp))
1565  {
1567  RegProcedure result;
1568 
1569  result = optup->oprjoin;
1570  ReleaseSysCache(tp);
1571  return result;
1572  }
1573  else
1574  return (RegProcedure) InvalidOid;
1575 }

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

Referenced by join_selectivity(), and scalararraysel().

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1535 of file lsyscache.c.

1536 {
1537  HeapTuple tp;
1538 
1539  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1540  if (HeapTupleIsValid(tp))
1541  {
1543  RegProcedure result;
1544 
1545  result = optup->oprrest;
1546  ReleaseSysCache(tp);
1547  return result;
1548  }
1549  else
1550  return (RegProcedure) InvalidOid;
1551 }

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), 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 305 of file lsyscache.c.

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

References 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 207 of file lsyscache.c.

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

References 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 2767 of file lsyscache.c.

2768 {
2769  Oid array_type = get_array_type(typid);
2770 
2771  if (OidIsValid(array_type))
2772  return array_type;
2773  if (OidIsValid(get_element_type(typid)))
2774  return typid;
2775  return InvalidOid;
2776 }
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2715
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2743

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

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

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum(), pstrdup(), 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 3581 of file lsyscache.c.

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

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

Referenced by get_object_address_unqualified(), and GetPublicationByName().

◆ get_range_collation()

Oid get_range_collation ( Oid  rangeOid)

Definition at line 3389 of file lsyscache.c.

3390 {
3391  HeapTuple tp;
3392 
3393  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3394  if (HeapTupleIsValid(tp))
3395  {
3396  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3397  Oid result;
3398 
3399  result = rngtup->rngcollation;
3400  ReleaseSysCache(tp);
3401  return result;
3402  }
3403  else
3404  return InvalidOid;
3405 }

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

Referenced by CheckAttributeType().

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

Definition at line 3414 of file lsyscache.c.

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

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

Referenced by AlterTypeOwnerInternal(), enforce_generic_type_consistency(), and resolve_anymultirange_from_others().

◆ get_range_subtype()

Oid get_range_subtype ( Oid  rangeOid)

Definition at line 3363 of file lsyscache.c.

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

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), 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 1906 of file lsyscache.c.

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

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

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_attnums(), AdjustNotNullInheritance(), AdjustNotNullInheritance1(), AlterPublicationOptions(), AlterSubscription_refresh(), AlterTableNamespace(), ATExecAlterConstraint(), ATExecChangeOwner(), check_enable_rls(), check_new_partition_bound(), check_publications_origin(), 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(), InitializeLogRepWorker(), 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_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(), swap_relation_files(), SysCacheGetAttrNotNull(), table_to_xml_internal(), TargetPrivilegesCheck(), and transformAlterTableStmt().

◆ get_rel_namespace()

◆ get_rel_persistence()

char get_rel_persistence ( Oid  relid)

Definition at line 2056 of file lsyscache.c.

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

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), 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 2005 of file lsyscache.c.

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

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

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

◆ get_rel_relkind()

char get_rel_relkind ( Oid  relid)

Definition at line 1981 of file lsyscache.c.

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

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

Referenced by AlterPublicationOptions(), AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), 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(), RangeVarCallbackOwnsRelation(), RangeVarCallbackOwnsTable(), RangeVarGetAndCheckCreationNamespace(), ReindexIndex(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), ReindexTable(), RelationBuildPartitionDesc(), RememberAllDependentForRebuilding(), 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 2032 of file lsyscache.c.

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

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), ReleaseSysCache(), 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 1957 of file lsyscache.c.

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

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

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

◆ get_relname_relid()

Oid get_relname_relid ( const char *  relname,
Oid  relnamespace 
)

◆ get_subscription_name()

char* get_subscription_name ( Oid  subid,
bool  missing_ok 
)

Definition at line 3651 of file lsyscache.c.

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

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

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

◆ get_subscription_oid()

Oid get_subscription_oid ( const char *  subname,
bool  missing_ok 
)

Definition at line 3631 of file lsyscache.c.

3632 {
3633  Oid oid;
3634 
3635  oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
3637  if (!OidIsValid(oid) && !missing_ok)
3638  ereport(ERROR,
3639  (errcode(ERRCODE_UNDEFINED_OBJECT),
3640  errmsg("subscription \"%s\" does not exist", subname)));
3641  return oid;
3642 }
Oid MyDatabaseId
Definition: globals.c:90

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

Referenced by binary_upgrade_add_sub_rel_state(), binary_upgrade_replorigin_advance(), and get_object_address_unqualified().

◆ get_transform_fromsql()

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

Definition at line 2076 of file lsyscache.c.

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

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

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

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

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

Referenced by plperl_sv_to_datum(), and PLy_output_setup_func().

◆ get_typ_typrelid()

Oid get_typ_typrelid ( Oid  typid)

Definition at line 2687 of file lsyscache.c.

2688 {
2689  HeapTuple tp;
2690 
2691  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2692  if (HeapTupleIsValid(tp))
2693  {
2694  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2695  Oid result;
2696 
2697  result = typtup->typrelid;
2698  ReleaseSysCache(tp);
2699  return result;
2700  }
2701  else
2702  return InvalidOid;
2703 }

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

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

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

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

2179 {
2180  HeapTuple tp;
2181 
2182  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2183  if (HeapTupleIsValid(tp))
2184  {
2185  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2186  bool result;
2187 
2188  result = typtup->typbyval;
2189  ReleaseSysCache(tp);
2190  return result;
2191  }
2192  else
2193  return false;
2194 }

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

Referenced by brin_range_deserialize(), and brin_range_serialize().

◆ get_typcollation()

◆ get_typdefault()

Node* get_typdefault ( Oid  typid)

Definition at line 2404 of file lsyscache.c.

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

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

Referenced by build_column_default().

◆ get_type_category_preferred()

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

Definition at line 2666 of file lsyscache.c.

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

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

Referenced by checkJsonOutputFormat(), func_select_candidate(), IsPreferredType(), select_common_type(), select_common_type_from_oids(), transformJsonParseArg(), transformJsonSerializeExpr(), 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 2281 of file lsyscache.c.

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

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

2130 {
2131  HeapTuple tp;
2132 
2133  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2134  if (HeapTupleIsValid(tp))
2135  {
2136  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2137  bool result;
2138 
2139  result = typtup->typisdefined;
2140  ReleaseSysCache(tp);
2141  return result;
2142  }
2143  else
2144  return false;
2145 }

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

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

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2153 of file lsyscache.c.

2154 {
2155  HeapTuple tp;
2156 
2157  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2158  if (HeapTupleIsValid(tp))
2159  {
2160  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2161  int16 result;
2162 
2163  result = typtup->typlen;
2164  ReleaseSysCache(tp);
2165  return result;
2166  }
2167  else
2168  return 0;
2169 }

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

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

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

◆ get_typlenbyvalalign()

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 2962 of file lsyscache.c.

2963 {
2964  HeapTuple tp;
2965 
2966  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2967  if (HeapTupleIsValid(tp))
2968  {
2969  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2970  Oid result;
2971 
2972  result = typtup->typmodin;
2973  ReleaseSysCache(tp);
2974  return result;
2975  }
2976  else
2977  return InvalidOid;
2978 }

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2375 of file lsyscache.c.

2376 {
2377  HeapTuple tp;
2378 
2379  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2380  if (HeapTupleIsValid(tp))
2381  {
2382  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2383  char result;
2384 
2385  result = typtup->typstorage;
2386  ReleaseSysCache(tp);
2387  return result;
2388  }
2389  else
2390  return TYPSTORAGE_PLAIN;
2391 }

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

Referenced by GetAttributeStorage().

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3053 of file lsyscache.c.

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

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

Referenced by exec_check_rw_parameter(), and getSubscriptingRoutines().

◆ get_typtype()

char get_typtype ( Oid  typid)

Definition at line 2585 of file lsyscache.c.

2586 {
2587  HeapTuple tp;
2588 
2589  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2590  if (HeapTupleIsValid(tp))
2591  {
2592  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2593  char result;
2594 
2595  result = typtup->typtype;
2596  ReleaseSysCache(tp);
2597  return result;
2598  }
2599  else
2600  return '\0';
2601 }

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

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

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2494 of file lsyscache.c.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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(), gist_page_items(), hstore_from_record(), json_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 1415 of file lsyscache.c.

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

References GETSTRUCT, TypeCacheEntry::hash_proc, HeapTupleIsValid, lookup_type_cache(), ObjectIdGetDatum(), 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()

bool op_in_opfamily ( Oid  opno,
Oid  opfamily 
)

◆ op_input_types()

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

Definition at line 1336 of file lsyscache.c.

1337 {
1338  HeapTuple tp;
1339  Form_pg_operator optup;
1340 
1341  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1342  if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1343  elog(ERROR, "cache lookup failed for operator %u", opno);
1344  optup = (Form_pg_operator) GETSTRUCT(tp);
1345  *lefttype = optup->oprleft;
1346  *righttype = optup->oprright;
1347  ReleaseSysCache(tp);
1348 }

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum(), 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 1364 of file lsyscache.c.

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

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

Referenced by check_mergejoinable(), and compute_semijoin_info().

◆ op_strict()

bool op_strict ( Oid  opno)

Definition at line 1455 of file lsyscache.c.

1456 {
1457  RegProcedure funcid = get_opcode(opno);
1458 
1459  if (funcid == (RegProcedure) InvalidOid)
1460  elog(ERROR, "operator %u does not exist", opno);
1461 
1462  return func_strict((Oid) funcid);
1463 }
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1263
bool func_strict(Oid funcid)
Definition: lsyscache.c:1739

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

1472 {
1473  RegProcedure funcid = get_opcode(opno);
1474 
1475  if (funcid == (RegProcedure) InvalidOid)
1476  elog(ERROR, "operator %u does not exist", opno);
1477 
1478  return func_volatile((Oid) funcid);
1479 }
char func_volatile(Oid funcid)
Definition: lsyscache.c:1758

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

2635 {
2636  return (get_typtype(typid) == TYPTYPE_ENUM);
2637 }
char get_typtype(Oid typid)
Definition: lsyscache.c:2585

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

2655 {
2656  return (get_typtype(typid) == TYPTYPE_MULTIRANGE);
2657 }

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

2645 {
2646  return (get_typtype(typid) == TYPTYPE_RANGE);
2647 }

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

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

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(), 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 53 of file lsyscache.c.

Referenced by get_attavgwidth().