Skip to content

Commit 1547ee0

Browse files
Jan WieckJan Wieck
authored andcommitted
This is part #1 for of the DEFERRED CONSTRAINT TRIGGER support.
Implements the CREATE CONSTRAINT TRIGGER and SET CONSTRAINTS commands. TODO: Generic builtin trigger procedures Automatic execution of appropriate CREATE CONSTRAINT... at CREATE TABLE Support of new trigger type in pg_dump Swapping of huge # of events to disk Jan
1 parent d810338 commit 1547ee0

File tree

20 files changed

+1473
-245
lines changed

20 files changed

+1473
-245
lines changed

src/backend/access/transam/xact.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.54 1999/09/28 11:41:03 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.55 1999/09/29 16:05:55 wieck Exp $
1111
*
1212
* NOTES
1313
* Transaction aborts can now occur two ways:
@@ -149,6 +149,7 @@
149149
#include "commands/async.h"
150150
#include "commands/sequence.h"
151151
#include "commands/vacuum.h"
152+
#include "commands/trigger.h"
152153
#include "libpq/be-fsstubs.h"
153154
#include "storage/proc.h"
154155
#include "storage/sinval.h"
@@ -865,6 +866,12 @@ StartTransaction()
865866
*/
866867
InitNoNameRelList();
867868

869+
/* ----------------
870+
* Tell the trigger manager to we're starting a transaction
871+
* ----------------
872+
*/
873+
DeferredTriggerBeginXact();
874+
868875
/* ----------------
869876
* done with start processing, set current transaction
870877
* state to "in progress"
@@ -904,6 +911,14 @@ CommitTransaction()
904911
if (s->state != TRANS_INPROGRESS)
905912
elog(NOTICE, "CommitTransaction and not in in-progress state ");
906913

914+
/* ----------------
915+
* Tell the trigger manager that this transaction is about to be
916+
* committed. He'll invoke all trigger deferred until XACT before
917+
* we really start on committing the transaction.
918+
* ----------------
919+
*/
920+
DeferredTriggerEndXact();
921+
907922
/* ----------------
908923
* set the current transaction state information
909924
* appropriately during the abort processing
@@ -992,6 +1007,13 @@ AbortTransaction()
9921007
if (s->state != TRANS_INPROGRESS)
9931008
elog(NOTICE, "AbortTransaction and not in in-progress state ");
9941009

1010+
/* ----------------
1011+
* Tell the trigger manager that this transaction is about to be
1012+
* aborted.
1013+
* ----------------
1014+
*/
1015+
DeferredTriggerAbortXact();
1016+
9951017
/* ----------------
9961018
* set the current transaction state information
9971019
* appropriately during the abort processing

src/backend/catalog/heap.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.98 1999/09/24 00:24:11 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.99 1999/09/29 16:05:56 wieck Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -1468,8 +1468,7 @@ heap_destroy_with_catalog(char *relname)
14681468
RelationRemoveRules(rid);
14691469

14701470
/* triggers */
1471-
if (rel->rd_rel->reltriggers > 0)
1472-
RelationRemoveTriggers(rel);
1471+
RelationRemoveTriggers(rel);
14731472

14741473
/* ----------------
14751474
* delete attribute tuples

src/backend/catalog/indexing.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.45 1999/09/18 19:06:33 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.46 1999/09/29 16:05:56 wieck Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -52,7 +52,9 @@ char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex};
5252

5353
char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex};
5454

55-
char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex};
55+
char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex,
56+
TriggerConstrNameIndex,
57+
TriggerConstrRelidIndex};
5658

5759

5860
static HeapTuple CatalogIndexFetchTuple(Relation heapRelation,

0 commit comments

Comments
 (0)