1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

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
This commit is contained in:
Alvaro Herrera
2022-08-12 12:05:50 +02:00
parent e1878cf941
commit 455d254d22
4 changed files with 37 additions and 0 deletions

View File

@ -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;