Re: ECPG and COPY - Mailing list pgsql-general

From Michael Fuhr
Subject Re: ECPG and COPY
Date
Msg-id 20060224074319.GA28742@winnie.fuhr.org
Whole thread Raw
In response to ECPG and COPY  (Wes <wespvp@syntegra.com>)
List 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

pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: subtracting minutes from date
Next
From: Michael Meskes
Date:
Subject: Re: ECPG and COPY