From 93236b58e088cd2151540528d484da9ad82e48c8 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 16 Jul 2003 17:25:48 +0000 Subject: 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. --- src/backend/parser/analyze.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/backend/parser') diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 90818b153b8..ca7759cfc82 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.278 2003/07/03 19:07:30 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.279 2003/07/16 17:25:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1787,6 +1787,15 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, */ sub_qry = getInsertSelectQuery(top_subqry, NULL); + /* + * If the sub_qry is a setop, we cannot attach any qualifications + * to it, because the planner won't notice them. This could + * perhaps be relaxed someday, but for now, we may as well reject + * such a rule immediately. + */ + if (sub_qry->setOperations != NULL && stmt->whereClause != NULL) + elog(ERROR, "Conditional UNION/INTERSECT/EXCEPT statements are not implemented"); + /* * Validate action's use of OLD/NEW, qual too */ @@ -1841,6 +1850,13 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, */ if (has_old || (has_new && stmt->event == CMD_UPDATE)) { + /* + * If sub_qry is a setop, manipulating its jointree will do + * no good at all, because the jointree is dummy. (This + * should be a can't-happen case because of prior tests.) + */ + if (sub_qry->setOperations != NULL) + elog(ERROR, "Conditional UNION/INTERSECT/EXCEPT statements are not implemented"); /* hack so we can use addRTEtoQuery() */ sub_pstate->p_rtable = sub_qry->rtable; sub_pstate->p_joinlist = sub_qry->jointree->fromlist; -- cgit v1.2.3