mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +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:
@ -4702,16 +4702,16 @@ make_result(PlannerInfo *root,
|
||||
* Build a ModifyTable plan node
|
||||
*
|
||||
* Currently, we don't charge anything extra for the actual table modification
|
||||
* work, nor for the RETURNING expressions if any. It would only be window
|
||||
* dressing, since these are always top-level nodes and there is no way for
|
||||
* the costs to change any higher-level planning choices. But we might want
|
||||
* to make it look better sometime.
|
||||
* work, nor for the WITH CHECK OPTIONS or RETURNING expressions if any. It
|
||||
* would only be window dressing, since these are always top-level nodes and
|
||||
* there is no way for the costs to change any higher-level planning choices.
|
||||
* But we might want to make it look better sometime.
|
||||
*/
|
||||
ModifyTable *
|
||||
make_modifytable(PlannerInfo *root,
|
||||
CmdType operation, bool canSetTag,
|
||||
List *resultRelations,
|
||||
List *subplans, List *returningLists,
|
||||
List *resultRelations, List *subplans,
|
||||
List *withCheckOptionLists, List *returningLists,
|
||||
List *rowMarks, int epqParam)
|
||||
{
|
||||
ModifyTable *node = makeNode(ModifyTable);
|
||||
@ -4723,6 +4723,8 @@ make_modifytable(PlannerInfo *root,
|
||||
int i;
|
||||
|
||||
Assert(list_length(resultRelations) == list_length(subplans));
|
||||
Assert(withCheckOptionLists == NIL ||
|
||||
list_length(resultRelations) == list_length(withCheckOptionLists));
|
||||
Assert(returningLists == NIL ||
|
||||
list_length(resultRelations) == list_length(returningLists));
|
||||
|
||||
@ -4759,6 +4761,7 @@ make_modifytable(PlannerInfo *root,
|
||||
node->resultRelations = resultRelations;
|
||||
node->resultRelIndex = -1; /* will be set correctly in setrefs.c */
|
||||
node->plans = subplans;
|
||||
node->withCheckOptionLists = withCheckOptionLists;
|
||||
node->returningLists = returningLists;
|
||||
node->rowMarks = rowMarks;
|
||||
node->epqParam = epqParam;
|
||||
|
Reference in New Issue
Block a user