mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
WITH CHECK OPTION support for auto-updatable VIEWs
For simple views which are automatically updatable, this patch allows the user to specify what level of checking should be done on records being inserted or updated. For 'LOCAL CHECK', new tuples are validated against the conditionals of the view they are being inserted into, while for 'CASCADED CHECK' the new tuples are validated against the conditionals for all views involved (from the top down). This option is part of the SQL specification. Dean Rasheed, reviewed by Pavel Stehule
This commit is contained in:
@@ -128,6 +128,8 @@ typedef struct Query
|
||||
|
||||
List *targetList; /* target list (of TargetEntry) */
|
||||
|
||||
List *withCheckOptions; /* a list of WithCheckOption's */
|
||||
|
||||
List *returningList; /* return-values list (of TargetEntry) */
|
||||
|
||||
List *groupClause; /* a list of SortGroupClause's */
|
||||
@@ -783,6 +785,19 @@ typedef struct RangeTblEntry
|
||||
Bitmapset *modifiedCols; /* columns needing INSERT/UPDATE permission */
|
||||
} RangeTblEntry;
|
||||
|
||||
/*
|
||||
* WithCheckOption -
|
||||
* representation of WITH CHECK OPTION checks to be applied to new tuples
|
||||
* when inserting/updating an auto-updatable view.
|
||||
*/
|
||||
typedef struct WithCheckOption
|
||||
{
|
||||
NodeTag type;
|
||||
char *viewname; /* name of view that specified the WCO */
|
||||
Node *qual; /* constraint qual to check */
|
||||
bool cascaded; /* true = WITH CASCADED CHECK OPTION */
|
||||
} WithCheckOption;
|
||||
|
||||
/*
|
||||
* SortGroupClause -
|
||||
* representation of ORDER BY, GROUP BY, PARTITION BY,
|
||||
@@ -2333,6 +2348,13 @@ typedef struct AlterEnumStmt
|
||||
* Create View Statement
|
||||
* ----------------------
|
||||
*/
|
||||
typedef enum ViewCheckOption
|
||||
{
|
||||
NO_CHECK_OPTION,
|
||||
LOCAL_CHECK_OPTION,
|
||||
CASCADED_CHECK_OPTION
|
||||
} ViewCheckOption;
|
||||
|
||||
typedef struct ViewStmt
|
||||
{
|
||||
NodeTag type;
|
||||
@@ -2341,6 +2363,7 @@ typedef struct ViewStmt
|
||||
Node *query; /* the SELECT query */
|
||||
bool replace; /* replace an existing view? */
|
||||
List *options; /* options from WITH clause */
|
||||
ViewCheckOption withCheckOption; /* WITH CHECK OPTION */
|
||||
} ViewStmt;
|
||||
|
||||
/* ----------------------
|
||||
|
||||
Reference in New Issue
Block a user