ON DELETE triggers don't work as documented

Поиск
Список
Период
Сортировка
От Mike Glover
Тема ON DELETE triggers don't work as documented
Дата
Msg-id 20021209213323.A21052@mdi.cc
обсуждение исходный текст
Ответы Re: ON DELETE triggers don't work as documented  (Joe Conway <mail@joeconway.com>)
Список pgsql-bugs
If PostgreSQL failed to compile on your computer or you found a bug that
is likely to be specific to one platform then please fill out this form
and e-mail it to pgsql-ports@postgresql.org.

To report any other bug, fill out the form below and e-mail it to
pgsql-bugs@postgresql.org.

If you not only found the problem but solved it and generated a patch
then e-mail it to pgsql-patches@postgresql.org instead.  Please use the
command "diff -c" to generate the patch.

You may also enter a bug report at http://www.postgresql.org/ instead of
e-mail-ing this form.

============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name        :    Mike Glover
Your email address    :    mpg4@mdi.cc


System Configuration
---------------------
  Architecture (example: Intel Pentium)      : Mixed ix86

  Operating System (example: Linux 2.0.26 ELF)     : Linux 2.4.x

  PostgreSQL version (example: PostgreSQL-7.2.1):   PostgreSQL-7.2.1

  Compiler used (example:  gcc 2.95.2)        : gcc 2.96


Please enter a FULL description of your problem:
------------------------------------------------
The docs state (section 23.9):

If a non-NULL value is returned then the operation proceeds with that row value. Note that returning a row value
differentfrom the original value of NEW alters the row that will be inserted or updated. 

the above suggests that returning NEW for a delete should cause the delete to proceed.  In fact, I've found it
necessaryto return a record with the row format of the table and all empty fields. 


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------
db=# create table test (field1 int, field2 text);
CREATE
db=# create or replace function test_trigger () returns opaque as '
mdisys'# DECLARE
mdisys'# BEGIN
mdisys'# return NEW;
mdisys'# END
mdisys'# ' language plpgsql;
CREATE
db=# create trigger run_test_trigger before delete on test for each row execute procedure test_trigger();
CREATE
db=# insert into test values (1, 'foo');
INSERT 123700 1
db=# insert into test values (2, 'bar');
INSERT 123701 1
db=# delete from test where field1=1;
DELETE 0
db=# select * from test;
 field1 | field2
--------+--------
      1 | foo
      2 | bar
(2 rows)

db=#


If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

I believe this is a documentation bug.

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

Предыдущее
От: Stéphane Bérubé
Дата:
Сообщение: Debian, postgresql 7.3a4
Следующее
От: Nikolay Hristov
Дата:
Сообщение: Bug #843: pg_clog files problem - clarification