mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +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:
doc/src/sgml/ref
src
backend
access
common
catalog
commands
executor
nodes
optimizer
parser
rewrite
bin
include
catalog
commands
executor
nodes
optimizer
rewrite
utils
test
regress
@ -1556,6 +1556,8 @@ expression_tree_walker(Node *node,
|
||||
case T_SortGroupClause:
|
||||
/* primitive node types with no expression subnodes */
|
||||
break;
|
||||
case T_WithCheckOption:
|
||||
return walker(((WithCheckOption *) node)->qual, context);
|
||||
case T_Aggref:
|
||||
{
|
||||
Aggref *expr = (Aggref *) node;
|
||||
@ -1873,6 +1875,8 @@ query_tree_walker(Query *query,
|
||||
|
||||
if (walker((Node *) query->targetList, context))
|
||||
return true;
|
||||
if (walker((Node *) query->withCheckOptions, context))
|
||||
return true;
|
||||
if (walker((Node *) query->returningList, context))
|
||||
return true;
|
||||
if (walker((Node *) query->jointree, context))
|
||||
@ -2074,6 +2078,15 @@ expression_tree_mutator(Node *node,
|
||||
case T_RangeTblRef:
|
||||
case T_SortGroupClause:
|
||||
return (Node *) copyObject(node);
|
||||
case T_WithCheckOption:
|
||||
{
|
||||
WithCheckOption *wco = (WithCheckOption *) node;
|
||||
WithCheckOption *newnode;
|
||||
|
||||
FLATCOPY(newnode, wco, WithCheckOption);
|
||||
MUTATE(newnode->qual, wco->qual, Node *);
|
||||
return (Node *) newnode;
|
||||
}
|
||||
case T_Aggref:
|
||||
{
|
||||
Aggref *aggref = (Aggref *) node;
|
||||
@ -2589,6 +2602,7 @@ query_tree_mutator(Query *query,
|
||||
}
|
||||
|
||||
MUTATE(query->targetList, query->targetList, List *);
|
||||
MUTATE(query->withCheckOptions, query->withCheckOptions, List *);
|
||||
MUTATE(query->returningList, query->returningList, List *);
|
||||
MUTATE(query->jointree, query->jointree, FromExpr *);
|
||||
MUTATE(query->setOperations, query->setOperations, Node *);
|
||||
|
Reference in New Issue
Block a user