From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Handling conflicting FOR UPDATE/SHARE specs |
Date: | 2006-04-30 00:58:42 |
Message-ID: | 10359.1146358722@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Currently, we disallow use of both FOR UPDATE and FOR SHARE in a single
query, as well as use of both NOWAIT and default "WAIT" semantics.
There is no reason for this except inadequately flexible data
representation, ie, a single flag for the whole Query instead of one per
target relation. I'm about to go fix that, because it looks to me like
the code will actually end up simpler as well as more flexible.
However, I notice that there is a definitional question this opens up:
what should happen given conflicting specifications for the same
relation? The obvious case is
FOR UPDATE OF x,y FOR SHARE OF y
but there is also the case of
FOR SHARE FOR UPDATE OF y
where the "FOR SHARE" implies all relations and therefore implicitly
conflicts with the per-relation FOR UPDATE flag on y.
Seems like we could adopt one of two attitudes: "throw an error"
or "use the more restrictive behavior" (the latter would make
FOR UPDATE win over FOR SHARE, and probably NOWAIT over WAIT).
In the case of the all-relations vs some-relations specs, we could also
try to make the all-relations spec apply only to the relations not
listed explicitly. But doing that seems a bit painful, particularly if
you want it to work independently of ordering of the clauses.
Another case to think about is that we consider FOR UPDATE/SHARE on a
view to mean that the clause propagates to all tables used in the view.
So if there's already any FOR UPDATE/SHARE specs inside the view
definition, "throw an error" would cause the query to fail unless
they're exactly like the clause applied to the view. (This is what
happens now, but it's not very nice IMHO.) "Use the more restrictive
behavior" seems like a more pleasant way to combine specs in this case.
I'm kind of leaning to "use the more restrictive behavior" but wanted
to ask if anyone really hates that.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Rod Taylor | 2006-04-30 01:26:02 | Re: Is a SERIAL column a "black box", or not? |
Previous Message | mark | 2006-04-29 23:41:15 | Re: Is a SERIAL column a "black box", or not? |