Re: C++: get value for integral types? - Mailing list pgsql-general

From Tommi Mäkitalo
Subject Re: C++: get value for integral types?
Date
Msg-id 200211122323.18191.t.maekitalo@epgmbh.de
Whole thread Raw
In response to Re: C++: get value for integral types?  (Vassil Kriakov <vassilk@yahoo.com>)
List pgsql-general
Hi,


Am Dienstag, 12. November 2002 18:27 schrieb Vassil Kriakov:
> If you declared a binary cursor (see example prog in postgresql tech
> doc. in libpq section), PQgetvalue() will return the "internal backend
> server binary representation" of the value you are getting. So if you
> were getting something that's an int, PQgetvalue() will return pointer
> to memory where your int is in binary format.
>
> Hoping that the backend server's way of storing int, float, bool, etc.
> is the same as at the client-end, you can re-interpret the char* to a
> float* or int*, etc.
>
That's exactly the problem. What if you have different platforms at server-end
and client-end? You can't reliable convert a char* to int* or even worse to
float*. The better way is to improve the interface to get some usable
typedata and an accessorfunction for int, long, double, bool...

There is a thread in pgsql-hackers about "protocol change in 7.4", which talks
about it.

I feel that using ascii-data is the most robust and portable way.


Tommi


pgsql-general by date:

Previous
From: wsheldah@lexmark.com
Date:
Subject: Re: Time manipulation..
Next
From: "Bjoern Metzdorf"
Date:
Subject: tsearch consistency trigger on inheritated table