Skip site navigation (1) Skip section navigation (2)

Re: Array elements (urgent help needed)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Akbar Mokhtarani <akbarm(at)slac(dot)stanford(dot)edu>
Cc: PostgreSQL-interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Array elements (urgent help needed)
Date: 2004-10-04 04:33:10
Message-ID: 12088.1096864390@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-interfaces
Akbar Mokhtarani <akbarm(at)slac(dot)stanford(dot)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

In response to

Responses

pgsql-interfaces by date

Next:From: Oliver D.Date: 2004-10-04 06:01:44
Subject: Re: Win32 libpq : Static Link ?
Previous:From: Akbar MokhtaraniDate: 2004-10-04 04:15:34
Subject: Re: Array elements (urgent help needed)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group