Thread: BUG #4947: libpq PQntuples should return 64-bit number

BUG #4947: libpq PQntuples should return 64-bit number

From
"Jim Michaels"
Date:
The following bug has been logged online:

Bug reference:      4947
Logged by:          Jim Michaels
Email address:      jmichae3@yahoo.com
PostgreSQL version: 8.4.0
Operating system:   Win XP Pro Sp3
Description:        libpq PQntuples should return 64-bit number
Details:

I agree that 64-bit numbers are compiler-specific.  this can be overcome
with something like the following code:

although now I understand that the microsoft 2008 compiler implements
UINT128, UINT8, UINT64, UINT32, INT64 and the like, but the MINGW compiler
and BCC++5.5 do not necessarily implement them.

maybe with some #if defined(INT64) the following code could be made proper.
something common to all 32-bit microsoft compilers is the __int64 type.

I suggest using the qlong type.

/*types.h*/
#if !defined(TYPES_LIB_VERSION)
#define TYPES_LIB_VERSION "1.0"

typedef unsigned long dword;
typedef unsigned short word;
typedef unsigned char byte;

#if defined(__DJGPP__)
typedef unsigned long long qword;
typedef long long qlong;
#elif defined(__BORLANDC__)||defined(_MSC_VER) || defined(__MINGW32__)
#include <windows.h>

#if defined(__MINGW32__)
#include <basetsd.h>
#endif

#endif //DJGPP

/*these are kept down here below the #include windows.h on purpose.
__int64 is defined in basetsd.h in MINGW.
*/
#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__GNUC__)

#if !defined(DWORD)
typedef unsigned long DWORD;
#endif

#if !defined(WORD)
typedef unsigned short WORD;
#endif

#if !defined(BYTE)
typedef unsigned char BYTE;
#endif

#endif /*BORLANDC||MSC_VER||GNUC*/

#if defined(__MINGW32__)||defined(_MSC_VER)||defined(__BORLANDC__)

typedef unsigned __int64 qword;
typedef __int64 qlong;

#if !defined(QWORD)
typedef unsigned __int64 QWORD;
#endif

#elif defined(__DJGPP__)

#if !defined(QWORD)
typedef unsigned long long QWORD;
#endif

#endif /*MINGW32*/


#endif

Re: BUG #4947: libpq PQntuples should return 64-bit number

From
Magnus Hagander
Date:
On Tue, Jul 28, 2009 at 08:54, Jim Michaels<jmichae3@yahoo.com> wrote:
>
> The following bug has been logged online:
>
> Bug reference: =A0 =A0 =A04947
> Logged by: =A0 =A0 =A0 =A0 =A0Jim Michaels
> Email address: =A0 =A0 =A0jmichae3@yahoo.com
> PostgreSQL version: 8.4.0
> Operating system: =A0 Win XP Pro Sp3
> Description: =A0 =A0 =A0 =A0libpq PQntuples should return 64-bit number

Why?

Do you have an actual use-case where PQexec() would return more than 2
billion rows, and not have other much more complex issues? For
example, the fact that they all have to be materialized in memory?

Also, this would break compatibility with previous versions, so I
think it would have to be a new function name, like PQntuples64(). But
we'd have to see an actual use-case first...


> I agree that 64-bit numbers are compiler-specific. =A0this can be overcome
> with something like the following code:
>
> although now I understand that the microsoft 2008 compiler implements
> UINT128, UINT8, UINT64, UINT32, INT64 and the like, but the MINGW compiler
> and BCC++5.5 do not necessarily implement them.
>
> maybe with some #if defined(INT64) the following code could be made prope=
r.
> something common to all 32-bit microsoft compilers is the __int64 type.

You seem to be focused on the Windows platform there. There are a
whole lot more platforms needed. But we already have generic types for
64-bit available in our headers, in the form of int64 and uint64.


--=20
 Magnus Hagander
 Self: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/