PostgreSQL Source Code  git master
lsyscache.c File Reference
#include "postgres.h"
#include "access/hash.h"
#include "access/htup_details.h"
#include "bootstrap/bootstrap.h"
#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "catalog/pg_amop.h"
#include "catalog/pg_amproc.h"
#include "catalog/pg_cast.h"
#include "catalog/pg_class.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_constraint.h"
#include "catalog/pg_index.h"
#include "catalog/pg_language.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_publication.h"
#include "catalog/pg_range.h"
#include "catalog/pg_statistic.h"
#include "catalog/pg_subscription.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/catcache.h"
#include "utils/datum.h"
#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
#include "utils/typcache.h"
Include dependency graph for lsyscache.c:

Go to the source code of this file.

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_constraint_type (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_rel_relam (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)
 
Oid getBaseType (Oid typid)
 
Oid getBaseTypeAndTypmod (Oid typid, int32 *typmod)
 
int32 get_typavgwidth (Oid typid, int32 typmod)
 
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)
 
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

get_attavgwidth_hook_type get_attavgwidth_hook = NULL
 

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:72
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:180
int n_members
Definition: catcache.h:178
HeapTupleData tuple
Definition: catcache.h:123
#define ReleaseSysCacheList(x)
Definition: syscache.h:134
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:127

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

3345 {
3346  /* The values[] array was separately palloc'd by deconstruct_array */
3347  if (sslot->values)
3348  pfree(sslot->values);
3349  /* The numbers[] array points into numbers_arr, do not pfree it */
3350  /* Free the detoasted array objects, if any */
3351  if (sslot->values_arr)
3352  pfree(sslot->values_arr);
3353  if (sslot->numbers_arr)
3354  pfree(sslot->numbers_arr);
3355 }
void pfree(void *pointer)
Definition: mcxt.c:1521
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 1799 of file lsyscache.c.

1800 {
1801  HeapTuple tp;
1802  char result;
1803 
1804  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1805  if (!HeapTupleIsValid(tp))
1806  elog(ERROR, "cache lookup failed for function %u", funcid);
1807 
1808  result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1809  ReleaseSysCache(tp);
1810  return result;
1811 }
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225
#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:269
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:221

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

1762 {
1763  HeapTuple tp;
1764  bool result;
1765 
1766  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1767  if (!HeapTupleIsValid(tp))
1768  elog(ERROR, "cache lookup failed for function %u", funcid);
1769 
1770  result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
1771  ReleaseSysCache(tp);
1772  return result;
1773 }

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

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 3158 of file lsyscache.c.

3159 {
3160  HeapTuple tp;
3161  int32 stawidth;
3162 
3164  {
3165  stawidth = (*get_attavgwidth_hook) (relid, attnum);
3166  if (stawidth > 0)
3167  return stawidth;
3168  }
3169  tp = SearchSysCache3(STATRELATTINH,
3170  ObjectIdGetDatum(relid),
3172  BoolGetDatum(false));
3173  if (HeapTupleIsValid(tp))
3174  {
3175  stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3176  ReleaseSysCache(tp);
3177  if (stawidth > 0)
3178  return stawidth;
3179  }
3180  return 0;
3181 }
signed int int32
Definition: c.h:482
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:243

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:232

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:725
char * pstrdup(const char *in)
Definition: mcxt.c:1696

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

Referenced by AddRelationNewConstraints(), AddRelationNotNullConstraints(), 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(), getIdentitySequence(), 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(), 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:600

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

3236 {
3237  Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
3238  int i;
3239  Datum val;
3240  ArrayType *statarray;
3241  Oid arrayelemtype;
3242  int narrayelem;
3243  HeapTuple typeTuple;
3244  Form_pg_type typeForm;
3245 
3246  /* initialize *sslot properly */
3247  memset(sslot, 0, sizeof(AttStatsSlot));
3248 
3249  for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
3250  {
3251  if ((&stats->stakind1)[i] == reqkind &&
3252  (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
3253  break;
3254  }
3255  if (i >= STATISTIC_NUM_SLOTS)
3256  return false; /* not there */
3257 
3258  sslot->staop = (&stats->staop1)[i];
3259  sslot->stacoll = (&stats->stacoll1)[i];
3260 
3261  if (flags & ATTSTATSSLOT_VALUES)
3262  {
3263  val = SysCacheGetAttrNotNull(STATRELATTINH, statstuple,
3264  Anum_pg_statistic_stavalues1 + i);
3265 
3266  /*
3267  * Detoast the array if needed, and in any case make a copy that's
3268  * under control of this AttStatsSlot.
3269  */
3270  statarray = DatumGetArrayTypePCopy(val);
3271 
3272  /*
3273  * Extract the actual array element type, and pass it back in case the
3274  * caller needs it.
3275  */
3276  sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3277 
3278  /* Need info about element type */
3279  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
3280  if (!HeapTupleIsValid(typeTuple))
3281  elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3282  typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
3283 
3284  /* Deconstruct array into Datum elements; NULLs not expected */
3285  deconstruct_array(statarray,
3286  arrayelemtype,
3287  typeForm->typlen,
3288  typeForm->typbyval,
3289  typeForm->typalign,
3290  &sslot->values, NULL, &sslot->nvalues);
3291 
3292  /*
3293  * If the element type is pass-by-reference, we now have a bunch of
3294  * Datums that are pointers into the statarray, so we need to keep
3295  * that until free_attstatsslot. Otherwise, all the useful info is in
3296  * sslot->values[], so we can free the array object immediately.
3297  */
3298  if (!typeForm->typbyval)
3299  sslot->values_arr = statarray;
3300  else
3301  pfree(statarray);
3302 
3303  ReleaseSysCache(typeTuple);
3304  }
3305 
3306  if (flags & ATTSTATSSLOT_NUMBERS)
3307  {
3308  val = SysCacheGetAttrNotNull(STATRELATTINH, statstuple,
3309  Anum_pg_statistic_stanumbers1 + i);
3310 
3311  /*
3312  * Detoast the array if needed, and in any case make a copy that's
3313  * under control of this AttStatsSlot.
3314  */
3315  statarray = DatumGetArrayTypePCopy(val);
3316 
3317  /*
3318  * We expect the array to be a 1-D float4 array; verify that. We don't
3319  * need to use deconstruct_array() since the array data is just going
3320  * to look like a C array of float4 values.
3321  */
3322  narrayelem = ARR_DIMS(statarray)[0];
3323  if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3324  ARR_HASNULL(statarray) ||
3325  ARR_ELEMTYPE(statarray) != FLOAT4OID)
3326  elog(ERROR, "stanumbers is not a 1-D float4 array");
3327 
3328  /* Give caller a pointer directly into the statarray */
3329  sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3330  sslot->nnumbers = narrayelem;
3331 
3332  /* We'll free the statarray in free_attstatsslot */
3333  sslot->numbers_arr = statarray;
3334  }
3335 
3336  return true;
3337 }
#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:3631
float float4
Definition: c.h:608
long val
Definition: informix.c:689
#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:631

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

2833 {
2834  /*
2835  * We loop to find the bottom base type in a stack of domains.
2836  */
2837  for (;;)
2838  {
2839  HeapTuple tup;
2840  Form_pg_type typTup;
2841 
2842  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2843  if (!HeapTupleIsValid(tup))
2844  break;
2845  typTup = (Form_pg_type) GETSTRUCT(tup);
2846  if (typTup->typtype != TYPTYPE_DOMAIN)
2847  {
2848  /* Not a domain, so stop descending */
2849  Oid result;
2850 
2851  /* This test must match get_element_type */
2852  if (IsTrueArrayType(typTup))
2853  result = typTup->typelem;
2854  else
2855  result = InvalidOid;
2856  ReleaseSysCache(tup);
2857  return result;
2858  }
2859 
2860  typid = typTup->typbasetype;
2861  ReleaseSysCache(tup);
2862  }
2863 
2864  /* Like get_element_type, silently return InvalidOid for bogus input */
2865  return InvalidOid;
2866 }

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_elem_stat_type(), 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:754
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#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:111

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 ATAddForeignKeyConstraint(), index_create(), and match_pattern_prefix().

◆ 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(), ATAddForeignKeyConstraint(), ATExecAddColumn(), checkViewColumns(), merge_collation_state(), MergeChildAttribute(), MergeInheritedAttribute(), select_common_collation(), and show_sortorder_options().

◆ get_commutator()

◆ get_compatible_hash_operators()

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

Definition at line 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(), CloneFkReferencing(), get_insert_query_def(), and report_triggers().

◆ get_constraint_type()

char get_constraint_type ( Oid  conoid)

Definition at line 1143 of file lsyscache.c.

1144 {
1145  HeapTuple tp;
1146  char contype;
1147 
1148  tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
1149  if (!HeapTupleIsValid(tp))
1150  elog(ERROR, "cache lookup failed for constraint %u", conoid);
1151 
1152  contype = ((Form_pg_constraint) GETSTRUCT(tp))->contype;
1153  ReleaseSysCache(tp);
1154 
1155  return contype;
1156 }

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

Referenced by AttachPartitionEnsureIndexes(), and RememberConstraintForRebuilding().

◆ 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:481
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 1837 of file lsyscache.c.

1838 {
1839  HeapTuple tp;
1840  bool result;
1841 
1842  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1843  if (!HeapTupleIsValid(tp))
1844  elog(ERROR, "cache lookup failed for function %u", funcid);
1845 
1846  result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
1847  ReleaseSysCache(tp);
1848  return result;
1849 }

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

1633 {
1634  HeapTuple tp;
1635 
1636  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1637  if (HeapTupleIsValid(tp))
1638  {
1639  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1640  Oid result;
1641 
1642  result = functup->pronamespace;
1643  ReleaseSysCache(tp);
1644  return result;
1645  }
1646  else
1647  return InvalidOid;
1648 }

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

1675 {
1676  HeapTuple tp;
1677  int result;
1678 
1679  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1680  if (!HeapTupleIsValid(tp))
1681  elog(ERROR, "cache lookup failed for function %u", funcid);
1682 
1683  result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1684  ReleaseSysCache(tp);
1685  return result;
1686 }
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 1818 of file lsyscache.c.

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

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

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

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

1697 {
1698  HeapTuple tp;
1699  Form_pg_proc procstruct;
1700  Oid result;
1701 
1702  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1703  if (!HeapTupleIsValid(tp))
1704  elog(ERROR, "cache lookup failed for function %u", funcid);
1705 
1706  procstruct = (Form_pg_proc) GETSTRUCT(tp);
1707 
1708  result = procstruct->prorettype;
1709  *nargs = (int) procstruct->pronargs;
1710  Assert(*nargs == procstruct->proargtypes.dim1);
1711  *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1712  memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1713 
1714  ReleaseSysCache(tp);
1715  return result;
1716 }
#define Assert(condition)
Definition: c.h:837
void * palloc(Size size)
Definition: mcxt.c:1317

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

1859 {
1860  HeapTuple tp;
1861 
1862  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1863  if (HeapTupleIsValid(tp))
1864  {
1865  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1866  RegProcedure result;
1867 
1868  result = functup->prosupport;
1869  ReleaseSysCache(tp);
1870  return result;
1871  }
1872  else
1873  return (RegProcedure) InvalidOid;
1874 }
regproc RegProcedure
Definition: c.h:629

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

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

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

3513 {
3514  HeapTuple tuple;
3515  Form_pg_index rd_index;
3516  Datum datum;
3517  oidvector *indclass;
3518  Oid opclass;
3519 
3520  /* First we need to know the column's opclass. */
3521 
3522  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3523  if (!HeapTupleIsValid(tuple))
3524  return InvalidOid;
3525 
3526  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3527 
3528  /* caller is supposed to guarantee this */
3529  Assert(attno > 0 && attno <= rd_index->indnatts);
3530 
3531  /* Non-key attributes don't have an opclass */
3532  if (attno > rd_index->indnkeyatts)
3533  {
3534  ReleaseSysCache(tuple);
3535  return InvalidOid;
3536  }
3537 
3538  datum = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
3539  indclass = ((oidvector *) DatumGetPointer(datum));
3540 
3541  Assert(attno <= indclass->dim1);
3542  opclass = indclass->values[attno - 1];
3543 
3544  ReleaseSysCache(tuple);
3545 
3546  return opclass;
3547 }
FormData_pg_index * Form_pg_index
Definition: pg_index.h:70
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:312
Definition: c.h:705
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition: c.h:712

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

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

◆ get_index_isclustered()

bool get_index_isclustered ( Oid  index_oid)

Definition at line 3601 of file lsyscache.c.

3602 {
3603  bool isclustered;
3604  HeapTuple tuple;
3605  Form_pg_index rd_index;
3606 
3607  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3608  if (!HeapTupleIsValid(tuple))
3609  elog(ERROR, "cache lookup failed for index %u", index_oid);
3610 
3611  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3612  isclustered = rd_index->indisclustered;
3613  ReleaseSysCache(tuple);
3614 
3615  return isclustered;
3616 }

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

3556 {
3557  HeapTuple tuple;
3558  Form_pg_index rd_index;
3559  bool result;
3560 
3561  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3562  if (!HeapTupleIsValid(tuple))
3563  return false;
3564 
3565  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3566  result = rd_index->indisreplident;
3567  ReleaseSysCache(tuple);
3568 
3569  return result;
3570 }

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

Referenced by RememberReplicaIdentityForRebuilding().

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3578 of file lsyscache.c.

3579 {
3580  bool isvalid;
3581  HeapTuple tuple;
3582  Form_pg_index rd_index;
3583 
3584  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3585  if (!HeapTupleIsValid(tuple))
3586  elog(ERROR, "cache lookup failed for index %u", index_oid);
3587 
3588  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3589  isvalid = rd_index->indisvalid;
3590  ReleaseSysCache(tuple);
3591 
3592  return isvalid;
3593 }

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

1162 {
1163  HeapTuple tp;
1164 
1165  tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
1166  if (HeapTupleIsValid(tp))
1167  {
1169  char *result;
1170 
1171  result = pstrdup(NameStr(lantup->lanname));
1172  ReleaseSysCache(tp);
1173  return result;
1174  }
1175 
1176  if (!missing_ok)
1177  elog(ERROR, "cache lookup failed for language %u",
1178  langoid);
1179  return NULL;
1180 }
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(), have_partkey_equi_join(), make_pathkey_from_sortinfo(), and match_eclasses_to_foreign_key_col().

◆ get_multirange_range()

Oid get_multirange_range ( Oid  multirangeOid)

Definition at line 3483 of file lsyscache.c.

3484 {
3485  HeapTuple tp;
3486 
3487  tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
3488  if (HeapTupleIsValid(tp))
3489  {
3490  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3491  Oid result;
3492 
3493  result = rngtup->rngtypid;
3494  ReleaseSysCache(tp);
3495  return result;
3496  }
3497  else
3498  return InvalidOid;
3499 }
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(), get_attr_stat_type(), 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 3366 of file lsyscache.c.

3367 {
3368  HeapTuple tp;
3369 
3370  tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid));
3371  if (HeapTupleIsValid(tp))
3372  {
3374  char *result;
3375 
3376  result = pstrdup(NameStr(nsptup->nspname));
3377  ReleaseSysCache(tp);
3378  return result;
3379  }
3380  else
3381  return NULL;
3382 }
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_and_init_gencol(), check_default_text_search_config(), check_publication_add_schema(), check_publications_origin(), CheckPubRelationColumnList(), compute_return_type(), copy_table(), copy_table_data(), create_pg_locale(), 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(), ExecAlterExtensionContentsRecurse(), ExecBRInsertTriggers(), 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(), pgoutput_column_list_init(), pgoutput_row_filter(), plpgsql_fulfill_promise(), publication_add_schema(), PublicationDropSchemas(), quoteRelationName(), RangeVarCallbackForAlterRelation(), RangeVarGetAndCheckCreationNamespace(), RebuildConstraintComment(), refresh_by_match_merge(), RefreshMatViewByOid(), regclassout(), regcollationout(), regconfigout(), regdictionaryout(), regnamespaceout(), regoperout(), regprocout(), reindex_index(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), report_namespace_conflict(), ReportApplyConflict(), 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 1533 of file lsyscache.c.

1534 {
1535  HeapTuple tp;
1536 
1537  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1538  if (HeapTupleIsValid(tp))
1539  {
1541  Oid result;
1542 
1543  result = optup->oprnegate;
1544  ReleaseSysCache(tp);
1545  return result;
1546  }
1547  else
1548  return InvalidOid;
1549 }

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:1533
@ ROWCOMPARE_NE
Definition: primnodes.h:1460
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(), ExecInitHashJoin(), 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 1333 of file lsyscache.c.

1334 {
1335  HeapTuple tp;
1336 
1337  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1338  if (HeapTupleIsValid(tp))
1339  {
1341  Oid result;
1342 
1343  result = optup->oprresult;
1344  ReleaseSysCache(tp);
1345  return result;
1346  }
1347  else
1348  return InvalidOid;
1349 }

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

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

◆ get_opclass_family()

Oid get_opclass_family ( 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->opcfamily;
1202  ReleaseSysCache(tp);
1203  return result;
1204 }
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 1212 of file lsyscache.c.

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

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

1261 {
1262  HeapTuple tp;
1263  Form_pg_opclass cla_tup;
1264  Oid result;
1265 
1266  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1267  if (!HeapTupleIsValid(tp))
1268  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1269  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1270 
1271  result = cla_tup->opcmethod;
1272  ReleaseSysCache(tp);
1273  return result;
1274 }

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

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

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

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

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1285 of file lsyscache.c.

1286 {
1287  HeapTuple tp;
1288 
1289  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1290  if (HeapTupleIsValid(tp))
1291  {
1293  RegProcedure result;
1294 
1295  result = optup->oprcode;
1296  ReleaseSysCache(tp);
1297  return result;
1298  }
1299  else
1300  return (RegProcedure) InvalidOid;
1301 }

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_orclause_to_indexcol(), match_pattern_prefix(), mcv_get_match_bitmap(), minmax_get_strategy_procinfo(), minmax_multi_get_strategy_procinfo(), mode_final(), networkjoinsel_semi(), networksel(), op_strict(), op_volatile(), OperatorLookup(), patternsel_common(), prefix_selectivity(), preparePresortedCols(), RelationGetExclusionInfo(), ri_HashCompareOp(), scalarineqsel(), select_equality_operator(), set_opfuncid(), set_sa_opfuncid(), statext_is_compatible_clause_internal(), std_typanalyze(), and var_eq_const().

◆ get_opfamily_member()

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

Definition at line 166 of file lsyscache.c.

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

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

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

◆ get_opfamily_proc()

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

◆ get_opname()

char* get_opname ( Oid  opno)

Definition at line 1310 of file lsyscache.c.

1311 {
1312  HeapTuple tp;
1313 
1314  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1315  if (HeapTupleIsValid(tp))
1316  {
1318  char *result;
1319 
1320  result = pstrdup(NameStr(optup->oprname));
1321  ReleaseSysCache(tp);
1322  return result;
1323  }
1324  else
1325  return NULL;
1326 }

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

1582 {
1583  HeapTuple tp;
1584 
1585  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1586  if (HeapTupleIsValid(tp))
1587  {
1589  RegProcedure result;
1590 
1591  result = optup->oprjoin;
1592  ReleaseSysCache(tp);
1593  return result;
1594  }
1595  else
1596  return (RegProcedure) InvalidOid;
1597 }

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

Referenced by join_selectivity(), and scalararraysel().

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1557 of file lsyscache.c.

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

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

2812 {
2813  Oid array_type = get_array_type(typid);
2814 
2815  if (OidIsValid(array_type))
2816  return array_type;
2817  if (OidIsValid(get_element_type(typid)))
2818  return typid;
2819  return InvalidOid;
2820 }
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2759
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2787

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

3646 {
3647  HeapTuple tup;
3648  char *pubname;
3649  Form_pg_publication pubform;
3650 
3651  tup = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pubid));
3652 
3653  if (!HeapTupleIsValid(tup))
3654  {
3655  if (!missing_ok)
3656  elog(ERROR, "cache lookup failed for publication %u", pubid);
3657  return NULL;
3658  }
3659 
3660  pubform = (Form_pg_publication) GETSTRUCT(tup);
3661  pubname = pstrdup(NameStr(pubform->pubname));
3662 
3663  ReleaseSysCache(tup);
3664 
3665  return pubname;
3666 }
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 3625 of file lsyscache.c.

3626 {
3627  Oid oid;
3628 
3629  oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
3630  CStringGetDatum(pubname));
3631  if (!OidIsValid(oid) && !missing_ok)
3632  ereport(ERROR,
3633  (errcode(ERRCODE_UNDEFINED_OBJECT),
3634  errmsg("publication \"%s\" does not exist", pubname)));
3635  return oid;
3636 }
static Datum CStringGetDatum(const char *X)
Definition: postgres.h:350
#define GetSysCacheOid1(cacheId, oidcol, key1)
Definition: syscache.h:109

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

3434 {
3435  HeapTuple tp;
3436 
3437  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3438  if (HeapTupleIsValid(tp))
3439  {
3440  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3441  Oid result;
3442 
3443  result = rngtup->rngcollation;
3444  ReleaseSysCache(tp);
3445  return result;
3446  }
3447  else
3448  return InvalidOid;
3449 }

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

Referenced by CheckAttributeType().

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

Definition at line 3458 of file lsyscache.c.

3459 {
3460  HeapTuple tp;
3461 
3462  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3463  if (HeapTupleIsValid(tp))
3464  {
3465  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3466  Oid result;
3467 
3468  result = rngtup->rngmultitypid;
3469  ReleaseSysCache(tp);
3470  return result;
3471  }
3472  else
3473  return InvalidOid;
3474 }

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

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

◆ get_range_subtype()

Oid get_range_subtype ( Oid  rangeOid)

Definition at line 3407 of file lsyscache.c.

3408 {
3409  HeapTuple tp;
3410 
3411  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3412  if (HeapTupleIsValid(tp))
3413  {
3414  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3415  Oid result;
3416 
3417  result = rngtup->rngsubtype;
3418  ReleaseSysCache(tp);
3419  return result;
3420  }
3421  else
3422  return InvalidOid;
3423 }

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

1929 {
1930  HeapTuple tp;
1931 
1932  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1933  if (HeapTupleIsValid(tp))
1934  {
1935  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1936  char *result;
1937 
1938  result = pstrdup(NameStr(reltup->relname));
1939  ReleaseSysCache(tp);
1940  return result;
1941  }
1942  else
1943  return NULL;
1944 }
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(), AlterPublicationOptions(), AlterSubscription_refresh(), AlterTableNamespace(), ATExecAlterConstraint(), ATExecChangeOwner(), ATPrepAddPrimaryKey(), attribute_statistics_update(), check_enable_rls(), check_new_partition_bound(), check_publications_origin(), cluster_is_permitted_for_relation(), convert_column_name(), CreateTriggerFiringOn(), DefineRelation(), do_autovacuum(), EnableDisableRule(), errdetail_apply_conflict(), 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_clear_attribute_stats(), 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 2078 of file lsyscache.c.

2079 {
2080  HeapTuple tp;
2081  Form_pg_class reltup;
2082  char result;
2083 
2084  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2085  if (!HeapTupleIsValid(tp))
2086  elog(ERROR, "cache lookup failed for relation %u", relid);
2087  reltup = (Form_pg_class) GETSTRUCT(tp);
2088  result = reltup->relpersistence;
2089  ReleaseSysCache(tp);
2090 
2091  return result;
2092 }

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

Oid get_rel_relam ( Oid  relid)

Definition at line 2100 of file lsyscache.c.

2101 {
2102  HeapTuple tp;
2103  Form_pg_class reltup;
2104  Oid result;
2105 
2106  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2107  if (!HeapTupleIsValid(tp))
2108  elog(ERROR, "cache lookup failed for relation %u", relid);
2109  reltup = (Form_pg_class) GETSTRUCT(tp);
2110  result = reltup->relam;
2111  ReleaseSysCache(tp);
2112 
2113  return result;
2114 }

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

Referenced by DefineRelation().

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

Definition at line 2027 of file lsyscache.c.

2028 {
2029  HeapTuple tp;
2030 
2031  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2032  if (HeapTupleIsValid(tp))
2033  {
2034  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2035  bool result;
2036 
2037  result = reltup->relispartition;
2038  ReleaseSysCache(tp);
2039  return result;
2040  }
2041  else
2042  return false;
2043 }

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

2004 {
2005  HeapTuple tp;
2006 
2007  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2008  if (HeapTupleIsValid(tp))
2009  {
2010  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2011  char result;
2012 
2013  result = reltup->relkind;
2014  ReleaseSysCache(tp);
2015  return result;
2016  }
2017  else
2018  return '\0';
2019 }

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(), RangeVarCallbackMaintainsTable(), RangeVarCallbackOwnsRelation(), 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(), sepgsql_relation_truncate(), and tryAttachPartitionForeignKey().

◆ get_rel_tablespace()

Oid get_rel_tablespace ( Oid  relid)

Definition at line 2054 of file lsyscache.c.

2055 {
2056  HeapTuple tp;
2057 
2058  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2059  if (HeapTupleIsValid(tp))
2060  {
2061  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2062  Oid result;
2063 
2064  result = reltup->reltablespace;
2065  ReleaseSysCache(tp);
2066  return result;
2067  }
2068  else
2069  return InvalidOid;
2070 }

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

1980 {
1981  HeapTuple tp;
1982 
1983  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1984  if (HeapTupleIsValid(tp))
1985  {
1986  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1987  Oid result;
1988 
1989  result = reltup->reltype;
1990  ReleaseSysCache(tp);
1991  return result;
1992  }
1993  else
1994  return InvalidOid;
1995 }

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

Referenced by ExecAlterExtensionContentsRecurse(), 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 3695 of file lsyscache.c.

3696 {
3697  HeapTuple tup;
3698  char *subname;
3699  Form_pg_subscription subform;
3700 
3701  tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
3702 
3703  if (!HeapTupleIsValid(tup))
3704  {
3705  if (!missing_ok)
3706  elog(ERROR, "cache lookup failed for subscription %u", subid);
3707  return NULL;
3708  }
3709 
3710  subform = (Form_pg_subscription) GETSTRUCT(tup);
3711  subname = pstrdup(NameStr(subform->subname));
3712 
3713  ReleaseSysCache(tup);
3714 
3715  return subname;
3716 }
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 3675 of file lsyscache.c.

3676 {
3677  Oid oid;
3678 
3679  oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
3681  if (!OidIsValid(oid) && !missing_ok)
3682  ereport(ERROR,
3683  (errcode(ERRCODE_UNDEFINED_OBJECT),
3684  errmsg("subscription \"%s\" does not exist", subname)));
3685  return oid;
3686 }
Oid MyDatabaseId
Definition: globals.c:93

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

2121 {
2122  HeapTuple tup;
2123 
2124  if (!list_member_oid(trftypes, typid))
2125  return InvalidOid;
2126 
2127  tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
2128  ObjectIdGetDatum(langid));
2129  if (HeapTupleIsValid(tup))
2130  {
2131  Oid funcid;
2132 
2133  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2134  ReleaseSysCache(tup);
2135  return funcid;
2136  }
2137  else
2138  return InvalidOid;
2139 }
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 2142 of file lsyscache.c.

2143 {
2144  HeapTuple tup;
2145 
2146  if (!list_member_oid(trftypes, typid))
2147  return InvalidOid;
2148 
2149  tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
2150  ObjectIdGetDatum(langid));
2151  if (HeapTupleIsValid(tup))
2152  {
2153  Oid funcid;
2154 
2155  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
2156  ReleaseSysCache(tup);
2157  return funcid;
2158  }
2159  else
2160  return InvalidOid;
2161 }

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

2732 {
2733  HeapTuple tp;
2734 
2735  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2736  if (HeapTupleIsValid(tp))
2737  {
2738  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2739  Oid result;
2740 
2741  result = typtup->typrelid;
2742  ReleaseSysCache(tp);
2743  return result;
2744  }
2745  else
2746  return InvalidOid;
2747 }

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

2579 {
2580  int typlen = get_typlen(typid);
2581  int32 maxwidth;
2582 
2583  /*
2584  * Easy if it's a fixed-width type
2585  */
2586  if (typlen > 0)
2587  return typlen;
2588 
2589  /*
2590  * type_maximum_size knows the encoding of typmod for some datatypes;
2591  * don't duplicate that knowledge here.
2592  */
2593  maxwidth = type_maximum_size(typid, typmod);
2594  if (maxwidth > 0)
2595  {
2596  /*
2597  * For BPCHAR, the max width is also the only width. Otherwise we
2598  * need to guess about the typical data width given the max. A sliding
2599  * scale for percentage of max width seems reasonable.
2600  */
2601  if (typid == BPCHAROID)
2602  return maxwidth;
2603  if (maxwidth <= 32)
2604  return maxwidth; /* assume full width */
2605  if (maxwidth < 1000)
2606  return 32 + (maxwidth - 32) / 2; /* assume 50% */
2607 
2608  /*
2609  * Beyond 1000, assume we're looking at something like
2610  * "varchar(10000)" where the limit isn't actually reached often, and
2611  * use a fixed estimate.
2612  */
2613  return 32 + (1000 - 32) / 2;
2614  }
2615 
2616  /*
2617  * Oops, we have no idea ... wild guess time.
2618  */
2619  return 32;
2620 }
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:412
int16 get_typlen(Oid typid)
Definition: lsyscache.c:2197

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

2223 {
2224  HeapTuple tp;
2225 
2226  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2227  if (HeapTupleIsValid(tp))
2228  {
2229  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2230  bool result;
2231 
2232  result = typtup->typbyval;
2233  ReleaseSysCache(tp);
2234  return result;
2235  }
2236  else
2237  return false;
2238 }

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

2449 {
2450  HeapTuple typeTuple;
2452  Datum datum;
2453  bool isNull;
2454  Node *expr;
2455 
2456  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2457  if (!HeapTupleIsValid(typeTuple))
2458  elog(ERROR, "cache lookup failed for type %u", typid);
2459  type = (Form_pg_type) GETSTRUCT(typeTuple);
2460 
2461  /*
2462  * typdefault and typdefaultbin are potentially null, so don't try to
2463  * access 'em as struct fields. Must do it the hard way with
2464  * SysCacheGetAttr.
2465  */
2466  datum = SysCacheGetAttr(TYPEOID,
2467  typeTuple,
2468  Anum_pg_type_typdefaultbin,
2469  &isNull);
2470 
2471  if (!isNull)
2472  {
2473  /* We have an expression default */
2474  expr = stringToNode(TextDatumGetCString(datum));
2475  }
2476  else
2477  {
2478  /* Perhaps we have a plain literal default */
2479  datum = SysCacheGetAttr(TYPEOID,
2480  typeTuple,
2481  Anum_pg_type_typdefault,
2482  &isNull);
2483 
2484  if (!isNull)
2485  {
2486  char *strDefaultVal;
2487 
2488  /* Convert text datum to C string */
2489  strDefaultVal = TextDatumGetCString(datum);
2490  /* Convert C string to a value of the given type */
2491  datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2492  getTypeIOParam(typeTuple), -1);
2493  /* Build a Const node containing the value */
2494  expr = (Node *) makeConst(typid,
2495  -1,
2496  type->typcollation,
2497  type->typlen,
2498  datum,
2499  false,
2500  type->typbyval);
2501  pfree(strDefaultVal);
2502  }
2503  else
2504  {
2505  /* No default */
2506  expr = NULL;
2507  }
2508  }
2509 
2510  ReleaseSysCache(typeTuple);
2511 
2512  return expr;
2513 }
#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:2303
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 2710 of file lsyscache.c.

2711 {
2712  HeapTuple tp;
2713  Form_pg_type typtup;
2714 
2715  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2716  if (!HeapTupleIsValid(tp))
2717  elog(ERROR, "cache lookup failed for type %u", typid);
2718  typtup = (Form_pg_type) GETSTRUCT(tp);
2719  *typcategory = typtup->typcategory;
2720  *typispreferred = typtup->typispreferred;
2721  ReleaseSysCache(tp);
2722 }

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

Referenced by checkJsonOutputFormat(), func_select_candidate(), get_json_table_columns(), 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 2325 of file lsyscache.c.

2333 {
2334  HeapTuple typeTuple;
2335  Form_pg_type typeStruct;
2336 
2337  /*
2338  * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2339  * use array_in and array_out during bootstrap.
2340  */
2342  {
2343  Oid typinput;
2344  Oid typoutput;
2345 
2346  boot_get_type_io_data(typid,
2347  typlen,
2348  typbyval,
2349  typalign,
2350  typdelim,
2351  typioparam,
2352  &typinput,
2353  &typoutput);
2354  switch (which_func)
2355  {
2356  case IOFunc_input:
2357  *func = typinput;
2358  break;
2359  case IOFunc_output:
2360  *func = typoutput;
2361  break;
2362  default:
2363  elog(ERROR, "binary I/O not supported during bootstrap");
2364  break;
2365  }
2366  return;
2367  }
2368 
2369  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2370  if (!HeapTupleIsValid(typeTuple))
2371  elog(ERROR, "cache lookup failed for type %u", typid);
2372  typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2373 
2374  *typlen = typeStruct->typlen;
2375  *typbyval = typeStruct->typbyval;
2376  *typalign = typeStruct->typalign;
2377  *typdelim = typeStruct->typdelim;
2378  *typioparam = getTypeIOParam(typeTuple);
2379  switch (which_func)
2380  {
2381  case IOFunc_input:
2382  *func = typeStruct->typinput;
2383  break;
2384  case IOFunc_output:
2385  *func = typeStruct->typoutput;
2386  break;
2387  case IOFunc_receive:
2388  *func = typeStruct->typreceive;
2389  break;
2390  case IOFunc_send:
2391  *func = typeStruct->typsend;
2392  break;
2393  }
2394  ReleaseSysCache(typeTuple);
2395 }
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:815
@ IOFunc_output
Definition: lsyscache.h:36
@ IOFunc_input
Definition: lsyscache.h:35
@ IOFunc_send
Definition: lsyscache.h:38
@ IOFunc_receive
Definition: lsyscache.h:37
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:454
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 2173 of file lsyscache.c.

2174 {
2175  HeapTuple tp;
2176 
2177  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2178  if (HeapTupleIsValid(tp))
2179  {
2180  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2181  bool result;
2182 
2183  result = typtup->typisdefined;
2184  ReleaseSysCache(tp);
2185  return result;
2186  }
2187  else
2188  return false;
2189 }

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

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

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2197 of file lsyscache.c.

2198 {
2199  HeapTuple tp;
2200 
2201  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2202  if (HeapTupleIsValid(tp))
2203  {
2204  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2205  int16 result;
2206 
2207  result = typtup->typlen;
2208  ReleaseSysCache(tp);
2209  return result;
2210  }
2211  else
2212  return 0;
2213 }

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

3007 {
3008  HeapTuple tp;
3009 
3010  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
3011  if (HeapTupleIsValid(tp))
3012  {
3013  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
3014  Oid result;
3015 
3016  result = typtup->typmodin;
3017  ReleaseSysCache(tp);
3018  return result;
3019  }
3020  else
3021  return InvalidOid;
3022 }

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2419 of file lsyscache.c.

2420 {
2421  HeapTuple tp;
2422 
2423  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2424  if (HeapTupleIsValid(tp))
2425  {
2426  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2427  char result;
2428 
2429  result = typtup->typstorage;
2430  ReleaseSysCache(tp);
2431  return result;
2432  }
2433  else
2434  return TYPSTORAGE_PLAIN;
2435 }

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

Referenced by GetAttributeStorage().

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3097 of file lsyscache.c.

3098 {
3099  HeapTuple tp;
3100 
3101  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
3102  if (HeapTupleIsValid(tp))
3103  {
3104  Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
3105  RegProcedure handler = typform->typsubscript;
3106 
3107  if (typelemp)
3108  *typelemp = typform->typelem;
3109  ReleaseSysCache(tp);
3110  return handler;
3111  }
3112  else
3113  {
3114  if (typelemp)
3115  *typelemp = InvalidOid;
3116  return InvalidOid;
3117  }
3118 }

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

Referenced by exec_check_rw_parameter(), and getSubscriptingRoutines().

◆ get_typtype()

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2538 of file lsyscache.c.

2539 {
2540  /*
2541  * We loop to find the bottom base type in a stack of domains.
2542  */
2543  for (;;)
2544  {
2545  HeapTuple tup;
2546  Form_pg_type typTup;
2547 
2548  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2549  if (!HeapTupleIsValid(tup))
2550  elog(ERROR, "cache lookup failed for type %u", typid);
2551  typTup = (Form_pg_type) GETSTRUCT(tup);
2552  if (typTup->typtype != TYPTYPE_DOMAIN)
2553  {
2554  /* Not a domain, so done */
2555  ReleaseSysCache(tup);
2556  break;
2557  }
2558 
2559  Assert(*typmod == -1);
2560  typid = typTup->typbasetype;
2561  *typmod = typTup->typtypmod;
2562 
2563  ReleaseSysCache(tup);
2564  }
2565 
2566  return typid;
2567 }

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

3131 {
3132  RegProcedure typsubscript = get_typsubscript(typid, typelemp);
3133 
3134  if (!OidIsValid(typsubscript))
3135  return NULL;
3136 
3137  return (const struct SubscriptRoutines *)
3138  DatumGetPointer(OidFunctionCall0(typsubscript));
3139 }
#define OidFunctionCall0(functionId)
Definition: fmgr.h:677
RegProcedure get_typsubscript(Oid typid, Oid *typelemp)
Definition: lsyscache.c:3097

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

2941 {
2942  HeapTuple typeTuple;
2943  Form_pg_type pt;
2944 
2945  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
2946  if (!HeapTupleIsValid(typeTuple))
2947  elog(ERROR, "cache lookup failed for type %u", type);
2948  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2949 
2950  if (!pt->typisdefined)
2951  ereport(ERROR,
2952  (errcode(ERRCODE_UNDEFINED_OBJECT),
2953  errmsg("type %s is only a shell",
2954  format_type_be(type))));
2955  if (!OidIsValid(pt->typreceive))
2956  ereport(ERROR,
2957  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2958  errmsg("no binary input function available for type %s",
2959  format_type_be(type))));
2960 
2961  *typReceive = pt->typreceive;
2962  *typIOParam = getTypeIOParam(typeTuple);
2963 
2964  ReleaseSysCache(typeTuple);
2965 }

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

2974 {
2975  HeapTuple typeTuple;
2976  Form_pg_type pt;
2977 
2978  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
2979  if (!HeapTupleIsValid(typeTuple))
2980  elog(ERROR, "cache lookup failed for type %u", type);
2981  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2982 
2983  if (!pt->typisdefined)
2984  ereport(ERROR,
2985  (errcode(ERRCODE_UNDEFINED_OBJECT),
2986  errmsg("type %s is only a shell",
2987  format_type_be(type))));
2988  if (!OidIsValid(pt->typsend))
2989  ereport(ERROR,
2990  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2991  errmsg("no binary output function available for type %s",
2992  format_type_be(type))));
2993 
2994  *typSend = pt->typsend;
2995  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2996 
2997  ReleaseSysCache(typeTuple);
2998 }

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(), SendFunctionResult(), and serialize_prepare_info().

◆ getTypeInputInfo()

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

Definition at line 2874 of file lsyscache.c.

2875 {
2876  HeapTuple typeTuple;
2877  Form_pg_type pt;
2878 
2879  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
2880  if (!HeapTupleIsValid(typeTuple))
2881  elog(ERROR, "cache lookup failed for type %u", type);
2882  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2883 
2884  if (!pt->typisdefined)
2885  ereport(ERROR,
2886  (errcode(ERRCODE_UNDEFINED_OBJECT),
2887  errmsg("type %s is only a shell",
2888  format_type_be(type))));
2889  if (!OidIsValid(pt->typinput))
2890  ereport(ERROR,
2891  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2892  errmsg("no input function available for type %s",
2893  format_type_be(type))));
2894 
2895  *typInput = pt->typinput;
2896  *typIOParam = getTypeIOParam(typeTuple);
2897 
2898  ReleaseSysCache(typeTuple);
2899 }

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

2304 {
2305  Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2306 
2307  /*
2308  * Array types get their typelem as parameter; everybody else gets their
2309  * own type OID as parameter.
2310  */
2311  if (OidIsValid(typeStruct->typelem))
2312  return typeStruct->typelem;
2313  else
2314  return typeStruct->oid;
2315 }

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

2908 {
2909  HeapTuple typeTuple;
2910  Form_pg_type pt;
2911 
2912  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
2913  if (!HeapTupleIsValid(typeTuple))
2914  elog(ERROR, "cache lookup failed for type %u", type);
2915  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2916 
2917  if (!pt->typisdefined)
2918  ereport(ERROR,
2919  (errcode(ERRCODE_UNDEFINED_OBJECT),
2920  errmsg("type %s is only a shell",
2921  format_type_be(type))));
2922  if (!OidIsValid(pt->typoutput))
2923  ereport(ERROR,
2924  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2925  errmsg("no output function available for type %s",
2926  format_type_be(type))));
2927 
2928  *typOutput = pt->typoutput;
2929  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2930 
2931  ReleaseSysCache(typeTuple);
2932 }

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(), serialize_prepare_info(), set_limit(), SPI_getvalue(), text_format(), and tuple_to_stringinfo().

◆ op_hashjoinable()

bool op_hashjoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1437 of file lsyscache.c.

1438 {
1439  bool result = false;
1440  HeapTuple tp;
1441  TypeCacheEntry *typentry;
1442 
1443  /* As in op_mergejoinable, let the typcache handle the hard cases */
1444  if (opno == ARRAY_EQ_OP)
1445  {
1446  typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1447  if (typentry->hash_proc == F_HASH_ARRAY)
1448  result = true;
1449  }
1450  else if (opno == RECORD_EQ_OP)
1451  {
1452  typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1453  if (typentry->hash_proc == F_HASH_RECORD)
1454  result = true;
1455  }
1456  else
1457  {
1458  /* For all other operators, rely on pg_operator.oprcanhash */
1459  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1460  if (HeapTupleIsValid(tp))
1461  {
1463 
1464  result = optup->oprcanhash;
1465  ReleaseSysCache(tp);
1466  }
1467  }
1468  return result;
1469 }
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:386
#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()

◆ op_input_types()

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

Definition at line 1358 of file lsyscache.c.

1359 {
1360  HeapTuple tp;
1361  Form_pg_operator optup;
1362 
1363  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1364  if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1365  elog(ERROR, "cache lookup failed for operator %u", opno);
1366  optup = (Form_pg_operator) GETSTRUCT(tp);
1367  *lefttype = optup->oprleft;
1368  *righttype = optup->oprright;
1369  ReleaseSysCache(tp);
1370 }

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

1387 {
1388  bool result = false;
1389  HeapTuple tp;
1390  TypeCacheEntry *typentry;
1391 
1392  /*
1393  * For array_eq or record_eq, we can sort if the element or field types
1394  * are all sortable. We could implement all the checks for that here, but
1395  * the typcache already does that and caches the results too, so let's
1396  * rely on the typcache.
1397  */
1398  if (opno == ARRAY_EQ_OP)
1399  {
1400  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1401  if (typentry->cmp_proc == F_BTARRAYCMP)
1402  result = true;
1403  }
1404  else if (opno == RECORD_EQ_OP)
1405  {
1406  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1407  if (typentry->cmp_proc == F_BTRECORDCMP)
1408  result = true;
1409  }
1410  else
1411  {
1412  /* For all other operators, rely on pg_operator.oprcanmerge */
1413  tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1414  if (HeapTupleIsValid(tp))
1415  {
1417 
1418  result = optup->oprcanmerge;
1419  ReleaseSysCache(tp);
1420  }
1421  }
1422  return result;
1423 }
#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 1477 of file lsyscache.c.

1478 {
1479  RegProcedure funcid = get_opcode(opno);
1480 
1481  if (funcid == (RegProcedure) InvalidOid)
1482  elog(ERROR, "operator %u does not exist", opno);
1483 
1484  return func_strict((Oid) funcid);
1485 }
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1285
bool func_strict(Oid funcid)
Definition: lsyscache.c:1761

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

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

◆ op_volatile()

char op_volatile ( Oid  opno)

Definition at line 1493 of file lsyscache.c.

1494 {
1495  RegProcedure funcid = get_opcode(opno);
1496 
1497  if (funcid == (RegProcedure) InvalidOid)
1498  elog(ERROR, "operator %u does not exist", opno);
1499 
1500  return func_volatile((Oid) funcid);
1501 }
char func_volatile(Oid funcid)
Definition: lsyscache.c:1780

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

2679 {
2680  return (get_typtype(typid) == TYPTYPE_ENUM);
2681 }
char get_typtype(Oid typid)
Definition: lsyscache.c:2629

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

2699 {
2700  return (get_typtype(typid) == TYPTYPE_MULTIRANGE);
2701 }

References get_typtype().

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

◆ type_is_range()

bool type_is_range ( Oid  typid)

Definition at line 2688 of file lsyscache.c.

2689 {
2690  return (get_typtype(typid) == TYPTYPE_RANGE);
2691 }

References get_typtype().

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

◆ type_is_rowtype()

bool type_is_rowtype ( Oid  typid)

Definition at line 2655 of file lsyscache.c.

2656 {
2657  if (typid == RECORDOID)
2658  return true; /* easy case */
2659  switch (get_typtype(typid))
2660  {
2661  case TYPTYPE_COMPOSITE:
2662  return true;
2663  case TYPTYPE_DOMAIN:
2664  if (get_typtype(getBaseType(typid)) == TYPTYPE_COMPOSITE)
2665  return true;
2666  break;
2667  default:
2668  break;
2669  }
2670  return false;
2671 }
Oid getBaseType(Oid typid)
Definition: lsyscache.c:2521

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(), match_orclause_to_indexcol(), plperl_hash_from_tuple(), plperl_ref_from_pg_array(), plperl_sv_to_datum(), plpgsql_exec_trigger(), and transformExprRecurse().

Variable Documentation

◆ get_attavgwidth_hook

get_attavgwidth_hook_type get_attavgwidth_hook = NULL

Definition at line 53 of file lsyscache.c.

Referenced by get_attavgwidth().