mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed bug #29611.
If a primary key is defined over column c of enum type then the EXPLAIN command for a look-up query of the form SELECT * FROM t WHERE c=0 said that the query was with an impossible where condition though the query correctly returned non-empty result set when the table indeed contained rows with error empty strings for column c. This kind of misbehavior was due to a bug in the function Field_enum::store(longlong,bool) that erroneously returned 1 if the the value to be stored was equal to 0. Note that the method Field_enum::store(const char *from,uint length,CHARSET_INFO *cs) correctly returned 0 if a value of the error empty string was stored. mysql-test/r/type_enum.result: Added a test case for bug #29661. mysql-test/t/type_enum.test: Added a test case for bug #29661. sql/field.cc: Fixed bug #29611. If a primary key was defined over column c of enum type then the EXPLAIN command for a look-up query of the form SELECT * FROM t WHERE c=0 said that the query was with an impossible where condition though the query correctly returned non-empty result set when the table indeed contained rows with error empty strings for column c. This kind of misbehavior was due to a bug in the function Field_enum::store(longlong,bool) that erroneously returned 1 if the the value to be stored was equal to 0. Note that the method Field_enum::store(const char *from,uint length,CHARSET_INFO *cs) correctly returned 0 if a value of the error empty string was stored.
This commit is contained in:
@ -200,3 +200,27 @@ CREATE TABLE t2 SELECT * FROM t1;
|
||||
CREATE TABLE t2 SELECT * FROM t1;
|
||||
SELECT c1 + 0 FROM t2;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
#
|
||||
# Bug#29661: Lookup by 0 for a primary index over a enum type
|
||||
#
|
||||
|
||||
CREATE TABLE t1(a enum('a','b','c','d'));
|
||||
INSERT INTO t1 VALUES (4),(1),(0),(3);
|
||||
|
||||
SELECT a FROM t1;
|
||||
|
||||
EXPLAIN SELECT a FROM t1 WHERE a=0;
|
||||
SELECT a FROM t1 WHERE a=0;
|
||||
|
||||
ALTER TABLE t1 ADD PRIMARY KEY (a);
|
||||
|
||||
EXPLAIN SELECT a FROM t1 WHERE a=0;
|
||||
SELECT a FROM t1 WHERE a=0;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user