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/

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to