Re: COPY statement cannot take binding parameters

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: COPY statement cannot take binding parameters
Дата
Msg-id 9951.1220405020@sss.pgh.pa.us
обсуждение исходный текст
Ответ на COPY statement cannot take binding parameters  ("Stephen R. van den Berg" <srb@cuci.nl>)
Список pgsql-hackers
"Stephen R. van den Berg" <srb@cuci.nl> 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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: What is the use of the CommitFestBlank template?
Следующее
От: "Brendan Jurd"
Дата:
Сообщение: Re: What is the use of the CommitFestBlank template?