Commit 62c42a05 authored by Jan Wieck's avatar Jan Wieck

Added global variable to have RI triggers override

time qualification of HeapTupleSatisfiesSnapshot()

Jan
parent d31ff14e
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/inval.h" #include "utils/inval.h"
#include "utils/syscache.h" #include "utils/syscache.h"
#include "utils/tqual.h"
DLLIMPORT TriggerData *CurrentTriggerData = NULL; DLLIMPORT TriggerData *CurrentTriggerData = NULL;
...@@ -1151,6 +1152,13 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno) ...@@ -1151,6 +1152,13 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno)
if (rettuple != NULL && rettuple != &oldtuple && rettuple != &newtuple) if (rettuple != NULL && rettuple != &oldtuple && rettuple != &newtuple)
pfree(rettuple); pfree(rettuple);
/* ----------
* Might have been a referential integrity constraint trigger.
* Reset the snapshot overriding flag.
* ----------
*/
ReferentialIntegritySnapshotOverride = false;
/* ---------- /* ----------
* Release buffers and close the relation * Release buffers and close the relation
* ---------- * ----------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* 1999 Jan Wieck * 1999 Jan Wieck
* *
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.9 1999/12/08 20:41:22 wieck Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.10 1999/12/10 12:34:13 wieck Exp $
* *
* ---------- * ----------
*/ */
...@@ -163,6 +163,7 @@ RI_FKey_check (FmgrInfo *proinfo) ...@@ -163,6 +163,7 @@ RI_FKey_check (FmgrInfo *proinfo)
trigdata = CurrentTriggerData; trigdata = CurrentTriggerData;
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ---------- /* ----------
* Check that this is a valid trigger call on the right time and event. * Check that this is a valid trigger call on the right time and event.
...@@ -489,6 +490,7 @@ RI_FKey_cascade_del (FmgrInfo *proinfo) ...@@ -489,6 +490,7 @@ RI_FKey_cascade_del (FmgrInfo *proinfo)
trigdata = CurrentTriggerData; trigdata = CurrentTriggerData;
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ---------- /* ----------
* Check that this is a valid trigger call on the right time and event. * Check that this is a valid trigger call on the right time and event.
...@@ -686,6 +688,7 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo) ...@@ -686,6 +688,7 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo)
trigdata = CurrentTriggerData; trigdata = CurrentTriggerData;
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ---------- /* ----------
* Check that this is a valid trigger call on the right time and event. * Check that this is a valid trigger call on the right time and event.
...@@ -911,6 +914,7 @@ RI_FKey_restrict_del (FmgrInfo *proinfo) ...@@ -911,6 +914,7 @@ RI_FKey_restrict_del (FmgrInfo *proinfo)
trigdata = CurrentTriggerData; trigdata = CurrentTriggerData;
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ---------- /* ----------
* Check that this is a valid trigger call on the right time and event. * Check that this is a valid trigger call on the right time and event.
...@@ -1118,6 +1122,7 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo) ...@@ -1118,6 +1122,7 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo)
trigdata = CurrentTriggerData; trigdata = CurrentTriggerData;
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ---------- /* ----------
* Check that this is a valid trigger call on the right time and event. * Check that this is a valid trigger call on the right time and event.
...@@ -1333,6 +1338,7 @@ RI_FKey_setnull_del (FmgrInfo *proinfo) ...@@ -1333,6 +1338,7 @@ RI_FKey_setnull_del (FmgrInfo *proinfo)
trigdata = CurrentTriggerData; trigdata = CurrentTriggerData;
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ---------- /* ----------
* Check that this is a valid trigger call on the right time and event. * Check that this is a valid trigger call on the right time and event.
...@@ -1540,6 +1546,7 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo) ...@@ -1540,6 +1546,7 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
trigdata = CurrentTriggerData; trigdata = CurrentTriggerData;
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ---------- /* ----------
* Check that this is a valid trigger call on the right time and event. * Check that this is a valid trigger call on the right time and event.
...@@ -1758,6 +1765,7 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo) ...@@ -1758,6 +1765,7 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
trigdata = CurrentTriggerData; trigdata = CurrentTriggerData;
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ---------- /* ----------
* Check that this is a valid trigger call on the right time and event. * Check that this is a valid trigger call on the right time and event.
...@@ -2005,6 +2013,7 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo) ...@@ -2005,6 +2013,7 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
trigdata = CurrentTriggerData; trigdata = CurrentTriggerData;
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ---------- /* ----------
* Check that this is a valid trigger call on the right time and event. * Check that this is a valid trigger call on the right time and event.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.32 1999/10/06 21:58:11 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.33 1999/12/10 12:34:14 wieck Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -24,6 +24,8 @@ Snapshot SnapshotDirty = &SnapshotDirtyData; ...@@ -24,6 +24,8 @@ Snapshot SnapshotDirty = &SnapshotDirtyData;
Snapshot QuerySnapshot = NULL; Snapshot QuerySnapshot = NULL;
Snapshot SerializableSnapshot = NULL; Snapshot SerializableSnapshot = NULL;
bool ReferentialIntegritySnapshotOverride = false;
/* /*
* XXX Transaction system override hacks start here * XXX Transaction system override hacks start here
*/ */
...@@ -493,6 +495,9 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) ...@@ -493,6 +495,9 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
if (AMI_OVERRIDE) if (AMI_OVERRIDE)
return true; return true;
if (ReferentialIntegritySnapshotOverride)
return HeapTupleSatisfiesNow(tuple);
if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
{ {
if (tuple->t_infomask & HEAP_XMIN_INVALID) if (tuple->t_infomask & HEAP_XMIN_INVALID)
...@@ -606,6 +611,9 @@ void ...@@ -606,6 +611,9 @@ void
SetQuerySnapshot(void) SetQuerySnapshot(void)
{ {
/* Initialize snapshot overriding to false */
ReferentialIntegritySnapshotOverride = false;
/* 1st call in xaction */ /* 1st call in xaction */
if (SerializableSnapshot == NULL) if (SerializableSnapshot == NULL)
{ {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: tqual.h,v 1.25 1999/09/29 16:06:28 wieck Exp $ * $Id: tqual.h,v 1.26 1999/12/10 12:34:15 wieck Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -36,6 +36,8 @@ extern Snapshot SnapshotDirty; ...@@ -36,6 +36,8 @@ extern Snapshot SnapshotDirty;
extern Snapshot QuerySnapshot; extern Snapshot QuerySnapshot;
extern Snapshot SerializableSnapshot; extern Snapshot SerializableSnapshot;
extern bool ReferentialIntegritySnapshotOverride;
#define IsSnapshotNow(snapshot) ((Snapshot) snapshot == SnapshotNow) #define IsSnapshotNow(snapshot) ((Snapshot) snapshot == SnapshotNow)
#define IsSnapshotSelf(snapshot) ((Snapshot) snapshot == SnapshotSelf) #define IsSnapshotSelf(snapshot) ((Snapshot) snapshot == SnapshotSelf)
#define IsSnapshotAny(snapshot) ((Snapshot) snapshot == SnapshotAny) #define IsSnapshotAny(snapshot) ((Snapshot) snapshot == SnapshotAny)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment