Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id D290F9FB1CF for ; Tue, 16 Jan 2007 19:36:15 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 20448-09 for ; Tue, 16 Jan 2007 19:35:51 -0400 (AST) X-Greylist: delayed 00:22:38.769157 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id B4E5C9FB1CD for ; Tue, 16 Jan 2007 19:36:00 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from vmx03.prolocation.net (vmx03.prolocation.net [81.23.230.33]) by svr4.postgresql.org (Postfix) with ESMTP id 2E4245AF932 for ; Tue, 16 Jan 2007 23:13:20 +0000 (GMT) Received: from noc.prolocation.net ([81.23.230.64] helo=control.prolocation.net) by vmx03.prolocation.net with esmtp (Exim 4.62) (envelope-from ) id 1H6xUN-0006WC-4H for pgsql-interfaces@postgresql.org; Wed, 17 Jan 2007 00:13:11 +0100 Received: from dop29.nfra.nl ([192.87.1.229]) (SquirrelMail authenticated user usr01873) by control.prolocation.net with HTTP; Wed, 17 Jan 2007 00:13:11 +0100 (CET) Message-ID: <53632.192.87.1.229.1168989191.squirrel@control.prolocation.net> Date: Wed, 17 Jan 2007 00:13:11 +0100 (CET) Subject: Array handling in libpq From: "Joris van Zwieten" To: pgsql-interfaces@postgresql.org Reply-To: vanzwieten@stcorp.nl User-Agent: SquirrelMail/1.5.2 [CVS] MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Prolocation-MailScanner-Information: Please contact helpdesk@prolocation.net for more information X-Prolocation-MailScanner: Found to be clean X-Prolocation-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-4.389, required 5, autolearn=not spam, ALL_TRUSTED -1.80, BAYES_00 -2.60, PROLO_NO_URI 0.01) X-Prolocation-MailScanner-From: vanzwieten@stcorp.nl X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2 tagged_above=0 required=5 tests=BAYES_80 X-Spam-Level: ** X-Archive-Number: 200701/27 X-Sequence-Number: 6405 Hi everyone, I've been using postgres for several projects and I must confess I really like it so far. :-) I hope someone on this list could help me out. Suppose I have a table defined with: CREATE TABLE foo(bar double precision[]); My initial guess was that, as postgres supports arrays, there would probably also be some support for this in libpq (which I'm using via libpqxx by the way). However, from what I've been able to find, it seems that if I use the text format for parameters / results, I would have to: 1. [SEND] Convert the double array on the C(++) side to a '{}' delimited string representation. 2. [RECV] Convert something like '{3.124, 4.5234, 123.123}' to a C(++) array of doubles myself. I hope I overlooked something and there is some support for sending / receiving (parsing) arrays in libpq?? That would be a big help. Still, sending double in ASCII does not seem that efficient. It's not a trivial conversion and it takes more bytes than sending it as binary. However, it seems that using the binary format, I would have to: 1. [SEND] Convert to network byte order Send the array in the format arrayfuncs.c::array_recv() expects, i.e. including the right header (and a length per element as well). 2. [RECV] Parse the header, and convert from byte order Am I missing something here? Or is this just the way it is? (Which is also fine, then at least I know what I'm up against... ;-) Thanks, Joris van Zwieten