mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
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.
This commit is contained in:
parent
4315b101f5
commit
58559ac827
3 changed files with 36 additions and 5 deletions
|
@ -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
|
||||
|
|
11
sql/item.h
11
sql/item.h
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue