diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-02-25 18:56:23 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-02-25 18:58:02 -0500 |
commit | 389af951552ff2209eae3e62fa147fef12329d4f (patch) | |
tree | 647af6827c57dc5bd902ec98db80269f950a57f0 /src/backend/commands | |
parent | 0056066d06067d2d7fc84b31937933b5724347d0 (diff) | |
download | postgresql-389af951552ff2209eae3e62fa147fef12329d4f.tar.gz postgresql-389af951552ff2209eae3e62fa147fef12329d4f.zip |
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
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/tablecmds.c | 3 | ||||
-rw-r--r-- | src/backend/commands/view.c | 14 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 5789a39ba3d..e76ce2ceb13 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -995,7 +995,7 @@ ExecuteTruncate(TruncateStmt *stmt) /* * To fire triggers, we'll need an EState as well as a ResultRelInfo for - * each relation. + * each relation. We don't need to call ExecOpenIndices, though. */ estate = CreateExecutorState(); resultRelInfos = (ResultRelInfo *) @@ -1008,7 +1008,6 @@ ExecuteTruncate(TruncateStmt *stmt) InitResultRelInfo(resultRelInfo, rel, 0, /* dummy rangetable index */ - CMD_DELETE, /* don't need any index info */ 0); resultRelInfo++; } 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 @@ -419,6 +419,20 @@ DefineView(ViewStmt *stmt, const char *queryString) 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 */ |