Skip site navigation (1) Skip section navigation (2)

Proposal for updatable views

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Proposal for updatable views
Date: 2006-03-10 10:21:45
Message-ID: A4470D5DA24CF98E50B75EE0@localhost.localdomain (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi folks,

Please find attached a patch that implements SQL92-compatible updatable 
views. The patch introduces new semantics into the rule system: implicit 
and explicit rules. Implicit rules are created to implement updatable views:

_INSERT
_NOTHING_INSERT (unconditional DO INSTEAD NOTHING rule)
_DELETE
_NOTHING_DELETE (unconditional DO INSTEAD NOTHING rule)
_UPDATE
_NOTHING_UPDATE (unconditional DO INSTEAD NOTHING rule)

These rules are marked 'implicit' in pg_rewrite, the rewriter is teached to 
handle them different, depending on wether they are created with a rule 
condition (a view's CHECK OPTION) or not. The CHECK OPTION itself is 
implemented with a new system function and a conditional rule that 
evaluates the view's WHERE condition (pg_view_update_error()).

The supported syntax is

CREATE VIEW foo AS SELECT ... [WITH [LOCAL | CASCADED] CHECK OPTION];

The LOCAL and CASCADED keywords are optional when a CHECK OPTION is 
specified, the default is CASCADED (this syntax creates a shift/reduce 
conflict in the grammar file i don't know how to fix).

If a user wants his own rules with CREATE RULE to be created, the implicit 
rule gets dropped, depending what action the user selects.

The patch introduces support for pg_dump as well.

Please note that the patch isn't complete yet, but it seems it's necessary 
to discuss its implementation on -hackers now.

        Bernd

Attachment: pgsql-view_update_8.2dev.tar.bz2
Description: application/octet-stream (25.3 KB)

Responses

pgsql-hackers by date

Next:From: Bernd HelmleDate: 2006-03-10 10:22:36
Subject: Re: Proposal for SYNONYMS
Previous:From: Martijn van OosterhoutDate: 2006-03-10 10:02:29
Subject: Re: Coverity Open Source Defect Scan of PostgreSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group