Fix handling of functions with non-attribute first argument in WHERE
authorVadim B. Mikheev
Thu, 25 Sep 1997 12:48:15 +0000 (12:48 +0000)
committerVadim B. Mikheev
Thu, 25 Sep 1997 12:48:15 +0000 (12:48 +0000)
clauses.

src/backend/optimizer/util/clauses.c

index 177466ee83e1e7fe0dea36e77333827fe27799c0..c62eb04fcc66f43c15476359ffbcf263e8cb11d6 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.11 1997/09/08 21:45:47 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.12 1997/09/25 12:48:15 vadim Exp $
  *
  * HISTORY
  *   AUTHOR            DATE            MAJOR EVENT
@@ -641,30 +641,20 @@ get_relattval(Node *clause,
             is_funcclause((Node *) left) &&
             IsA(right, Const))
    {
-       List       *args = ((Expr *) left)->args;
-
-
-       *relid = ((Var *) lfirst(args))->varno;
+       List       *vars = pull_var_clause((Node*)left);
+       
+       *relid = ((Var *) lfirst(vars))->varno;
        *attno = InvalidAttrNumber;
        *constval = ((Const *) right)->constvalue;
        *flag = (_SELEC_CONSTANT_RIGHT_ | _SELEC_IS_CONSTANT_);
-
-       /*
-        * XXX both of these func clause handling if's seem wrong to me.
-        * they assume that the first argument is the Var.  It could not
-        * handle (for example) f(1, emp.name).  I think I may have been
-        * assuming no constants in functional index scans when I
-        * implemented this originally (still currently true). -mer 10 Aug
-        * 1992
-        */
    }
    else if (is_opclause(clause) &&
             is_funcclause((Node *) right) &&
             IsA(left, Const))
    {
-       List       *args = ((Expr *) right)->args;
-
-       *relid = ((Var *) lfirst(args))->varno;
+       List       *vars = pull_var_clause((Node*)right);
+       
+       *relid = ((Var *) lfirst(vars))->varno;
        *attno = InvalidAttrNumber;
        *constval = ((Const *) left)->constvalue;
        *flag = (_SELEC_IS_CONSTANT_);