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)
 
int get_attstattarget (Oid relid, AttrNumber attnum)
 
char get_attgenerated (Oid relid, AttrNumber attnum)
 
Oid get_atttype (Oid relid, AttrNumber attnum)
 
void get_atttypetypmodcoll (Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
 
Datum get_attoptions (Oid relid, int16 attnum)
 
Oid get_cast_oid (Oid sourcetypeid, Oid targettypeid, bool missing_ok)
 
char * get_collation_name (Oid colloid)
 
bool get_collation_isdeterministic (Oid colloid)
 
char * get_constraint_name (Oid conoid)
 
Oid get_constraint_index (Oid conoid)
 
char * get_language_name (Oid langoid, bool missing_ok)
 
Oid get_opclass_family (Oid opclass)
 
Oid get_opclass_input_type (Oid opclass)
 
bool get_opclass_opfamily_and_input_type (Oid opclass, Oid *opfamily, Oid *opcintype)
 
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
@ AMOPOPID
Definition: syscache.h:37
#define ReleaseSysCacheList(x)
Definition: syscache.h:225
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:218

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

Referenced by ineq_histogram_selectivity().

◆ equality_ops_are_compatible()

bool equality_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 697 of file lsyscache.c.

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

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

Referenced by query_is_distinct_for().

◆ free_attstatsslot()

void free_attstatsslot ( AttStatsSlot sslot)

Definition at line 3326 of file lsyscache.c.

3327 {
3328  /* The values[] array was separately palloc'd by deconstruct_array */
3329  if (sslot->values)
3330  pfree(sslot->values);
3331  /* The numbers[] array points into numbers_arr, do not pfree it */
3332  /* Free the detoasted array objects, if any */
3333  if (sslot->values_arr)
3334  pfree(sslot->values_arr);
3335  if (sslot->numbers_arr)
3336  pfree(sslot->numbers_arr);
3337 }
void pfree(void *pointer)
Definition: mcxt.c:1456
Datum * values
Definition: lsyscache.h:53
void * numbers_arr
Definition: lsyscache.h:61
void * values_arr
Definition: lsyscache.h:60

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

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

◆ func_parallel()

char func_parallel ( Oid  funcid)

Definition at line 1803 of file lsyscache.c.

1804 {
1805  HeapTuple tp;
1806  char result;
1807 
1808  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1809  if (!HeapTupleIsValid(tp))
1810  elog(ERROR, "cache lookup failed for function %u", funcid);
1811 
1812  result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1813  ReleaseSysCache(tp);
1814  return result;
1815 }
#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:868
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:820
@ PROCOID
Definition: syscache.h:79

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

Referenced by max_parallel_hazard_checker(), and set_rel_consider_parallel().

◆ func_strict()

bool func_strict ( Oid  funcid)

Definition at line 1765 of file lsyscache.c.

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

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

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

◆ func_volatile()

◆ get_array_type()

Oid get_array_type ( Oid  typid)

Definition at line 2769 of file lsyscache.c.

2770 {
2771  HeapTuple tp;
2772  Oid result = InvalidOid;
2773 
2775  if (HeapTupleIsValid(tp))
2776  {
2777  result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
2778  ReleaseSysCache(tp);
2779  }
2780  return result;
2781 }
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define InvalidOid
Definition: postgres_ext.h:36
unsigned int Oid
Definition: postgres_ext.h:31
@ TYPEOID
Definition: syscache.h:114

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

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

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 3140 of file lsyscache.c.

3141 {
3142  HeapTuple tp;
3143  int32 stawidth;
3144 
3146  {
3147  stawidth = (*get_attavgwidth_hook) (relid, attnum);
3148  if (stawidth > 0)
3149  return stawidth;
3150  }
3152  ObjectIdGetDatum(relid),
3154  BoolGetDatum(false));
3155  if (HeapTupleIsValid(tp))
3156  {
3157  stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3158  ReleaseSysCache(tp);
3159  if (stawidth > 0)
3160  return stawidth;
3161  }
3162  return 0;
3163 }
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:842
@ STATRELATTINH
Definition: syscache.h:97

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

Referenced by get_rel_data_width(), and set_rel_width().

◆ get_attgenerated()

char get_attgenerated ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 914 of file lsyscache.c.

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

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

Referenced by check_nested_generated_walker().

◆ get_attname()

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

Definition at line 826 of file lsyscache.c.

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

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

Referenced by AddRelationNewConstraints(), AddRelationNotNullConstraints(), AdjustNotNullInheritance(), ATExecAlterColumnType(), 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(), set_attnotnull(), transformPartitionBound(), and transformPartitionRangeBounds().

◆ get_attnum()

◆ get_attoptions()

Datum get_attoptions ( Oid  relid,
int16  attnum 
)

Definition at line 996 of file lsyscache.c.

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

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

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

◆ get_attstatsslot()

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

Definition at line 3216 of file lsyscache.c.

3218 {
3219  Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
3220  int i;
3221  Datum val;
3222  ArrayType *statarray;
3223  Oid arrayelemtype;
3224  int narrayelem;
3225  HeapTuple typeTuple;
3226  Form_pg_type typeForm;
3227 
3228  /* initialize *sslot properly */
3229  memset(sslot, 0, sizeof(AttStatsSlot));
3230 
3231  for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
3232  {
3233  if ((&stats->stakind1)[i] == reqkind &&
3234  (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
3235  break;
3236  }
3237  if (i >= STATISTIC_NUM_SLOTS)
3238  return false; /* not there */
3239 
3240  sslot->staop = (&stats->staop1)[i];
3241  sslot->stacoll = (&stats->stacoll1)[i];
3242 
3243  if (flags & ATTSTATSSLOT_VALUES)
3244  {
3246  Anum_pg_statistic_stavalues1 + i);
3247 
3248  /*
3249  * Detoast the array if needed, and in any case make a copy that's
3250  * under control of this AttStatsSlot.
3251  */
3252  statarray = DatumGetArrayTypePCopy(val);
3253 
3254  /*
3255  * Extract the actual array element type, and pass it back in case the
3256  * caller needs it.
3257  */
3258  sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3259 
3260  /* Need info about element type */
3261  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
3262  if (!HeapTupleIsValid(typeTuple))
3263  elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3264  typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
3265 
3266  /* Deconstruct array into Datum elements; NULLs not expected */
3267  deconstruct_array(statarray,
3268  arrayelemtype,
3269  typeForm->typlen,
3270  typeForm->typbyval,
3271  typeForm->typalign,
3272  &sslot->values, NULL, &sslot->nvalues);
3273 
3274  /*
3275  * If the element type is pass-by-reference, we now have a bunch of
3276  * Datums that are pointers into the statarray, so we need to keep
3277  * that until free_attstatsslot. Otherwise, all the useful info is in
3278  * sslot->values[], so we can free the array object immediately.
3279  */
3280  if (!typeForm->typbyval)
3281  sslot->values_arr = statarray;
3282  else
3283  pfree(statarray);
3284 
3285  ReleaseSysCache(typeTuple);
3286  }
3287 
3288  if (flags & ATTSTATSSLOT_NUMBERS)
3289  {
3291  Anum_pg_statistic_stanumbers1 + i);
3292 
3293  /*
3294  * Detoast the array if needed, and in any case make a copy that's
3295  * under control of this AttStatsSlot.
3296  */
3297  statarray = DatumGetArrayTypePCopy(val);
3298 
3299  /*
3300  * We expect the array to be a 1-D float4 array; verify that. We don't
3301  * need to use deconstruct_array() since the array data is just going
3302  * to look like a C array of float4 values.
3303  */
3304  narrayelem = ARR_DIMS(statarray)[0];
3305  if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3306  ARR_HASNULL(statarray) ||
3307  ARR_ELEMTYPE(statarray) != FLOAT4OID)
3308  elog(ERROR, "stanumbers is not a 1-D float4 array");
3309 
3310  /* Give caller a pointer directly into the statarray */
3311  sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3312  sslot->nnumbers = narrayelem;
3313 
3314  /* We'll free the statarray in free_attstatsslot */
3315  sslot->numbers_arr = statarray;
3316  }
3317 
3318  return true;
3319 }
#define DatumGetArrayTypePCopy(X)
Definition: array.h:255
#define ARR_NDIM(a)
Definition: array.h:283
#define ARR_DATA_PTR(a)
Definition: array.h:315
#define ARR_ELEMTYPE(a)
Definition: array.h:285
#define ARR_DIMS(a)
Definition: array.h:287
#define ARR_HASNULL(a)
Definition: array.h:284
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3578
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:1112

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

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

◆ get_attstattarget()

int get_attstattarget ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 884 of file lsyscache.c.

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

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

Referenced by index_concurrently_swap().

◆ get_atttype()

Oid get_atttype ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 939 of file lsyscache.c.

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

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

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

◆ get_atttypetypmodcoll()

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

Definition at line 969 of file lsyscache.c.

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

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

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

◆ get_base_element_type()

Oid get_base_element_type ( Oid  typid)

Definition at line 2814 of file lsyscache.c.

2815 {
2816  /*
2817  * We loop to find the bottom base type in a stack of domains.
2818  */
2819  for (;;)
2820  {
2821  HeapTuple tup;
2822  Form_pg_type typTup;
2823 
2824  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2825  if (!HeapTupleIsValid(tup))
2826  break;
2827  typTup = (Form_pg_type) GETSTRUCT(tup);
2828  if (typTup->typtype != TYPTYPE_DOMAIN)
2829  {
2830  /* Not a domain, so stop descending */
2831  Oid result;
2832 
2833  /* This test must match get_element_type */
2834  if (IsTrueArrayType(typTup))
2835  result = typTup->typelem;
2836  else
2837  result = InvalidOid;
2838  ReleaseSysCache(tup);
2839  return result;
2840  }
2841 
2842  typid = typTup->typbasetype;
2843  ReleaseSysCache(tup);
2844  }
2845 
2846  /* Like get_element_type, silently return InvalidOid for bogus input */
2847  return InvalidOid;
2848 }

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

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

◆ get_cast_oid()

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

Definition at line 1033 of file lsyscache.c.

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

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

Referenced by get_object_address().

◆ get_collation_isdeterministic()

bool get_collation_isdeterministic ( Oid  colloid)

Definition at line 1080 of file lsyscache.c.

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

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

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

◆ get_collation_name()

char* get_collation_name ( Oid  colloid)

Definition at line 1061 of file lsyscache.c.

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

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

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

◆ get_commutator()

◆ get_compatible_hash_operators()

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

Definition at line 409 of file lsyscache.c.

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

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

Referenced by create_unique_plan(), and ExecInitSubPlan().

◆ get_constraint_index()

Oid get_constraint_index ( Oid  conoid)

Definition at line 1139 of file lsyscache.c.

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

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

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

◆ get_constraint_name()

char* get_constraint_name ( Oid  conoid)

Definition at line 1107 of file lsyscache.c.

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

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

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

◆ get_element_type()

◆ get_equality_op_for_ordering_op()

Oid get_equality_op_for_ordering_op ( Oid  opno,
bool reverse 
)

Definition at line 266 of file lsyscache.c.

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

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

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

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

◆ get_func_name()

◆ get_func_namespace()

Oid get_func_namespace ( Oid  funcid)

Definition at line 1636 of file lsyscache.c.

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

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

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

◆ get_func_nargs()

int get_func_nargs ( Oid  funcid)

Definition at line 1678 of file lsyscache.c.

1679 {
1680  HeapTuple tp;
1681  int result;
1682 
1683  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1684  if (!HeapTupleIsValid(tp))
1685  elog(ERROR, "cache lookup failed for function %u", funcid);
1686 
1687  result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1688  ReleaseSysCache(tp);
1689  return result;
1690 }
int16 pronargs
Definition: pg_proc.h:81

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

◆ get_func_prokind()

char get_func_prokind ( Oid  funcid)

Definition at line 1822 of file lsyscache.c.

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

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

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

◆ get_func_retset()

bool get_func_retset ( Oid  funcid)

Definition at line 1746 of file lsyscache.c.

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

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

Referenced by make_op(), and make_scalar_array_op().

◆ get_func_rettype()

◆ get_func_signature()

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

Definition at line 1700 of file lsyscache.c.

1701 {
1702  HeapTuple tp;
1703  Form_pg_proc procstruct;
1704  Oid result;
1705 
1706  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1707  if (!HeapTupleIsValid(tp))
1708  elog(ERROR, "cache lookup failed for function %u", funcid);
1709 
1710  procstruct = (Form_pg_proc) GETSTRUCT(tp);
1711 
1712  result = procstruct->prorettype;
1713  *nargs = (int) procstruct->pronargs;
1714  Assert(*nargs == procstruct->proargtypes.dim1);
1715  *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1716  memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1717 
1718  ReleaseSysCache(tp);
1719  return result;
1720 }
Assert(fmt[strlen(fmt) - 1] !='\n')
void * palloc(Size size)
Definition: mcxt.c:1226

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

Referenced by plperl_call_perl_func(), and resolve_aggregate_transtype().

◆ get_func_support()

RegProcedure get_func_support ( Oid  funcid)

Definition at line 1862 of file lsyscache.c.

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

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

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

◆ get_func_variadictype()

Oid get_func_variadictype ( Oid  funcid)

Definition at line 1727 of file lsyscache.c.

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

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

Referenced by assign_hypothetical_collations(), and assign_ordered_set_collations().

◆ get_index_column_opclass()

Oid get_index_column_opclass ( Oid  index_oid,
int  attno 
)

Definition at line 3494 of file lsyscache.c.

3495 {
3496  HeapTuple tuple;
3497  Form_pg_index rd_index;
3498  Datum datum;
3499  oidvector *indclass;
3500  Oid opclass;
3501 
3502  /* First we need to know the column's opclass. */
3503 
3504  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3505  if (!HeapTupleIsValid(tuple))
3506  return InvalidOid;
3507 
3508  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3509 
3510  /* caller is supposed to guarantee this */
3511  Assert(attno > 0 && attno <= rd_index->indnatts);
3512 
3513  /* Non-key attributes don't have an opclass */
3514  if (attno > rd_index->indnkeyatts)
3515  {
3516  ReleaseSysCache(tuple);
3517  return InvalidOid;
3518  }
3519 
3520  datum = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
3521  indclass = ((oidvector *) DatumGetPointer(datum));
3522 
3523  Assert(attno <= indclass->dim1);
3524  opclass = indclass->values[attno - 1];
3525 
3526  ReleaseSysCache(tuple);
3527 
3528  return opclass;
3529 }
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
@ INDEXRELID
Definition: syscache.h:66

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

Referenced by gistproperty(), and spgproperty().

◆ get_index_isclustered()

bool get_index_isclustered ( Oid  index_oid)

Definition at line 3583 of file lsyscache.c.

3584 {
3585  bool isclustered;
3586  HeapTuple tuple;
3587  Form_pg_index rd_index;
3588 
3589  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3590  if (!HeapTupleIsValid(tuple))
3591  elog(ERROR, "cache lookup failed for index %u", index_oid);
3592 
3593  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3594  isclustered = rd_index->indisclustered;
3595  ReleaseSysCache(tuple);
3596 
3597  return isclustered;
3598 }

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

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

◆ get_index_isreplident()

bool get_index_isreplident ( Oid  index_oid)

Definition at line 3537 of file lsyscache.c.

3538 {
3539  HeapTuple tuple;
3540  Form_pg_index rd_index;
3541  bool result;
3542 
3543  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3544  if (!HeapTupleIsValid(tuple))
3545  return false;
3546 
3547  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3548  result = rd_index->indisreplident;
3549  ReleaseSysCache(tuple);
3550 
3551  return result;
3552 }

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

Referenced by RememberReplicaIdentityForRebuilding().

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3560 of file lsyscache.c.

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

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

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

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

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

◆ get_mergejoin_opfamilies()

List* get_mergejoin_opfamilies ( Oid  opno)

Definition at line 365 of file lsyscache.c.

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

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

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

◆ get_multirange_range()

Oid get_multirange_range ( Oid  multirangeOid)

Definition at line 3465 of file lsyscache.c.

3466 {
3467  HeapTuple tp;
3468 
3469  tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
3470  if (HeapTupleIsValid(tp))
3471  {
3472  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3473  Oid result;
3474 
3475  result = rngtup->rngtypid;
3476  ReleaseSysCache(tp);
3477  return result;
3478  }
3479  else
3480  return InvalidOid;
3481 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:58
@ RANGEMULTIRANGE
Definition: syscache.h:86

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

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

◆ get_namespace_name()

char* get_namespace_name ( Oid  nspid)

Definition at line 3348 of file lsyscache.c.

3349 {
3350  HeapTuple tp;
3351 
3353  if (HeapTupleIsValid(tp))
3354  {
3356  char *result;
3357 
3358  result = pstrdup(NameStr(nsptup->nspname));
3359  ReleaseSysCache(tp);
3360  return result;
3361  }
3362  else
3363  return NULL;
3364 }
int nspid
FormData_pg_namespace * Form_pg_namespace
Definition: pg_namespace.h:52
@ NAMESPACEOID
Definition: syscache.h:70

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

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

◆ get_namespace_name_or_temp()

◆ get_negator()

Oid get_negator ( Oid  opno)

Definition at line 1537 of file lsyscache.c.

1538 {
1539  HeapTuple tp;
1540 
1542  if (HeapTupleIsValid(tp))
1543  {
1545  Oid result;
1546 
1547  result = optup->oprnegate;
1548  ReleaseSysCache(tp);
1549  return result;
1550  }
1551  else
1552  return InvalidOid;
1553 }

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

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

◆ get_op_btree_interpretation()

List* get_op_btree_interpretation ( Oid  opno)

Definition at line 600 of file lsyscache.c.

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

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

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

◆ get_op_hash_functions()

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

Definition at line 509 of file lsyscache.c.

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

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

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

◆ get_op_opfamily_properties()

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

Definition at line 135 of file lsyscache.c.

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

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

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

◆ get_op_opfamily_sortfamily()

Oid get_op_opfamily_sortfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 107 of file lsyscache.c.

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

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

Referenced by match_clause_to_ordering_op().

◆ get_op_opfamily_strategy()

int get_op_opfamily_strategy ( Oid  opno,
Oid  opfamily 
)

Definition at line 82 of file lsyscache.c.

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

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

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

◆ get_op_rettype()

Oid get_op_rettype ( Oid  opno)

Definition at line 1337 of file lsyscache.c.

1338 {
1339  HeapTuple tp;
1340 
1342  if (HeapTupleIsValid(tp))
1343  {
1345  Oid result;
1346 
1347  result = optup->oprresult;
1348  ReleaseSysCache(tp);
1349  return result;
1350  }
1351  else
1352  return InvalidOid;
1353 }

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

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

◆ get_opclass_family()

Oid get_opclass_family ( Oid  opclass)

Definition at line 1194 of file lsyscache.c.

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

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

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

◆ get_opclass_input_type()

Oid get_opclass_input_type ( Oid  opclass)

Definition at line 1216 of file lsyscache.c.

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

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

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

◆ get_opclass_method()

Oid get_opclass_method ( Oid  opclass)

Definition at line 1264 of file lsyscache.c.

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

References CLAOID, 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 1239 of file lsyscache.c.

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

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

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

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1289 of file lsyscache.c.

1290 {
1291  HeapTuple tp;
1292 
1294  if (HeapTupleIsValid(tp))
1295  {
1297  RegProcedure result;
1298 
1299  result = optup->oprcode;
1300  ReleaseSysCache(tp);
1301  return result;
1302  }
1303  else
1304  return (RegProcedure) InvalidOid;
1305 }

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

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

◆ get_opfamily_member()

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

Definition at line 165 of file lsyscache.c.

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

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

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

◆ get_opfamily_proc()

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

◆ get_opname()

char* get_opname ( Oid  opno)

Definition at line 1314 of file lsyscache.c.

1315 {
1316  HeapTuple tp;
1317 
1319  if (HeapTupleIsValid(tp))
1320  {
1322  char *result;
1323 
1324  result = pstrdup(NameStr(optup->oprname));
1325  ReleaseSysCache(tp);
1326  return result;
1327  }
1328  else
1329  return NULL;
1330 }

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

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

◆ get_oprjoin()

RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1585 of file lsyscache.c.

1586 {
1587  HeapTuple tp;
1588 
1590  if (HeapTupleIsValid(tp))
1591  {
1593  RegProcedure result;
1594 
1595  result = optup->oprjoin;
1596  ReleaseSysCache(tp);
1597  return result;
1598  }
1599  else
1600  return (RegProcedure) InvalidOid;
1601 }

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

Referenced by join_selectivity(), and scalararraysel().

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1561 of file lsyscache.c.

1562 {
1563  HeapTuple tp;
1564 
1566  if (HeapTupleIsValid(tp))
1567  {
1569  RegProcedure result;
1570 
1571  result = optup->oprrest;
1572  ReleaseSysCache(tp);
1573  return result;
1574  }
1575  else
1576  return (RegProcedure) InvalidOid;
1577 }

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

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

◆ get_ordering_op_for_equality_op()

Oid get_ordering_op_for_equality_op ( Oid  opno,
bool  use_lhs_type 
)

Definition at line 304 of file lsyscache.c.

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

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

Referenced by create_unique_plan().

◆ get_ordering_op_properties()

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

Definition at line 206 of file lsyscache.c.

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

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

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

◆ get_promoted_array_type()

Oid get_promoted_array_type ( Oid  typid)

Definition at line 2793 of file lsyscache.c.

2794 {
2795  Oid array_type = get_array_type(typid);
2796 
2797  if (OidIsValid(array_type))
2798  return array_type;
2799  if (OidIsValid(get_element_type(typid)))
2800  return typid;
2801  return InvalidOid;
2802 }
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2741
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2769

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

3628 {
3629  HeapTuple tup;
3630  char *pubname;
3631  Form_pg_publication pubform;
3632 
3634 
3635  if (!HeapTupleIsValid(tup))
3636  {
3637  if (!missing_ok)
3638  elog(ERROR, "cache lookup failed for publication %u", pubid);
3639  return NULL;
3640  }
3641 
3642  pubform = (Form_pg_publication) GETSTRUCT(tup);
3643  pubname = pstrdup(NameStr(pubform->pubname));
3644 
3645  ReleaseSysCache(tup);
3646 
3647  return pubname;
3648 }
FormData_pg_publication * Form_pg_publication
@ PUBLICATIONOID
Definition: syscache.h:83

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

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

◆ get_publication_oid()

Oid get_publication_oid ( const char *  pubname,
bool  missing_ok 
)

Definition at line 3607 of file lsyscache.c.

3608 {
3609  Oid oid;
3610 
3611  oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
3612  CStringGetDatum(pubname));
3613  if (!OidIsValid(oid) && !missing_ok)
3614  ereport(ERROR,
3615  (errcode(ERRCODE_UNDEFINED_OBJECT),
3616  errmsg("publication \"%s\" does not exist", pubname)));
3617  return oid;
3618 }
static Datum CStringGetDatum(const char *X)
Definition: postgres.h:350
@ PUBLICATIONNAME
Definition: syscache.h:80
#define GetSysCacheOid1(cacheId, oidcol, key1)
Definition: syscache.h:200

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

Referenced by get_object_address_unqualified(), and GetPublicationByName().

◆ get_range_collation()

Oid get_range_collation ( Oid  rangeOid)

Definition at line 3415 of file lsyscache.c.

3416 {
3417  HeapTuple tp;
3418 
3419  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3420  if (HeapTupleIsValid(tp))
3421  {
3422  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3423  Oid result;
3424 
3425  result = rngtup->rngcollation;
3426  ReleaseSysCache(tp);
3427  return result;
3428  }
3429  else
3430  return InvalidOid;
3431 }
@ RANGETYPE
Definition: syscache.h:87

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

Referenced by CheckAttributeType().

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

Definition at line 3440 of file lsyscache.c.

3441 {
3442  HeapTuple tp;
3443 
3444  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3445  if (HeapTupleIsValid(tp))
3446  {
3447  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3448  Oid result;
3449 
3450  result = rngtup->rngmultitypid;
3451  ReleaseSysCache(tp);
3452  return result;
3453  }
3454  else
3455  return InvalidOid;
3456 }

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

Referenced by enforce_generic_type_consistency(), and resolve_anymultirange_from_others().

◆ get_range_subtype()

Oid get_range_subtype ( Oid  rangeOid)

Definition at line 3389 of file lsyscache.c.

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

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

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

◆ get_rel_name()

char* get_rel_name ( Oid  relid)

Definition at line 1932 of file lsyscache.c.

1933 {
1934  HeapTuple tp;
1935 
1936  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1937  if (HeapTupleIsValid(tp))
1938  {
1939  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1940  char *result;
1941 
1942  result = pstrdup(NameStr(reltup->relname));
1943  ReleaseSysCache(tp);
1944  return result;
1945  }
1946  else
1947  return NULL;
1948 }
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
@ RELOID
Definition: syscache.h:89

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

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_attnums(), 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_get_expr(), pg_get_expr_ext(), pg_prewarm(), pg_sequence_parameters(), postgresExplainForeignScan(), process_owned_by(), reindex_index(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), RememberClusterOnForRebuilding(), RememberReplicaIdentityForRebuilding(), RemoveSubscriptionRel(), RenameConstraintById(), renametrig(), satisfies_hash_partition(), set_rtable_names(), show_modifytable_info(), 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 2082 of file lsyscache.c.

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

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

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

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

Definition at line 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  bool result;
2040 
2041  result = reltup->relispartition;
2042  ReleaseSysCache(tp);
2043  return result;
2044  }
2045  else
2046  return false;
2047 }

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

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

◆ get_rel_relkind()

char get_rel_relkind ( Oid  relid)

Definition at line 2007 of file lsyscache.c.

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

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

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

◆ get_rel_tablespace()

Oid get_rel_tablespace ( Oid  relid)

Definition at line 2058 of file lsyscache.c.

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

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

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

◆ get_rel_type_id()

Oid get_rel_type_id ( Oid  relid)

Definition at line 1983 of file lsyscache.c.

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

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

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

◆ get_relname_relid()

◆ get_subscription_name()

char* get_subscription_name ( Oid  subid,
bool  missing_ok 
)

Definition at line 3677 of file lsyscache.c.

3678 {
3679  HeapTuple tup;
3680  char *subname;
3681  Form_pg_subscription subform;
3682 
3684 
3685  if (!HeapTupleIsValid(tup))
3686  {
3687  if (!missing_ok)
3688  elog(ERROR, "cache lookup failed for subscription %u", subid);
3689  return NULL;
3690  }
3691 
3692  subform = (Form_pg_subscription) GETSTRUCT(tup);
3693  subname = pstrdup(NameStr(subform->subname));
3694 
3695  ReleaseSysCache(tup);
3696 
3697  return subname;
3698 }
NameData subname
FormData_pg_subscription * Form_pg_subscription
@ SUBSCRIPTIONOID
Definition: syscache.h:99

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

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

◆ get_subscription_oid()

Oid get_subscription_oid ( const char *  subname,
bool  missing_ok 
)

Definition at line 3657 of file lsyscache.c.

3658 {
3659  Oid oid;
3660 
3661  oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
3663  if (!OidIsValid(oid) && !missing_ok)
3664  ereport(ERROR,
3665  (errcode(ERRCODE_UNDEFINED_OBJECT),
3666  errmsg("subscription \"%s\" does not exist", subname)));
3667  return oid;
3668 }
Oid MyDatabaseId
Definition: globals.c:89
@ SUBSCRIPTIONNAME
Definition: syscache.h:98

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

Referenced by get_object_address_unqualified().

◆ get_transform_fromsql()

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

Definition at line 2102 of file lsyscache.c.

2103 {
2104  HeapTuple tup;
2105 
2106  if (!list_member_oid(trftypes, typid))
2107  return InvalidOid;
2108 
2110  ObjectIdGetDatum(langid));
2111  if (HeapTupleIsValid(tup))
2112  {
2113  Oid funcid;
2114 
2115  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2116  ReleaseSysCache(tup);
2117  return funcid;
2118  }
2119  else
2120  return InvalidOid;
2121 }
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:721
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:43
@ TRFTYPELANG
Definition: syscache.h:103

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

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

◆ get_transform_tosql()

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

Definition at line 2124 of file lsyscache.c.

2125 {
2126  HeapTuple tup;
2127 
2128  if (!list_member_oid(trftypes, typid))
2129  return InvalidOid;
2130 
2132  ObjectIdGetDatum(langid));
2133  if (HeapTupleIsValid(tup))
2134  {
2135  Oid funcid;
2136 
2137  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
2138  ReleaseSysCache(tup);
2139  return funcid;
2140  }
2141  else
2142  return InvalidOid;
2143 }

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

Referenced by plperl_sv_to_datum(), and PLy_output_setup_func().

◆ get_typ_typrelid()

Oid get_typ_typrelid ( Oid  typid)

Definition at line 2713 of file lsyscache.c.

2714 {
2715  HeapTuple tp;
2716 
2718  if (HeapTupleIsValid(tp))
2719  {
2720  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2721  Oid result;
2722 
2723  result = typtup->typrelid;
2724  ReleaseSysCache(tp);
2725  return result;
2726  }
2727  else
2728  return InvalidOid;
2729 }

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

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

◆ get_typavgwidth()

int32 get_typavgwidth ( Oid  typid,
int32  typmod 
)

Definition at line 2560 of file lsyscache.c.

2561 {
2562  int typlen = get_typlen(typid);
2563  int32 maxwidth;
2564 
2565  /*
2566  * Easy if it's a fixed-width type
2567  */
2568  if (typlen > 0)
2569  return typlen;
2570 
2571  /*
2572  * type_maximum_size knows the encoding of typmod for some datatypes;
2573  * don't duplicate that knowledge here.
2574  */
2575  maxwidth = type_maximum_size(typid, typmod);
2576  if (maxwidth > 0)
2577  {
2578  /*
2579  * For BPCHAR, the max width is also the only width. Otherwise we
2580  * need to guess about the typical data width given the max. A sliding
2581  * scale for percentage of max width seems reasonable.
2582  */
2583  if (typid == BPCHAROID)
2584  return maxwidth;
2585  if (maxwidth <= 32)
2586  return maxwidth; /* assume full width */
2587  if (maxwidth < 1000)
2588  return 32 + (maxwidth - 32) / 2; /* assume 50% */
2589 
2590  /*
2591  * Beyond 1000, assume we're looking at something like
2592  * "varchar(10000)" where the limit isn't actually reached often, and
2593  * use a fixed estimate.
2594  */
2595  return 32 + (1000 - 32) / 2;
2596  }
2597 
2598  /*
2599  * Oops, we have no idea ... wild guess time.
2600  */
2601  return 32;
2602 }
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:412
int16 get_typlen(Oid typid)
Definition: lsyscache.c:2179

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

2205 {
2206  HeapTuple tp;
2207 
2209  if (HeapTupleIsValid(tp))
2210  {
2211  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2212  bool result;
2213 
2214  result = typtup->typbyval;
2215  ReleaseSysCache(tp);
2216  return result;
2217  }
2218  else
2219  return false;
2220 }

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

Referenced by brin_range_deserialize(), and brin_range_serialize().

◆ get_typcollation()

◆ get_typdefault()

Node* get_typdefault ( Oid  typid)

Definition at line 2430 of file lsyscache.c.

2431 {
2432  HeapTuple typeTuple;
2434  Datum datum;
2435  bool isNull;
2436  Node *expr;
2437 
2438  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2439  if (!HeapTupleIsValid(typeTuple))
2440  elog(ERROR, "cache lookup failed for type %u", typid);
2441  type = (Form_pg_type) GETSTRUCT(typeTuple);
2442 
2443  /*
2444  * typdefault and typdefaultbin are potentially null, so don't try to
2445  * access 'em as struct fields. Must do it the hard way with
2446  * SysCacheGetAttr.
2447  */
2448  datum = SysCacheGetAttr(TYPEOID,
2449  typeTuple,
2450  Anum_pg_type_typdefaultbin,
2451  &isNull);
2452 
2453  if (!isNull)
2454  {
2455  /* We have an expression default */
2456  expr = stringToNode(TextDatumGetCString(datum));
2457  }
2458  else
2459  {
2460  /* Perhaps we have a plain literal default */
2461  datum = SysCacheGetAttr(TYPEOID,
2462  typeTuple,
2463  Anum_pg_type_typdefault,
2464  &isNull);
2465 
2466  if (!isNull)
2467  {
2468  char *strDefaultVal;
2469 
2470  /* Convert text datum to C string */
2471  strDefaultVal = TextDatumGetCString(datum);
2472  /* Convert C string to a value of the given type */
2473  datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2474  getTypeIOParam(typeTuple), -1);
2475  /* Build a Const node containing the value */
2476  expr = (Node *) makeConst(typid,
2477  -1,
2478  type->typcollation,
2479  type->typlen,
2480  datum,
2481  false,
2482  type->typbyval);
2483  pfree(strDefaultVal);
2484  }
2485  else
2486  {
2487  /* No default */
2488  expr = NULL;
2489  }
2490  }
2491 
2492  ReleaseSysCache(typeTuple);
2493 
2494  return expr;
2495 }
#define TextDatumGetCString(d)
Definition: builtins.h:95
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1737
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2285
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, type, and TYPEOID.

Referenced by build_column_default().

◆ get_type_category_preferred()

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

Definition at line 2692 of file lsyscache.c.

2693 {
2694  HeapTuple tp;
2695  Form_pg_type typtup;
2696 
2698  if (!HeapTupleIsValid(tp))
2699  elog(ERROR, "cache lookup failed for type %u", typid);
2700  typtup = (Form_pg_type) GETSTRUCT(tp);
2701  *typcategory = typtup->typcategory;
2702  *typispreferred = typtup->typispreferred;
2703  ReleaseSysCache(tp);
2704 }

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

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

2315 {
2316  HeapTuple typeTuple;
2317  Form_pg_type typeStruct;
2318 
2319  /*
2320  * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2321  * use array_in and array_out during bootstrap.
2322  */
2324  {
2325  Oid typinput;
2326  Oid typoutput;
2327 
2328  boot_get_type_io_data(typid,
2329  typlen,
2330  typbyval,
2331  typalign,
2332  typdelim,
2333  typioparam,
2334  &typinput,
2335  &typoutput);
2336  switch (which_func)
2337  {
2338  case IOFunc_input:
2339  *func = typinput;
2340  break;
2341  case IOFunc_output:
2342  *func = typoutput;
2343  break;
2344  default:
2345  elog(ERROR, "binary I/O not supported during bootstrap");
2346  break;
2347  }
2348  return;
2349  }
2350 
2351  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2352  if (!HeapTupleIsValid(typeTuple))
2353  elog(ERROR, "cache lookup failed for type %u", typid);
2354  typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2355 
2356  *typlen = typeStruct->typlen;
2357  *typbyval = typeStruct->typbyval;
2358  *typalign = typeStruct->typalign;
2359  *typdelim = typeStruct->typdelim;
2360  *typioparam = getTypeIOParam(typeTuple);
2361  switch (which_func)
2362  {
2363  case IOFunc_input:
2364  *func = typeStruct->typinput;
2365  break;
2366  case IOFunc_output:
2367  *func = typeStruct->typoutput;
2368  break;
2369  case IOFunc_receive:
2370  *func = typeStruct->typreceive;
2371  break;
2372  case IOFunc_send:
2373  *func = typeStruct->typsend;
2374  break;
2375  }
2376  ReleaseSysCache(typeTuple);
2377 }
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:811
@ 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:414
char typalign
Definition: pg_type.h:176

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

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

◆ get_typisdefined()

bool get_typisdefined ( Oid  typid)

Definition at line 2155 of file lsyscache.c.

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

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

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

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2179 of file lsyscache.c.

2180 {
2181  HeapTuple tp;
2182 
2184  if (HeapTupleIsValid(tp))
2185  {
2186  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2187  int16 result;
2188 
2189  result = typtup->typlen;
2190  ReleaseSysCache(tp);
2191  return result;
2192  }
2193  else
2194  return 0;
2195 }

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

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

◆ get_typlenbyval()

◆ get_typlenbyvalalign()

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 2988 of file lsyscache.c.

2989 {
2990  HeapTuple tp;
2991 
2993  if (HeapTupleIsValid(tp))
2994  {
2995  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2996  Oid result;
2997 
2998  result = typtup->typmodin;
2999  ReleaseSysCache(tp);
3000  return result;
3001  }
3002  else
3003  return InvalidOid;
3004 }

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2401 of file lsyscache.c.

2402 {
2403  HeapTuple tp;
2404 
2406  if (HeapTupleIsValid(tp))
2407  {
2408  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2409  char result;
2410 
2411  result = typtup->typstorage;
2412  ReleaseSysCache(tp);
2413  return result;
2414  }
2415  else
2416  return TYPSTORAGE_PLAIN;
2417 }

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

Referenced by GetAttributeStorage().

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3079 of file lsyscache.c.

3080 {
3081  HeapTuple tp;
3082 
3084  if (HeapTupleIsValid(tp))
3085  {
3086  Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
3087  RegProcedure handler = typform->typsubscript;
3088 
3089  if (typelemp)
3090  *typelemp = typform->typelem;
3091  ReleaseSysCache(tp);
3092  return handler;
3093  }
3094  else
3095  {
3096  if (typelemp)
3097  *typelemp = InvalidOid;
3098  return InvalidOid;
3099  }
3100 }

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

Referenced by exec_check_rw_parameter(), and getSubscriptingRoutines().

◆ get_typtype()

char get_typtype ( Oid  typid)

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2520 of file lsyscache.c.

2521 {
2522  /*
2523  * We loop to find the bottom base type in a stack of domains.
2524  */
2525  for (;;)
2526  {
2527  HeapTuple tup;
2528  Form_pg_type typTup;
2529 
2530  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2531  if (!HeapTupleIsValid(tup))
2532  elog(ERROR, "cache lookup failed for type %u", typid);
2533  typTup = (Form_pg_type) GETSTRUCT(tup);
2534  if (typTup->typtype != TYPTYPE_DOMAIN)
2535  {
2536  /* Not a domain, so done */
2537  ReleaseSysCache(tup);
2538  break;
2539  }
2540 
2541  Assert(*typmod == -1);
2542  typid = typTup->typbasetype;
2543  *typmod = typTup->typtypmod;
2544 
2545  ReleaseSysCache(tup);
2546  }
2547 
2548  return typid;
2549 }

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

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

◆ getSubscriptingRoutines()

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

Definition at line 3112 of file lsyscache.c.

3113 {
3114  RegProcedure typsubscript = get_typsubscript(typid, typelemp);
3115 
3116  if (!OidIsValid(typsubscript))
3117  return NULL;
3118 
3119  return (const struct SubscriptRoutines *)
3120  DatumGetPointer(OidFunctionCall0(typsubscript));
3121 }
#define OidFunctionCall0(functionId)
Definition: fmgr.h:678
RegProcedure get_typsubscript(Oid typid, Oid *typelemp)
Definition: lsyscache.c:3079

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

2923 {
2924  HeapTuple typeTuple;
2925  Form_pg_type pt;
2926 
2928  if (!HeapTupleIsValid(typeTuple))
2929  elog(ERROR, "cache lookup failed for type %u", type);
2930  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2931 
2932  if (!pt->typisdefined)
2933  ereport(ERROR,
2934  (errcode(ERRCODE_UNDEFINED_OBJECT),
2935  errmsg("type %s is only a shell",
2936  format_type_be(type))));
2937  if (!OidIsValid(pt->typreceive))
2938  ereport(ERROR,
2939  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2940  errmsg("no binary input function available for type %s",
2941  format_type_be(type))));
2942 
2943  *typReceive = pt->typreceive;
2944  *typIOParam = getTypeIOParam(typeTuple);
2945 
2946  ReleaseSysCache(typeTuple);
2947 }

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

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

◆ getTypeBinaryOutputInfo()

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

Definition at line 2955 of file lsyscache.c.

2956 {
2957  HeapTuple typeTuple;
2958  Form_pg_type pt;
2959 
2961  if (!HeapTupleIsValid(typeTuple))
2962  elog(ERROR, "cache lookup failed for type %u", type);
2963  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2964 
2965  if (!pt->typisdefined)
2966  ereport(ERROR,
2967  (errcode(ERRCODE_UNDEFINED_OBJECT),
2968  errmsg("type %s is only a shell",
2969  format_type_be(type))));
2970  if (!OidIsValid(pt->typsend))
2971  ereport(ERROR,
2972  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2973  errmsg("no binary output function available for type %s",
2974  format_type_be(type))));
2975 
2976  *typSend = pt->typsend;
2977  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2978 
2979  ReleaseSysCache(typeTuple);
2980 }

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

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

◆ getTypeInputInfo()

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

Definition at line 2856 of file lsyscache.c.

2857 {
2858  HeapTuple typeTuple;
2859  Form_pg_type pt;
2860 
2862  if (!HeapTupleIsValid(typeTuple))
2863  elog(ERROR, "cache lookup failed for type %u", type);
2864  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2865 
2866  if (!pt->typisdefined)
2867  ereport(ERROR,
2868  (errcode(ERRCODE_UNDEFINED_OBJECT),
2869  errmsg("type %s is only a shell",
2870  format_type_be(type))));
2871  if (!OidIsValid(pt->typinput))
2872  ereport(ERROR,
2873  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2874  errmsg("no input function available for type %s",
2875  format_type_be(type))));
2876 
2877  *typInput = pt->typinput;
2878  *typIOParam = getTypeIOParam(typeTuple);
2879 
2880  ReleaseSysCache(typeTuple);
2881 }

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

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

◆ getTypeIOParam()

Oid getTypeIOParam ( HeapTuple  typeTuple)

Definition at line 2285 of file lsyscache.c.

2286 {
2287  Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2288 
2289  /*
2290  * Array types get their typelem as parameter; everybody else gets their
2291  * own type OID as parameter.
2292  */
2293  if (OidIsValid(typeStruct->typelem))
2294  return typeStruct->typelem;
2295  else
2296  return typeStruct->oid;
2297 }

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

2890 {
2891  HeapTuple typeTuple;
2892  Form_pg_type pt;
2893 
2895  if (!HeapTupleIsValid(typeTuple))
2896  elog(ERROR, "cache lookup failed for type %u", type);
2897  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2898 
2899  if (!pt->typisdefined)
2900  ereport(ERROR,
2901  (errcode(ERRCODE_UNDEFINED_OBJECT),
2902  errmsg("type %s is only a shell",
2903  format_type_be(type))));
2904  if (!OidIsValid(pt->typoutput))
2905  ereport(ERROR,
2906  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2907  errmsg("no output function available for type %s",
2908  format_type_be(type))));
2909 
2910  *typOutput = pt->typoutput;
2911  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2912 
2913  ReleaseSysCache(typeTuple);
2914 }

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

Referenced by brin_minmax_multi_summary_out(), brin_page_items(), build_concat_foutcache(), BuildIndexValueDescription(), BuildParamLogString(), check_functions_in_node(), convert_value_to_string(), cost_qual_eval_walker(), create_foreign_modify(), debugtup(), deparseConst(), DoCopyTo(), eval_const_expressions_mutator(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), ExecInitExprRec(), get_const_expr(), 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 1441 of file lsyscache.c.

1442 {
1443  bool result = false;
1444  HeapTuple tp;
1445  TypeCacheEntry *typentry;
1446 
1447  /* As in op_mergejoinable, let the typcache handle the hard cases */
1448  if (opno == ARRAY_EQ_OP)
1449  {
1450  typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1451  if (typentry->hash_proc == F_HASH_ARRAY)
1452  result = true;
1453  }
1454  else if (opno == RECORD_EQ_OP)
1455  {
1456  typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1457  if (typentry->hash_proc == F_HASH_RECORD)
1458  result = true;
1459  }
1460  else
1461  {
1462  /* For all other operators, rely on pg_operator.oprcanhash */
1464  if (HeapTupleIsValid(tp))
1465  {
1467 
1468  result = optup->oprcanhash;
1469  ReleaseSysCache(tp);
1470  }
1471  }
1472  return result;
1473 }
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:344
#define TYPECACHE_HASH_PROC
Definition: typcache.h:140

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

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

◆ op_in_opfamily()

◆ op_input_types()

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

Definition at line 1362 of file lsyscache.c.

1363 {
1364  HeapTuple tp;
1365  Form_pg_operator optup;
1366 
1368  if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1369  elog(ERROR, "cache lookup failed for operator %u", opno);
1370  optup = (Form_pg_operator) GETSTRUCT(tp);
1371  *lefttype = optup->oprleft;
1372  *righttype = optup->oprright;
1373  ReleaseSysCache(tp);
1374 }

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

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

◆ op_mergejoinable()

bool op_mergejoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1390 of file lsyscache.c.

1391 {
1392  bool result = false;
1393  HeapTuple tp;
1394  TypeCacheEntry *typentry;
1395 
1396  /*
1397  * For array_eq or record_eq, we can sort if the element or field types
1398  * are all sortable. We could implement all the checks for that here, but
1399  * the typcache already does that and caches the results too, so let's
1400  * rely on the typcache.
1401  */
1402  if (opno == ARRAY_EQ_OP)
1403  {
1404  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1405  if (typentry->cmp_proc == F_BTARRAYCMP)
1406  result = true;
1407  }
1408  else if (opno == RECORD_EQ_OP)
1409  {
1410  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1411  if (typentry->cmp_proc == F_BTRECORDCMP)
1412  result = true;
1413  }
1414  else
1415  {
1416  /* For all other operators, rely on pg_operator.oprcanmerge */
1418  if (HeapTupleIsValid(tp))
1419  {
1421 
1422  result = optup->oprcanmerge;
1423  ReleaseSysCache(tp);
1424  }
1425  }
1426  return result;
1427 }
#define TYPECACHE_CMP_PROC
Definition: typcache.h:139

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

Referenced by check_mergejoinable(), and compute_semijoin_info().

◆ op_strict()

bool op_strict ( Oid  opno)

Definition at line 1481 of file lsyscache.c.

1482 {
1483  RegProcedure funcid = get_opcode(opno);
1484 
1485  if (funcid == (RegProcedure) InvalidOid)
1486  elog(ERROR, "operator %u does not exist", opno);
1487 
1488  return func_strict((Oid) funcid);
1489 }
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1289
bool func_strict(Oid funcid)
Definition: lsyscache.c:1765

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

1498 {
1499  RegProcedure funcid = get_opcode(opno);
1500 
1501  if (funcid == (RegProcedure) InvalidOid)
1502  elog(ERROR, "operator %u does not exist", opno);
1503 
1504  return func_volatile((Oid) funcid);
1505 }
char func_volatile(Oid funcid)
Definition: lsyscache.c:1784

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

2661 {
2662  return (get_typtype(typid) == TYPTYPE_ENUM);
2663 }
char get_typtype(Oid typid)
Definition: lsyscache.c:2611

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

2681 {
2682  return (get_typtype(typid) == TYPTYPE_MULTIRANGE);
2683 }

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

2671 {
2672  return (get_typtype(typid) == TYPTYPE_RANGE);
2673 }

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

2638 {
2639  if (typid == RECORDOID)
2640  return true; /* easy case */
2641  switch (get_typtype(typid))
2642  {
2643  case TYPTYPE_COMPOSITE:
2644  return true;
2645  case TYPTYPE_DOMAIN:
2646  if (get_typtype(getBaseType(typid)) == TYPTYPE_COMPOSITE)
2647  return true;
2648  break;
2649  default:
2650  break;
2651  }
2652  return false;
2653 }
Oid getBaseType(Oid typid)
Definition: lsyscache.c:2503

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