mirror of
https://github.com/postgres/postgres.git
synced 2025-05-28 05:21:27 +03:00
Cache NO ACTION foreign keys separately from RESTRICT foreign keys
Now that we generate different SQL for temporal NO ACTION vs RESTRICT foreign keys, we should cache their query plans with different keys. Since the key also includes the constraint oid, this shouldn't be necessary, but we have been seeing build farm failures that suggest we might be sometimes using a cached NO ACTION plan to implement a RESTRICT constraint. Author: Paul A. Jungwirth <pj@illuminatedcomputing.com> Discussion: https://www.postgresql.org/message-id/flat/CA+renyUApHgSZF9-nd-a0+OPGharLQLO=mDHcY4_qQ0+noCUVg@mail.gmail.com
This commit is contained in:
parent
a9258629ed
commit
9926f854d0
@ -74,12 +74,13 @@
|
||||
/* these queries are executed against the FK (referencing) table: */
|
||||
#define RI_PLAN_CASCADE_ONDELETE 3
|
||||
#define RI_PLAN_CASCADE_ONUPDATE 4
|
||||
#define RI_PLAN_NO_ACTION 5
|
||||
/* For RESTRICT, the same plan can be used for both ON DELETE and ON UPDATE triggers. */
|
||||
#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 RI_PLAN_RESTRICT 6
|
||||
#define RI_PLAN_SETNULL_ONDELETE 7
|
||||
#define RI_PLAN_SETNULL_ONUPDATE 8
|
||||
#define RI_PLAN_SETDEFAULT_ONDELETE 9
|
||||
#define RI_PLAN_SETDEFAULT_ONUPDATE 10
|
||||
|
||||
#define MAX_QUOTED_NAME_LEN (NAMEDATALEN*2+3)
|
||||
#define MAX_QUOTED_REL_NAME_LEN (MAX_QUOTED_NAME_LEN*2)
|
||||
@ -752,7 +753,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action)
|
||||
* Fetch or prepare a saved plan for the restrict lookup (it's the same
|
||||
* query for delete and update cases)
|
||||
*/
|
||||
ri_BuildQueryKey(&qkey, riinfo, RI_PLAN_RESTRICT);
|
||||
ri_BuildQueryKey(&qkey, riinfo, is_no_action ? RI_PLAN_NO_ACTION : RI_PLAN_RESTRICT);
|
||||
|
||||
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user