Re: array_agg and libpq(xx)

From: John R Pierce <pierce(at)hogranch(dot)com>
To: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: array_agg and libpq(xx)
Date: 2009-03-19 21:09:06
Message-ID: 49C2B472.30300@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Grzegorz Jaśkiewicz wrote:
> Hi,
>
> Anyone here passed array to C/c++ code via libpq(xx) ??
>

Do you mean, fetching the output of a query like

SELECT ARRAY['123','456','abc','def'];

?

> I need to pass on an array of strings, some of them might contain coma symbol.
> I am wondering, if there's anything already in libpq(xx) that would
> chop value into an array of char* , or will it just return a string
> and it is up to user to chop it.
>

pgResult = PQexec(pgConn, "select array['123','456','abc','def'];");
pgarray = PQgetvalue(pgResult,0,0);

will return a pointer to the ARRAY in postgres format as defined by the
typsend/recieve internal functions for the ARRAY type. you would need
to walk this and copy the strings comprising the array to your own
managed storage (malloc, or whatever) prior to calling
PQclear(pgResult). I'm trying to find the docs on what the typsend
format for ARRAY looks like and failing.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dann Corbit 2009-03-19 21:16:25 Re: Is there a meaningful benchmark?
Previous Message Will Rutherdale (rutherw) 2009-03-19 20:32:01 Is there a meaningful benchmark?