Re: [PATCHES] libpq object hooks (libpq events)

2008-05-20 Thread Merlin Moncure
On Mon, May 19, 2008 at 8:22 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > Andrew Chernow <[EMAIL PROTECTED]> writes: >> Here is an updated patch for what was called object hooks. This is now >> called libpq events. If someone has a better name or hates ours, let us >> know. > > This is starting to g

Re: [PATCHES] libpq object hooks (libpq events)

2008-05-19 Thread Andrew Chernow
Attached is the latest patch. It has addressed the requested changes found here: http://archives.postgresql.org/pgsql-patches/2008-05/msg00389.php Its a tarball because there are two new files, libpq-events.c and libpq-events.h. The patch is in the tarball as well as attached to the email.

Re: [PATCHES] libpq object hooks (libpq events)

2008-05-19 Thread Andrew Chernow
Tom Lane wrote: Andrew Chernow <[EMAIL PROTECTED]> writes: 4. add a setter for result instance data - There should also be a PQsetInstanceData(PGconn*, ...) - I see no need for a passThrough setter Check, though I assume we're not expecting PQsetInstanceData to propagate to previously cr

Re: [PATCHES] libpq object hooks (libpq events)

2008-05-19 Thread Merlin Moncure
On Mon, May 19, 2008 at 10:37 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > Andrew Chernow <[EMAIL PROTECTED]> writes: >> 4. add a setter for result instance data >>- There should also be a PQsetInstanceData(PGconn*, ...) >>- I see no need for a passThrough setter > > Check, though I assume we'

Re: [PATCHES] libpq object hooks (libpq events)

2008-05-19 Thread Tom Lane
Andrew Chernow <[EMAIL PROTECTED]> writes: > 4. add a setter for result instance data >- There should also be a PQsetInstanceData(PGconn*, ...) >- I see no need for a passThrough setter Check, though I assume we're not expecting PQsetInstanceData to propagate to previously created PGresult

Re: [PATCHES] libpq object hooks (libpq events)

2008-05-19 Thread Andrew Chernow
Will make all of those changes. We appreciate the help. 1. remove global registration :( 2. New Name: PGCallback 3. use instanceData and passThrough names (passThrough with upper 'T') 3. separate getters for conn/result instanceData and passthrough 4. add a setter for result instance data

Re: [PATCHES] libpq object hooks (libpq events)

2008-05-19 Thread Tom Lane
Andrew Chernow <[EMAIL PROTECTED]> writes: > Here is an updated patch for what was called object hooks. This is now > called libpq events. If someone has a better name or hates ours, let us > know. This is starting to get there, though I am still desperately unhappy with the notion of "global"

Re: [PATCHES] libpq object hooks (libpq events)

2008-05-18 Thread Andrew Chernow
Merlin Moncure wrote: On Sat, May 17, 2008 at 8:28 AM, Andrew Chernow <[EMAIL PROTECTED]> wrote: Here is an updated patch for what was called object hooks. This is now called libpq events. If someone has a better name or hates ours, let us know. Let's decide where to go with this. We have

Re: [PATCHES] libpq object hooks (libpq events)

2008-05-18 Thread Merlin Moncure
On Sat, May 17, 2008 at 8:28 AM, Andrew Chernow <[EMAIL PROTECTED]> wrote: > Here is an updated patch for what was called object hooks. This is now > called libpq events. If someone has a better name or hates ours, let us > know. Let's decide where to go with this. We have no objections to pus

Re: [PATCHES] libpq object hooks (libpq events)

2008-05-17 Thread Andrew Chernow
Here is an updated patch for what was called object hooks. This is now called libpq events. If someone has a better name or hates ours, let us know. I am continuing to use the object hooks thread to avoid confusing anyone. Terminology: I got rid of calling it object events because it is poss

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Andrew Chernow
Tom Lane wrote: ISTM the hook ought to be able to request that libpq return an out-of-memory failure for the query, just as would happen if the malloc failure had happened directly to libpq. I am working on this new patch and that is how I have been implementing it. If the eventProc functi

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Tom Lane
"Merlin Moncure" <[EMAIL PROTECTED]> writes: > On Fri, May 16, 2008 at 4:23 PM, Tom Lane <[EMAIL PROTECTED]> wrote: >> So you're imagining that on creation of a PGconn or PGresult, the >> hook function would be allowed to create some storage and libpq would >> then be responsible for tracking that

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Andrew Chernow
Tom Lane wrote: Where exactly does the hook hand off the storage pointer to libpq? What are you going to do if the hook fails to create the storage (ie, out of memory during PGresult creation)? The current submitted patch has 3 of its function callbacks returning a void*, initHookData after t

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Merlin Moncure
On Fri, May 16, 2008 at 4:23 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > "Merlin Moncure" <[EMAIL PROTECTED]> writes: >> Right. I actually overlooked the 'passthrough' in >> PQregisterEventProc. It turns out that we are still not quite on the >> same page and this needs to be clarified before we mo

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Tom Lane
"Merlin Moncure" <[EMAIL PROTECTED]> writes: > Right. I actually overlooked the 'passthrough' in > PQregisterEventProc. It turns out that we are still not quite on the > same page and this needs to be clarified before we move on. The > passthrough cannot exist... Yes, it *will* exist. You are

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Merlin Moncure
On Fri, May 16, 2008 at 3:49 PM, Merlin Moncure <[EMAIL PROTECTED]> wrote: > On Fri, May 16, 2008 at 2:34 PM, Andrew Chernow <[EMAIL PROTECTED]> wrote: >> Tom Lane wrote: >>> >>> typedef void (*PGeventProc) (PGeventId eventId, const void *eventInfo, >>> void *passthrough

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Merlin Moncure
On Fri, May 16, 2008 at 2:34 PM, Andrew Chernow <[EMAIL PROTECTED]> wrote: > Tom Lane wrote: >> >> typedef void (*PGeventProc) (PGeventId eventId, const void *eventInfo, >> void *passthrough); >> >> int PQregisterEventProc(PGconn *conn, PGeventProc proc, void >> *passthr

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Andrew Chernow
Tom Lane wrote: typedef void (*PGeventProc) (PGeventId eventId, const void *eventInfo, void *passthrough); int PQregisterEventProc(PGconn *conn, PGeventProc proc, void *passthrough); The above prototypes will work and we will add our 'event instance pointer' t

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Andrew Dunstan
Tom Lane wrote: Andrew Dunstan <[EMAIL PROTECTED]> writes: All of this is getting quite a long way from what was in the commitfest queue. Do we still want to try to get this in this cycle, or should it be marked returned to author for more work? So far I think it still falls within

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Merlin Moncure
On Fri, May 16, 2008 at 11:21 AM, Andrew Dunstan <[EMAIL PROTECTED]> wrote: > All of this is getting quite a long way from what was in the commitfest > queue. Do we still want to try to get this in this cycle, or should it be > marked returned to author for more work? That's your call...we can hav

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Alvaro Herrera
Andrew Dunstan escribió: > All of this is getting quite a long way from what was in the commitfest > queue. Do we still want to try to get this in this cycle, or should it > be marked returned to author for more work? There are still patches open for which no discussion has even started, so I

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Tom Lane
Andrew Dunstan <[EMAIL PROTECTED]> writes: > All of this is getting quite a long way from what was in the commitfest > queue. Do we still want to try to get this in this cycle, or should it > be marked returned to author for more work? So far I think it still falls within the category of allowin

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Tom Lane
"Merlin Moncure" <[EMAIL PROTECTED]> writes: > Switch, plus struct (basically a union) will do the trick nicely. Can > it be a formal union, or is it better as a void*? I don't think a union buys much notational convenience or safety here, although admittedly it's a close question. In one case y

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Andrew Dunstan
Merlin Moncure wrote: Also, even if varargs are safe they'd be notationally unpleasant in the extreme. varargs are just a PITA to work with --- you'd have to do all the decoding in the first-level hook routine, even for items you weren't going to use. With something like the above all you

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Merlin Moncure
On Fri, May 16, 2008 at 10:59 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > "Merlin Moncure" <[EMAIL PROTECTED]> writes: >>> typedef void *(*PGobjectEventProc)(PGobjectEventId evtId, ...); >>> int PQregisterObjectEventProc(PGconn*, PGobjectEventProc); >>> void *PQeventData(PGconn *, PGobjectEventProc);

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Tom Lane
"Merlin Moncure" <[EMAIL PROTECTED]> writes: >> typedef void *(*PGobjectEventProc)(PGobjectEventId evtId, ...); >> int PQregisterObjectEventProc(PGconn*, PGobjectEventProc); >> void *PQeventData(PGconn *, PGobjectEventProc); >> void *PQresultEventData(PGresult *, PGobjectEventProc); > This provide

Re: [PATCHES] libpq object hooks

2008-05-16 Thread Merlin Moncure
On Thu, May 15, 2008 at 8:38 PM, Andrew Chernow <[EMAIL PROTECTED]> wrote: > We need to add members to a conn and result, that's pretty much it. To do > this, an api user can register callbacks to receive notifications about > created/destroyed states of objects. PQhookData is just like PQerrorMe

Re: [PATCHES] libpq object hooks

2008-05-15 Thread Andrew Chernow
Tom Lane wrote: Andrew Chernow <[EMAIL PROTECTED]> writes: Which callback do we use as the key? Currently, none are required (only the name was required). We have to choose one callback that must be provided. What? I thought what you wanted back was the void * pointer that had been registe

Re: [PATCHES] libpq object hooks

2008-05-15 Thread Andrew Chernow
Tom Lane wrote: Andrew Chernow <[EMAIL PROTECTED]> writes: Which callback do we use as the key? Currently, none are required (only the name was required). We have to choose one callback that must be provided. What? I thought what you wanted back was the void * pointer that had been registe

Re: [PATCHES] libpq object hooks

2008-05-15 Thread Tom Lane
Andrew Chernow <[EMAIL PROTECTED]> writes: > Which callback do we use as the key? Currently, none are required (only > the name was required). We have to choose one callback that must be > provided. What? I thought what you wanted back was the void * pointer that had been registered with a pa

Re: [PATCHES] libpq object hooks

2008-05-15 Thread Andrew Chernow
Tom Lane wrote: Andrew Chernow <[EMAIL PROTECTED]> writes: There can be cases to use the same callbacks, although unlikely. To completely avoid collisions, the below would work: Still looks like overdesign to me. If we use the hook function address we solve the problem with no extra notation

Re: [PATCHES] libpq object hooks

2008-05-15 Thread Tom Lane
Andrew Chernow <[EMAIL PROTECTED]> writes: > There can be cases to use the same callbacks, although unlikely. To > completely avoid collisions, the below would work: Still looks like overdesign to me. If we use the hook function address we solve the problem with no extra notation and no extra s

Re: [PATCHES] libpq object hooks

2008-05-15 Thread Tom Lane
Andrew Dunstan <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> It might work to use the address of the hook callback function as >> a key for retrieving the associated void * pointer. You'd need to >> not register the same callback function more than once per object, >> but from what I gather her

Re: [PATCHES] libpq object hooks

2008-05-15 Thread Andrew Chernow
Andrew Dunstan wrote: Tom Lane wrote: It might work to use the address of the hook callback function as a key for retrieving the associated void * pointer. You'd need to not register the same callback function more than once per object, but from what I gather here you don't need to.

Re: [PATCHES] libpq object hooks

2008-05-15 Thread Andrew Chernow
Tom Lane wrote: "Merlin Moncure" <[EMAIL PROTECTED]> writes: The problem is the functions PQhookData(conn, hookname) and PQresultHookData(result, hookName). We need these to work in functions that are not callbacks. If we eliminate hookname completely, there is no way for libpq to know which p

Re: [PATCHES] libpq object hooks

2008-05-15 Thread Andrew Dunstan
Tom Lane wrote: "Merlin Moncure" <[EMAIL PROTECTED]> writes: The problem is the functions PQhookData(conn, hookname) and PQresultHookData(result, hookName). We need these to work in functions that are not callbacks. If we eliminate hookname completely, there is no way for libpq to know wh

Re: [PATCHES] libpq object hooks

2008-05-15 Thread Tom Lane
"Merlin Moncure" <[EMAIL PROTECTED]> writes: > The problem is the functions PQhookData(conn, hookname) and > PQresultHookData(result, hookName). We need these to work in > functions that are not callbacks. If we eliminate hookname > completely, there is no way for libpq to know which private stat

Re: [PATCHES] libpq object hooks

2008-05-15 Thread Merlin Moncure
On Wed, May 14, 2008 at 10:44 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > I'm wondering why the hooks need names at all. AFAICS all that > libpq needs to know about a hook is a callback function address > and a void * passthrough pointer. I'm trying to make this work as you suggest. It's pretty cl

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Merlin Moncure
On Wed, May 14, 2008 at 3:47 PM, daveg <[EMAIL PROTECTED]> wrote: > On Wed, May 14, 2008 at 10:52:43AM -0400, Bruce Momjian wrote: >> >> One idea would be to add the libpq hooks but not document them. This >> way, we can modify or remove the API as needed in the future. As >> libpqtypes matures a

Re: [PATCHES] libpq object hooks

2008-05-14 Thread daveg
On Wed, May 14, 2008 at 10:52:43AM -0400, Bruce Momjian wrote: > > One idea would be to add the libpq hooks but not document them. This > way, we can modify or remove the API as needed in the future. As > libpqtypes matures and we are sure what the API should be, we can > document it as stable a

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Andrew Chernow
Attached is an updated patch. The only change to this patch is that hookNames are now compared with strcmp rather than strcasecmp. The comparisons occur in fe-mics.c (bottom of file) during PQhookData and PQresultHookData. Not sure this needs clarification, but PQcopyResult, PQresultAlloc an

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Andrew Chernow
Merlin Moncure wrote: On Wed, May 14, 2008 at 10:44 AM, Tom Lane <[EMAIL PROTECTED]> wrote: I'm wondering why the hooks need names at all. AFAICS all that libpq needs to know about a hook is a callback function address and a void * passthrough pointer. For reference...here is what libpqtypes

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Merlin Moncure
On Wed, May 14, 2008 at 10:44 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > I'm wondering why the hooks need names at all. AFAICS all that > libpq needs to know about a hook is a callback function address > and a void * passthrough pointer. For reference...here is what libpqtypes has to do to bind vi

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Andrew Chernow
I'm wondering why the hooks need names at all. AFAICS all that libpq needs to know about a hook is a callback function address and a void * passthrough pointer. In question is: + void * + PQhookData(const PGconn *conn, const char *hookName) Basically, libpqtypes has various functions that tak

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Merlin Moncure
On Wed, May 14, 2008 at 10:52 AM, Bruce Momjian <[EMAIL PROTECTED]> wrote: > Merlin Moncure wrote: >> Regarding the other comments: >> *) API structure: Our major objective was to minimize exports to >> libpq. I think both copyresult and setvalue have some possible >> sideband usage (footguns or n

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Merlin Moncure
On Wed, May 14, 2008 at 10:44 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > No, they could revise their patch to be more stylistically in keeping > with libpq. I haven't looked at the current version of the patch yet, > but the early versions seemed quite overengineered to me, so your > criticism didn

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Bruce Momjian
Merlin Moncure wrote: > Regarding the other comments: > *) API structure: Our major objective was to minimize exports to > libpq. I think both copyresult and setvalue have some possible > sideband usage (footguns or no). Additional functions could be > speculated but are not required by libpqtype

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Merlin Moncure
On Tue, May 13, 2008 at 11:52 PM, Bruce Momjian <[EMAIL PROTECTED]> wrote: > My personal opinion is still that I would like to see a more general > usefulness for these functions before adding them to libpq. The > complexity of the API just mirrors my gut feeling on this. There has been a lot of

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Tom Lane
Andrew Dunstan <[EMAIL PROTECTED]> writes: > It should be noted that while this feels slightly foreign, it isn't > hugely invasive, unlike the previous effort - it's only a few hundred > lines of new code. > If we reject this, presumably the authors will have no alternative than > to offer libp

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Merlin Moncure
On Wed, May 14, 2008 at 8:18 AM, Andrew Dunstan <[EMAIL PROTECTED]> wrote: > Right, it was more the case insensitive part that bothered me. Done. We in fact had realized this was a mistake anyways following some profiling of the libpqtypes library. In some scenarios, this function gets called a l

Re: [PATCHES] libpq object hooks

2008-05-14 Thread Andrew Dunstan
Alvaro Herrera wrote: Andrew Dunstan escribió: The thing that is a bit disturbing is that the whole style of this scheme is very different from the fairly simple APIs that the rest of libpq presents. It's going to make libpq look rather odd, I think. I would have felt happier if the a

Re: [PATCHES] libpq object hooks

2008-05-13 Thread Alvaro Herrera
Andrew Dunstan escribió: > The thing that is a bit disturbing is that the whole style of this > scheme is very different from the fairly simple APIs that the rest of > libpq presents. It's going to make libpq look rather odd, I think. I > would have felt happier if the authors had been able

Re: [PATCHES] libpq object hooks

2008-05-13 Thread Bruce Momjian
Andrew Dunstan wrote: > The first thing it needs is lots and lots of documentation. I think it > probably needs a Section in the libpq chapter all on its own, preferably > with some examples. I think that lack alone is enough to keep it from > being committed for now. > > Second, the hook names

Re: [PATCHES] libpq object hooks

2008-05-13 Thread Andrew Dunstan
Merlin Moncure wrote: Attached is an updated version of 'libpq object hooks'. The primary purpose for libpq object hooks is to support our libpqtypes system (not attached), but could possibly some nice sideband features to libpq. We are hoping to sneak this into the May commit fest. I

[PATCHES] libpq object hooks

2008-04-30 Thread Merlin Moncure
Attached is an updated version of 'libpq object hooks'. The primary purpose for libpq object hooks is to support our libpqtypes system (not attached), but could possibly some nice sideband features to libpq. We are hoping to sneak this into the May commit fest. regards, merlin Index: exports.tx

Re: [PATCHES] libpq object hooks patch

2008-04-15 Thread Andrew Chernow
Andrew Chernow wrote: Here is an updated version of the object hooks patch. It now supports a list of hooks for a PGconn, and PGresult. This had to re-introduce the concept of hook name. Being that there is now a list, you need a way to reference an item of that list. Also added PQobjectHo

[PATCHES] libpq object hooks patch

2008-04-15 Thread Andrew Chernow
Here is an updated version of the object hooks patch. It now supports a list of hooks for a PGconn, and PGresult. This had to re-introduce the concept of hook name. Being that there is now a list, you need a way to reference an item of that list. Also added PQobjectHooks and PQresultObjectH