'missing parameter $1' for sql or pl/pgsql COPY
От | Merlin Moncure |
---|---|
Тема | 'missing parameter $1' for sql or pl/pgsql COPY |
Дата | |
Msg-id | b42b73150909161302y3564dc4am28701b4898366f6@mail.gmail.com обсуждение исходный текст |
Список | pgsql-bugs |
The following functions fail: create or replace function docopy(int[]) returns int as $$ copy (select unnest($1)) to stdout; select 0; $$ language sql; ERROR: there is no parameter $1 create or replace function docopy(int[]) returns int as $$ begin copy (select unnest($1)) to stdout; end; $$ language plpgsql; ERROR: SPI_execute_plan failed executing query "copy (select unnest( $1 )) to stdout": SPI_ERROR_COPY this error is expected i guess, plpgsql doesn't support copy to stdout. create or replace function docopy(_stuff int[]) returns int as $$ begin copy (select unnest(_stuff)) to '/tmp/scratch'; end; $$ language plpgsql; ERROR: there is no parameter $1 Also, copy does not allow variable substitution for the destination file. Dynamic sql is one work around, but EXECUTE USING does not work: create or replace function docopy(_stuff int[]) returns int as $$ begin execute 'copy (select unnest($1)) to ''/tmp/scratch''' using _stuff; end; $$ language plpgsql; ERROR: there is no parameter $1 merlin
В списке pgsql-bugs по дате отправления: