Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group