Re: Interesting COPY edge case...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris Browne <cbbrowne(at)acm(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Interesting COPY edge case...
Date: 2005-07-28 20:41:27
Message-ID: 28266.1122583287@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chris Browne <cbbrowne(at)acm(dot)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(at)[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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2005-07-28 21:57:10 Re: wal_buffer tests in
Previous Message Tom Lane 2005-07-28 18:42:50 Re: Some new list.c primitives