Re: Allow COPY to use parameters

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема Re: Allow COPY to use parameters
Дата
Msg-id 87iny0htrr.fsf@news-spur.riddles.org.uk
обсуждение исходный текст
Ответ на Re: Allow COPY to use parameters  (Merlin Moncure <mmoncure@gmail.com>)
Ответы Re: Allow COPY to use parameters  (Craig Ringer <craig@2ndquadrant.com>)
Список pgsql-hackers
>>>>> "Merlin" == Merlin Moncure <mmoncure@gmail.com> writes:

 Merlin> Note, the biggest pain point I have with COPY is not being able
 Merlin> to parameterize the filename argument.

Second proof of concept attached. This goes so far as to allow
statements like:

do $$
  declare t text := 'bar'; f text := '/tmp/copytest.dat';
  begin copy (select t, now()) to (f) csv header; end;
$$;

Also "copy foo to $1" or "copy (select * from foo where x=$1) to $2" and
so on should work from PQexecParams or in a plpgsql EXECUTE.

(I haven't tried to parameterize anything other than the filename and
query. Also, it does not accept arbitrary expressions - only $n, '...'
or a columnref. $n and '...' can have parens or not, but the columnref
must have them due to conflicts with unreserved keywords PROGRAM, STDIN,
STDOUT. This could be hacked around in other ways, I guess, if the
parens are too ugly.)

--
Andrew (irc:RhodiumToad)


Вложения

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

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: PATCH: pg_restore parallel-execution-deadlock issue
Следующее
От: Kyotaro HORIGUCHI
Дата:
Сообщение: Re: Parallel pg_dump's error reporting doesn't work worth squat