On Thu, Nov 19, 2026 at 5:52 PM Zsolt Parragi <[email protected]> wrote:
> Hello > > CREATE TABLE AS EXECUTE only accepts a prepared SELECT, rejecting > anything else with "prepared statement is not a SELECT". EXPLAIN > ANALYZE doesn't have the same check, so it runs whatever the prepared > statement is. > Confirmed on current master. EXPLAIN ANALYZE CREATE TABLE AS EXECUTE ins inserts into src and creates t2 from the RETURNING row, while CREATE TABLE AS EXECUTE ins is correctly rejected. Plain EXPLAIN shows the Insert plan. v1 adds the same check ExecuteQuery() already uses... if there's an INTO clause the prepared plan list must be a single CMD_SELECT. I applied it and retried the same cases; they now all fail with "prepared statement is not a SELECT", and the INSERT is not executed. A prepared SELECT still works with CREATE TABLE AS EXECUTE, with or without EXPLAIN ANALYZE. The new select_into tests pass, as do the rest of the regular regression tests. This is just closing the EXPLAIN hole, which seems right. The comment in ExecuteQuery() still leaves INSERT ... RETURNING as a separate question. LGTM. Roberto > >
