From: | Surafel Temesgen <surafel3000(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Okano, Naoki" <okano(dot)naoki(at)jp(dot)fujitsu(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Adding the optional clause 'AS' in CREATE TRIGGER |
Date: | 2017-03-17 15:58:17 |
Message-ID: | CALAY4q_hYB=8fxtt3Lbt7m7pN1YT04xd2Aie1N8PuL044M4tdw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>
>
> I am sending the review of this patch
I found the following
v Use <optional> tage in documentation
v Don’t modified existing test case add new one instead
v Comment in pg_constraint.c is extended make it short
v Error message can be more guider if it tells about general rule
v Wrong result in concurrency case
Step to produce the result
1. build with with --enable-cassert and with
-DCATCACHE_FORCE_RELEASE=1
2. Run these commands as setup:
CREATE TABLE my_table1 (id integer, name text);
CREATE TABLE my_table2 (id integer);
3. CREATE FUNCTION my_deleteproc1() RETURNS trigger AS $$
begin
DELETE FROM my_table2 WHERE id=OLD.id;
RETURN NULL;
end;$$ LANGUAGE plpgsql;
4. INSERT INTO my_table1 VALUES(323, 'Alex');
INSERT INTO my_table1 VALUES(23, 'Teddy');
INSERT INTO my_table1 VALUES(38, 'Bob');
INSERT INTO my_table2 VALUES(323);
INSERT INTO my_table2 VALUES(23);
INSERT INTO my_table2 VALUES(38);
5. CREATE OR REPLACE TRIGGER my_regular_trigger AFTER DELETE ON
my_table1
FOR EACH ROW
EXECUTE PROCEDURE my_deleteproc1();
6. Attach a debugger to your session set a breakpoint at
ExecARDeleteTriggers
7. Run this in your session
DELETE FROM my_table1 WHERE id=323;
8. start another session and run:
CREATE OR REPLACE TRIGGER my_regular_trigger
AFTER INSERT ON my_table1
FOR EACH ROW
EXECUTE PROCEDURE my_deleteproc1();
9. exite the debugger to release the first session
and the result
postgres=# SELECT * FROM my_table1;
id | name
----+-------
23 | Teddy
38 | Bob
(2 rows)
postgres=# SELECT * FROM my_table2;
id
-----
323
23
38
(3 rows)
Id number 323 should not be there in my_table2;
Regards
Surafel
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2017-03-17 15:59:50 | Re: logical decoding of two-phase transactions |
Previous Message | Petr Jelinek | 2017-03-17 15:54:03 | Re: [COMMITTERS] pgsql: Use asynchronous connect API in libpqwalreceiver |