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

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

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

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

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

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

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

1781 {
1782  HeapTuple tp;
1783  char result;
1784 
1785  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1786  if (!HeapTupleIsValid(tp))
1787  elog(ERROR, "cache lookup failed for function %u", funcid);
1788 
1789  result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1790  ReleaseSysCache(tp);
1791  return result;
1792 }
#define ERROR
Definition: elog.h:33
#define elog(elevel,...)
Definition: elog.h:218
#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:1221
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1173
@ 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 1742 of file lsyscache.c.

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

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

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

2745 {
2746  HeapTuple tp;
2747  Oid result = InvalidOid;
2748 
2750  if (HeapTupleIsValid(tp))
2751  {
2752  result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
2753  ReleaseSysCache(tp);
2754  }
2755  return result;
2756 }
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 3115 of file lsyscache.c.

3116 {
3117  HeapTuple tp;
3118  int32 stawidth;
3119 
3121  {
3122  stawidth = (*get_attavgwidth_hook) (relid, attnum);
3123  if (stawidth > 0)
3124  return stawidth;
3125  }
3127  ObjectIdGetDatum(relid),
3129  BoolGetDatum(false));
3130  if (HeapTupleIsValid(tp))
3131  {
3132  stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3133  ReleaseSysCache(tp);
3134  if (stawidth > 0)
3135  return stawidth;
3136  }
3137  return 0;
3138 }
signed int int32
Definition: c.h:429
get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:51
int16 attnum
Definition: pg_attribute.h:83
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:135
#define BoolGetDatum(X)
Definition: postgres.h:446
#define Int16GetDatum(X)
Definition: postgres.h:495
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1195
@ 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 913 of file lsyscache.c.

914 {
915  HeapTuple tp;
916  Form_pg_attribute att_tup;
917  char result;
918 
919  tp = SearchSysCache2(ATTNUM,
920  ObjectIdGetDatum(relid),
922  if (!HeapTupleIsValid(tp))
923  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
924  attnum, relid);
925  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
926  result = att_tup->attgenerated;
927  ReleaseSysCache(tp);
928  return result;
929 }
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:207
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1184
@ 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 825 of file lsyscache.c.

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

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

Referenced by AddRelationNewConstraints(), ATExecAlterColumnType(), check_nested_generated_walker(), ComputePartitionAttrs(), contain_invalid_rfcolumn_walker(), CreateStatistics(), decompile_column_index_array(), deparseColumnRef(), errtablecol(), fixup_inherited_columns(), generateClonedExtStatsStmt(), generateClonedIndexStmt(), get_insert_query_def(), get_rte_attribute_name(), get_update_query_targetlist_def(), getObjectDescription(), getObjectIdentityParts(), pg_get_constraintdef_worker(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsobj_worker(), pg_get_triggerdef_worker(), processIndirection(), pub_collist_contains_invalid_column(), transformPartitionBound(), and transformPartitionRangeBounds().

◆ get_attnum()

AttrNumber get_attnum ( Oid  relid,
const char *  attname 
)

Definition at line 856 of file lsyscache.c.

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

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

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

◆ get_attoptions()

Datum get_attoptions ( Oid  relid,
int16  attnum 
)

Definition at line 995 of file lsyscache.c.

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

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

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

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

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

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

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

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

References attnum, ATTNUM, 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 2789 of file lsyscache.c.

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

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

1033 {
1034  Oid oid;
1035 
1036  oid = GetSysCacheOid2(CASTSOURCETARGET, Anum_pg_cast_oid,
1037  ObjectIdGetDatum(sourcetypeid),
1038  ObjectIdGetDatum(targettypeid));
1039  if (!OidIsValid(oid) && !missing_ok)
1040  ereport(ERROR,
1041  (errcode(ERRCODE_UNDEFINED_OBJECT),
1042  errmsg("cast from type %s to type %s does not exist",
1043  format_type_be(sourcetypeid),
1044  format_type_be(targettypeid))));
1045  return oid;
1046 }
#define OidIsValid(objectId)
Definition: c.h:710
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define ereport(elevel,...)
Definition: elog.h:143
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:199

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

1080 {
1081  HeapTuple tp;
1082  Form_pg_collation colltup;
1083  bool result;
1084 
1085  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1086  if (!HeapTupleIsValid(tp))
1087  elog(ERROR, "cache lookup failed for collation %u", colloid);
1088  colltup = (Form_pg_collation) GETSTRUCT(tp);
1089  result = colltup->collisdeterministic;
1090  ReleaseSysCache(tp);
1091  return result;
1092 }
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:57
@ 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 1060 of file lsyscache.c.

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

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

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

1139 {
1140  HeapTuple tp;
1141 
1143  if (HeapTupleIsValid(tp))
1144  {
1146  Oid result;
1147 
1148  if (contup->contype == CONSTRAINT_UNIQUE ||
1149  contup->contype == CONSTRAINT_PRIMARY ||
1150  contup->contype == CONSTRAINT_EXCLUSION)
1151  result = contup->conindid;
1152  else
1153  result = InvalidOid;
1154  ReleaseSysCache(tp);
1155  return result;
1156  }
1157  else
1158  return InvalidOid;
1159 }
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 1106 of file lsyscache.c.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

◆ get_func_variadictype()

Oid get_func_variadictype ( Oid  funcid)

Definition at line 1704 of file lsyscache.c.

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

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

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

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

Referenced by gistproperty(), and spgproperty().

◆ get_index_isclustered()

bool get_index_isclustered ( Oid  index_oid)

Definition at line 3565 of file lsyscache.c.

3566 {
3567  bool isclustered;
3568  HeapTuple tuple;
3569  Form_pg_index rd_index;
3570 
3571  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3572  if (!HeapTupleIsValid(tuple))
3573  elog(ERROR, "cache lookup failed for index %u", index_oid);
3574 
3575  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3576  isclustered = rd_index->indisclustered;
3577  ReleaseSysCache(tuple);
3578 
3579  return isclustered;
3580 }

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

3520 {
3521  HeapTuple tuple;
3522  Form_pg_index rd_index;
3523  bool result;
3524 
3525  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3526  if (!HeapTupleIsValid(tuple))
3527  return false;
3528 
3529  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3530  result = rd_index->indisreplident;
3531  ReleaseSysCache(tuple);
3532 
3533  return result;
3534 }

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

Referenced by RememberReplicaIdentityForRebuilding().

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3542 of file lsyscache.c.

3543 {
3544  bool isvalid;
3545  HeapTuple tuple;
3546  Form_pg_index rd_index;
3547 
3548  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3549  if (!HeapTupleIsValid(tuple))
3550  elog(ERROR, "cache lookup failed for index %u", index_oid);
3551 
3552  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3553  isvalid = rd_index->indisvalid;
3554  ReleaseSysCache(tuple);
3555 
3556  return isvalid;
3557 }

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

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

◆ get_language_name()

char* get_language_name ( Oid  langoid,
bool  missing_ok 
)

Definition at line 1164 of file lsyscache.c.

1165 {
1166  HeapTuple tp;
1167 
1168  tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
1169  if (HeapTupleIsValid(tp))
1170  {
1172  char *result;
1173 
1174  result = pstrdup(NameStr(lantup->lanname));
1175  ReleaseSysCache(tp);
1176  return result;
1177  }
1178 
1179  if (!missing_ok)
1180  elog(ERROR, "cache lookup failed for language %u",
1181  langoid);
1182  return NULL;
1183 }
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 364 of file lsyscache.c.

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

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

3444 {
3445  HeapTuple tp;
3446 
3447  tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
3448  if (HeapTupleIsValid(tp))
3449  {
3450  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3451  Oid result;
3452 
3453  result = rngtup->rngtypid;
3454  ReleaseSysCache(tp);
3455  return result;
3456  }
3457  else
3458  return InvalidOid;
3459 }
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 3326 of file lsyscache.c.

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

References GETSTRUCT, HeapTupleIsValid, NAMESPACEOID, NameStr, 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(), ApplyExtensionUpdates(), ATExecChangeOwner(), ATParseTransformCmd(), BuildRelationExtStatistics(), check_publication_add_schema(), check_TSCurrentConfig(), CheckObjSchemaNotAlreadyInPublication(), 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_row_filter(), plpgsql_fulfill_promise(), publication_add_schema(), PublicationDropSchemas(), quoteRelationName(), RangeVarCallbackForAlterRelation(), RangeVarGetAndCheckCreationNamespace(), RebuildConstraintComment(), refresh_by_match_merge(), regclassout(), regcollationout(), regconfigout(), regdictionaryout(), regnamespaceout(), regoperout(), regprocout(), reindex_index(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), report_namespace_conflict(), ri_GenerateQualCollation(), schema_to_xml_internal(), sepgsql_proc_post_create(), sepgsql_relation_post_create(), SPI_getnspname(), transformAlterTableStmt(), transformCreateStmt(), and unaccent_dict().

◆ get_namespace_name_or_temp()

◆ get_negator()

Oid get_negator ( Oid  opno)

Definition at line 1514 of file lsyscache.c.

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

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

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

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

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

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

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

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

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

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

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

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

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

1194 {
1195  HeapTuple tp;
1196  Form_pg_opclass cla_tup;
1197  Oid result;
1198 
1199  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1200  if (!HeapTupleIsValid(tp))
1201  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1202  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1203 
1204  result = cla_tup->opcfamily;
1205  ReleaseSysCache(tp);
1206  return result;
1207 }
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(), DefineIndex(), 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 1215 of file lsyscache.c.

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

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

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

◆ get_opclass_opfamily_and_input_type()

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

Definition at line 1238 of file lsyscache.c.

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

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

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

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1266 of file lsyscache.c.

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

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

166 {
167  HeapTuple tp;
168  Form_pg_amop amop_tup;
169  Oid result;
170 
172  ObjectIdGetDatum(opfamily),
173  ObjectIdGetDatum(lefttype),
174  ObjectIdGetDatum(righttype),
175  Int16GetDatum(strategy));
176  if (!HeapTupleIsValid(tp))
177  return InvalidOid;
178  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
179  result = amop_tup->amopopr;
180  ReleaseSysCache(tp);
181  return result;
182 }
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1206
@ 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(), compute_cpu_sort_cost(), 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 1291 of file lsyscache.c.

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

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

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

◆ get_oprjoin()

RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1562 of file lsyscache.c.

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

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

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

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

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

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

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

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

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

Referenced by build_subplan(), and exprType().

◆ get_range_collation()

Oid get_range_collation ( Oid  rangeOid)

Definition at line 3393 of file lsyscache.c.

3394 {
3395  HeapTuple tp;
3396 
3397  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3398  if (HeapTupleIsValid(tp))
3399  {
3400  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3401  Oid result;
3402 
3403  result = rngtup->rngcollation;
3404  ReleaseSysCache(tp);
3405  return result;
3406  }
3407  else
3408  return InvalidOid;
3409 }
@ 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 3418 of file lsyscache.c.

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

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

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

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

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

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

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_attnums(), AlterPublicationOptions(), AlterSubscription_refresh(), AlterTableNamespace(), ApplyWorkerMain(), ATExecAlterConstraint(), ATExecChangeOwner(), check_enable_rls(), check_new_partition_bound(), convert_column_name(), CreateTriggerFiringOn(), DefineRelation(), do_autovacuum(), EnableDisableRule(), exec_object_restorecon(), ExecCheckRTPerms(), 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(), InsertRule(), LockTableRecurse(), LockViewRecurse_walker(), 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(), table_to_xml_internal(), TargetPrivilegesCheck(), and transformAlterTableStmt().

◆ get_rel_namespace()

◆ get_rel_persistence()

char get_rel_persistence ( Oid  relid)

Definition at line 2059 of file lsyscache.c.

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

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

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

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

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

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

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

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

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

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

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

Definition at line 2079 of file lsyscache.c.

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

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

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

◆ get_transform_tosql()

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

Definition at line 2100 of file lsyscache.c.

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

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

Referenced by plperl_sv_to_datum(), and PLy_output_setup_func().

◆ get_typ_typrelid()

Oid get_typ_typrelid ( Oid  typid)

Definition at line 2688 of file lsyscache.c.

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

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

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

◆ get_typavgwidth()

int32 get_typavgwidth ( Oid  typid,
int32  typmod 
)

Definition at line 2535 of file lsyscache.c.

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

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_rel_data_width(), get_width_cost_multiplier(), set_append_rel_size(), set_pathtarget_cost_width(), and set_rel_width().

◆ get_typbyval()

bool get_typbyval ( 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  bool result;
2188 
2189  result = typtup->typbyval;
2190  ReleaseSysCache(tp);
2191  return result;
2192  }
2193  else
2194  return false;
2195 }

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

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

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

Referenced by build_column_default().

◆ get_type_category_preferred()

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

Definition at line 2667 of file lsyscache.c.

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

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

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

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

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

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

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

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

◆ get_typlenbyval()

◆ get_typlenbyvalalign()

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 2963 of file lsyscache.c.

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

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2376 of file lsyscache.c.

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

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

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3054 of file lsyscache.c.

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

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

Referenced by exec_check_rw_parameter(), and getSubscriptingRoutines().

◆ get_typtype()

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2495 of file lsyscache.c.

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

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

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

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

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

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

Referenced by 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 2930 of file lsyscache.c.

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

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

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

◆ getTypeInputInfo()

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

Definition at line 2831 of file lsyscache.c.

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

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

Referenced by _sv_to_datum_finfo(), BeginCopyFrom(), check_functions_in_node(), cost_qual_eval_walker(), DefineAggregate(), domain_state_setup(), eval_const_expressions_mutator(), exec_bind_message(), ExecInitExprRec(), ExecInitTableFuncScan(), GetAggInitVal(), hstore_populate_record(), parse_fcall_arguments(), 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 2260 of file lsyscache.c.

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

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

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

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

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

◆ op_hashjoinable()

bool op_hashjoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1418 of file lsyscache.c.

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

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

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

◆ op_in_opfamily()

bool op_in_opfamily ( Oid  opno,
Oid  opfamily 
)

◆ op_input_types()

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

Definition at line 1339 of file lsyscache.c.

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

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

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

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

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(), operator_predicate_proof(), and reconsider_outer_join_clause().

◆ op_volatile()

char op_volatile ( Oid  opno)

Definition at line 1474 of file lsyscache.c.

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

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

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

References get_typtype().

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

◆ type_is_multirange()

bool type_is_multirange ( Oid  typid)

Definition at line 2655 of file lsyscache.c.

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

References get_typtype().

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

◆ type_is_range()

bool type_is_range ( Oid  typid)

Definition at line 2645 of file lsyscache.c.

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

References get_typtype().

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

◆ type_is_rowtype()

bool type_is_rowtype ( Oid  typid)

Definition at line 2612 of file lsyscache.c.

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

References get_typtype(), and getBaseType().

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

Variable Documentation

◆ get_attavgwidth_hook

get_attavgwidth_hook_type get_attavgwidth_hook = NULL

Definition at line 51 of file lsyscache.c.

Referenced by get_attavgwidth().