Use quoted column names in targetlist of subquery substituting modified table

Fix a bug introduced by 5b8b2f0, which built targetlist of subquery substituting
modified table. When a table has a column whose name includes a capital letter,
incremental view maintenance failed because crafted targetlist contains incorrect
column name which was parsed as lower case.

Isseu #124
This commit is contained in:
Yugo Nagata 2025-03-25 03:10:41 +09:00
parent eab5195be5
commit 78941053f5
3 changed files with 24 additions and 1 deletions

View file

@ -81,6 +81,21 @@ SELECT * FROM mv_ivm_1 ORDER BY 1,2,3;
4 | 40 | 104
(4 rows)
-- test for renaming column name to camel style
BEGIN;
ALTER TABLE mv_base_a RENAME i TO "I";
ALTER TABLE mv_base_a RENAME j TO "J";
UPDATE mv_base_a SET "J" = 0 WHERE "I" = 1;
SELECT * FROM mv_ivm_1 ORDER BY 1,2,3;
i | j | k
---+----+-----
1 | 0 | 101
2 | 20 | 102
3 | 30 | 103
4 | 40 | 104
(4 rows)
ROLLBACK;
-- TRUNCATE a base table in join views
BEGIN;
TRUNCATE mv_base_a;

View file

@ -1612,7 +1612,7 @@ make_subquery_targetlist_from_table(MV_TriggerTable *table)
if (attr->attisdropped)
appendStringInfo(&str, "null");
else
appendStringInfo(&str, "%s", NameStr(attr->attname));
appendStringInfo(&str, "%s", quote_identifier(NameStr(attr->attname)));
}
return str.data;

View file

@ -37,6 +37,14 @@ SELECT * FROM mv_ivm_1 ORDER BY 1,2,3;
ROLLBACK;
SELECT * FROM mv_ivm_1 ORDER BY 1,2,3;
-- test for renaming column name to camel style
BEGIN;
ALTER TABLE mv_base_a RENAME i TO "I";
ALTER TABLE mv_base_a RENAME j TO "J";
UPDATE mv_base_a SET "J" = 0 WHERE "I" = 1;
SELECT * FROM mv_ivm_1 ORDER BY 1,2,3;
ROLLBACK;
-- TRUNCATE a base table in join views
BEGIN;
TRUNCATE mv_base_a;