Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 261B964FCDF for ; Tue, 2 Sep 2008 05:36:59 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 18502-01 for ; Tue, 2 Sep 2008 05:36:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail128082.authsmtp.com (outmail128082.authsmtp.com [62.13.128.82]) by postgresql.org (Postfix) with ESMTP id 6D32464FFF4 for ; Tue, 2 Sep 2008 05:36:53 -0300 (ADT) Received: from punt9.authsmtp.com (punt9.authsmtp.com [62.13.128.70]) by punt4.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m828apw5022511 for ; Tue, 2 Sep 2008 09:36:51 +0100 (BST) Received: from mail-c189.authsmtp.com (mail-c189.authsmtp.com [62.13.128.71]) by punt9.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m828anJN090855; Tue, 2 Sep 2008 09:36:49 +0100 (BST) Received: from [192.168.0.2] (85-211-229-97.dyn.gotadsl.co.uk [85.211.229.97]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m828amxe001963; Tue, 2 Sep 2008 09:36:48 +0100 (BST) Subject: Re: rmgr hooks and contrib/rmgr_hook From: Simon Riggs To: ITAGAKI Takahiro Cc: List pgsql-patches In-Reply-To: <20080901121833.4A18.52131E4D@oss.ntt.co.jp> References: <1220174867.4371.107.camel@ebony.2ndQuadrant> <20080901121833.4A18.52131E4D@oss.ntt.co.jp> Content-Type: text/plain Date: Tue, 02 Sep 2008 09:44:24 +0100 Message-Id: <1220345064.4371.275.camel@ebony.2ndQuadrant> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: 48bcc110-78ca-11dd-bc7a-001f29070be2 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksadBtFaAdbflxB HGQLW1xEUFV7WmV/ bwMfZQBDYEtPQQdo WVZARU1QEQdtHhxP WxYcWkgvP1BGeH95 Y0UsXHBZWQp+fRQu EU9VFXABbTQxdWEe BBRFJVBTIR5Kfh4T aFl/U3NfNGdJBC9q VzwLFgwaHRhkHWxP Rw4XZVIVRkUQVjc6 S1gJGjMzB0wPAD82 IAYRKlkbHy42 X-Authentic-SMTP: 61633235383639.kestrel.dmpriest.net.uk:1186/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/4 X-Sequence-Number: 7019 On Mon, 2008-09-01 at 12:42 +0900, ITAGAKI Takahiro wrote: > Simon Riggs wrote: > > > 1) A refactoring of calls to Rmgr code from xlog.c, and having isolated > > the code for rmgrs then to allow rmgr plugins to modify and/or add rmgrs > > to Postgres. Includes additional code to generate log messages so we can > > see what is happening after plugin has executed. > > Why do we need to set rmgr_hook in _PG_init(), and add or mofify rmgrs > in our hook functions? I think it is possible to modify RmgrTable > directly in _PG_init() instead of to have rmgr_hook. If we can do so, > the patch would be more simple, no? Am I missing something? If we modify RmgrTable in _PG_init() then we would have to have that structure available in all backends, which was a stated objective to avoid. We would still need a fast access data structure for the XLogInsert() check, so the RmgrTable would just be wasted space in all normal backends. In the patch, plugin is only called when we call RmgrInitialize(), so the memory is malloc'd only when required. The other reason is that this way of doing things is common to most other server hooks. It allows the loaded module to specify that there will be a plugin, but for the server to determine when that is called. Calling code at the time _PG_init() runs limits us to certain types of activity. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support