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_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)
 
Oid get_opfamily_proc (Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
 
char * get_attname (Oid relid, AttrNumber attnum, bool missing_ok)
 
AttrNumber get_attnum (Oid relid, const char *attname)
 
char get_attgenerated (Oid relid, AttrNumber attnum)
 
Oid get_atttype (Oid relid, AttrNumber attnum)
 
void get_atttypetypmodcoll (Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
 
char * get_collation_name (Oid colloid)
 
bool get_collation_isdeterministic (Oid colloid)
 
char * get_constraint_name (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)
 
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)
 
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_index_column_opclass (Oid index_oid, int attno)
 

Variables

get_attavgwidth_hook_type get_attavgwidth_hook = NULL
 

Function Documentation

◆ equality_ops_are_compatible()

bool equality_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 695 of file lsyscache.c.

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

Referenced by query_is_distinct_for().

696 {
697  bool result;
698  CatCList *catlist;
699  int i;
700 
701  /* Easy if they're the same operator */
702  if (opno1 == opno2)
703  return true;
704 
705  /*
706  * We search through all the pg_amop entries for opno1.
707  */
708  catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
709 
710  result = false;
711  for (i = 0; i < catlist->n_members; i++)
712  {
713  HeapTuple op_tuple = &catlist->members[i]->tuple;
714  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
715 
716  /* must be btree or hash */
717  if (op_form->amopmethod == BTREE_AM_OID ||
718  op_form->amopmethod == HASH_AM_OID)
719  {
720  if (op_in_opfamily(opno2, op_form->amopfamily))
721  {
722  result = true;
723  break;
724  }
725  }
726  }
727 
728  ReleaseSysCacheList(catlist);
729 
730  return result;
731 }
bool op_in_opfamily(Oid opno, Oid opfamily)
Definition: lsyscache.c:63
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121

◆ free_attstatsslot()

void free_attstatsslot ( AttStatsSlot sslot)

Definition at line 3072 of file lsyscache.c.

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

Referenced by _int_matchsel(), booltestsel(), brincostestimate(), btcostestimate(), calc_arraycontsel(), calc_hist_selectivity(), 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().

3073 {
3074  /* The values[] array was separately palloc'd by deconstruct_array */
3075  if (sslot->values)
3076  pfree(sslot->values);
3077  /* The numbers[] array points into numbers_arr, do not pfree it */
3078  /* Free the detoasted array objects, if any */
3079  if (sslot->values_arr)
3080  pfree(sslot->values_arr);
3081  if (sslot->numbers_arr)
3082  pfree(sslot->numbers_arr);
3083 }
void pfree(void *pointer)
Definition: mcxt.c:1031
void * values_arr
Definition: lsyscache.h:57
Datum * values
Definition: lsyscache.h:50
void * numbers_arr
Definition: lsyscache.h:58

◆ func_parallel()

char func_parallel ( Oid  funcid)

Definition at line 1601 of file lsyscache.c.

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

Referenced by max_parallel_hazard_checker(), and set_rel_consider_parallel().

1602 {
1603  HeapTuple tp;
1604  char result;
1605 
1606  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1607  if (!HeapTupleIsValid(tp))
1608  elog(ERROR, "cache lookup failed for function %u", funcid);
1609 
1610  result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1611  ReleaseSysCache(tp);
1612  return result;
1613 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:226

◆ func_strict()

bool func_strict ( Oid  funcid)

Definition at line 1563 of file lsyscache.c.

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

1564 {
1565  HeapTuple tp;
1566  bool result;
1567 
1568  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1569  if (!HeapTupleIsValid(tp))
1570  elog(ERROR, "cache lookup failed for function %u", funcid);
1571 
1572  result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
1573  ReleaseSysCache(tp);
1574  return result;
1575 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:226

◆ func_volatile()

char func_volatile ( Oid  funcid)

Definition at line 1582 of file lsyscache.c.

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

Referenced by contain_mutable_functions_checker(), contain_volatile_functions_checker(), contain_volatile_functions_not_nextval_checker(), DefineType(), ece_function_is_safe(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), and op_volatile().

1583 {
1584  HeapTuple tp;
1585  char result;
1586 
1587  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1588  if (!HeapTupleIsValid(tp))
1589  elog(ERROR, "cache lookup failed for function %u", funcid);
1590 
1591  result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile;
1592  ReleaseSysCache(tp);
1593  return result;
1594 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:226

◆ get_array_type()

Oid get_array_type ( Oid  typid)

Definition at line 2554 of file lsyscache.c.

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

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

2555 {
2556  HeapTuple tp;
2557  Oid result = InvalidOid;
2558 
2560  if (HeapTupleIsValid(tp))
2561  {
2562  result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
2563  ReleaseSysCache(tp);
2564  }
2565  return result;
2566 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 2870 of file lsyscache.c.

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

Referenced by get_rel_data_width(), and set_rel_width().

2871 {
2872  HeapTuple tp;
2873  int32 stawidth;
2874 
2876  {
2877  stawidth = (*get_attavgwidth_hook) (relid, attnum);
2878  if (stawidth > 0)
2879  return stawidth;
2880  }
2882  ObjectIdGetDatum(relid),
2884  BoolGetDatum(false));
2885  if (HeapTupleIsValid(tp))
2886  {
2887  stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
2888  ReleaseSysCache(tp);
2889  if (stawidth > 0)
2890  return stawidth;
2891  }
2892  return 0;
2893 }
get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:50
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:134
signed int int32
Definition: c.h:346
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1146
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define BoolGetDatum(X)
Definition: postgres.h:402
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_attgenerated()

char get_attgenerated ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 836 of file lsyscache.c.

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

Referenced by ATExecAlterColumnType(), and check_nested_generated_walker().

837 {
838  HeapTuple tp;
839  Form_pg_attribute att_tup;
840  char result;
841 
842  tp = SearchSysCache2(ATTNUM,
843  ObjectIdGetDatum(relid),
845  if (!HeapTupleIsValid(tp))
846  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
847  attnum, relid);
848  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
849  result = att_tup->attgenerated;
850  ReleaseSysCache(tp);
851  return result;
852 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1135
#define elog(elevel,...)
Definition: elog.h:226

◆ get_attname()

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

Definition at line 775 of file lsyscache.c.

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

Referenced by AddRelationNewConstraints(), ATExecAlterColumnType(), check_nested_generated_walker(), ComputePartitionAttrs(), conversion_error_callback(), 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(), transformPartitionBound(), and transformPartitionRangeBounds().

776 {
777  HeapTuple tp;
778 
779  tp = SearchSysCache2(ATTNUM,
781  if (HeapTupleIsValid(tp))
782  {
784  char *result;
785 
786  result = pstrdup(NameStr(att_tup->attname));
787  ReleaseSysCache(tp);
788  return result;
789  }
790 
791  if (!missing_ok)
792  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
793  attnum, relid);
794  return NULL;
795 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1161
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1135
#define elog(elevel,...)
Definition: elog.h:226
#define NameStr(name)
Definition: c.h:609

◆ get_attnum()

AttrNumber get_attnum ( Oid  relid,
const char *  attname 
)

Definition at line 806 of file lsyscache.c.

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

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

807 {
808  HeapTuple tp;
809 
810  tp = SearchSysCacheAttName(relid, attname);
811  if (HeapTupleIsValid(tp))
812  {
814  AttrNumber result;
815 
816  result = att_tup->attnum;
817  ReleaseSysCache(tp);
818  return result;
819  }
820  else
821  return InvalidAttrNumber;
822 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
NameData attname
Definition: pg_attribute.h:40
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1265
#define InvalidAttrNumber
Definition: attnum.h:23
int16 AttrNumber
Definition: attnum.h:21

◆ get_attstatsslot()

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

Definition at line 2942 of file lsyscache.c.

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_rangesel(), eqjoinsel(), estimate_hash_bucket_stats(), ExecHashBuildSkewHash(), get_variable_range(), histogram_selectivity(), ineq_histogram_selectivity(), mcv_selectivity(), networkjoinsel_inner(), networkjoinsel_semi(), networksel(), prefix_selectivity(), scalararraysel_containment(), tsquerysel(), var_eq_const(), and var_eq_non_const().

2944 {
2945  Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
2946  int i;
2947  Datum val;
2948  bool isnull;
2949  ArrayType *statarray;
2950  Oid arrayelemtype;
2951  int narrayelem;
2952  HeapTuple typeTuple;
2953  Form_pg_type typeForm;
2954 
2955  /* initialize *sslot properly */
2956  memset(sslot, 0, sizeof(AttStatsSlot));
2957 
2958  for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
2959  {
2960  if ((&stats->stakind1)[i] == reqkind &&
2961  (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
2962  break;
2963  }
2964  if (i >= STATISTIC_NUM_SLOTS)
2965  return false; /* not there */
2966 
2967  sslot->staop = (&stats->staop1)[i];
2968  sslot->stacoll = (&stats->stacoll1)[i];
2969 
2970  /*
2971  * XXX Hopefully-temporary hack: if stacoll isn't set, inject the default
2972  * collation. This won't matter for non-collation-aware datatypes. For
2973  * those that are, this covers cases where stacoll has not been set. In
2974  * the short term we need this because some code paths involving type NAME
2975  * do not pass any collation to prefix_selectivity and related functions.
2976  * Even when that's been fixed, it's likely that some add-on typanalyze
2977  * functions won't get the word right away about filling stacoll during
2978  * ANALYZE, so we'll probably need this for awhile.
2979  */
2980  if (sslot->stacoll == InvalidOid)
2981  sslot->stacoll = DEFAULT_COLLATION_OID;
2982 
2983  if (flags & ATTSTATSSLOT_VALUES)
2984  {
2985  val = SysCacheGetAttr(STATRELATTINH, statstuple,
2986  Anum_pg_statistic_stavalues1 + i,
2987  &isnull);
2988  if (isnull)
2989  elog(ERROR, "stavalues is null");
2990 
2991  /*
2992  * Detoast the array if needed, and in any case make a copy that's
2993  * under control of this AttStatsSlot.
2994  */
2995  statarray = DatumGetArrayTypePCopy(val);
2996 
2997  /*
2998  * Extract the actual array element type, and pass it back in case the
2999  * caller needs it.
3000  */
3001  sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3002 
3003  /* Need info about element type */
3004  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
3005  if (!HeapTupleIsValid(typeTuple))
3006  elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3007  typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
3008 
3009  /* Deconstruct array into Datum elements; NULLs not expected */
3010  deconstruct_array(statarray,
3011  arrayelemtype,
3012  typeForm->typlen,
3013  typeForm->typbyval,
3014  typeForm->typalign,
3015  &sslot->values, NULL, &sslot->nvalues);
3016 
3017  /*
3018  * If the element type is pass-by-reference, we now have a bunch of
3019  * Datums that are pointers into the statarray, so we need to keep
3020  * that until free_attstatsslot. Otherwise, all the useful info is in
3021  * sslot->values[], so we can free the array object immediately.
3022  */
3023  if (!typeForm->typbyval)
3024  sslot->values_arr = statarray;
3025  else
3026  pfree(statarray);
3027 
3028  ReleaseSysCache(typeTuple);
3029  }
3030 
3031  if (flags & ATTSTATSSLOT_NUMBERS)
3032  {
3033  val = SysCacheGetAttr(STATRELATTINH, statstuple,
3034  Anum_pg_statistic_stanumbers1 + i,
3035  &isnull);
3036  if (isnull)
3037  elog(ERROR, "stanumbers is null");
3038 
3039  /*
3040  * Detoast the array if needed, and in any case make a copy that's
3041  * under control of this AttStatsSlot.
3042  */
3043  statarray = DatumGetArrayTypePCopy(val);
3044 
3045  /*
3046  * We expect the array to be a 1-D float4 array; verify that. We don't
3047  * need to use deconstruct_array() since the array data is just going
3048  * to look like a C array of float4 values.
3049  */
3050  narrayelem = ARR_DIMS(statarray)[0];
3051  if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3052  ARR_HASNULL(statarray) ||
3053  ARR_ELEMTYPE(statarray) != FLOAT4OID)
3054  elog(ERROR, "stanumbers is not a 1-D float4 array");
3055 
3056  /* Give caller a pointer directly into the statarray */
3057  sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3058  sslot->nnumbers = narrayelem;
3059 
3060  /* We'll free the statarray in free_attstatsslot */
3061  sslot->numbers_arr = statarray;
3062  }
3063 
3064  return true;
3065 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ATTSTATSSLOT_VALUES
Definition: lsyscache.h:39
int nnumbers
Definition: lsyscache.h:54
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:134
void pfree(void *pointer)
Definition: mcxt.c:1031
#define ATTSTATSSLOT_NUMBERS
Definition: lsyscache.h:40
void * values_arr
Definition: lsyscache.h:57
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
#define ARR_DIMS(a)
Definition: array.h:282
#define ARR_DATA_PTR(a)
Definition: array.h:310
float4 * numbers
Definition: lsyscache.h:53
#define ARR_HASNULL(a)
Definition: array.h:279
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
float float4
Definition: c.h:490
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1385
#define DatumGetArrayTypePCopy(X)
Definition: array.h:250
#define InvalidOid
Definition: postgres_ext.h:36
#define STATISTIC_NUM_SLOTS
Definition: pg_statistic.h:126
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
Datum * values
Definition: lsyscache.h:50
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251
#define ARR_NDIM(a)
Definition: array.h:278
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3461
#define elog(elevel,...)
Definition: elog.h:226
int i
void * numbers_arr
Definition: lsyscache.h:58
Oid valuetype
Definition: lsyscache.h:49
#define ARR_ELEMTYPE(a)
Definition: array.h:280
long val
Definition: informix.c:684

◆ get_atttype()

Oid get_atttype ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 861 of file lsyscache.c.

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

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

862 {
863  HeapTuple tp;
864 
865  tp = SearchSysCache2(ATTNUM,
866  ObjectIdGetDatum(relid),
868  if (HeapTupleIsValid(tp))
869  {
871  Oid result;
872 
873  result = att_tup->atttypid;
874  ReleaseSysCache(tp);
875  return result;
876  }
877  else
878  return InvalidOid;
879 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1135

◆ get_atttypetypmodcoll()

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

Definition at line 891 of file lsyscache.c.

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

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

893 {
894  HeapTuple tp;
895  Form_pg_attribute att_tup;
896 
897  tp = SearchSysCache2(ATTNUM,
898  ObjectIdGetDatum(relid),
900  if (!HeapTupleIsValid(tp))
901  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
902  attnum, relid);
903  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
904 
905  *typid = att_tup->atttypid;
906  *typmod = att_tup->atttypmod;
907  *collid = att_tup->attcollation;
908  ReleaseSysCache(tp);
909 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1135
#define elog(elevel,...)
Definition: elog.h:226

◆ get_base_element_type()

Oid get_base_element_type ( Oid  typid)

Definition at line 2599 of file lsyscache.c.

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

2600 {
2601  /*
2602  * We loop to find the bottom base type in a stack of domains.
2603  */
2604  for (;;)
2605  {
2606  HeapTuple tup;
2607  Form_pg_type typTup;
2608 
2609  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2610  if (!HeapTupleIsValid(tup))
2611  break;
2612  typTup = (Form_pg_type) GETSTRUCT(tup);
2613  if (typTup->typtype != TYPTYPE_DOMAIN)
2614  {
2615  /* Not a domain, so stop descending */
2616  Oid result;
2617 
2618  /* This test must match get_element_type */
2619  if (typTup->typlen == -1)
2620  result = typTup->typelem;
2621  else
2622  result = InvalidOid;
2623  ReleaseSysCache(tup);
2624  return result;
2625  }
2626 
2627  typid = typTup->typbasetype;
2628  ReleaseSysCache(tup);
2629  }
2630 
2631  /* Like get_element_type, silently return InvalidOid for bogus input */
2632  return InvalidOid;
2633 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ get_collation_isdeterministic()

bool get_collation_isdeterministic ( Oid  colloid)

Definition at line 942 of file lsyscache.c.

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

Referenced by btbpchar_pattern_sortsupport(), bttext_pattern_sortsupport(), internal_bpchar_pattern_compare(), internal_text_pattern_compare(), match_pattern_prefix(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), ri_restrict(), and ri_set().

943 {
944  HeapTuple tp;
945  Form_pg_collation colltup;
946  bool result;
947 
948  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
949  if (!HeapTupleIsValid(tp))
950  elog(ERROR, "cache lookup failed for collation %u", colloid);
951  colltup = (Form_pg_collation) GETSTRUCT(tp);
952  result = colltup->collisdeterministic;
953  ReleaseSysCache(tp);
954  return result;
955 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:51
#define elog(elevel,...)
Definition: elog.h:226

◆ get_collation_name()

char* get_collation_name ( Oid  colloid)

Definition at line 923 of file lsyscache.c.

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

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

924 {
925  HeapTuple tp;
926 
927  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
928  if (HeapTupleIsValid(tp))
929  {
931  char *result;
932 
933  result = pstrdup(NameStr(colltup->collname));
934  ReleaseSysCache(tp);
935  return result;
936  }
937  else
938  return NULL;
939 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1161
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:51
#define NameStr(name)
Definition: c.h:609

◆ get_commutator()

Oid get_commutator ( Oid  opno)

Definition at line 1311 of file lsyscache.c.

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

Referenced by CommuteOpExpr(), compute_semijoin_info(), ComputeIndexAttrs(), convert_EXISTS_to_ANY(), eqjoinsel(), expand_indexqual_rowcompare(), match_clause_to_ordering_op(), match_clause_to_partition_key(), match_foreign_keys_to_quals(), match_opclause_to_indexcol(), match_rowcompare_to_indexcol(), networkjoinsel(), operator_predicate_proof(), rangesel(), scalarineqsel_wrapper(), and targetIsInSortList().

1312 {
1313  HeapTuple tp;
1314 
1316  if (HeapTupleIsValid(tp))
1317  {
1319  Oid result;
1320 
1321  result = optup->oprcom;
1322  ReleaseSysCache(tp);
1323  return result;
1324  }
1325  else
1326  return InvalidOid;
1327 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:84

◆ get_compatible_hash_operators()

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

Definition at line 407 of file lsyscache.c.

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

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

◆ get_constraint_name()

char* get_constraint_name ( Oid  conoid)

Definition at line 969 of file lsyscache.c.

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

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

970 {
971  HeapTuple tp;
972 
974  if (HeapTupleIsValid(tp))
975  {
977  char *result;
978 
979  result = pstrdup(NameStr(contup->conname));
980  ReleaseSysCache(tp);
981  return result;
982  }
983  else
984  return NULL;
985 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1161
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_constraint * Form_pg_constraint
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:609

◆ get_element_type()

Oid get_element_type ( Oid  typid)

Definition at line 2526 of file lsyscache.c.

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

Referenced by aclcheck_error_type(), AlterTypeNamespace_oid(), build_coercion_expression(), check_generic_type_consistency(), CheckAttributeType(), CreateCast(), enforce_generic_type_consistency(), exec_assign_value(), exec_stmt_foreach_a(), ExecInitExprRec(), fetch_array_arg_replace_nulls(), find_coercion_pathway(), get_promoted_array_type(), initArrayResultAny(), initArrayResultArr(), interpret_function_parameter_list(), is_complex_array(), json_categorize_type(), jsonb_categorize_type(), moveArrayTypeName(), plperl_array_to_datum(), ProcedureCreate(), resolve_generic_type(), transformArrayExpr(), and transformTypeCast().

2527 {
2528  HeapTuple tp;
2529 
2531  if (HeapTupleIsValid(tp))
2532  {
2533  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2534  Oid result;
2535 
2536  if (typtup->typlen == -1)
2537  result = typtup->typelem;
2538  else
2539  result = InvalidOid;
2540  ReleaseSysCache(tp);
2541  return result;
2542  }
2543  else
2544  return InvalidOid;
2545 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ get_equality_op_for_ordering_op()

Oid get_equality_op_for_ordering_op ( Oid  opno,
bool reverse 
)

Definition at line 264 of file lsyscache.c.

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

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

265 {
266  Oid result = InvalidOid;
267  Oid opfamily;
268  Oid opcintype;
269  int16 strategy;
270 
271  /* Find the operator in pg_amop */
273  &opfamily, &opcintype, &strategy))
274  {
275  /* Found a suitable opfamily, get matching equality operator */
276  result = get_opfamily_member(opfamily,
277  opcintype,
278  opcintype,
280  if (reverse)
281  *reverse = (strategy == BTGreaterStrategyNumber);
282  }
283 
284  return result;
285 }
signed short int16
Definition: c.h:345
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
unsigned int Oid
Definition: postgres_ext.h:31
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:163
#define InvalidOid
Definition: postgres_ext.h:36
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
Definition: lsyscache.c:204
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_func_leakproof()

bool get_func_leakproof ( Oid  funcid)

Definition at line 1639 of file lsyscache.c.

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

1640 {
1641  HeapTuple tp;
1642  bool result;
1643 
1644  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1645  if (!HeapTupleIsValid(tp))
1646  elog(ERROR, "cache lookup failed for function %u", funcid);
1647 
1648  result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
1649  ReleaseSysCache(tp);
1650  return result;
1651 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:226

◆ get_func_name()

char* get_func_name ( Oid  funcid)

Definition at line 1410 of file lsyscache.c.

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

Referenced by AlterOpFamilyAdd(), DefineOpClass(), ExecBuildGroupingEqual(), ExecInitAgg(), ExecInitExprRec(), ExecInitFunc(), ExecInitWindowAgg(), ExecuteCallStmt(), ExplainTargetRel(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), HandleFunctionRequest(), init_sexpr(), initialize_peragg(), lookup_agg_function(), lookup_am_handler_func(), print_expr(), show_tablesample(), and statistic_proc_security_check().

1411 {
1412  HeapTuple tp;
1413 
1414  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1415  if (HeapTupleIsValid(tp))
1416  {
1417  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1418  char *result;
1419 
1420  result = pstrdup(NameStr(functup->proname));
1421  ReleaseSysCache(tp);
1422  return result;
1423  }
1424  else
1425  return NULL;
1426 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1161
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:609

◆ get_func_namespace()

Oid get_func_namespace ( Oid  funcid)

Definition at line 1434 of file lsyscache.c.

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

Referenced by sepgsql_proc_drop(), and unaccent_dict().

1435 {
1436  HeapTuple tp;
1437 
1438  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1439  if (HeapTupleIsValid(tp))
1440  {
1441  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1442  Oid result;
1443 
1444  result = functup->pronamespace;
1445  ReleaseSysCache(tp);
1446  return result;
1447  }
1448  else
1449  return InvalidOid;
1450 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_func_nargs()

int get_func_nargs ( Oid  funcid)

Definition at line 1476 of file lsyscache.c.

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

1477 {
1478  HeapTuple tp;
1479  int result;
1480 
1481  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1482  if (!HeapTupleIsValid(tp))
1483  elog(ERROR, "cache lookup failed for function %u", funcid);
1484 
1485  result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1486  ReleaseSysCache(tp);
1487  return result;
1488 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
int16 pronargs
Definition: pg_proc.h:82
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:226

◆ get_func_prokind()

char get_func_prokind ( Oid  funcid)

Definition at line 1620 of file lsyscache.c.

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

Referenced by LookupFuncWithArgs(), and RemoveObjects().

1621 {
1622  HeapTuple tp;
1623  char result;
1624 
1625  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1626  if (!HeapTupleIsValid(tp))
1627  elog(ERROR, "cache lookup failed for function %u", funcid);
1628 
1629  result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
1630  ReleaseSysCache(tp);
1631  return result;
1632 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:226

◆ get_func_retset()

bool get_func_retset ( Oid  funcid)

Definition at line 1544 of file lsyscache.c.

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

Referenced by make_op(), and make_scalar_array_op().

1545 {
1546  HeapTuple tp;
1547  bool result;
1548 
1549  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1550  if (!HeapTupleIsValid(tp))
1551  elog(ERROR, "cache lookup failed for function %u", funcid);
1552 
1553  result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
1554  ReleaseSysCache(tp);
1555  return result;
1556 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:226

◆ get_func_rettype()

Oid get_func_rettype ( Oid  funcid)

Definition at line 1457 of file lsyscache.c.

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

Referenced by CreateConversionCommand(), CreateEventTrigger(), CreateProceduralLanguage(), CreateTrigger(), DefineOperator(), DefineType(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), findTypeAnalyzeFunction(), findTypeTypmodinFunction(), findTypeTypmodoutFunction(), get_ts_parser_func(), get_ts_template_func(), gistrescan(), interpret_func_support(), lookup_am_handler_func(), lookup_fdw_handler_func(), OperatorCreate(), spgrescan(), transformRangeTableSample(), ValidateJoinEstimator(), and ValidateRestrictionEstimator().

1458 {
1459  HeapTuple tp;
1460  Oid result;
1461 
1462  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1463  if (!HeapTupleIsValid(tp))
1464  elog(ERROR, "cache lookup failed for function %u", funcid);
1465 
1466  result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype;
1467  ReleaseSysCache(tp);
1468  return result;
1469 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:226

◆ get_func_signature()

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

Definition at line 1498 of file lsyscache.c.

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

Referenced by plperl_call_perl_func(), and resolve_aggregate_transtype().

1499 {
1500  HeapTuple tp;
1501  Form_pg_proc procstruct;
1502  Oid result;
1503 
1504  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1505  if (!HeapTupleIsValid(tp))
1506  elog(ERROR, "cache lookup failed for function %u", funcid);
1507 
1508  procstruct = (Form_pg_proc) GETSTRUCT(tp);
1509 
1510  result = procstruct->prorettype;
1511  *nargs = (int) procstruct->pronargs;
1512  Assert(*nargs == procstruct->proargtypes.dim1);
1513  *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1514  memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1515 
1516  ReleaseSysCache(tp);
1517  return result;
1518 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:732
void * palloc(Size size)
Definition: mcxt.c:924
#define elog(elevel,...)
Definition: elog.h:226

◆ get_func_support()

RegProcedure get_func_support ( Oid  funcid)

Definition at line 1660 of file lsyscache.c.

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

Referenced by function_selectivity(), and get_index_clause_from_support().

1661 {
1662  HeapTuple tp;
1663 
1664  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1665  if (HeapTupleIsValid(tp))
1666  {
1667  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1668  RegProcedure result;
1669 
1670  result = functup->prosupport;
1671  ReleaseSysCache(tp);
1672  return result;
1673  }
1674  else
1675  return (RegProcedure) InvalidOid;
1676 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:505
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_func_variadictype()

Oid get_func_variadictype ( Oid  funcid)

Definition at line 1525 of file lsyscache.c.

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

Referenced by assign_hypothetical_collations(), and assign_ordered_set_collations().

1526 {
1527  HeapTuple tp;
1528  Oid result;
1529 
1530  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1531  if (!HeapTupleIsValid(tp))
1532  elog(ERROR, "cache lookup failed for function %u", funcid);
1533 
1534  result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
1535  ReleaseSysCache(tp);
1536  return result;
1537 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:134
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:226

◆ get_index_column_opclass()

Oid get_index_column_opclass ( Oid  index_oid,
int  attno 
)

Definition at line 3163 of file lsyscache.c.

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

Referenced by gistproperty(), and spgproperty().

3164 {
3165  HeapTuple tuple;
3167  Datum datum;
3168  bool isnull;
3169  oidvector *indclass;
3170  Oid opclass;
3171 
3172  /* First we need to know the column's opclass. */
3173 
3174  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3175  if (!HeapTupleIsValid(tuple))
3176  return InvalidOid;
3177 
3178  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3179 
3180  /* caller is supposed to guarantee this */
3181  Assert(attno > 0 && attno <= rd_index->indnatts);
3182 
3183  datum = SysCacheGetAttr(INDEXRELID, tuple,
3184  Anum_pg_index_indclass, &isnull);
3185  Assert(!isnull);
3186 
3187  indclass = ((oidvector *) DatumGetPointer(datum));
3188  opclass = indclass->values[attno - 1];
3189 
3190  ReleaseSysCache(tuple);
3191 
3192  return opclass;
3193 }
Definition: c.h:588
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition: c.h:596
FormData_pg_index * Form_pg_index
Definition: pg_index.h:66
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1385
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:732
#define DatumGetPointer(X)
Definition: postgres.h:549
#define PG_USED_FOR_ASSERTS_ONLY
Definition: c.h:123

◆ get_language_name()

char* get_language_name ( Oid  langoid,
bool  missing_ok 
)

Definition at line 990 of file lsyscache.c.

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

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

991 {
992  HeapTuple tp;
993 
994  tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
995  if (HeapTupleIsValid(tp))
996  {
998  char *result;
999 
1000  result = pstrdup(NameStr(lantup->lanname));
1001  ReleaseSysCache(tp);
1002  return result;
1003  }
1004 
1005  if (!missing_ok)
1006  elog(ERROR, "cache lookup failed for language %u",
1007  langoid);
1008  return NULL;
1009 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1161
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_language * Form_pg_language
Definition: pg_language.h:65
#define elog(elevel,...)
Definition: elog.h:226
#define NameStr(name)
Definition: c.h:609

◆ get_mergejoin_opfamilies()

List* get_mergejoin_opfamilies ( Oid  opno)

Definition at line 363 of file lsyscache.c.

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

364 {
365  List *result = NIL;
366  CatCList *catlist;
367  int i;
368 
369  /*
370  * Search pg_amop to see if the target operator is registered as the "="
371  * operator of any btree opfamily.
372  */
374 
375  for (i = 0; i < catlist->n_members; i++)
376  {
377  HeapTuple tuple = &catlist->members[i]->tuple;
378  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
379 
380  /* must be btree equality */
381  if (aform->amopmethod == BTREE_AM_OID &&
382  aform->amopstrategy == BTEqualStrategyNumber)
383  result = lappend_oid(result, aform->amopfamily);
384  }
385 
386  ReleaseSysCacheList(catlist);
387 
388  return result;
389 }
#define NIL
Definition: pg_list.h:65
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
List * lappend_oid(List *list, Oid datum)
Definition: list.c:357
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121
Definition: pg_list.h:50
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_namespace_name()

char* get_namespace_name ( Oid  nspid)

Definition at line 3094 of file lsyscache.c.

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

Referenced by acquire_inherited_sample_rows(), add_cast_to(), AlterExtensionNamespace(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterRelationNamespaceInternal(), AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), appendFunctionName(), ApplyExtensionUpdates(), ATExecChangeOwner(), BuildRelationExtStatistics(), check_TSCurrentConfig(), compute_return_type(), copy_table(), copy_table_data(), CreateConversionCommand(), CreateExtensionInternal(), CreateFunction(), current_schema(), current_schemas(), 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(), ExecRefreshMatView(), execute_extension_script(), ExplainTargetRel(), fetch_statentries_for_relation(), format_operator_internal(), format_procedure_internal(), generate_collation_name(), generate_function_name(), generate_operator_clause(), generate_operator_name(), generate_qualified_relation_name(), generate_qualified_type_name(), generate_relation_name(), generateClonedIndexStmt(), generateSerialExtraStmts(), get_collation(), get_namespace_name_or_temp(), get_opclass(), get_opclass_name(), get_other_operator(), getObjectDescription(), getOpFamilyDescription(), getRelationDescription(), GetTempNamespaceBackendId(), HandleFunctionRequest(), heap_create(), heap_vacuum_rel(), isAnyTempNamespace(), IsThereCollationInNamespace(), IsThereFunctionInNamespace(), IsThereOpClassInNamespace(), IsThereOpFamilyInNamespace(), lazy_scan_heap(), 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(), perform_work_item(), pg_decode_change(), pg_decode_truncate(), pg_event_trigger_ddl_commands(), pg_get_functiondef(), pg_get_statisticsobj_worker(), pg_identify_object(), pg_newlocale_from_collation(), plpgsql_fulfill_promise(), postgresGetForeignRelSize(), quoteRelationName(), RangeVarCallbackForAlterRelation(), RangeVarGetAndCheckCreationNamespace(), RebuildConstraintComment(), refresh_by_match_merge(), regclassout(), regconfigout(), regdictionaryout(), regnamespaceout(), regoperout(), regprocout(), ReindexMultipleTables(), 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().

3095 {
3096  HeapTuple tp;
3097 
3099  if (HeapTupleIsValid(tp))
3100  {
3102  char *result;
3103 
3104  result = pstrdup(NameStr(nsptup->nspname));
3105  ReleaseSysCache(tp);
3106  return result;
3107  }
3108  else
3109  return NULL;
3110 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
FormData_pg_namespace * Form_pg_namespace
Definition: pg_namespace.h:51
char * pstrdup(const char *in)
Definition: mcxt.c:1161
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:609

◆ get_namespace_name_or_temp()

char* get_namespace_name_or_temp ( Oid  nspid)

Definition at line 3118 of file lsyscache.c.

References get_namespace_name(), and isTempNamespace().

Referenced by format_operator_parts(), format_procedure_parts(), format_type_extended(), getObjectIdentityParts(), getOpFamilyIdentity(), and getRelationIdentity().

3119 {
3120  if (isTempNamespace(nspid))
3121  return "pg_temp";
3122  else
3123  return get_namespace_name(nspid);
3124 }
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3094
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3149

◆ get_negator()

Oid get_negator ( Oid  opno)

Definition at line 1335 of file lsyscache.c.

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

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

1336 {
1337  HeapTuple tp;
1338 
1340  if (HeapTupleIsValid(tp))
1341  {
1343  Oid result;
1344 
1345  result = optup->oprnegate;
1346  ReleaseSysCache(tp);
1347  return result;
1348  }
1349  else
1350  return InvalidOid;
1351 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:84

◆ get_op_btree_interpretation()

List* get_op_btree_interpretation ( Oid  opno)

Definition at line 598 of file lsyscache.c.

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

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

◆ get_op_hash_functions()

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

Definition at line 507 of file lsyscache.c.

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 ExecHashTableCreate(), ExecInitSubPlan(), and execTuplesHashPrepare().

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

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

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

137 {
138  HeapTuple tp;
139  Form_pg_amop amop_tup;
140 
142  ObjectIdGetDatum(opno),
143  CharGetDatum(ordering_op ? AMOP_ORDER : AMOP_SEARCH),
144  ObjectIdGetDatum(opfamily));
145  if (!HeapTupleIsValid(tp))
146  elog(ERROR, "operator %u is not a member of opfamily %u",
147  opno, opfamily);
148  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
149  *strategy = amop_tup->amopstrategy;
150  *lefttype = amop_tup->amoplefttype;
151  *righttype = amop_tup->amoprighttype;
152  ReleaseSysCache(tp);
153 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1146
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:416
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
#define elog(elevel,...)
Definition: elog.h:226

◆ get_op_opfamily_sortfamily()

Oid get_op_opfamily_sortfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 105 of file lsyscache.c.

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

Referenced by match_clause_to_ordering_op().

106 {
107  HeapTuple tp;
108  Form_pg_amop amop_tup;
109  Oid result;
110 
112  ObjectIdGetDatum(opno),
113  CharGetDatum(AMOP_ORDER),
114  ObjectIdGetDatum(opfamily));
115  if (!HeapTupleIsValid(tp))
116  return InvalidOid;
117  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
118  result = amop_tup->amopsortfamily;
119  ReleaseSysCache(tp);
120  return result;
121 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1146
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:416
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88

◆ get_op_opfamily_strategy()

int get_op_opfamily_strategy ( Oid  opno,
Oid  opfamily 
)

Definition at line 80 of file lsyscache.c.

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

81 {
82  HeapTuple tp;
83  Form_pg_amop amop_tup;
84  int result;
85 
87  ObjectIdGetDatum(opno),
88  CharGetDatum(AMOP_SEARCH),
89  ObjectIdGetDatum(opfamily));
90  if (!HeapTupleIsValid(tp))
91  return 0;
92  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
93  result = amop_tup->amopstrategy;
94  ReleaseSysCache(tp);
95  return result;
96 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1146
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:416
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88

◆ get_op_rettype()

Oid get_op_rettype ( Oid  opno)

Definition at line 1140 of file lsyscache.c.

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

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

1141 {
1142  HeapTuple tp;
1143 
1145  if (HeapTupleIsValid(tp))
1146  {
1148  Oid result;
1149 
1150  result = optup->oprresult;
1151  ReleaseSysCache(tp);
1152  return result;
1153  }
1154  else
1155  return InvalidOid;
1156 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:84

◆ get_opclass_family()

Oid get_opclass_family ( Oid  opclass)

Definition at line 1019 of file lsyscache.c.

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

1020 {
1021  HeapTuple tp;
1022  Form_pg_opclass cla_tup;
1023  Oid result;
1024 
1025  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1026  if (!HeapTupleIsValid(tp))
1027  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1028  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1029 
1030  result = cla_tup->opcfamily;
1031  ReleaseSysCache(tp);
1032  return result;
1033 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:226
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83

◆ get_opclass_input_type()

Oid get_opclass_input_type ( Oid  opclass)

Definition at line 1041 of file lsyscache.c.

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

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

1042 {
1043  HeapTuple tp;
1044  Form_pg_opclass cla_tup;
1045  Oid result;
1046 
1047  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1048  if (!HeapTupleIsValid(tp))
1049  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1050  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1051 
1052  result = cla_tup->opcintype;
1053  ReleaseSysCache(tp);
1054  return result;
1055 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:226
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83

◆ get_opclass_opfamily_and_input_type()

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

Definition at line 1064 of file lsyscache.c.

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

Referenced by gistproperty(), and spgproperty().

1065 {
1066  HeapTuple tp;
1067  Form_pg_opclass cla_tup;
1068 
1069  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1070  if (!HeapTupleIsValid(tp))
1071  return false;
1072 
1073  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1074 
1075  *opfamily = cla_tup->opcfamily;
1076  *opcintype = cla_tup->opcintype;
1077 
1078  ReleaseSysCache(tp);
1079 
1080  return true;
1081 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1092 of file lsyscache.c.

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

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

1093 {
1094  HeapTuple tp;
1095 
1097  if (HeapTupleIsValid(tp))
1098  {
1100  RegProcedure result;
1101 
1102  result = optup->oprcode;
1103  ReleaseSysCache(tp);
1104  return result;
1105  }
1106  else
1107  return (RegProcedure) InvalidOid;
1108 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:505
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:84

◆ get_opfamily_member()

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

Definition at line 163 of file lsyscache.c.

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

Referenced by _bt_compare_scankey_args(), _bt_find_extreme_element(), ATAddForeignKeyConstraint(), btcostestimate(), build_replindex_scan_key(), BuildSpeculativeIndexInfo(), create_indexscan_plan(), expand_indexqual_rowcompare(), 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(), match_pattern_prefix(), mergejoinscansel(), patternsel_common(), prefix_selectivity(), prepare_sort_from_pathkeys(), refresh_by_match_merge(), and select_equality_operator().

165 {
166  HeapTuple tp;
167  Form_pg_amop amop_tup;
168  Oid result;
169 
171  ObjectIdGetDatum(opfamily),
172  ObjectIdGetDatum(lefttype),
173  ObjectIdGetDatum(righttype),
174  Int16GetDatum(strategy));
175  if (!HeapTupleIsValid(tp))
176  return InvalidOid;
177  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
178  result = amop_tup->amopopr;
179  ReleaseSysCache(tp);
180  return result;
181 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1157
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88

◆ get_opfamily_proc()

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

Definition at line 744 of file lsyscache.c.

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

Referenced by _bt_first(), _bt_sort_array_elements(), _hash_datum2hashkey_type(), ExecIndexBuildScanKeys(), ExecInitExprRec(), FinishSortSupportFunction(), get_op_hash_functions(), gincost_pattern(), gistvalidate(), load_rangetype_info(), lookup_type_cache(), match_clause_to_partition_key(), MJExamineQuals(), and RelationBuildPartitionKey().

745 {
746  HeapTuple tp;
747  Form_pg_amproc amproc_tup;
748  RegProcedure result;
749 
751  ObjectIdGetDatum(opfamily),
752  ObjectIdGetDatum(lefttype),
753  ObjectIdGetDatum(righttype),
754  Int16GetDatum(procnum));
755  if (!HeapTupleIsValid(tp))
756  return InvalidOid;
757  amproc_tup = (Form_pg_amproc) GETSTRUCT(tp);
758  result = amproc_tup->amproc;
759  ReleaseSysCache(tp);
760  return result;
761 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
FormData_pg_amproc * Form_pg_amproc
Definition: pg_amproc.h:68
regproc RegProcedure
Definition: c.h:505
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1157
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_opname()

char* get_opname ( Oid  opno)

Definition at line 1117 of file lsyscache.c.

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

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

1118 {
1119  HeapTuple tp;
1120 
1122  if (HeapTupleIsValid(tp))
1123  {
1125  char *result;
1126 
1127  result = pstrdup(NameStr(optup->oprname));
1128  ReleaseSysCache(tp);
1129  return result;
1130  }
1131  else
1132  return NULL;
1133 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1161
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:84
#define NameStr(name)
Definition: c.h:609

◆ get_oprjoin()

RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1383 of file lsyscache.c.

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

Referenced by join_selectivity(), and scalararraysel().

1384 {
1385  HeapTuple tp;
1386 
1388  if (HeapTupleIsValid(tp))
1389  {
1391  RegProcedure result;
1392 
1393  result = optup->oprjoin;
1394  ReleaseSysCache(tp);
1395  return result;
1396  }
1397  else
1398  return (RegProcedure) InvalidOid;
1399 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:505
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:84

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1359 of file lsyscache.c.

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

Referenced by clauselist_selectivity_simple(), dependency_is_compatible_clause(), restriction_selectivity(), scalararraysel(), and statext_is_compatible_clause_internal().

1360 {
1361  HeapTuple tp;
1362 
1364  if (HeapTupleIsValid(tp))
1365  {
1367  RegProcedure result;
1368 
1369  result = optup->oprrest;
1370  ReleaseSysCache(tp);
1371  return result;
1372  }
1373  else
1374  return (RegProcedure) InvalidOid;
1375 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:505
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:84

◆ get_ordering_op_for_equality_op()

Oid get_ordering_op_for_equality_op ( Oid  opno,
bool  use_lhs_type 
)

Definition at line 302 of file lsyscache.c.

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

303 {
304  Oid result = InvalidOid;
305  CatCList *catlist;
306  int i;
307 
308  /*
309  * Search pg_amop to see if the target operator is registered as the "="
310  * operator of any btree opfamily.
311  */
313 
314  for (i = 0; i < catlist->n_members; i++)
315  {
316  HeapTuple tuple = &catlist->members[i]->tuple;
317  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
318 
319  /* must be btree */
320  if (aform->amopmethod != BTREE_AM_OID)
321  continue;
322 
323  if (aform->amopstrategy == BTEqualStrategyNumber)
324  {
325  /* Found a suitable opfamily, get matching ordering operator */
326  Oid typid;
327 
328  typid = use_lhs_type ? aform->amoplefttype : aform->amoprighttype;
329  result = get_opfamily_member(aform->amopfamily,
330  typid, typid,
332  if (OidIsValid(result))
333  break;
334  /* failure probably shouldn't happen, but keep looking if so */
335  }
336  }
337 
338  ReleaseSysCacheList(catlist);
339 
340  return result;
341 }
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:638
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:163
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
#define InvalidOid
Definition: postgres_ext.h:36
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121
#define BTLessStrategyNumber
Definition: stratnum.h:29
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_ordering_op_properties()

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

Definition at line 204 of file lsyscache.c.

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

206 {
207  bool result = false;
208  CatCList *catlist;
209  int i;
210 
211  /* ensure outputs are initialized on failure */
212  *opfamily = InvalidOid;
213  *opcintype = InvalidOid;
214  *strategy = 0;
215 
216  /*
217  * Search pg_amop to see if the target operator is registered as the "<"
218  * or ">" operator of any btree opfamily.
219  */
221 
222  for (i = 0; i < catlist->n_members; i++)
223  {
224  HeapTuple tuple = &catlist->members[i]->tuple;
225  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
226 
227  /* must be btree */
228  if (aform->amopmethod != BTREE_AM_OID)
229  continue;
230 
231  if (aform->amopstrategy == BTLessStrategyNumber ||
232  aform->amopstrategy == BTGreaterStrategyNumber)
233  {
234  /* Found it ... should have consistent input types */
235  if (aform->amoplefttype == aform->amoprighttype)
236  {
237  /* Found a suitable opfamily, return info */
238  *opfamily = aform->amopfamily;
239  *opcintype = aform->amoplefttype;
240  *strategy = aform->amopstrategy;
241  result = true;
242  break;
243  }
244  }
245  }
246 
247  ReleaseSysCacheList(catlist);
248 
249  return result;
250 }
int n_members
Definition: catcache.h:176
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
#define InvalidOid
Definition: postgres_ext.h:36
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121
#define BTLessStrategyNumber
Definition: stratnum.h:29

◆ get_promoted_array_type()

Oid get_promoted_array_type ( Oid  typid)

Definition at line 2578 of file lsyscache.c.

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

Referenced by build_subplan(), and exprType().

2579 {
2580  Oid array_type = get_array_type(typid);
2581 
2582  if (OidIsValid(array_type))
2583  return array_type;
2584  if (OidIsValid(get_element_type(typid)))
2585  return typid;
2586  return InvalidOid;
2587 }
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2526
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2554
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:638
#define InvalidOid
Definition: postgres_ext.h:36

◆ get_range_subtype()

Oid get_range_subtype ( Oid  rangeOid)

Definition at line 3135 of file lsyscache.c.

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

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

3136 {
3137  HeapTuple tp;
3138 
3139  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3140  if (HeapTupleIsValid(tp))
3141  {
3142  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3143  Oid result;
3144 
3145  result = rngtup->rngsubtype;
3146  ReleaseSysCache(tp);
3147  return result;
3148  }
3149  else
3150  return InvalidOid;
3151 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:55
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_rel_name()

char* get_rel_name ( Oid  relid)

Definition at line 1730 of file lsyscache.c.

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

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_tlist(), AlterSubscription_refresh(), AlterTableNamespace(), ApplyWorkerMain(), ATExecChangeOwner(), check_enable_rls(), check_new_partition_bound(), conversion_error_callback(), convert_column_name(), CreateTrigger(), 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_rte_attribute_type(), 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(), map_sql_schema_to_xmlschema_types(), 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(), postgresGetForeignRelSize(), process_owned_by(), reindex_index(), ReindexMultipleTables(), ReindexRelationConcurrently(), RenameConstraintById(), satisfies_hash_partition(), set_rtable_names(), show_modifytable_info(), table_to_xml_internal(), and transformAlterTableStmt().

1731 {
1732  HeapTuple tp;
1733 
1734  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1735  if (HeapTupleIsValid(tp))
1736  {
1737  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1738  char *result;
1739 
1740  result = pstrdup(NameStr(reltup->relname));
1741  ReleaseSysCache(tp);
1742  return result;
1743  }
1744  else
1745  return NULL;
1746 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1161
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:150
#define NameStr(name)
Definition: c.h:609

◆ get_rel_namespace()

Oid get_rel_namespace ( Oid  relid)

Definition at line 1754 of file lsyscache.c.

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

Referenced by AlterSubscription_refresh(), do_autovacuum(), exec_object_restorecon(), ExecCheckXactReadOnly(), perform_work_item(), pg_decode_change(), ReindexMultipleTables(), ReindexRelationConcurrently(), sepgsql_relation_drop(), and transformAlterTableStmt().

1755 {
1756  HeapTuple tp;
1757 
1758  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1759  if (HeapTupleIsValid(tp))
1760  {
1761  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1762  Oid result;
1763 
1764  result = reltup->relnamespace;
1765  ReleaseSysCache(tp);
1766  return result;
1767  }
1768  else
1769  return InvalidOid;
1770 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:150

◆ get_rel_persistence()

char get_rel_persistence ( Oid  relid)

Definition at line 1880 of file lsyscache.c.

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

Referenced by RangeVarCallbackForLockTable(), and set_rel_consider_parallel().

1881 {
1882  HeapTuple tp;
1883  Form_pg_class reltup;
1884  char result;
1885 
1886  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1887  if (!HeapTupleIsValid(tp))
1888  elog(ERROR, "cache lookup failed for relation %u", relid);
1889  reltup = (Form_pg_class) GETSTRUCT(tp);
1890  result = reltup->relpersistence;
1891  ReleaseSysCache(tp);
1892 
1893  return result;
1894 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:150
#define elog(elevel,...)
Definition: elog.h:226

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

Definition at line 1829 of file lsyscache.c.

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

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

1830 {
1831  HeapTuple tp;
1832 
1833  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1834  if (HeapTupleIsValid(tp))
1835  {
1836  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1837  bool result;
1838 
1839  result = reltup->relispartition;
1840  ReleaseSysCache(tp);
1841  return result;
1842  }
1843  else
1844  return false;
1845 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:150

◆ get_rel_relkind()

char get_rel_relkind ( Oid  relid)

Definition at line 1805 of file lsyscache.c.

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

Referenced by AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), ATExecAlterColumnType(), ATExecChangeOwner(), check_rel_can_be_partition(), check_relation_privileges(), CreateSubscription(), CreateTrigger(), doDeletion(), EnableDisableRule(), exec_object_restorecon(), ExecCheckRTPerms(), get_constraint_index(), get_object_type(), getOwnedSequences_internal(), 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(), LockTableRecurse(), pg_get_serial_sequence(), pg_get_triggerdef_worker(), pg_partition_tree(), ProcessUtilitySlow(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForDropRelation(), RangeVarCallbackForLockTable(), RangeVarCallbackForPolicy(), RangeVarCallbackForReindexIndex(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackOwnsRelation(), RangeVarCallbackOwnsTable(), RangeVarGetAndCheckCreationNamespace(), ReindexRelationConcurrently(), RelationBuildPartitionDesc(), renameatt_check(), RenameType(), sepgsql_attribute_drop(), sepgsql_attribute_post_create(), sepgsql_attribute_relabel(), sepgsql_attribute_setattr(), sepgsql_relation_drop(), sepgsql_relation_relabel(), and sepgsql_relation_setattr().

1806 {
1807  HeapTuple tp;
1808 
1809  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1810  if (HeapTupleIsValid(tp))
1811  {
1812  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1813  char result;
1814 
1815  result = reltup->relkind;
1816  ReleaseSysCache(tp);
1817  return result;
1818  }
1819  else
1820  return '\0';
1821 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:150

◆ get_rel_tablespace()

Oid get_rel_tablespace ( Oid  relid)

Definition at line 1856 of file lsyscache.c.

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

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

1857 {
1858  HeapTuple tp;
1859 
1860  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1861  if (HeapTupleIsValid(tp))
1862  {
1863  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1864  Oid result;
1865 
1866  result = reltup->reltablespace;
1867  ReleaseSysCache(tp);
1868  return result;
1869  }
1870  else
1871  return InvalidOid;
1872 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:150

◆ get_rel_type_id()

Oid get_rel_type_id ( Oid  relid)

Definition at line 1781 of file lsyscache.c.

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

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

1782 {
1783  HeapTuple tp;
1784 
1785  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1786  if (HeapTupleIsValid(tp))
1787  {
1788  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1789  Oid result;
1790 
1791  result = reltup->reltype;
1792  ReleaseSysCache(tp);
1793  return result;
1794  }
1795  else
1796  return InvalidOid;
1797 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:150

◆ get_relname_relid()

◆ get_transform_fromsql()

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

Definition at line 1900 of file lsyscache.c.

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

1901 {
1902  HeapTuple tup;
1903 
1904  if (!list_member_oid(trftypes, typid))
1905  return InvalidOid;
1906 
1907  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
1908  if (HeapTupleIsValid(tup))
1909  {
1910  Oid funcid;
1911 
1912  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
1913  ReleaseSysCache(tup);
1914  return funcid;
1915  }
1916  else
1917  return InvalidOid;
1918 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:674
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1135

◆ get_transform_tosql()

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

Definition at line 1921 of file lsyscache.c.

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

Referenced by plperl_sv_to_datum(), and PLy_output_setup_func().

1922 {
1923  HeapTuple tup;
1924 
1925  if (!list_member_oid(trftypes, typid))
1926  return InvalidOid;
1927 
1928  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
1929  if (HeapTupleIsValid(tup))
1930  {
1931  Oid funcid;
1932 
1933  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
1934  ReleaseSysCache(tup);
1935  return funcid;
1936  }
1937  else
1938  return InvalidOid;
1939 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:674
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1135

◆ get_typ_typrelid()

Oid get_typ_typrelid ( Oid  typid)

Definition at line 2499 of file lsyscache.c.

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

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

2500 {
2501  HeapTuple tp;
2502 
2504  if (HeapTupleIsValid(tp))
2505  {
2506  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2507  Oid result;
2508 
2509  result = typtup->typrelid;
2510  ReleaseSysCache(tp);
2511  return result;
2512  }
2513  else
2514  return InvalidOid;
2515 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ get_typavgwidth()

int32 get_typavgwidth ( Oid  typid,
int32  typmod 
)

Definition at line 2356 of file lsyscache.c.

References get_typlen(), and type_maximum_size().

Referenced by create_one_window_path(), find_placeholder_info(), get_agg_clause_costs_walker(), get_rel_data_width(), set_append_rel_size(), set_pathtarget_cost_width(), and set_rel_width().

2357 {
2358  int typlen = get_typlen(typid);
2359  int32 maxwidth;
2360 
2361  /*
2362  * Easy if it's a fixed-width type
2363  */
2364  if (typlen > 0)
2365  return typlen;
2366 
2367  /*
2368  * type_maximum_size knows the encoding of typmod for some datatypes;
2369  * don't duplicate that knowledge here.
2370  */
2371  maxwidth = type_maximum_size(typid, typmod);
2372  if (maxwidth > 0)
2373  {
2374  /*
2375  * For BPCHAR, the max width is also the only width. Otherwise we
2376  * need to guess about the typical data width given the max. A sliding
2377  * scale for percentage of max width seems reasonable.
2378  */
2379  if (typid == BPCHAROID)
2380  return maxwidth;
2381  if (maxwidth <= 32)
2382  return maxwidth; /* assume full width */
2383  if (maxwidth < 1000)
2384  return 32 + (maxwidth - 32) / 2; /* assume 50% */
2385 
2386  /*
2387  * Beyond 1000, assume we're looking at something like
2388  * "varchar(10000)" where the limit isn't actually reached often, and
2389  * use a fixed estimate.
2390  */
2391  return 32 + (1000 - 32) / 2;
2392  }
2393 
2394  /*
2395  * Oops, we have no idea ... wild guess time.
2396  */
2397  return 32;
2398 }
signed int int32
Definition: c.h:346
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:395
int16 get_typlen(Oid typid)
Definition: lsyscache.c:1975

◆ get_typbyval()

bool get_typbyval ( Oid  typid)

Definition at line 2000 of file lsyscache.c.

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

Referenced by get_agg_clause_costs_walker().

2001 {
2002  HeapTuple tp;
2003 
2005  if (HeapTupleIsValid(tp))
2006  {
2007  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2008  bool result;
2009 
2010  result = typtup->typbyval;
2011  ReleaseSysCache(tp);
2012  return result;
2013  }
2014  else
2015  return false;
2016 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ get_typcollation()

Oid get_typcollation ( Oid  typid)

Definition at line 2823 of file lsyscache.c.

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

Referenced by assign_collations_walker(), ATExecAddColumn(), check_sql_fn_retval(), DefineRange(), domainAddConstraint(), fixed_paramref_hook(), get_cast_hashentry(), get_collation(), get_const_collation(), get_from_clause_coldeflist(), GetColumnDefCollation(), resolve_polymorphic_tupdesc(), show_sortorder_options(), sql_fn_make_param(), transformAssignmentSubscripts(), transformRangeTableFunc(), type_is_collatable(), variable_coerce_param_hook(), and variable_paramref_hook().

2824 {
2825  HeapTuple tp;
2826 
2828  if (HeapTupleIsValid(tp))
2829  {
2830  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2831  Oid result;
2832 
2833  result = typtup->typcollation;
2834  ReleaseSysCache(tp);
2835  return result;
2836  }
2837  else
2838  return InvalidOid;
2839 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ get_typdefault()

Node* get_typdefault ( Oid  typid)

Definition at line 2226 of file lsyscache.c.

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

2227 {
2228  HeapTuple typeTuple;
2230  Datum datum;
2231  bool isNull;
2232  Node *expr;
2233 
2234  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2235  if (!HeapTupleIsValid(typeTuple))
2236  elog(ERROR, "cache lookup failed for type %u", typid);
2237  type = (Form_pg_type) GETSTRUCT(typeTuple);
2238 
2239  /*
2240  * typdefault and typdefaultbin are potentially null, so don't try to
2241  * access 'em as struct fields. Must do it the hard way with
2242  * SysCacheGetAttr.
2243  */
2244  datum = SysCacheGetAttr(TYPEOID,
2245  typeTuple,
2246  Anum_pg_type_typdefaultbin,
2247  &isNull);
2248 
2249  if (!isNull)
2250  {
2251  /* We have an expression default */
2252  expr = stringToNode(TextDatumGetCString(datum));
2253  }
2254  else
2255  {
2256  /* Perhaps we have a plain literal default */
2257  datum = SysCacheGetAttr(TYPEOID,
2258  typeTuple,
2259  Anum_pg_type_typdefault,
2260  &isNull);
2261 
2262  if (!isNull)
2263  {
2264  char *strDefaultVal;
2265 
2266  /* Convert text datum to C string */
2267  strDefaultVal = TextDatumGetCString(datum);
2268  /* Convert C string to a value of the given type */
2269  datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2270  getTypeIOParam(typeTuple), -1);
2271  /* Build a Const node containing the value */
2272  expr = (Node *) makeConst(typid,
2273  -1,
2274  type->typcollation,
2275  type->typlen,
2276  datum,
2277  false,
2278  type->typbyval);
2279  pfree(strDefaultVal);
2280  }
2281  else
2282  {
2283  /* No default */
2284  expr = NULL;
2285  }
2286  }
2287 
2288  ReleaseSysCache(typeTuple);
2289 
2290  return expr;
2291 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
Definition: nodes.h:524
void * stringToNode(const char *str)
Definition: read.c:89
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:297
void pfree(void *pointer)
Definition: mcxt.c:1031
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
#define TextDatumGetCString(d)
Definition: builtins.h:84
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1385
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251
#define elog(elevel,...)
Definition: elog.h:226
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2081
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1646

◆ get_type_category_preferred()

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

Definition at line 2478 of file lsyscache.c.

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

Referenced by func_select_candidate(), IsPreferredType(), select_common_type(), TypeCategory(), and XmlTableGetValue().

2479 {
2480  HeapTuple tp;
2481  Form_pg_type typtup;
2482 
2484  if (!HeapTupleIsValid(tp))
2485  elog(ERROR, "cache lookup failed for type %u", typid);
2486  typtup = (Form_pg_type) GETSTRUCT(tp);
2487  *typcategory = typtup->typcategory;
2488  *typispreferred = typtup->typispreferred;
2489  ReleaseSysCache(tp);
2490 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251
#define elog(elevel,...)
Definition: elog.h:226

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

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

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

2111 {
2112  HeapTuple typeTuple;
2113  Form_pg_type typeStruct;
2114 
2115  /*
2116  * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2117  * use array_in and array_out during bootstrap.
2118  */
2120  {
2121  Oid typinput;
2122  Oid typoutput;
2123 
2124  boot_get_type_io_data(typid,
2125  typlen,
2126  typbyval,
2127  typalign,
2128  typdelim,
2129  typioparam,
2130  &typinput,
2131  &typoutput);
2132  switch (which_func)
2133  {
2134  case IOFunc_input:
2135  *func = typinput;
2136  break;
2137  case IOFunc_output:
2138  *func = typoutput;
2139  break;
2140  default:
2141  elog(ERROR, "binary I/O not supported during bootstrap");
2142  break;
2143  }
2144  return;
2145  }
2146 
2147  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2148  if (!HeapTupleIsValid(typeTuple))
2149  elog(ERROR, "cache lookup failed for type %u", typid);
2150  typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2151 
2152  *typlen = typeStruct->typlen;
2153  *typbyval = typeStruct->typbyval;
2154  *typalign = typeStruct->typalign;
2155  *typdelim = typeStruct->typdelim;
2156  *typioparam = getTypeIOParam(typeTuple);
2157  switch (which_func)
2158  {
2159  case IOFunc_input:
2160  *func = typeStruct->typinput;
2161  break;
2162  case IOFunc_output:
2163  *func = typeStruct->typoutput;
2164  break;
2165  case IOFunc_receive:
2166  *func = typeStruct->typreceive;
2167  break;
2168  case IOFunc_send:
2169  *func = typeStruct->typsend;
2170  break;
2171  }
2172  ReleaseSysCache(typeTuple);
2173 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
char typalign
Definition: pg_type.h:170
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:374
#define elog(elevel,...)
Definition: elog.h:226
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2081
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:985

◆ get_typisdefined()

bool get_typisdefined ( Oid  typid)

Definition at line 1951 of file lsyscache.c.

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

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

1952 {
1953  HeapTuple tp;
1954 
1956  if (HeapTupleIsValid(tp))
1957  {
1958  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
1959  bool result;
1960 
1961  result = typtup->typisdefined;
1962  ReleaseSysCache(tp);
1963  return result;
1964  }
1965  else
1966  return false;
1967 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 1975 of file lsyscache.c.

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

Referenced by exec_assign_value(), ExecBuildProjectionInfo(), ExecInitCoerceToDomain(), ExecInitExprRec(), ExecInitSubscriptingRef(), get_typavgwidth(), and pg_column_size().

1976 {
1977  HeapTuple tp;
1978 
1980  if (HeapTupleIsValid(tp))
1981  {
1982  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
1983  int16 result;
1984 
1985  result = typtup->typlen;
1986  ReleaseSysCache(tp);
1987  return result;
1988  }
1989  else
1990  return 0;
1991 }
signed short int16
Definition: c.h:345
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ get_typlenbyval()

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

Definition at line 2029 of file lsyscache.c.

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

Referenced by build_pertrans_for_aggref(), copyParamList(), EstimateParamExecSpace(), EstimateParamListSpace(), eval_const_expressions_mutator(), evaluate_expr(), exec_eval_using_params(), exec_stmt_block(), ExecInitAgg(), ExecInitIndexScan(), ExecInitWindowAgg(), ExecWindowAgg(), fillTypeDesc(), get_actual_variable_range(), get_variable_range(), init_sql_fcache(), initialize_peragg(), makeNullConst(), scalararraysel(), SerializeParamExecParams(), SerializeParamList(), and tuplesort_begin_datum().

2030 {
2031  HeapTuple tp;
2032  Form_pg_type typtup;
2033 
2035  if (!HeapTupleIsValid(tp))
2036  elog(ERROR, "cache lookup failed for type %u", typid);
2037  typtup = (Form_pg_type) GETSTRUCT(tp);
2038  *typlen = typtup->typlen;
2039  *typbyval = typtup->typbyval;
2040  ReleaseSysCache(tp);
2041 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251
#define elog(elevel,...)
Definition: elog.h:226

◆ get_typlenbyvalalign()

void get_typlenbyvalalign ( Oid  typid,
int16 typlen,
bool typbyval,
char *  typalign 
)

Definition at line 2049 of file lsyscache.c.

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

Referenced by _bt_preprocess_array_keys(), array_create_iterator(), array_fill_internal(), array_map(), array_position_common(), array_positions(), array_to_json_internal(), array_to_jsonb_internal(), array_unnest(), arrayconst_startup_fn(), CreateCast(), DefineRange(), exec_assign_value(), ExecEvalScalarArrayOp(), ExecIndexEvalArrayKeys(), ExecInitExprRec(), ExecInitSubscriptingRef(), expand_array(), extract_variadic_args(), get_text_array_contents(), ginarrayextract(), gincost_scalararrayopexpr(), ginqueryarrayextract(), initArrayResult(), map_sql_value_to_xml_value(), match_clause_to_partition_key(), ordered_set_startup(), RelationBuildPartitionKey(), satisfies_hash_partition(), scalararraysel(), and text_format().

2051 {
2052  HeapTuple tp;
2053  Form_pg_type typtup;
2054 
2056  if (!HeapTupleIsValid(tp))
2057  elog(ERROR, "cache lookup failed for type %u", typid);
2058  typtup = (Form_pg_type) GETSTRUCT(tp);
2059  *typlen = typtup->typlen;
2060  *typbyval = typtup->typbyval;
2061  *typalign = typtup->typalign;
2062  ReleaseSysCache(tp);
2063 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char typalign
Definition: pg_type.h:170
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251
#define elog(elevel,...)
Definition: elog.h:226

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 2773 of file lsyscache.c.

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

2774 {
2775  HeapTuple tp;
2776 
2778  if (HeapTupleIsValid(tp))
2779  {
2780  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2781  Oid result;
2782 
2783  result = typtup->typmodin;
2784  ReleaseSysCache(tp);
2785  return result;
2786  }
2787  else
2788  return InvalidOid;
2789 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2197 of file lsyscache.c.

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

2198 {
2199  HeapTuple tp;
2200 
2202  if (HeapTupleIsValid(tp))
2203  {
2204  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2205  char result;
2206 
2207  result = typtup->typstorage;
2208  ReleaseSysCache(tp);
2209  return result;
2210  }
2211  else
2212  return 'p';
2213 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ get_typtype()

char get_typtype ( Oid  typid)

Definition at line 2407 of file lsyscache.c.

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

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

2408 {
2409  HeapTuple tp;
2410 
2412  if (HeapTupleIsValid(tp))
2413  {
2414  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2415  char result;
2416 
2417  result = typtup->typtype;
2418  ReleaseSysCache(tp);
2419  return result;
2420  }
2421  else
2422  return '\0';
2423 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2316 of file lsyscache.c.

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(), exec_assign_value(), getBaseType(), lookup_type_cache(), map_sql_type_to_xmlschema_type(), prepare_column_cache(), SendRowDescriptionCols_2(), SendRowDescriptionCols_3(), transformAssignmentIndirection(), transformContainerType(), and transformTypeCast().

2317 {
2318  /*
2319  * We loop to find the bottom base type in a stack of domains.
2320  */
2321  for (;;)
2322  {
2323  HeapTuple tup;
2324  Form_pg_type typTup;
2325 
2326  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2327  if (!HeapTupleIsValid(tup))
2328  elog(ERROR, "cache lookup failed for type %u", typid);
2329  typTup = (Form_pg_type) GETSTRUCT(tup);
2330  if (typTup->typtype != TYPTYPE_DOMAIN)
2331  {
2332  /* Not a domain, so done */
2333  ReleaseSysCache(tup);
2334  break;
2335  }
2336 
2337  Assert(*typmod == -1);
2338  typid = typTup->typbasetype;
2339  *typmod = typTup->typtypmod;
2340 
2341  ReleaseSysCache(tup);
2342  }
2343 
2344  return typid;
2345 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:732
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251
#define elog(elevel,...)
Definition: elog.h:226

◆ getTypeBinaryInputInfo()

void getTypeBinaryInputInfo ( Oid  type,
Oid typReceive,
Oid typIOParam 
)

Definition at line 2707 of file lsyscache.c.

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

Referenced by BeginCopyFrom(), domain_state_setup(), exec_bind_message(), parse_fcall_arguments(), parse_fcall_arguments_20(), and record_recv().

2708 {
2709  HeapTuple typeTuple;
2710  Form_pg_type pt;
2711 
2713  if (!HeapTupleIsValid(typeTuple))
2714  elog(ERROR, "cache lookup failed for type %u", type);
2715  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2716 
2717  if (!pt->typisdefined)
2718  ereport(ERROR,
2719  (errcode(ERRCODE_UNDEFINED_OBJECT),
2720  errmsg("type %s is only a shell",
2721  format_type_be(type))));
2722  if (!OidIsValid(pt->typreceive))
2723  ereport(ERROR,
2724  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2725  errmsg("no binary input function available for type %s",
2726  format_type_be(type))));
2727 
2728  *typReceive = pt->typreceive;
2729  *typIOParam = getTypeIOParam(typeTuple);
2730 
2731  ReleaseSysCache(typeTuple);
2732 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
int errcode(int sqlerrcode)
Definition: elog.c:570
char * format_type_be(Oid type_oid)
Definition: format_type.c:326
#define OidIsValid(objectId)
Definition: c.h:638
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:141
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251
int errmsg(const char *fmt,...)
Definition: elog.c:784
#define elog(elevel,...)
Definition: elog.h:226
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2081

◆ getTypeBinaryOutputInfo()

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

Definition at line 2740 of file lsyscache.c.

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

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

2741 {
2742  HeapTuple typeTuple;
2743  Form_pg_type pt;
2744 
2746  if (!HeapTupleIsValid(typeTuple))
2747  elog(ERROR, "cache lookup failed for type %u", type);
2748  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2749 
2750  if (!pt->typisdefined)
2751  ereport(ERROR,
2752  (errcode(ERRCODE_UNDEFINED_OBJECT),
2753  errmsg("type %s is only a shell",
2754  format_type_be(type))));
2755  if (!OidIsValid(pt->typsend))
2756  ereport(ERROR,
2757  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2758  errmsg("no binary output function available for type %s",
2759  format_type_be(type))));
2760 
2761  *typSend = pt->typsend;
2762  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2763 
2764  ReleaseSysCache(typeTuple);
2765 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
int errcode(int sqlerrcode)
Definition: elog.c:570
char * format_type_be(Oid type_oid)
Definition: format_type.c:326
#define OidIsValid(objectId)
Definition: c.h:638
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:141
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251
int errmsg(const char *fmt,...)
Definition: elog.c:784
#define elog(elevel,...)
Definition: elog.h:226

◆ getTypeInputInfo()

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

Definition at line 2641 of file lsyscache.c.

References elog, ereport, errcode(), errmsg(), ERROR, format_type_be(), GETSTRUCT, getTypeIOParam(), HeapTupleIsValid, ObjectIdGetDatum, OidIsValid, ReleaseSysCache(), SearchSysCache1(), 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_cstrings(), slot_store_cstrings(), and TupleDescGetAttInMetadata().

2642 {
2643  HeapTuple typeTuple;
2644  Form_pg_type pt;
2645 
2647  if (!HeapTupleIsValid(typeTuple))
2648  elog(ERROR, "cache lookup failed for type %u", type);
2649  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2650 
2651  if (!pt->typisdefined)
2652  ereport(ERROR,
2653  (errcode(ERRCODE_UNDEFINED_OBJECT),
2654  errmsg("type %s is only a shell",
2655  format_type_be(type))));
2656  if (!OidIsValid(pt->typinput))
2657  ereport(ERROR,
2658  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2659  errmsg("no input function available for type %s",
2660  format_type_be(type))));
2661 
2662  *typInput = pt->typinput;
2663  *typIOParam = getTypeIOParam(typeTuple);
2664 
2665  ReleaseSysCache(typeTuple);
2666 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
int errcode(int sqlerrcode)
Definition: elog.c:570
char * format_type_be(Oid type_oid)
Definition: format_type.c:326
#define OidIsValid(objectId)
Definition: c.h:638
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:141
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251
int errmsg(const char *fmt,...)
Definition: elog.c:784
#define elog(elevel,...)
Definition: elog.h:226
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2081

◆ getTypeIOParam()

Oid getTypeIOParam ( HeapTuple  typeTuple)

Definition at line 2081 of file lsyscache.c.

References GETSTRUCT, and OidIsValid.

Referenced by compile_plperl_function(), compile_pltcl_function(), get_typdefault(), get_type_io_data(), getTypeBinaryInputInfo(), getTypeInputInfo(), and stringTypeDatum().

2082 {
2083  Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2084 
2085  /*
2086  * Array types get their typelem as parameter; everybody else gets their
2087  * own type OID as parameter.
2088  */
2089  if (OidIsValid(typeStruct->typelem))
2090  return typeStruct->typelem;
2091  else
2092  return typeStruct->oid;
2093 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define OidIsValid(objectId)
Definition: c.h:638
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251

◆ getTypeOutputInfo()

void getTypeOutputInfo ( Oid  type,
Oid typOutput,
bool typIsVarlena 
)

Definition at line 2674 of file lsyscache.c.

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

Referenced by brin_page_items(), build_concat_foutcache(), BuildIndexValueDescription(), check_functions_in_node(), convert_value_to_string(), CopyTo(), cost_qual_eval_walker(), create_foreign_modify(), debugtup(), deparseConst(), errdetail_params(), 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().

2675 {
2676  HeapTuple typeTuple;
2677  Form_pg_type pt;
2678 
2680  if (!HeapTupleIsValid(typeTuple))
2681  elog(ERROR, "cache lookup failed for type %u", type);
2682  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2683 
2684  if (!pt->typisdefined)
2685  ereport(ERROR,
2686  (errcode(ERRCODE_UNDEFINED_OBJECT),
2687  errmsg("type %s is only a shell",
2688  format_type_be(type))));
2689  if (!OidIsValid(pt->typoutput))
2690  ereport(ERROR,
2691  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2692  errmsg("no output function available for type %s",
2693  format_type_be(type))));
2694 
2695  *typOutput = pt->typoutput;
2696  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2697 
2698  ReleaseSysCache(typeTuple);
2699 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
int errcode(int sqlerrcode)
Definition: elog.c:570
char * format_type_be(Oid type_oid)
Definition: format_type.c:326
#define OidIsValid(objectId)
Definition: c.h:638
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:141
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:251
int errmsg(const char *fmt,...)
Definition: elog.c:784
#define elog(elevel,...)
Definition: elog.h:226

◆ op_hashjoinable()

bool op_hashjoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1244 of file lsyscache.c.

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

1245 {
1246  bool result = false;
1247  HeapTuple tp;
1248  TypeCacheEntry *typentry;
1249 
1250  /* As in op_mergejoinable, let the typcache handle the hard cases */
1251  /* Eventually we'll need a similar case for record_eq ... */
1252  if (opno == ARRAY_EQ_OP)
1253  {
1254  typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1255  if (typentry->hash_proc == F_HASH_ARRAY)
1256  result = true;
1257  }
1258  else
1259  {
1260  /* For all other operators, rely on pg_operator.oprcanhash */
1262  if (HeapTupleIsValid(tp))
1263  {
1265 
1266  result = optup->oprcanhash;
1267  ReleaseSysCache(tp);
1268  }
1269  }
1270  return result;
1271 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:322
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:84
#define TYPECACHE_HASH_PROC
Definition: typcache.h:132

◆ op_in_opfamily()

bool op_in_opfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 63 of file lsyscache.c.

References AMOPOPID, CharGetDatum, ObjectIdGetDatum, and SearchSysCacheExists3.

Referenced by equality_ops_are_compatible(), have_partkey_equi_join(), match_clause_to_partition_key(), match_opclause_to_indexcol(), match_saopclause_to_indexcol(), and relation_has_unique_index_for().

64 {
66  ObjectIdGetDatum(opno),
67  CharGetDatum(AMOP_SEARCH),
68  ObjectIdGetDatum(opfamily));
69 }
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheExists3(cacheId, key1, key2, key3)
Definition: syscache.h:187
#define CharGetDatum(X)
Definition: postgres.h:416

◆ op_input_types()

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

Definition at line 1165 of file lsyscache.c.

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

1166 {
1167  HeapTuple tp;
1168  Form_pg_operator optup;
1169 
1171  if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1172  elog(ERROR, "cache lookup failed for operator %u", opno);
1173  optup = (Form_pg_operator) GETSTRUCT(tp);
1174  *lefttype = optup->oprleft;
1175  *righttype = optup->oprright;
1176  ReleaseSysCache(tp);
1177 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:84
#define elog(elevel,...)
Definition: elog.h:226

◆ op_mergejoinable()

bool op_mergejoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1193 of file lsyscache.c.

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

1194 {
1195  bool result = false;
1196  HeapTuple tp;
1197  TypeCacheEntry *typentry;
1198 
1199  /*
1200  * For array_eq or record_eq, we can sort if the element or field types
1201  * are all sortable. We could implement all the checks for that here, but
1202  * the typcache already does that and caches the results too, so let's
1203  * rely on the typcache.
1204  */
1205  if (opno == ARRAY_EQ_OP)
1206  {
1207  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1208  if (typentry->cmp_proc == F_BTARRAYCMP)
1209  result = true;
1210  }
1211  else if (opno == RECORD_EQ_OP)
1212  {
1213  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1214  if (typentry->cmp_proc == F_BTRECORDCMP)
1215  result = true;
1216  }
1217  else
1218  {
1219  /* For all other operators, rely on pg_operator.oprcanmerge */
1221  if (HeapTupleIsValid(tp))
1222  {
1224 
1225  result = optup->oprcanmerge;
1226  ReleaseSysCache(tp);
1227  }
1228  }
1229  return result;
1230 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1124
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1172
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:322
#define TYPECACHE_CMP_PROC
Definition: typcache.h:131
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:84

◆ op_strict()

bool op_strict ( Oid  opno)

Definition at line 1279 of file lsyscache.c.

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

1280 {
1281  RegProcedure funcid = get_opcode(opno);
1282 
1283  if (funcid == (RegProcedure) InvalidOid)
1284  elog(ERROR, "operator %u does not exist", opno);
1285 
1286  return func_strict((Oid) funcid);
1287 }
regproc RegProcedure
Definition: c.h:505
unsigned int Oid
Definition: postgres_ext.h:31
#define ERROR
Definition: elog.h:43
#define InvalidOid
Definition: postgres_ext.h:36
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1092
bool func_strict(Oid funcid)
Definition: lsyscache.c:1563
#define elog(elevel,...)
Definition: elog.h:226

◆ op_volatile()

char op_volatile ( Oid  opno)

Definition at line 1295 of file lsyscache.c.

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

Referenced by lookup_proof_cache(), and match_clause_to_partition_key().

1296 {
1297  RegProcedure funcid = get_opcode(opno);
1298 
1299  if (funcid == (RegProcedure) InvalidOid)
1300  elog(ERROR, "operator %u does not exist", opno);
1301 
1302  return func_volatile((Oid) funcid);
1303 }
regproc RegProcedure
Definition: c.h:505
unsigned int Oid
Definition: postgres_ext.h:31
#define ERROR
Definition: elog.h:43
#define InvalidOid
Definition: postgres_ext.h:36
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1092
char func_volatile(Oid funcid)
Definition: lsyscache.c:1582
#define elog(elevel,...)
Definition: elog.h:226

◆ type_is_collatable()

bool type_is_collatable ( Oid  typid)

Definition at line 2848 of file lsyscache.c.

References get_typcollation(), and OidIsValid.

Referenced by CheckAttributeType(), ComputeIndexAttrs(), ComputePartitionAttrs(), create_ctas_nodata(), DefineRange(), DefineVirtualRelation(), intorel_startup(), pg_collation_for(), and transformCollateClause().

2849 {
2850  return OidIsValid(get_typcollation(typid));
2851 }
#define OidIsValid(objectId)
Definition: c.h:638
Oid get_typcollation(Oid typid)
Definition: lsyscache.c:2823

◆ type_is_enum()

bool type_is_enum ( Oid  typid)

Definition at line 2456 of file lsyscache.c.

References get_typtype().

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

2457 {
2458  return (get_typtype(typid) == TYPTYPE_ENUM);
2459 }
char get_typtype(Oid typid)
Definition: lsyscache.c:2407

◆ type_is_range()

bool type_is_range ( Oid  typid)

Definition at line 2466 of file lsyscache.c.

References get_typtype().

Referenced by IsBinaryCoercible().

2467 {
2468  return (get_typtype(typid) == TYPTYPE_RANGE);
2469 }
char get_typtype(Oid typid)
Definition: lsyscache.c:2407

◆ type_is_rowtype()

bool type_is_rowtype ( Oid  typid)

Definition at line 2433 of file lsyscache.c.

References get_typtype(), and getBaseType().

Referenced by build_datatype(), coerce_function_result_tuple(), compile_plperl_function(), compile_pltcl_function(), deparseNullTest(), do_compile(), exec_assign_value(), exec_stmt_return(), exec_stmt_return_next(), ExecMakeTableFunctionResult(), find_minmax_aggs_walker(), 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().

2434 {
2435  if (typid == RECORDOID)
2436  return true; /* easy case */
2437  switch (get_typtype(typid))
2438  {
2439  case TYPTYPE_COMPOSITE:
2440  return true;
2441  case TYPTYPE_DOMAIN:
2442  if (get_typtype(getBaseType(typid)) == TYPTYPE_COMPOSITE)
2443  return true;
2444  break;
2445  default:
2446  break;
2447  }
2448  return false;
2449 }
char get_typtype(Oid typid)
Definition: lsyscache.c:2407
Oid getBaseType(Oid typid)
Definition: lsyscache.c:2299

Variable Documentation

◆ get_attavgwidth_hook

get_attavgwidth_hook_type get_attavgwidth_hook = NULL

Definition at line 50 of file lsyscache.c.

Referenced by get_attavgwidth().