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