Commits

Marc Fournier committed a7cfd65

Fixes:

Select queries with an isnull or notnull clause, like "select * where
somefield isnull", crash the backend if the table has at least one index.
If the indices are deleted the queries work again. Also the explain
command fail in the same way.
The is caused by a bug in subroutine of the optimizer which doesn't check
null values in the clauses.

Submitted by: Massimo Dal Zotto <dz@cs.unitn.it>

Comments (0)

Files changed (2)

src/backend/optimizer/path/indxpath.c

  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.1.1.1 1996/07/09 06:21:35 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.2 1996/07/19 07:13:26 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 	    /*
 	     * Check for standard s-argable clause
 	     */
-	    if (IsA(rightop,Const))
+	    if (rightop && IsA(rightop,Const))
 		{
 		    restrict_op = ((Oper*)((Expr*)clause)->oper)->opno;
 		    isIndexable =
 	    /*
 	     * Must try to commute the clause to standard s-arg format.
 	     */
-	    else if (IsA(leftop,Const))
+	    else if (leftop && IsA(leftop,Const))
 		{
 		    restrict_op =
 			get_commutator(((Oper*)((Expr*)clause)->oper)->opno);
      */
     else
 	{
-	    if (match_index_to_operand(indexkey,(Expr*)rightop,rel,index)) {
+	    if (rightop
+		&& match_index_to_operand(indexkey,(Expr*)rightop,rel,index)) {
 					
 		join_op = get_commutator(((Oper*)((Expr*)clause)->oper)->opno);
 
-	    } else if (match_index_to_operand(indexkey,
-					      (Expr*)leftop,rel,index)) {
+	    } else if (leftop
+		       && match_index_to_operand(indexkey,
+						 (Expr*)leftop,rel,index)) {
 		join_op = ((Oper*)((Expr*)clause)->oper)->opno;
 	    }
 

src/backend/utils/adt/varlena.c

  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.2 1996/07/19 06:08:21 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.3 1996/07/19 07:14:14 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 /* ========== PUBLIC ROUTINES ========== */
 
-/* 
-
 /*
  * textlen -
  *    returns the actual length of a text* (which may be less than