Hi,

MERGE command does not accept foreign tables as targets.
When a foreign table is specified as a target, it shows error messages like this:

-- ERROR:  cannot execute MERGE on relation "child1"
-- DETAIL:  This operation is not supported for foreign tables.

However, when a partitioned table includes foreign tables as partitions and MERGE is executed on the partitioned table, following error message shows.

-- ERROR:  unexpected operation: 5

The latter error message is unclear, and should be the same as the former one. The attached patch adds the code to display error the former error messages in the latter case.
Any thoughts?

Best,
Tatsuhiro Nakamori
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index d98709e5e8..b4fd54d913 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -1872,6 +1872,9 @@ postgresPlanForeignModify(PlannerInfo *root,
 							 returningList,
 							 &retrieved_attrs);
 			break;
+		case CMD_MERGE:
+			elog(ERROR, "MERGE not permitted on foreign tables");
+			break;
 		default:
 			elog(ERROR, "unexpected operation: %d", (int) operation);
 			break;

Reply via email to