Commit 58559ac8 authored by Tor Didriksen's avatar Tor Didriksen

Bug#50888 valgrind warnings in Field_timestamp::val_str

Ensure that we store the correct cached_field_type whenever we cache Field items
(in this case it allows us to compare dates as dates, rather than strings)


mysql-test/r/type_timestamp.result:
  Add test case.
mysql-test/t/type_timestamp.test:
  Add test case.
sql/item.h:
  Initialize cached_field_type from the Field item.
parent 4315b101
......@@ -503,3 +503,19 @@ f1 f2-f3
5 0
DROP TABLE t1;
End of 5.0 tests
Bug#50888 valgrind warnings in Field_timestamp::val_str
SET TIMESTAMP=0;
CREATE TABLE t1(a timestamp);
INSERT INTO t1 VALUES ('2008-02-23 09:23:45'), ('2010-03-05 11:08:02');
FLUSH TABLES t1;
SELECT MAX(a) FROM t1;
MAX(a)
2010-03-05 11:08:02
SELECT a FROM t1;
a
2008-02-23 09:23:45
2010-03-05 11:08:02
DROP TABLE t1;
End of Bug#50888
......@@ -346,3 +346,17 @@ SELECT f1,f2-f3 FROM t1;
DROP TABLE t1;
--echo End of 5.0 tests
--echo
--echo Bug#50888 valgrind warnings in Field_timestamp::val_str
--echo
SET TIMESTAMP=0;
CREATE TABLE t1(a timestamp);
INSERT INTO t1 VALUES ('2008-02-23 09:23:45'), ('2010-03-05 11:08:02');
FLUSH TABLES t1;
SELECT MAX(a) FROM t1;
SELECT a FROM t1;
DROP TABLE t1;
--echo End of Bug#50888
......@@ -3122,14 +3122,16 @@ protected:
bool value_cached;
public:
Item_cache():
example(0), used_table_map(0), cached_field(0), cached_field_type(MYSQL_TYPE_STRING),
example(0), used_table_map(0), cached_field(0),
cached_field_type(MYSQL_TYPE_STRING),
value_cached(0)
{
fixed= 1;
null_value= 1;
}
Item_cache(enum_field_types field_type_arg):
example(0), used_table_map(0), cached_field(0), cached_field_type(field_type_arg),
example(0), used_table_map(0), cached_field(0),
cached_field_type(field_type_arg),
value_cached(0)
{
fixed= 1;
......@@ -3233,10 +3235,9 @@ class Item_cache_str: public Item_cache
public:
Item_cache_str(const Item *item) :
Item_cache(), value(0),
Item_cache(item->field_type()), value(0),
is_varbinary(item->type() == FIELD_ITEM &&
((const Item_field *) item)->field->type() ==
MYSQL_TYPE_VARCHAR &&
cached_field_type == MYSQL_TYPE_VARCHAR &&
!((const Item_field *) item)->field->has_charset())
{}
double val_real();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment