]> granicus.if.org Git - postgresql/commitdiff
Add support for Case exprs to fix_indxqual_references,
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 29 Jul 1999 02:48:05 +0000 (02:48 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 29 Jul 1999 02:48:05 +0000 (02:48 +0000)
so that Case works in WHERE join clauses.  Temporary patch --- this routine
is one of many that ought to be changed to use centralized expression-tree-
walking logic.

src/backend/optimizer/plan/createplan.c

index 18837cf2824095c1fd29a6800648c1677f5fc5ac..a358308a46898a58e585abe65c92e647a9f3936a 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.64 1999/07/27 03:51:03 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.65 1999/07/29 02:48:05 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -740,6 +740,37 @@ fix_indxqual_references(Node *clause, Path *index_path)
 
                return (Node *) newnode;
        }
+       else if (IsA(clause, CaseExpr))
+       {
+               CaseExpr   *oldnode = (CaseExpr *) clause;
+               CaseExpr   *newnode = makeNode(CaseExpr);
+
+               newnode->casetype = oldnode->casetype;
+               newnode->arg = oldnode->arg;    /* XXX should always be null
+                                                                                * anyway ... */
+               newnode->args = (List *)
+                       fix_indxqual_references((Node *) oldnode->args,
+                                                                       index_path);
+               newnode->defresult =
+                       fix_indxqual_references(oldnode->defresult,
+                                                                       index_path);
+
+               return (Node *) newnode;
+       }
+       else if (IsA(clause, CaseWhen))
+       {
+               CaseWhen   *oldnode = (CaseWhen *) clause;
+               CaseWhen   *newnode = makeNode(CaseWhen);
+
+               newnode->expr =
+                       fix_indxqual_references(oldnode->expr,
+                                                                       index_path);
+               newnode->result =
+                       fix_indxqual_references(oldnode->result,
+                                                                       index_path);
+
+               return (Node *) newnode;
+       }
        else
        {
                elog(ERROR, "fix_indxqual_references: Cannot handle node type %d",