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

Commit 6be30fb

Browse files
committed
Fix handling of functions with non-attribute first argument in WHERE
clauses.
1 parent c42f7f1 commit 6be30fb

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/backend/optimizer/util/clauses.c

+7-17
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.11 1997/09/08 21:45:47 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.12 1997/09/25 12:48:15 vadim Exp $
1111
*
1212
* HISTORY
1313
* AUTHOR DATE MAJOR EVENT
@@ -641,30 +641,20 @@ get_relattval(Node *clause,
641641
is_funcclause((Node *) left) &&
642642
IsA(right, Const))
643643
{
644-
List *args = ((Expr *) left)->args;
645-
646-
647-
*relid = ((Var *) lfirst(args))->varno;
644+
List *vars = pull_var_clause((Node*)left);
645+
646+
*relid = ((Var *) lfirst(vars))->varno;
648647
*attno = InvalidAttrNumber;
649648
*constval = ((Const *) right)->constvalue;
650649
*flag = (_SELEC_CONSTANT_RIGHT_ | _SELEC_IS_CONSTANT_);
651-
652-
/*
653-
* XXX both of these func clause handling if's seem wrong to me.
654-
* they assume that the first argument is the Var. It could not
655-
* handle (for example) f(1, emp.name). I think I may have been
656-
* assuming no constants in functional index scans when I
657-
* implemented this originally (still currently true). -mer 10 Aug
658-
* 1992
659-
*/
660650
}
661651
else if (is_opclause(clause) &&
662652
is_funcclause((Node *) right) &&
663653
IsA(left, Const))
664654
{
665-
List *args = ((Expr *) right)->args;
666-
667-
*relid = ((Var *) lfirst(args))->varno;
655+
List *vars = pull_var_clause((Node*)right);
656+
657+
*relid = ((Var *) lfirst(vars))->varno;
668658
*attno = InvalidAttrNumber;
669659
*constval = ((Const *) left)->constvalue;
670660
*flag = (_SELEC_IS_CONSTANT_);

0 commit comments

Comments
 (0)