summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorigor@olga.mysql.com <>2007-07-22 18:26:16 -0700
committerigor@olga.mysql.com <>2007-07-22 18:26:16 -0700
commit54f3949a27940b68886fead2dfcec0efdc97dd18 (patch)
tree8638b7ea7fd40550d394c0c24efe37926c8b09be /sql/field.cc
parent7402fd6e79491c572579d7f0d7e07f603a73f381 (diff)
downloadmariadb-git-54f3949a27940b68886fead2dfcec0efdc97dd18.tar.gz
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.
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 993c1fb3c4f..4a1320af48c 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -7640,8 +7640,11 @@ int Field_enum::store(longlong nr, bool unsigned_val)
if ((ulonglong) nr > typelib->count || nr == 0)
{
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
- nr=0;
- error=1;
+ if (nr != 0 || table->in_use->count_cuted_fields)
+ {
+ nr= 0;
+ error= 1;
+ }
}
store_type((ulonglong) (uint) nr);
return error;