Produce the right error message for COPY (SELECT INTO) queries, that is
ERROR: COPY (SELECT INTO) is not supported
instead of the incorrect
ERROR: COPY query must have a RETURNING clause
The root cause is that the check in BeginCopy() was testing raw_query,
but XL wraps the original command in RawStmt, so we should be checking
raw_query->stmt instead.
* will ultimately lead to an error, but doing it here allows us to
* throw a more friendly and PG-compatible error.
*/
- if (IsA(raw_query, SelectStmt))
+ if (IsA(raw_query->stmt, SelectStmt))
{
- SelectStmt *stmt = (SelectStmt *) raw_query;
+ SelectStmt *stmt = (SelectStmt *) raw_query->stmt;
/*
* If it's a set-operation tree, drilldown to leftmost SelectStmt