44 #include "utils/fmgroids.h"
94 result = amop_tup->amopstrategy;
119 result = amop_tup->amopsortfamily;
147 elog(
ERROR,
"operator %u is not a member of opfamily %u",
150 *strategy = amop_tup->amopstrategy;
151 *lefttype = amop_tup->amoplefttype;
152 *righttype = amop_tup->amoprighttype;
179 result = amop_tup->amopopr;
229 if (aform->amopmethod != BTREE_AM_OID)
236 if (aform->amoplefttype == aform->amoprighttype)
239 *opfamily = aform->amopfamily;
240 *opcintype = aform->amoplefttype;
241 *strategy = aform->amopstrategy;
274 &opfamily, &opcintype, &strategy))
321 if (aform->amopmethod != BTREE_AM_OID)
329 typid = use_lhs_type ? aform->amoplefttype : aform->amoprighttype;
382 if (aform->amopmethod == BTREE_AM_OID &&
409 Oid *lhs_opno,
Oid *rhs_opno)
433 if (aform->amopmethod == HASH_AM_OID &&
437 if (aform->amoplefttype == aform->amoprighttype)
470 aform->amoprighttype,
471 aform->amoprighttype,
533 if (aform->amopmethod == HASH_AM_OID &&
556 if (aform->amoplefttype == aform->amoprighttype)
558 *rhs_procno = *lhs_procno;
566 aform->amoprighttype,
567 aform->amoprighttype,
618 if (op_form->amopmethod != BTREE_AM_OID)
623 Assert(op_strategy >= 1 && op_strategy <= 5);
629 thisresult->
oplefttype = op_form->amoplefttype;
631 result =
lappend(result, thisresult);
656 if (op_form->amopmethod != BTREE_AM_OID)
661 Assert(op_strategy >= 1 && op_strategy <= 5);
672 thisresult->
oplefttype = op_form->amoplefttype;
674 result =
lappend(result, thisresult);
718 if (op_form->amopmethod == BTREE_AM_OID ||
719 op_form->amopmethod == HASH_AM_OID)
768 if (op_form->amopmethod == BTREE_AM_OID)
808 result = amproc_tup->amproc;
842 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
866 result = att_tup->attnum;
893 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
896 result = att_tup->attstattarget;
923 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
926 result = att_tup->attgenerated;
950 result = att_tup->atttypid;
978 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
982 *typid = att_tup->atttypid;
983 *typmod = att_tup->atttypmod;
984 *collid = att_tup->attcollation;
1007 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1041 (
errcode(ERRCODE_UNDEFINED_OBJECT),
1042 errmsg(
"cast from type %s to type %s does not exist",
1087 elog(
ERROR,
"cache lookup failed for collation %u", colloid);
1089 result = colltup->collisdeterministic;
1148 if (contup->contype == CONSTRAINT_UNIQUE ||
1149 contup->contype == CONSTRAINT_PRIMARY ||
1150 contup->contype == CONSTRAINT_EXCLUSION)
1151 result = contup->conindid;
1180 elog(
ERROR,
"cache lookup failed for language %u",
1201 elog(
ERROR,
"cache lookup failed for opclass %u", opclass);
1204 result = cla_tup->opcfamily;
1223 elog(
ERROR,
"cache lookup failed for opclass %u", opclass);
1226 result = cla_tup->opcintype;
1249 *opfamily = cla_tup->opcfamily;
1250 *opcintype = cla_tup->opcintype;
1276 result = optup->oprcode;
1324 result = optup->oprresult;
1346 elog(
ERROR,
"cache lookup failed for operator %u", opno);
1348 *lefttype = optup->oprleft;
1349 *righttype = optup->oprright;
1369 bool result =
false;
1379 if (opno == ARRAY_EQ_OP)
1382 if (typentry->
cmp_proc == F_BTARRAYCMP)
1385 else if (opno == RECORD_EQ_OP)
1388 if (typentry->
cmp_proc == F_BTRECORDCMP)
1399 result = optup->oprcanmerge;
1420 bool result =
false;
1425 if (opno == ARRAY_EQ_OP)
1428 if (typentry->
hash_proc == F_HASH_ARRAY)
1431 else if (opno == RECORD_EQ_OP)
1434 if (typentry->
hash_proc == F_HASH_RECORD)
1445 result = optup->oprcanhash;
1463 elog(
ERROR,
"operator %u does not exist", opno);
1479 elog(
ERROR,
"operator %u does not exist", opno);
1500 result = optup->oprcom;
1524 result = optup->oprnegate;
1548 result = optup->oprrest;
1572 result = optup->oprjoin;
1623 result = functup->pronamespace;
1643 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1662 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1685 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1689 result = procstruct->prorettype;
1690 *nargs = (int) procstruct->pronargs;
1691 Assert(*nargs == procstruct->proargtypes.dim1);
1693 memcpy(*argtypes, procstruct->proargtypes.values, *nargs *
sizeof(
Oid));
1711 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1730 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1749 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1768 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1787 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1806 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1825 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1849 result = functup->prosupport;
1880 get_relnatts(
Oid relid)
1890 result = reltup->relnatts;
1943 result = reltup->relnamespace;
1970 result = reltup->reltype;
1994 result = reltup->relkind;
2018 result = reltup->relispartition;
2045 result = reltup->reltablespace;
2067 elog(
ERROR,
"cache lookup failed for relation %u", relid);
2069 result = reltup->relpersistence;
2140 result = typtup->typisdefined;
2164 result = typtup->typlen;
2189 result = typtup->typbyval;
2215 elog(
ERROR,
"cache lookup failed for type %u", typid);
2217 *typlen = typtup->typlen;
2218 *typbyval = typtup->typbyval;
2236 elog(
ERROR,
"cache lookup failed for type %u", typid);
2238 *typlen = typtup->typlen;
2239 *typbyval = typtup->typbyval;
2269 return typeStruct->typelem;
2271 return typeStruct->oid;
2320 elog(
ERROR,
"binary I/O not supported during bootstrap");
2328 elog(
ERROR,
"cache lookup failed for type %u", typid);
2331 *typlen = typeStruct->typlen;
2332 *typbyval = typeStruct->typbyval;
2334 *typdelim = typeStruct->typdelim;
2339 *func = typeStruct->typinput;
2342 *func = typeStruct->typoutput;
2345 *func = typeStruct->typreceive;
2348 *func = typeStruct->typsend;
2356 get_typalign(
Oid typid)
2366 result = typtup->typalign;
2371 return TYPALIGN_INT;
2386 result = typtup->typstorage;
2391 return TYPSTORAGE_PLAIN;
2415 elog(
ERROR,
"cache lookup failed for type %u", typid);
2425 Anum_pg_type_typdefaultbin,
2438 Anum_pg_type_typdefault,
2443 char *strDefaultVal;
2458 pfree(strDefaultVal);
2507 elog(
ERROR,
"cache lookup failed for type %u", typid);
2509 if (typTup->typtype != TYPTYPE_DOMAIN)
2517 typid = typTup->typbasetype;
2518 *typmod = typTup->typtypmod;
2558 if (typid == BPCHAROID)
2562 if (maxwidth < 1000)
2563 return 32 + (maxwidth - 32) / 2;
2570 return 32 + (1000 - 32) / 2;
2596 result = typtup->typtype;
2614 if (typid == RECORDOID)
2618 case TYPTYPE_COMPOSITE:
2620 case TYPTYPE_DOMAIN:
2657 return (
get_typtype(typid) == TYPTYPE_MULTIRANGE);
2674 elog(
ERROR,
"cache lookup failed for type %u", typid);
2676 *typcategory = typtup->typcategory;
2677 *typispreferred = typtup->typispreferred;
2698 result = typtup->typrelid;
2726 if (IsTrueArrayType(typtup))
2727 result = typtup->typelem;
2803 if (typTup->typtype != TYPTYPE_DOMAIN)
2809 if (IsTrueArrayType(typTup))
2810 result = typTup->typelem;
2817 typid = typTup->typbasetype;
2841 if (!pt->typisdefined)
2843 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2844 errmsg(
"type %s is only a shell",
2848 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2849 errmsg(
"no input function available for type %s",
2852 *typInput = pt->typinput;
2874 if (!pt->typisdefined)
2876 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2877 errmsg(
"type %s is only a shell",
2881 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2882 errmsg(
"no output function available for type %s",
2885 *typOutput = pt->typoutput;
2886 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2907 if (!pt->typisdefined)
2909 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2910 errmsg(
"type %s is only a shell",
2914 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2915 errmsg(
"no binary input function available for type %s",
2918 *typReceive = pt->typreceive;
2940 if (!pt->typisdefined)
2942 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2943 errmsg(
"type %s is only a shell",
2947 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2948 errmsg(
"no binary output function available for type %s",
2951 *typSend = pt->typsend;
2952 *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2973 result = typtup->typmodin;
2988 get_typmodout(
Oid typid)
2998 result = typtup->typmodout;
3023 result = typtup->typcollation;
3065 *typelemp = typform->typelem;
3122 stawidth = (*get_attavgwidth_hook) (relid,
attnum);
3188 int reqkind,
Oid reqop,
int flags)
3205 if ((&stats->stakind1)[
i] == reqkind &&
3206 (reqop ==
InvalidOid || (&stats->staop1)[
i] == reqop))
3212 sslot->
staop = (&stats->staop1)[
i];
3213 sslot->
stacoll = (&stats->stacoll1)[
i];
3218 Anum_pg_statistic_stavalues1 +
i,
3238 elog(
ERROR,
"cache lookup failed for type %u", arrayelemtype);
3255 if (!typeForm->typbyval)
3266 Anum_pg_statistic_stanumbers1 +
i,
3282 narrayelem =
ARR_DIMS(statarray)[0];
3283 if (
ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3286 elog(
ERROR,
"stanumbers is not a 1-D float4 array");
3377 result = rngtup->rngsubtype;
3403 result = rngtup->rngcollation;
3428 result = rngtup->rngmultitypid;
3453 result = rngtup->rngtypid;
3490 Assert(attno > 0 && attno <= rd_index->indnatts);
3493 if (attno > rd_index->indnkeyatts)
3500 Anum_pg_index_indclass, &isnull);
3505 Assert(attno <= indclass->dim1);
3506 opclass = indclass->
values[attno - 1];
3530 result = rd_index->indisreplident;
3550 elog(
ERROR,
"cache lookup failed for index %u", index_oid);
3553 isvalid = rd_index->indisvalid;
3573 elog(
ERROR,
"cache lookup failed for index %u", index_oid);
3576 isclustered = rd_index->indisclustered;
#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
#define HeapTupleIsValid(tuple)
Assert(fmt[strlen(fmt) - 1] !='\n')
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)
void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
Oid get_func_variadictype(Oid funcid)
bool get_compatible_hash_operators(Oid opno, Oid *lhs_opno, Oid *rhs_opno)
bool get_rel_relispartition(Oid relid)
char * get_language_name(Oid langoid, bool missing_ok)
Oid get_op_opfamily_sortfamily(Oid opno, Oid opfamily)
char get_rel_persistence(Oid relid)
char get_func_prokind(Oid funcid)
char * get_opname(Oid opno)
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)
int get_attstattarget(Oid relid, AttrNumber attnum)
List * get_mergejoin_opfamilies(Oid opno)
bool comparison_ops_are_compatible(Oid opno1, Oid opno2)
Oid get_constraint_index(Oid conoid)
bool get_func_retset(Oid funcid)
Oid get_element_type(Oid typid)
Oid get_opclass_input_type(Oid opclass)
char * get_namespace_name_or_temp(Oid nspid)
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)
char * get_namespace_name(Oid nspid)
Oid get_typmodin(Oid typid)
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)
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_rel_namespace(Oid relid)
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)
Oid get_rel_type_id(Oid relid)
char * get_rel_name(Oid relid)
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
char * get_func_name(Oid funcid)
bool get_index_isclustered(Oid index_oid)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
char * get_collation_name(Oid colloid)
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)
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
bool get_func_leakproof(Oid funcid)
List * get_op_btree_interpretation(Oid opno)
char * get_constraint_name(Oid conoid)
bool get_collation_isdeterministic(Oid colloid)
Oid get_range_collation(Oid rangeOid)
Oid get_range_multirange(Oid rangeOid)
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)
Node * get_typdefault(Oid typid)
char get_typtype(Oid typid)
Oid get_base_element_type(Oid typid)
Oid getTypeIOParam(HeapTuple typeTuple)
Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod)
Oid get_transform_fromsql(Oid typid, Oid langid, List *trftypes)
const struct SubscriptRoutines * getSubscriptingRoutines(Oid typid, Oid *typelemp)
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)
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)
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)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
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_proc * Form_pg_proc
FormData_pg_range * Form_pg_range
#define STATISTIC_NUM_SLOTS
FormData_pg_statistic * Form_pg_statistic
FormData_pg_type * Form_pg_type
#define DatumGetPointer(X)
#define ObjectIdGetDatum(X)
#define PointerGetDatum(X)
void * stringToNode(const char *str)
#define BTGreaterStrategyNumber
#define HTEqualStrategyNumber
#define BTLessStrategyNumber
#define BTEqualStrategyNumber
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)
#define ReleaseSysCacheList(x)
#define SearchSysCacheList1(cacheId, key1)
#define SearchSysCacheExists3(cacheId, key1, key2, key3)
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_CMP_PROC
#define TYPECACHE_HASH_PROC