48#include "utils/fmgroids.h"
97 result = amop_tup->amopstrategy;
122 result = amop_tup->amopsortfamily;
150 elog(
ERROR,
"operator %u is not a member of opfamily %u",
153 *strategy = amop_tup->amopstrategy;
154 *lefttype = amop_tup->amoplefttype;
155 *righttype = amop_tup->amoprighttype;
182 result = amop_tup->amopopr;
301 if (aform->amoplefttype == aform->amoprighttype)
304 *opfamily = aform->amopfamily;
305 *opcintype = aform->amoplefttype;
306 *cmptype = am_cmptype;
339 &opfamily, &opcintype, &cmptype))
399 typid = use_lhs_type ? aform->amoplefttype : aform->amoprighttype;
482 Oid *lhs_opno,
Oid *rhs_opno)
506 if (aform->amopmethod == HASH_AM_OID &&
510 if (aform->amoplefttype == aform->amoprighttype)
543 aform->amoprighttype,
544 aform->amoprighttype,
606 if (aform->amopmethod == HASH_AM_OID &&
629 if (aform->amoplefttype == aform->amoprighttype)
631 *rhs_procno = *lhs_procno;
639 aform->amoprighttype,
640 aform->amoprighttype,
708 thisresult->
oplefttype = op_form->amoplefttype;
710 result =
lappend(result, thisresult);
754 thisresult->
oplefttype = op_form->amoplefttype;
756 result =
lappend(result, thisresult);
902 result = amproc_tup->amproc;
936 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
960 result = att_tup->attnum;
990 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
993 result = att_tup->attgenerated;
1017 result = att_tup->atttypid;
1045 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1049 *typid = att_tup->atttypid;
1050 *typmod = att_tup->atttypmod;
1051 *
collid = att_tup->attcollation;
1074 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1077 attopts =
SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions,
1108 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1109 errmsg(
"cast from type %s to type %s does not exist",
1154 elog(
ERROR,
"cache lookup failed for collation %u", colloid);
1156 result = colltup->collisdeterministic;
1215 if (contup->contype == CONSTRAINT_UNIQUE ||
1216 contup->contype == CONSTRAINT_PRIMARY ||
1217 contup->contype == CONSTRAINT_EXCLUSION)
1218 result = contup->conindid;
1242 elog(
ERROR,
"cache lookup failed for constraint %u", conoid);
1269 elog(
ERROR,
"cache lookup failed for language %u",
1290 elog(
ERROR,
"cache lookup failed for opclass %u", opclass);
1293 result = cla_tup->opcfamily;
1312 elog(
ERROR,
"cache lookup failed for opclass %u", opclass);
1315 result = cla_tup->opcintype;
1338 *opfamily = cla_tup->opcfamily;
1339 *opcintype = cla_tup->opcintype;
1360 elog(
ERROR,
"cache lookup failed for opclass %u", opclass);
1363 result = cla_tup->opcmethod;
1384 elog(
ERROR,
"cache lookup failed for operator family %u", opfid);
1387 result = opfform->opfmethod;
1404 elog(
ERROR,
"cache lookup failed for operator family %u", opfid);
1435 result = optup->oprcode;
1483 result = optup->oprresult;
1505 elog(
ERROR,
"cache lookup failed for operator %u", opno);
1507 *lefttype = optup->oprleft;
1508 *righttype = optup->oprright;
1528 bool result =
false;
1538 if (opno == ARRAY_EQ_OP)
1541 if (typentry->
cmp_proc == F_BTARRAYCMP)
1544 else if (opno == RECORD_EQ_OP)
1547 if (typentry->
cmp_proc == F_BTRECORDCMP)
1558 result = optup->oprcanmerge;
1579 bool result =
false;
1584 if (opno == ARRAY_EQ_OP)
1587 if (typentry->
hash_proc == F_HASH_ARRAY)
1590 else if (opno == RECORD_EQ_OP)
1593 if (typentry->
hash_proc == F_HASH_RECORD)
1604 result = optup->oprcanhash;
1622 elog(
ERROR,
"operator %u does not exist", opno);
1638 elog(
ERROR,
"operator %u does not exist", opno);
1659 result = optup->oprcom;
1683 result = optup->oprnegate;
1707 result = optup->oprrest;
1731 result = optup->oprjoin;
1782 result = functup->pronamespace;
1802 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1821 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1844 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1848 result = procstruct->prorettype;
1849 *nargs = (int) procstruct->pronargs;
1850 Assert(*nargs == procstruct->proargtypes.dim1);
1852 memcpy(*argtypes, procstruct->proargtypes.values, *nargs *
sizeof(
Oid));
1870 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1889 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1908 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1927 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1946 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1965 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1984 elog(
ERROR,
"cache lookup failed for function %u", funcid);
2008 result = functup->prosupport;
2039get_relnatts(
Oid relid)
2049 result = reltup->relnatts;
2102 result = reltup->relnamespace;
2129 result = reltup->reltype;
2153 result = reltup->relkind;
2177 result = reltup->relispartition;
2204 result = reltup->reltablespace;
2226 elog(
ERROR,
"cache lookup failed for relation %u", relid);
2228 result = reltup->relpersistence;
2248 elog(
ERROR,
"cache lookup failed for relation %u", relid);
2250 result = reltup->relam;
2323 result = typtup->typisdefined;
2347 result = typtup->typlen;
2372 result = typtup->typbyval;
2398 elog(
ERROR,
"cache lookup failed for type %u", typid);
2400 *typlen = typtup->typlen;
2401 *typbyval = typtup->typbyval;
2419 elog(
ERROR,
"cache lookup failed for type %u", typid);
2421 *typlen = typtup->typlen;
2422 *typbyval = typtup->typbyval;
2452 return typeStruct->typelem;
2454 return typeStruct->oid;
2503 elog(
ERROR,
"binary I/O not supported during bootstrap");
2511 elog(
ERROR,
"cache lookup failed for type %u", typid);
2514 *typlen = typeStruct->typlen;
2515 *typbyval = typeStruct->typbyval;
2517 *typdelim = typeStruct->typdelim;
2522 *func = typeStruct->typinput;
2525 *func = typeStruct->typoutput;
2528 *func = typeStruct->typreceive;
2531 *func = typeStruct->typsend;
2539get_typalign(
Oid typid)
2549 result = typtup->typalign;
2554 return TYPALIGN_INT;
2569 result = typtup->typstorage;
2574 return TYPSTORAGE_PLAIN;
2598 elog(
ERROR,
"cache lookup failed for type %u", typid);
2608 Anum_pg_type_typdefaultbin,
2621 Anum_pg_type_typdefault,
2626 char *strDefaultVal;
2641 pfree(strDefaultVal);
2690 elog(
ERROR,
"cache lookup failed for type %u", typid);
2692 if (typTup->typtype != TYPTYPE_DOMAIN)
2700 typid = typTup->typbasetype;
2701 *typmod = typTup->typtypmod;
2741 if (typid == BPCHAROID)
2745 if (maxwidth < 1000)
2746 return 32 + (maxwidth - 32) / 2;
2753 return 32 + (1000 - 32) / 2;
2779 result = typtup->typtype;
2797 if (typid == RECORDOID)
2801 case TYPTYPE_COMPOSITE:
2803 case TYPTYPE_DOMAIN:
2840 return (
get_typtype(typid) == TYPTYPE_MULTIRANGE);
2857 elog(
ERROR,
"cache lookup failed for type %u", typid);
2859 *typcategory = typtup->typcategory;
2860 *typispreferred = typtup->typispreferred;
2881 result = typtup->typrelid;
2909 if (IsTrueArrayType(typtup))
2910 result = typtup->typelem;
2986 if (typTup->typtype != TYPTYPE_DOMAIN)
2992 if (IsTrueArrayType(typTup))
2993 result = typTup->typelem;
3000 typid = typTup->typbasetype;
3024 if (!pt->typisdefined)
3026 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3027 errmsg(
"type %s is only a shell",
3031 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
3032 errmsg(
"no input function available for type %s",
3035 *typInput = pt->typinput;
3057 if (!pt->typisdefined)
3059 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3060 errmsg(
"type %s is only a shell",
3064 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
3065 errmsg(
"no output function available for type %s",
3068 *typOutput = pt->typoutput;
3069 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
3090 if (!pt->typisdefined)
3092 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3093 errmsg(
"type %s is only a shell",
3097 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
3098 errmsg(
"no binary input function available for type %s",
3101 *typReceive = pt->typreceive;
3123 if (!pt->typisdefined)
3125 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3126 errmsg(
"type %s is only a shell",
3130 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
3131 errmsg(
"no binary output function available for type %s",
3134 *typSend = pt->typsend;
3135 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
3156 result = typtup->typmodin;
3171get_typmodout(
Oid typid)
3181 result = typtup->typmodout;
3206 result = typtup->typcollation;
3248 *typelemp = typform->typelem;
3305 stawidth = (*get_attavgwidth_hook) (relid,
attnum);
3375 int reqkind,
Oid reqop,
int flags)
3391 if ((&stats->stakind1)[
i] == reqkind &&
3392 (reqop ==
InvalidOid || (&stats->staop1)[
i] == reqop))
3398 sslot->
staop = (&stats->staop1)[
i];
3399 sslot->
stacoll = (&stats->stacoll1)[
i];
3404 Anum_pg_statistic_stavalues1 +
i);
3421 elog(
ERROR,
"cache lookup failed for type %u", arrayelemtype);
3438 if (!typeForm->typbyval)
3449 Anum_pg_statistic_stanumbers1 +
i);
3462 narrayelem =
ARR_DIMS(statarray)[0];
3463 if (
ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3466 elog(
ERROR,
"stanumbers is not a 1-D float4 array");
3557 result = rngtup->rngsubtype;
3583 result = rngtup->rngcollation;
3608 result = rngtup->rngmultitypid;
3633 result = rngtup->rngtypid;
3669 Assert(attno > 0 && attno <= rd_index->indnatts);
3672 if (attno > rd_index->indnkeyatts)
3681 Assert(attno <= indclass->dim1);
3682 opclass = indclass->
values[attno - 1];
3706 result = rd_index->indisreplident;
3726 elog(
ERROR,
"cache lookup failed for index %u", index_oid);
3729 isvalid = rd_index->indisvalid;
3749 elog(
ERROR,
"cache lookup failed for index %u", index_oid);
3752 isclustered = rd_index->indisclustered;
3773 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3774 errmsg(
"publication \"%s\" does not exist", pubname)));
3796 elog(
ERROR,
"cache lookup failed for publication %u", pubid);
3823 (
errcode(ERRCODE_UNDEFINED_OBJECT),
3846 elog(
ERROR,
"cache lookup failed for subscription %u", subid);
StrategyNumber IndexAmTranslateCompareType(CompareType cmptype, Oid amoid, Oid opfamily, bool missing_ok)
CompareType IndexAmTranslateStrategy(StrategyNumber strategy, Oid amoid, Oid opfamily, bool missing_ok)
IndexAmRoutine * GetIndexAmRoutineByAmId(Oid amoid, bool noerror)
#define DatumGetArrayTypePCopy(X)
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
#define InvalidAttrNumber
void boot_get_type_io_data(Oid typid, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *typinput, Oid *typoutput)
#define TextDatumGetCString(d)
#define OidIsValid(objectId)
Datum datumCopy(Datum value, bool typByVal, int typLen)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
#define OidFunctionCall0(functionId)
#define HASHSTANDARD_PROC
Assert(PointerIsAligned(start, uint64))
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
List * lappend(List *list, void *datum)
List * lappend_oid(List *list, Oid datum)
bool list_member_oid(const List *list, Oid datum)
Oid get_range_subtype(Oid rangeOid)
char * get_rel_name(Oid relid)
void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
Oid get_func_variadictype(Oid funcid)
Oid get_opclass_method(Oid opclass)
bool get_compatible_hash_operators(Oid opno, Oid *lhs_opno, Oid *rhs_opno)
bool get_rel_relispartition(Oid relid)
Oid get_op_opfamily_sortfamily(Oid opno, Oid opfamily)
char get_rel_persistence(Oid relid)
char get_func_prokind(Oid funcid)
bool get_index_isvalid(Oid index_oid)
Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok)
void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
AttrNumber get_attnum(Oid relid, const char *attname)
RegProcedure get_oprrest(Oid opno)
void free_attstatsslot(AttStatsSlot *sslot)
bool comparison_ops_are_compatible(Oid opno1, Oid opno2)
Oid get_constraint_index(Oid conoid)
bool get_func_retset(Oid funcid)
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, CompareType *cmptype)
Oid get_element_type(Oid typid)
Oid get_opclass_input_type(Oid opclass)
bool type_is_rowtype(Oid typid)
bool type_is_range(Oid typid)
char func_parallel(Oid funcid)
Oid get_opclass_family(Oid opclass)
char get_attgenerated(Oid relid, AttrNumber attnum)
bool type_is_enum(Oid typid)
Oid get_multirange_range(Oid multirangeOid)
Oid get_typmodin(Oid typid)
Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
char get_typstorage(Oid typid)
bool get_opclass_opfamily_and_input_type(Oid opclass, Oid *opfamily, Oid *opcintype)
RegProcedure get_func_support(Oid funcid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
bool get_typisdefined(Oid typid)
char * get_opname(Oid opno)
Datum get_attoptions(Oid relid, int16 attnum)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
int32 get_attavgwidth(Oid relid, AttrNumber attnum)
bool get_index_isreplident(Oid index_oid)
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
RegProcedure get_oprjoin(Oid opno)
Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse)
bool op_hashjoinable(Oid opno, Oid inputtype)
char get_rel_relkind(Oid relid)
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Oid get_func_signature(Oid funcid, Oid **argtypes, int *nargs)
Oid get_publication_oid(const char *pubname, bool missing_ok)
Oid get_rel_namespace(Oid relid)
static bool get_opmethod_canorder(Oid amoid)
RegProcedure get_opcode(Oid opno)
Oid get_typcollation(Oid typid)
Oid get_op_rettype(Oid opno)
int get_op_opfamily_strategy(Oid opno, Oid opfamily)
char * get_collation_name(Oid colloid)
Oid get_rel_type_id(Oid relid)
char * get_language_name(Oid langoid, bool missing_ok)
char * get_namespace_name_or_temp(Oid nspid)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
char func_volatile(Oid funcid)
bool equality_ops_are_compatible(Oid opno1, Oid opno2)
get_attavgwidth_hook_type get_attavgwidth_hook
bool get_index_isclustered(Oid index_oid)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Oid get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type)
Oid get_transform_tosql(Oid typid, Oid langid, List *trftypes)
bool func_strict(Oid funcid)
Oid get_index_column_opclass(Oid index_oid, int attno)
char * get_constraint_name(Oid conoid)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
bool get_func_leakproof(Oid funcid)
const struct SubscriptRoutines * getSubscriptingRoutines(Oid typid, Oid *typelemp)
Node * get_typdefault(Oid typid)
bool get_collation_isdeterministic(Oid colloid)
List * get_op_index_interpretation(Oid opno)
Oid get_subscription_oid(const char *subname, bool missing_ok)
char * get_subscription_name(Oid subid, bool missing_ok)
Oid get_range_collation(Oid rangeOid)
char * get_opfamily_name(Oid opfid, bool missing_ok)
char * get_func_name(Oid funcid)
Oid get_range_multirange(Oid rangeOid)
Oid get_rel_relam(Oid relid)
char op_volatile(Oid opno)
Oid get_func_namespace(Oid funcid)
bool type_is_collatable(Oid typid)
Oid get_rel_tablespace(Oid relid)
int get_func_nargs(Oid funcid)
void get_type_io_data(Oid typid, IOFuncSelector which_func, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *func)
int16 get_typlen(Oid typid)
Oid get_typ_typrelid(Oid typid)
char get_typtype(Oid typid)
Oid get_base_element_type(Oid typid)
Oid getTypeIOParam(HeapTuple typeTuple)
Oid get_opfamily_method(Oid opfid)
Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod)
Oid get_transform_fromsql(Oid typid, Oid langid, List *trftypes)
char * get_publication_name(Oid pubid, bool missing_ok)
Oid getBaseType(Oid typid)
bool get_op_hash_functions(Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
bool get_typbyval(Oid typid)
bool op_mergejoinable(Oid opno, Oid inputtype)
List * get_mergejoin_opfamilies(Oid opno)
char * get_namespace_name(Oid nspid)
Oid get_array_type(Oid typid)
Oid get_func_rettype(Oid funcid)
Oid get_promoted_array_type(Oid typid)
Oid get_atttype(Oid relid, AttrNumber attnum)
char get_constraint_type(Oid conoid)
int32 get_typavgwidth(Oid typid, int32 typmod)
bool op_in_opfamily(Oid opno, Oid opfamily)
RegProcedure get_typsubscript(Oid typid, Oid *typelemp)
void get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple, int reqkind, Oid reqop, int flags)
Oid get_relname_relid(const char *relname, Oid relnamespace)
Oid get_negator(Oid opno)
Oid get_commutator(Oid opno)
void op_input_types(Oid opno, Oid *lefttype, Oid *righttype)
bool type_is_multirange(Oid typid)
void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
void get_atttypetypmodcoll(Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
#define ATTSTATSSLOT_NUMBERS
#define ATTSTATSSLOT_VALUES
int32(* get_attavgwidth_hook_type)(Oid relid, AttrNumber attnum)
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
char * pstrdup(const char *in)
void pfree(void *pointer)
#define IsBootstrapProcessingMode()
bool isTempNamespace(Oid namespaceId)
FormData_pg_amop * Form_pg_amop
FormData_pg_amproc * Form_pg_amproc
FormData_pg_attribute * Form_pg_attribute
FormData_pg_class * Form_pg_class
FormData_pg_collation * Form_pg_collation
FormData_pg_constraint * Form_pg_constraint
FormData_pg_index * Form_pg_index
FormData_pg_language * Form_pg_language
FormData_pg_namespace * Form_pg_namespace
FormData_pg_opclass * Form_pg_opclass
FormData_pg_operator * Form_pg_operator
FormData_pg_opfamily * Form_pg_opfamily
FormData_pg_proc * Form_pg_proc
FormData_pg_publication * Form_pg_publication
FormData_pg_range * Form_pg_range
#define STATISTIC_NUM_SLOTS
FormData_pg_statistic * Form_pg_statistic
FormData_pg_subscription * Form_pg_subscription
FormData_pg_type * Form_pg_type
static Datum PointerGetDatum(const void *X)
static Datum Int16GetDatum(int16 X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static Datum CStringGetDatum(const char *X)
static Datum CharGetDatum(char X)
void * stringToNode(const char *str)
#define HTEqualStrategyNumber
bool amconsistentordering
bool amconsistentequality
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Oid values[FLEXIBLE_ARRAY_MEMBER]
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
#define ReleaseSysCacheList(x)
#define SearchSysCacheList1(cacheId, key1)
#define SearchSysCacheExists3(cacheId, key1, key2, key3)
#define GetSysCacheOid1(cacheId, oidcol, key1)
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_CMP_PROC
#define TYPECACHE_HASH_PROC