Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2022-08-12 10:05:50 +0000
committerAlvaro Herrera2022-08-12 10:05:50 +0000
commit92af9143f13df8c54362ebbd4397cb53f207ff2d (patch)
tree910a3a67d8aeb757872f24578c7052a9698fd09f /src/backend/commands/copy.c
parente7a552f303c56788d52ca4e46490236845662734 (diff)
Reject MERGE in CTEs and COPY
The grammar added for MERGE inadvertently made it accepted syntax in places that were not prepared to deal with it -- namely COPY and inside CTEs, but invoking these things with MERGE currently causes assertion failures or weird misbehavior in non-assertion builds. Protect those places by checking for it explicitly until somebody decides to implement it. Reported-by: Alexey Borzov <borz_off@cs.msu.su> Discussion: https://postgr.es/m/17579-82482cd7b267b862@postgresql.org
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r--src/backend/commands/copy.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 3ac731803bd..49924e476af 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -273,6 +273,12 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
{
Assert(stmt->query);
+ /* MERGE is allowed by parser, but unimplemented. Reject for now */
+ if (IsA(stmt->query, MergeStmt))
+ ereport(ERROR,
+ errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("MERGE not supported in COPY"));
+
query = makeNode(RawStmt);
query->stmt = stmt->query;
query->stmt_location = stmt_location;