PQntuples returns an int.

Started by Guillaume Yziquelabout 16 years ago4 messagesgeneral
Jump to latest
#1Guillaume Yziquel
guillaume.yziquel@citycable.ch

Hello.

I've been looking at the PQntuples function, in section 29.3.2.
'Retrieving query result information' of

http://www.postgresql.org/docs/8.2/interactive/libpq-exec.html

The declaration is:

int PQntuples(const PGresult *res);

I'm wondering: why the 'int'? why not a 'long int', or an 'unsigned
int', or whatever?

I'm asking this because I'm wondering whether you could have more tuples
in the result of a query than could be indexed by the 'int' type. May
this happen?

All the best,

--
Guillaume Yziquel
http://yziquel.homelinux.org/

#2Steve Atkins
steve@blighty.com
In reply to: Guillaume Yziquel (#1)
Re: PQntuples returns an int.

On Mar 3, 2010, at 10:05 AM, Guillaume Yziquel wrote:

Hello.

I've been looking at the PQntuples function, in section 29.3.2. 'Retrieving query result information' of

http://www.postgresql.org/docs/8.2/interactive/libpq-exec.html

The declaration is:

int PQntuples(const PGresult *res);

I'm wondering: why the 'int'? why not a 'long int', or an 'unsigned int', or whatever?

I'm asking this because I'm wondering whether you could have more tuples in the result of a query than could be indexed by the 'int' type. May this happen?

That's returning the number of tuples you've already retrieved and have in memory on the client.

I'm not sure what the overhead in storage is, but if you have more than two billion tuples in your result set you're probably going to blow out of memory long before you get there (and should be using a cursor instead).

Cheers,
Steve

#3Greg Sabino Mullane
greg@turnstep.com
In reply to: Guillaume Yziquel (#1)
Re: PQntuples returns an int.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

I'm asking this because I'm wondering whether you could have more tuples
in the result of a query than could be indexed by the 'int' type. May
this happen?

Yes, but it's a low concern as many other things would break before
you got to that point. See:

http://groups.google.com/group/pgsql.general/browse_thread/thread/462c454345221267/f61926526b539036
or:
http://5z8.info/super-nsfw_cyd

- --
Greg Sabino Mullane greg@turnstep.com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201003031555
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkuOz1cACgkQvJuQZxSWSsge+wCg0Wmo/YyEkymE7Y1FILtRoO3J
CDQAn36Gs8Si37YdeheaM6v2JiU+EPOz
=e+3U
-----END PGP SIGNATURE-----

#4Guillaume Yziquel
guillaume.yziquel@citycable.ch
In reply to: Greg Sabino Mullane (#3)
Re: PQntuples returns an int.

Greg Sabino Mullane a écrit :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

I'm asking this because I'm wondering whether you could have more tuples
in the result of a query than could be indexed by the 'int' type. May
this happen?

Yes, but it's a low concern as many other things would break before
you got to that point. See:

http://groups.google.com/group/pgsql.general/browse_thread/thread/462c454345221267/f61926526b539036
or:
http://5z8.info/super-nsfw_cyd

Thank you.

Indeed, I perfectly do believe you when you state that many things would
break before.

It's much more a typing issue in a strongly typed language (OCaml).

Thanks again.

Guillaume Yziquel.
--
Guillaume Yziquel
http://yziquel.homelinux.org/