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

Go to the source code of this file.

Functions

bool op_in_opfamily (Oid opno, Oid opfamily)
 
int get_op_opfamily_strategy (Oid opno, Oid opfamily)
 
Oid get_op_opfamily_sortfamily (Oid opno, Oid opfamily)
 
void get_op_opfamily_properties (Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
 
Oid get_opfamily_member (Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
 
Oid get_opfamily_member_for_cmptype (Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
 
static bool get_opmethod_canorder (Oid amoid)
 
bool get_ordering_op_properties (Oid opno, Oid *opfamily, Oid *opcintype, CompareType *cmptype)
 
Oid get_equality_op_for_ordering_op (Oid opno, bool *reverse)
 
Oid get_ordering_op_for_equality_op (Oid opno, bool use_lhs_type)
 
Listget_mergejoin_opfamilies (Oid opno)
 
bool get_compatible_hash_operators (Oid opno, Oid *lhs_opno, Oid *rhs_opno)
 
bool get_op_hash_functions (Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
 
bool get_op_hash_functions_ext (Oid opno, Oid inputtype, 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)
 
bool collations_agree_on_equality (Oid coll1, Oid coll2)
 
bool op_is_safe_index_member (Oid opno)
 
Oid get_opfamily_proc (Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
 
charget_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)
 
charget_collation_name (Oid colloid)
 
bool get_collation_isdeterministic (Oid colloid)
 
charget_constraint_name (Oid conoid)
 
Oid get_constraint_index (Oid conoid)
 
char get_constraint_type (Oid conoid)
 
charget_database_name (Oid dbid)
 
charget_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)
 
charget_opfamily_name (Oid opfid, bool missing_ok)
 
RegProcedure get_opcode (Oid opno)
 
charget_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)
 
charget_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)
 
charget_rel_name (Oid relid)
 
Oid get_rel_namespace (Oid relid)
 
Oid get_rel_type_id (Oid relid)
 
char get_rel_relkind (Oid relid)
 
bool get_rel_relispartition (Oid relid)
 
Oid get_rel_tablespace (Oid relid)
 
char get_rel_persistence (Oid relid)
 
Oid get_rel_relam (Oid relid)
 
Oid get_transform_fromsql (Oid typid, Oid langid, List *trftypes)
 
Oid get_transform_tosql (Oid typid, Oid langid, List *trftypes)
 
bool get_typisdefined (Oid typid)
 
int16 get_typlen (Oid typid)
 
bool get_typbyval (Oid typid)
 
void get_typlenbyval (Oid typid, int16 *typlen, bool *typbyval)
 
void get_typlenbyvalalign (Oid typid, int16 *typlen, bool *typbyval, char *typalign)
 
Oid getTypeIOParam (HeapTuple typeTuple)
 
void get_type_io_data (Oid typid, IOFuncSelector which_func, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *func)
 
char get_typstorage (Oid typid)
 
Nodeget_typdefault (Oid typid)
 
Oid getBaseType (Oid typid)
 
Oid getBaseTypeAndTypmod (Oid typid, int32 *typmod)
 
int32 get_typavgwidth (Oid typid, int32 typmod)
 
char get_typtype (Oid typid)
 
bool type_is_rowtype (Oid typid)
 
bool type_is_enum (Oid typid)
 
bool type_is_range (Oid typid)
 
bool type_is_multirange (Oid typid)
 
void get_type_category_preferred (Oid typid, char *typcategory, bool *typispreferred)
 
Oid get_typ_typrelid (Oid typid)
 
Oid get_element_type (Oid typid)
 
Oid get_array_type (Oid typid)
 
Oid get_promoted_array_type (Oid typid)
 
Oid get_base_element_type (Oid typid)
 
void getTypeInputInfo (Oid type, Oid *typInput, Oid *typIOParam)
 
void getTypeOutputInfo (Oid type, Oid *typOutput, bool *typIsVarlena)
 
void getTypeBinaryInputInfo (Oid type, Oid *typReceive, Oid *typIOParam)
 
void getTypeBinaryOutputInfo (Oid type, Oid *typSend, bool *typIsVarlena)
 
Oid get_typmodin (Oid typid)
 
Oid get_typcollation (Oid typid)
 
bool type_is_collatable (Oid typid)
 
RegProcedure get_typsubscript (Oid typid, Oid *typelemp)
 
const struct SubscriptRoutinesgetSubscriptingRoutines (Oid typid, Oid *typelemp)
 
int32 get_attavgwidth (Oid relid, AttrNumber attnum)
 
bool get_attstatsslot (AttStatsSlot *sslot, HeapTuple statstuple, int reqkind, Oid reqop, int flags)
 
void free_attstatsslot (AttStatsSlot *sslot)
 
charget_namespace_name (Oid nspid)
 
charget_namespace_name_or_temp (Oid nspid)
 
charget_qualified_objname (Oid nspid, char *objname)
 
Oid get_range_subtype (Oid rangeOid)
 
Oid get_range_collation (Oid rangeOid)
 
RegProcedure get_range_constructor2 (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)
 
charget_publication_name (Oid pubid, bool missing_ok)
 
Oid get_subscription_oid (const char *subname, bool missing_ok)
 
charget_subscription_name (Oid subid, bool missing_ok)
 
charget_propgraph_label_name (Oid labeloid)
 
charget_propgraph_property_name (Oid propoid)
 

Variables

get_attavgwidth_hook_type get_attavgwidth_hook = NULL
 

Function Documentation

◆ collations_agree_on_equality()

bool collations_agree_on_equality ( Oid  coll1,
Oid  coll2 
)

Definition at line 954 of file lsyscache.c.

955{
956 if (!OidIsValid(coll1) || !OidIsValid(coll2))
957 return true;
958
959 if (coll1 == coll2)
960 return true;
961
964 return false;
965
966 return true;
967}
#define OidIsValid(objectId)
Definition c.h:917
bool get_collation_isdeterministic(Oid colloid)
Definition lsyscache.c:1280
static int fb(int x)

References fb(), get_collation_isdeterministic(), and OidIsValid.

Referenced by query_is_distinct_for(), relation_has_unique_index_for(), and remove_useless_groupby_columns().

◆ comparison_ops_are_compatible()

bool comparison_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 893 of file lsyscache.c.

894{
895 bool result;
897 int i;
898
899 /* Easy if they're the same operator */
900 if (opno1 == opno2)
901 return true;
902
903 /*
904 * We search through all the pg_amop entries for opno1.
905 */
907
908 result = false;
909 for (i = 0; i < catlist->n_members; i++)
910 {
911 HeapTuple op_tuple = &catlist->members[i]->tuple;
913
914 /*
915 * op_in_opfamily() is cheaper than GetIndexAmRoutineByAmId(), so
916 * check it first
917 */
918 if (op_in_opfamily(opno2, op_form->amopfamily) &&
920 {
921 result = true;
922 break;
923 }
924 }
925
927
928 return result;
929}
const IndexAmRoutine * GetIndexAmRoutineByAmId(Oid amoid, bool noerror)
Definition amapi.c:69
uint32 result
static void * GETSTRUCT(const HeapTupleData *tuple)
int i
Definition isn.c:77
bool op_in_opfamily(Oid opno, Oid opfamily)
Definition lsyscache.c:70
END_CATALOG_STRUCT typedef FormData_pg_amop * Form_pg_amop
Definition pg_amop.h:92
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:252
bool amconsistentordering
Definition amapi.h:255
#define ReleaseSysCacheList(x)
Definition syscache.h:134
#define SearchSysCacheList1(cacheId, key1)
Definition syscache.h:127

References IndexAmRoutine::amconsistentordering, fb(), Form_pg_amop, GetIndexAmRoutineByAmId(), GETSTRUCT(), i, ObjectIdGetDatum(), op_in_opfamily(), ReleaseSysCacheList, result, and SearchSysCacheList1.

Referenced by ineq_histogram_selectivity().

◆ equality_ops_are_compatible()

bool equality_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 841 of file lsyscache.c.

842{
843 bool result;
845 int i;
846
847 /* Easy if they're the same operator */
848 if (opno1 == opno2)
849 return true;
850
851 /*
852 * We search through all the pg_amop entries for opno1.
853 */
855
856 result = false;
857 for (i = 0; i < catlist->n_members; i++)
858 {
859 HeapTuple op_tuple = &catlist->members[i]->tuple;
861
862 /*
863 * op_in_opfamily() is cheaper than GetIndexAmRoutineByAmId(), so
864 * check it first
865 */
866 if (op_in_opfamily(opno2, op_form->amopfamily) &&
868 {
869 result = true;
870 break;
871 }
872 }
873
875
876 return result;
877}
bool amconsistentequality
Definition amapi.h:253

References IndexAmRoutine::amconsistentequality, fb(), Form_pg_amop, GetIndexAmRoutineByAmId(), GETSTRUCT(), i, ObjectIdGetDatum(), op_in_opfamily(), ReleaseSysCacheList, result, and SearchSysCacheList1.

Referenced by grouping_check_operand(), and query_is_distinct_for().

◆ free_attstatsslot()

void free_attstatsslot ( AttStatsSlot sslot)

Definition at line 3660 of file lsyscache.c.

3661{
3662 /* The values[] array was separately palloc'd by deconstruct_array */
3663 if (sslot->values)
3664 pfree(sslot->values);
3665 /* The numbers[] array points into numbers_arr, do not pfree it */
3666 /* Free the detoasted array objects, if any */
3667 if (sslot->values_arr)
3668 pfree(sslot->values_arr);
3669 if (sslot->numbers_arr)
3670 pfree(sslot->numbers_arr);
3671}
void pfree(void *pointer)
Definition mcxt.c:1619

References fb(), and pfree().

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

2114{
2115 HeapTuple tp;
2116 char result;
2117
2119 if (!HeapTupleIsValid(tp))
2120 elog(ERROR, "cache lookup failed for function %u", funcid);
2121
2123 ReleaseSysCache(tp);
2124 return result;
2125}
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
#define HeapTupleIsValid(tuple)
Definition htup.h:78
END_CATALOG_STRUCT typedef FormData_pg_proc * Form_pg_proc
Definition pg_proc.h:140
void ReleaseSysCache(HeapTuple tuple)
Definition syscache.c:265
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Definition syscache.c:221

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

Referenced by max_parallel_hazard_checker(), and set_rel_consider_parallel().

◆ func_strict()

◆ func_volatile()

◆ get_array_type()

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 3474 of file lsyscache.c.

3475{
3476 HeapTuple tp;
3477 int32 stawidth;
3478
3480 {
3481 stawidth = (*get_attavgwidth_hook) (relid, attnum);
3482 if (stawidth > 0)
3483 return stawidth;
3484 }
3486 ObjectIdGetDatum(relid),
3488 BoolGetDatum(false));
3489 if (HeapTupleIsValid(tp))
3490 {
3491 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3492 ReleaseSysCache(tp);
3493 if (stawidth > 0)
3494 return stawidth;
3495 }
3496 return 0;
3497}
int32_t int32
Definition c.h:679
get_attavgwidth_hook_type get_attavgwidth_hook
Definition lsyscache.c:57
int16 attnum
FormData_pg_statistic * Form_pg_statistic
static Datum Int16GetDatum(int16 X)
Definition postgres.h:172
static Datum BoolGetDatum(bool X)
Definition postgres.h:112
HeapTuple SearchSysCache3(SysCacheIdentifier cacheId, Datum key1, Datum key2, Datum key3)
Definition syscache.c:241

References attnum, BoolGetDatum(), fb(), 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 1114 of file lsyscache.c.

1115{
1116 HeapTuple tp;
1118 char result;
1119
1121 ObjectIdGetDatum(relid),
1123 if (!HeapTupleIsValid(tp))
1124 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1125 attnum, relid);
1127 result = att_tup->attgenerated;
1128 ReleaseSysCache(tp);
1129 return result;
1130}
FormData_pg_attribute * Form_pg_attribute
HeapTuple SearchSysCache2(SysCacheIdentifier cacheId, Datum key1, Datum key2)
Definition syscache.c:231

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

Referenced by check_nested_generated_walker(), CreateStatistics(), and subquery_planner().

◆ get_attname()

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

Definition at line 1053 of file lsyscache.c.

1054{
1055 HeapTuple tp;
1056
1059 if (HeapTupleIsValid(tp))
1060 {
1062 char *result;
1063
1064 result = pstrdup(NameStr(att_tup->attname));
1065 ReleaseSysCache(tp);
1066 return result;
1067 }
1068
1069 if (!missing_ok)
1070 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1071 attnum, relid);
1072 return NULL;
1073}
#define NameStr(name)
Definition c.h:894
char * pstrdup(const char *in)
Definition mcxt.c:1910

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

Referenced by AddRelationNewConstraints(), AddRelationNotNullConstraints(), AdjustNotNullInheritance(), 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(), import_attribute_statistics(), make_propgraphdef_properties(), 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 1196 of file lsyscache.c.

1197{
1198 HeapTuple tuple;
1199 Datum attopts;
1200 Datum result;
1201 bool isnull;
1202
1203 tuple = SearchSysCache2(ATTNUM,
1204 ObjectIdGetDatum(relid),
1206
1207 if (!HeapTupleIsValid(tuple))
1208 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1209 attnum, relid);
1210
1212 &isnull);
1213
1214 if (isnull)
1215 result = (Datum) 0;
1216 else
1217 result = datumCopy(attopts, false, -1); /* text[] */
1218
1219 ReleaseSysCache(tuple);
1220
1221 return result;
1222}
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition datum.c:132
uint64_t Datum
Definition postgres.h:70
Datum SysCacheGetAttr(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition syscache.c:596

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

Referenced by CheckIndexCompatible(), generateClonedIndexStmt(), index_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 3550 of file lsyscache.c.

3552{
3554 int i;
3555 Datum val;
3558 int narrayelem;
3561
3562 /* initialize *sslot properly */
3563 memset(sslot, 0, sizeof(AttStatsSlot));
3564
3565 for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
3566 {
3567 if ((&stats->stakind1)[i] == reqkind &&
3568 (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
3569 break;
3570 }
3571 if (i >= STATISTIC_NUM_SLOTS)
3572 return false; /* not there */
3573
3574 sslot->staop = (&stats->staop1)[i];
3575 sslot->stacoll = (&stats->stacoll1)[i];
3576
3577 if (flags & ATTSTATSSLOT_VALUES)
3578 {
3581
3582 /*
3583 * Detoast the array if needed, and in any case make a copy that's
3584 * under control of this AttStatsSlot.
3585 */
3587
3588 /*
3589 * Extract the actual array element type, and pass it back in case the
3590 * caller needs it.
3591 */
3592 sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3593
3594 /* Need info about element type */
3597 elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3599
3600 /* Deconstruct array into Datum elements; NULLs not expected */
3603 typeForm->typlen,
3604 typeForm->typbyval,
3605 typeForm->typalign,
3606 &sslot->values, NULL, &sslot->nvalues);
3607
3608 /*
3609 * If the element type is pass-by-reference, we now have a bunch of
3610 * Datums that are pointers into the statarray, so we need to keep
3611 * that until free_attstatsslot. Otherwise, all the useful info is in
3612 * sslot->values[], so we can free the array object immediately.
3613 */
3614 if (!typeForm->typbyval)
3615 sslot->values_arr = statarray;
3616 else
3618
3620 }
3621
3622 if (flags & ATTSTATSSLOT_NUMBERS)
3623 {
3626
3627 /*
3628 * Detoast the array if needed, and in any case make a copy that's
3629 * under control of this AttStatsSlot.
3630 */
3632
3633 /*
3634 * We expect the array to be a 1-D float4 array; verify that. We don't
3635 * need to use deconstruct_array() since the array data is just going
3636 * to look like a C array of float4 values.
3637 */
3639 if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3642 elog(ERROR, "stanumbers is not a 1-D float4 array");
3643
3644 /* Give caller a pointer directly into the statarray */
3645 sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3646 sslot->nnumbers = narrayelem;
3647
3648 /* We'll free the statarray in free_attstatsslot */
3649 sslot->numbers_arr = statarray;
3650 }
3651
3652 return true;
3653}
#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)
float float4
Definition c.h:772
long val
Definition informix.c:689
#define ATTSTATSSLOT_NUMBERS
Definition lsyscache.h:44
#define ATTSTATSSLOT_VALUES
Definition lsyscache.h:43
#define STATISTIC_NUM_SLOTS
Datum SysCacheGetAttrNotNull(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber)
Definition syscache.c:626

References ARR_DATA_PTR, ARR_DIMS, ARR_ELEMTYPE, ARR_HASNULL, ARR_NDIM, ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, DatumGetArrayTypePCopy, deconstruct_array(), elog, ERROR, fb(), Form_pg_type, GETSTRUCT(), HeapTupleIsValid, i, InvalidOid, ObjectIdGetDatum(), pfree(), ReleaseSysCache(), SearchSysCache1(), STATISTIC_NUM_SLOTS, SysCacheGetAttrNotNull(), and val.

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

1140{
1141 HeapTuple tp;
1142
1144 ObjectIdGetDatum(relid),
1146 if (HeapTupleIsValid(tp))
1147 {
1149 Oid result;
1150
1151 result = att_tup->atttypid;
1152 ReleaseSysCache(tp);
1153 return result;
1154 }
1155 else
1156 return InvalidOid;
1157}

References attnum, fb(), GETSTRUCT(), HeapTupleIsValid, Int16GetDatum(), InvalidOid, ObjectIdGetDatum(), ReleaseSysCache(), result, 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 1169 of file lsyscache.c.

1171{
1172 HeapTuple tp;
1174
1176 ObjectIdGetDatum(relid),
1178 if (!HeapTupleIsValid(tp))
1179 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1180 attnum, relid);
1182
1183 *typid = att_tup->atttypid;
1184 *typmod = att_tup->atttypmod;
1185 *collid = att_tup->attcollation;
1186 ReleaseSysCache(tp);
1187}
Oid collid

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

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

◆ get_base_element_type()

Oid get_base_element_type ( Oid  typid)

Definition at line 3148 of file lsyscache.c.

3149{
3150 /*
3151 * We loop to find the bottom base type in a stack of domains.
3152 */
3153 for (;;)
3154 {
3155 HeapTuple tup;
3157
3159 if (!HeapTupleIsValid(tup))
3160 break;
3162 if (typTup->typtype != TYPTYPE_DOMAIN)
3163 {
3164 /* Not a domain, so stop descending */
3165 Oid result;
3166
3167 /* This test must match get_element_type */
3169 result = typTup->typelem;
3170 else
3173 return result;
3174 }
3175
3176 typid = typTup->typbasetype;
3178 }
3179
3180 /* Like get_element_type, silently return InvalidOid for bogus input */
3181 return InvalidOid;
3182}

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

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

◆ get_cast_oid()

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

Definition at line 1233 of file lsyscache.c.

1234{
1235 Oid oid;
1236
1240 if (!OidIsValid(oid) && !missing_ok)
1241 ereport(ERROR,
1243 errmsg("cast from type %s to type %s does not exist",
1246 return oid;
1247}
int errcode(int sqlerrcode)
Definition elog.c:875
#define ereport(elevel,...)
Definition elog.h:152
char * format_type_be(Oid type_oid)
static char * errmsg
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
Definition syscache.h:111

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

Referenced by get_object_address().

◆ get_collation_isdeterministic()

bool get_collation_isdeterministic ( Oid  colloid)

Definition at line 1280 of file lsyscache.c.

1281{
1282 HeapTuple tp;
1284 bool result;
1285
1287 if (!HeapTupleIsValid(tp))
1288 elog(ERROR, "cache lookup failed for collation %u", colloid);
1290 result = colltup->collisdeterministic;
1291 ReleaseSysCache(tp);
1292 return result;
1293}
END_CATALOG_STRUCT typedef FormData_pg_collation * Form_pg_collation

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

Referenced by ATAddForeignKeyConstraint(), collations_agree_on_equality(), grouping_check_operand(), grouping_conflict_walker(), and index_create().

◆ get_collation_name()

◆ get_commutator()

◆ get_compatible_hash_operators()

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

Definition at line 483 of file lsyscache.c.

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

References fb(), Form_pg_amop, get_opfamily_member(), GETSTRUCT(), HTEqualStrategyNumber, i, InvalidOid, ObjectIdGetDatum(), OidIsValid, ReleaseSysCacheList, result, and SearchSysCacheList1.

Referenced by create_unique_paths(), and ExecInitSubPlan().

◆ get_constraint_index()

Oid get_constraint_index ( Oid  conoid)

Definition at line 1339 of file lsyscache.c.

1340{
1341 HeapTuple tp;
1342
1344 if (HeapTupleIsValid(tp))
1345 {
1347 Oid result;
1348
1349 if (contup->contype == CONSTRAINT_UNIQUE ||
1350 contup->contype == CONSTRAINT_PRIMARY ||
1351 contup->contype == CONSTRAINT_EXCLUSION)
1352 result = contup->conindid;
1353 else
1355 ReleaseSysCache(tp);
1356 return result;
1357 }
1358 else
1359 return InvalidOid;
1360}
END_CATALOG_STRUCT typedef FormData_pg_constraint * Form_pg_constraint

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

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

◆ get_constraint_name()

char * get_constraint_name ( Oid  conoid)

Definition at line 1307 of file lsyscache.c.

1308{
1309 HeapTuple tp;
1310
1312 if (HeapTupleIsValid(tp))
1313 {
1315 char *result;
1316
1317 result = pstrdup(NameStr(contup->conname));
1318 ReleaseSysCache(tp);
1319 return result;
1320 }
1321 else
1322 return NULL;
1323}

References fb(), Form_pg_constraint, GETSTRUCT(), HeapTupleIsValid, NameStr, ObjectIdGetDatum(), pstrdup(), ReleaseSysCache(), result, 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 1369 of file lsyscache.c.

1370{
1371 HeapTuple tp;
1372 char contype;
1373
1375 if (!HeapTupleIsValid(tp))
1376 elog(ERROR, "cache lookup failed for constraint %u", conoid);
1377
1378 contype = ((Form_pg_constraint) GETSTRUCT(tp))->contype;
1379 ReleaseSysCache(tp);
1380
1381 return contype;
1382}

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

Referenced by AttachPartitionEnsureIndexes(), and RememberConstraintForRebuilding().

◆ get_database_name()

char * get_database_name ( Oid  dbid)

Definition at line 1392 of file lsyscache.c.

1393{
1395 char *result;
1396
1399 {
1402 }
1403 else
1404 result = NULL;
1405
1406 return result;
1407}
NameData datname
Definition pg_database.h:37
END_CATALOG_STRUCT typedef FormData_pg_database * Form_pg_database

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

Referenced by AfterTriggerSetState(), AlterObjectRename_internal(), AlterPublicationOwner_internal(), AlterSchemaOwner_internal(), AlterSubscriptionOwner_internal(), calculate_database_size(), createdb(), CreatePublication(), CreateSchemaCommand(), 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(), pg_get_database_ddl_internal(), pg_get_role_ddl_internal(), 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 326 of file lsyscache.c.

327{
329 Oid opfamily;
330 Oid opcintype;
331 CompareType cmptype;
332
333 /* Find the operator in pg_amop */
335 &opfamily, &opcintype, &cmptype))
336 {
337 /* Found a suitable opfamily, get matching equality operator */
339 opcintype,
340 opcintype,
341 COMPARE_EQ);
342 if (reverse)
343 *reverse = (cmptype == COMPARE_GT);
344 }
345
346 return result;
347}
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:261
Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
Definition lsyscache.c:199

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

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

◆ get_func_leakproof()

bool get_func_leakproof ( Oid  funcid)

◆ get_func_name()

◆ get_func_namespace()

Oid get_func_namespace ( Oid  funcid)

Definition at line 1946 of file lsyscache.c.

1947{
1948 HeapTuple tp;
1949
1951 if (HeapTupleIsValid(tp))
1952 {
1954 Oid result;
1955
1956 result = functup->pronamespace;
1957 ReleaseSysCache(tp);
1958 return result;
1959 }
1960 else
1961 return InvalidOid;
1962}

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

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

◆ get_func_nargs()

int get_func_nargs ( Oid  funcid)

Definition at line 1988 of file lsyscache.c.

1989{
1990 HeapTuple tp;
1991 int result;
1992
1994 if (!HeapTupleIsValid(tp))
1995 elog(ERROR, "cache lookup failed for function %u", funcid);
1996
1998 ReleaseSysCache(tp);
1999 return result;
2000}
int16 pronargs
Definition pg_proc.h:83

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

◆ get_func_prokind()

char get_func_prokind ( Oid  funcid)

Definition at line 2132 of file lsyscache.c.

2133{
2134 HeapTuple tp;
2135 char result;
2136
2138 if (!HeapTupleIsValid(tp))
2139 elog(ERROR, "cache lookup failed for function %u", funcid);
2140
2141 result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
2142 ReleaseSysCache(tp);
2143 return result;
2144}

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

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

◆ get_func_retset()

bool get_func_retset ( Oid  funcid)

Definition at line 2056 of file lsyscache.c.

2057{
2058 HeapTuple tp;
2059 bool result;
2060
2062 if (!HeapTupleIsValid(tp))
2063 elog(ERROR, "cache lookup failed for function %u", funcid);
2064
2066 ReleaseSysCache(tp);
2067 return result;
2068}

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

Referenced by build_edge_vertex_link_quals(), 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 2010 of file lsyscache.c.

2011{
2012 HeapTuple tp;
2014 Oid result;
2015
2017 if (!HeapTupleIsValid(tp))
2018 elog(ERROR, "cache lookup failed for function %u", funcid);
2019
2021
2022 result = procstruct->prorettype;
2023 *nargs = (int) procstruct->pronargs;
2024 Assert(*nargs == procstruct->proargtypes.dim1);
2025 *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
2026 memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
2027
2028 ReleaseSysCache(tp);
2029 return result;
2030}
#define Assert(condition)
Definition c.h:1002
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
void * palloc(Size size)
Definition mcxt.c:1390

References Assert, elog, ERROR, fb(), Form_pg_proc, GETSTRUCT(), HeapTupleIsValid, memcpy(), ObjectIdGetDatum(), palloc(), ReleaseSysCache(), result, and SearchSysCache1().

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

◆ get_func_support()

RegProcedure get_func_support ( Oid  funcid)

◆ get_func_variadictype()

Oid get_func_variadictype ( Oid  funcid)

Definition at line 2037 of file lsyscache.c.

2038{
2039 HeapTuple tp;
2040 Oid result;
2041
2043 if (!HeapTupleIsValid(tp))
2044 elog(ERROR, "cache lookup failed for function %u", funcid);
2045
2047 ReleaseSysCache(tp);
2048 return result;
2049}

References elog, ERROR, fb(), Form_pg_proc, GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), result, 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 3873 of file lsyscache.c.

3874{
3875 HeapTuple tuple;
3876 Form_pg_index rd_index;
3877 Datum datum;
3879 Oid opclass;
3880
3881 /* First we need to know the column's opclass. */
3882
3884 if (!HeapTupleIsValid(tuple))
3885 return InvalidOid;
3886
3887 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3888
3889 /* caller is supposed to guarantee this */
3890 Assert(attno > 0 && attno <= rd_index->indnatts);
3891
3892 /* Non-key attributes don't have an opclass */
3893 if (attno > rd_index->indnkeyatts)
3894 {
3895 ReleaseSysCache(tuple);
3896 return InvalidOid;
3897 }
3898
3900 indclass = ((oidvector *) DatumGetPointer(datum));
3901
3903 opclass = indclass->values[attno - 1];
3904
3905 ReleaseSysCache(tuple);
3906
3907 return opclass;
3908}
END_CATALOG_STRUCT typedef FormData_pg_index * Form_pg_index
Definition pg_index.h:74
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:332
Definition c.h:874

References Assert, DatumGetPointer(), fb(), Form_pg_index, GETSTRUCT(), HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), ReleaseSysCache(), SearchSysCache1(), and SysCacheGetAttrNotNull().

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

◆ get_index_isclustered()

bool get_index_isclustered ( Oid  index_oid)

Definition at line 3962 of file lsyscache.c.

3963{
3964 bool isclustered;
3965 HeapTuple tuple;
3966 Form_pg_index rd_index;
3967
3969 if (!HeapTupleIsValid(tuple))
3970 elog(ERROR, "cache lookup failed for index %u", index_oid);
3971
3972 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3973 isclustered = rd_index->indisclustered;
3974 ReleaseSysCache(tuple);
3975
3976 return isclustered;
3977}

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

Referenced by cluster_rel_recheck(), determine_clustered_index(), mark_index_clustered(), and RememberClusterOnForRebuilding().

◆ get_index_isreplident()

bool get_index_isreplident ( Oid  index_oid)

Definition at line 3916 of file lsyscache.c.

3917{
3918 HeapTuple tuple;
3919 Form_pg_index rd_index;
3920 bool result;
3921
3923 if (!HeapTupleIsValid(tuple))
3924 return false;
3925
3926 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3927 result = rd_index->indisreplident;
3928 ReleaseSysCache(tuple);
3929
3930 return result;
3931}

References fb(), Form_pg_index, GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), result, and SearchSysCache1().

Referenced by RememberReplicaIdentityForRebuilding().

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3939 of file lsyscache.c.

3940{
3941 bool isvalid;
3942 HeapTuple tuple;
3943 Form_pg_index rd_index;
3944
3946 if (!HeapTupleIsValid(tuple))
3947 elog(ERROR, "cache lookup failed for index %u", index_oid);
3948
3949 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3950 isvalid = rd_index->indisvalid;
3951 ReleaseSysCache(tuple);
3952
3953 return isvalid;
3954}

References elog, ERROR, fb(), Form_pg_index, 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 1413 of file lsyscache.c.

1414{
1415 HeapTuple tp;
1416
1418 if (HeapTupleIsValid(tp))
1419 {
1421 char *result;
1422
1423 result = pstrdup(NameStr(lantup->lanname));
1424 ReleaseSysCache(tp);
1425 return result;
1426 }
1427
1428 if (!missing_ok)
1429 elog(ERROR, "cache lookup failed for language %u",
1430 langoid);
1431 return NULL;
1432}
END_CATALOG_STRUCT typedef FormData_pg_language * Form_pg_language
Definition pg_language.h:69

References elog, ERROR, fb(), Form_pg_language, GETSTRUCT(), HeapTupleIsValid, NameStr, ObjectIdGetDatum(), pstrdup(), ReleaseSysCache(), result, 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 430 of file lsyscache.c.

431{
432 List *result = NIL;
434 int i;
435
436 /*
437 * Search pg_amop to see if the target operator is registered as the "="
438 * operator of any opfamily of an ordering index type.
439 */
441
442 for (i = 0; i < catlist->n_members; i++)
443 {
444 HeapTuple tuple = &catlist->members[i]->tuple;
446
447 /* must be ordering index equality */
448 if (get_opmethod_canorder(aform->amopmethod) &&
449 IndexAmTranslateStrategy(aform->amopstrategy,
450 aform->amopmethod,
451 aform->amopfamily,
452 true) == COMPARE_EQ)
453 result = lappend_oid(result, aform->amopfamily);
454 }
455
457
458 return result;
459}
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:223
#define NIL
Definition pg_list.h:68
Definition pg_list.h:54

References COMPARE_EQ, fb(), Form_pg_amop, get_opmethod_canorder(), GETSTRUCT(), i, IndexAmTranslateStrategy(), lappend_oid(), NIL, ObjectIdGetDatum(), ReleaseSysCacheList, result, and SearchSysCacheList1.

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

◆ get_multirange_range()

◆ get_namespace_name()

char * get_namespace_name ( Oid  nspid)

Definition at line 3682 of file lsyscache.c.

3683{
3684 HeapTuple tp;
3685
3687 if (HeapTupleIsValid(tp))
3688 {
3690 char *result;
3691
3692 result = pstrdup(NameStr(nsptup->nspname));
3693 ReleaseSysCache(tp);
3694 return result;
3695 }
3696 else
3697 return NULL;
3698}
int nspid
END_CATALOG_STRUCT typedef FormData_pg_namespace * Form_pg_namespace

References fb(), Form_pg_namespace, GETSTRUCT(), HeapTupleIsValid, NameStr, nspid, ObjectIdGetDatum(), pstrdup(), ReleaseSysCache(), result, 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(), import_attribute_statistics(), import_relation_statistics(), 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_clear_extended_stats(), pg_decode_change(), pg_decode_truncate(), pg_get_propgraphdef(), pg_identify_object(), pgoutput_column_list_init(), pgoutput_row_filter(), plpgsql_fulfill_promise(), postgresImportForeignStatistics(), ProcessSingleRelationFork(), 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_CheckPermissions(), 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()

◆ get_op_hash_functions()

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

Definition at line 589 of file lsyscache.c.

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

References fb(), Form_pg_amop, get_opfamily_proc(), GETSTRUCT(), HASHSTANDARD_PROC, HTEqualStrategyNumber, i, InvalidOid, ObjectIdGetDatum(), OidIsValid, ReleaseSysCacheList, result, and SearchSysCacheList1.

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

◆ get_op_hash_functions_ext()

bool get_op_hash_functions_ext ( Oid  opno,
Oid  inputtype,
RegProcedure lhs_procno,
RegProcedure rhs_procno 
)

Definition at line 677 of file lsyscache.c.

679{
680 TypeCacheEntry *typentry;
681
682 /* Ensure output args are initialized on failure */
683 if (lhs_procno)
685 if (rhs_procno)
687
688 /* As in op_hashjoinable, let the typcache handle the hard cases */
689 if (opno == ARRAY_EQ_OP)
690 {
691 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
692 if (typentry->hash_proc != F_HASH_ARRAY)
693 return false;
694 }
695 else if (opno == RECORD_EQ_OP)
696 {
697 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
698 if (typentry->hash_proc != F_HASH_RECORD)
699 return false;
700 }
701 else if (opno == RANGE_EQ_OP)
702 {
703 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
704 if (typentry->hash_proc != F_HASH_RANGE)
705 return false;
706 }
707 else if (opno == MULTIRANGE_EQ_OP)
708 {
709 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
710 if (typentry->hash_proc != F_HASH_MULTIRANGE)
711 return false;
712 }
713
714 /* OK, do the normal lookup */
716}
bool get_op_hash_functions(Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
Definition lsyscache.c:589
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition typcache.c:389
#define TYPECACHE_HASH_PROC
Definition typcache.h:142

References fb(), get_op_hash_functions(), TypeCacheEntry::hash_proc, InvalidOid, lookup_type_cache(), and TYPECACHE_HASH_PROC.

Referenced by convert_saop_to_hashed_saop_walker(), and eqjoinsel().

◆ get_op_index_interpretation()

List * get_op_index_interpretation ( Oid  opno)

Definition at line 729 of file lsyscache.c.

730{
731 List *result = NIL;
734 int i;
735
736 /*
737 * Find all the pg_amop entries containing the operator.
738 */
740
741 for (i = 0; i < catlist->n_members; i++)
742 {
743 HeapTuple op_tuple = &catlist->members[i]->tuple;
745 CompareType cmptype;
746
747 /* must be ordering index */
748 if (!get_opmethod_canorder(op_form->amopmethod))
749 continue;
750
751 /* Get the operator's comparison type */
752 cmptype = IndexAmTranslateStrategy(op_form->amopstrategy,
753 op_form->amopmethod,
754 op_form->amopfamily,
755 true);
756
757 /* should not happen */
758 if (cmptype == COMPARE_INVALID)
759 continue;
760
762 thisresult->opfamily_id = op_form->amopfamily;
763 thisresult->cmptype = cmptype;
764 thisresult->oplefttype = op_form->amoplefttype;
765 thisresult->oprighttype = op_form->amoprighttype;
767 }
768
770
771 /*
772 * If we didn't find any btree opfamily containing the operator, perhaps
773 * it is a <> operator. See if it has a negator that is in an opfamily.
774 */
775 if (result == NIL)
776 {
777 Oid op_negator = get_negator(opno);
778
780 {
783
784 for (i = 0; i < catlist->n_members; i++)
785 {
786 HeapTuple op_tuple = &catlist->members[i]->tuple;
788 const IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
789 CompareType cmptype;
790
791 /* must be ordering index */
792 if (!amroutine->amcanorder)
793 continue;
794
795 /* Get the operator's comparison type */
796 cmptype = IndexAmTranslateStrategy(op_form->amopstrategy,
797 op_form->amopmethod,
798 op_form->amopfamily,
799 true);
800
801 /* Only consider negators that are = */
802 if (cmptype != COMPARE_EQ)
803 continue;
804
805 /* OK, report it as COMPARE_NE */
807 thisresult->opfamily_id = op_form->amopfamily;
808 thisresult->cmptype = COMPARE_NE;
809 thisresult->oplefttype = op_form->amoplefttype;
810 thisresult->oprighttype = op_form->amoprighttype;
812 }
813
815 }
816 }
817
818 return result;
819}
@ COMPARE_INVALID
Definition cmptype.h:33
@ COMPARE_NE
Definition cmptype.h:39
#define palloc_object(type)
Definition fe_memutils.h:89
List * lappend(List *list, void *datum)
Definition list.c:339
Oid get_negator(Oid opno)
Definition lsyscache.c:1847

References COMPARE_EQ, COMPARE_INVALID, COMPARE_NE, fb(), Form_pg_amop, get_negator(), get_opmethod_canorder(), GetIndexAmRoutineByAmId(), GETSTRUCT(), i, IndexAmTranslateStrategy(), lappend(), NIL, ObjectIdGetDatum(), OidIsValid, palloc_object, ReleaseSysCacheList, result, and SearchSysCacheList1.

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

144{
145 HeapTuple tp;
147
149 ObjectIdGetDatum(opno),
151 ObjectIdGetDatum(opfamily));
152 if (!HeapTupleIsValid(tp))
153 elog(ERROR, "operator %u is not a member of opfamily %u",
154 opno, opfamily);
156 *strategy = amop_tup->amopstrategy;
157 *lefttype = amop_tup->amoplefttype;
158 *righttype = amop_tup->amoprighttype;
159 ReleaseSysCache(tp);
160}
static Datum CharGetDatum(char X)
Definition postgres.h:132

References CharGetDatum(), elog, ERROR, fb(), Form_pg_amop, 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(), MJExamineQuals(), and ri_populate_fastpath_metadata().

◆ get_op_opfamily_sortfamily()

Oid get_op_opfamily_sortfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 112 of file lsyscache.c.

113{
114 HeapTuple tp;
116 Oid result;
117
119 ObjectIdGetDatum(opno),
121 ObjectIdGetDatum(opfamily));
122 if (!HeapTupleIsValid(tp))
123 return InvalidOid;
125 result = amop_tup->amopsortfamily;
126 ReleaseSysCache(tp);
127 return result;
128}

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

Referenced by match_clause_to_ordering_op().

◆ get_op_opfamily_strategy()

◆ get_op_rettype()

Oid get_op_rettype ( Oid  opno)

Definition at line 1633 of file lsyscache.c.

1634{
1635 HeapTuple tp;
1636
1638 if (HeapTupleIsValid(tp))
1639 {
1641 Oid result;
1642
1643 result = optup->oprresult;
1644 ReleaseSysCache(tp);
1645 return result;
1646 }
1647 else
1648 return InvalidOid;
1649}

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

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

◆ get_opclass_family()

Oid get_opclass_family ( Oid  opclass)

Definition at line 1442 of file lsyscache.c.

1443{
1444 HeapTuple tp;
1446 Oid result;
1447
1448 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1449 if (!HeapTupleIsValid(tp))
1450 elog(ERROR, "cache lookup failed for opclass %u", opclass);
1452
1453 result = cla_tup->opcfamily;
1454 ReleaseSysCache(tp);
1455 return result;
1456}
END_CATALOG_STRUCT typedef FormData_pg_opclass * Form_pg_opclass
Definition pg_opclass.h:87

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

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

◆ get_opclass_input_type()

Oid get_opclass_input_type ( Oid  opclass)

◆ get_opclass_method()

Oid get_opclass_method ( Oid  opclass)

Definition at line 1512 of file lsyscache.c.

1513{
1514 HeapTuple tp;
1516 Oid result;
1517
1518 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1519 if (!HeapTupleIsValid(tp))
1520 elog(ERROR, "cache lookup failed for opclass %u", opclass);
1522
1523 result = cla_tup->opcmethod;
1524 ReleaseSysCache(tp);
1525 return result;
1526}

References elog, ERROR, fb(), Form_pg_opclass, GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), result, 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 1487 of file lsyscache.c.

1488{
1489 HeapTuple tp;
1491
1492 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1493 if (!HeapTupleIsValid(tp))
1494 return false;
1495
1497
1498 *opfamily = cla_tup->opcfamily;
1499 *opcintype = cla_tup->opcintype;
1500
1501 ReleaseSysCache(tp);
1502
1503 return true;
1504}

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

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

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1585 of file lsyscache.c.

1586{
1587 HeapTuple tp;
1588
1590 if (HeapTupleIsValid(tp))
1591 {
1594
1595 result = optup->oprcode;
1596 ReleaseSysCache(tp);
1597 return result;
1598 }
1599 else
1600 return (RegProcedure) InvalidOid;
1601}

References fb(), Form_pg_operator, GETSTRUCT(), HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), ReleaseSysCache(), result, 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(), initialize_change_context(), 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(), ri_populate_fastpath_metadata(), scalarineqsel(), select_equality_operator(), set_opfuncid(), set_sa_opfuncid(), statext_is_compatible_clause_internal(), std_typanalyze(), transformForPortionOfClause(), and var_eq_const().

◆ get_opfamily_member()

◆ get_opfamily_member_for_cmptype()

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

Definition at line 199 of file lsyscache.c.

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

References fb(), 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 1536 of file lsyscache.c.

1537{
1538 HeapTuple tp;
1540 Oid result;
1541
1543 if (!HeapTupleIsValid(tp))
1544 elog(ERROR, "cache lookup failed for operator family %u", opfid);
1546
1547 result = opfform->opfmethod;
1548 ReleaseSysCache(tp);
1549 return result;
1550}
END_CATALOG_STRUCT typedef FormData_pg_opfamily * Form_pg_opfamily
Definition pg_opfamily.h:55

References elog, ERROR, fb(), Form_pg_opfamily, GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), result, 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 1553 of file lsyscache.c.

1554{
1555 HeapTuple tup;
1556 char *opfname;
1558
1560
1561 if (!HeapTupleIsValid(tup))
1562 {
1563 if (!missing_ok)
1564 elog(ERROR, "cache lookup failed for operator family %u", opfid);
1565 return NULL;
1566 }
1567
1569 opfname = pstrdup(NameStr(opfform->opfname));
1570
1572
1573 return opfname;
1574}

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

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

◆ get_opfamily_proc()

◆ get_opmethod_canorder()

static bool get_opmethod_canorder ( Oid  amoid)
static

Definition at line 223 of file lsyscache.c.

224{
225 switch (amoid)
226 {
227 case BTREE_AM_OID:
228 return true;
229 case HASH_AM_OID:
230 case GIST_AM_OID:
231 case GIN_AM_OID:
232 case SPGIST_AM_OID:
233 case BRIN_AM_OID:
234 return false;
235 default:
237 }
238}
bool amcanorder
Definition amapi.h:247

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

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

◆ get_opname()

char * get_opname ( Oid  opno)

Definition at line 1610 of file lsyscache.c.

1611{
1612 HeapTuple tp;
1613
1615 if (HeapTupleIsValid(tp))
1616 {
1618 char *result;
1619
1620 result = pstrdup(NameStr(optup->oprname));
1621 ReleaseSysCache(tp);
1622 return result;
1623 }
1624 else
1625 return NULL;
1626}

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

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

◆ get_oprjoin()

RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1895 of file lsyscache.c.

1896{
1897 HeapTuple tp;
1898
1900 if (HeapTupleIsValid(tp))
1901 {
1904
1905 result = optup->oprjoin;
1906 ReleaseSysCache(tp);
1907 return result;
1908 }
1909 else
1910 return (RegProcedure) InvalidOid;
1911}

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

Referenced by join_selectivity(), and scalararraysel().

◆ get_oprrest()

◆ get_ordering_op_for_equality_op()

Oid get_ordering_op_for_equality_op ( Oid  opno,
bool  use_lhs_type 
)

Definition at line 364 of file lsyscache.c.

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

References COMPARE_EQ, COMPARE_LT, fb(), Form_pg_amop, get_opfamily_member_for_cmptype(), get_opmethod_canorder(), GETSTRUCT(), i, IndexAmTranslateStrategy(), InvalidOid, ObjectIdGetDatum(), OidIsValid, ReleaseSysCacheList, result, and SearchSysCacheList1.

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

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

References COMPARE_GT, COMPARE_INVALID, COMPARE_LT, fb(), Form_pg_amop, get_opmethod_canorder(), GETSTRUCT(), i, IndexAmTranslateStrategy(), InvalidOid, ObjectIdGetDatum(), ReleaseSysCacheList, result, and SearchSysCacheList1.

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

3128{
3129 Oid array_type = get_array_type(typid);
3130
3131 if (OidIsValid(array_type))
3132 return array_type;
3133 if (OidIsValid(get_element_type(typid)))
3134 return typid;
3135 return InvalidOid;
3136}
Oid get_element_type(Oid typid)
Definition lsyscache.c:3075
Oid get_array_type(Oid typid)
Definition lsyscache.c:3103

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

Referenced by build_subplan(), and exprType().

◆ get_propgraph_label_name()

char * get_propgraph_label_name ( Oid  labeloid)

Definition at line 4080 of file lsyscache.c.

4081{
4082 HeapTuple tuple;
4083 char *labelname;
4084
4086 if (!tuple)
4087 {
4088 elog(ERROR, "cache lookup failed for label %u", labeloid);
4089 return NULL;
4090 }
4092 ReleaseSysCache(tuple);
4093
4094 return labelname;
4095}
END_CATALOG_STRUCT typedef FormData_pg_propgraph_label * Form_pg_propgraph_label

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

Referenced by check_element_label_properties(), get_graph_label_expr(), get_path_elements_for_path_factor(), getObjectDescription(), getObjectIdentityParts(), and make_propgraphdef_labels().

◆ get_propgraph_property_name()

char * get_propgraph_property_name ( Oid  propoid)

Definition at line 4098 of file lsyscache.c.

4099{
4100 HeapTuple tuple;
4101 char *propname;
4102
4104 if (!tuple)
4105 {
4106 elog(ERROR, "cache lookup failed for property %u", propoid);
4107 return NULL;
4108 }
4110 ReleaseSysCache(tuple);
4111
4112 return propname;
4113}
END_CATALOG_STRUCT typedef FormData_pg_propgraph_property * Form_pg_propgraph_property

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

Referenced by check_element_properties(), get_element_label_property_names(), get_rule_expr(), getObjectDescription(), getObjectIdentityParts(), make_propgraphdef_properties(), replace_property_refs_mutator(), and transformRangeGraphTable().

◆ get_publication_name()

char * get_publication_name ( Oid  pubid,
bool  missing_ok 
)

Definition at line 4006 of file lsyscache.c.

4007{
4008 HeapTuple tup;
4009 char *pubname;
4011
4013
4014 if (!HeapTupleIsValid(tup))
4015 {
4016 if (!missing_ok)
4017 elog(ERROR, "cache lookup failed for publication %u", pubid);
4018 return NULL;
4019 }
4020
4022 pubname = pstrdup(NameStr(pubform->pubname));
4023
4025
4026 return pubname;
4027}
END_CATALOG_STRUCT typedef FormData_pg_publication * Form_pg_publication

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

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

◆ get_publication_oid()

Oid get_publication_oid ( const char pubname,
bool  missing_ok 
)

Definition at line 3986 of file lsyscache.c.

3987{
3988 Oid oid;
3989
3991 CStringGetDatum(pubname));
3992 if (!OidIsValid(oid) && !missing_ok)
3993 ereport(ERROR,
3995 errmsg("publication \"%s\" does not exist", pubname)));
3996 return oid;
3997}
static Datum CStringGetDatum(const char *X)
Definition postgres.h:383
#define GetSysCacheOid1(cacheId, oidcol, key1)
Definition syscache.h:109

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

Referenced by get_object_address_unqualified(), and GetPublicationByName().

◆ get_qualified_objname()

char * get_qualified_objname ( Oid  nspid,
char objname 
)

Definition at line 3720 of file lsyscache.c.

3721{
3722 char *nspname;
3723 char *result;
3724
3726 if (!nspname)
3727 elog(ERROR, "cache lookup failed for namespace %u", nspid);
3728
3729 result = quote_qualified_identifier(nspname, objname);
3730
3731 return result;
3732}
char * get_namespace_name_or_temp(Oid nspid)
Definition lsyscache.c:3706
char * quote_qualified_identifier(const char *qualifier, const char *ident)

References elog, ERROR, get_namespace_name_or_temp(), nspid, quote_qualified_identifier(), and result.

Referenced by create_conflict_log_table(), drop_sub_conflict_log_table(), generate_qualified_relation_name(), and RelationGetQualifiedRelationName().

◆ get_range_collation()

Oid get_range_collation ( Oid  rangeOid)

Definition at line 3769 of file lsyscache.c.

3770{
3771 HeapTuple tp;
3772
3774 if (HeapTupleIsValid(tp))
3775 {
3777 Oid result;
3778
3779 result = rngtup->rngcollation;
3780 ReleaseSysCache(tp);
3781 return result;
3782 }
3783 else
3784 return InvalidOid;
3785}

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

Referenced by CheckAttributeType().

◆ get_range_constructor2()

RegProcedure get_range_constructor2 ( Oid  rangeOid)

Definition at line 3794 of file lsyscache.c.

3795{
3796 HeapTuple tp;
3797
3799 if (HeapTupleIsValid(tp))
3800 {
3803
3804 result = rngtup->rngconstruct2;
3805 ReleaseSysCache(tp);
3806 return result;
3807 }
3808 else
3809 elog(ERROR, "cache lookup failed for range type %u", rangeOid);
3810}

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

Referenced by transformForPortionOfClause().

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

◆ get_range_subtype()

◆ get_rel_name()

char * get_rel_name ( Oid  relid)

Definition at line 2242 of file lsyscache.c.

2243{
2244 HeapTuple tp;
2245
2247 if (HeapTupleIsValid(tp))
2248 {
2250 char *result;
2251
2252 result = pstrdup(NameStr(reltup->relname));
2253 ReleaseSysCache(tp);
2254 return result;
2255 }
2256 else
2257 return NULL;
2258}
FormData_pg_class * Form_pg_class
Definition pg_class.h:160

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

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_attnums(), AdjustNotNullInheritance(), AlterCheckConstrEnforceabilityRecurse(), AlterPropGraph(), AlterPublicationOptions(), AlterSubscription_refresh(), AlterSubscription_refresh_seq(), AlterTableNamespace(), array_from_column_list(), ATExecAlterCheckConstrEnforceability(), ATExecAlterConstraint(), ATExecChangeOwner(), ATPrepAddPrimaryKey(), BeginCopyTo(), build_new_indexes(), check_element_properties(), check_enable_rls(), check_new_partition_bound(), check_parent_values_in_new_partitions(), check_partition_bounds_for_split_list(), check_partition_bounds_for_split_range(), check_publications_origin_sequences(), check_publications_origin_tables(), check_split_partition_not_same_bound(), collectPartitionIndexExtDeps(), convert_column_name(), CreateTriggerFiringOn(), DefineRelation(), do_autovacuum(), drop_sub_conflict_log_table(), EnableDisableRule(), errdetail_apply_conflict(), exec_object_restorecon(), ExecCheckPermissions(), execCurrentOf(), expand_col_privileges(), explain_get_index_name(), ExplainTargetRel(), FinishSyncWorker(), get_edge_oid(), get_path_elements_for_path_factor(), get_relation_constraint_attnos(), get_relation_constraint_oid(), get_relation_name(), get_relation_policy_oid(), get_rewrite_oid(), get_trigger_oid(), get_vertex_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(), make_propgraphdef_elements(), 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(), pgpa_compute_identifier_by_rti(), pgpa_create_identifiers_for_planned_stmt(), pgpa_output_relation_name(), pgpa_planner_apply_scan_advice(), pgpa_walker_index_target_matches_plan(), postgresExplainForeignScan(), process_owned_by(), QueueNNConstraintValidation(), rebuild_relation_finish_concurrent(), refuseDupeIndexAttach(), reindex_index(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), RememberClusterOnForRebuilding(), RememberReplicaIdentityForRebuilding(), RemoveSubscriptionRel(), RenameConstraintById(), renametrig(), repack_is_permitted_for_relation(), satisfies_hash_partition(), set_rtable_names(), show_modifytable_info(), start_repack_decoding_worker(), subquery_planner(), swap_relation_files(), SysCacheGetAttrNotNull(), table_to_xml_internal(), TargetPrivilegesCheck(), transformAlterTableStmt(), transformLabelExpr(), transformPartitionCmdForSplit(), and verifyNotNullPKCompatible().

◆ get_rel_namespace()

◆ get_rel_persistence()

char get_rel_persistence ( Oid  relid)

Definition at line 2392 of file lsyscache.c.

2393{
2394 HeapTuple tp;
2396 char result;
2397
2399 if (!HeapTupleIsValid(tp))
2400 elog(ERROR, "cache lookup failed for relation %u", relid);
2402 result = reltup->relpersistence;
2403 ReleaseSysCache(tp);
2404
2405 return result;
2406}

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

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

◆ get_rel_relam()

Oid get_rel_relam ( Oid  relid)

Definition at line 2414 of file lsyscache.c.

2415{
2416 HeapTuple tp;
2418 Oid result;
2419
2421 if (!HeapTupleIsValid(tp))
2422 elog(ERROR, "cache lookup failed for relation %u", relid);
2424 result = reltup->relam;
2425 ReleaseSysCache(tp);
2426
2427 return result;
2428}

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

Referenced by DefineRelation().

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

◆ get_rel_relkind()

char get_rel_relkind ( Oid  relid)

Definition at line 2317 of file lsyscache.c.

2318{
2319 HeapTuple tp;
2320
2322 if (HeapTupleIsValid(tp))
2323 {
2325 char result;
2326
2327 result = reltup->relkind;
2328 ReleaseSysCache(tp);
2329 return result;
2330 }
2331 else
2332 return '\0';
2333}

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

Referenced by AlterPublicationOptions(), AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), ATExecAlterConstrDeferrability(), ATExecAlterFKConstrEnforceability(), ATExecChangeOwner(), AttachPartitionForeignKey(), BeginCopyTo(), check_rel_can_be_partition(), check_relation_privileges(), CreateTriggerFiringOn(), doDeletion(), EnableDisableRule(), exec_object_restorecon(), ExecCheckPermissions(), FetchRelationStates(), get_object_type(), get_rel_sync_entry(), get_tables_to_repack_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(), is_table_publishable_in_publication(), 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(), ri_LoadConstraintInfo(), 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 2368 of file lsyscache.c.

2369{
2370 HeapTuple tp;
2371
2373 if (HeapTupleIsValid(tp))
2374 {
2376 Oid result;
2377
2378 result = reltup->reltablespace;
2379 ReleaseSysCache(tp);
2380 return result;
2381 }
2382 else
2383 return InvalidOid;
2384}

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

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

◆ get_rel_type_id()

◆ get_relname_relid()

◆ get_subscription_name()

char * get_subscription_name ( Oid  subid,
bool  missing_ok 
)

Definition at line 4056 of file lsyscache.c.

4057{
4058 HeapTuple tup;
4059 char *subname;
4061
4063
4064 if (!HeapTupleIsValid(tup))
4065 {
4066 if (!missing_ok)
4067 elog(ERROR, "cache lookup failed for subscription %u", subid);
4068 return NULL;
4069 }
4070
4072 subname = pstrdup(NameStr(subform->subname));
4073
4075
4076 return subname;
4077}
NameData subname
END_CATALOG_STRUCT typedef FormData_pg_subscription * Form_pg_subscription

References elog, ERROR, fb(), Form_pg_subscription, 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 4036 of file lsyscache.c.

4037{
4038 Oid oid;
4039
4042 if (!OidIsValid(oid) && !missing_ok)
4043 ereport(ERROR,
4045 errmsg("subscription \"%s\" does not exist", subname)));
4046 return oid;
4047}
Oid MyDatabaseId
Definition globals.c:96

References CStringGetDatum(), ereport, errcode(), errmsg, ERROR, fb(), 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 2434 of file lsyscache.c.

2435{
2436 HeapTuple tup;
2437
2438 if (!list_member_oid(trftypes, typid))
2439 return InvalidOid;
2440
2442 ObjectIdGetDatum(langid));
2443 if (HeapTupleIsValid(tup))
2444 {
2445 Oid funcid;
2446
2447 funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2449 return funcid;
2450 }
2451 else
2452 return InvalidOid;
2453}
bool list_member_oid(const List *list, Oid datum)
Definition list.c:722
END_CATALOG_STRUCT typedef FormData_pg_transform * Form_pg_transform

References fb(), Form_pg_transform, 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 2456 of file lsyscache.c.

2457{
2458 HeapTuple tup;
2459
2460 if (!list_member_oid(trftypes, typid))
2461 return InvalidOid;
2462
2464 ObjectIdGetDatum(langid));
2465 if (HeapTupleIsValid(tup))
2466 {
2467 Oid funcid;
2468
2469 funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
2471 return funcid;
2472 }
2473 else
2474 return InvalidOid;
2475}

References fb(), Form_pg_transform, 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 3047 of file lsyscache.c.

3048{
3049 HeapTuple tp;
3050
3052 if (HeapTupleIsValid(tp))
3053 {
3055 Oid result;
3056
3057 result = typtup->typrelid;
3058 ReleaseSysCache(tp);
3059 return result;
3060 }
3061 else
3062 return InvalidOid;
3063}

References fb(), Form_pg_type, GETSTRUCT(), HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), ReleaseSysCache(), result, 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 2894 of file lsyscache.c.

2895{
2896 int typlen = get_typlen(typid);
2898
2899 /*
2900 * Easy if it's a fixed-width type
2901 */
2902 if (typlen > 0)
2903 return typlen;
2904
2905 /*
2906 * type_maximum_size knows the encoding of typmod for some datatypes;
2907 * don't duplicate that knowledge here.
2908 */
2909 maxwidth = type_maximum_size(typid, typmod);
2910 if (maxwidth > 0)
2911 {
2912 /*
2913 * For BPCHAR, the max width is also the only width. Otherwise we
2914 * need to guess about the typical data width given the max. A sliding
2915 * scale for percentage of max width seems reasonable.
2916 */
2917 if (typid == BPCHAROID)
2918 return maxwidth;
2919 if (maxwidth <= 32)
2920 return maxwidth; /* assume full width */
2921 if (maxwidth < 1000)
2922 return 32 + (maxwidth - 32) / 2; /* assume 50% */
2923
2924 /*
2925 * Beyond 1000, assume we're looking at something like
2926 * "varchar(10000)" where the limit isn't actually reached often, and
2927 * use a fixed estimate.
2928 */
2929 return 32 + (1000 - 32) / 2;
2930 }
2931
2932 /*
2933 * Oops, we have no idea ... wild guess time.
2934 */
2935 return 32;
2936}
int32 type_maximum_size(Oid type_oid, int32 typemod)
int16 get_typlen(Oid typid)
Definition lsyscache.c:2511

References fb(), 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 2536 of file lsyscache.c.

2537{
2538 HeapTuple tp;
2539
2541 if (HeapTupleIsValid(tp))
2542 {
2544 bool result;
2545
2546 result = typtup->typbyval;
2547 ReleaseSysCache(tp);
2548 return result;
2549 }
2550 else
2551 return false;
2552}

References fb(), Form_pg_type, GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), result, and SearchSysCache1().

Referenced by brin_range_deserialize(), and brin_range_serialize().

◆ get_typcollation()

◆ get_typdefault()

Node * get_typdefault ( Oid  typid)

Definition at line 2764 of file lsyscache.c.

2765{
2768 Datum datum;
2769 bool isNull;
2770 Node *expr;
2771
2774 elog(ERROR, "cache lookup failed for type %u", typid);
2776
2777 /*
2778 * typdefault and typdefaultbin are potentially null, so don't try to
2779 * access 'em as struct fields. Must do it the hard way with
2780 * SysCacheGetAttr.
2781 */
2782 datum = SysCacheGetAttr(TYPEOID,
2783 typeTuple,
2785 &isNull);
2786
2787 if (!isNull)
2788 {
2789 /* We have an expression default */
2790 expr = stringToNode(TextDatumGetCString(datum));
2791 }
2792 else
2793 {
2794 /* Perhaps we have a plain literal default */
2795 datum = SysCacheGetAttr(TYPEOID,
2796 typeTuple,
2798 &isNull);
2799
2800 if (!isNull)
2801 {
2802 char *strDefaultVal;
2803
2804 /* Convert text datum to C string */
2806 /* Convert C string to a value of the given type */
2807 datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2809 /* Build a Const node containing the value */
2810 expr = (Node *) makeConst(typid,
2811 -1,
2812 type->typcollation,
2813 type->typlen,
2814 datum,
2815 false,
2816 type->typbyval);
2818 }
2819 else
2820 {
2821 /* No default */
2822 expr = NULL;
2823 }
2824 }
2825
2827
2828 return expr;
2829}
#define TextDatumGetCString(d)
Definition builtins.h:99
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition fmgr.c:1755
Oid getTypeIOParam(HeapTuple typeTuple)
Definition lsyscache.c:2617
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:133
const char * type

References elog, ERROR, fb(), Form_pg_type, 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 
)

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

2647{
2650
2651 /*
2652 * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2653 * use array_in and array_out during bootstrap.
2654 */
2656 {
2657 Oid typinput;
2658 Oid typoutput;
2659 Oid typcollation;
2660
2662 typlen,
2663 typbyval,
2664 typalign,
2665 typdelim,
2666 typioparam,
2667 &typinput,
2668 &typoutput,
2669 &typcollation);
2670 switch (which_func)
2671 {
2672 case IOFunc_input:
2673 *func = typinput;
2674 break;
2675 case IOFunc_output:
2676 *func = typoutput;
2677 break;
2678 default:
2679 elog(ERROR, "binary I/O not supported during bootstrap");
2680 break;
2681 }
2682 return;
2683 }
2684
2687 elog(ERROR, "cache lookup failed for type %u", typid);
2689
2690 *typlen = typeStruct->typlen;
2691 *typbyval = typeStruct->typbyval;
2692 *typalign = typeStruct->typalign;
2693 *typdelim = typeStruct->typdelim;
2694 *typioparam = getTypeIOParam(typeTuple);
2695 switch (which_func)
2696 {
2697 case IOFunc_input:
2698 *func = typeStruct->typinput;
2699 break;
2700 case IOFunc_output:
2701 *func = typeStruct->typoutput;
2702 break;
2703 case IOFunc_receive:
2704 *func = typeStruct->typreceive;
2705 break;
2706 case IOFunc_send:
2707 *func = typeStruct->typsend;
2708 break;
2709 }
2711}
void boot_get_type_io_data(Oid typid, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *typinput, Oid *typoutput, Oid *typcollation)
Definition bootstrap.c:1011
@ IOFunc_output
Definition lsyscache.h:37
@ IOFunc_input
Definition lsyscache.h:36
@ IOFunc_send
Definition lsyscache.h:39
@ IOFunc_receive
Definition lsyscache.h:38
#define IsBootstrapProcessingMode()
Definition miscadmin.h:486
char typalign
Definition pg_type.h:178

References boot_get_type_io_data(), elog, ERROR, fb(), Form_pg_type, 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 2487 of file lsyscache.c.

2488{
2489 HeapTuple tp;
2490
2492 if (HeapTupleIsValid(tp))
2493 {
2495 bool result;
2496
2497 result = typtup->typisdefined;
2498 ReleaseSysCache(tp);
2499 return result;
2500 }
2501 else
2502 return false;
2503}

References fb(), Form_pg_type, GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), result, and SearchSysCache1().

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

◆ get_typlen()

◆ get_typlenbyval()

◆ get_typlenbyvalalign()

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

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 3322 of file lsyscache.c.

3323{
3324 HeapTuple tp;
3325
3327 if (HeapTupleIsValid(tp))
3328 {
3330 Oid result;
3331
3332 result = typtup->typmodin;
3333 ReleaseSysCache(tp);
3334 return result;
3335 }
3336 else
3337 return InvalidOid;
3338}

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2735 of file lsyscache.c.

2736{
2737 HeapTuple tp;
2738
2740 if (HeapTupleIsValid(tp))
2741 {
2743 char result;
2744
2745 result = typtup->typstorage;
2746 ReleaseSysCache(tp);
2747 return result;
2748 }
2749 else
2750 return TYPSTORAGE_PLAIN;
2751}

References fb(), Form_pg_type, GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), result, and SearchSysCache1().

Referenced by GetAttributeStorage().

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3413 of file lsyscache.c.

3414{
3415 HeapTuple tp;
3416
3418 if (HeapTupleIsValid(tp))
3419 {
3421 RegProcedure handler = typform->typsubscript;
3422
3423 if (typelemp)
3424 *typelemp = typform->typelem;
3425 ReleaseSysCache(tp);
3426 return handler;
3427 }
3428 else
3429 {
3430 if (typelemp)
3432 return InvalidOid;
3433 }
3434}

References fb(), Form_pg_type, 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 2854 of file lsyscache.c.

2855{
2856 /*
2857 * We loop to find the bottom base type in a stack of domains.
2858 */
2859 for (;;)
2860 {
2861 HeapTuple tup;
2863
2865 if (!HeapTupleIsValid(tup))
2866 elog(ERROR, "cache lookup failed for type %u", typid);
2868 if (typTup->typtype != TYPTYPE_DOMAIN)
2869 {
2870 /* Not a domain, so done */
2872 break;
2873 }
2874
2875 Assert(*typmod == -1);
2876 typid = typTup->typbasetype;
2877 *typmod = typTup->typtypmod;
2878
2880 }
2881
2882 return typid;
2883}

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

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

◆ getSubscriptingRoutines()

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

Definition at line 3446 of file lsyscache.c.

3447{
3448 RegProcedure typsubscript = get_typsubscript(typid, typelemp);
3449
3450 if (!OidIsValid(typsubscript))
3451 return NULL;
3452
3453 return (const struct SubscriptRoutines *)
3454 DatumGetPointer(OidFunctionCall0(typsubscript));
3455}
#define OidFunctionCall0(functionId)
Definition fmgr.h:724
RegProcedure get_typsubscript(Oid typid, Oid *typelemp)
Definition lsyscache.c:3413

References DatumGetPointer(), fb(), 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 3256 of file lsyscache.c.

3257{
3260
3263 elog(ERROR, "cache lookup failed for type %u", type);
3265
3266 if (!pt->typisdefined)
3267 ereport(ERROR,
3269 errmsg("type %s is only a shell",
3270 format_type_be(type))));
3271 if (!OidIsValid(pt->typreceive))
3272 ereport(ERROR,
3274 errmsg("no binary input function available for type %s",
3275 format_type_be(type))));
3276
3277 *typReceive = pt->typreceive;
3279
3281}

References elog, ereport, errcode(), errmsg, ERROR, fb(), Form_pg_type, 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 3289 of file lsyscache.c.

3290{
3293
3296 elog(ERROR, "cache lookup failed for type %u", type);
3298
3299 if (!pt->typisdefined)
3300 ereport(ERROR,
3302 errmsg("type %s is only a shell",
3303 format_type_be(type))));
3304 if (!OidIsValid(pt->typsend))
3305 ereport(ERROR,
3307 errmsg("no binary output function available for type %s",
3308 format_type_be(type))));
3309
3310 *typSend = pt->typsend;
3311 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
3312
3314}

References elog, ereport, errcode(), errmsg, ERROR, fb(), Form_pg_type, 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 3190 of file lsyscache.c.

3191{
3194
3197 elog(ERROR, "cache lookup failed for type %u", type);
3199
3200 if (!pt->typisdefined)
3201 ereport(ERROR,
3203 errmsg("type %s is only a shell",
3204 format_type_be(type))));
3205 if (!OidIsValid(pt->typinput))
3206 ereport(ERROR,
3208 errmsg("no input function available for type %s",
3209 format_type_be(type))));
3210
3211 *typInput = pt->typinput;
3213
3215}

References elog, ereport, errcode(), errmsg, ERROR, fb(), Form_pg_type, 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(), GetAggInitVal(), 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(), statext_mcv_import(), transformJsonArrayQueryConstructor(), and TupleDescGetAttInMetadata().

◆ getTypeIOParam()

Oid getTypeIOParam ( HeapTuple  typeTuple)

Definition at line 2617 of file lsyscache.c.

2618{
2620
2621 /*
2622 * Array types get their typelem as parameter; everybody else gets their
2623 * own type OID as parameter.
2624 */
2625 if (OidIsValid(typeStruct->typelem))
2626 return typeStruct->typelem;
2627 else
2628 return typeStruct->oid;
2629}

References fb(), Form_pg_type, 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 3223 of file lsyscache.c.

3224{
3227
3230 elog(ERROR, "cache lookup failed for type %u", type);
3232
3233 if (!pt->typisdefined)
3234 ereport(ERROR,
3236 errmsg("type %s is only a shell",
3237 format_type_be(type))));
3238 if (!OidIsValid(pt->typoutput))
3239 ereport(ERROR,
3241 errmsg("no output function available for type %s",
3242 format_type_be(type))));
3243
3244 *typOutput = pt->typoutput;
3245 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
3246
3248}

References elog, ereport, errcode(), errmsg, ERROR, fb(), Form_pg_type, 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(), ChooseIndexExpressionName_walker(), 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 1739 of file lsyscache.c.

1740{
1741 bool result = false;
1742 HeapTuple tp;
1743 TypeCacheEntry *typentry;
1744
1745 /* As in op_mergejoinable, let the typcache handle the hard cases */
1746 if (opno == ARRAY_EQ_OP)
1747 {
1748 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1749 if (typentry->hash_proc == F_HASH_ARRAY)
1750 result = true;
1751 }
1752 else if (opno == RECORD_EQ_OP)
1753 {
1754 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1755 if (typentry->hash_proc == F_HASH_RECORD)
1756 result = true;
1757 }
1758 else if (opno == RANGE_EQ_OP)
1759 {
1760 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1761 if (typentry->hash_proc == F_HASH_RANGE)
1762 result = true;
1763 }
1764 else if (opno == MULTIRANGE_EQ_OP)
1765 {
1766 typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1767 if (typentry->hash_proc == F_HASH_MULTIRANGE)
1768 result = true;
1769 }
1770 else
1771 {
1772 /* For all other operators, rely on pg_operator.oprcanhash */
1774 if (HeapTupleIsValid(tp))
1775 {
1777
1778 result = optup->oprcanhash;
1779 ReleaseSysCache(tp);
1780 }
1781 }
1782 return result;
1783}

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

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

◆ op_in_opfamily()

◆ op_input_types()

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

Definition at line 1658 of file lsyscache.c.

1659{
1660 HeapTuple tp;
1662
1664 if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1665 elog(ERROR, "cache lookup failed for operator %u", opno);
1667 *lefttype = optup->oprleft;
1668 *righttype = optup->oprright;
1669 ReleaseSysCache(tp);
1670}

References elog, ERROR, fb(), Form_pg_operator, 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_is_safe_index_member()

bool op_is_safe_index_member ( Oid  opno)

Definition at line 980 of file lsyscache.c.

981{
982 bool result = false;
984 int i;
985
986 /*
987 * Search pg_amop to see if the target operator is registered for any
988 * btree or hash opfamily.
989 */
991
992 for (i = 0; i < catlist->n_members; i++)
993 {
994 HeapTuple tuple = &catlist->members[i]->tuple;
996
997 /* Check if the AM is B-tree or Hash */
998 if (aform->amopmethod == BTREE_AM_OID ||
999 aform->amopmethod == HASH_AM_OID)
1000 {
1001 result = true;
1002 break;
1003 }
1004 }
1005
1007
1008 return result;
1009}

References fb(), Form_pg_amop, GETSTRUCT(), i, ObjectIdGetDatum(), ReleaseSysCacheList, result, and SearchSysCacheList1.

Referenced by grouping_conflict_walker(), and sublink_testexpr_is_not_nullable().

◆ op_mergejoinable()

bool op_mergejoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1686 of file lsyscache.c.

1687{
1688 bool result = false;
1689 HeapTuple tp;
1690 TypeCacheEntry *typentry;
1691
1692 /*
1693 * For array_eq or record_eq, we can sort if the element or field types
1694 * are all sortable. We could implement all the checks for that here, but
1695 * the typcache already does that and caches the results too, so let's
1696 * rely on the typcache. We do not need similar special cases for ranges
1697 * or multiranges, because their subtypes are required to be sortable.
1698 */
1699 if (opno == ARRAY_EQ_OP)
1700 {
1701 typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1702 if (typentry->cmp_proc == F_BTARRAYCMP)
1703 result = true;
1704 }
1705 else if (opno == RECORD_EQ_OP)
1706 {
1707 typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1708 if (typentry->cmp_proc == F_BTRECORDCMP)
1709 result = true;
1710 }
1711 else
1712 {
1713 /* For all other operators, rely on pg_operator.oprcanmerge */
1715 if (HeapTupleIsValid(tp))
1716 {
1718
1719 result = optup->oprcanmerge;
1720 ReleaseSysCache(tp);
1721 }
1722 }
1723 return result;
1724}
#define TYPECACHE_CMP_PROC
Definition typcache.h:141

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

Referenced by check_mergejoinable(), and compute_semijoin_info().

◆ op_strict()

bool op_strict ( Oid  opno)

Definition at line 1791 of file lsyscache.c.

1792{
1793 RegProcedure funcid = get_opcode(opno);
1794
1795 if (funcid == (RegProcedure) InvalidOid)
1796 elog(ERROR, "operator %u does not exist", opno);
1797
1798 return func_strict((Oid) funcid);
1799}
RegProcedure get_opcode(Oid opno)
Definition lsyscache.c:1585
bool func_strict(Oid funcid)
Definition lsyscache.c:2075

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

1808{
1809 RegProcedure funcid = get_opcode(opno);
1810
1811 if (funcid == (RegProcedure) InvalidOid)
1812 elog(ERROR, "operator %u does not exist", opno);
1813
1814 return func_volatile((Oid) funcid);
1815}
char func_volatile(Oid funcid)
Definition lsyscache.c:2094

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

2995{
2996 return (get_typtype(typid) == TYPTYPE_ENUM);
2997}
char get_typtype(Oid typid)
Definition lsyscache.c:2945

References fb(), and get_typtype().

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

◆ type_is_multirange()

◆ type_is_range()

◆ type_is_rowtype()

bool type_is_rowtype ( Oid  typid)

Variable Documentation

◆ get_attavgwidth_hook

get_attavgwidth_hook_type get_attavgwidth_hook = NULL

Definition at line 57 of file lsyscache.c.

Referenced by get_attavgwidth().