summaryrefslogtreecommitdiff
path: root/src/backend/nodes/copyfuncs.c
diff options
context:
space:
mode:
authorStephen Frost <sfrost@snowman.net>2013-07-18 17:10:16 -0400
committerStephen Frost <sfrost@snowman.net>2013-07-18 17:10:16 -0400
commit4cbe3ac3e86790d05c569de4585e5075a62a9b41 (patch)
tree8adc929520d4103b4493c0c23bcb7d2b2c2a5a4d /src/backend/nodes/copyfuncs.c
parent6f9e39bc9993c18686f0950f9b9657c7c97c7450 (diff)
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
Diffstat (limited to 'src/backend/nodes/copyfuncs.c')
-rw-r--r--src/backend/nodes/copyfuncs.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index f524a7a9943..bcc6496a952 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -178,6 +178,7 @@ _copyModifyTable(const ModifyTable *from)
COPY_NODE_FIELD(resultRelations);
COPY_SCALAR_FIELD(resultRelIndex);
COPY_NODE_FIELD(plans);
+ COPY_NODE_FIELD(withCheckOptionLists);
COPY_NODE_FIELD(returningLists);
COPY_NODE_FIELD(fdwPrivLists);
COPY_NODE_FIELD(rowMarks);
@@ -2003,6 +2004,18 @@ _copyRangeTblEntry(const RangeTblEntry *from)
return newnode;
}
+static WithCheckOption *
+_copyWithCheckOption(const WithCheckOption *from)
+{
+ WithCheckOption *newnode = makeNode(WithCheckOption);
+
+ COPY_STRING_FIELD(viewname);
+ COPY_NODE_FIELD(qual);
+ COPY_SCALAR_FIELD(cascaded);
+
+ return newnode;
+}
+
static SortGroupClause *
_copySortGroupClause(const SortGroupClause *from)
{
@@ -2446,6 +2459,7 @@ _copyQuery(const Query *from)
COPY_NODE_FIELD(rtable);
COPY_NODE_FIELD(jointree);
COPY_NODE_FIELD(targetList);
+ COPY_NODE_FIELD(withCheckOptions);
COPY_NODE_FIELD(returningList);
COPY_NODE_FIELD(groupClause);
COPY_NODE_FIELD(havingQual);
@@ -3075,6 +3089,7 @@ _copyViewStmt(const ViewStmt *from)
COPY_NODE_FIELD(query);
COPY_SCALAR_FIELD(replace);
COPY_NODE_FIELD(options);
+ COPY_SCALAR_FIELD(withCheckOption);
return newnode;
}
@@ -4517,6 +4532,9 @@ copyObject(const void *from)
case T_RangeTblEntry:
retval = _copyRangeTblEntry(from);
break;
+ case T_WithCheckOption:
+ retval = _copyWithCheckOption(from);
+ break;
case T_SortGroupClause:
retval = _copySortGroupClause(from);
break;