aboutsummaryrefslogtreecommitdiff
path: root/src/backend/rewrite/rewriteHandler.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-07-16 17:25:48 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-07-16 17:25:48 +0000
commit93236b58e088cd2151540528d484da9ad82e48c8 (patch)
tree5d12e2000fc4813421d32b94e042d6a04ce07e29 /src/backend/rewrite/rewriteHandler.c
parent96be4b28a31e37d2eb2757118164a6c9ae297d46 (diff)
downloadpostgresql-93236b58e088cd2151540528d484da9ad82e48c8.tar.gz
postgresql-93236b58e088cd2151540528d484da9ad82e48c8.zip
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.
Diffstat (limited to 'src/backend/rewrite/rewriteHandler.c')
-rw-r--r--src/backend/rewrite/rewriteHandler.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index a1d9122f828..7ee28291e0d 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -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);
+ }
}
/*