Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 514ce7a

Browse files
committed
Fix overly enthusiastic Assert introduced in 8.1: it's expecting a
CaseTestExpr, but forgot that the optimizer is sometimes able to replace CaseTestExpr by Const.
1 parent 87cd901 commit 514ce7a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/backend/utils/adt/ruleutils.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* ruleutils.c - Functions to convert stored expressions/querytrees
33
* back to source text
44
*
5-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.232 2006/08/21 00:57:25 tgl Exp $
5+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.233 2006/10/01 17:23:38 tgl Exp $
66
**********************************************************************/
77

88
#include "postgres.h"
@@ -3584,14 +3584,18 @@ get_rule_expr(Node *node, deparse_context *context,
35843584
* the optimizer's simplify_boolean_equality() may
35853585
* have reduced this to just "CaseTestExpr" or
35863586
* "NOT CaseTestExpr", for which we have to show
3587-
* "TRUE" or "FALSE".
3587+
* "TRUE" or "FALSE". Also, depending on context
3588+
* the original CaseTestExpr might have been reduced
3589+
* to a Const (but we won't see "WHEN Const").
35883590
*/
35893591
if (IsA(w, OpExpr))
35903592
{
35913593
Node *rhs;
35923594

35933595
Assert(IsA(linitial(((OpExpr *) w)->args),
3594-
CaseTestExpr));
3596+
CaseTestExpr) ||
3597+
IsA(linitial(((OpExpr *) w)->args),
3598+
Const));
35953599
rhs = (Node *) lsecond(((OpExpr *) w)->args);
35963600
get_rule_expr(rhs, context, false);
35973601
}

0 commit comments

Comments
 (0)