Re: [COMMITTERS] pgsql: Automatic view update rules Bernd Helmle

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bernd Helmle <mailings(at)oopsware(dot)de>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Automatic view update rules Bernd Helmle
Date: 2009-01-24 20:15:59
Message-ID: 87mydglatc.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> ON UPDATE DO INSTEAD SUBSTITUTE base_table [ (base_column_name, ...) ]
> [ WHERE ... ]
>
> ON UPDATE DO INSTEAD
> UPDATE base_table SET base_col_1 = new.derived_col_1, base_col_2 ...
> WHERE CURRENT OF VIEW;

What would happen with these if the view is defined with "SELECT *" and I add
a new column or drop columns from the table? It seems like the former with the
optional list of columns would magically apply to the new columns which would
make it behave differently from the normal select rule. Or would you expand an
ommitted column list like we do with "select *"

In any case the fact that the latter allows you to extend things with computed
values seems pretty attractive. We could always allow shortcuts like "SET *
WHERE CURRENT OF VIEW" analogous to "SELECT *" for manually created views. We
could also allow the rhs of the expressions to be skipped so you could do

UPDATE base_table SET col1, col2, col, base_col = new.derived_col - 1
WHERE CURRENT OF VIEW

This same machinery isn't present in the normal executor is it? I mean, if I
can update a view then ISTM I should be able to update a view written inline
in the query like:

UPDATE (select * from a where x=1) set y=2

just like I can with SELECTs. This does incidentally work in Oracle and is its
way of doing what we do with UPDATE...FROM. It's the only way AFAIK to get
merge join update plans out of it.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Bernd Helmle 2009-01-24 20:49:22 Re: [COMMITTERS] pgsql: Automatic view update rules Bernd Helmle
Previous Message Tom Lane 2009-01-24 19:17:58 Re: [COMMITTERS] pgsql: Automatic view update rules Bernd Helmle

Browse pgsql-hackers by date

  From Date Subject
Next Message Bernd Helmle 2009-01-24 20:49:22 Re: [COMMITTERS] pgsql: Automatic view update rules Bernd Helmle
Previous Message Andrew Chernow 2009-01-24 20:10:43 UnixWare 7.1.4 (and OpenServer) sigwait issue