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

948{
949 if (!OidIsValid(coll1) || !OidIsValid(coll2))
950 return true;
951
952 if (coll1 == coll2)
953 return true;
954
957 return false;
958
959 return true;
960}
#define OidIsValid(objectId)
Definition c.h:858
bool get_collation_isdeterministic(Oid colloid)
Definition lsyscache.c:1272
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 886 of file lsyscache.c.

887{
888 bool result;
890 int i;
891
892 /* Easy if they're the same operator */
893 if (opno1 == opno2)
894 return true;
895
896 /*
897 * We search through all the pg_amop entries for opno1.
898 */
900
901 result = false;
902 for (i = 0; i < catlist->n_members; i++)
903 {
904 HeapTuple op_tuple = &catlist->members[i]->tuple;
906
907 /*
908 * op_in_opfamily() is cheaper than GetIndexAmRoutineByAmId(), so
909 * check it first
910 */
911 if (op_in_opfamily(opno2, op_form->amopfamily) &&
913 {
914 result = true;
915 break;
916 }
917 }
918
920
921 return result;
922}
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 834 of file lsyscache.c.

835{
836 bool result;
838 int i;
839
840 /* Easy if they're the same operator */
841 if (opno1 == opno2)
842 return true;
843
844 /*
845 * We search through all the pg_amop entries for opno1.
846 */
848
849 result = false;
850 for (i = 0; i < catlist->n_members; i++)
851 {
852 HeapTuple op_tuple = &catlist->members[i]->tuple;
854
855 /*
856 * op_in_opfamily() is cheaper than GetIndexAmRoutineByAmId(), so
857 * check it first
858 */
859 if (op_in_opfamily(opno2, op_form->amopfamily) &&
861 {
862 result = true;
863 break;
864 }
865 }
866
868
869 return result;
870}
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 query_is_distinct_for().

◆ free_attstatsslot()

void free_attstatsslot ( AttStatsSlot sslot)

Definition at line 3652 of file lsyscache.c.

3653{
3654 /* The values[] array was separately palloc'd by deconstruct_array */
3655 if (sslot->values)
3656 pfree(sslot->values);
3657 /* The numbers[] array points into numbers_arr, do not pfree it */
3658 /* Free the detoasted array objects, if any */
3659 if (sslot->values_arr)
3660 pfree(sslot->values_arr);
3661 if (sslot->numbers_arr)
3662 pfree(sslot->numbers_arr);
3663}
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 2105 of file lsyscache.c.

2106{
2107 HeapTuple tp;
2108 char result;
2109
2111 if (!HeapTupleIsValid(tp))
2112 elog(ERROR, "cache lookup failed for function %u", funcid);
2113
2115 ReleaseSysCache(tp);
2116 return result;
2117}
#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 3466 of file lsyscache.c.

3467{
3468 HeapTuple tp;
3469 int32 stawidth;
3470
3472 {
3473 stawidth = (*get_attavgwidth_hook) (relid, attnum);
3474 if (stawidth > 0)
3475 return stawidth;
3476 }
3478 ObjectIdGetDatum(relid),
3480 BoolGetDatum(false));
3481 if (HeapTupleIsValid(tp))
3482 {
3483 stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3484 ReleaseSysCache(tp);
3485 if (stawidth > 0)
3486 return stawidth;
3487 }
3488 return 0;
3489}
int32_t int32
Definition c.h:620
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 1106 of file lsyscache.c.

1107{
1108 HeapTuple tp;
1110 char result;
1111
1113 ObjectIdGetDatum(relid),
1115 if (!HeapTupleIsValid(tp))
1116 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1117 attnum, relid);
1119 result = att_tup->attgenerated;
1120 ReleaseSysCache(tp);
1121 return result;
1122}
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(), and CreateStatistics().

◆ get_attname()

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

Definition at line 1045 of file lsyscache.c.

1046{
1047 HeapTuple tp;
1048
1051 if (HeapTupleIsValid(tp))
1052 {
1054 char *result;
1055
1056 result = pstrdup(NameStr(att_tup->attname));
1057 ReleaseSysCache(tp);
1058 return result;
1059 }
1060
1061 if (!missing_ok)
1062 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1063 attnum, relid);
1064 return NULL;
1065}
#define NameStr(name)
Definition c.h:835
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(), 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 1188 of file lsyscache.c.

1189{
1190 HeapTuple tuple;
1191 Datum attopts;
1192 Datum result;
1193 bool isnull;
1194
1195 tuple = SearchSysCache2(ATTNUM,
1196 ObjectIdGetDatum(relid),
1198
1199 if (!HeapTupleIsValid(tuple))
1200 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1201 attnum, relid);
1202
1204 &isnull);
1205
1206 if (isnull)
1207 result = (Datum) 0;
1208 else
1209 result = datumCopy(attopts, false, -1); /* text[] */
1210
1211 ReleaseSysCache(tuple);
1212
1213 return result;
1214}
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 3542 of file lsyscache.c.

3544{
3546 int i;
3547 Datum val;
3550 int narrayelem;
3553
3554 /* initialize *sslot properly */
3555 memset(sslot, 0, sizeof(AttStatsSlot));
3556
3557 for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
3558 {
3559 if ((&stats->stakind1)[i] == reqkind &&
3560 (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
3561 break;
3562 }
3563 if (i >= STATISTIC_NUM_SLOTS)
3564 return false; /* not there */
3565
3566 sslot->staop = (&stats->staop1)[i];
3567 sslot->stacoll = (&stats->stacoll1)[i];
3568
3569 if (flags & ATTSTATSSLOT_VALUES)
3570 {
3573
3574 /*
3575 * Detoast the array if needed, and in any case make a copy that's
3576 * under control of this AttStatsSlot.
3577 */
3579
3580 /*
3581 * Extract the actual array element type, and pass it back in case the
3582 * caller needs it.
3583 */
3584 sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3585
3586 /* Need info about element type */
3589 elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3591
3592 /* Deconstruct array into Datum elements; NULLs not expected */
3595 typeForm->typlen,
3596 typeForm->typbyval,
3597 typeForm->typalign,
3598 &sslot->values, NULL, &sslot->nvalues);
3599
3600 /*
3601 * If the element type is pass-by-reference, we now have a bunch of
3602 * Datums that are pointers into the statarray, so we need to keep
3603 * that until free_attstatsslot. Otherwise, all the useful info is in
3604 * sslot->values[], so we can free the array object immediately.
3605 */
3606 if (!typeForm->typbyval)
3607 sslot->values_arr = statarray;
3608 else
3610
3612 }
3613
3614 if (flags & ATTSTATSSLOT_NUMBERS)
3615 {
3618
3619 /*
3620 * Detoast the array if needed, and in any case make a copy that's
3621 * under control of this AttStatsSlot.
3622 */
3624
3625 /*
3626 * We expect the array to be a 1-D float4 array; verify that. We don't
3627 * need to use deconstruct_array() since the array data is just going
3628 * to look like a C array of float4 values.
3629 */
3631 if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3634 elog(ERROR, "stanumbers is not a 1-D float4 array");
3635
3636 /* Give caller a pointer directly into the statarray */
3637 sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3638 sslot->nnumbers = narrayelem;
3639
3640 /* We'll free the statarray in free_attstatsslot */
3641 sslot->numbers_arr = statarray;
3642 }
3643
3644 return true;
3645}
#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:713
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 1131 of file lsyscache.c.

1132{
1133 HeapTuple tp;
1134
1136 ObjectIdGetDatum(relid),
1138 if (HeapTupleIsValid(tp))
1139 {
1141 Oid result;
1142
1143 result = att_tup->atttypid;
1144 ReleaseSysCache(tp);
1145 return result;
1146 }
1147 else
1148 return InvalidOid;
1149}

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

1163{
1164 HeapTuple tp;
1166
1168 ObjectIdGetDatum(relid),
1170 if (!HeapTupleIsValid(tp))
1171 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1172 attnum, relid);
1174
1175 *typid = att_tup->atttypid;
1176 *typmod = att_tup->atttypmod;
1177 *collid = att_tup->attcollation;
1178 ReleaseSysCache(tp);
1179}
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 3140 of file lsyscache.c.

3141{
3142 /*
3143 * We loop to find the bottom base type in a stack of domains.
3144 */
3145 for (;;)
3146 {
3147 HeapTuple tup;
3149
3151 if (!HeapTupleIsValid(tup))
3152 break;
3154 if (typTup->typtype != TYPTYPE_DOMAIN)
3155 {
3156 /* Not a domain, so stop descending */
3157 Oid result;
3158
3159 /* This test must match get_element_type */
3161 result = typTup->typelem;
3162 else
3165 return result;
3166 }
3167
3168 typid = typTup->typbasetype;
3170 }
3171
3172 /* Like get_element_type, silently return InvalidOid for bogus input */
3173 return InvalidOid;
3174}

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

1226{
1227 Oid oid;
1228
1232 if (!OidIsValid(oid) && !missing_ok)
1233 ereport(ERROR,
1235 errmsg("cast from type %s to type %s does not exist",
1238 return oid;
1239}
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 1272 of file lsyscache.c.

1273{
1274 HeapTuple tp;
1276 bool result;
1277
1279 if (!HeapTupleIsValid(tp))
1280 elog(ERROR, "cache lookup failed for collation %u", colloid);
1282 result = colltup->collisdeterministic;
1283 ReleaseSysCache(tp);
1284 return result;
1285}
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(), having_collation_conflict_walker(), index_create(), and match_pattern_prefix().

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

1332{
1333 HeapTuple tp;
1334
1336 if (HeapTupleIsValid(tp))
1337 {
1339 Oid result;
1340
1341 if (contup->contype == CONSTRAINT_UNIQUE ||
1342 contup->contype == CONSTRAINT_PRIMARY ||
1343 contup->contype == CONSTRAINT_EXCLUSION)
1344 result = contup->conindid;
1345 else
1347 ReleaseSysCache(tp);
1348 return result;
1349 }
1350 else
1351 return InvalidOid;
1352}
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 1299 of file lsyscache.c.

1300{
1301 HeapTuple tp;
1302
1304 if (HeapTupleIsValid(tp))
1305 {
1307 char *result;
1308
1309 result = pstrdup(NameStr(contup->conname));
1310 ReleaseSysCache(tp);
1311 return result;
1312 }
1313 else
1314 return NULL;
1315}

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

1362{
1363 HeapTuple tp;
1364 char contype;
1365
1367 if (!HeapTupleIsValid(tp))
1368 elog(ERROR, "cache lookup failed for constraint %u", conoid);
1369
1370 contype = ((Form_pg_constraint) GETSTRUCT(tp))->contype;
1371 ReleaseSysCache(tp);
1372
1373 return contype;
1374}

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

1385{
1387 char *result;
1388
1391 {
1394 }
1395 else
1396 result = NULL;
1397
1398 return result;
1399}
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(), CreateSubscription(), current_database(), database_to_xml_internal(), DeconstructQualifiedName(), do_analyze_rel(), do_autovacuum(), exec_object_restorecon(), ExpandColumnRefStar(), GetNewMultiXactId(), GetNewTransactionId(), getObjectDescription(), getObjectIdentityParts(), heap_vacuum_rel(), IdentifySystem(), InitTempTableNamespace(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), perform_work_item(), 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 1938 of file lsyscache.c.

1939{
1940 HeapTuple tp;
1941
1943 if (HeapTupleIsValid(tp))
1944 {
1946 Oid result;
1947
1948 result = functup->pronamespace;
1949 ReleaseSysCache(tp);
1950 return result;
1951 }
1952 else
1953 return InvalidOid;
1954}

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

1981{
1982 HeapTuple tp;
1983 int result;
1984
1986 if (!HeapTupleIsValid(tp))
1987 elog(ERROR, "cache lookup failed for function %u", funcid);
1988
1990 ReleaseSysCache(tp);
1991 return result;
1992}
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 2124 of file lsyscache.c.

2125{
2126 HeapTuple tp;
2127 char result;
2128
2130 if (!HeapTupleIsValid(tp))
2131 elog(ERROR, "cache lookup failed for function %u", funcid);
2132
2133 result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
2134 ReleaseSysCache(tp);
2135 return result;
2136}

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

2049{
2050 HeapTuple tp;
2051 bool result;
2052
2054 if (!HeapTupleIsValid(tp))
2055 elog(ERROR, "cache lookup failed for function %u", funcid);
2056
2058 ReleaseSysCache(tp);
2059 return result;
2060}

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

2003{
2004 HeapTuple tp;
2006 Oid result;
2007
2009 if (!HeapTupleIsValid(tp))
2010 elog(ERROR, "cache lookup failed for function %u", funcid);
2011
2013
2014 result = procstruct->prorettype;
2015 *nargs = (int) procstruct->pronargs;
2016 Assert(*nargs == procstruct->proargtypes.dim1);
2017 *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
2018 memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
2019
2020 ReleaseSysCache(tp);
2021 return result;
2022}
#define Assert(condition)
Definition c.h:943
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 2029 of file lsyscache.c.

2030{
2031 HeapTuple tp;
2032 Oid result;
2033
2035 if (!HeapTupleIsValid(tp))
2036 elog(ERROR, "cache lookup failed for function %u", funcid);
2037
2039 ReleaseSysCache(tp);
2040 return result;
2041}

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

3866{
3867 HeapTuple tuple;
3868 Form_pg_index rd_index;
3869 Datum datum;
3871 Oid opclass;
3872
3873 /* First we need to know the column's opclass. */
3874
3876 if (!HeapTupleIsValid(tuple))
3877 return InvalidOid;
3878
3879 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3880
3881 /* caller is supposed to guarantee this */
3882 Assert(attno > 0 && attno <= rd_index->indnatts);
3883
3884 /* Non-key attributes don't have an opclass */
3885 if (attno > rd_index->indnkeyatts)
3886 {
3887 ReleaseSysCache(tuple);
3888 return InvalidOid;
3889 }
3890
3892 indclass = ((oidvector *) DatumGetPointer(datum));
3893
3895 opclass = indclass->values[attno - 1];
3896
3897 ReleaseSysCache(tuple);
3898
3899 return opclass;
3900}
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:815

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

3955{
3956 bool isclustered;
3957 HeapTuple tuple;
3958 Form_pg_index rd_index;
3959
3961 if (!HeapTupleIsValid(tuple))
3962 elog(ERROR, "cache lookup failed for index %u", index_oid);
3963
3964 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3965 isclustered = rd_index->indisclustered;
3966 ReleaseSysCache(tuple);
3967
3968 return isclustered;
3969}

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

3909{
3910 HeapTuple tuple;
3911 Form_pg_index rd_index;
3912 bool result;
3913
3915 if (!HeapTupleIsValid(tuple))
3916 return false;
3917
3918 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3919 result = rd_index->indisreplident;
3920 ReleaseSysCache(tuple);
3921
3922 return result;
3923}

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

3932{
3933 bool isvalid;
3934 HeapTuple tuple;
3935 Form_pg_index rd_index;
3936
3938 if (!HeapTupleIsValid(tuple))
3939 elog(ERROR, "cache lookup failed for index %u", index_oid);
3940
3941 rd_index = (Form_pg_index) GETSTRUCT(tuple);
3942 isvalid = rd_index->indisvalid;
3943 ReleaseSysCache(tuple);
3944
3945 return isvalid;
3946}

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

1406{
1407 HeapTuple tp;
1408
1410 if (HeapTupleIsValid(tp))
1411 {
1413 char *result;
1414
1415 result = pstrdup(NameStr(lantup->lanname));
1416 ReleaseSysCache(tp);
1417 return result;
1418 }
1419
1420 if (!missing_ok)
1421 elog(ERROR, "cache lookup failed for language %u",
1422 langoid);
1423 return NULL;
1424}
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 3674 of file lsyscache.c.

3675{
3676 HeapTuple tp;
3677
3679 if (HeapTupleIsValid(tp))
3680 {
3682 char *result;
3683
3684 result = pstrdup(NameStr(nsptup->nspname));
3685 ReleaseSysCache(tp);
3686 return result;
3687 }
3688 else
3689 return NULL;
3690}
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(), 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:1014

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

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

1626{
1627 HeapTuple tp;
1628
1630 if (HeapTupleIsValid(tp))
1631 {
1633 Oid result;
1634
1635 result = optup->oprresult;
1636 ReleaseSysCache(tp);
1637 return result;
1638 }
1639 else
1640 return InvalidOid;
1641}

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

1435{
1436 HeapTuple tp;
1438 Oid result;
1439
1440 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1441 if (!HeapTupleIsValid(tp))
1442 elog(ERROR, "cache lookup failed for opclass %u", opclass);
1444
1445 result = cla_tup->opcfamily;
1446 ReleaseSysCache(tp);
1447 return result;
1448}
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 1504 of file lsyscache.c.

1505{
1506 HeapTuple tp;
1508 Oid result;
1509
1510 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1511 if (!HeapTupleIsValid(tp))
1512 elog(ERROR, "cache lookup failed for opclass %u", opclass);
1514
1515 result = cla_tup->opcmethod;
1516 ReleaseSysCache(tp);
1517 return result;
1518}

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

1480{
1481 HeapTuple tp;
1483
1484 tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1485 if (!HeapTupleIsValid(tp))
1486 return false;
1487
1489
1490 *opfamily = cla_tup->opcfamily;
1491 *opcintype = cla_tup->opcintype;
1492
1493 ReleaseSysCache(tp);
1494
1495 return true;
1496}

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

1578{
1579 HeapTuple tp;
1580
1582 if (HeapTupleIsValid(tp))
1583 {
1586
1587 result = optup->oprcode;
1588 ReleaseSysCache(tp);
1589 return result;
1590 }
1591 else
1592 return (RegProcedure) InvalidOid;
1593}

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

1529{
1530 HeapTuple tp;
1532 Oid result;
1533
1535 if (!HeapTupleIsValid(tp))
1536 elog(ERROR, "cache lookup failed for operator family %u", opfid);
1538
1539 result = opfform->opfmethod;
1540 ReleaseSysCache(tp);
1541 return result;
1542}
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 1545 of file lsyscache.c.

1546{
1547 HeapTuple tup;
1548 char *opfname;
1550
1552
1553 if (!HeapTupleIsValid(tup))
1554 {
1555 if (!missing_ok)
1556 elog(ERROR, "cache lookup failed for operator family %u", opfid);
1557 return NULL;
1558 }
1559
1561 opfname = pstrdup(NameStr(opfform->opfname));
1562
1564
1565 return opfname;
1566}

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

1603{
1604 HeapTuple tp;
1605
1607 if (HeapTupleIsValid(tp))
1608 {
1610 char *result;
1611
1612 result = pstrdup(NameStr(optup->oprname));
1613 ReleaseSysCache(tp);
1614 return result;
1615 }
1616 else
1617 return NULL;
1618}

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

1888{
1889 HeapTuple tp;
1890
1892 if (HeapTupleIsValid(tp))
1893 {
1896
1897 result = optup->oprjoin;
1898 ReleaseSysCache(tp);
1899 return result;
1900 }
1901 else
1902 return (RegProcedure) InvalidOid;
1903}

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

3120{
3121 Oid array_type = get_array_type(typid);
3122
3123 if (OidIsValid(array_type))
3124 return array_type;
3125 if (OidIsValid(get_element_type(typid)))
3126 return typid;
3127 return InvalidOid;
3128}
Oid get_element_type(Oid typid)
Definition lsyscache.c:3067
Oid get_array_type(Oid typid)
Definition lsyscache.c:3095

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

4073{
4074 HeapTuple tuple;
4075 char *labelname;
4076
4078 if (!tuple)
4079 {
4080 elog(ERROR, "cache lookup failed for label %u", labeloid);
4081 return NULL;
4082 }
4084 ReleaseSysCache(tuple);
4085
4086 return labelname;
4087}
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 4090 of file lsyscache.c.

4091{
4092 HeapTuple tuple;
4093 char *propname;
4094
4096 if (!tuple)
4097 {
4098 elog(ERROR, "cache lookup failed for property %u", propoid);
4099 return NULL;
4100 }
4102 ReleaseSysCache(tuple);
4103
4104 return propname;
4105}
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 3998 of file lsyscache.c.

3999{
4000 HeapTuple tup;
4001 char *pubname;
4003
4005
4006 if (!HeapTupleIsValid(tup))
4007 {
4008 if (!missing_ok)
4009 elog(ERROR, "cache lookup failed for publication %u", pubid);
4010 return NULL;
4011 }
4012
4014 pubname = pstrdup(NameStr(pubform->pubname));
4015
4017
4018 return pubname;
4019}
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 3978 of file lsyscache.c.

3979{
3980 Oid oid;
3981
3983 CStringGetDatum(pubname));
3984 if (!OidIsValid(oid) && !missing_ok)
3985 ereport(ERROR,
3987 errmsg("publication \"%s\" does not exist", pubname)));
3988 return oid;
3989}
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 3712 of file lsyscache.c.

3713{
3714 char *nspname;
3715 char *result;
3716
3718 if (!nspname)
3719 elog(ERROR, "cache lookup failed for namespace %u", nspid);
3720
3721 result = quote_qualified_identifier(nspname, objname);
3722
3723 return result;
3724}
char * get_namespace_name_or_temp(Oid nspid)
Definition lsyscache.c:3698
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 generate_qualified_relation_name(), and RelationGetQualifiedRelationName().

◆ get_range_collation()

Oid get_range_collation ( Oid  rangeOid)

Definition at line 3761 of file lsyscache.c.

3762{
3763 HeapTuple tp;
3764
3766 if (HeapTupleIsValid(tp))
3767 {
3769 Oid result;
3770
3771 result = rngtup->rngcollation;
3772 ReleaseSysCache(tp);
3773 return result;
3774 }
3775 else
3776 return InvalidOid;
3777}

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

3787{
3788 HeapTuple tp;
3789
3791 if (HeapTupleIsValid(tp))
3792 {
3795
3796 result = rngtup->rngconstruct2;
3797 ReleaseSysCache(tp);
3798 return result;
3799 }
3800 else
3801 elog(ERROR, "cache lookup failed for range type %u", rangeOid);
3802}

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

2235{
2236 HeapTuple tp;
2237
2239 if (HeapTupleIsValid(tp))
2240 {
2242 char *result;
2243
2244 result = pstrdup(NameStr(reltup->relname));
2245 ReleaseSysCache(tp);
2246 return result;
2247 }
2248 else
2249 return NULL;
2250}
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(), 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(), 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 2384 of file lsyscache.c.

2385{
2386 HeapTuple tp;
2388 char result;
2389
2391 if (!HeapTupleIsValid(tp))
2392 elog(ERROR, "cache lookup failed for relation %u", relid);
2394 result = reltup->relpersistence;
2395 ReleaseSysCache(tp);
2396
2397 return result;
2398}

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

2407{
2408 HeapTuple tp;
2410 Oid result;
2411
2413 if (!HeapTupleIsValid(tp))
2414 elog(ERROR, "cache lookup failed for relation %u", relid);
2416 result = reltup->relam;
2417 ReleaseSysCache(tp);
2418
2419 return result;
2420}

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

2310{
2311 HeapTuple tp;
2312
2314 if (HeapTupleIsValid(tp))
2315 {
2317 char result;
2318
2319 result = reltup->relkind;
2320 ReleaseSysCache(tp);
2321 return result;
2322 }
2323 else
2324 return '\0';
2325}

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

2361{
2362 HeapTuple tp;
2363
2365 if (HeapTupleIsValid(tp))
2366 {
2368 Oid result;
2369
2370 result = reltup->reltablespace;
2371 ReleaseSysCache(tp);
2372 return result;
2373 }
2374 else
2375 return InvalidOid;
2376}

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

4049{
4050 HeapTuple tup;
4051 char *subname;
4053
4055
4056 if (!HeapTupleIsValid(tup))
4057 {
4058 if (!missing_ok)
4059 elog(ERROR, "cache lookup failed for subscription %u", subid);
4060 return NULL;
4061 }
4062
4064 subname = pstrdup(NameStr(subform->subname));
4065
4067
4068 return subname;
4069}
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 4028 of file lsyscache.c.

4029{
4030 Oid oid;
4031
4034 if (!OidIsValid(oid) && !missing_ok)
4035 ereport(ERROR,
4037 errmsg("subscription \"%s\" does not exist", subname)));
4038 return oid;
4039}
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 2426 of file lsyscache.c.

2427{
2428 HeapTuple tup;
2429
2430 if (!list_member_oid(trftypes, typid))
2431 return InvalidOid;
2432
2434 ObjectIdGetDatum(langid));
2435 if (HeapTupleIsValid(tup))
2436 {
2437 Oid funcid;
2438
2439 funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2441 return funcid;
2442 }
2443 else
2444 return InvalidOid;
2445}
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 2448 of file lsyscache.c.

2449{
2450 HeapTuple tup;
2451
2452 if (!list_member_oid(trftypes, typid))
2453 return InvalidOid;
2454
2456 ObjectIdGetDatum(langid));
2457 if (HeapTupleIsValid(tup))
2458 {
2459 Oid funcid;
2460
2461 funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
2463 return funcid;
2464 }
2465 else
2466 return InvalidOid;
2467}

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

3040{
3041 HeapTuple tp;
3042
3044 if (HeapTupleIsValid(tp))
3045 {
3047 Oid result;
3048
3049 result = typtup->typrelid;
3050 ReleaseSysCache(tp);
3051 return result;
3052 }
3053 else
3054 return InvalidOid;
3055}

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

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

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

2529{
2530 HeapTuple tp;
2531
2533 if (HeapTupleIsValid(tp))
2534 {
2536 bool result;
2537
2538 result = typtup->typbyval;
2539 ReleaseSysCache(tp);
2540 return result;
2541 }
2542 else
2543 return false;
2544}

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

2757{
2760 Datum datum;
2761 bool isNull;
2762 Node *expr;
2763
2766 elog(ERROR, "cache lookup failed for type %u", typid);
2768
2769 /*
2770 * typdefault and typdefaultbin are potentially null, so don't try to
2771 * access 'em as struct fields. Must do it the hard way with
2772 * SysCacheGetAttr.
2773 */
2774 datum = SysCacheGetAttr(TYPEOID,
2775 typeTuple,
2777 &isNull);
2778
2779 if (!isNull)
2780 {
2781 /* We have an expression default */
2782 expr = stringToNode(TextDatumGetCString(datum));
2783 }
2784 else
2785 {
2786 /* Perhaps we have a plain literal default */
2787 datum = SysCacheGetAttr(TYPEOID,
2788 typeTuple,
2790 &isNull);
2791
2792 if (!isNull)
2793 {
2794 char *strDefaultVal;
2795
2796 /* Convert text datum to C string */
2798 /* Convert C string to a value of the given type */
2799 datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2801 /* Build a Const node containing the value */
2802 expr = (Node *) makeConst(typid,
2803 -1,
2804 type->typcollation,
2805 type->typlen,
2806 datum,
2807 false,
2808 type->typbyval);
2810 }
2811 else
2812 {
2813 /* No default */
2814 expr = NULL;
2815 }
2816 }
2817
2819
2820 return expr;
2821}
#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:2609
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition makefuncs.c:350
void * stringToNode(const char *str)
Definition read.c:90
Definition nodes.h:135
const char * type

References elog, ERROR, 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 2631 of file lsyscache.c.

2639{
2642
2643 /*
2644 * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2645 * use array_in and array_out during bootstrap.
2646 */
2648 {
2649 Oid typinput;
2650 Oid typoutput;
2651 Oid typcollation;
2652
2654 typlen,
2655 typbyval,
2656 typalign,
2657 typdelim,
2658 typioparam,
2659 &typinput,
2660 &typoutput,
2661 &typcollation);
2662 switch (which_func)
2663 {
2664 case IOFunc_input:
2665 *func = typinput;
2666 break;
2667 case IOFunc_output:
2668 *func = typoutput;
2669 break;
2670 default:
2671 elog(ERROR, "binary I/O not supported during bootstrap");
2672 break;
2673 }
2674 return;
2675 }
2676
2679 elog(ERROR, "cache lookup failed for type %u", typid);
2681
2682 *typlen = typeStruct->typlen;
2683 *typbyval = typeStruct->typbyval;
2684 *typalign = typeStruct->typalign;
2685 *typdelim = typeStruct->typdelim;
2686 *typioparam = getTypeIOParam(typeTuple);
2687 switch (which_func)
2688 {
2689 case IOFunc_input:
2690 *func = typeStruct->typinput;
2691 break;
2692 case IOFunc_output:
2693 *func = typeStruct->typoutput;
2694 break;
2695 case IOFunc_receive:
2696 *func = typeStruct->typreceive;
2697 break;
2698 case IOFunc_send:
2699 *func = typeStruct->typsend;
2700 break;
2701 }
2703}
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 2479 of file lsyscache.c.

2480{
2481 HeapTuple tp;
2482
2484 if (HeapTupleIsValid(tp))
2485 {
2487 bool result;
2488
2489 result = typtup->typisdefined;
2490 ReleaseSysCache(tp);
2491 return result;
2492 }
2493 else
2494 return false;
2495}

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

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 3314 of file lsyscache.c.

3315{
3316 HeapTuple tp;
3317
3319 if (HeapTupleIsValid(tp))
3320 {
3322 Oid result;
3323
3324 result = typtup->typmodin;
3325 ReleaseSysCache(tp);
3326 return result;
3327 }
3328 else
3329 return InvalidOid;
3330}

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

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2727 of file lsyscache.c.

2728{
2729 HeapTuple tp;
2730
2732 if (HeapTupleIsValid(tp))
2733 {
2735 char result;
2736
2737 result = typtup->typstorage;
2738 ReleaseSysCache(tp);
2739 return result;
2740 }
2741 else
2742 return TYPSTORAGE_PLAIN;
2743}

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

3406{
3407 HeapTuple tp;
3408
3410 if (HeapTupleIsValid(tp))
3411 {
3413 RegProcedure handler = typform->typsubscript;
3414
3415 if (typelemp)
3416 *typelemp = typform->typelem;
3417 ReleaseSysCache(tp);
3418 return handler;
3419 }
3420 else
3421 {
3422 if (typelemp)
3424 return InvalidOid;
3425 }
3426}

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

2847{
2848 /*
2849 * We loop to find the bottom base type in a stack of domains.
2850 */
2851 for (;;)
2852 {
2853 HeapTuple tup;
2855
2857 if (!HeapTupleIsValid(tup))
2858 elog(ERROR, "cache lookup failed for type %u", typid);
2860 if (typTup->typtype != TYPTYPE_DOMAIN)
2861 {
2862 /* Not a domain, so done */
2864 break;
2865 }
2866
2867 Assert(*typmod == -1);
2868 typid = typTup->typbasetype;
2869 *typmod = typTup->typtypmod;
2870
2872 }
2873
2874 return typid;
2875}

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

3439{
3440 RegProcedure typsubscript = get_typsubscript(typid, typelemp);
3441
3442 if (!OidIsValid(typsubscript))
3443 return NULL;
3444
3445 return (const struct SubscriptRoutines *)
3446 DatumGetPointer(OidFunctionCall0(typsubscript));
3447}
#define OidFunctionCall0(functionId)
Definition fmgr.h:724
RegProcedure get_typsubscript(Oid typid, Oid *typelemp)
Definition lsyscache.c:3405

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

3249{
3252
3255 elog(ERROR, "cache lookup failed for type %u", type);
3257
3258 if (!pt->typisdefined)
3259 ereport(ERROR,
3261 errmsg("type %s is only a shell",
3262 format_type_be(type))));
3263 if (!OidIsValid(pt->typreceive))
3264 ereport(ERROR,
3266 errmsg("no binary input function available for type %s",
3267 format_type_be(type))));
3268
3269 *typReceive = pt->typreceive;
3271
3273}

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

3282{
3285
3288 elog(ERROR, "cache lookup failed for type %u", type);
3290
3291 if (!pt->typisdefined)
3292 ereport(ERROR,
3294 errmsg("type %s is only a shell",
3295 format_type_be(type))));
3296 if (!OidIsValid(pt->typsend))
3297 ereport(ERROR,
3299 errmsg("no binary output function available for type %s",
3300 format_type_be(type))));
3301
3302 *typSend = pt->typsend;
3303 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
3304
3306}

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

3183{
3186
3189 elog(ERROR, "cache lookup failed for type %u", type);
3191
3192 if (!pt->typisdefined)
3193 ereport(ERROR,
3195 errmsg("type %s is only a shell",
3196 format_type_be(type))));
3197 if (!OidIsValid(pt->typinput))
3198 ereport(ERROR,
3200 errmsg("no input function available for type %s",
3201 format_type_be(type))));
3202
3203 *typInput = pt->typinput;
3205
3207}

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

2610{
2612
2613 /*
2614 * Array types get their typelem as parameter; everybody else gets their
2615 * own type OID as parameter.
2616 */
2617 if (OidIsValid(typeStruct->typelem))
2618 return typeStruct->typelem;
2619 else
2620 return typeStruct->oid;
2621}

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

3216{
3219
3222 elog(ERROR, "cache lookup failed for type %u", type);
3224
3225 if (!pt->typisdefined)
3226 ereport(ERROR,
3228 errmsg("type %s is only a shell",
3229 format_type_be(type))));
3230 if (!OidIsValid(pt->typoutput))
3231 ereport(ERROR,
3233 errmsg("no output function available for type %s",
3234 format_type_be(type))));
3235
3236 *typOutput = pt->typoutput;
3237 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
3238
3240}

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

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

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

1651{
1652 HeapTuple tp;
1654
1656 if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1657 elog(ERROR, "cache lookup failed for operator %u", opno);
1659 *lefttype = optup->oprleft;
1660 *righttype = optup->oprright;
1661 ReleaseSysCache(tp);
1662}

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

973{
974 bool result = false;
976 int i;
977
978 /*
979 * Search pg_amop to see if the target operator is registered for any
980 * btree or hash opfamily.
981 */
983
984 for (i = 0; i < catlist->n_members; i++)
985 {
986 HeapTuple tuple = &catlist->members[i]->tuple;
988
989 /* Check if the AM is B-tree or Hash */
990 if (aform->amopmethod == BTREE_AM_OID ||
991 aform->amopmethod == HASH_AM_OID)
992 {
993 result = true;
994 break;
995 }
996 }
997
999
1000 return result;
1001}

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

Referenced by sublink_testexpr_is_not_nullable().

◆ op_mergejoinable()

bool op_mergejoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1678 of file lsyscache.c.

1679{
1680 bool result = false;
1681 HeapTuple tp;
1682 TypeCacheEntry *typentry;
1683
1684 /*
1685 * For array_eq or record_eq, we can sort if the element or field types
1686 * are all sortable. We could implement all the checks for that here, but
1687 * the typcache already does that and caches the results too, so let's
1688 * rely on the typcache. We do not need similar special cases for ranges
1689 * or multiranges, because their subtypes are required to be sortable.
1690 */
1691 if (opno == ARRAY_EQ_OP)
1692 {
1693 typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1694 if (typentry->cmp_proc == F_BTARRAYCMP)
1695 result = true;
1696 }
1697 else if (opno == RECORD_EQ_OP)
1698 {
1699 typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1700 if (typentry->cmp_proc == F_BTRECORDCMP)
1701 result = true;
1702 }
1703 else
1704 {
1705 /* For all other operators, rely on pg_operator.oprcanmerge */
1707 if (HeapTupleIsValid(tp))
1708 {
1710
1711 result = optup->oprcanmerge;
1712 ReleaseSysCache(tp);
1713 }
1714 }
1715 return result;
1716}
#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 1783 of file lsyscache.c.

1784{
1785 RegProcedure funcid = get_opcode(opno);
1786
1787 if (funcid == (RegProcedure) InvalidOid)
1788 elog(ERROR, "operator %u does not exist", opno);
1789
1790 return func_strict((Oid) funcid);
1791}
RegProcedure get_opcode(Oid opno)
Definition lsyscache.c:1577
bool func_strict(Oid funcid)
Definition lsyscache.c:2067

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

1800{
1801 RegProcedure funcid = get_opcode(opno);
1802
1803 if (funcid == (RegProcedure) InvalidOid)
1804 elog(ERROR, "operator %u does not exist", opno);
1805
1806 return func_volatile((Oid) funcid);
1807}
char func_volatile(Oid funcid)
Definition lsyscache.c:2086

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

2987{
2988 return (get_typtype(typid) == TYPTYPE_ENUM);
2989}
char get_typtype(Oid typid)
Definition lsyscache.c:2937

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