Call ErrorIfMergeInCopy only if Citus tables are involved, fix tests

pull/7781/head
naisila 2024-12-19 13:13:27 +03:00
parent 3db76fdc8f
commit 4e6b62fee8
4 changed files with 9 additions and 15 deletions

View File

@ -2842,6 +2842,11 @@ ErrorIfMergeInCopy(CopyStmt *copyStatement)
#else
if (!copyStatement->relation && (IsA(copyStatement->query, MergeStmt)))
{
/*
* This path is currently not reachable because Merge in COPY can
* only work with a RETURNING clause, and a RETURNING check
* will error out sooner for Citus
*/
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("MERGE with Citus tables "
"is not yet supported in COPY")));
@ -2860,8 +2865,6 @@ Node *
ProcessCopyStmt(CopyStmt *copyStatement, QueryCompletion *completionTag, const
char *queryString)
{
ErrorIfMergeInCopy(copyStatement);
/*
* Handle special COPY "resultid" FROM STDIN WITH (format result) commands
* for sending intermediate results to workers.
@ -2889,6 +2892,8 @@ ProcessCopyStmt(CopyStmt *copyStatement, QueryCompletion *completionTag, const
*/
if (copyStatement->relation != NULL)
{
ErrorIfMergeInCopy(copyStatement);
bool isFrom = copyStatement->is_from;
/* consider using RangeVarGetRelidExtended to check perms before locking */

View File

@ -40,7 +40,7 @@ COPY (
MERGE INTO target USING source ON (true)
WHEN MATCHED THEN DELETE
) TO stdout;
ERROR: MERGE with Citus tables is not yet supported in COPY
ERROR: COPY query must have a RETURNING clause
-- used in a CTE with RETURNING
WITH foo AS (
MERGE INTO target USING source ON (true)
@ -52,7 +52,7 @@ COPY (
MERGE INTO target USING source ON (true)
WHEN MATCHED THEN DELETE RETURNING target.*
) TO stdout;
ERROR: MERGE with Citus tables is not yet supported in COPY
ERROR: MERGE with RETURNING is not yet supported for Citus tables
-- unsupported relation types
-- view
CREATE VIEW tv AS SELECT count(tid) AS tid FROM target;

View File

@ -162,12 +162,6 @@ ON tid = tid
WHEN MATCHED THEN DO NOTHING;
ERROR: name "target" specified more than once
DETAIL: The name is used both as MERGE target table and data source.
-- used in COPY
COPY (
MERGE INTO target USING source ON (true)
WHEN MATCHED THEN DELETE
) TO stdout;
ERROR: MERGE with Citus tables is not yet supported in COPY
-- unsupported relation types
-- materialized view
CREATE MATERIALIZED VIEW mv AS SELECT * FROM target;

View File

@ -116,11 +116,6 @@ MERGE INTO target
USING target
ON tid = tid
WHEN MATCHED THEN DO NOTHING;
-- used in COPY
COPY (
MERGE INTO target USING source ON (true)
WHEN MATCHED THEN DELETE
) TO stdout;
-- unsupported relation types
-- materialized view