mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Repair breakage of rules containing INSERT ... SELECT actions, per bug
report from Joel Burton. Turns out that my simple idea of turning the SELECT into a subquery does not interact well *at all* with the way the rule rewriter works. Really what we need to make INSERT ... SELECT work cleanly is to decouple targetlists from rangetables: an INSERT ... SELECT wants to have two levels of targetlist but only one rangetable. No time for that for 7.1, however, so I've inserted some ugly hacks to make the rewriter know explicitly about the structure of INSERT ... SELECT queries. Ugh :-(
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.55 2000/10/26 21:36:50 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.56 2000/12/05 19:15:09 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -24,6 +24,7 @@
|
||||
#include "optimizer/clauses.h"
|
||||
#include "parser/parse_relation.h"
|
||||
#include "rewrite/rewriteDefine.h"
|
||||
#include "rewrite/rewriteManip.h"
|
||||
#include "rewrite/rewriteSupport.h"
|
||||
#include "storage/smgr.h"
|
||||
#include "utils/builtins.h"
|
||||
@ -205,16 +206,17 @@ DefineQueryRewrite(RuleStmt *stmt)
|
||||
foreach(l, action)
|
||||
{
|
||||
query = (Query *) lfirst(l);
|
||||
if (query->resultRelation == 0)
|
||||
continue;
|
||||
/* Don't be fooled by INSERT/SELECT */
|
||||
if (query != getInsertSelectQuery(query, NULL))
|
||||
continue;
|
||||
if (query->resultRelation == PRS2_OLD_VARNO)
|
||||
{
|
||||
elog(ERROR, "rule actions on OLD currently not supported"
|
||||
"\n\tuse views or triggers instead");
|
||||
}
|
||||
if (query->resultRelation == PRS2_NEW_VARNO)
|
||||
{
|
||||
elog(ERROR, "rule actions on NEW currently not supported"
|
||||
"\n\tuse triggers instead");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user