From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | 'missing parameter $1' for sql or pl/pgsql COPY |
Date: | 2009-09-16 20:02:02 |
Message-ID: | b42b73150909161302y3564dc4am28701b4898366f6@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2009-09-16 21:32:39 | Re: BUG #5059: Planner ignores estimates when planning an IN () subquery |
Previous Message | Jeff Davis | 2009-09-16 18:43:36 | Re: strange bug with gist over box and circle |