"Stephen R. van den Berg" <[EMAIL PROTECTED]> writes:
> Trying to parse and bind the following:
>    COPY (SELECT $1::INT) TO STDOUT
> gives a correct parsing-done, but then in the parameterdescription tells
> me that there are no parameters.

> Is this intended?

It's an artifact of the klugy way that SELECT was shoehorned into COPY :-(.
The SELECT isn't actually parsed/planned until execution time, so there
is no opportunity even to notice that it contains parameter symbols,
much less identify their types.  If you experiment you'll soon see that
any but the most basic syntactical errors in the SELECT aren't reported
at Parse-message time.

It might be possible to fix that by inverting the structure of the
statement internally, turning it into something approximating

        SELECT ... INTO <copy parameters here> FROM ...

where IntoClause or some equivalent is made to carry everything from the
outer COPY syntax.  Don't hold your breath though.  (I think the parser
changes would actually be pretty trivial, but it might take some major
refactoring of the COPY code to let it be driven entirely as a tuple
receiver.)

                        regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to