From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: hyanchurevich@spotware.com
Subject: BUG #17827: Rule on insert into table doesn't work when excepting select from the table itself
Date: Thu, 09 Mar 2023 10:27:00 +0000
Message-ID: <17827-1dfd5ad9af280484@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 17827
Logged by: Hanna Yanchurevich
Email address: hyanchurevich@spotware.com
PostgreSQL version: 13.2
Operating system: Centos 7
Description:
To reproduce this bug you may use following script:
create table tbl (id int);
create table rule_stat (msg text, id int);
create rule rule_tbl as on insert to tbl do insert into rule_stat
values('Rule triggered for ',new.id);
insert into tbl
select 1
except
select id from tbl;
table rule_stat; -- no rows
And using WHERE true clause for target table rule not working too:
insert into tbl
select 2
except
select id from tbl where true;
table rule_stat; -- no rows
But using WHERE false clause for target table rule starts working:
insert into tbl
select 1
except
select id from tbl where false;
table rule_stat; -- new row appears
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, hyanchurevich@spotware.com
Subject: Re: BUG #17827: Rule on insert into table doesn't work when excepting select from the table itself
In-Reply-To: <17827-1dfd5ad9af280484@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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