46 #include "utils/fmgroids.h"
61 #define RI_MAX_NUMKEYS INDEX_MAX_KEYS
63 #define RI_INIT_CONSTRAINTHASHSIZE 64
64 #define RI_INIT_QUERYHASHSIZE (RI_INIT_CONSTRAINTHASHSIZE * 4)
66 #define RI_KEYS_ALL_NULL 0
67 #define RI_KEYS_SOME_NULL 1
68 #define RI_KEYS_NONE_NULL 2
72 #define RI_PLAN_CHECK_LOOKUPPK 1
73 #define RI_PLAN_CHECK_LOOKUPPK_FROM_PK 2
74 #define RI_PLAN_LAST_ON_PK RI_PLAN_CHECK_LOOKUPPK_FROM_PK
76 #define RI_PLAN_CASCADE_ONDELETE 3
77 #define RI_PLAN_CASCADE_ONUPDATE 4
79 #define RI_PLAN_RESTRICT 5
80 #define RI_PLAN_SETNULL_ONDELETE 6
81 #define RI_PLAN_SETNULL_ONUPDATE 7
82 #define RI_PLAN_SETDEFAULT_ONDELETE 8
83 #define RI_PLAN_SETDEFAULT_ONUPDATE 9
85 #define MAX_QUOTED_NAME_LEN (NAMEDATALEN*2+3)
86 #define MAX_QUOTED_REL_NAME_LEN (MAX_QUOTED_NAME_LEN*2)
88 #define RIAttName(rel, attnum) NameStr(*attnumAttName(rel, attnum))
89 #define RIAttType(rel, attnum) attnumTypeId(rel, attnum)
90 #define RIAttCollation(rel, attnum) attnumCollationId(rel, attnum)
92 #define RI_TRIGTYPE_INSERT 1
93 #define RI_TRIGTYPE_UPDATE 2
94 #define RI_TRIGTYPE_DELETE 3
194 const char *leftop,
Oid leftoptype,
196 const char *rightop,
Oid rightoptype);
202 int32 constr_queryno);
226 bool detectNewRows,
int expect_OK);
229 Datum *vals,
char *nulls);
305 (
errcode(ERRCODE_FOREIGN_KEY_VIOLATION),
306 errmsg(
"insert or update on table \"%s\" violates foreign key constraint \"%s\"",
309 errdetail(
"MATCH FULL does not allow mixing of null and nonnull key values."),
358 const char *querysep;
371 pk_only = pk_rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE ?
377 for (
int i = 0;
i < riinfo->
nkeys;
i++)
390 queryoids[
i] = fk_type;
396 &qkey, fk_rel, pk_rel);
409 pk_rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE,
490 const char *querysep;
503 pk_only = pk_rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE ?
509 for (
int i = 0;
i < riinfo->
nkeys;
i++)
521 queryoids[
i] = pk_type;
527 &qkey, fk_rel, pk_rel);
677 const char *querysep;
690 fk_only = fk_rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE ?
696 for (
int i = 0;
i < riinfo->
nkeys;
i++)
713 queryoids[
i] = pk_type;
719 &qkey, fk_rel, pk_rel);
784 const char *querysep;
796 fk_only = fk_rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE ?
802 for (
int i = 0;
i < riinfo->nkeys;
i++)
814 riinfo->pf_eq_oprs[
i],
819 queryoids[
i] = pk_type;
824 &qkey, fk_rel, pk_rel);
894 const char *querysep;
911 fk_only = fk_rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE ?
918 for (
int i = 0,
j = riinfo->nkeys; i < riinfo->nkeys;
i++,
j++)
933 riinfo->pf_eq_oprs[
i],
939 queryoids[
i] = pk_type;
940 queryoids[
j] = pk_type;
946 &qkey, fk_rel, pk_rel);
1066 queryno = is_set_null
1071 queryno = is_set_null
1076 elog(
ERROR,
"invalid tgkind passed to ri_set");
1087 const char *querysep;
1088 const char *qualsep;
1090 const char *fk_only;
1091 int num_cols_to_set;
1092 const int16 *set_cols;
1097 num_cols_to_set = riinfo->
nkeys;
1114 num_cols_to_set = riinfo->
nkeys;
1119 elog(
ERROR,
"invalid tgkind passed to ri_set");
1131 fk_only = fk_rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE ?
1135 fk_only, fkrelname);
1141 for (
int i = 0;
i < num_cols_to_set;
i++)
1147 is_set_null ?
"NULL" :
"DEFAULT");
1155 for (
int i = 0;
i < riinfo->
nkeys;
i++)
1173 queryoids[
i] = pk_type;
1178 &qkey, fk_rel, pk_rel);
1244 if (newslot &&
ri_KeysEqual(pk_rel, oldslot, newslot, riinfo,
true))
1274 Assert(fk_rel->
rd_rel->relkind != RELKIND_PARTITIONED_TABLE);
1343 if (
ri_KeysEqual(fk_rel, oldslot, newslot, riinfo,
false))
1382 const char *fk_only;
1383 const char *pk_only;
1385 char workmembuf[32];
1401 perminfos =
lappend(perminfos, pk_perminfo);
1413 perminfos =
lappend(perminfos, fk_perminfo);
1422 for (
int i = 0;
i < riinfo->
nkeys;
i++)
1442 ((pk_rel->
rd_rel->relrowsecurity &&
1445 (fk_rel->
rd_rel->relrowsecurity &&
1468 for (
int i = 0;
i < riinfo->
nkeys;
i++)
1478 fk_only = fk_rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE ?
1480 pk_only = pk_rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE ?
1483 " FROM %s%s fk LEFT OUTER JOIN %s%s pk ON",
1484 fk_only, fkrelname, pk_only, pkrelname);
1486 strcpy(pkattname,
"pk.");
1487 strcpy(fkattname,
"fk.");
1489 for (
int i = 0;
i < riinfo->
nkeys;
i++)
1503 fkattname, fk_type);
1504 if (pk_coll != fk_coll)
1517 for (
int i = 0;
i < riinfo->
nkeys;
i++)
1521 "%sfk.%s IS NOT NULL",
1569 elog(
ERROR,
"SPI_prepare returned %s for %s",
1613 for (
int i = 0;
i < fake_riinfo.
nkeys;
i++)
1624 (
errcode(ERRCODE_FOREIGN_KEY_VIOLATION),
1625 errmsg(
"insert or update on table \"%s\" violates foreign key constraint \"%s\"",
1628 errdetail(
"MATCH FULL does not allow mixing of null and nonnull key values."),
1667 char *constraintDef;
1673 const char *fk_only;
1675 char workmembuf[32];
1706 for (
i = 0;
i < riinfo->
nkeys;
i++)
1716 fk_only = fk_rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE ?
1719 " FROM %s%s fk JOIN %s pk ON",
1720 fk_only, fkrelname, pkrelname);
1721 strcpy(pkattname,
"pk.");
1722 strcpy(fkattname,
"fk.");
1724 for (
i = 0;
i < riinfo->
nkeys;
i++)
1738 fkattname, fk_type);
1739 if (pk_coll != fk_coll)
1750 if (constraintDef && constraintDef[0] !=
'\0')
1757 for (
i = 0;
i < riinfo->
nkeys;
i++)
1761 "%sfk.%s IS NOT NULL",
1809 elog(
ERROR,
"SPI_prepare returned %s for %s",
1853 for (
i = 0;
i < fake_riinfo.
nkeys;
i++)
1857 slot, tupdesc, 0,
true);
1890 *buffer++ = *
name++;
1905 buffer += strlen(buffer);
1921 const char *leftop,
Oid leftoptype,
1923 const char *rightop,
Oid rightoptype)
1927 rightop, rightoptype);
1961 elog(
ERROR,
"cache lookup failed for collation %u", collation);
1963 collname =
NameStr(colltup->collname);
1990 int32 constr_queryno)
2014 key->constr_queryno = constr_queryno;
2027 (
errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
2028 errmsg(
"function \"%s\" was not called by trigger manager",
funcname)));
2036 (
errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
2044 (
errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
2050 (
errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
2056 (
errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
2079 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2080 errmsg(
"no pg_constraint entry for trigger \"%s\" on table \"%s\"",
2082 errhint(
"Remove this referential integrity trigger and its mates, then do ALTER TABLE ADD CONSTRAINT.")));
2092 elog(
ERROR,
"wrong pg_constraint entry for trigger \"%s\" on table \"%s\"",
2099 elog(
ERROR,
"wrong pg_constraint entry for trigger \"%s\" on table \"%s\"",
2106 elog(
ERROR,
"unrecognized confmatchtype: %d",
2111 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2112 errmsg(
"MATCH PARTIAL not yet implemented")));
2141 riinfo->
valid =
false;
2142 else if (riinfo->
valid)
2150 elog(
ERROR,
"cache lookup failed for constraint %u", constraintOid);
2153 if (conForm->contype != CONSTRAINT_FOREIGN)
2154 elog(
ERROR,
"constraint %u is not a foreign key constraint",
2169 riinfo->
pk_relid = conForm->confrelid;
2170 riinfo->
fk_relid = conForm->conrelid;
2193 riinfo->
valid =
true;
2208 Oid constrParentOid;
2212 elog(
ERROR,
"cache lookup failed for constraint %u", constrOid);
2217 constrOid = constrParentOid;
2255 valid_link, iter.
cur);
2262 if (hashvalue == 0 ||
2266 riinfo->
valid =
false;
2284 int save_sec_context;
2325 bool detectNewRows,
int expect_OK)
2335 int save_sec_context;
2357 source_rel = fk_rel;
2358 source_is_pk =
false;
2362 source_rel = pk_rel;
2363 source_is_pk =
true;
2373 vals + riinfo->
nkeys, nulls + riinfo->
nkeys);
2422 test_snapshot, crosscheck_snapshot,
2423 false,
false, limit);
2432 if (expect_OK >= 0 && spi_result != expect_OK)
2434 (
errcode(ERRCODE_INTERNAL_ERROR),
2435 errmsg(
"referential integrity query on \"%s\" from constraint \"%s\" on \"%s\" gave unexpected result",
2439 errhint(
"This is most likely due to a rule having rewritten the query.")));
2447 newslot ? newslot : oldslot,
2460 Datum *vals,
char *nulls)
2462 const int16 *attnums;
2470 for (
int i = 0;
i < riinfo->
nkeys;
i++)
2473 nulls[
i] = isnull ?
'n' :
' ';
2490 int queryno,
bool partgone)
2495 const int16 *attnums;
2498 bool has_perm =
true;
2508 rel_oid = fk_rel->
rd_id;
2509 if (tupdesc == NULL)
2510 tupdesc = fk_rel->
rd_att;
2515 rel_oid = pk_rel->
rd_id;
2516 if (tupdesc == NULL)
2517 tupdesc = pk_rel->
rd_att;
2566 int fnum = attnums[
idx];
2599 (
errcode(ERRCODE_FOREIGN_KEY_VIOLATION),
2600 errmsg(
"removing partition \"%s\" violates foreign key constraint \"%s\"",
2603 errdetail(
"Key (%s)=(%s) is still referenced from table \"%s\".",
2609 (
errcode(ERRCODE_FOREIGN_KEY_VIOLATION),
2610 errmsg(
"insert or update on table \"%s\" violates foreign key constraint \"%s\"",
2614 errdetail(
"Key (%s)=(%s) is not present in table \"%s\".",
2617 errdetail(
"Key is not present in table \"%s\".",
2622 (
errcode(ERRCODE_FOREIGN_KEY_VIOLATION),
2623 errmsg(
"update or delete on table \"%s\" violates foreign key constraint \"%s\" on table \"%s\"",
2628 errdetail(
"Key (%s)=(%s) is still referenced from table \"%s\".",
2631 errdetail(
"Key is still referenced from table \"%s\".",
2649 const int16 *attnums;
2650 bool allnull =
true;
2651 bool nonenull =
true;
2658 for (
int i = 0;
i < riinfo->
nkeys;
i++)
2807 const int16 *attnums;
2815 for (
int i = 0;
i < riinfo->
nkeys;
i++)
2847 if (!
datum_image_eq(oldvalue, newvalue, att->attbyval, att->attlen))
2858 oldvalue, newvalue))
2906 DEFAULT_COLLATION_OID,
2907 oldvalue, newvalue));
2933 key.eq_opr = eq_opr;
2934 key.typeid =
typeid;
2939 entry->
valid =
false;
2970 Assert(lefttype == righttype);
2971 if (
typeid == lefttype)
2988 elog(
ERROR,
"no conversion function from %s to %s",
2998 entry->
valid =
true;
3014 case F_RI_FKEY_CASCADE_DEL:
3015 case F_RI_FKEY_CASCADE_UPD:
3016 case F_RI_FKEY_RESTRICT_DEL:
3017 case F_RI_FKEY_RESTRICT_UPD:
3018 case F_RI_FKEY_SETNULL_DEL:
3019 case F_RI_FKEY_SETNULL_UPD:
3020 case F_RI_FKEY_SETDEFAULT_DEL:
3021 case F_RI_FKEY_SETDEFAULT_UPD:
3022 case F_RI_FKEY_NOACTION_DEL:
3023 case F_RI_FKEY_NOACTION_UPD:
3026 case F_RI_FKEY_CHECK_INS:
3027 case F_RI_FKEY_CHECK_UPD:
Datum idx(PG_FUNCTION_ARGS)
bool has_bypassrls_privilege(Oid roleid)
AclResult pg_attribute_aclcheck(Oid table_oid, AttrNumber attnum, Oid roleid, AclMode mode)
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
Bitmapset * bms_add_member(Bitmapset *a, int x)
#define pg_attribute_noreturn()
#define OidIsValid(objectId)
bool datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
elog(ERROR, "%s: %s", p2, msg)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool ExecCheckPermissions(List *rangeTable, List *rteperminfos, bool ereport_on_violation)
const TupleTableSlotOps TTSOpsVirtual
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
char * OidOutputFunctionCall(Oid functionId, Datum val)
#define FunctionCall3(flinfo, arg1, arg2, arg3)
int NewGUCNestLevel(void)
void AtEOXact_GUC(bool isCommit, int nestLevel)
int set_config_option(const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
#define HeapTupleIsValid(tuple)
#define dclist_container(type, membername, ptr)
static void dclist_push_tail(dclist_head *head, dlist_node *node)
static uint32 dclist_count(const dclist_head *head)
static void dclist_delete_from(dclist_head *head, dlist_node *node)
#define dclist_foreach_modify(iter, lhead)
void CacheRegisterSyscacheCallback(int cacheid, SyscacheCallbackFunction func, Datum arg)
if(TABLE==NULL||TABLE_index==NULL)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
char * get_namespace_name(Oid nspid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
RegProcedure get_opcode(Oid opno)
bool get_collation_isdeterministic(Oid colloid)
void op_input_types(Oid opno, Oid *lefttype, Oid *righttype)
MemoryContext TopMemoryContext
#define SECURITY_NOFORCE_RLS
#define SECURITY_LOCAL_USERID_CHANGE
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
void SetUserIdAndSecContext(Oid userid, int sec_context)
CoercionPathType find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, Oid *funcid)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
@ COERCION_PATH_RELABELTYPE
#define FKCONSTR_MATCH_SIMPLE
#define FKCONSTR_MATCH_PARTIAL
#define FKCONSTR_MATCH_FULL
FormData_pg_attribute * Form_pg_attribute
FormData_pg_collation * Form_pg_collation
void DeconstructFkConstraintRow(HeapTuple tuple, int *numfks, AttrNumber *conkey, AttrNumber *confkey, Oid *pf_eq_oprs, Oid *pp_eq_oprs, Oid *ff_eq_oprs, int *num_fk_del_set_cols, AttrNumber *fk_del_set_cols)
FormData_pg_constraint * Form_pg_constraint
static int list_length(const List *l)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static TransactionId DatumGetTransactionId(Datum X)
static Datum Int32GetDatum(int32 X)
#define RelationGetForm(relation)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define RelationGetNamespace(relation)
int errtableconstraint(Relation rel, const char *conname)
static Datum ri_set(TriggerData *trigdata, bool is_set_null, int tgkind)
#define RI_TRIGTYPE_INSERT
struct RI_ConstraintInfo RI_ConstraintInfo
static const RI_ConstraintInfo * ri_LoadConstraintInfo(Oid constraintOid)
static Datum RI_FKey_check(TriggerData *trigdata)
#define RI_PLAN_SETNULL_ONUPDATE
#define RI_PLAN_CASCADE_ONUPDATE
#define RI_TRIGTYPE_DELETE
Datum RI_FKey_setnull_del(PG_FUNCTION_ARGS)
static bool ri_PerformCheck(const RI_ConstraintInfo *riinfo, RI_QueryKey *qkey, SPIPlanPtr qplan, Relation fk_rel, Relation pk_rel, TupleTableSlot *oldslot, TupleTableSlot *newslot, bool detectNewRows, int expect_OK)
static void ri_HashPreparedPlan(RI_QueryKey *key, SPIPlanPtr plan)
static void quoteOneName(char *buffer, const char *name)
bool RI_FKey_pk_upd_check_required(Trigger *trigger, Relation pk_rel, TupleTableSlot *oldslot, TupleTableSlot *newslot)
#define RI_PLAN_LAST_ON_PK
#define RIAttType(rel, attnum)
static void ri_GenerateQualCollation(StringInfo buf, Oid collation)
Datum RI_FKey_cascade_del(PG_FUNCTION_ARGS)
#define RI_KEYS_SOME_NULL
Datum RI_FKey_check_upd(PG_FUNCTION_ARGS)
static HTAB * ri_query_cache
#define MAX_QUOTED_REL_NAME_LEN
static void ri_ReportViolation(const RI_ConstraintInfo *riinfo, Relation pk_rel, Relation fk_rel, TupleTableSlot *violatorslot, TupleDesc tupdesc, int queryno, bool partgone) pg_attribute_noreturn()
Datum RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
static void InvalidateConstraintCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
static Datum ri_restrict(TriggerData *trigdata, bool is_no_action)
Datum RI_FKey_restrict_del(PG_FUNCTION_ARGS)
static bool ri_AttributesEqual(Oid eq_opr, Oid typeid, Datum oldvalue, Datum newvalue)
Datum RI_FKey_noaction_del(PG_FUNCTION_ARGS)
static void quoteRelationName(char *buffer, Relation rel)
static int ri_NullCheck(TupleDesc tupDesc, TupleTableSlot *slot, const RI_ConstraintInfo *riinfo, bool rel_is_pk)
static void ri_GenerateQual(StringInfo buf, const char *sep, const char *leftop, Oid leftoptype, Oid opoid, const char *rightop, Oid rightoptype)
struct RI_QueryKey RI_QueryKey
static bool ri_KeysEqual(Relation rel, TupleTableSlot *oldslot, TupleTableSlot *newslot, const RI_ConstraintInfo *riinfo, bool rel_is_pk)
struct RI_CompareHashEntry RI_CompareHashEntry
static RI_CompareHashEntry * ri_HashCompareOp(Oid eq_opr, Oid typeid)
#define RI_PLAN_CHECK_LOOKUPPK_FROM_PK
#define RIAttCollation(rel, attnum)
static dclist_head ri_constraint_cache_valid_list
static Oid get_ri_constraint_root(Oid constrOid)
Datum RI_FKey_check_ins(PG_FUNCTION_ARGS)
struct RI_QueryHashEntry RI_QueryHashEntry
static HTAB * ri_compare_cache
#define RI_KEYS_NONE_NULL
#define RI_INIT_QUERYHASHSIZE
static const RI_ConstraintInfo * ri_FetchConstraintInfo(Trigger *trigger, Relation trig_rel, bool rel_is_pk)
static void ri_BuildQueryKey(RI_QueryKey *key, const RI_ConstraintInfo *riinfo, int32 constr_queryno)
#define RI_PLAN_CASCADE_ONDELETE
Datum RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
#define RI_PLAN_SETDEFAULT_ONDELETE
Datum RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
#define RI_PLAN_SETDEFAULT_ONUPDATE
#define RI_PLAN_CHECK_LOOKUPPK
#define RI_PLAN_SETNULL_ONDELETE
#define RI_INIT_CONSTRAINTHASHSIZE
bool RI_Initial_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel)
static bool ri_Check_Pk_Match(Relation pk_rel, Relation fk_rel, TupleTableSlot *oldslot, const RI_ConstraintInfo *riinfo)
void RI_PartitionRemove_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel)
static SPIPlanPtr ri_PlanCheck(const char *querystr, int nargs, Oid *argtypes, RI_QueryKey *qkey, Relation fk_rel, Relation pk_rel)
#define MAX_QUOTED_NAME_LEN
static void ri_CheckTrigger(FunctionCallInfo fcinfo, const char *funcname, int tgkind)
#define RI_TRIGTYPE_UPDATE
bool RI_FKey_fk_upd_check_required(Trigger *trigger, Relation fk_rel, TupleTableSlot *oldslot, TupleTableSlot *newslot)
int RI_FKey_trigger_type(Oid tgfoid)
Datum RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
Datum RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
static void ri_InitHashTables(void)
static void ri_ExtractValues(Relation rel, TupleTableSlot *slot, const RI_ConstraintInfo *riinfo, bool rel_is_pk, Datum *vals, char *nulls)
#define RIAttName(rel, attnum)
static HTAB * ri_constraint_cache
static SPIPlanPtr ri_FetchPreparedPlan(RI_QueryKey *key)
struct RI_CompareKey RI_CompareKey
Datum RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
int check_enable_rls(Oid relid, Oid checkAsUser, bool noError)
char * pg_get_partconstrdef_string(Oid partitionId, char *aliasname)
void generate_operator_clause(StringInfo buf, const char *leftop, Oid leftoptype, Oid opoid, const char *rightop, Oid rightoptype)
Snapshot GetTransactionSnapshot(void)
Snapshot GetLatestSnapshot(void)
bool SPI_plan_is_valid(SPIPlanPtr plan)
int SPI_freeplan(SPIPlanPtr plan)
SPITupleTable * SPI_tuptable
int SPI_execute_snapshot(SPIPlanPtr plan, Datum *Values, const char *Nulls, Snapshot snapshot, Snapshot crosscheck_snapshot, bool read_only, bool fire_triggers, long tcount)
const char * SPI_result_code_string(int code)
SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes)
int SPI_keepplan(SPIPlanPtr plan)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
int16 pk_attnums[RI_MAX_NUMKEYS]
int16 fk_attnums[RI_MAX_NUMKEYS]
Oid pp_eq_oprs[RI_MAX_NUMKEYS]
Oid pf_eq_oprs[RI_MAX_NUMKEYS]
int16 confdelsetcols[RI_MAX_NUMKEYS]
Oid ff_eq_oprs[RI_MAX_NUMKEYS]
TupleTableSlot * tg_trigslot
TupleTableSlot * tg_newslot
TupleDesc tts_tupleDescriptor
#define MinTransactionIdAttributeNumber
#define FirstLowInvalidHeapAttributeNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define GetSysCacheHashValue1(cacheId, key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
static bool table_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot, Snapshot snapshot)
#define TRIGGER_FIRED_BY_DELETE(event)
#define CALLED_AS_TRIGGER(fcinfo)
#define TRIGGER_FIRED_FOR_ROW(event)
#define TRIGGER_FIRED_AFTER(event)
#define TRIGGER_FIRED_BY_INSERT(event)
#define TRIGGER_FIRED_BY_UPDATE(event)
#define TupleDescAttr(tupdesc, i)
static Datum slot_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
static Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
static bool slot_attisnull(TupleTableSlot *slot, int attnum)
void CommandCounterIncrement(void)
bool TransactionIdIsCurrentTransactionId(TransactionId xid)
#define IsolationUsesXactSnapshot()