PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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)
 
Oid get_opfamily_member_for_cmptype (Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
 
static bool get_opmethod_canorder (Oid amoid)
 
bool get_ordering_op_properties (Oid opno, Oid *opfamily, Oid *opcintype, CompareType *cmptype)
 
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_index_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)
 
Oid get_opfamily_method (Oid opfid)
 
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 835 of file lsyscache.c.

836{
837 bool result;
838 CatCList *catlist;
839 int i;
840
841 /* Easy if they're the same operator */
842 if (opno1 == opno2)
843 return true;
844
845 /*
846 * We search through all the pg_amop entries for opno1.
847 */
848 catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
849
850 result = false;
851 for (i = 0; i < catlist->n_members; i++)
852 {
853 HeapTuple op_tuple = &catlist->members[i]->tuple;
854 Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
855
856 /*
857 * op_in_opfamily() is cheaper than GetIndexAmRoutineByAmId(), so
858 * check it first
859 */
860 if (op_in_opfamily(opno2, op_form->amopfamily))
861 {
862 IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
863
864 if (amroutine->amconsistentordering)
865 {
866 result = true;
867 break;
868 }
869 }
870 }
871
872 ReleaseSysCacheList(catlist);
873
874 return result;
875}
IndexAmRoutine * GetIndexAmRoutineByAmId(Oid amoid, bool noerror)
Definition: amapi.c:56
static void * GETSTRUCT(const HeapTupleData *tuple)
Definition: htup_details.h:728
int i
Definition: isn.c:77
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
bool amconsistentordering
Definition: amapi.h:252
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 IndexAmRoutine::amconsistentordering, GetIndexAmRoutineByAmId(), 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 779 of file lsyscache.c.

780{
781 bool result;
782 CatCList *catlist;
783 int i;
784
785 /* Easy if they're the same operator */
786 if (opno1 == opno2)
787 return true;
788
789 /*
790 * We search through all the pg_amop entries for opno1.
791 */
792 catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
793
794 result = false;
795 for (i = 0; i < catlist->n_members; i++)
796 {
797 HeapTuple op_tuple = &catlist->members[i]->tuple;
798 Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
799
800 /*
801 * op_in_opfamily() is cheaper than GetIndexAmRoutineByAmId(), so
802 * check it first
803 */
804 if (op_in_opfamily(opno2, op_form->amopfamily))
805 {
806 IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
807
808 if (amroutine->amconsistentequality)
809 {
810 result = true;
811 break;
812 }
813 }
814 }
815
816 ReleaseSysCacheList(catlist);
817
818 return result;
819}
bool amconsistentequality
Definition: amapi.h:250

References IndexAmRoutine::amconsistentequality, GetIndexAmRoutineByAmId(), 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 3484 of file lsyscache.c.

3485{
3486 /* The values[] array was separately palloc'd by deconstruct_array */
3487 if (sslot->values)
3488 pfree(sslot->values);
3489 /* The numbers[] array points into numbers_arr, do not pfree it */
3490 /* Free the detoasted array objects, if any */
3491 if (sslot->values_arr)
3492 pfree(sslot->values_arr);
3493 if (sslot->numbers_arr)
3494 pfree(sslot->numbers_arr);
3495}
void pfree(void *pointer)
Definition: mcxt.c:1524
Datum * values
Definition: lsyscache.h:54
void * numbers_arr
Definition: lsyscache.h:62
void * values_arr
Definition: lsyscache.h:61

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

Referenced by _int_matchsel(), booltestsel(), brincostestimate(), btcost_correlation(), 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 1939 of file lsyscache.c.

1940{
1941 HeapTuple tp;
1942 char result;
1943
1944 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1945 if (!HeapTupleIsValid(tp))
1946 elog(ERROR, "cache lookup failed for function %u", funcid);
1947
1948 result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1949 ReleaseSysCache(tp);
1950 return result;
1951}
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
#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 1901 of file lsyscache.c.

1902{
1903 HeapTuple tp;
1904 bool result;
1905
1906 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1907 if (!HeapTupleIsValid(tp))
1908 elog(ERROR, "cache lookup failed for function %u", funcid);
1909
1910 result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
1911 ReleaseSysCache(tp);
1912 return result;
1913}

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

3299{
3300 HeapTuple tp;
3301 int32 stawidth;
3302
3304 {
3305 stawidth = (*get_attavgwidth_hook) (relid, attnum);
3306 if (stawidth > 0)
3307 return stawidth;
3308 }
3309 tp = SearchSysCache3(STATRELATTINH,
3310 ObjectIdGetDatum(relid),
3312 BoolGetDatum(false));
3313 if (HeapTupleIsValid(tp))
3314 {
3315 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3316 ReleaseSysCache(tp);
3317 if (stawidth > 0)
3318 return stawidth;
3319 }
3320 return 0;
3321}
int32_t int32
Definition: c.h:498
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 980 of file lsyscache.c.

981{
982 HeapTuple tp;
983 Form_pg_attribute att_tup;
984 char result;
985
986 tp = SearchSysCache2(ATTNUM,
987 ObjectIdGetDatum(relid),
989 if (!HeapTupleIsValid(tp))
990 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
991 attnum, relid);
992 att_tup = (Form_pg_attribute) GETSTRUCT(tp);
993 result = att_tup->attgenerated;
994 ReleaseSysCache(tp);
995 return result;
996}
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:202
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 check_nested_generated_walker(), and CreateStatistics().

◆ get_attname()

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

Definition at line 919 of file lsyscache.c.

920{
921 HeapTuple tp;
922
923 tp = SearchSysCache2(ATTNUM,
925 if (HeapTupleIsValid(tp))
926 {
928 char *result;
929
930 result = pstrdup(NameStr(att_tup->attname));
931 ReleaseSysCache(tp);
932 return result;
933 }
934
935 if (!missing_ok)
936 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
937 attnum, relid);
938 return NULL;
939}
#define NameStr(name)
Definition: c.h:717
char * pstrdup(const char *in)
Definition: mcxt.c:1699

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

Referenced by AddRelationNewConstraints(), AddRelationNotNullConstraints(), ATExecAlterConstrInheritability(), attribute_statistics_update(), 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(), QueueNNConstraintValidation(), RelationGetNotNullConstraints(), RememberAllDependentForRebuilding(), transformPartitionBound(), and transformPartitionRangeBounds().

◆ get_attnum()

◆ get_attoptions()

Datum get_attoptions ( Oid  relid,
int16  attnum 
)

Definition at line 1062 of file lsyscache.c.

1063{
1064 HeapTuple tuple;
1065 Datum attopts;
1066 Datum result;
1067 bool isnull;
1068
1069 tuple = SearchSysCache2(ATTNUM,
1070 ObjectIdGetDatum(relid),
1072
1073 if (!HeapTupleIsValid(tuple))
1074 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1075 attnum, relid);
1076
1077 attopts = SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions,
1078 &isnull);
1079
1080 if (isnull)
1081 result = (Datum) 0;
1082 else
1083 result = datumCopy(attopts, false, -1); /* text[] */
1084
1085 ReleaseSysCache(tuple);
1086
1087 return result;
1088}
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 3374 of file lsyscache.c.

3376{
3377 Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
3378 int i;
3379 Datum val;
3380 ArrayType *statarray;
3381 Oid arrayelemtype;
3382 int narrayelem;
3383 HeapTuple typeTuple;
3384 Form_pg_type typeForm;
3385
3386 /* initialize *sslot properly */
3387 memset(sslot, 0, sizeof(AttStatsSlot));
3388
3389 for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
3390 {
3391 if ((&stats->stakind1)[i] == reqkind &&
3392 (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
3393 break;
3394 }
3395 if (i >= STATISTIC_NUM_SLOTS)
3396 return false; /* not there */
3397
3398 sslot->staop = (&stats->staop1)[i];
3399 sslot->stacoll = (&stats->stacoll1)[i];
3400
3401 if (flags & ATTSTATSSLOT_VALUES)
3402 {
3403 val = SysCacheGetAttrNotNull(STATRELATTINH, statstuple,
3404 Anum_pg_statistic_stavalues1 + i);
3405
3406 /*
3407 * Detoast the array if needed, and in any case make a copy that's
3408 * under control of this AttStatsSlot.
3409 */
3410 statarray = DatumGetArrayTypePCopy(val);
3411
3412 /*
3413 * Extract the actual array element type, and pass it back in case the
3414 * caller needs it.
3415 */
3416 sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3417
3418 /* Need info about element type */
3419 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
3420 if (!HeapTupleIsValid(typeTuple))
3421 elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3422 typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
3423
3424 /* Deconstruct array into Datum elements; NULLs not expected */
3425 deconstruct_array(statarray,
3426 arrayelemtype,
3427 typeForm->typlen,
3428 typeForm->typbyval,
3429 typeForm->typalign,
3430 &sslot->values, NULL, &sslot->nvalues);
3431
3432 /*
3433 * If the element type is pass-by-reference, we now have a bunch of
3434 * Datums that are pointers into the statarray, so we need to keep
3435 * that until free_attstatsslot. Otherwise, all the useful info is in
3436 * sslot->values[], so we can free the array object immediately.
3437 */
3438 if (!typeForm->typbyval)
3439 sslot->values_arr = statarray;
3440 else
3441 pfree(statarray);
3442
3443 ReleaseSysCache(typeTuple);
3444 }
3445
3446 if (flags & ATTSTATSSLOT_NUMBERS)
3447 {
3448 val = SysCacheGetAttrNotNull(STATRELATTINH, statstuple,
3449 Anum_pg_statistic_stanumbers1 + i);
3450
3451 /*
3452 * Detoast the array if needed, and in any case make a copy that's
3453 * under control of this AttStatsSlot.
3454 */
3455 statarray = DatumGetArrayTypePCopy(val);
3456
3457 /*
3458 * We expect the array to be a 1-D float4 array; verify that. We don't
3459 * need to use deconstruct_array() since the array data is just going
3460 * to look like a C array of float4 values.
3461 */
3462 narrayelem = ARR_DIMS(statarray)[0];
3463 if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3464 ARR_HASNULL(statarray) ||
3465 ARR_ELEMTYPE(statarray) != FLOAT4OID)
3466 elog(ERROR, "stanumbers is not a 1-D float4 array");
3467
3468 /* Give caller a pointer directly into the statarray */
3469 sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3470 sslot->nnumbers = narrayelem;
3471
3472 /* We'll free the statarray in free_attstatsslot */
3473 sslot->numbers_arr = statarray;
3474 }
3475
3476 return true;
3477}
#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:600
long val
Definition: informix.c:689
#define ATTSTATSSLOT_NUMBERS
Definition: lsyscache.h:44
#define ATTSTATSSLOT_VALUES
Definition: lsyscache.h:43
#define STATISTIC_NUM_SLOTS
Definition: pg_statistic.h:127
Oid valuetype
Definition: lsyscache.h:53
float4 * numbers
Definition: lsyscache.h:57
int nnumbers
Definition: lsyscache.h:58
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(), btcost_correlation(), 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 1005 of file lsyscache.c.

1006{
1007 HeapTuple tp;
1008
1009 tp = SearchSysCache2(ATTNUM,
1010 ObjectIdGetDatum(relid),
1012 if (HeapTupleIsValid(tp))
1013 {
1015 Oid result;
1016
1017 result = att_tup->atttypid;
1018 ReleaseSysCache(tp);
1019 return result;
1020 }
1021 else
1022 return InvalidOid;
1023}

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

1037{
1038 HeapTuple tp;
1039 Form_pg_attribute att_tup;
1040
1041 tp = SearchSysCache2(ATTNUM,
1042 ObjectIdGetDatum(relid),
1044 if (!HeapTupleIsValid(tp))
1045 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1046 attnum, relid);
1047 att_tup = (Form_pg_attribute) GETSTRUCT(tp);
1048
1049 *typid = att_tup->atttypid;
1050 *typmod = att_tup->atttypmod;
1051 *collid = att_tup->attcollation;
1052 ReleaseSysCache(tp);
1053}
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 2972 of file lsyscache.c.

2973{
2974 /*
2975 * We loop to find the bottom base type in a stack of domains.
2976 */
2977 for (;;)
2978 {
2979 HeapTuple tup;
2980 Form_pg_type typTup;
2981
2982 tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2983 if (!HeapTupleIsValid(tup))
2984 break;
2985 typTup = (Form_pg_type) GETSTRUCT(tup);
2986 if (typTup->typtype != TYPTYPE_DOMAIN)
2987 {
2988 /* Not a domain, so stop descending */
2989 Oid result;
2990
2991 /* This test must match get_element_type */
2992 if (IsTrueArrayType(typTup))
2993 result = typTup->typelem;
2994 else
2995 result = InvalidOid;
2996 ReleaseSysCache(tup);
2997 return result;
2998 }
2999
3000 typid = typTup->typbasetype;
3001 ReleaseSysCache(tup);
3002 }
3003
3004 /* Like get_element_type, silently return InvalidOid for bogus input */
3005 return InvalidOid;
3006}

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

1100{
1101 Oid oid;
1102
1103 oid = GetSysCacheOid2(CASTSOURCETARGET, Anum_pg_cast_oid,
1104 ObjectIdGetDatum(sourcetypeid),
1105 ObjectIdGetDatum(targettypeid));
1106 if (!OidIsValid(oid) && !missing_ok)
1107 ereport(ERROR,
1108 (errcode(ERRCODE_UNDEFINED_OBJECT),
1109 errmsg("cast from type %s to type %s does not exist",
1110 format_type_be(sourcetypeid),
1111 format_type_be(targettypeid))));
1112 return oid;
1113}
#define OidIsValid(objectId)
Definition: c.h:746
int errcode(int sqlerrcode)
Definition: elog.c:854
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#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 1146 of file lsyscache.c.

1147{
1148 HeapTuple tp;
1149 Form_pg_collation colltup;
1150 bool result;
1151
1152 tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1153 if (!HeapTupleIsValid(tp))
1154 elog(ERROR, "cache lookup failed for collation %u", colloid);
1155 colltup = (Form_pg_collation) GETSTRUCT(tp);
1156 result = colltup->collisdeterministic;
1157 ReleaseSysCache(tp);
1158 return result;
1159}
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 1127 of file lsyscache.c.

1128{
1129 HeapTuple tp;
1130
1131 tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1132 if (HeapTupleIsValid(tp))
1133 {
1135 char *result;
1136
1137 result = pstrdup(NameStr(colltup->collname));
1138 ReleaseSysCache(tp);
1139 return result;
1140 }
1141 else
1142 return NULL;
1143}

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

483{
484 bool result = false;
485 CatCList *catlist;
486 int i;
487
488 /* Ensure output args are initialized on failure */
489 if (lhs_opno)
490 *lhs_opno = InvalidOid;
491 if (rhs_opno)
492 *rhs_opno = InvalidOid;
493
494 /*
495 * Search pg_amop to see if the target operator is registered as the "="
496 * operator of any hash opfamily. If the operator is registered in
497 * multiple opfamilies, assume we can use any one.
498 */
499 catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
500
501 for (i = 0; i < catlist->n_members; i++)
502 {
503 HeapTuple tuple = &catlist->members[i]->tuple;
504 Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
505
506 if (aform->amopmethod == HASH_AM_OID &&
507 aform->amopstrategy == HTEqualStrategyNumber)
508 {
509 /* No extra lookup needed if given operator is single-type */
510 if (aform->amoplefttype == aform->amoprighttype)
511 {
512 if (lhs_opno)
513 *lhs_opno = opno;
514 if (rhs_opno)
515 *rhs_opno = opno;
516 result = true;
517 break;
518 }
519
520 /*
521 * Get the matching single-type operator(s). Failure probably
522 * shouldn't happen --- it implies a bogus opfamily --- but
523 * continue looking if so.
524 */
525 if (lhs_opno)
526 {
527 *lhs_opno = get_opfamily_member(aform->amopfamily,
528 aform->amoplefttype,
529 aform->amoplefttype,
531 if (!OidIsValid(*lhs_opno))
532 continue;
533 /* Matching LHS found, done if caller doesn't want RHS */
534 if (!rhs_opno)
535 {
536 result = true;
537 break;
538 }
539 }
540 if (rhs_opno)
541 {
542 *rhs_opno = get_opfamily_member(aform->amopfamily,
543 aform->amoprighttype,
544 aform->amoprighttype,
546 if (!OidIsValid(*rhs_opno))
547 {
548 /* Forget any LHS operator from this opfamily */
549 if (lhs_opno)
550 *lhs_opno = InvalidOid;
551 continue;
552 }
553 /* Matching RHS found, so done */
554 result = true;
555 break;
556 }
557 }
558 }
559
560 ReleaseSysCacheList(catlist);
561
562 return result;
563}
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 1205 of file lsyscache.c.

1206{
1207 HeapTuple tp;
1208
1209 tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
1210 if (HeapTupleIsValid(tp))
1211 {
1213 Oid result;
1214
1215 if (contup->contype == CONSTRAINT_UNIQUE ||
1216 contup->contype == CONSTRAINT_PRIMARY ||
1217 contup->contype == CONSTRAINT_EXCLUSION)
1218 result = contup->conindid;
1219 else
1220 result = InvalidOid;
1221 ReleaseSysCache(tp);
1222 return result;
1223 }
1224 else
1225 return InvalidOid;
1226}
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 1173 of file lsyscache.c.

1174{
1175 HeapTuple tp;
1176
1177 tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
1178 if (HeapTupleIsValid(tp))
1179 {
1181 char *result;
1182
1183 result = pstrdup(NameStr(contup->conname));
1184 ReleaseSysCache(tp);
1185 return result;
1186 }
1187 else
1188 return NULL;
1189}

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

1236{
1237 HeapTuple tp;
1238 char contype;
1239
1240 tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
1241 if (!HeapTupleIsValid(tp))
1242 elog(ERROR, "cache lookup failed for constraint %u", conoid);
1243
1244 contype = ((Form_pg_constraint) GETSTRUCT(tp))->contype;
1245 ReleaseSysCache(tp);
1246
1247 return contype;
1248}

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

331{
332 Oid result = InvalidOid;
333 Oid opfamily;
334 Oid opcintype;
335 CompareType cmptype;
336
337 /* Find the operator in pg_amop */
339 &opfamily, &opcintype, &cmptype))
340 {
341 /* Found a suitable opfamily, get matching equality operator */
342 result = get_opfamily_member_for_cmptype(opfamily,
343 opcintype,
344 opcintype,
345 COMPARE_EQ);
346 if (reverse)
347 *reverse = (cmptype == COMPARE_GT);
348 }
349
350 return result;
351}
CompareType
Definition: cmptype.h:32
@ COMPARE_GT
Definition: cmptype.h:38
@ COMPARE_EQ
Definition: cmptype.h:36
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, CompareType *cmptype)
Definition: lsyscache.c:265
Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
Definition: lsyscache.c:196

References COMPARE_EQ, COMPARE_GT, get_opfamily_member_for_cmptype(), 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 1977 of file lsyscache.c.

1978{
1979 HeapTuple tp;
1980 bool result;
1981
1982 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1983 if (!HeapTupleIsValid(tp))
1984 elog(ERROR, "cache lookup failed for function %u", funcid);
1985
1986 result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
1987 ReleaseSysCache(tp);
1988 return result;
1989}

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

1773{
1774 HeapTuple tp;
1775
1776 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1777 if (HeapTupleIsValid(tp))
1778 {
1779 Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1780 Oid result;
1781
1782 result = functup->pronamespace;
1783 ReleaseSysCache(tp);
1784 return result;
1785 }
1786 else
1787 return InvalidOid;
1788}

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

1815{
1816 HeapTuple tp;
1817 int result;
1818
1819 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1820 if (!HeapTupleIsValid(tp))
1821 elog(ERROR, "cache lookup failed for function %u", funcid);
1822
1823 result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1824 ReleaseSysCache(tp);
1825 return result;
1826}
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 1958 of file lsyscache.c.

1959{
1960 HeapTuple tp;
1961 char result;
1962
1963 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1964 if (!HeapTupleIsValid(tp))
1965 elog(ERROR, "cache lookup failed for function %u", funcid);
1966
1967 result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
1968 ReleaseSysCache(tp);
1969 return result;
1970}

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

1883{
1884 HeapTuple tp;
1885 bool result;
1886
1887 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1888 if (!HeapTupleIsValid(tp))
1889 elog(ERROR, "cache lookup failed for function %u", funcid);
1890
1891 result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
1892 ReleaseSysCache(tp);
1893 return result;
1894}

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

1837{
1838 HeapTuple tp;
1839 Form_pg_proc procstruct;
1840 Oid result;
1841
1842 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1843 if (!HeapTupleIsValid(tp))
1844 elog(ERROR, "cache lookup failed for function %u", funcid);
1845
1846 procstruct = (Form_pg_proc) GETSTRUCT(tp);
1847
1848 result = procstruct->prorettype;
1849 *nargs = (int) procstruct->pronargs;
1850 Assert(*nargs == procstruct->proargtypes.dim1);
1851 *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1852 memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1853
1854 ReleaseSysCache(tp);
1855 return result;
1856}
Assert(PointerIsAligned(start, uint64))
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 1998 of file lsyscache.c.

1999{
2000 HeapTuple tp;
2001
2002 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
2003 if (HeapTupleIsValid(tp))
2004 {
2005 Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
2006 RegProcedure result;
2007
2008 result = functup->prosupport;
2009 ReleaseSysCache(tp);
2010 return result;
2011 }
2012 else
2013 return (RegProcedure) InvalidOid;
2014}
regproc RegProcedure
Definition: c.h:621

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

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

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

3653{
3654 HeapTuple tuple;
3655 Form_pg_index rd_index;
3656 Datum datum;
3657 oidvector *indclass;
3658 Oid opclass;
3659
3660 /* First we need to know the column's opclass. */
3661
3662 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3663 if (!HeapTupleIsValid(tuple))
3664 return InvalidOid;
3665
3666 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3667
3668 /* caller is supposed to guarantee this */
3669 Assert(attno > 0 && attno <= rd_index->indnatts);
3670
3671 /* Non-key attributes don't have an opclass */
3672 if (attno > rd_index->indnkeyatts)
3673 {
3674 ReleaseSysCache(tuple);
3675 return InvalidOid;
3676 }
3677
3678 datum = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
3679 indclass = ((oidvector *) DatumGetPointer(datum));
3680
3681 Assert(attno <= indclass->dim1);
3682 opclass = indclass->values[attno - 1];
3683
3684 ReleaseSysCache(tuple);
3685
3686 return opclass;
3687}
FormData_pg_index * Form_pg_index
Definition: pg_index.h:70
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:317
Definition: c.h:697
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition: c.h:704

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

3742{
3743 bool isclustered;
3744 HeapTuple tuple;
3745 Form_pg_index rd_index;
3746
3747 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3748 if (!HeapTupleIsValid(tuple))
3749 elog(ERROR, "cache lookup failed for index %u", index_oid);
3750
3751 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3752 isclustered = rd_index->indisclustered;
3753 ReleaseSysCache(tuple);
3754
3755 return isclustered;
3756}

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

3696{
3697 HeapTuple tuple;
3698 Form_pg_index rd_index;
3699 bool result;
3700
3701 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3702 if (!HeapTupleIsValid(tuple))
3703 return false;
3704
3705 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3706 result = rd_index->indisreplident;
3707 ReleaseSysCache(tuple);
3708
3709 return result;
3710}

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

Referenced by RememberReplicaIdentityForRebuilding().

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3718 of file lsyscache.c.

3719{
3720 bool isvalid;
3721 HeapTuple tuple;
3722 Form_pg_index rd_index;
3723
3724 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3725 if (!HeapTupleIsValid(tuple))
3726 elog(ERROR, "cache lookup failed for index %u", index_oid);
3727
3728 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3729 isvalid = rd_index->indisvalid;
3730 ReleaseSysCache(tuple);
3731
3732 return isvalid;
3733}

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

1254{
1255 HeapTuple tp;
1256
1257 tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
1258 if (HeapTupleIsValid(tp))
1259 {
1261 char *result;
1262
1263 result = pstrdup(NameStr(lantup->lanname));
1264 ReleaseSysCache(tp);
1265 return result;
1266 }
1267
1268 if (!missing_ok)
1269 elog(ERROR, "cache lookup failed for language %u",
1270 langoid);
1271 return NULL;
1272}
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 434 of file lsyscache.c.

435{
436 List *result = NIL;
437 CatCList *catlist;
438 int i;
439
440 /*
441 * Search pg_amop to see if the target operator is registered as the "="
442 * operator of any opfamily of an ordering index type.
443 */
444 catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
445
446 for (i = 0; i < catlist->n_members; i++)
447 {
448 HeapTuple tuple = &catlist->members[i]->tuple;
449 Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
450
451 /* must be ordering index equality */
452 if (get_opmethod_canorder(aform->amopmethod) &&
453 IndexAmTranslateStrategy(aform->amopstrategy,
454 aform->amopmethod,
455 aform->amopfamily,
456 true) == COMPARE_EQ)
457 result = lappend_oid(result, aform->amopfamily);
458 }
459
460 ReleaseSysCacheList(catlist);
461
462 return result;
463}
CompareType IndexAmTranslateStrategy(StrategyNumber strategy, Oid amoid, Oid opfamily, bool missing_ok)
Definition: amapi.c:118
List * lappend_oid(List *list, Oid datum)
Definition: list.c:375
static bool get_opmethod_canorder(Oid amoid)
Definition: lsyscache.c:220
#define NIL
Definition: pg_list.h:68
Definition: pg_list.h:54

References COMPARE_EQ, get_opmethod_canorder(), GETSTRUCT(), i, IndexAmTranslateStrategy(), 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 3623 of file lsyscache.c.

3624{
3625 HeapTuple tp;
3626
3627 tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
3628 if (HeapTupleIsValid(tp))
3629 {
3630 Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3631 Oid result;
3632
3633 result = rngtup->rngtypid;
3634 ReleaseSysCache(tp);
3635 return result;
3636 }
3637 else
3638 return InvalidOid;
3639}
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 3506 of file lsyscache.c.

3507{
3508 HeapTuple tp;
3509
3510 tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid));
3511 if (HeapTupleIsValid(tp))
3512 {
3514 char *result;
3515
3516 result = pstrdup(NameStr(nsptup->nspname));
3517 ReleaseSysCache(tp);
3518 return result;
3519 }
3520 else
3521 return NULL;
3522}
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 1673 of file lsyscache.c.

1674{
1675 HeapTuple tp;
1676
1677 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1678 if (HeapTupleIsValid(tp))
1679 {
1681 Oid result;
1682
1683 result = optup->oprnegate;
1684 ReleaseSysCache(tp);
1685 return result;
1686 }
1687 else
1688 return InvalidOid;
1689}

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

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

◆ get_op_hash_functions()

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

Definition at line 581 of file lsyscache.c.

583{
584 bool result = false;
585 CatCList *catlist;
586 int i;
587
588 /* Ensure output args are initialized on failure */
589 if (lhs_procno)
590 *lhs_procno = InvalidOid;
591 if (rhs_procno)
592 *rhs_procno = InvalidOid;
593
594 /*
595 * Search pg_amop to see if the target operator is registered as the "="
596 * operator of any hash opfamily. If the operator is registered in
597 * multiple opfamilies, assume we can use any one.
598 */
599 catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
600
601 for (i = 0; i < catlist->n_members; i++)
602 {
603 HeapTuple tuple = &catlist->members[i]->tuple;
604 Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
605
606 if (aform->amopmethod == HASH_AM_OID &&
607 aform->amopstrategy == HTEqualStrategyNumber)
608 {
609 /*
610 * Get the matching support function(s). Failure probably
611 * shouldn't happen --- it implies a bogus opfamily --- but
612 * continue looking if so.
613 */
614 if (lhs_procno)
615 {
616 *lhs_procno = get_opfamily_proc(aform->amopfamily,
617 aform->amoplefttype,
618 aform->amoplefttype,
620 if (!OidIsValid(*lhs_procno))
621 continue;
622 /* Matching LHS found, done if caller doesn't want RHS */
623 if (!rhs_procno)
624 {
625 result = true;
626 break;
627 }
628 /* Only one lookup needed if given operator is single-type */
629 if (aform->amoplefttype == aform->amoprighttype)
630 {
631 *rhs_procno = *lhs_procno;
632 result = true;
633 break;
634 }
635 }
636 if (rhs_procno)
637 {
638 *rhs_procno = get_opfamily_proc(aform->amopfamily,
639 aform->amoprighttype,
640 aform->amoprighttype,
642 if (!OidIsValid(*rhs_procno))
643 {
644 /* Forget any LHS function from this opfamily */
645 if (lhs_procno)
646 *lhs_procno = InvalidOid;
647 continue;
648 }
649 /* Matching RHS found, so done */
650 result = true;
651 break;
652 }
653 }
654 }
655
656 ReleaseSysCacheList(catlist);
657
658 return result;
659}
#define HASHSTANDARD_PROC
Definition: hash.h:355
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
Definition: lsyscache.c:888

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

List * get_op_index_interpretation ( Oid  opno)

Definition at line 672 of file lsyscache.c.

673{
674 List *result = NIL;
675 OpIndexInterpretation *thisresult;
676 CatCList *catlist;
677 int i;
678
679 /*
680 * Find all the pg_amop entries containing the operator.
681 */
682 catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
683
684 for (i = 0; i < catlist->n_members; i++)
685 {
686 HeapTuple op_tuple = &catlist->members[i]->tuple;
687 Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
688 CompareType cmptype;
689
690 /* must be ordering index */
691 if (!get_opmethod_canorder(op_form->amopmethod))
692 continue;
693
694 /* Get the operator's comparision type */
695 cmptype = IndexAmTranslateStrategy(op_form->amopstrategy,
696 op_form->amopmethod,
697 op_form->amopfamily,
698 true);
699
700 /* should not happen */
701 if (cmptype == COMPARE_INVALID)
702 continue;
703
704 thisresult = (OpIndexInterpretation *)
706 thisresult->opfamily_id = op_form->amopfamily;
707 thisresult->cmptype = cmptype;
708 thisresult->oplefttype = op_form->amoplefttype;
709 thisresult->oprighttype = op_form->amoprighttype;
710 result = lappend(result, thisresult);
711 }
712
713 ReleaseSysCacheList(catlist);
714
715 /*
716 * If we didn't find any btree opfamily containing the operator, perhaps
717 * it is a <> operator. See if it has a negator that is in an opfamily.
718 */
719 if (result == NIL)
720 {
721 Oid op_negator = get_negator(opno);
722
723 if (OidIsValid(op_negator))
724 {
725 catlist = SearchSysCacheList1(AMOPOPID,
726 ObjectIdGetDatum(op_negator));
727
728 for (i = 0; i < catlist->n_members; i++)
729 {
730 HeapTuple op_tuple = &catlist->members[i]->tuple;
731 Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
732 IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
733 CompareType cmptype;
734
735 /* must be ordering index */
736 if (!amroutine->amcanorder)
737 continue;
738
739 /* Get the operator's comparision type */
740 cmptype = IndexAmTranslateStrategy(op_form->amopstrategy,
741 op_form->amopmethod,
742 op_form->amopfamily,
743 true);
744
745 /* Only consider negators that are = */
746 if (cmptype != COMPARE_EQ)
747 continue;
748
749 /* OK, report it as COMPARE_NE */
750 thisresult = (OpIndexInterpretation *)
752 thisresult->opfamily_id = op_form->amopfamily;
753 thisresult->cmptype = COMPARE_NE;
754 thisresult->oplefttype = op_form->amoplefttype;
755 thisresult->oprighttype = op_form->amoprighttype;
756 result = lappend(result, thisresult);
757 }
758
759 ReleaseSysCacheList(catlist);
760 }
761 }
762
763 return result;
764}
@ COMPARE_INVALID
Definition: cmptype.h:33
@ COMPARE_NE
Definition: cmptype.h:39
List * lappend(List *list, void *datum)
Definition: list.c:339
Oid get_negator(Oid opno)
Definition: lsyscache.c:1673
bool amcanorder
Definition: amapi.h:244
CompareType cmptype
Definition: lsyscache.h:28

References IndexAmRoutine::amcanorder, OpIndexInterpretation::cmptype, COMPARE_EQ, COMPARE_INVALID, COMPARE_NE, get_negator(), get_opmethod_canorder(), GetIndexAmRoutineByAmId(), GETSTRUCT(), i, IndexAmTranslateStrategy(), lappend(), catclist::members, catclist::n_members, NIL, ObjectIdGetDatum(), OidIsValid, OpIndexInterpretation::opfamily_id, OpIndexInterpretation::oplefttype, OpIndexInterpretation::oprighttype, palloc(), ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

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

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

1474{
1475 HeapTuple tp;
1476
1477 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1478 if (HeapTupleIsValid(tp))
1479 {
1481 Oid result;
1482
1483 result = optup->oprresult;
1484 ReleaseSysCache(tp);
1485 return result;
1486 }
1487 else
1488 return InvalidOid;
1489}

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

1283{
1284 HeapTuple tp;
1285 Form_pg_opclass cla_tup;
1286 Oid result;
1287
1288 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1289 if (!HeapTupleIsValid(tp))
1290 elog(ERROR, "cache lookup failed for opclass %u", opclass);
1291 cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1292
1293 result = cla_tup->opcfamily;
1294 ReleaseSysCache(tp);
1295 return result;
1296}
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(), IsIndexUsableForReplicaIdentityFull(), load_rangetype_info(), and lookup_type_cache().

◆ get_opclass_input_type()

Oid get_opclass_input_type ( Oid  opclass)

Definition at line 1304 of file lsyscache.c.

1305{
1306 HeapTuple tp;
1307 Form_pg_opclass cla_tup;
1308 Oid result;
1309
1310 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1311 if (!HeapTupleIsValid(tp))
1312 elog(ERROR, "cache lookup failed for opclass %u", opclass);
1313 cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1314
1315 result = cla_tup->opcintype;
1316 ReleaseSysCache(tp);
1317 return result;
1318}

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

1353{
1354 HeapTuple tp;
1355 Form_pg_opclass cla_tup;
1356 Oid result;
1357
1358 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1359 if (!HeapTupleIsValid(tp))
1360 elog(ERROR, "cache lookup failed for opclass %u", opclass);
1361 cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1362
1363 result = cla_tup->opcmethod;
1364 ReleaseSysCache(tp);
1365 return result;
1366}

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

1328{
1329 HeapTuple tp;
1330 Form_pg_opclass cla_tup;
1331
1332 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1333 if (!HeapTupleIsValid(tp))
1334 return false;
1335
1336 cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1337
1338 *opfamily = cla_tup->opcfamily;
1339 *opcintype = cla_tup->opcintype;
1340
1341 ReleaseSysCache(tp);
1342
1343 return true;
1344}

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

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

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1425 of file lsyscache.c.

1426{
1427 HeapTuple tp;
1428
1429 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1430 if (HeapTupleIsValid(tp))
1431 {
1433 RegProcedure result;
1434
1435 result = optup->oprcode;
1436 ReleaseSysCache(tp);
1437 return result;
1438 }
1439 else
1440 return (RegProcedure) InvalidOid;
1441}

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

Referenced by _bt_compare_scankey_args(), _bt_find_extreme_element(), _bt_preprocess_array_keys(), _bt_skiparray_strat_decrement(), _bt_skiparray_strat_increment(), 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(), make_SAOP_expr(), match_pattern_prefix(), mcv_get_match_bitmap(), minmax_get_strategy_procinfo(), minmax_multi_get_strategy_procinfo(), mode_final(), networkjoinsel_semi(), networksel(), op_strict(), op_volatile(), OperatorLookup(), patternsel_common(), prefix_selectivity(), preparePresortedCols(), RelationGetExclusionInfo(), ri_HashCompareOp(), scalarineqsel(), select_equality_operator(), set_opfuncid(), set_sa_opfuncid(), statext_is_compatible_clause_internal(), std_typanalyze(), and var_eq_const().

◆ get_opfamily_member()

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

◆ get_opfamily_member_for_cmptype()

Oid get_opfamily_member_for_cmptype ( Oid  opfamily,
Oid  lefttype,
Oid  righttype,
CompareType  cmptype 
)

Definition at line 196 of file lsyscache.c.

198{
199 Oid opmethod;
200 StrategyNumber strategy;
201
202 opmethod = get_opfamily_method(opfamily);
203 strategy = IndexAmTranslateCompareType(cmptype, opmethod, opfamily, true);
204 if (!strategy)
205 return InvalidOid;
206 return get_opfamily_member(opfamily, lefttype, righttype, strategy);
207}
StrategyNumber IndexAmTranslateCompareType(CompareType cmptype, Oid amoid, Oid opfamily, bool missing_ok)
Definition: amapi.c:148
Oid get_opfamily_method(Oid opfid)
Definition: lsyscache.c:1376
uint16 StrategyNumber
Definition: stratnum.h:22

References get_opfamily_member(), get_opfamily_method(), IndexAmTranslateCompareType(), and InvalidOid.

Referenced by appendOrderByClause(), create_indexscan_plan(), DefineIndex(), find_window_run_conditions(), get_equality_op_for_ordering_op(), get_ordering_op_for_equality_op(), get_relation_info(), lookup_proof_cache(), make_pathkey_from_sortinfo(), make_unique_from_pathkeys(), match_network_subset(), prepare_sort_from_pathkeys(), refresh_by_match_merge(), and select_equality_operator().

◆ get_opfamily_method()

Oid get_opfamily_method ( Oid  opfid)

Definition at line 1376 of file lsyscache.c.

1377{
1378 HeapTuple tp;
1379 Form_pg_opfamily opfform;
1380 Oid result;
1381
1382 tp = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfid));
1383 if (!HeapTupleIsValid(tp))
1384 elog(ERROR, "cache lookup failed for operator family %u", opfid);
1385 opfform = (Form_pg_opfamily) GETSTRUCT(tp);
1386
1387 result = opfform->opfmethod;
1388 ReleaseSysCache(tp);
1389 return result;
1390}
FormData_pg_opfamily * Form_pg_opfamily
Definition: pg_opfamily.h:51

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

Referenced by DefineIndex(), get_opfamily_member_for_cmptype(), mergejoinscansel(), and MJExamineQuals().

◆ get_opfamily_name()

char * get_opfamily_name ( Oid  opfid,
bool  missing_ok 
)

Definition at line 1393 of file lsyscache.c.

1394{
1395 HeapTuple tup;
1396 char *opfname;
1397 Form_pg_opfamily opfform;
1398
1399 tup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfid));
1400
1401 if (!HeapTupleIsValid(tup))
1402 {
1403 if (!missing_ok)
1404 elog(ERROR, "cache lookup failed for operator family %u", opfid);
1405 return NULL;
1406 }
1407
1408 opfform = (Form_pg_opfamily) GETSTRUCT(tup);
1409 opfname = pstrdup(NameStr(opfform->opfname));
1410
1411 ReleaseSysCache(tup);
1412
1413 return opfname;
1414}

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

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

◆ get_opfamily_proc()

◆ get_opmethod_canorder()

static bool get_opmethod_canorder ( Oid  amoid)
static

Definition at line 220 of file lsyscache.c.

221{
222 switch (amoid)
223 {
224 case BTREE_AM_OID:
225 return true;
226 case HASH_AM_OID:
227 case GIST_AM_OID:
228 case GIN_AM_OID:
229 case SPGIST_AM_OID:
230 case BRIN_AM_OID:
231 return false;
232 default:
233 {
234 bool result;
235 IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(amoid, false);
236
237 result = amroutine->amcanorder;
238 pfree(amroutine);
239 return result;
240 }
241 }
242}

References IndexAmRoutine::amcanorder, GetIndexAmRoutineByAmId(), and pfree().

Referenced by get_mergejoin_opfamilies(), get_op_index_interpretation(), get_ordering_op_for_equality_op(), and get_ordering_op_properties().

◆ get_opname()

char * get_opname ( Oid  opno)

Definition at line 1450 of file lsyscache.c.

1451{
1452 HeapTuple tp;
1453
1454 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1455 if (HeapTupleIsValid(tp))
1456 {
1458 char *result;
1459
1460 result = pstrdup(NameStr(optup->oprname));
1461 ReleaseSysCache(tp);
1462 return result;
1463 }
1464 else
1465 return NULL;
1466}

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

1722{
1723 HeapTuple tp;
1724
1725 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1726 if (HeapTupleIsValid(tp))
1727 {
1729 RegProcedure result;
1730
1731 result = optup->oprjoin;
1732 ReleaseSysCache(tp);
1733 return result;
1734 }
1735 else
1736 return (RegProcedure) InvalidOid;
1737}

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

Referenced by join_selectivity(), and scalararraysel().

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1697 of file lsyscache.c.

1698{
1699 HeapTuple tp;
1700
1701 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1702 if (HeapTupleIsValid(tp))
1703 {
1705 RegProcedure result;
1706
1707 result = optup->oprrest;
1708 ReleaseSysCache(tp);
1709 return result;
1710 }
1711 else
1712 return (RegProcedure) InvalidOid;
1713}

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

369{
370 Oid result = InvalidOid;
371 CatCList *catlist;
372 int i;
373
374 /*
375 * Search pg_amop to see if the target operator is registered as the "="
376 * operator of any btree opfamily.
377 */
378 catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
379
380 for (i = 0; i < catlist->n_members; i++)
381 {
382 HeapTuple tuple = &catlist->members[i]->tuple;
383 Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
384 CompareType cmptype;
385
386 /* must be ordering index */
387 if (!get_opmethod_canorder(aform->amopmethod))
388 continue;
389
390 cmptype = IndexAmTranslateStrategy(aform->amopstrategy,
391 aform->amopmethod,
392 aform->amopfamily,
393 true);
394 if (cmptype == COMPARE_EQ)
395 {
396 /* Found a suitable opfamily, get matching ordering operator */
397 Oid typid;
398
399 typid = use_lhs_type ? aform->amoplefttype : aform->amoprighttype;
400 result = get_opfamily_member_for_cmptype(aform->amopfamily,
401 typid, typid,
402 COMPARE_LT);
403 if (OidIsValid(result))
404 break;
405 /* failure probably shouldn't happen, but keep looking if so */
406 }
407 }
408
409 ReleaseSysCacheList(catlist);
410
411 return result;
412}
@ COMPARE_LT
Definition: cmptype.h:34

References COMPARE_EQ, COMPARE_LT, get_opfamily_member_for_cmptype(), get_opmethod_canorder(), GETSTRUCT(), i, IndexAmTranslateStrategy(), 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,
CompareType cmptype 
)

Definition at line 265 of file lsyscache.c.

267{
268 bool result = false;
269 CatCList *catlist;
270 int i;
271
272 /* ensure outputs are initialized on failure */
273 *opfamily = InvalidOid;
274 *opcintype = InvalidOid;
275 *cmptype = COMPARE_INVALID;
276
277 /*
278 * Search pg_amop to see if the target operator is registered as the "<"
279 * or ">" operator of any btree opfamily.
280 */
281 catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));
282
283 for (i = 0; i < catlist->n_members; i++)
284 {
285 HeapTuple tuple = &catlist->members[i]->tuple;
286 Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
287 CompareType am_cmptype;
288
289 /* must be ordering index */
290 if (!get_opmethod_canorder(aform->amopmethod))
291 continue;
292
293 am_cmptype = IndexAmTranslateStrategy(aform->amopstrategy,
294 aform->amopmethod,
295 aform->amopfamily,
296 true);
297
298 if (am_cmptype == COMPARE_LT || am_cmptype == COMPARE_GT)
299 {
300 /* Found it ... should have consistent input types */
301 if (aform->amoplefttype == aform->amoprighttype)
302 {
303 /* Found a suitable opfamily, return info */
304 *opfamily = aform->amopfamily;
305 *opcintype = aform->amoplefttype;
306 *cmptype = am_cmptype;
307 result = true;
308 break;
309 }
310 }
311 }
312
313 ReleaseSysCacheList(catlist);
314
315 return result;
316}

References COMPARE_GT, COMPARE_INVALID, COMPARE_LT, get_opmethod_canorder(), GETSTRUCT(), i, IndexAmTranslateStrategy(), 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 2951 of file lsyscache.c.

2952{
2953 Oid array_type = get_array_type(typid);
2954
2955 if (OidIsValid(array_type))
2956 return array_type;
2957 if (OidIsValid(get_element_type(typid)))
2958 return typid;
2959 return InvalidOid;
2960}
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2899
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2927

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

3786{
3787 HeapTuple tup;
3788 char *pubname;
3789 Form_pg_publication pubform;
3790
3791 tup = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pubid));
3792
3793 if (!HeapTupleIsValid(tup))
3794 {
3795 if (!missing_ok)
3796 elog(ERROR, "cache lookup failed for publication %u", pubid);
3797 return NULL;
3798 }
3799
3800 pubform = (Form_pg_publication) GETSTRUCT(tup);
3801 pubname = pstrdup(NameStr(pubform->pubname));
3802
3803 ReleaseSysCache(tup);
3804
3805 return pubname;
3806}
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 3765 of file lsyscache.c.

3766{
3767 Oid oid;
3768
3769 oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
3770 CStringGetDatum(pubname));
3771 if (!OidIsValid(oid) && !missing_ok)
3772 ereport(ERROR,
3773 (errcode(ERRCODE_UNDEFINED_OBJECT),
3774 errmsg("publication \"%s\" does not exist", pubname)));
3775 return oid;
3776}
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 3573 of file lsyscache.c.

3574{
3575 HeapTuple tp;
3576
3577 tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3578 if (HeapTupleIsValid(tp))
3579 {
3580 Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3581 Oid result;
3582
3583 result = rngtup->rngcollation;
3584 ReleaseSysCache(tp);
3585 return result;
3586 }
3587 else
3588 return InvalidOid;
3589}

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

Referenced by CheckAttributeType().

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

Definition at line 3598 of file lsyscache.c.

3599{
3600 HeapTuple tp;
3601
3602 tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3603 if (HeapTupleIsValid(tp))
3604 {
3605 Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3606 Oid result;
3607
3608 result = rngtup->rngmultitypid;
3609 ReleaseSysCache(tp);
3610 return result;
3611 }
3612 else
3613 return InvalidOid;
3614}

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

3548{
3549 HeapTuple tp;
3550
3551 tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3552 if (HeapTupleIsValid(tp))
3553 {
3554 Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3555 Oid result;
3556
3557 result = rngtup->rngsubtype;
3558 ReleaseSysCache(tp);
3559 return result;
3560 }
3561 else
3562 return InvalidOid;
3563}

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

2069{
2070 HeapTuple tp;
2071
2072 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2073 if (HeapTupleIsValid(tp))
2074 {
2075 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2076 char *result;
2077
2078 result = pstrdup(NameStr(reltup->relname));
2079 ReleaseSysCache(tp);
2080 return result;
2081 }
2082 else
2083 return NULL;
2084}
FormData_pg_class * Form_pg_class
Definition: pg_class.h:156

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(), 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(), finish_sync_worker(), 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(), overexplain_range_table(), perform_work_item(), pg_clear_attribute_stats(), pg_decode_change(), pg_extension_config_dump(), pg_prewarm(), pg_sequence_parameters(), postgresExplainForeignScan(), process_owned_by(), QueueNNConstraintValidation(), 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 2218 of file lsyscache.c.

2219{
2220 HeapTuple tp;
2221 Form_pg_class reltup;
2222 char result;
2223
2224 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2225 if (!HeapTupleIsValid(tp))
2226 elog(ERROR, "cache lookup failed for relation %u", relid);
2227 reltup = (Form_pg_class) GETSTRUCT(tp);
2228 result = reltup->relpersistence;
2229 ReleaseSysCache(tp);
2230
2231 return result;
2232}

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

2241{
2242 HeapTuple tp;
2243 Form_pg_class reltup;
2244 Oid result;
2245
2246 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2247 if (!HeapTupleIsValid(tp))
2248 elog(ERROR, "cache lookup failed for relation %u", relid);
2249 reltup = (Form_pg_class) GETSTRUCT(tp);
2250 result = reltup->relam;
2251 ReleaseSysCache(tp);
2252
2253 return result;
2254}

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

Referenced by DefineRelation().

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

Definition at line 2167 of file lsyscache.c.

2168{
2169 HeapTuple tp;
2170
2171 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2172 if (HeapTupleIsValid(tp))
2173 {
2174 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2175 bool result;
2176
2177 result = reltup->relispartition;
2178 ReleaseSysCache(tp);
2179 return result;
2180 }
2181 else
2182 return false;
2183}

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

2144{
2145 HeapTuple tp;
2146
2147 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2148 if (HeapTupleIsValid(tp))
2149 {
2150 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2151 char result;
2152
2153 result = reltup->relkind;
2154 ReleaseSysCache(tp);
2155 return result;
2156 }
2157 else
2158 return '\0';
2159}

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

Referenced by AlterPublicationOptions(), AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), ATExecAlterConstrDeferrability(), ATExecAlterConstrEnforceability(), ATExecChangeOwner(), AttachPartitionForeignKey(), 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(), and stats_lock_check_privileges().

◆ get_rel_tablespace()

Oid get_rel_tablespace ( Oid  relid)

Definition at line 2194 of file lsyscache.c.

2195{
2196 HeapTuple tp;
2197
2198 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2199 if (HeapTupleIsValid(tp))
2200 {
2201 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2202 Oid result;
2203
2204 result = reltup->reltablespace;
2205 ReleaseSysCache(tp);
2206 return result;
2207 }
2208 else
2209 return InvalidOid;
2210}

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

2120{
2121 HeapTuple tp;
2122
2123 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2124 if (HeapTupleIsValid(tp))
2125 {
2126 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2127 Oid result;
2128
2129 result = reltup->reltype;
2130 ReleaseSysCache(tp);
2131 return result;
2132 }
2133 else
2134 return InvalidOid;
2135}

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

3836{
3837 HeapTuple tup;
3838 char *subname;
3839 Form_pg_subscription subform;
3840
3841 tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
3842
3843 if (!HeapTupleIsValid(tup))
3844 {
3845 if (!missing_ok)
3846 elog(ERROR, "cache lookup failed for subscription %u", subid);
3847 return NULL;
3848 }
3849
3850 subform = (Form_pg_subscription) GETSTRUCT(tup);
3851 subname = pstrdup(NameStr(subform->subname));
3852
3853 ReleaseSysCache(tup);
3854
3855 return subname;
3856}
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 3815 of file lsyscache.c.

3816{
3817 Oid oid;
3818
3819 oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
3821 if (!OidIsValid(oid) && !missing_ok)
3822 ereport(ERROR,
3823 (errcode(ERRCODE_UNDEFINED_OBJECT),
3824 errmsg("subscription \"%s\" does not exist", subname)));
3825 return oid;
3826}
Oid MyDatabaseId
Definition: globals.c:94

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

2261{
2262 HeapTuple tup;
2263
2264 if (!list_member_oid(trftypes, typid))
2265 return InvalidOid;
2266
2267 tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
2268 ObjectIdGetDatum(langid));
2269 if (HeapTupleIsValid(tup))
2270 {
2271 Oid funcid;
2272
2273 funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2274 ReleaseSysCache(tup);
2275 return funcid;
2276 }
2277 else
2278 return InvalidOid;
2279}
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 2282 of file lsyscache.c.

2283{
2284 HeapTuple tup;
2285
2286 if (!list_member_oid(trftypes, typid))
2287 return InvalidOid;
2288
2289 tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
2290 ObjectIdGetDatum(langid));
2291 if (HeapTupleIsValid(tup))
2292 {
2293 Oid funcid;
2294
2295 funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
2296 ReleaseSysCache(tup);
2297 return funcid;
2298 }
2299 else
2300 return InvalidOid;
2301}

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

2872{
2873 HeapTuple tp;
2874
2875 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2876 if (HeapTupleIsValid(tp))
2877 {
2878 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2879 Oid result;
2880
2881 result = typtup->typrelid;
2882 ReleaseSysCache(tp);
2883 return result;
2884 }
2885 else
2886 return InvalidOid;
2887}

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

2719{
2720 int typlen = get_typlen(typid);
2721 int32 maxwidth;
2722
2723 /*
2724 * Easy if it's a fixed-width type
2725 */
2726 if (typlen > 0)
2727 return typlen;
2728
2729 /*
2730 * type_maximum_size knows the encoding of typmod for some datatypes;
2731 * don't duplicate that knowledge here.
2732 */
2733 maxwidth = type_maximum_size(typid, typmod);
2734 if (maxwidth > 0)
2735 {
2736 /*
2737 * For BPCHAR, the max width is also the only width. Otherwise we
2738 * need to guess about the typical data width given the max. A sliding
2739 * scale for percentage of max width seems reasonable.
2740 */
2741 if (typid == BPCHAROID)
2742 return maxwidth;
2743 if (maxwidth <= 32)
2744 return maxwidth; /* assume full width */
2745 if (maxwidth < 1000)
2746 return 32 + (maxwidth - 32) / 2; /* assume 50% */
2747
2748 /*
2749 * Beyond 1000, assume we're looking at something like
2750 * "varchar(10000)" where the limit isn't actually reached often, and
2751 * use a fixed estimate.
2752 */
2753 return 32 + (1000 - 32) / 2;
2754 }
2755
2756 /*
2757 * Oops, we have no idea ... wild guess time.
2758 */
2759 return 32;
2760}
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:412
int16 get_typlen(Oid typid)
Definition: lsyscache.c:2337

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

2363{
2364 HeapTuple tp;
2365
2366 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2367 if (HeapTupleIsValid(tp))
2368 {
2369 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2370 bool result;
2371
2372 result = typtup->typbyval;
2373 ReleaseSysCache(tp);
2374 return result;
2375 }
2376 else
2377 return false;
2378}

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

2589{
2590 HeapTuple typeTuple;
2592 Datum datum;
2593 bool isNull;
2594 Node *expr;
2595
2596 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2597 if (!HeapTupleIsValid(typeTuple))
2598 elog(ERROR, "cache lookup failed for type %u", typid);
2599 type = (Form_pg_type) GETSTRUCT(typeTuple);
2600
2601 /*
2602 * typdefault and typdefaultbin are potentially null, so don't try to
2603 * access 'em as struct fields. Must do it the hard way with
2604 * SysCacheGetAttr.
2605 */
2606 datum = SysCacheGetAttr(TYPEOID,
2607 typeTuple,
2608 Anum_pg_type_typdefaultbin,
2609 &isNull);
2610
2611 if (!isNull)
2612 {
2613 /* We have an expression default */
2614 expr = stringToNode(TextDatumGetCString(datum));
2615 }
2616 else
2617 {
2618 /* Perhaps we have a plain literal default */
2619 datum = SysCacheGetAttr(TYPEOID,
2620 typeTuple,
2621 Anum_pg_type_typdefault,
2622 &isNull);
2623
2624 if (!isNull)
2625 {
2626 char *strDefaultVal;
2627
2628 /* Convert text datum to C string */
2629 strDefaultVal = TextDatumGetCString(datum);
2630 /* Convert C string to a value of the given type */
2631 datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2632 getTypeIOParam(typeTuple), -1);
2633 /* Build a Const node containing the value */
2634 expr = (Node *) makeConst(typid,
2635 -1,
2636 type->typcollation,
2637 type->typlen,
2638 datum,
2639 false,
2640 type->typbyval);
2641 pfree(strDefaultVal);
2642 }
2643 else
2644 {
2645 /* No default */
2646 expr = NULL;
2647 }
2648 }
2649
2650 ReleaseSysCache(typeTuple);
2651
2652 return expr;
2653}
#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:2443
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:350
void * stringToNode(const char *str)
Definition: read.c:90
Definition: nodes.h:135
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 2850 of file lsyscache.c.

2851{
2852 HeapTuple tp;
2853 Form_pg_type typtup;
2854
2855 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2856 if (!HeapTupleIsValid(tp))
2857 elog(ERROR, "cache lookup failed for type %u", typid);
2858 typtup = (Form_pg_type) GETSTRUCT(tp);
2859 *typcategory = typtup->typcategory;
2860 *typispreferred = typtup->typispreferred;
2861 ReleaseSysCache(tp);
2862}

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

2473{
2474 HeapTuple typeTuple;
2475 Form_pg_type typeStruct;
2476
2477 /*
2478 * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2479 * use array_in and array_out during bootstrap.
2480 */
2482 {
2483 Oid typinput;
2484 Oid typoutput;
2485
2487 typlen,
2488 typbyval,
2489 typalign,
2490 typdelim,
2491 typioparam,
2492 &typinput,
2493 &typoutput);
2494 switch (which_func)
2495 {
2496 case IOFunc_input:
2497 *func = typinput;
2498 break;
2499 case IOFunc_output:
2500 *func = typoutput;
2501 break;
2502 default:
2503 elog(ERROR, "binary I/O not supported during bootstrap");
2504 break;
2505 }
2506 return;
2507 }
2508
2509 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2510 if (!HeapTupleIsValid(typeTuple))
2511 elog(ERROR, "cache lookup failed for type %u", typid);
2512 typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2513
2514 *typlen = typeStruct->typlen;
2515 *typbyval = typeStruct->typbyval;
2516 *typalign = typeStruct->typalign;
2517 *typdelim = typeStruct->typdelim;
2518 *typioparam = getTypeIOParam(typeTuple);
2519 switch (which_func)
2520 {
2521 case IOFunc_input:
2522 *func = typeStruct->typinput;
2523 break;
2524 case IOFunc_output:
2525 *func = typeStruct->typoutput;
2526 break;
2527 case IOFunc_receive:
2528 *func = typeStruct->typreceive;
2529 break;
2530 case IOFunc_send:
2531 *func = typeStruct->typsend;
2532 break;
2533 }
2534 ReleaseSysCache(typeTuple);
2535}
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:37
@ IOFunc_input
Definition: lsyscache.h:36
@ IOFunc_send
Definition: lsyscache.h:39
@ IOFunc_receive
Definition: lsyscache.h:38
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:476
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 2313 of file lsyscache.c.

2314{
2315 HeapTuple tp;
2316
2317 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2318 if (HeapTupleIsValid(tp))
2319 {
2320 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2321 bool result;
2322
2323 result = typtup->typisdefined;
2324 ReleaseSysCache(tp);
2325 return result;
2326 }
2327 else
2328 return false;
2329}

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

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

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2337 of file lsyscache.c.

2338{
2339 HeapTuple tp;
2340
2341 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2342 if (HeapTupleIsValid(tp))
2343 {
2344 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2345 int16 result;
2346
2347 result = typtup->typlen;
2348 ReleaseSysCache(tp);
2349 return result;
2350 }
2351 else
2352 return 0;
2353}
int16_t int16
Definition: c.h:497

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

3147{
3148 HeapTuple tp;
3149
3150 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
3151 if (HeapTupleIsValid(tp))
3152 {
3153 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
3154 Oid result;
3155
3156 result = typtup->typmodin;
3157 ReleaseSysCache(tp);
3158 return result;
3159 }
3160 else
3161 return InvalidOid;
3162}

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2559 of file lsyscache.c.

2560{
2561 HeapTuple tp;
2562
2563 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2564 if (HeapTupleIsValid(tp))
2565 {
2566 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2567 char result;
2568
2569 result = typtup->typstorage;
2570 ReleaseSysCache(tp);
2571 return result;
2572 }
2573 else
2574 return TYPSTORAGE_PLAIN;
2575}

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

Referenced by GetAttributeStorage().

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3237 of file lsyscache.c.

3238{
3239 HeapTuple tp;
3240
3241 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
3242 if (HeapTupleIsValid(tp))
3243 {
3244 Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
3245 RegProcedure handler = typform->typsubscript;
3246
3247 if (typelemp)
3248 *typelemp = typform->typelem;
3249 ReleaseSysCache(tp);
3250 return handler;
3251 }
3252 else
3253 {
3254 if (typelemp)
3255 *typelemp = InvalidOid;
3256 return InvalidOid;
3257 }
3258}

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

2679{
2680 /*
2681 * We loop to find the bottom base type in a stack of domains.
2682 */
2683 for (;;)
2684 {
2685 HeapTuple tup;
2686 Form_pg_type typTup;
2687
2688 tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2689 if (!HeapTupleIsValid(tup))
2690 elog(ERROR, "cache lookup failed for type %u", typid);
2691 typTup = (Form_pg_type) GETSTRUCT(tup);
2692 if (typTup->typtype != TYPTYPE_DOMAIN)
2693 {
2694 /* Not a domain, so done */
2695 ReleaseSysCache(tup);
2696 break;
2697 }
2698
2699 Assert(*typmod == -1);
2700 typid = typTup->typbasetype;
2701 *typmod = typTup->typtypmod;
2702
2703 ReleaseSysCache(tup);
2704 }
2705
2706 return typid;
2707}

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

3271{
3272 RegProcedure typsubscript = get_typsubscript(typid, typelemp);
3273
3274 if (!OidIsValid(typsubscript))
3275 return NULL;
3276
3277 return (const struct SubscriptRoutines *)
3278 DatumGetPointer(OidFunctionCall0(typsubscript));
3279}
#define OidFunctionCall0(functionId)
Definition: fmgr.h:718
RegProcedure get_typsubscript(Oid typid, Oid *typelemp)
Definition: lsyscache.c:3237

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

3081{
3082 HeapTuple typeTuple;
3083 Form_pg_type pt;
3084
3085 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
3086 if (!HeapTupleIsValid(typeTuple))
3087 elog(ERROR, "cache lookup failed for type %u", type);
3088 pt = (Form_pg_type) GETSTRUCT(typeTuple);
3089
3090 if (!pt->typisdefined)
3091 ereport(ERROR,
3092 (errcode(ERRCODE_UNDEFINED_OBJECT),
3093 errmsg("type %s is only a shell",
3094 format_type_be(type))));
3095 if (!OidIsValid(pt->typreceive))
3096 ereport(ERROR,
3097 (errcode(ERRCODE_UNDEFINED_FUNCTION),
3098 errmsg("no binary input function available for type %s",
3099 format_type_be(type))));
3100
3101 *typReceive = pt->typreceive;
3102 *typIOParam = getTypeIOParam(typeTuple);
3103
3104 ReleaseSysCache(typeTuple);
3105}

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

Referenced by array_agg_deserialize(), CopyFromBinaryInFunc(), 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 3113 of file lsyscache.c.

3114{
3115 HeapTuple typeTuple;
3116 Form_pg_type pt;
3117
3118 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
3119 if (!HeapTupleIsValid(typeTuple))
3120 elog(ERROR, "cache lookup failed for type %u", type);
3121 pt = (Form_pg_type) GETSTRUCT(typeTuple);
3122
3123 if (!pt->typisdefined)
3124 ereport(ERROR,
3125 (errcode(ERRCODE_UNDEFINED_OBJECT),
3126 errmsg("type %s is only a shell",
3127 format_type_be(type))));
3128 if (!OidIsValid(pt->typsend))
3129 ereport(ERROR,
3130 (errcode(ERRCODE_UNDEFINED_FUNCTION),
3131 errmsg("no binary output function available for type %s",
3132 format_type_be(type))));
3133
3134 *typSend = pt->typsend;
3135 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
3136
3137 ReleaseSysCache(typeTuple);
3138}

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

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

◆ getTypeInputInfo()

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

Definition at line 3014 of file lsyscache.c.

3015{
3016 HeapTuple typeTuple;
3017 Form_pg_type pt;
3018
3019 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
3020 if (!HeapTupleIsValid(typeTuple))
3021 elog(ERROR, "cache lookup failed for type %u", type);
3022 pt = (Form_pg_type) GETSTRUCT(typeTuple);
3023
3024 if (!pt->typisdefined)
3025 ereport(ERROR,
3026 (errcode(ERRCODE_UNDEFINED_OBJECT),
3027 errmsg("type %s is only a shell",
3028 format_type_be(type))));
3029 if (!OidIsValid(pt->typinput))
3030 ereport(ERROR,
3031 (errcode(ERRCODE_UNDEFINED_FUNCTION),
3032 errmsg("no input function available for type %s",
3033 format_type_be(type))));
3034
3035 *typInput = pt->typinput;
3036 *typIOParam = getTypeIOParam(typeTuple);
3037
3038 ReleaseSysCache(typeTuple);
3039}

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

Referenced by _sv_to_datum_finfo(), check_functions_in_node(), CopyFromTextLikeInFunc(), 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 2443 of file lsyscache.c.

2444{
2445 Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2446
2447 /*
2448 * Array types get their typelem as parameter; everybody else gets their
2449 * own type OID as parameter.
2450 */
2451 if (OidIsValid(typeStruct->typelem))
2452 return typeStruct->typelem;
2453 else
2454 return typeStruct->oid;
2455}

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

3048{
3049 HeapTuple typeTuple;
3050 Form_pg_type pt;
3051
3052 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
3053 if (!HeapTupleIsValid(typeTuple))
3054 elog(ERROR, "cache lookup failed for type %u", type);
3055 pt = (Form_pg_type) GETSTRUCT(typeTuple);
3056
3057 if (!pt->typisdefined)
3058 ereport(ERROR,
3059 (errcode(ERRCODE_UNDEFINED_OBJECT),
3060 errmsg("type %s is only a shell",
3061 format_type_be(type))));
3062 if (!OidIsValid(pt->typoutput))
3063 ereport(ERROR,
3064 (errcode(ERRCODE_UNDEFINED_FUNCTION),
3065 errmsg("no output function available for type %s",
3066 format_type_be(type))));
3067
3068 *typOutput = pt->typoutput;
3069 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
3070
3071 ReleaseSysCache(typeTuple);
3072}

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(), CopyToTextLikeOutFunc(), cost_qual_eval_walker(), create_foreign_modify(), debugtup(), deparseConst(), 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 1577 of file lsyscache.c.

1578{
1579 bool result = false;
1580 HeapTuple tp;
1581 TypeCacheEntry *typentry;
1582
1583 /* As in op_mergejoinable, let the typcache handle the hard cases */
1584 if (opno == ARRAY_EQ_OP)
1585 {
1586 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1587 if (typentry->hash_proc == F_HASH_ARRAY)
1588 result = true;
1589 }
1590 else if (opno == RECORD_EQ_OP)
1591 {
1592 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1593 if (typentry->hash_proc == F_HASH_RECORD)
1594 result = true;
1595 }
1596 else
1597 {
1598 /* For all other operators, rely on pg_operator.oprcanhash */
1599 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1600 if (HeapTupleIsValid(tp))
1601 {
1603
1604 result = optup->oprcanhash;
1605 ReleaseSysCache(tp);
1606 }
1607 }
1608 return result;
1609}
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:386
#define TYPECACHE_HASH_PROC
Definition: typcache.h:142

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

1499{
1500 HeapTuple tp;
1501 Form_pg_operator optup;
1502
1503 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1504 if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1505 elog(ERROR, "cache lookup failed for operator %u", opno);
1506 optup = (Form_pg_operator) GETSTRUCT(tp);
1507 *lefttype = optup->oprleft;
1508 *righttype = optup->oprright;
1509 ReleaseSysCache(tp);
1510}

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

1527{
1528 bool result = false;
1529 HeapTuple tp;
1530 TypeCacheEntry *typentry;
1531
1532 /*
1533 * For array_eq or record_eq, we can sort if the element or field types
1534 * are all sortable. We could implement all the checks for that here, but
1535 * the typcache already does that and caches the results too, so let's
1536 * rely on the typcache.
1537 */
1538 if (opno == ARRAY_EQ_OP)
1539 {
1540 typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1541 if (typentry->cmp_proc == F_BTARRAYCMP)
1542 result = true;
1543 }
1544 else if (opno == RECORD_EQ_OP)
1545 {
1546 typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1547 if (typentry->cmp_proc == F_BTRECORDCMP)
1548 result = true;
1549 }
1550 else
1551 {
1552 /* For all other operators, rely on pg_operator.oprcanmerge */
1553 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1554 if (HeapTupleIsValid(tp))
1555 {
1557
1558 result = optup->oprcanmerge;
1559 ReleaseSysCache(tp);
1560 }
1561 }
1562 return result;
1563}
#define TYPECACHE_CMP_PROC
Definition: typcache.h:141

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

1618{
1619 RegProcedure funcid = get_opcode(opno);
1620
1621 if (funcid == (RegProcedure) InvalidOid)
1622 elog(ERROR, "operator %u does not exist", opno);
1623
1624 return func_strict((Oid) funcid);
1625}
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1425
bool func_strict(Oid funcid)
Definition: lsyscache.c:1901

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

1634{
1635 RegProcedure funcid = get_opcode(opno);
1636
1637 if (funcid == (RegProcedure) InvalidOid)
1638 elog(ERROR, "operator %u does not exist", opno);
1639
1640 return func_volatile((Oid) funcid);
1641}
char func_volatile(Oid funcid)
Definition: lsyscache.c:1920

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

2819{
2820 return (get_typtype(typid) == TYPTYPE_ENUM);
2821}
char get_typtype(Oid typid)
Definition: lsyscache.c:2769

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

2839{
2840 return (get_typtype(typid) == TYPTYPE_MULTIRANGE);
2841}

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

2829{
2830 return (get_typtype(typid) == TYPTYPE_RANGE);
2831}

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

2796{
2797 if (typid == RECORDOID)
2798 return true; /* easy case */
2799 switch (get_typtype(typid))
2800 {
2801 case TYPTYPE_COMPOSITE:
2802 return true;
2803 case TYPTYPE_DOMAIN:
2804 if (get_typtype(getBaseType(typid)) == TYPTYPE_COMPOSITE)
2805 return true;
2806 break;
2807 default:
2808 break;
2809 }
2810 return false;
2811}
Oid getBaseType(Oid typid)
Definition: lsyscache.c:2661

References get_typtype(), and getBaseType().

Referenced by build_datatype(), can_minmax_aggs(), coerce_function_result_tuple(), compile_plperl_function(), compile_pltcl_function(), deparseNullTest(), exec_assign_value(), exec_stmt_return(), exec_stmt_return_next(), ExecMakeTableFunctionResult(), get_rule_expr(), hstore_populate_record(), init_execution_state(), json_categorize_type(), makeWholeRowVar(), match_orclause_to_indexcol(), plperl_hash_from_tuple(), plperl_ref_from_pg_array(), plperl_sv_to_datum(), plpgsql_compile_callback(), 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().