From: Japin Li <japinli@hotmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Richard Guo <guofenglinux@gmail.com>
Cc: jiye_sw@126.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.
Date: Wed, 12 Oct 2022 00:16:37 +0800
Message-ID: <MEYP282MB16690E8D4FCC095086FC9242B6239@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <348879.1665502632@sss.pgh.pa.us>
References: <17633-98cc85e1fa91e905@postgresql.org>
<CAMbWs49K+LkBFTu3XqJgso=_BTJ81NJv9N5Bx0_4XikkmG-qdA@mail.gmail.com>
<CAMbWs4-Z8hSnHOTrCV4-Pp1+H9+i34O68pSkhEHLyDpYfPyqpQ@mail.gmail.com>
<MEYP282MB1669B7492DAFE6913C127ED8B6239@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM>
<CAMbWs491JOKxnc3f3XGj1oYAzi=OJP6=YjUZnQ=hAUxo3BF+hQ@mail.gmail.com>
<MEYP282MB1669B5146A97FCD8D18A75EFB6239@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM>
<312797.1665500865@sss.pgh.pa.us>
<348879.1665502632@sss.pgh.pa.us>
On Tue, 11 Oct 2022 at 23:37, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> I wrote:
>> I think the basic problem is that the two calls of rewriteValuesRTE
>> are really dealing with fundamentally different cases, and we should
>> probably not have tried to make the same function do both. I'm going
>> to try splitting it into two functions, one for the force_nulls case
>> and one for the !force_nulls case.
>
> As attached. This seems *way* cleaner to me, even if it means we need
> two copies of the loops-over-VALUES-list-entries. I didn't write a
> regression test yet, but this fixes the submitted bug and passes
> check-world.
>
Great. LGTM. Should we add the test-case for this?
--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.
Attachments:test-case-for-bug-17633.patch (text/x-patch, 1.4K) downloaddiff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.outindex 9dd137415e..2fbc30aaad 100644--- a/src/test/regress/expected/rules.out+++ b/src/test/regress/expected/rules.out@@ -3585,3 +3585,15 @@ DROP VIEW ruletest_v1;
DROP TABLE ruletest_t2;
DROP TABLE ruletest_t1;
DROP USER regress_rule_user1;
+--+-- Test case for BUG 17633+--+CREATE TABLE ruletest_t1 (x int);+CREATE TABLE ruletest_t2 (a int, b int);+CREATE VIEW ruletest_v1 AS SELECT * FROM ruletest_t1;+CREATE RULE rule1 AS ON INSERT TO ruletest_v1+ DO ALSO INSERT INTO ruletest_t2(b) VALUES (NEW.*);+INSERT INTO ruletest_v1 VALUES (default), (default);+DROP VIEW ruletest_v1;+DROP TABLE ruletest_t1;+DROP TABLE ruletest_t2;diff --git a/src/test/regress/sql/rules.sql b/src/test/regress/sql/rules.sqlindex bfb5f3b0bb..290ea2bd8a 100644--- a/src/test/regress/sql/rules.sql+++ b/src/test/regress/sql/rules.sql@@ -1318,3 +1318,19 @@ DROP TABLE ruletest_t2;
DROP TABLE ruletest_t1;
DROP USER regress_rule_user1;
++--+-- Test case for BUG 17633+--+CREATE TABLE ruletest_t1 (x int);+CREATE TABLE ruletest_t2 (a int, b int);+CREATE VIEW ruletest_v1 AS SELECT * FROM ruletest_t1;++CREATE RULE rule1 AS ON INSERT TO ruletest_v1+ DO ALSO INSERT INTO ruletest_t2(b) VALUES (NEW.*);++INSERT INTO ruletest_v1 VALUES (default), (default);++DROP VIEW ruletest_v1;+DROP TABLE ruletest_t1;+DROP TABLE ruletest_t2;
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: japinli@hotmail.com, tgl@sss.pgh.pa.us, guofenglinux@gmail.com, jiye_sw@126.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.
In-Reply-To: <MEYP282MB16690E8D4FCC095086FC9242B6239@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM>
* 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