pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
C-Interface Amound of Tupels in Result after COPYout
5+ messages / 2 participants
[nested] [flat]

* C-Interface Amound of Tupels in Result after COPYout
@ 2007-11-15 12:15  Bert Horvath <bert.horvath@fh-erfurt.de>
  0 siblings, 1 reply; 5+ messages in thread

From: Bert Horvath @ 2007-11-15 12:15 UTC (permalink / raw)
  To: pgsql-interfaces

Hi,

do i have any chance to get the amount of tupels in the result set after 
   executing a query with a copy command? Its not a problem to count the 
columns with PQnFields(*conn,*result) but there is no documentation für 
PQnTupels(*conn,*result) and it does not work.

greetings
beho




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: C-Interface Amound of Tupels in Result after COPYout
@ 2007-11-15 15:27  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Bert Horvath <bert.horvath@fh-erfurt.de>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2007-11-15 15:27 UTC (permalink / raw)
  To: bert.horvath@fh-erfurt.de; +Cc: pgsql-interfaces

Bert Horvath <bert.horvath@fh-erfurt.de> writes:
> do i have any chance to get the amount of tupels in the result set after 
>    executing a query with a copy command? Its not a problem to count the 
> columns with PQnFields(*conn,*result) but there is no documentation für 
> PQnTupels(*conn,*result) and it does not work.

PQcmdTuples.  PQnTuples is for the number of rows actually returned to
the client by a SELECT.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: C-Interface Amound of Tupels in Result after COPYout
@ 2007-11-15 15:36  Bert Horvath <bert.horvath@fh-erfurt.de>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Bert Horvath @ 2007-11-15 15:36 UTC (permalink / raw)
  To: pgsql-interfaces

i have allready tryed out this it allways returns 0...

Tom Lane schrieb:
> Bert Horvath <bert.horvath@fh-erfurt.de> writes:
>> do i have any chance to get the amount of tupels in the result set after 
>>    executing a query with a copy command? Its not a problem to count the 
>> columns with PQnFields(*conn,*result) but there is no documentation für 
>> PQnTupels(*conn,*result) and it does not work.
> 
> PQcmdTuples.  PQnTuples is for the number of rows actually returned to
> the client by a SELECT.
> 
> 			regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
> 

-- 
Bert Horvath
MSc Angewandte Informatik
FB Gebäudetechnik und Informatik
wissenschaftlicher Mitarbeiter, Projekt MoSDeP

Fachhochschule Erfurt - University of Applied Sciences
Altonaer Str. 25, D-99085 Erfurt (Haus 10, Raum 10.01.09)
Tel: +49 361 / 6700 - 393
Fax: +49 361 / 6700 - 8960
E-Mail: bert.horvath@fh-erfurt.de




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: C-Interface Amound of Tupels in Result after COPYout
@ 2007-11-15 16:14  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Bert Horvath <bert.horvath@fh-erfurt.de>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2007-11-15 16:14 UTC (permalink / raw)
  To: bert.horvath@fh-erfurt.de; +Cc: pgsql-interfaces

Bert Horvath <bert.horvath@fh-erfurt.de> writes:
> Tom Lane schrieb:
>> PQcmdTuples.  PQnTuples is for the number of rows actually returned to
>> the client by a SELECT.

> i have allready tryed out this it allways returns 0...

Try a more recent release.

[ checks code... ]  Looks like the count was added to COPY's command
status in 8.2.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: C-Interface Amound of Tupels in Result after COPYout
@ 2007-11-15 16:56  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2007-11-15 16:56 UTC (permalink / raw)
  To: bert.horvath@fh-erfurt.de; +Cc: pgsql-interfaces

Bert Horvath <bert.horvath@fh-erfurt.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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2007-11-15 16:56 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-11-15 12:15 C-Interface Amound of Tupels in Result after COPYout Bert Horvath <bert.horvath@fh-erfurt.de>
2007-11-15 15:27 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-11-15 15:36   ` Bert Horvath <bert.horvath@fh-erfurt.de>
2007-11-15 16:14     ` Tom Lane <tgl@sss.pgh.pa.us>
2007-11-15 16:56       ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox