Thanks to visit codestin.com
Credit goes to doxygen.postgresql.org

PostgreSQL Source Code git master
lsyscache.c File Reference
#include "postgres.h"
#include "access/hash.h"
#include "access/htup_details.h"
#include "bootstrap/bootstrap.h"
#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "catalog/pg_amop.h"
#include "catalog/pg_amproc.h"
#include "catalog/pg_cast.h"
#include "catalog/pg_class.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_constraint.h"
#include "catalog/pg_database.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_database_name (Oid dbid)
 
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 836 of file lsyscache.c.

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

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

3512{
3513 /* The values[] array was separately palloc'd by deconstruct_array */
3514 if (sslot->values)
3515 pfree(sslot->values);
3516 /* The numbers[] array points into numbers_arr, do not pfree it */
3517 /* Free the detoasted array objects, if any */
3518 if (sslot->values_arr)
3519 pfree(sslot->values_arr);
3520 if (sslot->numbers_arr)
3521 pfree(sslot->numbers_arr);
3522}
void pfree(void *pointer)
Definition: mcxt.c:1594
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 1966 of file lsyscache.c.

1967{
1968 HeapTuple tp;
1969 char result;
1970
1971 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1972 if (!HeapTupleIsValid(tp))
1973 elog(ERROR, "cache lookup failed for function %u", funcid);
1974
1975 result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1976 ReleaseSysCache(tp);
1977 return result;
1978}
#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:264
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:220

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

1929{
1930 HeapTuple tp;
1931 bool result;
1932
1933 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1934 if (!HeapTupleIsValid(tp))
1935 elog(ERROR, "cache lookup failed for function %u", funcid);
1936
1937 result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
1938 ReleaseSysCache(tp);
1939 return result;
1940}

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

3326{
3327 HeapTuple tp;
3328 int32 stawidth;
3329
3331 {
3332 stawidth = (*get_attavgwidth_hook) (relid, attnum);
3333 if (stawidth > 0)
3334 return stawidth;
3335 }
3336 tp = SearchSysCache3(STATRELATTINH,
3337 ObjectIdGetDatum(relid),
3339 BoolGetDatum(false));
3340 if (HeapTupleIsValid(tp))
3341 {
3342 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3343 ReleaseSysCache(tp);
3344 if (stawidth > 0)
3345 return stawidth;
3346 }
3347 return 0;
3348}
int32_t int32
Definition: c.h:535
get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:55
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:182
static Datum BoolGetDatum(bool X)
Definition: postgres.h:112
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:240

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

982{
983 HeapTuple tp;
984 Form_pg_attribute att_tup;
985 char result;
986
987 tp = SearchSysCache2(ATTNUM,
988 ObjectIdGetDatum(relid),
990 if (!HeapTupleIsValid(tp))
991 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
992 attnum, relid);
993 att_tup = (Form_pg_attribute) GETSTRUCT(tp);
994 result = att_tup->attgenerated;
995 ReleaseSysCache(tp);
996 return result;
997}
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:202
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:230

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

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

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

1064{
1065 HeapTuple tuple;
1066 Datum attopts;
1067 Datum result;
1068 bool isnull;
1069
1070 tuple = SearchSysCache2(ATTNUM,
1071 ObjectIdGetDatum(relid),
1073
1074 if (!HeapTupleIsValid(tuple))
1075 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1076 attnum, relid);
1077
1078 attopts = SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions,
1079 &isnull);
1080
1081 if (isnull)
1082 result = (Datum) 0;
1083 else
1084 result = datumCopy(attopts, false, -1); /* text[] */
1085
1086 ReleaseSysCache(tuple);
1087
1088 return result;
1089}
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition: datum.c:132
uint64_t Datum
Definition: postgres.h:70
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:595

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

3403{
3404 Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
3405 int i;
3406 Datum val;
3407 ArrayType *statarray;
3408 Oid arrayelemtype;
3409 int narrayelem;
3410 HeapTuple typeTuple;
3411 Form_pg_type typeForm;
3412
3413 /* initialize *sslot properly */
3414 memset(sslot, 0, sizeof(AttStatsSlot));
3415
3416 for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
3417 {
3418 if ((&stats->stakind1)[i] == reqkind &&
3419 (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
3420 break;
3421 }
3422 if (i >= STATISTIC_NUM_SLOTS)
3423 return false; /* not there */
3424
3425 sslot->staop = (&stats->staop1)[i];
3426 sslot->stacoll = (&stats->stacoll1)[i];
3427
3428 if (flags & ATTSTATSSLOT_VALUES)
3429 {
3430 val = SysCacheGetAttrNotNull(STATRELATTINH, statstuple,
3431 Anum_pg_statistic_stavalues1 + i);
3432
3433 /*
3434 * Detoast the array if needed, and in any case make a copy that's
3435 * under control of this AttStatsSlot.
3436 */
3437 statarray = DatumGetArrayTypePCopy(val);
3438
3439 /*
3440 * Extract the actual array element type, and pass it back in case the
3441 * caller needs it.
3442 */
3443 sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3444
3445 /* Need info about element type */
3446 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
3447 if (!HeapTupleIsValid(typeTuple))
3448 elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3449 typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
3450
3451 /* Deconstruct array into Datum elements; NULLs not expected */
3452 deconstruct_array(statarray,
3453 arrayelemtype,
3454 typeForm->typlen,
3455 typeForm->typbyval,
3456 typeForm->typalign,
3457 &sslot->values, NULL, &sslot->nvalues);
3458
3459 /*
3460 * If the element type is pass-by-reference, we now have a bunch of
3461 * Datums that are pointers into the statarray, so we need to keep
3462 * that until free_attstatsslot. Otherwise, all the useful info is in
3463 * sslot->values[], so we can free the array object immediately.
3464 */
3465 if (!typeForm->typbyval)
3466 sslot->values_arr = statarray;
3467 else
3468 pfree(statarray);
3469
3470 ReleaseSysCache(typeTuple);
3471 }
3472
3473 if (flags & ATTSTATSSLOT_NUMBERS)
3474 {
3475 val = SysCacheGetAttrNotNull(STATRELATTINH, statstuple,
3476 Anum_pg_statistic_stanumbers1 + i);
3477
3478 /*
3479 * Detoast the array if needed, and in any case make a copy that's
3480 * under control of this AttStatsSlot.
3481 */
3482 statarray = DatumGetArrayTypePCopy(val);
3483
3484 /*
3485 * We expect the array to be a 1-D float4 array; verify that. We don't
3486 * need to use deconstruct_array() since the array data is just going
3487 * to look like a C array of float4 values.
3488 */
3489 narrayelem = ARR_DIMS(statarray)[0];
3490 if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3491 ARR_HASNULL(statarray) ||
3492 ARR_ELEMTYPE(statarray) != FLOAT4OID)
3493 elog(ERROR, "stanumbers is not a 1-D float4 array");
3494
3495 /* Give caller a pointer directly into the statarray */
3496 sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3497 sslot->nnumbers = narrayelem;
3498
3499 /* We'll free the statarray in free_attstatsslot */
3500 sslot->numbers_arr = statarray;
3501 }
3502
3503 return true;
3504}
#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:635
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:625

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

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

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

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

3000{
3001 /*
3002 * We loop to find the bottom base type in a stack of domains.
3003 */
3004 for (;;)
3005 {
3006 HeapTuple tup;
3007 Form_pg_type typTup;
3008
3009 tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
3010 if (!HeapTupleIsValid(tup))
3011 break;
3012 typTup = (Form_pg_type) GETSTRUCT(tup);
3013 if (typTup->typtype != TYPTYPE_DOMAIN)
3014 {
3015 /* Not a domain, so stop descending */
3016 Oid result;
3017
3018 /* This test must match get_element_type */
3019 if (IsTrueArrayType(typTup))
3020 result = typTup->typelem;
3021 else
3022 result = InvalidOid;
3023 ReleaseSysCache(tup);
3024 return result;
3025 }
3026
3027 typid = typTup->typbasetype;
3028 ReleaseSysCache(tup);
3029 }
3030
3031 /* Like get_element_type, silently return InvalidOid for bogus input */
3032 return InvalidOid;
3033}

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

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

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

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

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

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

◆ get_constraint_index()

Oid get_constraint_index ( Oid  conoid)

Definition at line 1206 of file lsyscache.c.

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

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

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

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

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

Referenced by AttachPartitionEnsureIndexes(), and RememberConstraintForRebuilding().

◆ get_database_name()

char * get_database_name ( Oid  dbid)

Definition at line 1259 of file lsyscache.c.

1260{
1261 HeapTuple dbtuple;
1262 char *result;
1263
1264 dbtuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbid));
1265 if (HeapTupleIsValid(dbtuple))
1266 {
1267 result = pstrdup(NameStr(((Form_pg_database) GETSTRUCT(dbtuple))->datname));
1268 ReleaseSysCache(dbtuple);
1269 }
1270 else
1271 result = NULL;
1272
1273 return result;
1274}
FormData_pg_database * Form_pg_database
Definition: pg_database.h:96
NameData datname
Definition: pg_database.h:35

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

Referenced by AfterTriggerSetState(), AlterObjectRename_internal(), AlterPublicationOwner_internal(), AlterSchemaOwner_internal(), AlterSubscriptionOwner_internal(), calculate_database_size(), createdb(), CreatePublication(), CreateSchemaCommand(), CreateSubscription(), current_database(), database_to_xml_internal(), DeconstructQualifiedName(), do_analyze_rel(), do_autovacuum(), exec_object_restorecon(), ExpandColumnRefStar(), GetNewMultiXactId(), GetNewTransactionId(), getObjectDescription(), getObjectIdentityParts(), heap_vacuum_rel(), IdentifySystem(), InitTempTableNamespace(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), perform_work_item(), RangeVarGetAndCheckCreationNamespace(), RangeVarGetCreationNamespace(), RangeVarGetRelidExtended(), regdatabaseout(), ReindexMultipleTables(), RenameSchema(), SetMultiXactIdLimit(), SetTransactionIdLimit(), shdepLockAndCheckObject(), TerminateOtherDBBackends(), and transformColumnRef().

◆ get_element_type()

◆ get_equality_op_for_ordering_op()

Oid get_equality_op_for_ordering_op ( Oid  opno,
bool *  reverse 
)

Definition at line 331 of file lsyscache.c.

332{
333 Oid result = InvalidOid;
334 Oid opfamily;
335 Oid opcintype;
336 CompareType cmptype;
337
338 /* Find the operator in pg_amop */
340 &opfamily, &opcintype, &cmptype))
341 {
342 /* Found a suitable opfamily, get matching equality operator */
343 result = get_opfamily_member_for_cmptype(opfamily,
344 opcintype,
345 opcintype,
346 COMPARE_EQ);
347 if (reverse)
348 *reverse = (cmptype == COMPARE_GT);
349 }
350
351 return result;
352}
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:266
Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
Definition: lsyscache.c:197

References COMPARE_EQ, COMPARE_GT, get_opfamily_member_for_cmptype(), get_ordering_op_properties(), and InvalidOid.

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

◆ get_func_leakproof()

bool get_func_leakproof ( Oid  funcid)

Definition at line 2004 of file lsyscache.c.

2005{
2006 HeapTuple tp;
2007 bool result;
2008
2009 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
2010 if (!HeapTupleIsValid(tp))
2011 elog(ERROR, "cache lookup failed for function %u", funcid);
2012
2013 result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
2014 ReleaseSysCache(tp);
2015 return result;
2016}

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

1800{
1801 HeapTuple tp;
1802
1803 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1804 if (HeapTupleIsValid(tp))
1805 {
1806 Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1807 Oid result;
1808
1809 result = functup->pronamespace;
1810 ReleaseSysCache(tp);
1811 return result;
1812 }
1813 else
1814 return InvalidOid;
1815}

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

1842{
1843 HeapTuple tp;
1844 int result;
1845
1846 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1847 if (!HeapTupleIsValid(tp))
1848 elog(ERROR, "cache lookup failed for function %u", funcid);
1849
1850 result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1851 ReleaseSysCache(tp);
1852 return result;
1853}
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 1985 of file lsyscache.c.

1986{
1987 HeapTuple tp;
1988 char result;
1989
1990 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1991 if (!HeapTupleIsValid(tp))
1992 elog(ERROR, "cache lookup failed for function %u", funcid);
1993
1994 result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
1995 ReleaseSysCache(tp);
1996 return result;
1997}

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

1910{
1911 HeapTuple tp;
1912 bool result;
1913
1914 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1915 if (!HeapTupleIsValid(tp))
1916 elog(ERROR, "cache lookup failed for function %u", funcid);
1917
1918 result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
1919 ReleaseSysCache(tp);
1920 return result;
1921}

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

1864{
1865 HeapTuple tp;
1866 Form_pg_proc procstruct;
1867 Oid result;
1868
1869 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1870 if (!HeapTupleIsValid(tp))
1871 elog(ERROR, "cache lookup failed for function %u", funcid);
1872
1873 procstruct = (Form_pg_proc) GETSTRUCT(tp);
1874
1875 result = procstruct->prorettype;
1876 *nargs = (int) procstruct->pronargs;
1877 Assert(*nargs == procstruct->proargtypes.dim1);
1878 *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1879 memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1880
1881 ReleaseSysCache(tp);
1882 return result;
1883}
Assert(PointerIsAligned(start, uint64))
void * palloc(Size size)
Definition: mcxt.c:1365

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

2026{
2027 HeapTuple tp;
2028
2029 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
2030 if (HeapTupleIsValid(tp))
2031 {
2032 Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
2033 RegProcedure result;
2034
2035 result = functup->prosupport;
2036 ReleaseSysCache(tp);
2037 return result;
2038 }
2039 else
2040 return (RegProcedure) InvalidOid;
2041}
regproc RegProcedure
Definition: c.h:656

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

1891{
1892 HeapTuple tp;
1893 Oid result;
1894
1895 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1896 if (!HeapTupleIsValid(tp))
1897 elog(ERROR, "cache lookup failed for function %u", funcid);
1898
1899 result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
1900 ReleaseSysCache(tp);
1901 return result;
1902}

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

3680{
3681 HeapTuple tuple;
3682 Form_pg_index rd_index;
3683 Datum datum;
3684 oidvector *indclass;
3685 Oid opclass;
3686
3687 /* First we need to know the column's opclass. */
3688
3689 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3690 if (!HeapTupleIsValid(tuple))
3691 return InvalidOid;
3692
3693 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3694
3695 /* caller is supposed to guarantee this */
3696 Assert(attno > 0 && attno <= rd_index->indnatts);
3697
3698 /* Non-key attributes don't have an opclass */
3699 if (attno > rd_index->indnkeyatts)
3700 {
3701 ReleaseSysCache(tuple);
3702 return InvalidOid;
3703 }
3704
3705 datum = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
3706 indclass = ((oidvector *) DatumGetPointer(datum));
3707
3708 Assert(attno <= indclass->dim1);
3709 opclass = indclass->values[attno - 1];
3710
3711 ReleaseSysCache(tuple);
3712
3713 return opclass;
3714}
FormData_pg_index * Form_pg_index
Definition: pg_index.h:70
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:322
Definition: c.h:732
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition: c.h:739

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

3769{
3770 bool isclustered;
3771 HeapTuple tuple;
3772 Form_pg_index rd_index;
3773
3774 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3775 if (!HeapTupleIsValid(tuple))
3776 elog(ERROR, "cache lookup failed for index %u", index_oid);
3777
3778 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3779 isclustered = rd_index->indisclustered;
3780 ReleaseSysCache(tuple);
3781
3782 return isclustered;
3783}

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

3723{
3724 HeapTuple tuple;
3725 Form_pg_index rd_index;
3726 bool result;
3727
3728 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3729 if (!HeapTupleIsValid(tuple))
3730 return false;
3731
3732 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3733 result = rd_index->indisreplident;
3734 ReleaseSysCache(tuple);
3735
3736 return result;
3737}

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

Referenced by RememberReplicaIdentityForRebuilding().

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3745 of file lsyscache.c.

3746{
3747 bool isvalid;
3748 HeapTuple tuple;
3749 Form_pg_index rd_index;
3750
3751 tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3752 if (!HeapTupleIsValid(tuple))
3753 elog(ERROR, "cache lookup failed for index %u", index_oid);
3754
3755 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3756 isvalid = rd_index->indisvalid;
3757 ReleaseSysCache(tuple);
3758
3759 return isvalid;
3760}

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

1281{
1282 HeapTuple tp;
1283
1284 tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
1285 if (HeapTupleIsValid(tp))
1286 {
1288 char *result;
1289
1290 result = pstrdup(NameStr(lantup->lanname));
1291 ReleaseSysCache(tp);
1292 return result;
1293 }
1294
1295 if (!missing_ok)
1296 elog(ERROR, "cache lookup failed for language %u",
1297 langoid);
1298 return NULL;
1299}
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 435 of file lsyscache.c.

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

3651{
3652 HeapTuple tp;
3653
3654 tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
3655 if (HeapTupleIsValid(tp))
3656 {
3657 Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3658 Oid result;
3659
3660 result = rngtup->rngtypid;
3661 ReleaseSysCache(tp);
3662 return result;
3663 }
3664 else
3665 return InvalidOid;
3666}
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 3533 of file lsyscache.c.

3534{
3535 HeapTuple tp;
3536
3537 tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid));
3538 if (HeapTupleIsValid(tp))
3539 {
3541 char *result;
3542
3543 result = pstrdup(NameStr(nsptup->nspname));
3544 ReleaseSysCache(tp);
3545 return result;
3546 }
3547 else
3548 return NULL;
3549}
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(), obtain_object_name_namespace(), 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 1700 of file lsyscache.c.

1701{
1702 HeapTuple tp;
1703
1704 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1705 if (HeapTupleIsValid(tp))
1706 {
1708 Oid result;
1709
1710 result = optup->oprnegate;
1711 ReleaseSysCache(tp);
1712 return result;
1713 }
1714 else
1715 return InvalidOid;
1716}

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

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

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

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

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

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

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

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

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

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

1501{
1502 HeapTuple tp;
1503
1504 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1505 if (HeapTupleIsValid(tp))
1506 {
1508 Oid result;
1509
1510 result = optup->oprresult;
1511 ReleaseSysCache(tp);
1512 return result;
1513 }
1514 else
1515 return InvalidOid;
1516}

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

1310{
1311 HeapTuple tp;
1312 Form_pg_opclass cla_tup;
1313 Oid result;
1314
1315 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1316 if (!HeapTupleIsValid(tp))
1317 elog(ERROR, "cache lookup failed for opclass %u", opclass);
1318 cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1319
1320 result = cla_tup->opcfamily;
1321 ReleaseSysCache(tp);
1322 return result;
1323}
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 1331 of file lsyscache.c.

1332{
1333 HeapTuple tp;
1334 Form_pg_opclass cla_tup;
1335 Oid result;
1336
1337 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1338 if (!HeapTupleIsValid(tp))
1339 elog(ERROR, "cache lookup failed for opclass %u", opclass);
1340 cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1341
1342 result = cla_tup->opcintype;
1343 ReleaseSysCache(tp);
1344 return result;
1345}

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

1380{
1381 HeapTuple tp;
1382 Form_pg_opclass cla_tup;
1383 Oid result;
1384
1385 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1386 if (!HeapTupleIsValid(tp))
1387 elog(ERROR, "cache lookup failed for opclass %u", opclass);
1388 cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1389
1390 result = cla_tup->opcmethod;
1391 ReleaseSysCache(tp);
1392 return result;
1393}

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

1355{
1356 HeapTuple tp;
1357 Form_pg_opclass cla_tup;
1358
1359 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1360 if (!HeapTupleIsValid(tp))
1361 return false;
1362
1363 cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1364
1365 *opfamily = cla_tup->opcfamily;
1366 *opcintype = cla_tup->opcintype;
1367
1368 ReleaseSysCache(tp);
1369
1370 return true;
1371}

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

1453{
1454 HeapTuple tp;
1455
1456 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1457 if (HeapTupleIsValid(tp))
1458 {
1460 RegProcedure result;
1461
1462 result = optup->oprcode;
1463 ReleaseSysCache(tp);
1464 return result;
1465 }
1466 else
1467 return (RegProcedure) InvalidOid;
1468}

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

199{
200 Oid opmethod;
201 StrategyNumber strategy;
202
203 opmethod = get_opfamily_method(opfamily);
204 strategy = IndexAmTranslateCompareType(cmptype, opmethod, opfamily, true);
205 if (!strategy)
206 return InvalidOid;
207 return get_opfamily_member(opfamily, lefttype, righttype, strategy);
208}
StrategyNumber IndexAmTranslateCompareType(CompareType cmptype, Oid amoid, Oid opfamily, bool missing_ok)
Definition: amapi.c:161
Oid get_opfamily_method(Oid opfid)
Definition: lsyscache.c:1403
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 1403 of file lsyscache.c.

1404{
1405 HeapTuple tp;
1406 Form_pg_opfamily opfform;
1407 Oid result;
1408
1409 tp = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfid));
1410 if (!HeapTupleIsValid(tp))
1411 elog(ERROR, "cache lookup failed for operator family %u", opfid);
1412 opfform = (Form_pg_opfamily) GETSTRUCT(tp);
1413
1414 result = opfform->opfmethod;
1415 ReleaseSysCache(tp);
1416 return result;
1417}
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 1420 of file lsyscache.c.

1421{
1422 HeapTuple tup;
1423 char *opfname;
1424 Form_pg_opfamily opfform;
1425
1426 tup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfid));
1427
1428 if (!HeapTupleIsValid(tup))
1429 {
1430 if (!missing_ok)
1431 elog(ERROR, "cache lookup failed for operator family %u", opfid);
1432 return NULL;
1433 }
1434
1435 opfform = (Form_pg_opfamily) GETSTRUCT(tup);
1436 opfname = pstrdup(NameStr(opfform->opfname));
1437
1438 ReleaseSysCache(tup);
1439
1440 return opfname;
1441}

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

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

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

1478{
1479 HeapTuple tp;
1480
1481 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1482 if (HeapTupleIsValid(tp))
1483 {
1485 char *result;
1486
1487 result = pstrdup(NameStr(optup->oprname));
1488 ReleaseSysCache(tp);
1489 return result;
1490 }
1491 else
1492 return NULL;
1493}

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

1749{
1750 HeapTuple tp;
1751
1752 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1753 if (HeapTupleIsValid(tp))
1754 {
1756 RegProcedure result;
1757
1758 result = optup->oprjoin;
1759 ReleaseSysCache(tp);
1760 return result;
1761 }
1762 else
1763 return (RegProcedure) InvalidOid;
1764}

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

Referenced by join_selectivity(), and scalararraysel().

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1724 of file lsyscache.c.

1725{
1726 HeapTuple tp;
1727
1728 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1729 if (HeapTupleIsValid(tp))
1730 {
1732 RegProcedure result;
1733
1734 result = optup->oprrest;
1735 ReleaseSysCache(tp);
1736 return result;
1737 }
1738 else
1739 return (RegProcedure) InvalidOid;
1740}

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

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

◆ get_ordering_op_properties()

bool get_ordering_op_properties ( Oid  opno,
Oid opfamily,
Oid opcintype,
CompareType cmptype 
)

Definition at line 266 of file lsyscache.c.

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

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

2979{
2980 Oid array_type = get_array_type(typid);
2981
2982 if (OidIsValid(array_type))
2983 return array_type;
2984 if (OidIsValid(get_element_type(typid)))
2985 return typid;
2986 return InvalidOid;
2987}
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2926
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2954

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

3813{
3814 HeapTuple tup;
3815 char *pubname;
3816 Form_pg_publication pubform;
3817
3818 tup = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pubid));
3819
3820 if (!HeapTupleIsValid(tup))
3821 {
3822 if (!missing_ok)
3823 elog(ERROR, "cache lookup failed for publication %u", pubid);
3824 return NULL;
3825 }
3826
3827 pubform = (Form_pg_publication) GETSTRUCT(tup);
3828 pubname = pstrdup(NameStr(pubform->pubname));
3829
3830 ReleaseSysCache(tup);
3831
3832 return pubname;
3833}
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 3792 of file lsyscache.c.

3793{
3794 Oid oid;
3795
3796 oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
3797 CStringGetDatum(pubname));
3798 if (!OidIsValid(oid) && !missing_ok)
3799 ereport(ERROR,
3800 (errcode(ERRCODE_UNDEFINED_OBJECT),
3801 errmsg("publication \"%s\" does not exist", pubname)));
3802 return oid;
3803}
static Datum CStringGetDatum(const char *X)
Definition: postgres.h:360
#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 3600 of file lsyscache.c.

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

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

Referenced by CheckAttributeType().

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

Definition at line 3625 of file lsyscache.c.

3626{
3627 HeapTuple tp;
3628
3629 tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3630 if (HeapTupleIsValid(tp))
3631 {
3632 Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3633 Oid result;
3634
3635 result = rngtup->rngmultitypid;
3636 ReleaseSysCache(tp);
3637 return result;
3638 }
3639 else
3640 return InvalidOid;
3641}

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

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

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

2096{
2097 HeapTuple tp;
2098
2099 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2100 if (HeapTupleIsValid(tp))
2101 {
2102 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2103 char *result;
2104
2105 result = pstrdup(NameStr(reltup->relname));
2106 ReleaseSysCache(tp);
2107 return result;
2108 }
2109 else
2110 return NULL;
2111}
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(), refuseDupeIndexAttach(), reindex_index(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), RememberClusterOnForRebuilding(), RememberReplicaIdentityForRebuilding(), RemoveSubscriptionRel(), RenameConstraintById(), renametrig(), satisfies_hash_partition(), set_rtable_names(), show_modifytable_info(), subquery_planner(), swap_relation_files(), SysCacheGetAttrNotNull(), table_to_xml_internal(), TargetPrivilegesCheck(), transformAlterTableStmt(), and verifyNotNullPKCompatible().

◆ get_rel_namespace()

◆ get_rel_persistence()

char get_rel_persistence ( Oid  relid)

Definition at line 2245 of file lsyscache.c.

2246{
2247 HeapTuple tp;
2248 Form_pg_class reltup;
2249 char result;
2250
2251 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2252 if (!HeapTupleIsValid(tp))
2253 elog(ERROR, "cache lookup failed for relation %u", relid);
2254 reltup = (Form_pg_class) GETSTRUCT(tp);
2255 result = reltup->relpersistence;
2256 ReleaseSysCache(tp);
2257
2258 return result;
2259}

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

2268{
2269 HeapTuple tp;
2270 Form_pg_class reltup;
2271 Oid result;
2272
2273 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2274 if (!HeapTupleIsValid(tp))
2275 elog(ERROR, "cache lookup failed for relation %u", relid);
2276 reltup = (Form_pg_class) GETSTRUCT(tp);
2277 result = reltup->relam;
2278 ReleaseSysCache(tp);
2279
2280 return result;
2281}

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

Referenced by DefineRelation().

◆ get_rel_relispartition()

bool get_rel_relispartition ( 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 bool result;
2203
2204 result = reltup->relispartition;
2205 ReleaseSysCache(tp);
2206 return result;
2207 }
2208 else
2209 return false;
2210}

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

2171{
2172 HeapTuple tp;
2173
2174 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2175 if (HeapTupleIsValid(tp))
2176 {
2177 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2178 char result;
2179
2180 result = reltup->relkind;
2181 ReleaseSysCache(tp);
2182 return result;
2183 }
2184 else
2185 return '\0';
2186}

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

2222{
2223 HeapTuple tp;
2224
2225 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2226 if (HeapTupleIsValid(tp))
2227 {
2228 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2229 Oid result;
2230
2231 result = reltup->reltablespace;
2232 ReleaseSysCache(tp);
2233 return result;
2234 }
2235 else
2236 return InvalidOid;
2237}

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

2147{
2148 HeapTuple tp;
2149
2150 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2151 if (HeapTupleIsValid(tp))
2152 {
2153 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2154 Oid result;
2155
2156 result = reltup->reltype;
2157 ReleaseSysCache(tp);
2158 return result;
2159 }
2160 else
2161 return InvalidOid;
2162}

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

3863{
3864 HeapTuple tup;
3865 char *subname;
3866 Form_pg_subscription subform;
3867
3868 tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
3869
3870 if (!HeapTupleIsValid(tup))
3871 {
3872 if (!missing_ok)
3873 elog(ERROR, "cache lookup failed for subscription %u", subid);
3874 return NULL;
3875 }
3876
3877 subform = (Form_pg_subscription) GETSTRUCT(tup);
3878 subname = pstrdup(NameStr(subform->subname));
3879
3880 ReleaseSysCache(tup);
3881
3882 return subname;
3883}
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 3842 of file lsyscache.c.

3843{
3844 Oid oid;
3845
3846 oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
3848 if (!OidIsValid(oid) && !missing_ok)
3849 ereport(ERROR,
3850 (errcode(ERRCODE_UNDEFINED_OBJECT),
3851 errmsg("subscription \"%s\" does not exist", subname)));
3852 return oid;
3853}
Oid MyDatabaseId
Definition: globals.c:94

References CStringGetDatum(), ereport, errcode(), errmsg(), ERROR, GetSysCacheOid2, MyDatabaseId, ObjectIdGetDatum(), 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 2287 of file lsyscache.c.

2288{
2289 HeapTuple tup;
2290
2291 if (!list_member_oid(trftypes, typid))
2292 return InvalidOid;
2293
2294 tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
2295 ObjectIdGetDatum(langid));
2296 if (HeapTupleIsValid(tup))
2297 {
2298 Oid funcid;
2299
2300 funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2301 ReleaseSysCache(tup);
2302 return funcid;
2303 }
2304 else
2305 return InvalidOid;
2306}
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 2309 of file lsyscache.c.

2310{
2311 HeapTuple tup;
2312
2313 if (!list_member_oid(trftypes, typid))
2314 return InvalidOid;
2315
2316 tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
2317 ObjectIdGetDatum(langid));
2318 if (HeapTupleIsValid(tup))
2319 {
2320 Oid funcid;
2321
2322 funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
2323 ReleaseSysCache(tup);
2324 return funcid;
2325 }
2326 else
2327 return InvalidOid;
2328}

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

2899{
2900 HeapTuple tp;
2901
2902 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2903 if (HeapTupleIsValid(tp))
2904 {
2905 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2906 Oid result;
2907
2908 result = typtup->typrelid;
2909 ReleaseSysCache(tp);
2910 return result;
2911 }
2912 else
2913 return InvalidOid;
2914}

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

2746{
2747 int typlen = get_typlen(typid);
2748 int32 maxwidth;
2749
2750 /*
2751 * Easy if it's a fixed-width type
2752 */
2753 if (typlen > 0)
2754 return typlen;
2755
2756 /*
2757 * type_maximum_size knows the encoding of typmod for some datatypes;
2758 * don't duplicate that knowledge here.
2759 */
2760 maxwidth = type_maximum_size(typid, typmod);
2761 if (maxwidth > 0)
2762 {
2763 /*
2764 * For BPCHAR, the max width is also the only width. Otherwise we
2765 * need to guess about the typical data width given the max. A sliding
2766 * scale for percentage of max width seems reasonable.
2767 */
2768 if (typid == BPCHAROID)
2769 return maxwidth;
2770 if (maxwidth <= 32)
2771 return maxwidth; /* assume full width */
2772 if (maxwidth < 1000)
2773 return 32 + (maxwidth - 32) / 2; /* assume 50% */
2774
2775 /*
2776 * Beyond 1000, assume we're looking at something like
2777 * "varchar(10000)" where the limit isn't actually reached often, and
2778 * use a fixed estimate.
2779 */
2780 return 32 + (1000 - 32) / 2;
2781 }
2782
2783 /*
2784 * Oops, we have no idea ... wild guess time.
2785 */
2786 return 32;
2787}
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:412
int16 get_typlen(Oid typid)
Definition: lsyscache.c:2364

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

2390{
2391 HeapTuple tp;
2392
2393 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2394 if (HeapTupleIsValid(tp))
2395 {
2396 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2397 bool result;
2398
2399 result = typtup->typbyval;
2400 ReleaseSysCache(tp);
2401 return result;
2402 }
2403 else
2404 return false;
2405}

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

2616{
2617 HeapTuple typeTuple;
2619 Datum datum;
2620 bool isNull;
2621 Node *expr;
2622
2623 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2624 if (!HeapTupleIsValid(typeTuple))
2625 elog(ERROR, "cache lookup failed for type %u", typid);
2626 type = (Form_pg_type) GETSTRUCT(typeTuple);
2627
2628 /*
2629 * typdefault and typdefaultbin are potentially null, so don't try to
2630 * access 'em as struct fields. Must do it the hard way with
2631 * SysCacheGetAttr.
2632 */
2633 datum = SysCacheGetAttr(TYPEOID,
2634 typeTuple,
2635 Anum_pg_type_typdefaultbin,
2636 &isNull);
2637
2638 if (!isNull)
2639 {
2640 /* We have an expression default */
2641 expr = stringToNode(TextDatumGetCString(datum));
2642 }
2643 else
2644 {
2645 /* Perhaps we have a plain literal default */
2646 datum = SysCacheGetAttr(TYPEOID,
2647 typeTuple,
2648 Anum_pg_type_typdefault,
2649 &isNull);
2650
2651 if (!isNull)
2652 {
2653 char *strDefaultVal;
2654
2655 /* Convert text datum to C string */
2656 strDefaultVal = TextDatumGetCString(datum);
2657 /* Convert C string to a value of the given type */
2658 datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2659 getTypeIOParam(typeTuple), -1);
2660 /* Build a Const node containing the value */
2661 expr = (Node *) makeConst(typid,
2662 -1,
2663 type->typcollation,
2664 type->typlen,
2665 datum,
2666 false,
2667 type->typbyval);
2668 pfree(strDefaultVal);
2669 }
2670 else
2671 {
2672 /* No default */
2673 expr = NULL;
2674 }
2675 }
2676
2677 ReleaseSysCache(typeTuple);
2678
2679 return expr;
2680}
#define TextDatumGetCString(d)
Definition: builtins.h:98
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1753
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2470
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 2877 of file lsyscache.c.

2878{
2879 HeapTuple tp;
2880 Form_pg_type typtup;
2881
2882 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2883 if (!HeapTupleIsValid(tp))
2884 elog(ERROR, "cache lookup failed for type %u", typid);
2885 typtup = (Form_pg_type) GETSTRUCT(tp);
2886 *typcategory = typtup->typcategory;
2887 *typispreferred = typtup->typispreferred;
2888 ReleaseSysCache(tp);
2889}

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

2500{
2501 HeapTuple typeTuple;
2502 Form_pg_type typeStruct;
2503
2504 /*
2505 * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2506 * use array_in and array_out during bootstrap.
2507 */
2509 {
2510 Oid typinput;
2511 Oid typoutput;
2512
2514 typlen,
2515 typbyval,
2516 typalign,
2517 typdelim,
2518 typioparam,
2519 &typinput,
2520 &typoutput);
2521 switch (which_func)
2522 {
2523 case IOFunc_input:
2524 *func = typinput;
2525 break;
2526 case IOFunc_output:
2527 *func = typoutput;
2528 break;
2529 default:
2530 elog(ERROR, "binary I/O not supported during bootstrap");
2531 break;
2532 }
2533 return;
2534 }
2535
2536 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2537 if (!HeapTupleIsValid(typeTuple))
2538 elog(ERROR, "cache lookup failed for type %u", typid);
2539 typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2540
2541 *typlen = typeStruct->typlen;
2542 *typbyval = typeStruct->typbyval;
2543 *typalign = typeStruct->typalign;
2544 *typdelim = typeStruct->typdelim;
2545 *typioparam = getTypeIOParam(typeTuple);
2546 switch (which_func)
2547 {
2548 case IOFunc_input:
2549 *func = typeStruct->typinput;
2550 break;
2551 case IOFunc_output:
2552 *func = typeStruct->typoutput;
2553 break;
2554 case IOFunc_receive:
2555 *func = typeStruct->typreceive;
2556 break;
2557 case IOFunc_send:
2558 *func = typeStruct->typsend;
2559 break;
2560 }
2561 ReleaseSysCache(typeTuple);
2562}
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:839
@ 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 2340 of file lsyscache.c.

2341{
2342 HeapTuple tp;
2343
2344 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2345 if (HeapTupleIsValid(tp))
2346 {
2347 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2348 bool result;
2349
2350 result = typtup->typisdefined;
2351 ReleaseSysCache(tp);
2352 return result;
2353 }
2354 else
2355 return false;
2356}

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

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

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2364 of file lsyscache.c.

2365{
2366 HeapTuple tp;
2367
2368 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2369 if (HeapTupleIsValid(tp))
2370 {
2371 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2372 int16 result;
2373
2374 result = typtup->typlen;
2375 ReleaseSysCache(tp);
2376 return result;
2377 }
2378 else
2379 return 0;
2380}
int16_t int16
Definition: c.h:534

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

◆ get_typlenbyval()

◆ get_typlenbyvalalign()

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 3173 of file lsyscache.c.

3174{
3175 HeapTuple tp;
3176
3177 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
3178 if (HeapTupleIsValid(tp))
3179 {
3180 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
3181 Oid result;
3182
3183 result = typtup->typmodin;
3184 ReleaseSysCache(tp);
3185 return result;
3186 }
3187 else
3188 return InvalidOid;
3189}

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2586 of file lsyscache.c.

2587{
2588 HeapTuple tp;
2589
2590 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2591 if (HeapTupleIsValid(tp))
2592 {
2593 Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2594 char result;
2595
2596 result = typtup->typstorage;
2597 ReleaseSysCache(tp);
2598 return result;
2599 }
2600 else
2601 return TYPSTORAGE_PLAIN;
2602}

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

Referenced by GetAttributeStorage().

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3264 of file lsyscache.c.

3265{
3266 HeapTuple tp;
3267
3268 tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
3269 if (HeapTupleIsValid(tp))
3270 {
3271 Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
3272 RegProcedure handler = typform->typsubscript;
3273
3274 if (typelemp)
3275 *typelemp = typform->typelem;
3276 ReleaseSysCache(tp);
3277 return handler;
3278 }
3279 else
3280 {
3281 if (typelemp)
3282 *typelemp = InvalidOid;
3283 return InvalidOid;
3284 }
3285}

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

2706{
2707 /*
2708 * We loop to find the bottom base type in a stack of domains.
2709 */
2710 for (;;)
2711 {
2712 HeapTuple tup;
2713 Form_pg_type typTup;
2714
2715 tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2716 if (!HeapTupleIsValid(tup))
2717 elog(ERROR, "cache lookup failed for type %u", typid);
2718 typTup = (Form_pg_type) GETSTRUCT(tup);
2719 if (typTup->typtype != TYPTYPE_DOMAIN)
2720 {
2721 /* Not a domain, so done */
2722 ReleaseSysCache(tup);
2723 break;
2724 }
2725
2726 Assert(*typmod == -1);
2727 typid = typTup->typbasetype;
2728 *typmod = typTup->typtypmod;
2729
2730 ReleaseSysCache(tup);
2731 }
2732
2733 return typid;
2734}

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

3298{
3299 RegProcedure typsubscript = get_typsubscript(typid, typelemp);
3300
3301 if (!OidIsValid(typsubscript))
3302 return NULL;
3303
3304 return (const struct SubscriptRoutines *)
3305 DatumGetPointer(OidFunctionCall0(typsubscript));
3306}
#define OidFunctionCall0(functionId)
Definition: fmgr.h:718
RegProcedure get_typsubscript(Oid typid, Oid *typelemp)
Definition: lsyscache.c:3264

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

3108{
3109 HeapTuple typeTuple;
3110 Form_pg_type pt;
3111
3112 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
3113 if (!HeapTupleIsValid(typeTuple))
3114 elog(ERROR, "cache lookup failed for type %u", type);
3115 pt = (Form_pg_type) GETSTRUCT(typeTuple);
3116
3117 if (!pt->typisdefined)
3118 ereport(ERROR,
3119 (errcode(ERRCODE_UNDEFINED_OBJECT),
3120 errmsg("type %s is only a shell",
3121 format_type_be(type))));
3122 if (!OidIsValid(pt->typreceive))
3123 ereport(ERROR,
3124 (errcode(ERRCODE_UNDEFINED_FUNCTION),
3125 errmsg("no binary input function available for type %s",
3126 format_type_be(type))));
3127
3128 *typReceive = pt->typreceive;
3129 *typIOParam = getTypeIOParam(typeTuple);
3130
3131 ReleaseSysCache(typeTuple);
3132}

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

3141{
3142 HeapTuple typeTuple;
3143 Form_pg_type pt;
3144
3145 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
3146 if (!HeapTupleIsValid(typeTuple))
3147 elog(ERROR, "cache lookup failed for type %u", type);
3148 pt = (Form_pg_type) GETSTRUCT(typeTuple);
3149
3150 if (!pt->typisdefined)
3151 ereport(ERROR,
3152 (errcode(ERRCODE_UNDEFINED_OBJECT),
3153 errmsg("type %s is only a shell",
3154 format_type_be(type))));
3155 if (!OidIsValid(pt->typsend))
3156 ereport(ERROR,
3157 (errcode(ERRCODE_UNDEFINED_FUNCTION),
3158 errmsg("no binary output function available for type %s",
3159 format_type_be(type))));
3160
3161 *typSend = pt->typsend;
3162 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
3163
3164 ReleaseSysCache(typeTuple);
3165}

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

3042{
3043 HeapTuple typeTuple;
3044 Form_pg_type pt;
3045
3046 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
3047 if (!HeapTupleIsValid(typeTuple))
3048 elog(ERROR, "cache lookup failed for type %u", type);
3049 pt = (Form_pg_type) GETSTRUCT(typeTuple);
3050
3051 if (!pt->typisdefined)
3052 ereport(ERROR,
3053 (errcode(ERRCODE_UNDEFINED_OBJECT),
3054 errmsg("type %s is only a shell",
3055 format_type_be(type))));
3056 if (!OidIsValid(pt->typinput))
3057 ereport(ERROR,
3058 (errcode(ERRCODE_UNDEFINED_FUNCTION),
3059 errmsg("no input function available for type %s",
3060 format_type_be(type))));
3061
3062 *typInput = pt->typinput;
3063 *typIOParam = getTypeIOParam(typeTuple);
3064
3065 ReleaseSysCache(typeTuple);
3066}

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

2471{
2472 Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2473
2474 /*
2475 * Array types get their typelem as parameter; everybody else gets their
2476 * own type OID as parameter.
2477 */
2478 if (OidIsValid(typeStruct->typelem))
2479 return typeStruct->typelem;
2480 else
2481 return typeStruct->oid;
2482}

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

3075{
3076 HeapTuple typeTuple;
3077 Form_pg_type pt;
3078
3079 typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
3080 if (!HeapTupleIsValid(typeTuple))
3081 elog(ERROR, "cache lookup failed for type %u", type);
3082 pt = (Form_pg_type) GETSTRUCT(typeTuple);
3083
3084 if (!pt->typisdefined)
3085 ereport(ERROR,
3086 (errcode(ERRCODE_UNDEFINED_OBJECT),
3087 errmsg("type %s is only a shell",
3088 format_type_be(type))));
3089 if (!OidIsValid(pt->typoutput))
3090 ereport(ERROR,
3091 (errcode(ERRCODE_UNDEFINED_FUNCTION),
3092 errmsg("no output function available for type %s",
3093 format_type_be(type))));
3094
3095 *typOutput = pt->typoutput;
3096 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
3097
3098 ReleaseSysCache(typeTuple);
3099}

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

1605{
1606 bool result = false;
1607 HeapTuple tp;
1608 TypeCacheEntry *typentry;
1609
1610 /* As in op_mergejoinable, let the typcache handle the hard cases */
1611 if (opno == ARRAY_EQ_OP)
1612 {
1613 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1614 if (typentry->hash_proc == F_HASH_ARRAY)
1615 result = true;
1616 }
1617 else if (opno == RECORD_EQ_OP)
1618 {
1619 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1620 if (typentry->hash_proc == F_HASH_RECORD)
1621 result = true;
1622 }
1623 else
1624 {
1625 /* For all other operators, rely on pg_operator.oprcanhash */
1626 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1627 if (HeapTupleIsValid(tp))
1628 {
1630
1631 result = optup->oprcanhash;
1632 ReleaseSysCache(tp);
1633 }
1634 }
1635 return result;
1636}
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()

bool op_in_opfamily ( Oid  opno,
Oid  opfamily 
)

◆ op_input_types()

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

Definition at line 1525 of file lsyscache.c.

1526{
1527 HeapTuple tp;
1528 Form_pg_operator optup;
1529
1530 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1531 if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1532 elog(ERROR, "cache lookup failed for operator %u", opno);
1533 optup = (Form_pg_operator) GETSTRUCT(tp);
1534 *lefttype = optup->oprleft;
1535 *righttype = optup->oprright;
1536 ReleaseSysCache(tp);
1537}

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

1554{
1555 bool result = false;
1556 HeapTuple tp;
1557 TypeCacheEntry *typentry;
1558
1559 /*
1560 * For array_eq or record_eq, we can sort if the element or field types
1561 * are all sortable. We could implement all the checks for that here, but
1562 * the typcache already does that and caches the results too, so let's
1563 * rely on the typcache.
1564 */
1565 if (opno == ARRAY_EQ_OP)
1566 {
1567 typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1568 if (typentry->cmp_proc == F_BTARRAYCMP)
1569 result = true;
1570 }
1571 else if (opno == RECORD_EQ_OP)
1572 {
1573 typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1574 if (typentry->cmp_proc == F_BTRECORDCMP)
1575 result = true;
1576 }
1577 else
1578 {
1579 /* For all other operators, rely on pg_operator.oprcanmerge */
1580 tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
1581 if (HeapTupleIsValid(tp))
1582 {
1584
1585 result = optup->oprcanmerge;
1586 ReleaseSysCache(tp);
1587 }
1588 }
1589 return result;
1590}
#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 1644 of file lsyscache.c.

1645{
1646 RegProcedure funcid = get_opcode(opno);
1647
1648 if (funcid == (RegProcedure) InvalidOid)
1649 elog(ERROR, "operator %u does not exist", opno);
1650
1651 return func_strict((Oid) funcid);
1652}
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1452
bool func_strict(Oid funcid)
Definition: lsyscache.c:1928

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

1661{
1662 RegProcedure funcid = get_opcode(opno);
1663
1664 if (funcid == (RegProcedure) InvalidOid)
1665 elog(ERROR, "operator %u does not exist", opno);
1666
1667 return func_volatile((Oid) funcid);
1668}
char func_volatile(Oid funcid)
Definition: lsyscache.c:1947

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

2846{
2847 return (get_typtype(typid) == TYPTYPE_ENUM);
2848}
char get_typtype(Oid typid)
Definition: lsyscache.c:2796

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

2866{
2867 return (get_typtype(typid) == TYPTYPE_MULTIRANGE);
2868}

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

2856{
2857 return (get_typtype(typid) == TYPTYPE_RANGE);
2858}

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

2823{
2824 if (typid == RECORDOID)
2825 return true; /* easy case */
2826 switch (get_typtype(typid))
2827 {
2828 case TYPTYPE_COMPOSITE:
2829 return true;
2830 case TYPTYPE_DOMAIN:
2831 if (get_typtype(getBaseType(typid)) == TYPTYPE_COMPOSITE)
2832 return true;
2833 break;
2834 default:
2835 break;
2836 }
2837 return false;
2838}
Oid getBaseType(Oid typid)
Definition: lsyscache.c:2688

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

Referenced by get_attavgwidth().