Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.

Поиск
Список
Период
Сортировка
От Japin Li
Тема Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.
Дата
Msg-id MEYP282MB16690E8D4FCC095086FC9242B6239@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
обсуждение исходный текст
Ответ на Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
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.

diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 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.sql
index 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;

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

Предыдущее
От: "Blum, Kimber"
Дата:
Сообщение: RE: BUG #17634: Inconsistent view_definition in information_schema.views
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #17635: The behavior of quote_ident differs from what the doc specifies