Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 6FE5F2E0033 for ; Fri, 16 May 2008 17:23:25 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 76393-03 for ; Fri, 16 May 2008 17:23:19 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id E3BC72E0031 for ; Fri, 16 May 2008 17:23:21 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m4GKNG3b020532; Fri, 16 May 2008 16:23:16 -0400 (EDT) To: "Merlin Moncure" cc: "Andrew Dunstan" , "Alvaro Herrera" , "Patches (PostgreSQL)" , "Andrew Chernow" Subject: Re: libpq object hooks In-reply-to: References: <6044.1210867771@sss.pgh.pa.us> <482C77E5.1060500@esilo.com> <9458.1210875556@sss.pgh.pa.us> <482C82BA.3090100@esilo.com> <9867.1210877054@sss.pgh.pa.us> <482CD76E.6000202@esilo.com> <17177.1210949948@sss.pgh.pa.us> <482DD3AC.9020207@esilo.com> Comments: In-reply-to "Merlin Moncure" message dated "Fri, 16 May 2008 15:49:36 -0400" Date: Fri, 16 May 2008 16:23:16 -0400 Message-ID: <20531.1210969396@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/340 X-Sequence-Number: 6366 "Merlin Moncure" 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 assuming that the goals you have for these hooks are the only ones anyone will ever have. There are other possible usage patterns and many of them will need some passthrough state data. I'd venture to say that anytime I've ever used a callback design that did not include a passthrough, I've had reason to curse its designer sooner or later (qsort being a pretty typical example). However, it's clear that we are not on the same page, because what I thought you wanted the PQeventData function to return was the passthrough pointer. Evidently that's not what you want it to do, so you'd better back up a few steps and say what you do want it to do. (I think that a function to get the passthrough value associated with a given hook function might be useful too, but it's clear that what you are after must be something else.) > The purpose of the callbacks is to allow a hooking library to > establish private data that is associated with a PGconn or a PGresult. 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 storage? Okay, but that's a separate feature from the sort of passthrough I had in mind. 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)? > Invoking PQregisterEventProc tells libpq 'I am interested in doing > this', for the supplied PGconn, future results created with that > connection, and (if PGconn is passed as null), all future connections. I am entirely serious about saying that I will not accept that last bit. To do that we have to buy into having permanent modifiable storage within libpq, protecting it with thread mutexes, etc etc. And I don't like any of the possible usage scenarios for it. I think hooking into a PGconn immediately after its creation is just as useful and a lot easier to manage. > Once that is established, libpq begins telling the hooking library > when and what needs to be allocated or deleted. Wait a minute --- you're trying to get between libpq and malloc? Why? That's getting a *whole* lot more invasive than I thought this patch intended to be, and I don't see a good reason for it. regards, tom lane