Re: WIP: Automatic view update rules

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: WIP: Automatic view update rules
Date: 2009-01-19 21:02:11
Message-ID: E3C0E65F7653B087DB6EBBDE@teje
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

--On Samstag, Januar 17, 2009 02:01:15 +0200 Peter Eisentraut
<peter_e(at)gmx(dot)net> wrote:

> Here is my updated patch based on yours.
>
> Outstanding issues, as far as I can see, are:
>
> Critical:
>
> * Updatability check must reject views where the select list references
> the same column more than once.
>

checkTree() will recheck this against reused varattno's within the query
tree and will reject such view definitions as non-updatable now.

> * Various scenarios of REPLACE VIEW misbehave. I have marked these as
> FIXME in the regression test. I think all this would behave better if
> REPLACE VIEW dropped all automatic rules and reassembled them from
> scratch for the new view. The infrastructure for this is already there,
> so it should be a small change.
>

DefineViewRules() will drop all implicit rules when REPLACE is used now.

> Important:
>
> * Array support should be clarified. checkTree() appears to reject most
> variants of array references, but other parts of the code try to handle
> it. Should be cleaned up.
>

I'm currently working on this.

> * It is not clear how automatic rules and manual DO ALSO rules should
> interact. A manual DO ALSO rule will currently clear out an automatic
> INSTEAD rule, which I find to be illogical.
>

What i've done so far is to replace implicit DO INSTEAD rules only, when
the new explicit one is DO INSTEAD, too. An additional DO ALSO rule will be
added to the view without dropping any automatic rules now.

> Optional:
>
> * The use of must_replace is create_update_rule() seems a bit useless.
> You might as well just always pass replace = true.
>

Fixed

> * You may want to consider writing the rule qualifications
>
> WHERE ((CASE WHEN (old.a IS NOT NULL) THEN (old.a = vutestv20.x) ELSE
> (vutestv20.x IS NULL) END))
>
> more like
>
> WHERE ((old.a = vutestv20.x) OR (old IS NULL AND vutestv20.x IS NULL))
>
> for better optimizability.

Done.

Please note that i haven't fixed the regression test yet. Thanks very much
for reviewing!

--
Thanks

Bernd

Attachment Content-Type Size
view_update_20090119.patch.bz2 application/octet-stream 21.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Todd A. Cook 2009-01-19 21:22:21 is 8.4 array_agg() supposed to work with array values?
Previous Message Zdenek Kotala 2009-01-19 20:39:30 Re: foreign_data test fails with non-C locale