Re: PQParam version 0.5

From: Andrew Chernow <ac(at)esilo(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-patches(at)postgresql(dot)org
Subject: Re: PQParam version 0.5
Date: 2007-12-05 20:03:02
Message-ID: 475703F6.8060309@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Merlin Moncure wrote:
> On Dec 5, 2007 2:44 PM, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>> Andrew Chernow escribió:
>>
>>> Also changed PQputint8's prototype. Previously, it was using a void* as
>>> the value argument, due to a lack of a portable 64-bit type in libpq. We
>>> found an intersting way around this by using macro and variable argument
>>> tricks.
>> I didn't read the patch, but variadic macros are not portable. FWIW
>> uint64 should "portable" to all platforms that have it (and it should be
>> 32 bits on platforms that don't), but you have to watch for
>> INT64_IS_BUSTED.
>
> we don't use variadic macros...just a macro wrapper to a variadic function.
>
> merlin
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
>

Taken from libpq-fe.h

#define PQputint8(conn, i8) PQputint8v(conn, sizeof(i8), i8)
/* Function subject to change. Do not use directly, see PQputint8. */
extern int PQputint8v(PGconn *conn, size_t valsize, ...);

// goal was pass by value, not by ptr, which was our first solution
PQputint8(conn, 12345678912345LL);

The problem is libpq has no public 64-bit data type to use with the
PQputint8 prototype. But! if we make PQputint8 a macro that wraps a
variadic function, we get around the data type issue.

Since libpq doesn't have a public 64-bit portable data type, we felt
this was done for a good reason. We didn't want to break that convention.

andrew

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Chris Browne 2007-12-05 20:13:48 Re: Better default_statistics_target
Previous Message Merlin Moncure 2007-12-05 19:48:46 Re: PQParam version 0.5