Chris Browne <cbbrowne@acm.org> writes:
> create or replace function build_table (integer) returns integer as '
> begin
> execute ''copy foo to stdout;'';
> return 1;
> end' language plpgsql;
> The result:
> /* cbbrowne@[local]/dba2 in=*/ select try_copy(1);
> ERROR: unexpected error -2 in EXECUTE of query "copy dups to stdout;"
> CONTEXT: PL/pgSQL function "try_copy" line 2 at execute statement
In CVS tip I get
ERROR: cannot COPY to/from client in PL/pgSQL
CONTEXT: PL/pgSQL function "build_table" line 2 at execute statement
There are some protocol-level reasons for not supporting this, IIRC.
You're already inside a SELECT and the client library would probably
get terribly confused.
regards, tom lane