X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6912732A54A for ; Mon, 4 Oct 2004 05:33:23 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63404-06 for ; Mon, 4 Oct 2004 04:33:14 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5DFAD32A549 for ; Mon, 4 Oct 2004 05:33:11 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i944XAaM012089; Mon, 4 Oct 2004 00:33:10 -0400 (EDT) To: Akbar Mokhtarani Cc: PostgreSQL-interfaces Subject: Re: Array elements (urgent help needed) In-reply-to: References: Comments: In-reply-to Akbar Mokhtarani message dated "Sun, 03 Oct 2004 19:58:50 -0700" Date: Mon, 04 Oct 2004 00:33:10 -0400 Message-ID: <12088.1096864390@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/9 X-Sequence-Number: 5104 Akbar Mokhtarani 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