Josh Berkus wrote:
Josh is probably basing that on the long history of
discussion/revision cycles.

Yep, and that *I* don't understand what the patch does, so I'm not going to turn a newbie reviewer loose on it.


Here is a quick overview, there are two parts to the patch:

1. event system
This allows one to register "PQregisterEventProc" a per-conn callback function with libpq that gets called when particular events occur. Currently, the events tell you when a conn or result is created, reset, destroyed and copied. It is generic enough to add more events in the future.

By receiving events about libpq objects, you can properly allocate and free userland memory (PQfinish, PQexec, PQclear, etc... trigger events) and associate it with the libpq object: thus PQsetInstanceData(conn...) or PQsetResultInstanceData(res....). This is basically adding members to the opaque PGconn or PGresult during runtime. This "instance data" can be retreived via PQinstanceData and PQresultInstanceData. To shine a different light on it, apps normally wrap a PGconn or PGresult within their own structures, but now you can wrap the app structures inside a PGconn or PGresult.

This may help, its the libpqtypes PGEventProc implementation.
http://libpqtypes.esilo.com/browse_source.html?file=events.c

Also check out the patches sgml docs if you get a chance.


2. result management
There are also four functions that provide more control over PGresult. If you need to create a result from scratch, expands on the PQmakeEmptyPGResult idea.

PQcopyResult - copy a given source result, flags argument determines what portions of the result are copied.

PQsetResultAttrs - sets the attributes of the reuslt (its columns).

PQsetvalue - sets a tuple value in a result

PQresultAlloc - thin wrapper around the internal pqResultAlloc. Uses the result's block allocater, which allows PQclear to properly free all memory assocaited with a PGresult.

--
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