it's pointed out that our documentation claims the WITH [NO] DATA option
works for all variants of CREATE TABLE AS. But in fact it's only
implemented for the SelectStmt variant, not for the ExecuteStmt variant,
and the ugly kluge used for SelectStmt (paste on a LIMIT 0 at parse
time) isn't going to work for the ExecuteStmt case.
What I'm considering doing to improve this is to add a bool field
"skipData" or some such to IntoClause. By default that would be false,
but the CREATE TABLE AS productions could set it true when they have
WITH NO DATA. Then we'd need to add an execution-time test; the most
expedient way seems to be to add something like this to ExecutorRun:
if (estate->es_select_into &&
direction = NoMovementScanDirection;
which will cause it to skip the ExecutePlan call. In the normal case
this adds just one boolean test to ExecutorRun, so I don't think it
represents a measurable slowdown. The EXECUTE code path needs no
changes since it's just passing the IntoClause through to the executor.
While at it, it occurs to me that we could handle the
IntoClause.colNames option for the ExecuteStmt case if we were to move
the responsibility for plastering on the substitute column names into
the executor's OpenIntoRel, instead of making parse analysis do this
(which is also pretty klugy, see applyColumnNames callers).
Any objections or better ideas?
regards, tom lane
pgsql-hackers by date
|Next:||From: Peter Eisentraut||Date: 2011-11-24 20:01:20|
|Subject: Re: Notes on implementing URI syntax for libpq|
|Previous:||From: Jeff Davis||Date: 2011-11-24 19:01:52|
|Subject: Re: Obstacles to user-defined range canonicalization functions|