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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

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: Thu, 15 Nov 2007 11:56:22 -0500
  • Message-id: <4285.1195145782@sss.pgh.pa.us> <text/plain>

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



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group