diff options
| author | Noah Misch | 2024-07-13 15:09:33 +0000 |
|---|---|---|
| committer | Noah Misch | 2024-07-13 15:09:33 +0000 |
| commit | d5e6891502ca9e359aa5f5a381d904fe9d606338 (patch) | |
| tree | 4230d43a582c15d733976f20ab33abea44768ebf /src/test | |
| parent | 7102070329d8147246d2791321f9915c3b5abf31 (diff) | |
Fix new assertion for MERGE view_name ... DO NOTHING.
Such queries don't expand automatically updatable views, and ModifyTable
uses the wholerow attribute unconditionally. The user-visible behavior
is fine, so change to more-specific assertions. Commit
d5f788b41dc2cbdde6e7694c70dda54d829a5ed5 added the wrong assertion.
Back-patch to v17, where commit 5f2e179bd31e5f5803005101eb12a8d7bf8db8f3
introduced MERGE view_name.
Reported by Alexander Lakhin.
Discussion: https://postgr.es/m/e4b40a88-c134-6926-3196-bc4501cb87a2@gmail.com
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/updatable_views.out | 5 | ||||
| -rw-r--r-- | src/test/regress/sql/updatable_views.sql | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/test/regress/expected/updatable_views.out b/src/test/regress/expected/updatable_views.out index 9c21b768002..44aba0d1dcb 100644 --- a/src/test/regress/expected/updatable_views.out +++ b/src/test/regress/expected/updatable_views.out @@ -199,6 +199,9 @@ MERGE INTO ro_view13 AS t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a ERROR: cannot insert into view "ro_view13" DETAIL: Views that do not select from a single table or view are not automatically updatable. HINT: To enable inserting into the view using MERGE, provide an INSTEAD OF INSERT trigger. +MERGE INTO ro_view13 AS t USING (VALUES (2, 'Row 2')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DO NOTHING + WHEN NOT MATCHED THEN DO NOTHING; -- should be OK to do nothing MERGE INTO ro_view13 AS t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a WHEN MATCHED THEN DO NOTHING WHEN NOT MATCHED THEN DO NOTHING; -- should be OK to do nothing @@ -375,6 +378,8 @@ DELETE FROM ro_view18; ERROR: cannot delete from view "ro_view18" DETAIL: Views that do not select from a single table or view are not automatically updatable. HINT: To enable deleting from the view, provide an INSTEAD OF DELETE trigger or an unconditional ON DELETE DO INSTEAD rule. +MERGE INTO ro_view18 AS t USING (VALUES (1, 'Row 1')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DO NOTHING; -- should be OK to do nothing UPDATE ro_view19 SET last_value=1000; ERROR: cannot update view "ro_view19" DETAIL: Views that do not select from a single table or view are not automatically updatable. diff --git a/src/test/regress/sql/updatable_views.sql b/src/test/regress/sql/updatable_views.sql index e0ab923d5d1..abfa5574a6e 100644 --- a/src/test/regress/sql/updatable_views.sql +++ b/src/test/regress/sql/updatable_views.sql @@ -68,6 +68,9 @@ MERGE INTO ro_view13 AS t USING (VALUES (2, 'Row 2')) AS v(a,b) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = v.b; MERGE INTO ro_view13 AS t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a WHEN NOT MATCHED THEN INSERT VALUES (v.a, v.b); +MERGE INTO ro_view13 AS t USING (VALUES (2, 'Row 2')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DO NOTHING + WHEN NOT MATCHED THEN DO NOTHING; -- should be OK to do nothing MERGE INTO ro_view13 AS t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a WHEN MATCHED THEN DO NOTHING WHEN NOT MATCHED THEN DO NOTHING; -- should be OK to do nothing @@ -121,6 +124,8 @@ DELETE FROM rw_view16 WHERE a=-3; -- should be OK -- Read-only views INSERT INTO ro_view17 VALUES (3, 'ROW 3'); DELETE FROM ro_view18; +MERGE INTO ro_view18 AS t USING (VALUES (1, 'Row 1')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DO NOTHING; -- should be OK to do nothing UPDATE ro_view19 SET last_value=1000; UPDATE ro_view20 SET b=upper(b); |
