From: Tom Lane <tgl@sss.pgh.pa.us>
To: Akbar Mokhtarani <akbarm@slac.stanford.edu>
Cc: PostgreSQL-interfaces <pgsql-interfaces@postgresql.org>
Subject: Re: Array elements (urgent help needed)
Date: Mon, 04 Oct 2004 00:33:10 -0400
Message-ID: <12088.1096864390@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.58.0410031950350.32241@noric03.slac.stanford.edu>
References: <Pine.LNX.4.58.0410031950350.32241@noric03.slac.stanford.edu>
Akbar Mokhtarani <akbarm@slac.stanford.edu> writes:
> I am desparate to find a way to access array elements from my c/c++
> program. I have stored int and double data as arrays in my tables and need
> to retrieve them from the database. I use a binary cursor to store the
> query results and PQgetvalue gives me a char* pointer to the storage area
> where the data is stored (this is according to the documentation).
What PG version are you using?
In 7.3 and earlier you have to deal with the server's internal
representation, warts and all. (I think what you're getting burnt by is
failing to account for MAXALIGN alignment, but it's hard to be sure
without more detail.)
7.4 and up have a documented, more or less platform-independent
representation, but it's not necessarily any easier to work with since
you do need to be able to convert to whatever internal representation
you want to use.
In any case, you need to read the server-side source code to see what
you're dealing with. None of these details have made it into the SGML
documentation, but they're covered fairly well in the source comments.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, akbarm@slac.stanford.edu
Subject: Re: Array elements (urgent help needed)
In-Reply-To: <12088.1096864390@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox