List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:September 29 2010 3:48pm
Subject:Re: bzr commit into mysql-5.1-bugteam branch
(nirbhay.choubey:3519) Bug#44771
View as plain text  
Hi Nirbhay,

good catch! I approve this fix.

Please note that this bug is unlikely ok to go into 5.1. Check with Staale
and/or Joro what is the proper tree for this bugfix.

Regards,
Sergey

On Mon, Sep 27, 2010 at 02:08:00PM +0000, Nirbhay Choubey wrote:
> #At file:///home/nirbhay/Project/mysql/repo/wl/mysql-5.1-bugteam/ based on
> revid:davi.arnaut@stripped
> 
>  3519 Nirbhay Choubey	2010-09-27
>       Bug#44771 : Unique Hash index in memory engine will give wrong query result
> for
>                    NULL value.
>       
>       In a memory table when there are more than one NULL values for a unique key
>       column using HASH index, a search for NULL on that column returns just one
>       row.
>       
>       In memory engine, while reading a hash key which is NULL, it doesn't get
> copied
>       to info->lastkey, which inturn is used to search next records.
>       
>       Fixed by adding the condition to check for NULL key, which lets copying of key
>       to info->lastkey.
>      @ mysql-test/r/heap_hash.result
>         Bug#44771 : Unique Hash index in memory engine will give wrong query result
> for
>                      NULL value.
>      @ mysql-test/t/heap_hash.test
>         Bug#44771 : Unique Hash index in memory engine will give wrong query result
> for
>                      NULL value.
>      @ storage/heap/hp_rkey.c
>         Bug#44771 : Unique Hash index in memory engine will give wrong query result
> for
>                      NULL value.
>         
>         Modified the condition to check for NULL key which is checked before copying
> key
>         to info->lastkey in heap_rkey function. info->lastkey is further used
> by
>         heap_rnext to search for the records with the same key.
> 
>     modified:
>       mysql-test/r/heap_hash.result
>       mysql-test/t/heap_hash.test
>       storage/heap/hp_rkey.c
> === modified file 'mysql-test/r/heap_hash.result'
> --- a/mysql-test/r/heap_hash.result	2007-05-31 12:04:58 +0000
> +++ b/mysql-test/r/heap_hash.result	2010-09-27 14:07:48 +0000
> @@ -382,3 +382,24 @@ INSERT INTO t1 VALUES('A ', 'A ');
>  ERROR 23000: Duplicate entry 'A -A ' for key 'key1'
>  DROP TABLE t1;
>  End of 5.0 tests
> +#
> +# Bug #44771: Unique Hash index in memory engine will give wrong
> +#             query result for NULL value.
> +#
> +CREATE TABLE t1
> +(
> +pk INT PRIMARY KEY,
> +val INT,
> +UNIQUE KEY USING HASH(val)
> +) ENGINE=MEMORY;
> +INSERT INTO t1 VALUES (1, NULL);
> +INSERT INTO t1 VALUES (2, NULL);
> +INSERT INTO t1 VALUES (3, NULL);
> +INSERT INTO t1 VALUES (4, NULL);
> +SELECT * FROM t1 WHERE val IS NULL;
> +pk	val
> +4	NULL
> +3	NULL
> +2	NULL
> +1	NULL
> +DROP TABLE t1;
> 
> === modified file 'mysql-test/t/heap_hash.test'
> --- a/mysql-test/t/heap_hash.test	2007-06-06 17:57:07 +0000
> +++ b/mysql-test/t/heap_hash.test	2010-09-27 14:07:48 +0000
> @@ -284,3 +284,23 @@ INSERT INTO t1 VALUES('A ', 'A ');
>  DROP TABLE t1;
>  
>  --echo End of 5.0 tests
> +
> +--echo #
> +--echo # Bug #44771: Unique Hash index in memory engine will give wrong
> +--echo #             query result for NULL value.
> +--echo #
> +
> +CREATE TABLE t1
> +(
> +  pk INT PRIMARY KEY,
> +  val INT,
> +  UNIQUE KEY USING HASH(val)
> +) ENGINE=MEMORY;
> +
> +INSERT INTO t1 VALUES (1, NULL);
> +INSERT INTO t1 VALUES (2, NULL);
> +INSERT INTO t1 VALUES (3, NULL);
> +INSERT INTO t1 VALUES (4, NULL);
> +
> +SELECT * FROM t1 WHERE val IS NULL;
> +DROP TABLE t1;
> 
> === modified file 'storage/heap/hp_rkey.c'
> --- a/storage/heap/hp_rkey.c	2007-05-10 09:59:39 +0000
> +++ b/storage/heap/hp_rkey.c	2010-09-27 14:07:48 +0000
> @@ -63,7 +63,8 @@ int heap_rkey(HP_INFO *info, uchar *reco
>        info->update= 0;
>        DBUG_RETURN(my_errno);
>      }
> -    if (!(keyinfo->flag & HA_NOSAME) || (keyinfo->flag &
> HA_END_SPACE_KEY))
> +    if (!(keyinfo->flag & HA_NOSAME) || (keyinfo->flag &
> HA_END_SPACE_KEY) ||
> +        (keyinfo->flag & HA_NULL_PART_KEY))
>        memcpy(info->lastkey, key, (size_t) keyinfo->length);
>    }
>    memcpy(record, pos, (size_t) share->reclength);
> 


> 
> -- 
> MySQL Code Commits Mailing List
> For list archives: http://lists.mysql.com/commits
> To unsubscribe:    http://lists.mysql.com/commits?unsub=1


-- 
Sergey Vojtovich <svoj@stripped>
MySQL AB, Software Engineer
Izhevsk, Russia, www.mysql.com
Thread
bzr commit into mysql-5.1-bugteam branch (nirbhay.choubey:3519)Bug#44771Nirbhay Choubey27 Sep
  • Re: bzr commit into mysql-5.1-bugteam branch(nirbhay.choubey:3519) Bug#44771Sergey Vojtovich29 Sep