From: | Tommi Mäkitalo <t(dot)maekitalo(at)epgmbh(dot)de> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: C++: get value for integral types? |
Date: | 2002-11-12 22:23:18 |
Message-ID: | 200211122323.18191.t.maekitalo@epgmbh.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Bjoern Metzdorf | 2002-11-12 23:11:41 | tsearch consistency trigger on inheritated table |
Previous Message | wsheldah | 2002-11-12 22:10:23 | Re: Time manipulation.. |