mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Add defenses against trying to attach qual conditions to a setOperation
query node, since that won't work unless the planner is upgraded. Someday we should try to support at least some cases of this, but for now just plug the hole in the dike. Per discussion with Dmitry Tkach.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.122 2003/07/03 16:34:25 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.123 2003/07/16 17:25:48 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -148,18 +148,31 @@ rewriteRuleAction(Query *parsetree,
|
||||
* As above, the action's jointree must not share substructure with the
|
||||
* main parsetree's.
|
||||
*/
|
||||
if (sub_action->jointree != NULL)
|
||||
if (sub_action->commandType != CMD_UTILITY)
|
||||
{
|
||||
bool keeporig;
|
||||
List *newjointree;
|
||||
|
||||
Assert(sub_action->jointree != NULL);
|
||||
keeporig = (!rangeTableEntry_used((Node *) sub_action->jointree,
|
||||
rt_index, 0)) &&
|
||||
(rangeTableEntry_used(rule_qual, rt_index, 0) ||
|
||||
rangeTableEntry_used(parsetree->jointree->quals, rt_index, 0));
|
||||
newjointree = adjustJoinTreeList(parsetree, !keeporig, rt_index);
|
||||
sub_action->jointree->fromlist =
|
||||
nconc(newjointree, sub_action->jointree->fromlist);
|
||||
if (newjointree != NIL)
|
||||
{
|
||||
/*
|
||||
* If sub_action is a setop, manipulating its jointree will do
|
||||
* no good at all, because the jointree is dummy. (Perhaps
|
||||
* someday we could push the joining and quals down to the
|
||||
* member statements of the setop?)
|
||||
*/
|
||||
if (sub_action->setOperations != NULL)
|
||||
elog(ERROR, "Conditional UNION/INTERSECT/EXCEPT statements are not implemented");
|
||||
|
||||
sub_action->jointree->fromlist =
|
||||
nconc(newjointree, sub_action->jointree->fromlist);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.72 2003/06/06 15:04:02 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.73 2003/07/16 17:25:48 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -733,6 +733,16 @@ AddQual(Query *parsetree, Node *qual)
|
||||
elog(ERROR, "Conditional utility statements are not implemented");
|
||||
}
|
||||
|
||||
if (parsetree->setOperations != NULL)
|
||||
{
|
||||
/*
|
||||
* There's noplace to put the qual on a setop statement, either.
|
||||
* (This could be fixed, but right now the planner simply ignores
|
||||
* any qual condition on a setop query.)
|
||||
*/
|
||||
elog(ERROR, "Conditional UNION/INTERSECT/EXCEPT statements are not implemented");
|
||||
}
|
||||
|
||||
/* INTERSECT want's the original, but we need to copy - Jan */
|
||||
copy = copyObject(qual);
|
||||
|
||||
@@ -773,6 +783,16 @@ AddHavingQual(Query *parsetree, Node *havingQual)
|
||||
elog(ERROR, "Conditional utility statements are not implemented");
|
||||
}
|
||||
|
||||
if (parsetree->setOperations != NULL)
|
||||
{
|
||||
/*
|
||||
* There's noplace to put the qual on a setop statement, either.
|
||||
* (This could be fixed, but right now the planner simply ignores
|
||||
* any qual condition on a setop query.)
|
||||
*/
|
||||
elog(ERROR, "Conditional UNION/INTERSECT/EXCEPT statements are not implemented");
|
||||
}
|
||||
|
||||
/* INTERSECT want's the original, but we need to copy - Jan */
|
||||
copy = copyObject(havingQual);
|
||||
|
||||
|
Reference in New Issue
Block a user