Re: C-Interface Amound of Tupels in Result after COPYout

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: bert(dot)horvath(at)fh-erfurt(dot)de
Cc: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: C-Interface Amound of Tupels in Result after COPYout
Date: 2007-11-15 16:56:22
Message-ID: 4285.1195145782@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Bert Horvath <bert(dot)horvath(at)fh-erfurt(dot)de> writes:
> Small example:

> create table foo(bar integer);
> insert into foo values(1),(2),(3);

> res = PQexec(conn, "COPY foo TO stdout;");
> if ( PQresultStatus( res ) == PGRES_COPY_OUT )
> {
> printf("RowCount: ");
> printf("%s\n",PQcmdTuples(res)); // this is NULL
> ...

Wrong result --- at that point you've only started the COPY, not
completed it, so how would it know how many rows there are?
You need to look at the PGRES_COMMAND_OK result after the COPY.

regards, tom lane

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Joshua D. Drake 2007-11-15 18:51:51 change to interfaces.html
Previous Message Tom Lane 2007-11-15 16:14:00 Re: C-Interface Amound of Tupels in Result after COPYout