Added global variable to have RI triggers override

time qualification of HeapTupleSatisfiesSnapshot()

Jan
This commit is contained in:
Jan Wieck 1999-12-10 12:34:15 +00:00
parent d31ff14ed8
commit 62c42a05a2
4 changed files with 30 additions and 3 deletions

View File

@ -24,6 +24,7 @@
#include "utils/builtins.h"
#include "utils/inval.h"
#include "utils/syscache.h"
#include "utils/tqual.h"
DLLIMPORT TriggerData *CurrentTriggerData = NULL;
@ -1151,6 +1152,13 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno)
if (rettuple != NULL && rettuple != &oldtuple && rettuple != &newtuple)
pfree(rettuple);
/* ----------
* Might have been a referential integrity constraint trigger.
* Reset the snapshot overriding flag.
* ----------
*/
ReferentialIntegritySnapshotOverride = false;
/* ----------
* Release buffers and close the relation
* ----------

View File

@ -6,7 +6,7 @@
*
* 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)
trigdata = CurrentTriggerData;
CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ----------
* Check that this is a valid trigger call on the right time and event.
@ -489,6 +490,7 @@ RI_FKey_cascade_del (FmgrInfo *proinfo)
trigdata = CurrentTriggerData;
CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ----------
* Check that this is a valid trigger call on the right time and event.
@ -686,6 +688,7 @@ RI_FKey_cascade_upd (FmgrInfo *proinfo)
trigdata = CurrentTriggerData;
CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ----------
* Check that this is a valid trigger call on the right time and event.
@ -911,6 +914,7 @@ RI_FKey_restrict_del (FmgrInfo *proinfo)
trigdata = CurrentTriggerData;
CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ----------
* Check that this is a valid trigger call on the right time and event.
@ -1118,6 +1122,7 @@ RI_FKey_restrict_upd (FmgrInfo *proinfo)
trigdata = CurrentTriggerData;
CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ----------
* Check that this is a valid trigger call on the right time and event.
@ -1333,6 +1338,7 @@ RI_FKey_setnull_del (FmgrInfo *proinfo)
trigdata = CurrentTriggerData;
CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ----------
* Check that this is a valid trigger call on the right time and event.
@ -1540,6 +1546,7 @@ RI_FKey_setnull_upd (FmgrInfo *proinfo)
trigdata = CurrentTriggerData;
CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ----------
* Check that this is a valid trigger call on the right time and event.
@ -1758,6 +1765,7 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
trigdata = CurrentTriggerData;
CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ----------
* Check that this is a valid trigger call on the right time and event.
@ -2005,6 +2013,7 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
trigdata = CurrentTriggerData;
CurrentTriggerData = NULL;
ReferentialIntegritySnapshotOverride = true;
/* ----------
* Check that this is a valid trigger call on the right time and event.

View File

@ -7,7 +7,7 @@
*
*
* 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;
Snapshot QuerySnapshot = NULL;
Snapshot SerializableSnapshot = NULL;
bool ReferentialIntegritySnapshotOverride = false;
/*
* XXX Transaction system override hacks start here
*/
@ -493,6 +495,9 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
if (AMI_OVERRIDE)
return true;
if (ReferentialIntegritySnapshotOverride)
return HeapTupleSatisfiesNow(tuple);
if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
{
if (tuple->t_infomask & HEAP_XMIN_INVALID)
@ -606,6 +611,9 @@ void
SetQuerySnapshot(void)
{
/* Initialize snapshot overriding to false */
ReferentialIntegritySnapshotOverride = false;
/* 1st call in xaction */
if (SerializableSnapshot == NULL)
{

View File

@ -7,7 +7,7 @@
*
* 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;
extern Snapshot QuerySnapshot;
extern Snapshot SerializableSnapshot;
extern bool ReferentialIntegritySnapshotOverride;
#define IsSnapshotNow(snapshot) ((Snapshot) snapshot == SnapshotNow)
#define IsSnapshotSelf(snapshot) ((Snapshot) snapshot == SnapshotSelf)
#define IsSnapshotAny(snapshot) ((Snapshot) snapshot == SnapshotAny)