PostgreSQL Source Code git master
lsyscache.h File Reference
#include "access/attnum.h"
#include "access/cmptype.h"
#include "access/htup.h"
#include "nodes/pg_list.h"
Include dependency graph for lsyscache.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  OpIndexInterpretation
 
struct  AttStatsSlot
 

Macros

#define ATTSTATSSLOT_VALUES   0x01
 
#define ATTSTATSSLOT_NUMBERS   0x02
 
#define type_is_array(typid)   (get_element_type(typid) != InvalidOid)
 
#define type_is_array_domain(typid)   (get_base_element_type(typid) != InvalidOid)
 
#define TypeIsToastable(typid)   (get_typstorage(typid) != TYPSTORAGE_PLAIN)
 

Typedefs

typedef struct SubscriptRoutines SubscriptRoutines
 
typedef struct OpIndexInterpretation OpIndexInterpretation
 
typedef enum IOFuncSelector IOFuncSelector
 
typedef struct AttStatsSlot AttStatsSlot
 
typedef int32(* get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum)
 

Enumerations

enum  IOFuncSelector { IOFunc_input , IOFunc_output , IOFunc_receive , IOFunc_send }
 

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)
 
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)
 
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 SubscriptRoutinesgetSubscriptingRoutines (Oid typid, Oid *typelemp)
 
Oid getBaseType (Oid typid)
 
Oid getBaseTypeAndTypmod (Oid typid, int32 *typmod)
 
int32 get_typavgwidth (Oid typid, int32 typmod)
 
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

PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook
 

Macro Definition Documentation

◆ ATTSTATSSLOT_NUMBERS

#define ATTSTATSSLOT_NUMBERS   0x02

Definition at line 44 of file lsyscache.h.

◆ ATTSTATSSLOT_VALUES

#define ATTSTATSSLOT_VALUES   0x01

Definition at line 43 of file lsyscache.h.

◆ type_is_array

#define type_is_array (   typid)    (get_element_type(typid) != InvalidOid)

Definition at line 214 of file lsyscache.h.

◆ type_is_array_domain

#define type_is_array_domain (   typid)    (get_base_element_type(typid) != InvalidOid)

Definition at line 216 of file lsyscache.h.

◆ TypeIsToastable

#define TypeIsToastable (   typid)    (get_typstorage(typid) != TYPSTORAGE_PLAIN)

Definition at line 218 of file lsyscache.h.

Typedef Documentation

◆ AttStatsSlot

typedef struct AttStatsSlot AttStatsSlot

◆ get_attavgwidth_hook_type

typedef int32(* get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum)

Definition at line 66 of file lsyscache.h.

◆ IOFuncSelector

◆ OpIndexInterpretation

◆ SubscriptRoutines

Definition at line 22 of file lsyscache.h.

Enumeration Type Documentation

◆ IOFuncSelector

Enumerator
IOFunc_input 
IOFunc_output 
IOFunc_receive 
IOFunc_send 

Definition at line 34 of file lsyscache.h.

35{
IOFuncSelector
Definition: lsyscache.h:35
@ IOFunc_output
Definition: lsyscache.h:37
@ IOFunc_input
Definition: lsyscache.h:36
@ IOFunc_send
Definition: lsyscache.h:39
@ IOFunc_receive
Definition: lsyscache.h:38

Function Documentation

◆ comparison_ops_are_compatible()

bool comparison_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 834 of file lsyscache.c.

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

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

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

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

1965{
1966 HeapTuple tp;
1967 char result;
1968
1969 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1970 if (!HeapTupleIsValid(tp))
1971 elog(ERROR, "cache lookup failed for function %u", funcid);
1972
1973 result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1974 ReleaseSysCache(tp);
1975 return result;
1976}
#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 1926 of file lsyscache.c.

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

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

3324{
3325 HeapTuple tp;
3326 int32 stawidth;
3327
3329 {
3330 stawidth = (*get_attavgwidth_hook) (relid, attnum);
3331 if (stawidth > 0)
3332 return stawidth;
3333 }
3334 tp = SearchSysCache3(STATRELATTINH,
3335 ObjectIdGetDatum(relid),
3337 BoolGetDatum(false));
3338 if (HeapTupleIsValid(tp))
3339 {
3340 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3341 ReleaseSysCache(tp);
3342 if (stawidth > 0)
3343 return stawidth;
3344 }
3345 return 0;
3346}
int32_t int32
Definition: c.h:548
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 979 of file lsyscache.c.

980{
981 HeapTuple tp;
982 Form_pg_attribute att_tup;
983 char result;
984
985 tp = SearchSysCache2(ATTNUM,
986 ObjectIdGetDatum(relid),
988 if (!HeapTupleIsValid(tp))
989 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
990 attnum, relid);
991 att_tup = (Form_pg_attribute) GETSTRUCT(tp);
992 result = att_tup->attgenerated;
993 ReleaseSysCache(tp);
994 return result;
995}
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 918 of file lsyscache.c.

919{
920 HeapTuple tp;
921
922 tp = SearchSysCache2(ATTNUM,
924 if (HeapTupleIsValid(tp))
925 {
927 char *result;
928
929 result = pstrdup(NameStr(att_tup->attname));
930 ReleaseSysCache(tp);
931 return result;
932 }
933
934 if (!missing_ok)
935 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
936 attnum, relid);
937 return NULL;
938}
#define NameStr(name)
Definition: c.h:765
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(), DoCopy(), 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 1061 of file lsyscache.c.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1258{
1259 HeapTuple dbtuple;
1260 char *result;
1261
1262 dbtuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbid));
1263 if (HeapTupleIsValid(dbtuple))
1264 {
1265 result = pstrdup(NameStr(((Form_pg_database) GETSTRUCT(dbtuple))->datname));
1266 ReleaseSysCache(dbtuple);
1267 }
1268 else
1269 result = NULL;
1270
1271 return result;
1272}
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 2002 of file lsyscache.c.

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

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

Referenced by contain_leaked_vars_checker(), contain_leaked_vars_walker(), create_agg_clause_infos(), 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 1797 of file lsyscache.c.

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

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

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

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

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

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

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

1862{
1863 HeapTuple tp;
1864 Form_pg_proc procstruct;
1865 Oid result;
1866
1867 tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1868 if (!HeapTupleIsValid(tp))
1869 elog(ERROR, "cache lookup failed for function %u", funcid);
1870
1871 procstruct = (Form_pg_proc) GETSTRUCT(tp);
1872
1873 result = procstruct->prorettype;
1874 *nargs = (int) procstruct->pronargs;
1875 Assert(*nargs == procstruct->proargtypes.dim1);
1876 *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1877 memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1878
1879 ReleaseSysCache(tp);
1880 return result;
1881}
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 2023 of file lsyscache.c.

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

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

◆ get_func_variadictype()

Oid get_func_variadictype ( Oid  funcid)

Definition at line 1888 of file lsyscache.c.

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

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

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

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

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

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

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

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

Referenced by RememberReplicaIdentityForRebuilding().

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3743 of file lsyscache.c.

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

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

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

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

3532{
3533 HeapTuple tp;
3534
3535 tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid));
3536 if (HeapTupleIsValid(tp))
3537 {
3539 char *result;
3540
3541 result = pstrdup(NameStr(nsptup->nspname));
3542 ReleaseSysCache(tp);
3543 return result;
3544 }
3545 else
3546 return NULL;
3547}
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(), AlterSubscription_refresh_seq(), 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_sequences(), check_publications_origin_tables(), CheckPubRelationColumnList(), compute_return_type(), copy_table(), copy_table_data(), create_pg_locale(), CreateConversionCommand(), CreateExtensionInternal(), CreateFunction(), CreateStatistics(), 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_and_validate_seq_info(), 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(), LogicalRepSyncSequences(), 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 1698 of file lsyscache.c.

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

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:887

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(), eqjoinsel(), 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
706 thisresult->opfamily_id = op_form->amopfamily;
707 thisresult->cmptype = cmptype;
708 thisresult->oplefttype = op_form->amoplefttype;
709 thisresult->oprighttype = op_form->amoprighttype;
710 result = lappend(result, thisresult);
711 }
712
713 ReleaseSysCacheList(catlist);
714
715 /*
716 * If we didn't find any btree opfamily containing the operator, perhaps
717 * it is a <> operator. See if it has a negator that is in an opfamily.
718 */
719 if (result == NIL)
720 {
721 Oid op_negator = get_negator(opno);
722
723 if (OidIsValid(op_negator))
724 {
725 catlist = SearchSysCacheList1(AMOPOPID,
726 ObjectIdGetDatum(op_negator));
727
728 for (i = 0; i < catlist->n_members; i++)
729 {
730 HeapTuple op_tuple = &catlist->members[i]->tuple;
731 Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
732 IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
733 CompareType cmptype;
734
735 /* must be ordering index */
736 if (!amroutine->amcanorder)
737 continue;
738
739 /* Get the operator's comparision type */
740 cmptype = IndexAmTranslateStrategy(op_form->amopstrategy,
741 op_form->amopmethod,
742 op_form->amopfamily,
743 true);
744
745 /* Only consider negators that are = */
746 if (cmptype != COMPARE_EQ)
747 continue;
748
749 /* OK, report it as COMPARE_NE */
751 thisresult->opfamily_id = op_form->amopfamily;
752 thisresult->cmptype = COMPARE_NE;
753 thisresult->oplefttype = op_form->amoplefttype;
754 thisresult->oprighttype = op_form->amoprighttype;
755 result = lappend(result, thisresult);
756 }
757
758 ReleaseSysCacheList(catlist);
759 }
760 }
761
762 return result;
763}
@ COMPARE_INVALID
Definition: cmptype.h:33
@ COMPARE_NE
Definition: cmptype.h:39
#define palloc_object(type)
Definition: fe_memutils.h:74
List * lappend(List *list, void *datum)
Definition: list.c:339
Oid get_negator(Oid opno)
Definition: lsyscache.c:1698
bool amcanorder
Definition: amapi.h:246
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_object, 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 1498 of file lsyscache.c.

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

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

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

◆ get_opclass_family()

Oid get_opclass_family ( Oid  opclass)

Definition at line 1307 of file lsyscache.c.

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

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

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

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

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

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

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

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

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:1401
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_eclass_for_sortgroupclause(), 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 1401 of file lsyscache.c.

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

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

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

char * get_opname ( Oid  opno)

Definition at line 1475 of file lsyscache.c.

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

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

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

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

Referenced by join_selectivity(), and scalararraysel().

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1722 of file lsyscache.c.

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

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

2977{
2978 Oid array_type = get_array_type(typid);
2979
2980 if (OidIsValid(array_type))
2981 return array_type;
2982 if (OidIsValid(get_element_type(typid)))
2983 return typid;
2984 return InvalidOid;
2985}
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2924
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2952

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

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

3791{
3792 Oid oid;
3793
3794 oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
3795 CStringGetDatum(pubname));
3796 if (!OidIsValid(oid) && !missing_ok)
3797 ereport(ERROR,
3798 (errcode(ERRCODE_UNDEFINED_OBJECT),
3799 errmsg("publication \"%s\" does not exist", pubname)));
3800 return oid;
3801}
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 3598 of file lsyscache.c.

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

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

Referenced by CheckAttributeType().

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

Definition at line 3623 of file lsyscache.c.

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

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

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

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

2094{
2095 HeapTuple tp;
2096
2097 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2098 if (HeapTupleIsValid(tp))
2099 {
2100 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2101 char *result;
2102
2103 result = pstrdup(NameStr(reltup->relname));
2104 ReleaseSysCache(tp);
2105 return result;
2106 }
2107 else
2108 return NULL;
2109}
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(), AlterSubscription_refresh_seq(), AlterTableNamespace(), ATExecAlterConstraint(), ATExecChangeOwner(), ATPrepAddPrimaryKey(), BeginCopyTo(), check_enable_rls(), check_new_partition_bound(), check_publications_origin_sequences(), check_publications_origin_tables(), 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(), FinishSyncWorker(), 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 2243 of file lsyscache.c.

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

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

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

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

Referenced by DefineRelation().

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

Definition at line 2192 of file lsyscache.c.

2193{
2194 HeapTuple tp;
2195
2196 tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2197 if (HeapTupleIsValid(tp))
2198 {
2199 Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2200 bool result;
2201
2202 result = reltup->relispartition;
2203 ReleaseSysCache(tp);
2204 return result;
2205 }
2206 else
2207 return false;
2208}

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

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

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

Referenced by AlterPublicationOptions(), AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), ATExecAlterConstrDeferrability(), ATExecAlterConstrEnforceability(), ATExecChangeOwner(), AttachPartitionForeignKey(), BeginCopyTo(), check_rel_can_be_partition(), check_relation_privileges(), CreateSubscription(), CreateTriggerFiringOn(), doDeletion(), EnableDisableRule(), exec_object_restorecon(), ExecCheckPermissions(), FetchRelationStates(), get_object_type(), get_rel_sync_entry(), get_tables_to_cluster_partitioned(), getOwnedSequences_internal(), GetPubPartitionOptionRelations(), GetSchemaPublicationRelations(), GetSubscriptionRelations(), 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(), HasSubscriptionTables(), LockTableCommand(), pg_get_serial_sequence(), pg_get_triggerdef_worker(), pg_partition_tree(), pg_prewarm(), ProcessSyncingTablesForApply(), ProcessUtilitySlow(), QueueFKConstraintValidation(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForDblink(), RangeVarCallbackForLockTable(), RangeVarCallbackForPolicy(), RangeVarCallbackForReindexIndex(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackForStats(), RangeVarCallbackMaintainsTable(), RangeVarCallbackOwnsRelation(), RangeVarGetAndCheckCreationNamespace(), ReindexIndex(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), ReindexTable(), RelationBuildPartitionDesc(), RememberAllDependentForRebuilding(), RemoveSubscriptionRel(), renameatt_check(), RenameRelation(), RenameType(), sepgsql_attribute_drop(), sepgsql_attribute_post_create(), sepgsql_attribute_relabel(), sepgsql_attribute_setattr(), sepgsql_relation_drop(), sepgsql_relation_relabel(), sepgsql_relation_setattr(), and sepgsql_relation_truncate().

◆ get_rel_tablespace()

Oid get_rel_tablespace ( Oid  relid)

Definition at line 2219 of file lsyscache.c.

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

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

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

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

Oid get_relname_relid ( const char *  relname,
Oid  relnamespace 
)

◆ get_subscription_name()

char * get_subscription_name ( Oid  subid,
bool  missing_ok 
)

Definition at line 3860 of file lsyscache.c.

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

3841{
3842 Oid oid;
3843
3844 oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
3846 if (!OidIsValid(oid) && !missing_ok)
3847 ereport(ERROR,
3848 (errcode(ERRCODE_UNDEFINED_OBJECT),
3849 errmsg("subscription \"%s\" does not exist", subname)));
3850 return oid;
3851}
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 2285 of file lsyscache.c.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2362 of file lsyscache.c.

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

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

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

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2584 of file lsyscache.c.

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

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

Referenced by GetAttributeStorage().

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3262 of file lsyscache.c.

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

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

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

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 SubscriptRoutines * getSubscriptingRoutines ( Oid  typid,
Oid typelemp 
)

Definition at line 3295 of file lsyscache.c.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2844{
2845 return (get_typtype(typid) == TYPTYPE_ENUM);
2846}
char get_typtype(Oid typid)
Definition: lsyscache.c:2794

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

2864{
2865 return (get_typtype(typid) == TYPTYPE_MULTIRANGE);
2866}

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

2854{
2855 return (get_typtype(typid) == TYPTYPE_RANGE);
2856}

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

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

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

PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook
extern

Definition at line 55 of file lsyscache.c.

Referenced by get_attavgwidth().