Re: bug report: delete where column <=> null fails when column isindexed

Re: bug report: delete where column <=> null fails when column isindexed

am 21.11.2002 02:42:22 von Jocelyn Fournier

Hi,

Perhaps a more correct patch :

===== opt_range.cc 1.68 vs edited =====
--- 1.68/sql/opt_range.cc Fri Nov 15 08:44:20 2002
+++ edited/opt_range.cc Thu Nov 21 02:41:45 2002
@@ -1029,6 +1029,16 @@
}
DBUG_RETURN(&null_element); // NULL is never
true
}
+ if (type == Item_func::EQUAL_FUNC && value->is_null_result())
+ {
+ /* convert column_name <=> NULL -> column_name IS NULL */
+ // Get local copy of key
+ char *str= (char*) alloc_root(param->mem_root,1);
+ if (!*str)
+ DBUG_RETURN(0);
+ *str = 1;
+ DBUG_RETURN(new SEL_ARG(field,str,str));
+ }
// Get local copy of key
char *str= (char*) alloc_root(param->mem_root,
key_part->part_length+maybe_null);

Regards,
Jocelyn
----- Original Message -----
From: "Jocelyn Fournier"
To: "Alexander Keremidarski" ; ;

Cc:
Sent: Thursday, November 21, 2002 9:55 PM
Subject: Re: bug report: delete where column <=> null fails when column
isindexed


> Hi,
>
> I don't know if it's the proper patch to fix this bug, but at least, it
> works for me :
>
> ===== opt_range.cc 1.68 vs edited =====
> --- 1.68/sql/opt_range.cc Fri Nov 15 08:44:20 2002
> +++ edited/opt_range.cc Wed Nov 20 22:52:13 2002
> @@ -1014,7 +1014,7 @@
> field->cmp_type() != value->result_type())
> DBUG_RETURN(0);
>
> - if (value->save_in_field(field) > 0)
> + if (value->save_in_field(field) > 0 || field->is_null())
> {
> // TODO; Check if we can we remove the following block.
> if (type == Item_func::EQUAL_FUNC)
>
> Regards,
> Jocelyn
> ----- Original Message -----
> From: "Jocelyn Fournier"
> To: "Alexander Keremidarski" ;
> Cc:
> Sent: Wednesday, November 20, 2002 3:10 PM
> Subject: Re: bug report: delete where column <=> null fails when column
> isindexed
>
>
> > Hi,
> >
> > select * from t where id <=> null returns the following :
> >
> > mysql> select * from t where id <=> null;
> > +------+
> > | id |
> > +------+
> > | NULL |
> > +------+
> > 1 row in set (0.00 sec)
> >
> > Then, I don't understand why DELETE FROM t WHERE id <=> NULL should not
> > delete this row ??
> >
> > mysql> DELETE FROM t WHERE id <=> NULL ;
> > Query OK, 0 rows affected (0.00 sec)
> >
> > With MySQL-4.1, when dropping id key, the bug disappears :
> >
> > mysql> ALTER TABLE t DROP KEY id;
> > Query OK, 1 row affected (0.04 sec)
> > Records: 1 Duplicates: 0 Warnings: 0
> >
> > mysql> DELETE FROM t WHERE id <=> NULL ;
> > Query OK, 1 row affected (0.00 sec)
> >
> > select * from t where id <=> null;
> > Empty set (0.00 sec)
> >
> > Regards,
> > Jocelyn


------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail internals-thread5598@lists.mysql.com
To unsubscribe, e-mail