Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id A111C9FB1BE for ; Tue, 16 Jan 2007 23:47:01 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 40628-04 for ; Tue, 16 Jan 2007 23:46:17 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from momjian.us (momjian.us [70.90.9.53]) by postgresql.org (Postfix) with ESMTP id 72A1F9FB1A5 for ; Tue, 16 Jan 2007 23:46:17 -0400 (AST) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id l0H3kBd23330; Tue, 16 Jan 2007 22:46:11 -0500 (EST) From: Bruce Momjian Message-Id: <200701170346.l0H3kBd23330@momjian.us> Subject: Re: Array handling in libpq In-Reply-To: <53632.192.87.1.229.1168989191.squirrel@control.prolocation.net> To: vanzwieten@stcorp.nl Date: Tue, 16 Jan 2007 22:46:11 -0500 (EST) CC: pgsql-interfaces@postgresql.org X-Mailer: ELM [version 2.4ME+ PL123] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/28 X-Sequence-Number: 6406 Condsidering all the processing required by the query, the conversion and number of bytes sent over the nework really don't affect performance. --------------------------------------------------------------------------- Joris van Zwieten wrote: > 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 > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq -- Bruce Momjian bruce@momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +