mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +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:
@ -332,6 +332,7 @@ _outModifyTable(StringInfo str, const ModifyTable *node)
|
||||
WRITE_NODE_FIELD(resultRelations);
|
||||
WRITE_INT_FIELD(resultRelIndex);
|
||||
WRITE_NODE_FIELD(plans);
|
||||
WRITE_NODE_FIELD(withCheckOptionLists);
|
||||
WRITE_NODE_FIELD(returningLists);
|
||||
WRITE_NODE_FIELD(fdwPrivLists);
|
||||
WRITE_NODE_FIELD(rowMarks);
|
||||
@ -2247,6 +2248,7 @@ _outQuery(StringInfo str, const Query *node)
|
||||
WRITE_NODE_FIELD(rtable);
|
||||
WRITE_NODE_FIELD(jointree);
|
||||
WRITE_NODE_FIELD(targetList);
|
||||
WRITE_NODE_FIELD(withCheckOptions);
|
||||
WRITE_NODE_FIELD(returningList);
|
||||
WRITE_NODE_FIELD(groupClause);
|
||||
WRITE_NODE_FIELD(havingQual);
|
||||
@ -2260,6 +2262,16 @@ _outQuery(StringInfo str, const Query *node)
|
||||
WRITE_NODE_FIELD(constraintDeps);
|
||||
}
|
||||
|
||||
static void
|
||||
_outWithCheckOption(StringInfo str, const WithCheckOption *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("WITHCHECKOPTION");
|
||||
|
||||
WRITE_STRING_FIELD(viewname);
|
||||
WRITE_NODE_FIELD(qual);
|
||||
WRITE_BOOL_FIELD(cascaded);
|
||||
}
|
||||
|
||||
static void
|
||||
_outSortGroupClause(StringInfo str, const SortGroupClause *node)
|
||||
{
|
||||
@ -3114,6 +3126,9 @@ _outNode(StringInfo str, const void *obj)
|
||||
case T_Query:
|
||||
_outQuery(str, obj);
|
||||
break;
|
||||
case T_WithCheckOption:
|
||||
_outWithCheckOption(str, obj);
|
||||
break;
|
||||
case T_SortGroupClause:
|
||||
_outSortGroupClause(str, obj);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user