Re: [HACKERS] Adding the optional clause 'AS' in CREATE TRIGGER

Поиск
Список
Период
Сортировка
От Surafel Temesgen
Тема Re: [HACKERS] Adding the optional clause 'AS' in CREATE TRIGGER
Дата
Msg-id CALAY4q_hYB=8fxtt3Lbt7m7pN1YT04xd2Aie1N8PuL044M4tdw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Adding the optional clause 'AS' in CREATE TRIGGER  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Adding the optional clause 'AS' in CREATE TRIGGER
Список 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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Petr Jelinek
Дата:
Сообщение: Re: [HACKERS] [COMMITTERS] pgsql: Use asynchronous connect API inlibpqwalreceiver
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] logical decoding of two-phase transactions