Re: one more word about rules - Mailing list pgsql-general

From Tom Lane
Subject Re: one more word about rules
Date
Msg-id 26602.969633954@sss.pgh.pa.us
Whole thread Raw
In response to one more word about rules  (Papp Gyozo <s7461pap@hszk.bme.hu>)
List pgsql-general
Papp Gyozo <s7461pap@hszk.bme.hu> writes:
> In pgsql 7.0.2, there is no way to create a rule which can perform  an
> additional query after SELECT. What I'm writing  about:
> CREATE RULE r_my_dream AS ON SELECT TO xxx
> DO UPDATE xxx SET c_lastref = current_timestamp, c_refnum = c_refnum + 1
> WHERE xxx.oid = old.oid;

I don't think this is a real good idea.  If it were enforced by the
database then you couldn't (just to take one example) produce a backup
dump without clobbering all your lastref information.  And what of
queries like SELECT count(*) FROM table --- should that update the
timestamps of all the rows it reads, and if not why not?

I think you'll have to consider "access" (ie, an action that triggers
a lastref update) to be an application-defined concept, and that means
implementing the updates on the application side.

            regards, tom lane

pgsql-general by date:

Previous
From: "Abe Asghar"
Date:
Subject: Re: one more word about rules
Next
From: Denis Perchine
Date:
Subject: Re: Re: Large Objects