Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 12FA32E005A for ; Thu, 15 May 2008 15:21:22 -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 01075-01-10 for ; Thu, 15 May 2008 15:21:07 -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 314CD2E00C1 for ; Thu, 15 May 2008 15:19:38 -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 m4FIJGG3009459; Thu, 15 May 2008 14:19:16 -0400 (EDT) To: Andrew Chernow cc: Merlin Moncure , Andrew Dunstan , Alvaro Herrera , "Patches (PostgreSQL)" Subject: Re: libpq object hooks In-reply-to: <482C77E5.1060500@esilo.com> References: <482A58D8.2030205@dunslane.net> <20080514043313.GS6966@alvh.no-ip.org> <482AD896.4000504@dunslane.net> <19342.1210776271@sss.pgh.pa.us> <6044.1210867771@sss.pgh.pa.us> <482C77E5.1060500@esilo.com> Comments: In-reply-to Andrew Chernow message dated "Thu, 15 May 2008 13:50:29 -0400" Date: Thu, 15 May 2008 14:19:16 -0400 Message-ID: <9458.1210875556@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/283 X-Sequence-Number: 6309 Andrew Chernow 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 storage. Note that if you want N fixed keys, you can just have N hook functions (all calling a shared workhorse routine, no doubt). So your proposal adds no functionality whatever if the usage involves a fixed number of static handles. Now it could possibly allow a variable-at-runtime number of handles, but I'd want to see a worked-out use case before designing for that much complexity. In particular, it seems to me that the problem would then shift to how do you know which handle to use for the lookup, thus you've just introduced another layer of complexity without buying anything. I think the typical use case is just that you need to distinguish "your" hook from anyone else's hooks, so the function address is plenty sufficient. It should also be noted that this whole problem *can* be solved without any PQhookData at all: as long as you have hooks to get control at creation and destruction of PGconns and PGresults, you can maintain your own index data structure. I'm willing to grant some amount of extra API-stuff to save users having to do that in simple cases, but I don't think we need to try to support infinitely complex cases. regards, tom lane