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 49493534B8 for ; Sat, 14 May 2005 15:51:15 -0300 (ADT) 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 35137-07 for ; Sat, 14 May 2005 18:51: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 DBD39531FE for ; Sat, 14 May 2005 15:51:12 -0300 (ADT) 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 j4EIpDU7005158; Sat, 14 May 2005 14:51:13 -0400 (EDT) To: Teunis Peters Cc: pgsql-interfaces@postgresql.org Subject: Re: Two seperate problems with libpq - arrays and bytea edit In-reply-to: <4dc6bdd876380e9a6d8673c5d36c449f@wintersgift.com> References: <4dc6bdd876380e9a6d8673c5d36c449f@wintersgift.com> Comments: In-reply-to Teunis Peters message dated "Sat, 14 May 2005 11:40:10 -0700" Date: Sat, 14 May 2005 14:51:13 -0400 Message-ID: <5157.1116096673@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/36 X-Sequence-Number: 5539 Teunis Peters writes: > I'm trying to figure out how to read from and write to bytea values and > array (specifically "text[2][]" for a key:value 'dictionary') and > cannot figure it out. Well, since you are asking for binary output format from PQexecParams, the bytea result is going to just be raw binary data: you should not be trying to apply PQunescapeBytea to it. I don't know the notation you are using well enough to tell what's wrong with your second variant. > Arrays I'm completely lost - I haven't a clue what the format would be. Looking at array_send, the binary wire format is number of dimensions (int4) flags (int4) element type id (Oid) for each dimension: dimension length (int4) dimension lower subscript bound (int4) for each array element: element value, in the appropriate format The "flags" are currently always 0, and I would recommend punting if you see something else, since something else would very possibly indicate a change in the wire format. Don't forget that the wire format for integers is network byte order (ie, big-endian). regards, tom lane