Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2022-10-15 17:24:26 +0000
committerAlvaro Herrera2022-10-15 17:24:26 +0000
commitcba4e78f3599f7edc3fb53d1b094f037fbb8158a (patch)
treee25faddf0e60731a5bda39596a31ccad2728326e /contrib/postgres_fdw
parent1054c604bcdbae5de42beab2f60da7b0067cd4bb (diff)
Disallow MERGE cleanly for foreign partitions
While directly targetting a foreign table with MERGE was already expressly forbidden, we failed to catch the case of a partitioned table that has a foreign table as a partition; and the result if you try is an incomprehensible error. Fix that by adding a specific check. Backpatch to 15. Reported-by: Tatsuhiro Nakamori <bt22nakamorit@oss.nttdata.com> Discussion: https://postgr.es/m/bt22nakamorit@oss.nttdata.com
Diffstat (limited to 'contrib/postgres_fdw')
-rw-r--r--contrib/postgres_fdw/expected/postgres_fdw.out5
-rw-r--r--contrib/postgres_fdw/sql/postgres_fdw.sql4
2 files changed, 9 insertions, 0 deletions
diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out
index 9746998751a..b3c8ce01313 100644
--- a/contrib/postgres_fdw/expected/postgres_fdw.out
+++ b/contrib/postgres_fdw/expected/postgres_fdw.out
@@ -8284,6 +8284,11 @@ select tableoid::regclass, * FROM remp2;
(3 rows)
delete from itrtest;
+-- MERGE ought to fail cleanly
+merge into itrtest using (select 1, 'foo') as source on (true)
+ when matched then do nothing;
+ERROR: cannot execute MERGE on relation "remp1"
+DETAIL: This operation is not supported for foreign tables.
create unique index loct1_idx on loct1 (a);
-- DO NOTHING without an inference specification is supported
insert into itrtest values (1, 'foo') on conflict do nothing returning *;
diff --git a/contrib/postgres_fdw/sql/postgres_fdw.sql b/contrib/postgres_fdw/sql/postgres_fdw.sql
index 1962051e541..b0dbb41fb55 100644
--- a/contrib/postgres_fdw/sql/postgres_fdw.sql
+++ b/contrib/postgres_fdw/sql/postgres_fdw.sql
@@ -2207,6 +2207,10 @@ select tableoid::regclass, * FROM remp2;
delete from itrtest;
+-- MERGE ought to fail cleanly
+merge into itrtest using (select 1, 'foo') as source on (true)
+ when matched then do nothing;
+
create unique index loct1_idx on loct1 (a);
-- DO NOTHING without an inference specification is supported