a row not deletes - Mailing list pgsql-general

From Rafał Pietrak
Subject a row not deletes
Date
Msg-id 535CBE76.7030909@ztk-rp.eu
Whole thread Raw
Responses Re: a row not deletes  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-general
Hi the list,

I've just experienced an unexpected (for me) "loss" of DELETE. Is this a
feature or a bug (postgres v.s. SQL)?

-------------------- test case -------------------------
test=# CREATE  TABLE test (a int, b text);
test=# INSERT  INTO  test (a,b) values (1,'asd');
test=# INSERT  INTO  test (a,b) values (2,'dfg');
test=# INSERT  INTO  test (a,b) values (3,'ghj');
test=# CREATE or replace FUNCTION test_del () returns trigger language
plpgsql as $$ begin  update test t set b = 'will delete this' where
t.a=old.a; return old; end; $$;
test=# CREATE  TRIGGER  test_trig BEFORE DELETE ON test for each row
execute procedure test_del();

test=# DELETE FROM  test where a=2;
DELETE 0
test=# SELECT * from test;
  a  |  b
----+-----
   1 | asd
   3 | ghj
   2 | will delete this
(3 rows)
--------------------------------------------------------

e.g.: an indicated row is not deleted, despite the fact, that the
selector wasn't changed by the intermediate UPDATE.  I understand, that
the bucket was changed by the update, but should that matter?

-R


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: about the copy command
Next
From: Andres Freund
Date:
Subject: Re: a row not deletes