Allowing DML RULEs that produce Read Only actions during RO xacts

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Allowing DML RULEs that produce Read Only actions during RO xacts
Date: 2009-12-06 11:02:53
Message-ID: 1260097373.13774.44448.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


I would like to allow RULEs ON INSERT, ON UPDATE and ON DELETE during
read only transactions iff they generate only SELECT statements that act
INSTEAD OF the actual event.

CREATE RULE foorah
AS ON INSERT TO foo
DO INSTEAD SELECT remote_insert(NEW.col1, NEW.col2, ...);

The above rule is currently disallowed during READ ONLY transactions,
even though the write action is re-written into a read-only action.

I have a small patch that allows this, attached here with test cases.

This would be a small, but useful additional feature for Hot Standby,
since it would allow INSERT, UPDATE, DELETE statements to be re-routed,
for various applications.

--
Simon Riggs www.2ndQuadrant.com

Attachment Content-Type Size
ro_dml_rules.v1.patch text/x-patch 2.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2009-12-06 11:18:10 Re: Hot standby, recent changes
Previous Message Simon Riggs 2009-12-06 10:51:29 Re: Hot standby, recent changes