Gavin Sherry <swm@linuxworld.com.au> writes:
> I haven't had time to look into it further, but it occurs to me that
> handling views which rely on joins would be far from trivial.
Views containing joins would not be updatable; problem solved. The set
of views the automatic-rule-generation machinery needs to handle are
those defined as updatable by the SQL spec. SQL92 says
12)A <query specification> QS is updatable if and only if the fol- lowing conditions hold:
a) QS does not specify DISTINCT.
b) Every <value expression> contained in the <select list> imme- diately contained in QS
consistsof a <column reference>, and no <column reference> appears more than once.
c) The <from clause> immediately contained in the <table ex- pression> immediately contained in
QSspecifies exactly one <table reference> and that <table reference> refers either to a base
tableor to an updatable derived table.
Note: updatable derived table is defined in Subclause 6.3, "<table reference>".
d) If the <table expression> immediately contained in QS imme- diately contains a <where clause>
WC,then no leaf generally underlying table of QS shall be a generally underlying table of any
<queryexpression> contained in WC.
e) The <table expression> immediately contained in QS does not include a <group by clause> or a
<havingclause>.
The reference to 6.3 appears to be pointing at this:
8) A <derived table> is an updatable derived table if and only if the <query expression> simply
containedin the <subquery> of the <table subquery> of the <derived table> is updatable.
I haven't quite wrapped my head around what clause 12d means, but 12c is
perfectly clear that you only get one table reference.
regards, tom lane