Commit 6be30fb5 authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

Fix handling of functions with non-attribute first argument in WHERE

clauses.
parent c42f7f14
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -641,30 +641,20 @@ get_relattval(Node *clause, ...@@ -641,30 +641,20 @@ get_relattval(Node *clause,
is_funcclause((Node *) left) && is_funcclause((Node *) left) &&
IsA(right, Const)) IsA(right, Const))
{ {
List *args = ((Expr *) left)->args; List *vars = pull_var_clause((Node*)left);
*relid = ((Var *) lfirst(vars))->varno;
*relid = ((Var *) lfirst(args))->varno;
*attno = InvalidAttrNumber; *attno = InvalidAttrNumber;
*constval = ((Const *) right)->constvalue; *constval = ((Const *) right)->constvalue;
*flag = (_SELEC_CONSTANT_RIGHT_ | _SELEC_IS_CONSTANT_); *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) && else if (is_opclause(clause) &&
is_funcclause((Node *) right) && is_funcclause((Node *) right) &&
IsA(left, Const)) IsA(left, Const))
{ {
List *args = ((Expr *) right)->args; List *vars = pull_var_clause((Node*)right);
*relid = ((Var *) lfirst(args))->varno; *relid = ((Var *) lfirst(vars))->varno;
*attno = InvalidAttrNumber; *attno = InvalidAttrNumber;
*constval = ((Const *) left)->constvalue; *constval = ((Const *) left)->constvalue;
*flag = (_SELEC_IS_CONSTANT_); *flag = (_SELEC_IS_CONSTANT_);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment