Re: ECPG and COPY

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Wes <wespvp(at)syntegra(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ECPG and COPY
Date: 2006-02-24 07:43:20
Message-ID: 20060224074319.GA28742@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Feb 23, 2006 at 10:26:35PM -0600, Wes wrote:
> I found this in the archives:
>
> <http://archives.postgresql.org/pgsql-interfaces/2004-04/msg00005.php>
>
> With 8.x, is it still true that with ECPG, it is not possible to use COPY
> inline - I'd have to write the data to a file, then 'COPY FROM filename' (or
> use direct libpq API calls instead of ECPG)?

Looks that way. The ECPGexecute() function in ecpglib/execute.c
has the following code:

case PGRES_COPY_OUT:
ECPGlog("ECPGexecute line %d: Got PGRES_COPY_OUT ... tossing.\n", stmt->lineno);
PQendcopy(stmt->connection->connection);
break;
case PGRES_COPY_IN:
ECPGlog("ECPGexecute line %d: Got PGRES_COPY_IN ... tossing.\n", stmt->lineno);
PQendcopy(stmt->connection->connection);
break;

You can see this code being executed if you enable debugging:

% cat foo.pgc
int
main(void)
{
ECPGdebug(1, stdout);
EXEC SQL CONNECT TO test;
EXEC SQL COPY foo FROM stdin;
EXEC SQL COMMIT;
EXEC SQL DISCONNECT;
return 0;
}

% ./foo
[33044]: ECPGdebug: set to 1
[33044]: ECPGconnect: opening database test on <DEFAULT> port <DEFAULT>
[33044]: ECPGexecute line 6: QUERY: copy foo from stdin on connection test
[33044]: ECPGexecute line 6: Got PGRES_COPY_IN ... tossing.
[33044]: ECPGtrans line 7 action = commit connection = test
[33044]: ecpg_finish: Connection test closed.

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Meskes 2006-02-24 08:14:27 Re: ECPG and COPY
Previous Message Bruno Wolff III 2006-02-24 06:03:35 Re: subtracting minutes from date