pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14679: Inconsistent/wrong behavior of pg_trigger_depth when used with DEFERRED CONSTRAINTS
3+ messages / 3 participants
[nested] [flat]

* BUG #14679: Inconsistent/wrong behavior of pg_trigger_depth when used with DEFERRED CONSTRAINTS
@ 2017-05-30 06:55 achill@matrix.gatewaynet.com
  2017-05-30 14:03 ` Re: BUG #14679: Inconsistent/wrong behavior of pg_trigger_depth when used with DEFERRED CONSTRAINTS Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: achill@matrix.gatewaynet.com @ 2017-05-30 06:55 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      14679
Logged by:          Achilleas Mantzios
Email address:      achill@matrix.gatewaynet.com
PostgreSQL version: 9.5.6
Operating system:   Ubuntu 16.04.1 LTS , 4.4.0-38-generic
Description:        

I just run into a behavior that I consider wrong. Test case :

create table test(id serial primary key, name text);

CREATE OR REPLACE FUNCTION public.force_integrity()
 RETURNS trigger
 LANGUAGE plpgsql
AS $function$DECLARE

BEGIN
        RAISE NOTICE 'TABLE = %.% , pg_trigger_depth()=%',TG_TABLE_SCHEMA,
TG_TABLE_NAME, pg_trigger_depth();
        IF (pg_trigger_depth() = 1) THEN
                UPDATE test SET id=id WHERE id=NEW.id;
        END IF;
        RETURN NEW;
END;
$function$

CREATE CONSTRAINT TRIGGER test_force_integrity_tg
  AFTER INSERT OR UPDATE
  ON test
  DEFERRABLE INITIALLY DEFERRED
  FOR EACH ROW
  EXECUTE PROCEDURE force_integrity();


-- test by forcing immediate constraints and thus expected results

begin;

BEGIN

set CONSTRAINTS ALL IMMEDIATE;

insert into test(name) values ('foo');
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=2
CONTEXT:  SQL statement "UPDATE test SET id=id WHERE id=NEW.id"
PL/pgSQL function force_integrity() line 9 at SQL statement
INSERT 0 1

commit;

COMMIT

-- test with defaults - unexpected results

begin ;
BEGIN
insert into test(name) values ('foo');
INSERT 0 1
commit ;

NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1
NOTICE:  TABLE = public.test , pg_trigger_depth()=1

-- Endless loop, pg_trigger_depth() never gets increased

This was reproduced on 9.3.17 and on 9.5.6


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #14679: Inconsistent/wrong behavior of pg_trigger_depth when used with DEFERRED CONSTRAINTS
  2017-05-30 06:55 BUG #14679: Inconsistent/wrong behavior of pg_trigger_depth when used with DEFERRED CONSTRAINTS achill@matrix.gatewaynet.com
@ 2017-05-30 14:03 ` Tom Lane <tgl@sss.pgh.pa.us>
  2017-05-30 14:11   ` Re: BUG #14679: Inconsistent/wrong behavior of pg_trigger_depth when used with DEFERRED CONSTRAINTS Achilleas Mantzios <achill@matrix.gatewaynet.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2017-05-30 14:03 UTC (permalink / raw)
  To: achill@matrix.gatewaynet.com; +Cc: pgsql-bugs

achill@matrix.gatewaynet.com writes:
> I just run into a behavior that I consider wrong. Test case :

Isn't this the same thing you already filed in
<3d1a5143-389c-256a-cda9-44ca002fc606@matrix.gatewaynet.com>?

Duplicate bug reports just confuse matters.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #14679: Inconsistent/wrong behavior of pg_trigger_depth when used with DEFERRED CONSTRAINTS
  2017-05-30 06:55 BUG #14679: Inconsistent/wrong behavior of pg_trigger_depth when used with DEFERRED CONSTRAINTS achill@matrix.gatewaynet.com
  2017-05-30 14:03 ` Re: BUG #14679: Inconsistent/wrong behavior of pg_trigger_depth when used with DEFERRED CONSTRAINTS Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-05-30 14:11   ` Achilleas Mantzios <achill@matrix.gatewaynet.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Achilleas Mantzios @ 2017-05-30 14:11 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

On 30/05/2017 17:03, Tom Lane wrote:
> achill@matrix.gatewaynet.com writes:
>> I just run into a behavior that I consider wrong. Test case :
> Isn't this the same thing you already filed in
> <3d1a5143-389c-256a-cda9-44ca002fc606@matrix.gatewaynet.com>?
Yes, I just thought that it went unnoticed , so I tried the official method.
>
> Duplicate bug reports just confuse matters.
Won't happen again. Thanks for taking care of this.
>
> 			regards, tom lane


-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2017-05-30 14:11 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 06:55 BUG #14679: Inconsistent/wrong behavior of pg_trigger_depth when used with DEFERRED CONSTRAINTS achill@matrix.gatewaynet.com
2017-05-30 14:03 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-05-30 14:11   ` Achilleas Mantzios <achill@matrix.gatewaynet.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox