mirror of
https://github.com/postgres/postgres.git
synced 2025-12-18 05:01:01 +03:00
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
This commit is contained in:
@@ -64,101 +64,6 @@ NOTICE: check_pkeys_fkey_cascade: 1 tuple(s) of fkeys2 are deleted
|
||||
QUERY: DROP TABLE pkeys;
|
||||
QUERY: DROP TABLE fkeys;
|
||||
QUERY: DROP TABLE fkeys2;
|
||||
QUERY: create table dup17 (x int4);
|
||||
QUERY: create trigger dup17_before
|
||||
before insert on dup17
|
||||
for each row
|
||||
execute procedure
|
||||
funny_dup17 ()
|
||||
;
|
||||
QUERY: insert into dup17 values (17);
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 1: 0/0 tuples inserted/selected
|
||||
QUERY: select count(*) from dup17;
|
||||
count
|
||||
-----
|
||||
1
|
||||
(1 row)
|
||||
|
||||
QUERY: insert into dup17 values (17);
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 17: 1/2 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 16: 1/3 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 15: 1/4 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 14: 1/5 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 13: 1/6 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 12: 1/7 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 11: 1/8 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 10: 1/9 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 9: 1/10 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 8: 1/11 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 7: 1/12 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 6: 1/13 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 5: 1/14 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 4: 1/15 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 3: 1/16 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 2: 1/17 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired BEFORE) on level 1: 1/18 tuples inserted/selected
|
||||
QUERY: select count(*) from dup17;
|
||||
count
|
||||
-----
|
||||
19
|
||||
(1 row)
|
||||
|
||||
QUERY: drop trigger dup17_before on dup17;
|
||||
QUERY: create trigger dup17_after
|
||||
after insert on dup17
|
||||
for each row
|
||||
execute procedure
|
||||
funny_dup17 ()
|
||||
;
|
||||
QUERY: insert into dup17 values (13);
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 17: 17/34 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 16: 16/49 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 15: 15/63 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 14: 14/76 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 13: 13/88 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 12: 12/99 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 11: 11/109 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 10: 10/118 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 9: 9/126 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 8: 8/133 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 7: 7/139 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 6: 6/144 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 5: 5/148 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 4: 4/151 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 3: 3/153 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 2: 2/154 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 1: 1/154 tuples inserted/selected
|
||||
QUERY: select count(*) from dup17 where x = 13;
|
||||
count
|
||||
-----
|
||||
154
|
||||
(1 row)
|
||||
|
||||
QUERY: insert into dup17 values (13);
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 17: 171/342 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 16: 170/511 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 15: 169/679 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 14: 168/846 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 13: 167/1012 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 12: 166/1177 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 11: 165/1341 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 10: 164/1504 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 9: 163/1666 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 8: 162/1827 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 7: 161/1987 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 6: 160/2146 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 5: 159/2304 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 4: 158/2461 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 3: 157/2617 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 2: 156/2772 tuples inserted/selected
|
||||
NOTICE: funny_dup17 (fired AFTER ) on level 1: 155/2926 tuples inserted/selected
|
||||
QUERY: select count(*) from dup17 where x = 13;
|
||||
count
|
||||
-----
|
||||
2926
|
||||
(1 row)
|
||||
|
||||
QUERY: DROP TABLE dup17;
|
||||
QUERY: create sequence ttdummy_seq increment 10 start 0 minvalue 0;
|
||||
QUERY: create table tttest (
|
||||
price_id int4,
|
||||
|
||||
@@ -88,34 +88,40 @@ DROP TABLE pkeys;
|
||||
DROP TABLE fkeys;
|
||||
DROP TABLE fkeys2;
|
||||
|
||||
create table dup17 (x int4);
|
||||
|
||||
create trigger dup17_before
|
||||
before insert on dup17
|
||||
for each row
|
||||
execute procedure
|
||||
funny_dup17 ()
|
||||
;
|
||||
|
||||
insert into dup17 values (17);
|
||||
select count(*) from dup17;
|
||||
insert into dup17 values (17);
|
||||
select count(*) from dup17;
|
||||
|
||||
drop trigger dup17_before on dup17;
|
||||
|
||||
create trigger dup17_after
|
||||
after insert on dup17
|
||||
for each row
|
||||
execute procedure
|
||||
funny_dup17 ()
|
||||
;
|
||||
insert into dup17 values (13);
|
||||
select count(*) from dup17 where x = 13;
|
||||
insert into dup17 values (13);
|
||||
select count(*) from dup17 where x = 13;
|
||||
|
||||
DROP TABLE dup17;
|
||||
-- -- I've disabled the funny_dup17 test because the new semantics
|
||||
-- -- of AFTER ROW triggers, which get now fired at the end of a
|
||||
-- -- query allways, cause funny_dup17 to enter an endless loop.
|
||||
-- --
|
||||
-- -- Jan
|
||||
--
|
||||
-- create table dup17 (x int4);
|
||||
--
|
||||
-- create trigger dup17_before
|
||||
-- before insert on dup17
|
||||
-- for each row
|
||||
-- execute procedure
|
||||
-- funny_dup17 ()
|
||||
-- ;
|
||||
--
|
||||
-- insert into dup17 values (17);
|
||||
-- select count(*) from dup17;
|
||||
-- insert into dup17 values (17);
|
||||
-- select count(*) from dup17;
|
||||
--
|
||||
-- drop trigger dup17_before on dup17;
|
||||
--
|
||||
-- create trigger dup17_after
|
||||
-- after insert on dup17
|
||||
-- for each row
|
||||
-- execute procedure
|
||||
-- funny_dup17 ()
|
||||
-- ;
|
||||
-- insert into dup17 values (13);
|
||||
-- select count(*) from dup17 where x = 13;
|
||||
-- insert into dup17 values (13);
|
||||
-- select count(*) from dup17 where x = 13;
|
||||
--
|
||||
-- DROP TABLE dup17;
|
||||
|
||||
create sequence ttdummy_seq increment 10 start 0 minvalue 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user