Fix overly enthusiastic Assert introduced in 8.1: it's expecting a
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 1 Oct 2006 17:23:51 +0000 (17:23 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 1 Oct 2006 17:23:51 +0000 (17:23 +0000)
CaseTestExpr, but forgot that the optimizer is sometimes able to replace
CaseTestExpr by Const.

src/backend/utils/adt/ruleutils.c

index c08ff098e5f71e1cae7bc7140dae6413f990d7a3..613d7982456a69cfb5aee3409a086a902584eb09 100644 (file)
@@ -3458,14 +3458,18 @@ get_rule_expr(Node *node, deparse_context *context,
                                                 * the optimizer's simplify_boolean_equality() may
                                                 * have reduced this to just "CaseTestExpr" or
                                                 * "NOT CaseTestExpr", for which we have to show
-                                                * "TRUE" or "FALSE".
+                                                * "TRUE" or "FALSE".  Also, depending on context
+                                                * the original CaseTestExpr might have been reduced
+                                                * to a Const (but we won't see "WHEN Const").
                                                 */
                                                if (IsA(w, OpExpr))
                                                {
                                                        Node       *rhs;
 
                                                        Assert(IsA(linitial(((OpExpr *) w)->args),
-                                                                          CaseTestExpr));
+                                                                          CaseTestExpr) ||
+                                                                  IsA(linitial(((OpExpr *) w)->args),
+                                                                          Const));
                                                        rhs = (Node *) lsecond(((OpExpr *) w)->args);
                                                        get_rule_expr(rhs, context, false);
                                                }