Re: Interesting COPY edge case... - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Interesting COPY edge case...
Date
Msg-id 28266.1122583287@sss.pgh.pa.us
Whole thread Raw
In response to Interesting COPY edge case...  (Chris Browne <cbbrowne@acm.org>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: [Testperf-general] dbt2 & opteron performance
Next
From: "Denis Lussier"
Date:
Subject: MySQL to PostgreSQL for SugarCRM