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

Go to the source code of this file.

Functions

bool op_in_opfamily (Oid opno, Oid opfamily)
 
int get_op_opfamily_strategy (Oid opno, Oid opfamily)
 
Oid get_op_opfamily_sortfamily (Oid opno, Oid opfamily)
 
void get_op_opfamily_properties (Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
 
Oid get_opfamily_member (Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
 
bool get_ordering_op_properties (Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
 
Oid get_equality_op_for_ordering_op (Oid opno, bool *reverse)
 
Oid get_ordering_op_for_equality_op (Oid opno, bool use_lhs_type)
 
Listget_mergejoin_opfamilies (Oid opno)
 
bool get_compatible_hash_operators (Oid opno, Oid *lhs_opno, Oid *rhs_opno)
 
bool get_op_hash_functions (Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
 
Listget_op_btree_interpretation (Oid opno)
 
bool equality_ops_are_compatible (Oid opno1, Oid opno2)
 
bool comparison_ops_are_compatible (Oid opno1, Oid opno2)
 
Oid get_opfamily_proc (Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
 
char * get_attname (Oid relid, AttrNumber attnum, bool missing_ok)
 
AttrNumber get_attnum (Oid relid, const char *attname)
 
char get_attgenerated (Oid relid, AttrNumber attnum)
 
Oid get_atttype (Oid relid, AttrNumber attnum)
 
void get_atttypetypmodcoll (Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
 
Datum get_attoptions (Oid relid, int16 attnum)
 
Oid get_cast_oid (Oid sourcetypeid, Oid targettypeid, bool missing_ok)
 
char * get_collation_name (Oid colloid)
 
bool get_collation_isdeterministic (Oid colloid)
 
char * get_constraint_name (Oid conoid)
 
Oid get_constraint_index (Oid conoid)
 
char get_constraint_type (Oid conoid)
 
char * get_language_name (Oid langoid, bool missing_ok)
 
Oid get_opclass_family (Oid opclass)
 
Oid get_opclass_input_type (Oid opclass)
 
bool get_opclass_opfamily_and_input_type (Oid opclass, Oid *opfamily, Oid *opcintype)
 
Oid get_opclass_method (Oid opclass)
 
char * get_opfamily_name (Oid opfid, bool missing_ok)
 
RegProcedure get_opcode (Oid opno)
 
char * get_opname (Oid opno)
 
Oid get_op_rettype (Oid opno)
 
void op_input_types (Oid opno, Oid *lefttype, Oid *righttype)
 
bool op_mergejoinable (Oid opno, Oid inputtype)
 
bool op_hashjoinable (Oid opno, Oid inputtype)
 
bool op_strict (Oid opno)
 
char op_volatile (Oid opno)
 
Oid get_commutator (Oid opno)
 
Oid get_negator (Oid opno)
 
RegProcedure get_oprrest (Oid opno)
 
RegProcedure get_oprjoin (Oid opno)
 
char * get_func_name (Oid funcid)
 
Oid get_func_namespace (Oid funcid)
 
Oid get_func_rettype (Oid funcid)
 
int get_func_nargs (Oid funcid)
 
Oid get_func_signature (Oid funcid, Oid **argtypes, int *nargs)
 
Oid get_func_variadictype (Oid funcid)
 
bool get_func_retset (Oid funcid)
 
bool func_strict (Oid funcid)
 
char func_volatile (Oid funcid)
 
char func_parallel (Oid funcid)
 
char get_func_prokind (Oid funcid)
 
bool get_func_leakproof (Oid funcid)
 
RegProcedure get_func_support (Oid funcid)
 
Oid get_relname_relid (const char *relname, Oid relnamespace)
 
char * get_rel_name (Oid relid)
 
Oid get_rel_namespace (Oid relid)
 
Oid get_rel_type_id (Oid relid)
 
char get_rel_relkind (Oid relid)
 
bool get_rel_relispartition (Oid relid)
 
Oid get_rel_tablespace (Oid relid)
 
char get_rel_persistence (Oid relid)
 
Oid get_rel_relam (Oid relid)
 
Oid get_transform_fromsql (Oid typid, Oid langid, List *trftypes)
 
Oid get_transform_tosql (Oid typid, Oid langid, List *trftypes)
 
bool get_typisdefined (Oid typid)
 
int16 get_typlen (Oid typid)
 
bool get_typbyval (Oid typid)
 
void get_typlenbyval (Oid typid, int16 *typlen, bool *typbyval)
 
void get_typlenbyvalalign (Oid typid, int16 *typlen, bool *typbyval, char *typalign)
 
Oid getTypeIOParam (HeapTuple typeTuple)
 
void get_type_io_data (Oid typid, IOFuncSelector which_func, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *func)
 
char get_typstorage (Oid typid)
 
Nodeget_typdefault (Oid typid)
 
Oid getBaseType (Oid typid)
 
Oid getBaseTypeAndTypmod (Oid typid, int32 *typmod)
 
int32 get_typavgwidth (Oid typid, int32 typmod)
 
char get_typtype (Oid typid)
 
bool type_is_rowtype (Oid typid)
 
bool type_is_enum (Oid typid)
 
bool type_is_range (Oid typid)
 
bool type_is_multirange (Oid typid)
 
void get_type_category_preferred (Oid typid, char *typcategory, bool *typispreferred)
 
Oid get_typ_typrelid (Oid typid)
 
Oid get_element_type (Oid typid)
 
Oid get_array_type (Oid typid)
 
Oid get_promoted_array_type (Oid typid)
 
Oid get_base_element_type (Oid typid)
 
void getTypeInputInfo (Oid type, Oid *typInput, Oid *typIOParam)
 
void getTypeOutputInfo (Oid type, Oid *typOutput, bool *typIsVarlena)
 
void getTypeBinaryInputInfo (Oid type, Oid *typReceive, Oid *typIOParam)
 
void getTypeBinaryOutputInfo (Oid type, Oid *typSend, bool *typIsVarlena)
 
Oid get_typmodin (Oid typid)
 
Oid get_typcollation (Oid typid)
 
bool type_is_collatable (Oid typid)
 
RegProcedure get_typsubscript (Oid typid, Oid *typelemp)
 
const struct SubscriptRoutinesgetSubscriptingRoutines (Oid typid, Oid *typelemp)
 
int32 get_attavgwidth (Oid relid, AttrNumber attnum)
 
bool get_attstatsslot (AttStatsSlot *sslot, HeapTuple statstuple, int reqkind, Oid reqop, int flags)
 
void free_attstatsslot (AttStatsSlot *sslot)
 
char * get_namespace_name (Oid nspid)
 
char * get_namespace_name_or_temp (Oid nspid)
 
Oid get_range_subtype (Oid rangeOid)
 
Oid get_range_collation (Oid rangeOid)
 
Oid get_range_multirange (Oid rangeOid)
 
Oid get_multirange_range (Oid multirangeOid)
 
Oid get_index_column_opclass (Oid index_oid, int attno)
 
bool get_index_isreplident (Oid index_oid)
 
bool get_index_isvalid (Oid index_oid)
 
bool get_index_isclustered (Oid index_oid)
 
Oid get_publication_oid (const char *pubname, bool missing_ok)
 
char * get_publication_name (Oid pubid, bool missing_ok)
 
Oid get_subscription_oid (const char *subname, bool missing_ok)
 
char * get_subscription_name (Oid subid, bool missing_ok)
 

Variables

get_attavgwidth_hook_type get_attavgwidth_hook = NULL
 

Function Documentation

◆ comparison_ops_are_compatible()

bool comparison_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 750 of file lsyscache.c.

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

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

Referenced by ineq_histogram_selectivity().

◆ equality_ops_are_compatible()

bool equality_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 699 of file lsyscache.c.

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

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

Referenced by query_is_distinct_for().

◆ free_attstatsslot()

void free_attstatsslot ( AttStatsSlot sslot)

Definition at line 3371 of file lsyscache.c.

3372{
3373 /* The values[] array was separately palloc'd by deconstruct_array */
3374 if (sslot->values)
3375 pfree(sslot->values);
3376 /* The numbers[] array points into numbers_arr, do not pfree it */
3377 /* Free the detoasted array objects, if any */
3378 if (sslot->values_arr)
3379 pfree(sslot->values_arr);
3380 if (sslot->numbers_arr)
3381 pfree(sslot->numbers_arr);
3382}
void pfree(void *pointer)
Definition: mcxt.c:1521
Datum * values
Definition: lsyscache.h:53
void * numbers_arr
Definition: lsyscache.h:61
void * values_arr
Definition: lsyscache.h:60

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

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

◆ func_parallel()

char func_parallel ( Oid  funcid)

Definition at line 1826 of file lsyscache.c.

1827{
1828 HeapTuple tp;
1829 char result;
1830
1831 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1832 if (!HeapTupleIsValid(tp))
1833 elog(ERROR, "cache lookup failed for function %u", funcid);
1834
1835 result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1836 ReleaseSysCache(tp);
1837 return result;
1838}
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:269
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:221

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

Referenced by max_parallel_hazard_checker(), and set_rel_consider_parallel().

◆ func_strict()

bool func_strict ( Oid  funcid)

Definition at line 1788 of file lsyscache.c.

1789{
1790 HeapTuple tp;
1791 bool result;
1792
1793 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1794 if (!HeapTupleIsValid(tp))
1795 elog(ERROR, "cache lookup failed for function %u", funcid);
1796
1797 result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
1798 ReleaseSysCache(tp);
1799 return result;
1800}

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

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

◆ func_volatile()

◆ get_array_type()

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 3185 of file lsyscache.c.

3186{
3187 HeapTuple tp;
3188 int32 stawidth;
3189
3191 {
3192 stawidth = (*get_attavgwidth_hook) (relid, attnum);
3193 if (stawidth > 0)
3194 return stawidth;
3195 }
3196 tp = SearchSysCache3(STATRELATTINH,
3197 ObjectIdGetDatum(relid),
3199 BoolGetDatum(false));
3200 if (HeapTupleIsValid(tp))
3201 {
3202 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3203 ReleaseSysCache(tp);
3204 if (stawidth > 0)
3205 return stawidth;
3206 }
3207 return 0;
3208}
int32_t int32
Definition: c.h:484
get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:54
int16 attnum
Definition: pg_attribute.h:74
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:135
static Datum Int16GetDatum(int16 X)
Definition: postgres.h:177
static Datum BoolGetDatum(bool X)
Definition: postgres.h:107
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:243

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

Referenced by get_rel_data_width(), and set_rel_width().

◆ get_attgenerated()

char get_attgenerated ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 889 of file lsyscache.c.

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

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

Referenced by AddRelationNewConstraints(), AddRelationNotNullConstraints(), check_nested_generated_walker(), and CreateStatistics().

◆ get_attname()

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

Definition at line 828 of file lsyscache.c.

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

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

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

◆ get_attnum()

◆ get_attoptions()

Datum get_attoptions ( Oid  relid,
int16  attnum 
)

Definition at line 971 of file lsyscache.c.

972{
973 HeapTuple tuple;
974 Datum attopts;
975 Datum result;
976 bool isnull;
977
978 tuple = SearchSysCache2(ATTNUM,
979 ObjectIdGetDatum(relid),
981
982 if (!HeapTupleIsValid(tuple))
983 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
984 attnum, relid);
985
986 attopts = SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions,
987 &isnull);
988
989 if (isnull)
990 result = (Datum) 0;
991 else
992 result = datumCopy(attopts, false, -1); /* text[] */
993
994 ReleaseSysCache(tuple);
995
996 return result;
997}
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition: datum.c:132
uintptr_t Datum
Definition: postgres.h:69
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:600

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

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

◆ get_attstatsslot()

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

Definition at line 3261 of file lsyscache.c.

3263{
3264 Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
3265 int i;
3266 Datum val;
3267 ArrayType *statarray;
3268 Oid arrayelemtype;
3269 int narrayelem;
3270 HeapTuple typeTuple;
3271 Form_pg_type typeForm;
3272
3273 /* initialize *sslot properly */
3274 memset(sslot, 0, sizeof(AttStatsSlot));
3275
3276 for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
3277 {
3278 if ((&stats->stakind1)[i] == reqkind &&
3279 (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
3280 break;
3281 }
3282 if (i >= STATISTIC_NUM_SLOTS)
3283 return false; /* not there */
3284
3285 sslot->staop = (&stats->staop1)[i];
3286 sslot->stacoll = (&stats->stacoll1)[i];
3287
3288 if (flags & ATTSTATSSLOT_VALUES)
3289 {
3290 val = SysCacheGetAttrNotNull(STATRELATTINH, statstuple,
3291 Anum_pg_statistic_stavalues1 + i);
3292
3293 /*
3294 * Detoast the array if needed, and in any case make a copy that's
3295 * under control of this AttStatsSlot.
3296 */
3297 statarray = DatumGetArrayTypePCopy(val);
3298
3299 /*
3300 * Extract the actual array element type, and pass it back in case the
3301 * caller needs it.
3302 */
3303 sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3304
3305 /* Need info about element type */
3306 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
3307 if (!HeapTupleIsValid(typeTuple))
3308 elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3309 typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
3310
3311 /* Deconstruct array into Datum elements; NULLs not expected */
3312 deconstruct_array(statarray,
3313 arrayelemtype,
3314 typeForm->typlen,
3315 typeForm->typbyval,
3316 typeForm->typalign,
3317 &sslot->values, NULL, &sslot->nvalues);
3318
3319 /*
3320 * If the element type is pass-by-reference, we now have a bunch of
3321 * Datums that are pointers into the statarray, so we need to keep
3322 * that until free_attstatsslot. Otherwise, all the useful info is in
3323 * sslot->values[], so we can free the array object immediately.
3324 */
3325 if (!typeForm->typbyval)
3326 sslot->values_arr = statarray;
3327 else
3328 pfree(statarray);
3329
3330 ReleaseSysCache(typeTuple);
3331 }
3332
3333 if (flags & ATTSTATSSLOT_NUMBERS)
3334 {
3335 val = SysCacheGetAttrNotNull(STATRELATTINH, statstuple,
3336 Anum_pg_statistic_stanumbers1 + i);
3337
3338 /*
3339 * Detoast the array if needed, and in any case make a copy that's
3340 * under control of this AttStatsSlot.
3341 */
3342 statarray = DatumGetArrayTypePCopy(val);
3343
3344 /*
3345 * We expect the array to be a 1-D float4 array; verify that. We don't
3346 * need to use deconstruct_array() since the array data is just going
3347 * to look like a C array of float4 values.
3348 */
3349 narrayelem = ARR_DIMS(statarray)[0];
3350 if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3351 ARR_HASNULL(statarray) ||
3352 ARR_ELEMTYPE(statarray) != FLOAT4OID)
3353 elog(ERROR, "stanumbers is not a 1-D float4 array");
3354
3355 /* Give caller a pointer directly into the statarray */
3356 sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3357 sslot->nnumbers = narrayelem;
3358
3359 /* We'll free the statarray in free_attstatsslot */
3360 sslot->numbers_arr = statarray;
3361 }
3362
3363 return true;
3364}
#define DatumGetArrayTypePCopy(X)
Definition: array.h:262
#define ARR_NDIM(a)
Definition: array.h:290
#define ARR_DATA_PTR(a)
Definition: array.h:322
#define ARR_ELEMTYPE(a)
Definition: array.h:292
#define ARR_DIMS(a)
Definition: array.h:294
#define ARR_HASNULL(a)
Definition: array.h:291
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3631
float float4
Definition: c.h:586
long val
Definition: informix.c:689
#define ATTSTATSSLOT_NUMBERS
Definition: lsyscache.h:43
#define ATTSTATSSLOT_VALUES
Definition: lsyscache.h:42
#define STATISTIC_NUM_SLOTS
Definition: pg_statistic.h:127
Oid valuetype
Definition: lsyscache.h:52
float4 * numbers
Definition: lsyscache.h:56
int nnumbers
Definition: lsyscache.h:57
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
Definition: syscache.c:631

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

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

◆ get_atttype()

Oid get_atttype ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 914 of file lsyscache.c.

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

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

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

◆ get_atttypetypmodcoll()

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

Definition at line 944 of file lsyscache.c.

946{
947 HeapTuple tp;
948 Form_pg_attribute att_tup;
949
950 tp = SearchSysCache2(ATTNUM,
951 ObjectIdGetDatum(relid),
953 if (!HeapTupleIsValid(tp))
954 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
955 attnum, relid);
956 att_tup = (Form_pg_attribute) GETSTRUCT(tp);
957
958 *typid = att_tup->atttypid;
959 *typmod = att_tup->atttypmod;
960 *collid = att_tup->attcollation;
961 ReleaseSysCache(tp);
962}
Oid collid

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

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

◆ get_base_element_type()

Oid get_base_element_type ( Oid  typid)

Definition at line 2859 of file lsyscache.c.

2860{
2861 /*
2862 * We loop to find the bottom base type in a stack of domains.
2863 */
2864 for (;;)
2865 {
2866 HeapTuple tup;
2867 Form_pg_type typTup;
2868
2869 tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2870 if (!HeapTupleIsValid(tup))
2871 break;
2872 typTup = (Form_pg_type) GETSTRUCT(tup);
2873 if (typTup->typtype != TYPTYPE_DOMAIN)
2874 {
2875 /* Not a domain, so stop descending */
2876 Oid result;
2877
2878 /* This test must match get_element_type */
2879 if (IsTrueArrayType(typTup))
2880 result = typTup->typelem;
2881 else
2882 result = InvalidOid;
2883 ReleaseSysCache(tup);
2884 return result;
2885 }
2886
2887 typid = typTup->typbasetype;
2888 ReleaseSysCache(tup);
2889 }
2890
2891 /* Like get_element_type, silently return InvalidOid for bogus input */
2892 return InvalidOid;
2893}

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

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

◆ get_cast_oid()

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

Definition at line 1008 of file lsyscache.c.

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

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

Referenced by get_object_address().

◆ get_collation_isdeterministic()

bool get_collation_isdeterministic ( Oid  colloid)

Definition at line 1055 of file lsyscache.c.

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

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

Referenced by ATAddForeignKeyConstraint(), index_create(), and match_pattern_prefix().

◆ get_collation_name()

char * get_collation_name ( Oid  colloid)

Definition at line 1036 of file lsyscache.c.

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

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

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

◆ get_commutator()

◆ get_compatible_hash_operators()

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

Definition at line 411 of file lsyscache.c.

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

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

Referenced by create_unique_plan(), and ExecInitSubPlan().

◆ get_constraint_index()

Oid get_constraint_index ( Oid  conoid)

Definition at line 1114 of file lsyscache.c.

1115{
1116 HeapTuple tp;
1117
1118 tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
1119 if (HeapTupleIsValid(tp))
1120 {
1122 Oid result;
1123
1124 if (contup->contype == CONSTRAINT_UNIQUE ||
1125 contup->contype == CONSTRAINT_PRIMARY ||
1126 contup->contype == CONSTRAINT_EXCLUSION)
1127 result = contup->conindid;
1128 else
1129 result = InvalidOid;
1130 ReleaseSysCache(tp);
1131 return result;
1132 }
1133 else
1134 return InvalidOid;
1135}
FormData_pg_constraint * Form_pg_constraint

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

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

◆ get_constraint_name()

char * get_constraint_name ( Oid  conoid)

Definition at line 1082 of file lsyscache.c.

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

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

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

◆ get_constraint_type()

char get_constraint_type ( Oid  conoid)

Definition at line 1144 of file lsyscache.c.

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

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

Referenced by AttachPartitionEnsureIndexes(), and RememberConstraintForRebuilding().

◆ get_element_type()

◆ get_equality_op_for_ordering_op()

Oid get_equality_op_for_ordering_op ( Oid  opno,
bool *  reverse 
)

Definition at line 268 of file lsyscache.c.

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

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

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

◆ get_func_leakproof()

bool get_func_leakproof ( Oid  funcid)

Definition at line 1864 of file lsyscache.c.

1865{
1866 HeapTuple tp;
1867 bool result;
1868
1869 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1870 if (!HeapTupleIsValid(tp))
1871 elog(ERROR, "cache lookup failed for function %u", funcid);
1872
1873 result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
1874 ReleaseSysCache(tp);
1875 return result;
1876}

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

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

◆ get_func_name()

◆ get_func_namespace()

Oid get_func_namespace ( Oid  funcid)

Definition at line 1659 of file lsyscache.c.

1660{
1661 HeapTuple tp;
1662
1663 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1664 if (HeapTupleIsValid(tp))
1665 {
1666 Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1667 Oid result;
1668
1669 result = functup->pronamespace;
1670 ReleaseSysCache(tp);
1671 return result;
1672 }
1673 else
1674 return InvalidOid;
1675}

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

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

◆ get_func_nargs()

int get_func_nargs ( Oid  funcid)

Definition at line 1701 of file lsyscache.c.

1702{
1703 HeapTuple tp;
1704 int result;
1705
1706 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1707 if (!HeapTupleIsValid(tp))
1708 elog(ERROR, "cache lookup failed for function %u", funcid);
1709
1710 result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1711 ReleaseSysCache(tp);
1712 return result;
1713}
int16 pronargs
Definition: pg_proc.h:81

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

◆ get_func_prokind()

char get_func_prokind ( Oid  funcid)

Definition at line 1845 of file lsyscache.c.

1846{
1847 HeapTuple tp;
1848 char result;
1849
1850 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1851 if (!HeapTupleIsValid(tp))
1852 elog(ERROR, "cache lookup failed for function %u", funcid);
1853
1854 result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
1855 ReleaseSysCache(tp);
1856 return result;
1857}

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

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

◆ get_func_retset()

bool get_func_retset ( Oid  funcid)

Definition at line 1769 of file lsyscache.c.

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

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

Referenced by make_op(), and make_scalar_array_op().

◆ get_func_rettype()

◆ get_func_signature()

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

Definition at line 1723 of file lsyscache.c.

1724{
1725 HeapTuple tp;
1726 Form_pg_proc procstruct;
1727 Oid result;
1728
1729 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1730 if (!HeapTupleIsValid(tp))
1731 elog(ERROR, "cache lookup failed for function %u", funcid);
1732
1733 procstruct = (Form_pg_proc) GETSTRUCT(tp);
1734
1735 result = procstruct->prorettype;
1736 *nargs = (int) procstruct->pronargs;
1737 Assert(*nargs == procstruct->proargtypes.dim1);
1738 *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1739 memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1740
1741 ReleaseSysCache(tp);
1742 return result;
1743}
#define Assert(condition)
Definition: c.h:815
void * palloc(Size size)
Definition: mcxt.c:1317

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

Referenced by plperl_call_perl_func(), resolve_aggregate_transtype(), and typeDepNeeded().

◆ get_func_support()

RegProcedure get_func_support ( Oid  funcid)

Definition at line 1885 of file lsyscache.c.

1886{
1887 HeapTuple tp;
1888
1889 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1890 if (HeapTupleIsValid(tp))
1891 {
1892 Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1893 RegProcedure result;
1894
1895 result = functup->prosupport;
1896 ReleaseSysCache(tp);
1897 return result;
1898 }
1899 else
1900 return (RegProcedure) InvalidOid;
1901}
regproc RegProcedure
Definition: c.h:607

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

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

◆ get_func_variadictype()

Oid get_func_variadictype ( Oid  funcid)

Definition at line 1750 of file lsyscache.c.

1751{
1752 HeapTuple tp;
1753 Oid result;
1754
1755 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1756 if (!HeapTupleIsValid(tp))
1757 elog(ERROR, "cache lookup failed for function %u", funcid);
1758
1759 result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
1760 ReleaseSysCache(tp);
1761 return result;
1762}

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

Referenced by assign_hypothetical_collations(), and assign_ordered_set_collations().

◆ get_index_column_opclass()

Oid get_index_column_opclass ( Oid  index_oid,
int  attno 
)

Definition at line 3539 of file lsyscache.c.

3540{
3541 HeapTuple tuple;
3542 Form_pg_index rd_index;
3543 Datum datum;
3544 oidvector *indclass;
3545 Oid opclass;
3546
3547 /* First we need to know the column's opclass. */
3548
3549 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3550 if (!HeapTupleIsValid(tuple))
3551 return InvalidOid;
3552
3553 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3554
3555 /* caller is supposed to guarantee this */
3556 Assert(attno > 0 && attno <= rd_index->indnatts);
3557
3558 /* Non-key attributes don't have an opclass */
3559 if (attno > rd_index->indnkeyatts)
3560 {
3561 ReleaseSysCache(tuple);
3562 return InvalidOid;
3563 }
3564
3565 datum = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
3566 indclass = ((oidvector *) DatumGetPointer(datum));
3567
3568 Assert(attno <= indclass->dim1);
3569 opclass = indclass->values[attno - 1];
3570
3571 ReleaseSysCache(tuple);
3572
3573 return opclass;
3574}
FormData_pg_index * Form_pg_index
Definition: pg_index.h:70
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:317
Definition: c.h:683
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition: c.h:690

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

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

◆ get_index_isclustered()

bool get_index_isclustered ( Oid  index_oid)

Definition at line 3628 of file lsyscache.c.

3629{
3630 bool isclustered;
3631 HeapTuple tuple;
3632 Form_pg_index rd_index;
3633
3634 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3635 if (!HeapTupleIsValid(tuple))
3636 elog(ERROR, "cache lookup failed for index %u", index_oid);
3637
3638 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3639 isclustered = rd_index->indisclustered;
3640 ReleaseSysCache(tuple);
3641
3642 return isclustered;
3643}

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

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

◆ get_index_isreplident()

bool get_index_isreplident ( Oid  index_oid)

Definition at line 3582 of file lsyscache.c.

3583{
3584 HeapTuple tuple;
3585 Form_pg_index rd_index;
3586 bool result;
3587
3588 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3589 if (!HeapTupleIsValid(tuple))
3590 return false;
3591
3592 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3593 result = rd_index->indisreplident;
3594 ReleaseSysCache(tuple);
3595
3596 return result;
3597}

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

Referenced by RememberReplicaIdentityForRebuilding().

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3605 of file lsyscache.c.

3606{
3607 bool isvalid;
3608 HeapTuple tuple;
3609 Form_pg_index rd_index;
3610
3611 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3612 if (!HeapTupleIsValid(tuple))
3613 elog(ERROR, "cache lookup failed for index %u", index_oid);
3614
3615 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3616 isvalid = rd_index->indisvalid;
3617 ReleaseSysCache(tuple);
3618
3619 return isvalid;
3620}

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

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

◆ get_language_name()

char * get_language_name ( Oid  langoid,
bool  missing_ok 
)

Definition at line 1162 of file lsyscache.c.

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

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

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

◆ get_mergejoin_opfamilies()

List * get_mergejoin_opfamilies ( Oid  opno)

Definition at line 367 of file lsyscache.c.

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

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

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

◆ get_multirange_range()

Oid get_multirange_range ( Oid  multirangeOid)

Definition at line 3510 of file lsyscache.c.

3511{
3512 HeapTuple tp;
3513
3514 tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
3515 if (HeapTupleIsValid(tp))
3516 {
3517 Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3518 Oid result;
3519
3520 result = rngtup->rngtypid;
3521 ReleaseSysCache(tp);
3522 return result;
3523 }
3524 else
3525 return InvalidOid;
3526}
FormData_pg_range * Form_pg_range
Definition: pg_range.h:58

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

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

◆ get_namespace_name()

char * get_namespace_name ( Oid  nspid)

Definition at line 3393 of file lsyscache.c.

3394{
3395 HeapTuple tp;
3396
3397 tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid));
3398 if (HeapTupleIsValid(tp))
3399 {
3401 char *result;
3402
3403 result = pstrdup(NameStr(nsptup->nspname));
3404 ReleaseSysCache(tp);
3405 return result;
3406 }
3407 else
3408 return NULL;
3409}
int nspid
FormData_pg_namespace * Form_pg_namespace
Definition: pg_namespace.h:52

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

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

◆ get_namespace_name_or_temp()

◆ get_negator()

Oid get_negator ( Oid  opno)

Definition at line 1560 of file lsyscache.c.

1561{
1562 HeapTuple tp;
1563
1564 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1565 if (HeapTupleIsValid(tp))
1566 {
1568 Oid result;
1569
1570 result = optup->oprnegate;
1571 ReleaseSysCache(tp);
1572 return result;
1573 }
1574 else
1575 return InvalidOid;
1576}

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

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

◆ get_op_btree_interpretation()

List * get_op_btree_interpretation ( Oid  opno)

Definition at line 602 of file lsyscache.c.

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

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

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

◆ get_op_hash_functions()

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

Definition at line 511 of file lsyscache.c.

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

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

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

◆ get_op_opfamily_properties()

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

Definition at line 137 of file lsyscache.c.

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

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

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

◆ get_op_opfamily_sortfamily()

Oid get_op_opfamily_sortfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 109 of file lsyscache.c.

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

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

Referenced by match_clause_to_ordering_op().

◆ get_op_opfamily_strategy()

int get_op_opfamily_strategy ( Oid  opno,
Oid  opfamily 
)

Definition at line 84 of file lsyscache.c.

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

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

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

◆ get_op_rettype()

Oid get_op_rettype ( Oid  opno)

Definition at line 1360 of file lsyscache.c.

1361{
1362 HeapTuple tp;
1363
1364 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1365 if (HeapTupleIsValid(tp))
1366 {
1368 Oid result;
1369
1370 result = optup->oprresult;
1371 ReleaseSysCache(tp);
1372 return result;
1373 }
1374 else
1375 return InvalidOid;
1376}

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

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

◆ get_opclass_family()

Oid get_opclass_family ( Oid  opclass)

Definition at line 1191 of file lsyscache.c.

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

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

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

◆ get_opclass_input_type()

Oid get_opclass_input_type ( Oid  opclass)

Definition at line 1213 of file lsyscache.c.

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

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

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

◆ get_opclass_method()

Oid get_opclass_method ( Oid  opclass)

Definition at line 1261 of file lsyscache.c.

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

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

Referenced by GetOperatorFromCompareType().

◆ get_opclass_opfamily_and_input_type()

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

Definition at line 1236 of file lsyscache.c.

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

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

Referenced by DefineIndex(), FindFKPeriodOpers(), GetOperatorFromCompareType(), gistproperty(), IsIndexUsableForReplicaIdentityFull(), and spgproperty().

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1312 of file lsyscache.c.

1313{
1314 HeapTuple tp;
1315
1316 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1317 if (HeapTupleIsValid(tp))
1318 {
1320 RegProcedure result;
1321
1322 result = optup->oprcode;
1323 ReleaseSysCache(tp);
1324 return result;
1325 }
1326 else
1327 return (RegProcedure) InvalidOid;
1328}

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

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

◆ get_opfamily_member()

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

◆ get_opfamily_name()

char * get_opfamily_name ( Oid  opfid,
bool  missing_ok 
)

Definition at line 1280 of file lsyscache.c.

1281{
1282 HeapTuple tup;
1283 char *opfname;
1284 Form_pg_opfamily opfform;
1285
1286 tup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfid));
1287
1288 if (!HeapTupleIsValid(tup))
1289 {
1290 if (!missing_ok)
1291 elog(ERROR, "cache lookup failed for operator family %u", opfid);
1292 return NULL;
1293 }
1294
1295 opfform = (Form_pg_opfamily) GETSTRUCT(tup);
1296 opfname = pstrdup(NameStr(opfform->opfname));
1297
1298 ReleaseSysCache(tup);
1299
1300 return opfname;
1301}
FormData_pg_opfamily * Form_pg_opfamily
Definition: pg_opfamily.h:51

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

Referenced by ATAddForeignKeyConstraint(), blvalidate(), brinvalidate(), btvalidate(), ComputeIndexAttrs(), GetOperatorFromCompareType(), ginvalidate(), gistvalidate(), hashvalidate(), and spgvalidate().

◆ get_opfamily_proc()

◆ get_opname()

char * get_opname ( Oid  opno)

Definition at line 1337 of file lsyscache.c.

1338{
1339 HeapTuple tp;
1340
1341 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1342 if (HeapTupleIsValid(tp))
1343 {
1345 char *result;
1346
1347 result = pstrdup(NameStr(optup->oprname));
1348 ReleaseSysCache(tp);
1349 return result;
1350 }
1351 else
1352 return NULL;
1353}

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

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

◆ get_oprjoin()

RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1608 of file lsyscache.c.

1609{
1610 HeapTuple tp;
1611
1612 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1613 if (HeapTupleIsValid(tp))
1614 {
1616 RegProcedure result;
1617
1618 result = optup->oprjoin;
1619 ReleaseSysCache(tp);
1620 return result;
1621 }
1622 else
1623 return (RegProcedure) InvalidOid;
1624}

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

Referenced by join_selectivity(), and scalararraysel().

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1584 of file lsyscache.c.

1585{
1586 HeapTuple tp;
1587
1588 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1589 if (HeapTupleIsValid(tp))
1590 {
1592 RegProcedure result;
1593
1594 result = optup->oprrest;
1595 ReleaseSysCache(tp);
1596 return result;
1597 }
1598 else
1599 return (RegProcedure) InvalidOid;
1600}

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

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

◆ get_ordering_op_for_equality_op()

Oid get_ordering_op_for_equality_op ( Oid  opno,
bool  use_lhs_type 
)

Definition at line 306 of file lsyscache.c.

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

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

Referenced by create_unique_plan().

◆ get_ordering_op_properties()

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

Definition at line 208 of file lsyscache.c.

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

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

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

◆ get_promoted_array_type()

Oid get_promoted_array_type ( Oid  typid)

Definition at line 2838 of file lsyscache.c.

2839{
2840 Oid array_type = get_array_type(typid);
2841
2842 if (OidIsValid(array_type))
2843 return array_type;
2844 if (OidIsValid(get_element_type(typid)))
2845 return typid;
2846 return InvalidOid;
2847}
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2786
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2814

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

Referenced by build_subplan(), and exprType().

◆ get_publication_name()

char * get_publication_name ( Oid  pubid,
bool  missing_ok 
)

Definition at line 3672 of file lsyscache.c.

3673{
3674 HeapTuple tup;
3675 char *pubname;
3676 Form_pg_publication pubform;
3677
3678 tup = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pubid));
3679
3680 if (!HeapTupleIsValid(tup))
3681 {
3682 if (!missing_ok)
3683 elog(ERROR, "cache lookup failed for publication %u", pubid);
3684 return NULL;
3685 }
3686
3687 pubform = (Form_pg_publication) GETSTRUCT(tup);
3688 pubname = pstrdup(NameStr(pubform->pubname));
3689
3690 ReleaseSysCache(tup);
3691
3692 return pubname;
3693}
FormData_pg_publication * Form_pg_publication

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

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

◆ get_publication_oid()

Oid get_publication_oid ( const char *  pubname,
bool  missing_ok 
)

Definition at line 3652 of file lsyscache.c.

3653{
3654 Oid oid;
3655
3656 oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
3657 CStringGetDatum(pubname));
3658 if (!OidIsValid(oid) && !missing_ok)
3659 ereport(ERROR,
3660 (errcode(ERRCODE_UNDEFINED_OBJECT),
3661 errmsg("publication \"%s\" does not exist", pubname)));
3662 return oid;
3663}
static Datum CStringGetDatum(const char *X)
Definition: postgres.h:355
#define GetSysCacheOid1(cacheId, oidcol, key1)
Definition: syscache.h:109

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

Referenced by get_object_address_unqualified(), and GetPublicationByName().

◆ get_range_collation()

Oid get_range_collation ( Oid  rangeOid)

Definition at line 3460 of file lsyscache.c.

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

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

Referenced by CheckAttributeType().

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

Definition at line 3485 of file lsyscache.c.

3486{
3487 HeapTuple tp;
3488
3489 tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3490 if (HeapTupleIsValid(tp))
3491 {
3492 Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3493 Oid result;
3494
3495 result = rngtup->rngmultitypid;
3496 ReleaseSysCache(tp);
3497 return result;
3498 }
3499 else
3500 return InvalidOid;
3501}

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

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

◆ get_range_subtype()

Oid get_range_subtype ( Oid  rangeOid)

Definition at line 3434 of file lsyscache.c.

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

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

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

◆ get_rel_name()

char * get_rel_name ( Oid  relid)

Definition at line 1955 of file lsyscache.c.

1956{
1957 HeapTuple tp;
1958
1959 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1960 if (HeapTupleIsValid(tp))
1961 {
1962 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1963 char *result;
1964
1965 result = pstrdup(NameStr(reltup->relname));
1966 ReleaseSysCache(tp);
1967 return result;
1968 }
1969 else
1970 return NULL;
1971}
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153

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

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

◆ get_rel_namespace()

◆ get_rel_persistence()

char get_rel_persistence ( Oid  relid)

Definition at line 2105 of file lsyscache.c.

2106{
2107 HeapTuple tp;
2108 Form_pg_class reltup;
2109 char result;
2110
2111 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2112 if (!HeapTupleIsValid(tp))
2113 elog(ERROR, "cache lookup failed for relation %u", relid);
2114 reltup = (Form_pg_class) GETSTRUCT(tp);
2115 result = reltup->relpersistence;
2116 ReleaseSysCache(tp);
2117
2118 return result;
2119}

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

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

◆ get_rel_relam()

Oid get_rel_relam ( Oid  relid)

Definition at line 2127 of file lsyscache.c.

2128{
2129 HeapTuple tp;
2130 Form_pg_class reltup;
2131 Oid result;
2132
2133 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2134 if (!HeapTupleIsValid(tp))
2135 elog(ERROR, "cache lookup failed for relation %u", relid);
2136 reltup = (Form_pg_class) GETSTRUCT(tp);
2137 result = reltup->relam;
2138 ReleaseSysCache(tp);
2139
2140 return result;
2141}

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

Referenced by DefineRelation().

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

Definition at line 2054 of file lsyscache.c.

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

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

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

◆ get_rel_relkind()

char get_rel_relkind ( Oid  relid)

Definition at line 2030 of file lsyscache.c.

2031{
2032 HeapTuple tp;
2033
2034 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2035 if (HeapTupleIsValid(tp))
2036 {
2037 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2038 char result;
2039
2040 result = reltup->relkind;
2041 ReleaseSysCache(tp);
2042 return result;
2043 }
2044 else
2045 return '\0';
2046}

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

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

◆ get_rel_tablespace()

Oid get_rel_tablespace ( Oid  relid)

Definition at line 2081 of file lsyscache.c.

2082{
2083 HeapTuple tp;
2084
2085 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2086 if (HeapTupleIsValid(tp))
2087 {
2088 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2089 Oid result;
2090
2091 result = reltup->reltablespace;
2092 ReleaseSysCache(tp);
2093 return result;
2094 }
2095 else
2096 return InvalidOid;
2097}

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

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

◆ get_rel_type_id()

Oid get_rel_type_id ( Oid  relid)

Definition at line 2006 of file lsyscache.c.

2007{
2008 HeapTuple tp;
2009
2010 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2011 if (HeapTupleIsValid(tp))
2012 {
2013 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2014 Oid result;
2015
2016 result = reltup->reltype;
2017 ReleaseSysCache(tp);
2018 return result;
2019 }
2020 else
2021 return InvalidOid;
2022}

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

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

◆ get_relname_relid()

◆ get_subscription_name()

char * get_subscription_name ( Oid  subid,
bool  missing_ok 
)

Definition at line 3722 of file lsyscache.c.

3723{
3724 HeapTuple tup;
3725 char *subname;
3726 Form_pg_subscription subform;
3727
3728 tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
3729
3730 if (!HeapTupleIsValid(tup))
3731 {
3732 if (!missing_ok)
3733 elog(ERROR, "cache lookup failed for subscription %u", subid);
3734 return NULL;
3735 }
3736
3737 subform = (Form_pg_subscription) GETSTRUCT(tup);
3738 subname = pstrdup(NameStr(subform->subname));
3739
3740 ReleaseSysCache(tup);
3741
3742 return subname;
3743}
NameData subname
FormData_pg_subscription * Form_pg_subscription

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

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

◆ get_subscription_oid()

Oid get_subscription_oid ( const char *  subname,
bool  missing_ok 
)

Definition at line 3702 of file lsyscache.c.

3703{
3704 Oid oid;
3705
3706 oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
3708 if (!OidIsValid(oid) && !missing_ok)
3709 ereport(ERROR,
3710 (errcode(ERRCODE_UNDEFINED_OBJECT),
3711 errmsg("subscription \"%s\" does not exist", subname)));
3712 return oid;
3713}
Oid MyDatabaseId
Definition: globals.c:93

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

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

◆ get_transform_fromsql()

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

Definition at line 2147 of file lsyscache.c.

2148{
2149 HeapTuple tup;
2150
2151 if (!list_member_oid(trftypes, typid))
2152 return InvalidOid;
2153
2154 tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
2155 ObjectIdGetDatum(langid));
2156 if (HeapTupleIsValid(tup))
2157 {
2158 Oid funcid;
2159
2160 funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2161 ReleaseSysCache(tup);
2162 return funcid;
2163 }
2164 else
2165 return InvalidOid;
2166}
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:722
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:43

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

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

◆ get_transform_tosql()

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

Definition at line 2169 of file lsyscache.c.

2170{
2171 HeapTuple tup;
2172
2173 if (!list_member_oid(trftypes, typid))
2174 return InvalidOid;
2175
2176 tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
2177 ObjectIdGetDatum(langid));
2178 if (HeapTupleIsValid(tup))
2179 {
2180 Oid funcid;
2181
2182 funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
2183 ReleaseSysCache(tup);
2184 return funcid;
2185 }
2186 else
2187 return InvalidOid;
2188}

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

Referenced by plperl_sv_to_datum(), and PLy_output_setup_func().

◆ get_typ_typrelid()

Oid get_typ_typrelid ( Oid  typid)

Definition at line 2758 of file lsyscache.c.

2759{
2760 HeapTuple tp;
2761
2762 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2763 if (HeapTupleIsValid(tp))
2764 {
2765 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2766 Oid result;
2767
2768 result = typtup->typrelid;
2769 ReleaseSysCache(tp);
2770 return result;
2771 }
2772 else
2773 return InvalidOid;
2774}

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

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

◆ get_typavgwidth()

int32 get_typavgwidth ( Oid  typid,
int32  typmod 
)

Definition at line 2605 of file lsyscache.c.

2606{
2607 int typlen = get_typlen(typid);
2608 int32 maxwidth;
2609
2610 /*
2611 * Easy if it's a fixed-width type
2612 */
2613 if (typlen > 0)
2614 return typlen;
2615
2616 /*
2617 * type_maximum_size knows the encoding of typmod for some datatypes;
2618 * don't duplicate that knowledge here.
2619 */
2620 maxwidth = type_maximum_size(typid, typmod);
2621 if (maxwidth > 0)
2622 {
2623 /*
2624 * For BPCHAR, the max width is also the only width. Otherwise we
2625 * need to guess about the typical data width given the max. A sliding
2626 * scale for percentage of max width seems reasonable.
2627 */
2628 if (typid == BPCHAROID)
2629 return maxwidth;
2630 if (maxwidth <= 32)
2631 return maxwidth; /* assume full width */
2632 if (maxwidth < 1000)
2633 return 32 + (maxwidth - 32) / 2; /* assume 50% */
2634
2635 /*
2636 * Beyond 1000, assume we're looking at something like
2637 * "varchar(10000)" where the limit isn't actually reached often, and
2638 * use a fixed estimate.
2639 */
2640 return 32 + (1000 - 32) / 2;
2641 }
2642
2643 /*
2644 * Oops, we have no idea ... wild guess time.
2645 */
2646 return 32;
2647}
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:412
int16 get_typlen(Oid typid)
Definition: lsyscache.c:2224

References get_typlen(), and type_maximum_size().

Referenced by add_row_identity_var(), create_one_window_path(), find_placeholder_info(), get_agg_clause_costs(), get_expr_width(), get_rel_data_width(), set_append_rel_size(), and set_rel_width().

◆ get_typbyval()

bool get_typbyval ( Oid  typid)

Definition at line 2249 of file lsyscache.c.

2250{
2251 HeapTuple tp;
2252
2253 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2254 if (HeapTupleIsValid(tp))
2255 {
2256 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2257 bool result;
2258
2259 result = typtup->typbyval;
2260 ReleaseSysCache(tp);
2261 return result;
2262 }
2263 else
2264 return false;
2265}

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

Referenced by brin_range_deserialize(), and brin_range_serialize().

◆ get_typcollation()

◆ get_typdefault()

Node * get_typdefault ( Oid  typid)

Definition at line 2475 of file lsyscache.c.

2476{
2477 HeapTuple typeTuple;
2479 Datum datum;
2480 bool isNull;
2481 Node *expr;
2482
2483 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2484 if (!HeapTupleIsValid(typeTuple))
2485 elog(ERROR, "cache lookup failed for type %u", typid);
2486 type = (Form_pg_type) GETSTRUCT(typeTuple);
2487
2488 /*
2489 * typdefault and typdefaultbin are potentially null, so don't try to
2490 * access 'em as struct fields. Must do it the hard way with
2491 * SysCacheGetAttr.
2492 */
2493 datum = SysCacheGetAttr(TYPEOID,
2494 typeTuple,
2495 Anum_pg_type_typdefaultbin,
2496 &isNull);
2497
2498 if (!isNull)
2499 {
2500 /* We have an expression default */
2501 expr = stringToNode(TextDatumGetCString(datum));
2502 }
2503 else
2504 {
2505 /* Perhaps we have a plain literal default */
2506 datum = SysCacheGetAttr(TYPEOID,
2507 typeTuple,
2508 Anum_pg_type_typdefault,
2509 &isNull);
2510
2511 if (!isNull)
2512 {
2513 char *strDefaultVal;
2514
2515 /* Convert text datum to C string */
2516 strDefaultVal = TextDatumGetCString(datum);
2517 /* Convert C string to a value of the given type */
2518 datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2519 getTypeIOParam(typeTuple), -1);
2520 /* Build a Const node containing the value */
2521 expr = (Node *) makeConst(typid,
2522 -1,
2523 type->typcollation,
2524 type->typlen,
2525 datum,
2526 false,
2527 type->typbyval);
2528 pfree(strDefaultVal);
2529 }
2530 else
2531 {
2532 /* No default */
2533 expr = NULL;
2534 }
2535 }
2536
2537 ReleaseSysCache(typeTuple);
2538
2539 return expr;
2540}
#define TextDatumGetCString(d)
Definition: builtins.h:98
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1754
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2330
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:303
void * stringToNode(const char *str)
Definition: read.c:90
Definition: nodes.h:129
const char * type

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

Referenced by build_column_default().

◆ get_type_category_preferred()

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

Definition at line 2737 of file lsyscache.c.

2738{
2739 HeapTuple tp;
2740 Form_pg_type typtup;
2741
2742 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2743 if (!HeapTupleIsValid(tp))
2744 elog(ERROR, "cache lookup failed for type %u", typid);
2745 typtup = (Form_pg_type) GETSTRUCT(tp);
2746 *typcategory = typtup->typcategory;
2747 *typispreferred = typtup->typispreferred;
2748 ReleaseSysCache(tp);
2749}

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

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

◆ get_type_io_data()

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

Definition at line 2352 of file lsyscache.c.

2360{
2361 HeapTuple typeTuple;
2362 Form_pg_type typeStruct;
2363
2364 /*
2365 * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2366 * use array_in and array_out during bootstrap.
2367 */
2369 {
2370 Oid typinput;
2371 Oid typoutput;
2372
2374 typlen,
2375 typbyval,
2376 typalign,
2377 typdelim,
2378 typioparam,
2379 &typinput,
2380 &typoutput);
2381 switch (which_func)
2382 {
2383 case IOFunc_input:
2384 *func = typinput;
2385 break;
2386 case IOFunc_output:
2387 *func = typoutput;
2388 break;
2389 default:
2390 elog(ERROR, "binary I/O not supported during bootstrap");
2391 break;
2392 }
2393 return;
2394 }
2395
2396 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2397 if (!HeapTupleIsValid(typeTuple))
2398 elog(ERROR, "cache lookup failed for type %u", typid);
2399 typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2400
2401 *typlen = typeStruct->typlen;
2402 *typbyval = typeStruct->typbyval;
2403 *typalign = typeStruct->typalign;
2404 *typdelim = typeStruct->typdelim;
2405 *typioparam = getTypeIOParam(typeTuple);
2406 switch (which_func)
2407 {
2408 case IOFunc_input:
2409 *func = typeStruct->typinput;
2410 break;
2411 case IOFunc_output:
2412 *func = typeStruct->typoutput;
2413 break;
2414 case IOFunc_receive:
2415 *func = typeStruct->typreceive;
2416 break;
2417 case IOFunc_send:
2418 *func = typeStruct->typsend;
2419 break;
2420 }
2421 ReleaseSysCache(typeTuple);
2422}
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:837
@ IOFunc_output
Definition: lsyscache.h:36
@ IOFunc_input
Definition: lsyscache.h:35
@ IOFunc_send
Definition: lsyscache.h:38
@ IOFunc_receive
Definition: lsyscache.h:37
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:466
char typalign
Definition: pg_type.h:176

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

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

◆ get_typisdefined()

bool get_typisdefined ( Oid  typid)

Definition at line 2200 of file lsyscache.c.

2201{
2202 HeapTuple tp;
2203
2204 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2205 if (HeapTupleIsValid(tp))
2206 {
2207 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2208 bool result;
2209
2210 result = typtup->typisdefined;
2211 ReleaseSysCache(tp);
2212 return result;
2213 }
2214 else
2215 return false;
2216}

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

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

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2224 of file lsyscache.c.

2225{
2226 HeapTuple tp;
2227
2228 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2229 if (HeapTupleIsValid(tp))
2230 {
2231 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2232 int16 result;
2233
2234 result = typtup->typlen;
2235 ReleaseSysCache(tp);
2236 return result;
2237 }
2238 else
2239 return 0;
2240}

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

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

◆ get_typlenbyval()

◆ get_typlenbyvalalign()

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 3033 of file lsyscache.c.

3034{
3035 HeapTuple tp;
3036
3037 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
3038 if (HeapTupleIsValid(tp))
3039 {
3040 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
3041 Oid result;
3042
3043 result = typtup->typmodin;
3044 ReleaseSysCache(tp);
3045 return result;
3046 }
3047 else
3048 return InvalidOid;
3049}

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2446 of file lsyscache.c.

2447{
2448 HeapTuple tp;
2449
2450 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2451 if (HeapTupleIsValid(tp))
2452 {
2453 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2454 char result;
2455
2456 result = typtup->typstorage;
2457 ReleaseSysCache(tp);
2458 return result;
2459 }
2460 else
2461 return TYPSTORAGE_PLAIN;
2462}

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

Referenced by GetAttributeStorage().

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3124 of file lsyscache.c.

3125{
3126 HeapTuple tp;
3127
3128 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
3129 if (HeapTupleIsValid(tp))
3130 {
3131 Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
3132 RegProcedure handler = typform->typsubscript;
3133
3134 if (typelemp)
3135 *typelemp = typform->typelem;
3136 ReleaseSysCache(tp);
3137 return handler;
3138 }
3139 else
3140 {
3141 if (typelemp)
3142 *typelemp = InvalidOid;
3143 return InvalidOid;
3144 }
3145}

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

Referenced by exec_check_rw_parameter(), and getSubscriptingRoutines().

◆ get_typtype()

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2565 of file lsyscache.c.

2566{
2567 /*
2568 * We loop to find the bottom base type in a stack of domains.
2569 */
2570 for (;;)
2571 {
2572 HeapTuple tup;
2573 Form_pg_type typTup;
2574
2575 tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2576 if (!HeapTupleIsValid(tup))
2577 elog(ERROR, "cache lookup failed for type %u", typid);
2578 typTup = (Form_pg_type) GETSTRUCT(tup);
2579 if (typTup->typtype != TYPTYPE_DOMAIN)
2580 {
2581 /* Not a domain, so done */
2582 ReleaseSysCache(tup);
2583 break;
2584 }
2585
2586 Assert(*typmod == -1);
2587 typid = typTup->typbasetype;
2588 *typmod = typTup->typtypmod;
2589
2590 ReleaseSysCache(tup);
2591 }
2592
2593 return typid;
2594}

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

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

◆ getSubscriptingRoutines()

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

Definition at line 3157 of file lsyscache.c.

3158{
3159 RegProcedure typsubscript = get_typsubscript(typid, typelemp);
3160
3161 if (!OidIsValid(typsubscript))
3162 return NULL;
3163
3164 return (const struct SubscriptRoutines *)
3165 DatumGetPointer(OidFunctionCall0(typsubscript));
3166}
#define OidFunctionCall0(functionId)
Definition: fmgr.h:677
RegProcedure get_typsubscript(Oid typid, Oid *typelemp)
Definition: lsyscache.c:3124

References DatumGetPointer(), get_typsubscript(), OidFunctionCall0, and OidIsValid.

Referenced by contain_leaked_vars_walker(), contain_nonstrict_functions_walker(), ExecInitSubscriptingRef(), and transformContainerSubscripts().

◆ getTypeBinaryInputInfo()

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

Definition at line 2967 of file lsyscache.c.

2968{
2969 HeapTuple typeTuple;
2970 Form_pg_type pt;
2971
2972 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
2973 if (!HeapTupleIsValid(typeTuple))
2974 elog(ERROR, "cache lookup failed for type %u", type);
2975 pt = (Form_pg_type) GETSTRUCT(typeTuple);
2976
2977 if (!pt->typisdefined)
2978 ereport(ERROR,
2979 (errcode(ERRCODE_UNDEFINED_OBJECT),
2980 errmsg("type %s is only a shell",
2981 format_type_be(type))));
2982 if (!OidIsValid(pt->typreceive))
2983 ereport(ERROR,
2984 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2985 errmsg("no binary input function available for type %s",
2986 format_type_be(type))));
2987
2988 *typReceive = pt->typreceive;
2989 *typIOParam = getTypeIOParam(typeTuple);
2990
2991 ReleaseSysCache(typeTuple);
2992}

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

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

◆ getTypeBinaryOutputInfo()

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

Definition at line 3000 of file lsyscache.c.

3001{
3002 HeapTuple typeTuple;
3003 Form_pg_type pt;
3004
3005 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
3006 if (!HeapTupleIsValid(typeTuple))
3007 elog(ERROR, "cache lookup failed for type %u", type);
3008 pt = (Form_pg_type) GETSTRUCT(typeTuple);
3009
3010 if (!pt->typisdefined)
3011 ereport(ERROR,
3012 (errcode(ERRCODE_UNDEFINED_OBJECT),
3013 errmsg("type %s is only a shell",
3014 format_type_be(type))));
3015 if (!OidIsValid(pt->typsend))
3016 ereport(ERROR,
3017 (errcode(ERRCODE_UNDEFINED_FUNCTION),
3018 errmsg("no binary output function available for type %s",
3019 format_type_be(type))));
3020
3021 *typSend = pt->typsend;
3022 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
3023
3024 ReleaseSysCache(typeTuple);
3025}

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

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

◆ getTypeInputInfo()

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

Definition at line 2901 of file lsyscache.c.

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

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

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

◆ getTypeIOParam()

Oid getTypeIOParam ( HeapTuple  typeTuple)

Definition at line 2330 of file lsyscache.c.

2331{
2332 Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2333
2334 /*
2335 * Array types get their typelem as parameter; everybody else gets their
2336 * own type OID as parameter.
2337 */
2338 if (OidIsValid(typeStruct->typelem))
2339 return typeStruct->typelem;
2340 else
2341 return typeStruct->oid;
2342}

References GETSTRUCT(), and OidIsValid.

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

◆ getTypeOutputInfo()

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

Definition at line 2934 of file lsyscache.c.

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

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

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

◆ op_hashjoinable()

bool op_hashjoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1464 of file lsyscache.c.

1465{
1466 bool result = false;
1467 HeapTuple tp;
1468 TypeCacheEntry *typentry;
1469
1470 /* As in op_mergejoinable, let the typcache handle the hard cases */
1471 if (opno == ARRAY_EQ_OP)
1472 {
1473 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1474 if (typentry->hash_proc == F_HASH_ARRAY)
1475 result = true;
1476 }
1477 else if (opno == RECORD_EQ_OP)
1478 {
1479 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1480 if (typentry->hash_proc == F_HASH_RECORD)
1481 result = true;
1482 }
1483 else
1484 {
1485 /* For all other operators, rely on pg_operator.oprcanhash */
1486 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1487 if (HeapTupleIsValid(tp))
1488 {
1490
1491 result = optup->oprcanhash;
1492 ReleaseSysCache(tp);
1493 }
1494 }
1495 return result;
1496}
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:386
#define TYPECACHE_HASH_PROC
Definition: typcache.h:141

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

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

◆ op_in_opfamily()

◆ op_input_types()

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

Definition at line 1385 of file lsyscache.c.

1386{
1387 HeapTuple tp;
1388 Form_pg_operator optup;
1389
1390 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1391 if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1392 elog(ERROR, "cache lookup failed for operator %u", opno);
1393 optup = (Form_pg_operator) GETSTRUCT(tp);
1394 *lefttype = optup->oprleft;
1395 *righttype = optup->oprright;
1396 ReleaseSysCache(tp);
1397}

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

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

◆ op_mergejoinable()

bool op_mergejoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1413 of file lsyscache.c.

1414{
1415 bool result = false;
1416 HeapTuple tp;
1417 TypeCacheEntry *typentry;
1418
1419 /*
1420 * For array_eq or record_eq, we can sort if the element or field types
1421 * are all sortable. We could implement all the checks for that here, but
1422 * the typcache already does that and caches the results too, so let's
1423 * rely on the typcache.
1424 */
1425 if (opno == ARRAY_EQ_OP)
1426 {
1427 typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1428 if (typentry->cmp_proc == F_BTARRAYCMP)
1429 result = true;
1430 }
1431 else if (opno == RECORD_EQ_OP)
1432 {
1433 typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1434 if (typentry->cmp_proc == F_BTRECORDCMP)
1435 result = true;
1436 }
1437 else
1438 {
1439 /* For all other operators, rely on pg_operator.oprcanmerge */
1440 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1441 if (HeapTupleIsValid(tp))
1442 {
1444
1445 result = optup->oprcanmerge;
1446 ReleaseSysCache(tp);
1447 }
1448 }
1449 return result;
1450}
#define TYPECACHE_CMP_PROC
Definition: typcache.h:140

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

Referenced by check_mergejoinable(), and compute_semijoin_info().

◆ op_strict()

bool op_strict ( Oid  opno)

Definition at line 1504 of file lsyscache.c.

1505{
1506 RegProcedure funcid = get_opcode(opno);
1507
1508 if (funcid == (RegProcedure) InvalidOid)
1509 elog(ERROR, "operator %u does not exist", opno);
1510
1511 return func_strict((Oid) funcid);
1512}
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1312
bool func_strict(Oid funcid)
Definition: lsyscache.c:1788

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

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

◆ op_volatile()

char op_volatile ( Oid  opno)

Definition at line 1520 of file lsyscache.c.

1521{
1522 RegProcedure funcid = get_opcode(opno);
1523
1524 if (funcid == (RegProcedure) InvalidOid)
1525 elog(ERROR, "operator %u does not exist", opno);
1526
1527 return func_volatile((Oid) funcid);
1528}
char func_volatile(Oid funcid)
Definition: lsyscache.c:1807

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

Referenced by lookup_proof_cache(), and match_clause_to_partition_key().

◆ type_is_collatable()

◆ type_is_enum()

bool type_is_enum ( Oid  typid)

Definition at line 2705 of file lsyscache.c.

2706{
2707 return (get_typtype(typid) == TYPTYPE_ENUM);
2708}
char get_typtype(Oid typid)
Definition: lsyscache.c:2656

References get_typtype().

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

◆ type_is_multirange()

bool type_is_multirange ( Oid  typid)

Definition at line 2725 of file lsyscache.c.

2726{
2727 return (get_typtype(typid) == TYPTYPE_MULTIRANGE);
2728}

References get_typtype().

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

◆ type_is_range()

bool type_is_range ( Oid  typid)

Definition at line 2715 of file lsyscache.c.

2716{
2717 return (get_typtype(typid) == TYPTYPE_RANGE);
2718}

References get_typtype().

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

◆ type_is_rowtype()

bool type_is_rowtype ( Oid  typid)

Definition at line 2682 of file lsyscache.c.

2683{
2684 if (typid == RECORDOID)
2685 return true; /* easy case */
2686 switch (get_typtype(typid))
2687 {
2688 case TYPTYPE_COMPOSITE:
2689 return true;
2690 case TYPTYPE_DOMAIN:
2691 if (get_typtype(getBaseType(typid)) == TYPTYPE_COMPOSITE)
2692 return true;
2693 break;
2694 default:
2695 break;
2696 }
2697 return false;
2698}
Oid getBaseType(Oid typid)
Definition: lsyscache.c:2548

References get_typtype(), and getBaseType().

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

Variable Documentation

◆ get_attavgwidth_hook

get_attavgwidth_hook_type get_attavgwidth_hook = NULL

Definition at line 54 of file lsyscache.c.

Referenced by get_attavgwidth().