PostgreSQL Source Code  git master
lsyscache.c File Reference
#include "postgres.h"
#include "access/hash.h"
#include "access/htup_details.h"
#include "access/nbtree.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_collation.h"
#include "catalog/pg_constraint.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_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/rel.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_language_name (Oid langoid, bool missing_ok)
 
Oid get_opclass_family (Oid opclass)
 
Oid get_opclass_input_type (Oid opclass)
 
bool get_opclass_opfamily_and_input_type (Oid opclass, Oid *opfamily, Oid *opcintype)
 
Oid get_opclass_method (Oid opclass)
 
RegProcedure get_opcode (Oid opno)
 
char * get_opname (Oid opno)
 
Oid get_op_rettype (Oid opno)
 
void op_input_types (Oid opno, Oid *lefttype, Oid *righttype)
 
bool op_mergejoinable (Oid opno, Oid inputtype)
 
bool op_hashjoinable (Oid opno, Oid inputtype)
 
bool op_strict (Oid opno)
 
char op_volatile (Oid opno)
 
Oid get_commutator (Oid opno)
 
Oid get_negator (Oid opno)
 
RegProcedure get_oprrest (Oid opno)
 
RegProcedure get_oprjoin (Oid opno)
 
char * get_func_name (Oid funcid)
 
Oid get_func_namespace (Oid funcid)
 
Oid get_func_rettype (Oid funcid)
 
int get_func_nargs (Oid funcid)
 
Oid get_func_signature (Oid funcid, Oid **argtypes, int *nargs)
 
Oid get_func_variadictype (Oid funcid)
 
bool get_func_retset (Oid funcid)
 
bool func_strict (Oid funcid)
 
char func_volatile (Oid funcid)
 
char func_parallel (Oid funcid)
 
char get_func_prokind (Oid funcid)
 
bool get_func_leakproof (Oid funcid)
 
RegProcedure get_func_support (Oid funcid)
 
Oid get_relname_relid (const char *relname, Oid relnamespace)
 
char * get_rel_name (Oid relid)
 
Oid get_rel_namespace (Oid relid)
 
Oid get_rel_type_id (Oid relid)
 
char get_rel_relkind (Oid relid)
 
bool get_rel_relispartition (Oid relid)
 
Oid get_rel_tablespace (Oid relid)
 
char get_rel_persistence (Oid relid)
 
Oid get_transform_fromsql (Oid typid, Oid langid, List *trftypes)
 
Oid get_transform_tosql (Oid typid, Oid langid, List *trftypes)
 
bool get_typisdefined (Oid typid)
 
int16 get_typlen (Oid typid)
 
bool get_typbyval (Oid typid)
 
void get_typlenbyval (Oid typid, int16 *typlen, bool *typbyval)
 
void get_typlenbyvalalign (Oid typid, int16 *typlen, bool *typbyval, char *typalign)
 
Oid getTypeIOParam (HeapTuple typeTuple)
 
void get_type_io_data (Oid typid, IOFuncSelector which_func, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *func)
 
char get_typstorage (Oid typid)
 
Nodeget_typdefault (Oid typid)
 
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 748 of file lsyscache.c.

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

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

Referenced by ineq_histogram_selectivity().

◆ equality_ops_are_compatible()

bool equality_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 697 of file lsyscache.c.

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

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

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

1777 {
1778  HeapTuple tp;
1779  char result;
1780 
1781  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1782  if (!HeapTupleIsValid(tp))
1783  elog(ERROR, "cache lookup failed for function %u", funcid);
1784 
1785  result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1786  ReleaseSysCache(tp);
1787  return result;
1788 }
#define ERROR
Definition: elog.h:39
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:267
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:219

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

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

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

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

◆ func_volatile()

◆ get_array_type()

Oid get_array_type ( Oid  typid)

Definition at line 2742 of file lsyscache.c.

2743 {
2744  HeapTuple tp;
2745  Oid result = InvalidOid;
2746 
2747  tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2748  if (HeapTupleIsValid(tp))
2749  {
2750  result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
2751  ReleaseSysCache(tp);
2752  }
2753  return result;
2754 }
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define InvalidOid
Definition: postgres_ext.h:36
unsigned int Oid
Definition: postgres_ext.h:31

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

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

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 3113 of file lsyscache.c.

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

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

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

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

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

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

Referenced by AddRelationNewConstraints(), AddRelationNotNullConstraints(), AdjustNotNullInheritance(), AttachPartitionEnsureIndexes(), check_nested_generated_walker(), ComputePartitionAttrs(), contain_invalid_rfcolumn_walker(), CreateStatistics(), decompile_column_index_array(), deparseColumnRef(), dropconstraint_internal(), errtablecol(), fixup_inherited_columns(), generateClonedExtStatsStmt(), generateClonedIndexStmt(), get_insert_query_def(), get_merge_query_def(), get_rte_attribute_name(), get_update_query_targetlist_def(), getObjectDescription(), getObjectIdentityParts(), MergeConstraintsIntoExisting(), pg_get_constraintdef_worker(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsobj_worker(), pg_get_triggerdef_worker(), processIndirection(), pub_collist_contains_invalid_column(), RelationGetNotNullConstraints(), RememberAllDependentForRebuilding(), set_attnotnull(), transformPartitionBound(), and transformPartitionRangeBounds().

◆ get_attnum()

◆ get_attoptions()

Datum get_attoptions ( Oid  relid,
int16  attnum 
)

Definition at line 969 of file lsyscache.c.

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

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

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

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

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

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

944 {
945  HeapTuple tp;
946  Form_pg_attribute att_tup;
947 
948  tp = SearchSysCache2(ATTNUM,
949  ObjectIdGetDatum(relid),
951  if (!HeapTupleIsValid(tp))
952  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
953  attnum, relid);
954  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
955 
956  *typid = att_tup->atttypid;
957  *typmod = att_tup->atttypmod;
958  *collid = att_tup->attcollation;
959  ReleaseSysCache(tp);
960 }
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 2787 of file lsyscache.c.

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

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

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

◆ get_cast_oid()

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

Definition at line 1006 of file lsyscache.c.

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

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

Referenced by get_object_address().

◆ get_collation_isdeterministic()

bool get_collation_isdeterministic ( Oid  colloid)

Definition at line 1053 of file lsyscache.c.

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

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

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

◆ get_collation_name()

char* get_collation_name ( Oid  colloid)

Definition at line 1034 of file lsyscache.c.

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

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

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

◆ get_commutator()

Oid get_commutator ( Oid  opno)

◆ get_compatible_hash_operators()

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

Definition at line 409 of file lsyscache.c.

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

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

1113 {
1114  HeapTuple tp;
1115 
1116  tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
1117  if (HeapTupleIsValid(tp))
1118  {
1120  Oid result;
1121 
1122  if (contup->contype == CONSTRAINT_UNIQUE ||
1123  contup->contype == CONSTRAINT_PRIMARY ||
1124  contup->contype == CONSTRAINT_EXCLUSION)
1125  result = contup->conindid;
1126  else
1127  result = InvalidOid;
1128  ReleaseSysCache(tp);
1129  return result;
1130  }
1131  else
1132  return InvalidOid;
1133 }
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 1080 of file lsyscache.c.

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

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

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

◆ get_element_type()

◆ get_equality_op_for_ordering_op()

Oid get_equality_op_for_ordering_op ( Oid  opno,
bool reverse 
)

Definition at line 266 of file lsyscache.c.

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

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

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

◆ get_func_leakproof()

bool get_func_leakproof ( Oid  funcid)

Definition at line 1814 of file lsyscache.c.

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

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

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

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

1652 {
1653  HeapTuple tp;
1654  int result;
1655 
1656  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1657  if (!HeapTupleIsValid(tp))
1658  elog(ERROR, "cache lookup failed for function %u", funcid);
1659 
1660  result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1661  ReleaseSysCache(tp);
1662  return result;
1663 }
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 1795 of file lsyscache.c.

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

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

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

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

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

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

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

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

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

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

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

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

Referenced by gistproperty(), and spgproperty().

◆ get_index_isclustered()

bool get_index_isclustered ( Oid  index_oid)

Definition at line 3556 of file lsyscache.c.

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

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

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

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

Referenced by RememberReplicaIdentityForRebuilding().

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3533 of file lsyscache.c.

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

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

1139 {
1140  HeapTuple tp;
1141 
1142  tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
1143  if (HeapTupleIsValid(tp))
1144  {
1146  char *result;
1147 
1148  result = pstrdup(NameStr(lantup->lanname));
1149  ReleaseSysCache(tp);
1150  return result;
1151  }
1152 
1153  if (!missing_ok)
1154  elog(ERROR, "cache lookup failed for language %u",
1155  langoid);
1156  return NULL;
1157 }
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 365 of file lsyscache.c.

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

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

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

◆ get_multirange_range()

Oid get_multirange_range ( Oid  multirangeOid)

Definition at line 3438 of file lsyscache.c.

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

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

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

◆ get_namespace_name()

char* get_namespace_name ( Oid  nspid)

Definition at line 3321 of file lsyscache.c.

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

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

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

◆ get_namespace_name_or_temp()

◆ get_negator()

Oid get_negator ( Oid  opno)

Definition at line 1510 of file lsyscache.c.

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

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

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

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

Referenced by find_window_run_conditions(), lookup_proof_cache(), and make_row_comparison_op().

◆ get_op_hash_functions()

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

Definition at line 509 of file lsyscache.c.

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

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

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

◆ get_op_opfamily_properties()

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

Definition at line 135 of file lsyscache.c.

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

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

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

◆ get_op_opfamily_sortfamily()

Oid get_op_opfamily_sortfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 107 of file lsyscache.c.

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

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

Referenced by match_clause_to_ordering_op().

◆ get_op_opfamily_strategy()

int get_op_opfamily_strategy ( Oid  opno,
Oid  opfamily 
)

Definition at line 82 of file lsyscache.c.

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

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

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

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

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

◆ get_opclass_family()

Oid get_opclass_family ( Oid  opclass)

Definition at line 1167 of file lsyscache.c.

1168 {
1169  HeapTuple tp;
1170  Form_pg_opclass cla_tup;
1171  Oid result;
1172 
1173  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1174  if (!HeapTupleIsValid(tp))
1175  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1176  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1177 
1178  result = cla_tup->opcfamily;
1179  ReleaseSysCache(tp);
1180  return result;
1181 }
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 1189 of file lsyscache.c.

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

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

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

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

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

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

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

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1262 of file lsyscache.c.

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

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

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

◆ get_opfamily_member()

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

◆ get_opfamily_proc()

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

◆ get_opname()

char* get_opname ( Oid  opno)

Definition at line 1287 of file lsyscache.c.

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

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

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

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

Referenced by join_selectivity(), and scalararraysel().

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1534 of file lsyscache.c.

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

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

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

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

Referenced by create_unique_plan().

◆ get_ordering_op_properties()

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

Definition at line 206 of file lsyscache.c.

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

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

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

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

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

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

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

Referenced by get_object_address_unqualified(), and GetPublicationByName().

◆ get_range_collation()

Oid get_range_collation ( Oid  rangeOid)

Definition at line 3388 of file lsyscache.c.

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

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

Referenced by CheckAttributeType().

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

Definition at line 3413 of file lsyscache.c.

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

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

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

◆ get_range_subtype()

Oid get_range_subtype ( Oid  rangeOid)

Definition at line 3362 of file lsyscache.c.

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

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

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

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

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_attnums(), AdjustNotNullInheritance(), AdjustNotNullInheritance1(), AlterPublicationOptions(), AlterSubscription_refresh(), AlterTableNamespace(), ATExecAlterConstraint(), ATExecChangeOwner(), check_enable_rls(), check_new_partition_bound(), check_publications_origin(), convert_column_name(), CreateTriggerFiringOn(), DefineRelation(), do_autovacuum(), EnableDisableRule(), exec_object_restorecon(), ExecCheckPermissions(), execCurrentOf(), expand_col_privileges(), explain_get_index_name(), ExplainTargetRel(), get_relation_constraint_attnos(), get_relation_constraint_oid(), get_relation_name(), get_relation_policy_oid(), get_rewrite_oid(), get_trigger_oid(), gincost_pattern(), has_sequence_privilege_id(), has_sequence_privilege_id_id(), has_sequence_privilege_name_id(), heap_truncate_check_FKs(), InitializeLogRepWorker(), InsertRule(), LockTableRecurse(), LockViewRecurse_walker(), make_modifytable(), makeWholeRowVar(), map_sql_schema_to_xmlschema_types(), MarkInheritDetached(), perform_work_item(), pg_attribute_noreturn(), pg_decode_change(), pg_extension_config_dump(), pg_prewarm(), pg_sequence_parameters(), postgresExplainForeignScan(), process_owned_by(), reindex_index(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), RememberClusterOnForRebuilding(), RememberReplicaIdentityForRebuilding(), RemoveSubscriptionRel(), RenameConstraintById(), renametrig(), satisfies_hash_partition(), set_rtable_names(), show_modifytable_info(), swap_relation_files(), SysCacheGetAttrNotNull(), table_to_xml_internal(), TargetPrivilegesCheck(), and transformAlterTableStmt().

◆ get_rel_namespace()

◆ get_rel_persistence()

char get_rel_persistence ( Oid  relid)

Definition at line 2055 of file lsyscache.c.

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

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

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

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

Definition at line 2004 of file lsyscache.c.

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

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

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

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

Referenced by AlterPublicationOptions(), AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), ATExecAlterConstrRecurse(), ATExecChangeOwner(), check_rel_can_be_partition(), check_relation_privileges(), CreateSubscription(), CreateTriggerFiringOn(), doDeletion(), EnableDisableRule(), exec_object_restorecon(), ExecCheckPermissions(), get_object_type(), get_rel_sync_entry(), get_tables_to_cluster_partitioned(), getOwnedSequences_internal(), GetPubPartitionOptionRelations(), GetSchemaPublicationRelations(), has_sequence_privilege_id(), has_sequence_privilege_id_id(), has_sequence_privilege_id_name(), has_sequence_privilege_name(), has_sequence_privilege_name_id(), has_sequence_privilege_name_name(), LockTableCommand(), pg_get_serial_sequence(), pg_get_triggerdef_worker(), pg_partition_tree(), ProcessUtilitySlow(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForLockTable(), RangeVarCallbackForPolicy(), RangeVarCallbackForReindexIndex(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackOwnsRelation(), RangeVarCallbackOwnsTable(), RangeVarGetAndCheckCreationNamespace(), ReindexIndex(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), ReindexTable(), RelationBuildPartitionDesc(), RememberAllDependentForRebuilding(), renameatt_check(), RenameRelation(), RenameType(), sepgsql_attribute_drop(), sepgsql_attribute_post_create(), sepgsql_attribute_relabel(), sepgsql_attribute_setattr(), sepgsql_relation_drop(), sepgsql_relation_relabel(), sepgsql_relation_setattr(), and sepgsql_relation_truncate().

◆ get_rel_tablespace()

Oid get_rel_tablespace ( Oid  relid)

Definition at line 2031 of file lsyscache.c.

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

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

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

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

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

◆ get_relname_relid()

Oid get_relname_relid ( const char *  relname,
Oid  relnamespace 
)

◆ get_subscription_name()

char* get_subscription_name ( Oid  subid,
bool  missing_ok 
)

Definition at line 3650 of file lsyscache.c.

3651 {
3652  HeapTuple tup;
3653  char *subname;
3654  Form_pg_subscription subform;
3655 
3656  tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
3657 
3658  if (!HeapTupleIsValid(tup))
3659  {
3660  if (!missing_ok)
3661  elog(ERROR, "cache lookup failed for subscription %u", subid);
3662  return NULL;
3663  }
3664 
3665  subform = (Form_pg_subscription) GETSTRUCT(tup);
3666  subname = pstrdup(NameStr(subform->subname));
3667 
3668  ReleaseSysCache(tup);
3669 
3670  return subname;
3671 }
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 3630 of file lsyscache.c.

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

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

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

◆ get_transform_fromsql()

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

Definition at line 2075 of file lsyscache.c.

2076 {
2077  HeapTuple tup;
2078 
2079  if (!list_member_oid(trftypes, typid))
2080  return InvalidOid;
2081 
2082  tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
2083  ObjectIdGetDatum(langid));
2084  if (HeapTupleIsValid(tup))
2085  {
2086  Oid funcid;
2087 
2088  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2089  ReleaseSysCache(tup);
2090  return funcid;
2091  }
2092  else
2093  return InvalidOid;
2094 }
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 2097 of file lsyscache.c.

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

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

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

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

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

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

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

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

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

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

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

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

◆ get_type_io_data()

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

Definition at line 2280 of file lsyscache.c.

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

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

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

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

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2152 of file lsyscache.c.

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

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

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

◆ get_typlenbyval()

◆ get_typlenbyvalalign()

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 2961 of file lsyscache.c.

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

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2374 of file lsyscache.c.

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

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

Referenced by GetAttributeStorage().

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3052 of file lsyscache.c.

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

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

Referenced by exec_check_rw_parameter(), and getSubscriptingRoutines().

◆ get_typtype()

char get_typtype ( Oid  typid)

Definition at line 2584 of file lsyscache.c.

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

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

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

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2493 of file lsyscache.c.

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

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

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

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

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

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

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

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

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

◆ getTypeInputInfo()

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

Definition at line 2829 of file lsyscache.c.

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

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

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

◆ getTypeIOParam()

Oid getTypeIOParam ( HeapTuple  typeTuple)

Definition at line 2258 of file lsyscache.c.

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

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

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

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

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

◆ op_hashjoinable()

bool op_hashjoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1414 of file lsyscache.c.

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

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

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

◆ op_in_opfamily()

bool op_in_opfamily ( Oid  opno,
Oid  opfamily 
)

◆ op_input_types()

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

Definition at line 1335 of file lsyscache.c.

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

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

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

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

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

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

◆ op_volatile()

char op_volatile ( Oid  opno)

Definition at line 1470 of file lsyscache.c.

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

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

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

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

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

References get_typtype().

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

◆ type_is_range()

bool type_is_range ( Oid  typid)

Definition at line 2643 of file lsyscache.c.

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

References get_typtype().

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

◆ type_is_rowtype()

bool type_is_rowtype ( Oid  typid)

Definition at line 2610 of file lsyscache.c.

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

References get_typtype(), and getBaseType().

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

Variable Documentation

◆ get_attavgwidth_hook

get_attavgwidth_hook_type get_attavgwidth_hook = NULL

Definition at line 52 of file lsyscache.c.

Referenced by get_attavgwidth().