PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
#include "access/table.h"
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_constraint.h"
#include "catalog/pg_proc.h"
#include "commands/trigger.h"
#include "executor/executor.h"
#include "executor/spi.h"
#include "lib/ilist.h"
#include "miscadmin.h"
#include "parser/parse_coerce.h"
#include "parser/parse_relation.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/datum.h"
#include "utils/fmgroids.h"
#include "utils/guc.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/rangetypes.h"
#include "utils/rel.h"
#include "utils/rls.h"
#include "utils/ruleutils.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
Go to the source code of this file.
Data Structures | |
struct | RI_ConstraintInfo |
struct | RI_QueryKey |
struct | RI_QueryHashEntry |
struct | RI_CompareKey |
struct | RI_CompareHashEntry |
Macros | |
#define | RI_MAX_NUMKEYS INDEX_MAX_KEYS |
#define | RI_INIT_CONSTRAINTHASHSIZE 64 |
#define | RI_INIT_QUERYHASHSIZE (RI_INIT_CONSTRAINTHASHSIZE * 4) |
#define | RI_KEYS_ALL_NULL 0 |
#define | RI_KEYS_SOME_NULL 1 |
#define | RI_KEYS_NONE_NULL 2 |
#define | RI_PLAN_CHECK_LOOKUPPK 1 |
#define | RI_PLAN_CHECK_LOOKUPPK_FROM_PK 2 |
#define | RI_PLAN_LAST_ON_PK RI_PLAN_CHECK_LOOKUPPK_FROM_PK |
#define | RI_PLAN_CASCADE_ONDELETE 3 |
#define | RI_PLAN_CASCADE_ONUPDATE 4 |
#define | RI_PLAN_RESTRICT 5 |
#define | RI_PLAN_SETNULL_ONDELETE 6 |
#define | RI_PLAN_SETNULL_ONUPDATE 7 |
#define | RI_PLAN_SETDEFAULT_ONDELETE 8 |
#define | RI_PLAN_SETDEFAULT_ONUPDATE 9 |
#define | MAX_QUOTED_NAME_LEN (NAMEDATALEN*2+3) |
#define | MAX_QUOTED_REL_NAME_LEN (MAX_QUOTED_NAME_LEN*2) |
#define | RIAttName(rel, attnum) NameStr(*attnumAttName(rel, attnum)) |
#define | RIAttType(rel, attnum) attnumTypeId(rel, attnum) |
#define | RIAttCollation(rel, attnum) attnumCollationId(rel, attnum) |
#define | RI_TRIGTYPE_INSERT 1 |
#define | RI_TRIGTYPE_UPDATE 2 |
#define | RI_TRIGTYPE_DELETE 3 |
Typedefs | |
typedef struct RI_ConstraintInfo | RI_ConstraintInfo |
typedef struct RI_QueryKey | RI_QueryKey |
typedef struct RI_QueryHashEntry | RI_QueryHashEntry |
typedef struct RI_CompareKey | RI_CompareKey |
typedef struct RI_CompareHashEntry | RI_CompareHashEntry |
Variables | |
static HTAB * | ri_constraint_cache = NULL |
static HTAB * | ri_query_cache = NULL |
static HTAB * | ri_compare_cache = NULL |
static dclist_head | ri_constraint_cache_valid_list |
#define MAX_QUOTED_NAME_LEN (NAMEDATALEN*2+3) |
Definition at line 84 of file ri_triggers.c.
#define MAX_QUOTED_REL_NAME_LEN (MAX_QUOTED_NAME_LEN*2) |
Definition at line 85 of file ri_triggers.c.
#define RI_INIT_CONSTRAINTHASHSIZE 64 |
Definition at line 62 of file ri_triggers.c.
#define RI_INIT_QUERYHASHSIZE (RI_INIT_CONSTRAINTHASHSIZE * 4) |
Definition at line 63 of file ri_triggers.c.
#define RI_KEYS_ALL_NULL 0 |
Definition at line 65 of file ri_triggers.c.
#define RI_KEYS_NONE_NULL 2 |
Definition at line 67 of file ri_triggers.c.
#define RI_KEYS_SOME_NULL 1 |
Definition at line 66 of file ri_triggers.c.
#define RI_MAX_NUMKEYS INDEX_MAX_KEYS |
Definition at line 60 of file ri_triggers.c.
#define RI_PLAN_CASCADE_ONDELETE 3 |
Definition at line 75 of file ri_triggers.c.
#define RI_PLAN_CASCADE_ONUPDATE 4 |
Definition at line 76 of file ri_triggers.c.
#define RI_PLAN_CHECK_LOOKUPPK 1 |
Definition at line 71 of file ri_triggers.c.
#define RI_PLAN_CHECK_LOOKUPPK_FROM_PK 2 |
Definition at line 72 of file ri_triggers.c.
#define RI_PLAN_LAST_ON_PK RI_PLAN_CHECK_LOOKUPPK_FROM_PK |
Definition at line 73 of file ri_triggers.c.
#define RI_PLAN_RESTRICT 5 |
Definition at line 78 of file ri_triggers.c.
#define RI_PLAN_SETDEFAULT_ONDELETE 8 |
Definition at line 81 of file ri_triggers.c.
#define RI_PLAN_SETDEFAULT_ONUPDATE 9 |
Definition at line 82 of file ri_triggers.c.
#define RI_PLAN_SETNULL_ONDELETE 6 |
Definition at line 79 of file ri_triggers.c.
#define RI_PLAN_SETNULL_ONUPDATE 7 |
Definition at line 80 of file ri_triggers.c.
#define RI_TRIGTYPE_DELETE 3 |
Definition at line 93 of file ri_triggers.c.
#define RI_TRIGTYPE_INSERT 1 |
Definition at line 91 of file ri_triggers.c.
#define RI_TRIGTYPE_UPDATE 2 |
Definition at line 92 of file ri_triggers.c.
#define RIAttCollation | ( | rel, | |
attnum | |||
) | attnumCollationId(rel, attnum) |
Definition at line 89 of file ri_triggers.c.
#define RIAttName | ( | rel, | |
attnum | |||
) | NameStr(*attnumAttName(rel, attnum)) |
Definition at line 87 of file ri_triggers.c.
#define RIAttType | ( | rel, | |
attnum | |||
) | attnumTypeId(rel, attnum) |
Definition at line 88 of file ri_triggers.c.
typedef struct RI_CompareHashEntry RI_CompareHashEntry |
typedef struct RI_CompareKey RI_CompareKey |
typedef struct RI_ConstraintInfo RI_ConstraintInfo |
typedef struct RI_QueryHashEntry RI_QueryHashEntry |
typedef struct RI_QueryKey RI_QueryKey |
Definition at line 2286 of file ri_triggers.c.
References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), and SearchSysCache1().
Referenced by ri_LoadConstraintInfo().
Definition at line 2320 of file ri_triggers.c.
References Assert, dlist_mutable_iter::cur, dclist_container, dclist_count(), dclist_delete_from(), dclist_foreach_modify, RI_ConstraintInfo::oidHashValue, ri_constraint_cache, ri_constraint_cache_valid_list, RI_ConstraintInfo::rootHashValue, and RI_ConstraintInfo::valid.
Referenced by ri_InitHashTables().
|
static |
Definition at line 1950 of file ri_triggers.c.
References name.
Referenced by quoteRelationName(), ri_Check_Pk_Match(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check(), ri_GenerateQualCollation(), RI_Initial_Check(), RI_PartitionRemove_Check(), ri_restrict(), and ri_set().
|
static |
Definition at line 1970 of file ri_triggers.c.
References get_namespace_name(), quoteOneName(), RelationGetNamespace, and RelationGetRelationName.
Referenced by ri_Check_Pk_Match(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check(), RI_Initial_Check(), RI_PartitionRemove_Check(), ri_restrict(), and ri_set().
|
static |
Definition at line 2057 of file ri_triggers.c.
References RI_ConstraintInfo::constraint_id, RI_ConstraintInfo::constraint_root_id, sort-test::key, and RI_PLAN_CHECK_LOOKUPPK_FROM_PK.
Referenced by ri_Check_Pk_Match(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check(), ri_restrict(), and ri_set().
|
static |
Definition at line 507 of file ri_triggers.c.
References RI_ConstraintInfo::agged_period_contained_by_oper, appendStringInfo(), appendStringInfoString(), Assert, attname, StringInfoData::data, elog, ERROR, RI_ConstraintInfo::fk_attnums, RI_ConstraintInfo::hasperiod, i, initStringInfo(), MAX_QUOTED_NAME_LEN, MAX_QUOTED_REL_NAME_LEN, RI_ConstraintInfo::nkeys, RI_ConstraintInfo::pk_attnums, RI_ConstraintInfo::pp_eq_oprs, quoteOneName(), quoteRelationName(), RelationData::rd_rel, RelationGetDescr, ri_BuildQueryKey(), ri_FetchPreparedPlan(), ri_GenerateQual(), RI_KEYS_NONE_NULL, RI_MAX_NUMKEYS, ri_NullCheck(), ri_PerformCheck(), RI_PLAN_CHECK_LOOKUPPK_FROM_PK, ri_PlanCheck(), RIAttName, RIAttType, SPI_connect(), SPI_finish(), SPI_OK_FINISH, SPI_OK_SELECT, and sprintf.
Referenced by ri_restrict().
|
static |
Definition at line 2089 of file ri_triggers.c.
References CALLED_AS_TRIGGER, FunctionCallInfoBaseData::context, ereport, errcode(), errmsg(), ERROR, funcname, if(), RI_TRIGTYPE_DELETE, RI_TRIGTYPE_INSERT, RI_TRIGTYPE_UPDATE, TriggerData::tg_event, TRIGGER_FIRED_AFTER, TRIGGER_FIRED_BY_DELETE, TRIGGER_FIRED_BY_INSERT, TRIGGER_FIRED_BY_UPDATE, and TRIGGER_FIRED_FOR_ROW.
Referenced by RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check_ins(), RI_FKey_check_upd(), RI_FKey_noaction_del(), RI_FKey_noaction_upd(), RI_FKey_restrict_del(), RI_FKey_restrict_upd(), RI_FKey_setdefault_del(), RI_FKey_setdefault_upd(), RI_FKey_setnull_del(), and RI_FKey_setnull_upd().
Definition at line 2975 of file ri_triggers.c.
References BoolGetDatum(), RI_CompareHashEntry::cast_func_finfo, DatumGetBool(), RI_CompareHashEntry::eq_opr_finfo, FmgrInfo::fn_oid, FunctionCall2Coll(), FunctionCall3, Int32GetDatum(), OidIsValid, and ri_HashCompareOp().
Referenced by ri_KeysEqual().
|
static |
Definition at line 2541 of file ri_triggers.c.
References RI_ConstraintInfo::fk_attnums, i, RI_ConstraintInfo::nkeys, RI_ConstraintInfo::pk_attnums, and slot_getattr().
Referenced by ri_PerformCheck().
|
static |
Definition at line 2135 of file ri_triggers.c.
References RI_ConstraintInfo::confmatchtype, elog, ereport, errcode(), errhint(), errmsg(), ERROR, RI_ConstraintInfo::fk_relid, FKCONSTR_MATCH_FULL, FKCONSTR_MATCH_PARTIAL, FKCONSTR_MATCH_SIMPLE, OidIsValid, RI_ConstraintInfo::pk_relid, RelationGetRelationName, RelationGetRelid, ri_LoadConstraintInfo(), Trigger::tgconstraint, Trigger::tgconstrrelid, and Trigger::tgname.
Referenced by RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check(), RI_FKey_fk_upd_check_required(), RI_FKey_pk_upd_check_required(), RI_Initial_Check(), RI_PartitionRemove_Check(), ri_restrict(), and ri_set().
|
static |
Definition at line 2801 of file ri_triggers.c.
References HASH_FIND, hash_search(), sort-test::key, RI_QueryHashEntry::plan, plan, ri_InitHashTables(), ri_query_cache, SPI_freeplan(), and SPI_plan_is_valid().
Referenced by ri_Check_Pk_Match(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check(), ri_restrict(), and ri_set().
Datum RI_FKey_cascade_del | ( | PG_FUNCTION_ARGS | ) |
Definition at line 825 of file ri_triggers.c.
References appendStringInfo(), attname, StringInfoData::data, elog, ERROR, get_collation_isdeterministic(), i, initStringInfo(), MAX_QUOTED_NAME_LEN, MAX_QUOTED_REL_NAME_LEN, PointerGetDatum(), quoteOneName(), quoteRelationName(), ri_BuildQueryKey(), ri_CheckTrigger(), ri_FetchConstraintInfo(), ri_FetchPreparedPlan(), ri_GenerateQual(), ri_GenerateQualCollation(), RI_MAX_NUMKEYS, ri_PerformCheck(), RI_PLAN_CASCADE_ONDELETE, ri_PlanCheck(), RI_TRIGTYPE_DELETE, RIAttCollation, RIAttName, RIAttType, RowExclusiveLock, SPI_connect(), SPI_finish(), SPI_OK_DELETE, SPI_OK_FINISH, sprintf, table_close(), table_open(), TriggerData::tg_relation, TriggerData::tg_trigger, and TriggerData::tg_trigslot.
Datum RI_FKey_cascade_upd | ( | PG_FUNCTION_ARGS | ) |
Definition at line 930 of file ri_triggers.c.
References appendBinaryStringInfo(), appendStringInfo(), attname, StringInfoData::data, elog, ERROR, get_collation_isdeterministic(), i, initStringInfo(), j, StringInfoData::len, MAX_QUOTED_NAME_LEN, MAX_QUOTED_REL_NAME_LEN, PointerGetDatum(), quoteOneName(), quoteRelationName(), ri_BuildQueryKey(), ri_CheckTrigger(), ri_FetchConstraintInfo(), ri_FetchPreparedPlan(), ri_GenerateQual(), ri_GenerateQualCollation(), RI_MAX_NUMKEYS, ri_PerformCheck(), RI_PLAN_CASCADE_ONUPDATE, ri_PlanCheck(), RI_TRIGTYPE_UPDATE, RIAttCollation, RIAttName, RIAttType, RowExclusiveLock, SPI_connect(), SPI_finish(), SPI_OK_FINISH, SPI_OK_UPDATE, sprintf, table_close(), table_open(), TriggerData::tg_newslot, TriggerData::tg_relation, TriggerData::tg_trigger, and TriggerData::tg_trigslot.
|
static |
Definition at line 247 of file ri_triggers.c.
References RI_ConstraintInfo::agged_period_contained_by_oper, appendStringInfo(), appendStringInfoString(), attname, RI_ConstraintInfo::confmatchtype, RI_ConstraintInfo::conname, StringInfoData::data, elog, ereport, errcode(), errdetail(), errmsg(), ERROR, errtableconstraint(), RI_ConstraintInfo::fk_attnums, FKCONSTR_MATCH_FULL, FKCONSTR_MATCH_PARTIAL, FKCONSTR_MATCH_SIMPLE, RI_ConstraintInfo::hasperiod, i, initStringInfo(), MAX_QUOTED_NAME_LEN, MAX_QUOTED_REL_NAME_LEN, NameStr, RI_ConstraintInfo::nkeys, RI_ConstraintInfo::pf_eq_oprs, RI_ConstraintInfo::pk_attnums, RI_ConstraintInfo::pk_relid, PointerGetDatum(), quoteOneName(), quoteRelationName(), RelationData::rd_rel, RelationGetDescr, RelationGetRelationName, ri_BuildQueryKey(), ri_FetchConstraintInfo(), ri_FetchPreparedPlan(), ri_GenerateQual(), RI_KEYS_ALL_NULL, RI_KEYS_NONE_NULL, RI_KEYS_SOME_NULL, RI_MAX_NUMKEYS, ri_NullCheck(), ri_PerformCheck(), RI_PLAN_CHECK_LOOKUPPK, ri_PlanCheck(), RIAttName, RIAttType, RowShareLock, SnapshotSelf, SPI_connect(), SPI_finish(), SPI_OK_FINISH, SPI_OK_SELECT, sprintf, table_close(), table_open(), table_tuple_satisfies_snapshot(), TriggerData::tg_event, TriggerData::tg_newslot, TriggerData::tg_relation, TriggerData::tg_trigger, TriggerData::tg_trigslot, and TRIGGER_FIRED_BY_UPDATE.
Referenced by RI_FKey_check_ins(), and RI_FKey_check_upd().
Datum RI_FKey_check_ins | ( | PG_FUNCTION_ARGS | ) |
Definition at line 470 of file ri_triggers.c.
References ri_CheckTrigger(), RI_FKey_check(), and RI_TRIGTYPE_INSERT.
Referenced by validateForeignKeyConstraint().
Datum RI_FKey_check_upd | ( | PG_FUNCTION_ARGS | ) |
Definition at line 486 of file ri_triggers.c.
References ri_CheckTrigger(), RI_FKey_check(), and RI_TRIGTYPE_UPDATE.
bool RI_FKey_fk_upd_check_required | ( | Trigger * | trigger, |
Relation | fk_rel, | ||
TupleTableSlot * | oldslot, | ||
TupleTableSlot * | newslot | ||
) |
Definition at line 1337 of file ri_triggers.c.
References Assert, RI_ConstraintInfo::confmatchtype, FKCONSTR_MATCH_FULL, FKCONSTR_MATCH_PARTIAL, FKCONSTR_MATCH_SIMPLE, RelationData::rd_rel, RelationGetDescr, ri_FetchConstraintInfo(), RI_KEYS_ALL_NULL, RI_KEYS_SOME_NULL, ri_KeysEqual(), ri_NullCheck(), and slot_is_current_xact_tuple().
Referenced by AfterTriggerSaveEvent().
Datum RI_FKey_noaction_del | ( | PG_FUNCTION_ARGS | ) |
Definition at line 634 of file ri_triggers.c.
References ri_CheckTrigger(), ri_restrict(), and RI_TRIGTYPE_DELETE.
Datum RI_FKey_noaction_upd | ( | PG_FUNCTION_ARGS | ) |
Definition at line 671 of file ri_triggers.c.
References ri_CheckTrigger(), ri_restrict(), and RI_TRIGTYPE_UPDATE.
bool RI_FKey_pk_upd_check_required | ( | Trigger * | trigger, |
Relation | pk_rel, | ||
TupleTableSlot * | oldslot, | ||
TupleTableSlot * | newslot | ||
) |
Definition at line 1305 of file ri_triggers.c.
References RelationGetDescr, ri_FetchConstraintInfo(), RI_KEYS_NONE_NULL, ri_KeysEqual(), and ri_NullCheck().
Referenced by AfterTriggerSaveEvent().
Datum RI_FKey_restrict_del | ( | PG_FUNCTION_ARGS | ) |
Definition at line 654 of file ri_triggers.c.
References ri_CheckTrigger(), ri_restrict(), and RI_TRIGTYPE_DELETE.
Datum RI_FKey_restrict_upd | ( | PG_FUNCTION_ARGS | ) |
Definition at line 691 of file ri_triggers.c.
References ri_CheckTrigger(), ri_restrict(), and RI_TRIGTYPE_UPDATE.
Datum RI_FKey_setdefault_del | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1080 of file ri_triggers.c.
References ri_CheckTrigger(), ri_set(), and RI_TRIGTYPE_DELETE.
Datum RI_FKey_setdefault_upd | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1095 of file ri_triggers.c.
References ri_CheckTrigger(), ri_set(), and RI_TRIGTYPE_UPDATE.
Datum RI_FKey_setnull_del | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1050 of file ri_triggers.c.
References ri_CheckTrigger(), ri_set(), and RI_TRIGTYPE_DELETE.
Datum RI_FKey_setnull_upd | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1065 of file ri_triggers.c.
References ri_CheckTrigger(), ri_set(), and RI_TRIGTYPE_UPDATE.
int RI_FKey_trigger_type | ( | Oid | tgfoid | ) |
Definition at line 3116 of file ri_triggers.c.
References RI_TRIGGER_FK, RI_TRIGGER_NONE, and RI_TRIGGER_PK.
Referenced by AfterTriggerSaveEvent(), ExecCrossPartitionUpdateForeignKey(), GetForeignKeyActionTriggers(), and GetForeignKeyCheckTriggers().
|
static |
Definition at line 1987 of file ri_triggers.c.
References appendStringInfo(), buf, and generate_operator_clause().
Referenced by ri_Check_Pk_Match(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check(), RI_Initial_Check(), RI_PartitionRemove_Check(), ri_restrict(), and ri_set().
|
static |
Definition at line 2016 of file ri_triggers.c.
References appendStringInfo(), buf, elog, ERROR, get_namespace_name(), GETSTRUCT, HeapTupleIsValid, MAX_QUOTED_NAME_LEN, NameStr, ObjectIdGetDatum(), OidIsValid, quoteOneName(), ReleaseSysCache(), and SearchSysCache1().
Referenced by RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_Initial_Check(), RI_PartitionRemove_Check(), ri_restrict(), and ri_set().
|
static |
Definition at line 3023 of file ri_triggers.c.
References Assert, RI_CompareHashEntry::cast_func_finfo, COERCION_IMPLICIT, COERCION_PATH_FUNC, COERCION_PATH_RELABELTYPE, elog, RI_CompareHashEntry::eq_opr_finfo, ERROR, find_coercion_pathway(), fmgr_info_cxt(), FmgrInfo::fn_oid, format_type_be(), get_opcode(), HASH_ENTER, hash_search(), InvalidOid, IsBinaryCoercible(), sort-test::key, OidIsValid, op_input_types(), ri_compare_cache, ri_InitHashTables(), TopMemoryContext, and RI_CompareHashEntry::valid.
Referenced by ri_CompareWithCast().
|
static |
Definition at line 2853 of file ri_triggers.c.
References Assert, HASH_ENTER, hash_search(), sort-test::key, RI_QueryHashEntry::plan, plan, ri_InitHashTables(), and ri_query_cache.
Referenced by ri_PlanCheck().
|
static |
Definition at line 2765 of file ri_triggers.c.
References CacheRegisterSyscacheCallback(), ctl, HASH_BLOBS, hash_create(), HASH_ELEM, InvalidateConstraintCacheCallBack(), ri_compare_cache, ri_constraint_cache, RI_INIT_CONSTRAINTHASHSIZE, RI_INIT_QUERYHASHSIZE, and ri_query_cache.
Referenced by ri_FetchPreparedPlan(), ri_HashCompareOp(), ri_HashPreparedPlan(), and ri_LoadConstraintInfo().
Definition at line 1438 of file ri_triggers.c.
References AccessShareLock, ACL_SELECT, appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), AtEOXact_GUC(), bms_add_member(), RI_ConstraintInfo::confmatchtype, RI_ConstraintInfo::conname, StringInfoData::data, elog, ereport, errcode(), errdetail(), errmsg(), ERROR, errtableconstraint(), ExecCheckPermissions(), ExecDropSingleTupleTableSlot(), ExecStoreVirtualTuple(), FirstLowInvalidHeapAttributeNumber, RI_ConstraintInfo::fk_attnums, FKCONSTR_MATCH_FULL, FKCONSTR_MATCH_SIMPLE, GetLatestSnapshot(), GetUserId(), GUC_ACTION_SAVE, has_bypassrls_privilege(), heap_deform_tuple(), i, if(), initStringInfo(), InvalidSnapshot, lappend(), list_length(), maintenance_work_mem, makeNode, MakeSingleTupleTableSlot(), MAX_QUOTED_NAME_LEN, MAX_QUOTED_REL_NAME_LEN, NameStr, NewGUCNestLevel(), NIL, RI_ConstraintInfo::nkeys, object_ownercheck(), RI_ConstraintInfo::pf_eq_oprs, PGC_S_SESSION, PGC_USERSET, RI_ConstraintInfo::pk_attnums, quoteOneName(), quoteRelationName(), RelationData::rd_rel, RelationGetRelationName, RelationGetRelid, RangeTblEntry::relid, RTEPermissionInfo::relid, RTEPermissionInfo::requiredPerms, ri_FetchConstraintInfo(), ri_GenerateQual(), ri_GenerateQualCollation(), RI_KEYS_NONE_NULL, ri_NullCheck(), RI_PLAN_CHECK_LOOKUPPK, ri_ReportViolation(), RIAttCollation, RIAttName, RIAttType, RTE_RELATION, RangeTblEntry::rtekind, RTEPermissionInfo::selectedCols, set_config_option(), snprintf, SPI_connect(), SPI_execute_snapshot(), SPI_finish(), SPI_OK_FINISH, SPI_OK_SELECT, SPI_prepare(), SPI_processed, SPI_result, SPI_result_code_string(), SPI_tuptable, TupleTableSlot::tts_isnull, TupleTableSlot::tts_values, TTSOpsVirtual, SPITupleTable::tupdesc, and SPITupleTable::vals.
Referenced by validateForeignKeyConstraint().
|
static |
Definition at line 2890 of file ri_triggers.c.
References datum_image_eq(), RI_ConstraintInfo::ff_eq_oprs, RI_ConstraintInfo::fk_attnums, RI_ConstraintInfo::hasperiod, i, RI_ConstraintInfo::nkeys, RI_ConstraintInfo::period_contained_by_oper, RI_ConstraintInfo::pk_attnums, ri_CompareWithCast(), RIAttType, slot_getattr(), TupleTableSlot::tts_tupleDescriptor, and TupleDescAttr.
Referenced by RI_FKey_fk_upd_check_required(), and RI_FKey_pk_upd_check_required().
|
static |
Definition at line 2189 of file ri_triggers.c.
References RI_ConstraintInfo::agged_period_contained_by_oper, Assert, RI_ConstraintInfo::confdelsetcols, RI_ConstraintInfo::confdeltype, RI_ConstraintInfo::confmatchtype, RI_ConstraintInfo::confupdtype, RI_ConstraintInfo::conname, RI_ConstraintInfo::constraint_id, RI_ConstraintInfo::constraint_root_id, dclist_push_tail(), DeconstructFkConstraintRow(), elog, ERROR, RI_ConstraintInfo::ff_eq_oprs, FindFKPeriodOpers(), RI_ConstraintInfo::fk_attnums, RI_ConstraintInfo::fk_relid, get_index_column_opclass(), get_ri_constraint_root(), GETSTRUCT, GetSysCacheHashValue1, HASH_ENTER, hash_search(), RI_ConstraintInfo::hasperiod, HeapTupleIsValid, RI_ConstraintInfo::ndelsetcols, RI_ConstraintInfo::nkeys, ObjectIdGetDatum(), RI_ConstraintInfo::oidHashValue, OidIsValid, RI_ConstraintInfo::period_contained_by_oper, RI_ConstraintInfo::pf_eq_oprs, RI_ConstraintInfo::pk_attnums, RI_ConstraintInfo::pk_relid, RI_ConstraintInfo::pp_eq_oprs, ReleaseSysCache(), ri_constraint_cache, ri_constraint_cache_valid_list, ri_InitHashTables(), RI_ConstraintInfo::rootHashValue, SearchSysCache1(), RI_ConstraintInfo::valid, and RI_ConstraintInfo::valid_link.
Referenced by ri_FetchConstraintInfo().
|
static |
Definition at line 2728 of file ri_triggers.c.
References RI_ConstraintInfo::fk_attnums, i, RI_ConstraintInfo::nkeys, RI_ConstraintInfo::pk_attnums, RI_KEYS_ALL_NULL, RI_KEYS_NONE_NULL, RI_KEYS_SOME_NULL, and slot_attisnull().
Referenced by ri_Check_Pk_Match(), RI_FKey_check(), RI_FKey_fk_upd_check_required(), RI_FKey_pk_upd_check_required(), and RI_Initial_Check().
Definition at line 1732 of file ri_triggers.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), AtEOXact_GUC(), RI_ConstraintInfo::confmatchtype, StringInfoData::data, elog, ERROR, ExecStoreVirtualTuple(), RI_ConstraintInfo::fk_attnums, FKCONSTR_MATCH_FULL, FKCONSTR_MATCH_SIMPLE, GetLatestSnapshot(), GUC_ACTION_SAVE, heap_deform_tuple(), i, initStringInfo(), InvalidSnapshot, maintenance_work_mem, MakeSingleTupleTableSlot(), MAX_QUOTED_NAME_LEN, MAX_QUOTED_REL_NAME_LEN, NewGUCNestLevel(), RI_ConstraintInfo::nkeys, RI_ConstraintInfo::pf_eq_oprs, pg_get_partconstrdef_string(), PGC_S_SESSION, PGC_USERSET, RI_ConstraintInfo::pk_attnums, quoteOneName(), quoteRelationName(), RelationData::rd_rel, RelationGetRelid, ri_FetchConstraintInfo(), ri_GenerateQual(), ri_GenerateQualCollation(), ri_ReportViolation(), RIAttCollation, RIAttName, RIAttType, set_config_option(), snprintf, SPI_connect(), SPI_execute_snapshot(), SPI_finish(), SPI_OK_FINISH, SPI_OK_SELECT, SPI_prepare(), SPI_processed, SPI_result, SPI_result_code_string(), SPI_tuptable, TupleTableSlot::tts_isnull, TupleTableSlot::tts_values, TTSOpsVirtual, SPITupleTable::tupdesc, and SPITupleTable::vals.
Referenced by ATDetachCheckNoForeignKeyRefs().
|
static |
Definition at line 2404 of file ri_triggers.c.
References CommandCounterIncrement(), RI_ConstraintInfo::conname, RI_QueryKey::constr_queryno, elog, ereport, errcode(), errhint(), errmsg(), ERROR, GetLatestSnapshot(), GetTransactionSnapshot(), GetUserIdAndSecContext(), InvalidSnapshot, IsolationUsesXactSnapshot, NameStr, RI_ConstraintInfo::nkeys, RelationGetForm, RelationGetRelationName, ri_ExtractValues(), RI_MAX_NUMKEYS, RI_PLAN_CHECK_LOOKUPPK, RI_PLAN_CHECK_LOOKUPPK_FROM_PK, RI_PLAN_LAST_ON_PK, ri_ReportViolation(), SECURITY_LOCAL_USERID_CHANGE, SECURITY_NOFORCE_RLS, SetUserIdAndSecContext(), SPI_execute_snapshot(), SPI_OK_SELECT, SPI_processed, and SPI_result_code_string().
Referenced by ri_Check_Pk_Match(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check(), ri_restrict(), and ri_set().
|
static |
Definition at line 2361 of file ri_triggers.c.
References RI_QueryKey::constr_queryno, elog, ERROR, GetUserIdAndSecContext(), RelationGetForm, ri_HashPreparedPlan(), RI_PLAN_LAST_ON_PK, SECURITY_LOCAL_USERID_CHANGE, SECURITY_NOFORCE_RLS, SetUserIdAndSecContext(), SPI_keepplan(), SPI_prepare(), SPI_result, and SPI_result_code_string().
Referenced by ri_Check_Pk_Match(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check(), ri_restrict(), and ri_set().
|
static |
Definition at line 2570 of file ri_triggers.c.
References ACL_SELECT, ACLCHECK_OK, appendStringInfoString(), check_enable_rls(), RI_ConstraintInfo::conname, StringInfoData::data, ereport, errcode(), errdetail(), errmsg(), ERROR, errtableconstraint(), RI_ConstraintInfo::fk_attnums, getTypeOutputInfo(), GetUserId(), idx(), initStringInfo(), InvalidOid, name, NameStr, RI_ConstraintInfo::nkeys, OidOutputFunctionCall(), pg_attribute_aclcheck(), pg_class_aclcheck(), RI_ConstraintInfo::pk_attnums, RelationData::rd_att, RelationData::rd_id, RelationGetRelationName, RI_PLAN_CHECK_LOOKUPPK, RLS_ENABLED, slot_getattr(), TupleDescAttr, and val.
Referenced by RI_Initial_Check(), RI_PartitionRemove_Check(), and ri_PerformCheck().
|
static |
Definition at line 707 of file ri_triggers.c.
References appendStringInfo(), appendStringInfoString(), attname, StringInfoData::data, elog, ERROR, RI_ConstraintInfo::fk_attnums, RI_ConstraintInfo::fk_relid, get_collation_isdeterministic(), i, initStringInfo(), MAX_QUOTED_NAME_LEN, MAX_QUOTED_REL_NAME_LEN, RI_ConstraintInfo::nkeys, RI_ConstraintInfo::pf_eq_oprs, RI_ConstraintInfo::pk_attnums, PointerGetDatum(), quoteOneName(), quoteRelationName(), RelationData::rd_rel, ri_BuildQueryKey(), ri_Check_Pk_Match(), ri_FetchConstraintInfo(), ri_FetchPreparedPlan(), ri_GenerateQual(), ri_GenerateQualCollation(), RI_MAX_NUMKEYS, ri_PerformCheck(), RI_PLAN_RESTRICT, ri_PlanCheck(), RIAttCollation, RIAttName, RIAttType, RowShareLock, SPI_connect(), SPI_finish(), SPI_OK_FINISH, SPI_OK_SELECT, sprintf, table_close(), table_open(), TriggerData::tg_relation, TriggerData::tg_trigger, and TriggerData::tg_trigslot.
Referenced by RI_FKey_noaction_del(), RI_FKey_noaction_upd(), RI_FKey_restrict_del(), RI_FKey_restrict_upd(), and ri_set().
|
static |
Definition at line 1111 of file ri_triggers.c.
References appendStringInfo(), attname, RI_ConstraintInfo::confdelsetcols, StringInfoData::data, elog, ERROR, RI_ConstraintInfo::fk_attnums, RI_ConstraintInfo::fk_relid, get_collation_isdeterministic(), i, initStringInfo(), MAX_QUOTED_NAME_LEN, MAX_QUOTED_REL_NAME_LEN, RI_ConstraintInfo::ndelsetcols, RI_ConstraintInfo::nkeys, RI_ConstraintInfo::pf_eq_oprs, RI_ConstraintInfo::pk_attnums, PointerGetDatum(), quoteOneName(), quoteRelationName(), RelationData::rd_rel, ri_BuildQueryKey(), ri_FetchConstraintInfo(), ri_FetchPreparedPlan(), ri_GenerateQual(), ri_GenerateQualCollation(), RI_MAX_NUMKEYS, ri_PerformCheck(), RI_PLAN_SETDEFAULT_ONDELETE, RI_PLAN_SETDEFAULT_ONUPDATE, RI_PLAN_SETNULL_ONDELETE, RI_PLAN_SETNULL_ONUPDATE, ri_PlanCheck(), ri_restrict(), RI_TRIGTYPE_DELETE, RI_TRIGTYPE_UPDATE, RIAttCollation, RIAttName, RIAttType, RowExclusiveLock, SPI_connect(), SPI_finish(), SPI_OK_FINISH, SPI_OK_UPDATE, sprintf, table_close(), table_open(), TriggerData::tg_relation, TriggerData::tg_trigger, and TriggerData::tg_trigslot.
Referenced by RI_FKey_setdefault_del(), RI_FKey_setdefault_upd(), RI_FKey_setnull_del(), and RI_FKey_setnull_upd().
|
static |
Definition at line 183 of file ri_triggers.c.
Referenced by ri_HashCompareOp(), and ri_InitHashTables().
|
static |
Definition at line 181 of file ri_triggers.c.
Referenced by InvalidateConstraintCacheCallBack(), ri_InitHashTables(), and ri_LoadConstraintInfo().
|
static |
Definition at line 184 of file ri_triggers.c.
Referenced by InvalidateConstraintCacheCallBack(), and ri_LoadConstraintInfo().
|
static |
Definition at line 182 of file ri_triggers.c.
Referenced by ri_FetchPreparedPlan(), ri_HashPreparedPlan(), and ri_InitHashTables().