From 389af951552ff2209eae3e62fa147fef12329d4f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 25 Feb 2011 18:56:23 -0500 Subject: Support data-modifying commands (INSERT/UPDATE/DELETE) in WITH. This patch implements data-modifying WITH queries according to the semantics that the updates all happen with the same command counter value, and in an unspecified order. Therefore one WITH clause can't see the effects of another, nor can the outer query see the effects other than through the RETURNING values. And attempts to do conflicting updates will have unpredictable results. We'll need to document all that. This commit just fixes the code; documentation updates are waiting on author. Marko Tiikkaja and Hitoshi Harada --- src/backend/commands/view.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/backend/commands/view.c') diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c index 1f418e907ea..5576ea259f4 100644 --- a/src/backend/commands/view.c +++ b/src/backend/commands/view.c @@ -418,6 +418,20 @@ DefineView(ViewStmt *stmt, const char *queryString) viewParse->commandType != CMD_SELECT) elog(ERROR, "unexpected parse analysis result"); + /* + * Check for unsupported cases. These tests are redundant with ones in + * DefineQueryRewrite(), but that function will complain about a bogus + * ON SELECT rule, and we'd rather the message complain about a view. + */ + if (viewParse->intoClause != NULL) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("views must not contain SELECT INTO"))); + if (viewParse->hasModifyingCTE) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("views must not contain data-modifying statements in WITH"))); + /* * If a list of column names was given, run through and insert these into * the actual query tree. - thomas 2000-03-08 -- cgit v1.2.3