Re: [PATCHES] libpq type system 0.9a

From: Andrew Chernow <ac(at)esilo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] libpq type system 0.9a
Date: 2008-04-10 01:14:31
Message-ID: 47FD69F7.20506@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Andrew Chernow wrote:
> Tom Lane wrote:
>>
>> Perhaps we could do a partial exposure, where the exported struct
>> declaration contains "public" fields and there are some "private" ones
>> after that.
>>
>
> I have another idea. It would remove a boat load of members that would
> need to be exposed (may remove them all).
>
> Can we make a variant of PQmakeEmptyPGresult? Maybe something like this:
>
>

Here is a quick implementation demonstrating the idea. It is very similar to
the patches internal dupresult function (handlers/utils.c).

/* numParameters, paramDescs, errFields, curBlock, curOffset and spaceLeft
* are not assigned at all, initialized to zero. errMsg is handled by
* PQmakeEmptyPGresult.
*/
PGresult *PQdupPGresult(
PGconn *conn,
PGresult *source,
int numAttributes,
int ntups)
{
PGresult *r;

if(!source || numAttributes < 0 || ntups < 0)
return NULL;

r = PQmakeEmptyPGresult(conn, source->resultStatus);
if(!r)
return NULL;

r->binary = source->binary;
strcpy(r->cmdStatus, source->cmdStatus);

/* assigned by PQmakeEmptyPGresult when conn is not NULL */
if(!conn)
{
r->noticeHooks = source->noticeHooks;
r->client_encoding = source->client_encoding;
}

r->attDescs = (PGresAttDesc *)
pqResultAlloc(r, numAttributes * sizeof(PGresAttDesc), TRUE);

if(!r->attDescs)
{
PQclear(r);
return NULL;
}

r->numAttributes = numAttributes;

r->tuples = (PGresAttValue **)
malloc(ntups * sizeof(PGresAttValue *));

if(!r->tuples)
{
PQclear(r);
return NULL;
}

r->ntups = ntups;
r->tupArrSize = ntups;

return r;
}

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2008-04-10 01:15:52 Re: Index AM change proposals, redux
Previous Message Andrew Chernow 2008-04-10 00:54:08 Re: [PATCHES] libpq type system 0.9a

Browse pgsql-patches by date

  From Date Subject
Next Message Csaba Nagy 2008-04-10 08:17:32 Re: Concurrent psql API
Previous Message Andrew Chernow 2008-04-10 00:54:08 Re: [PATCHES] libpq type system 0.9a