From 1aa1827d64a354d01922232b2750a42dede42631 Mon Sep 17 00:00:00 2001
From: "Vadim B. Mikheev" <vadim4o@yahoo.com>
Date: Wed, 22 Jan 1997 06:25:42 +0000
Subject: [PATCH] 1. INDEXSCAN_PATCH changes: (op Param Var) should work too 2.
 IndexScanableOperand now uses match_indexkey_operand instead of
 equal_indexkey_var (if we have some index on attribute X then we shouldn't
 use it for 'where some_func(X) OP CONST').

---
 src/backend/optimizer/path/indxpath.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index 41cbdf985d8..ce6a3f715e4 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.4 1996/11/08 05:56:55 momjian Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.5 1997/01/22 06:25:42 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -441,9 +441,17 @@ group_clauses_by_indexkey(Rel *rel,
  */
 #define IndexScanableOperand(opnd, indkeys, rel, index) \
     ((index->indproc == InvalidOid) ? \
-	equal_indexkey_var(indkeys,opnd) : \
+	match_indexkey_operand(indkeys, opnd, rel) : \
 	function_index_operand((Expr*)opnd,rel,index))
 
+/*
+ * There was
+ *	equal_indexkey_var(indkeys,opnd) : \
+ * above, and now
+ *	match_indexkey_operand(indkeys, opnd, rel) : \
+ * - vadim 01/22/97
+ */
+
 /*    
  * match_clause_to-indexkey--
  *    Finds the first of a relation's available restriction clauses that
@@ -513,7 +521,13 @@ match_clause_to_indexkey(Rel *rel,
 	    /*
 	     * Must try to commute the clause to standard s-arg format.
 	     */
+#ifdef INDEXSCAN_PATCH
+	    /* ...And here...  - vadim 01/22/97 */ 
+	    else if ((leftop && IsA(leftop,Const)) ||
+			(leftop && IsA(leftop,Param)))
+#else
 	    else if (leftop && IsA(leftop,Const))
+#endif
 		{
 		    restrict_op =
 			get_commutator(((Oper*)((Expr*)clause)->oper)->opno);