lp:737458 Casting dates and times into integers works differently in 5.1-micro

better default for Field::cast_to_int_type()
This commit is contained in:
Sergei Golubchik 2011-03-18 14:52:20 +01:00
commit 6998bacfb3
3 changed files with 16 additions and 1 deletions

View file

@ -452,3 +452,9 @@ SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1
1
DROP TABLE t1;
End of 5.1 tests
create table t1 (f1 time, f2 date, f3 datetime);
insert into t1 values ('11:22:33','2011-12-13','2011-12-13 11:22:33');
select cast(f1 as unsigned), cast(f2 as unsigned), cast(f3 as unsigned) from t1;
cast(f1 as unsigned) cast(f2 as unsigned) cast(f3 as unsigned)
112233 20111213 20111213112233
drop table t1;

View file

@ -284,3 +284,12 @@ DROP TABLE t1;
--echo End of 5.1 tests
#
# lp:737458 Casting dates and times into integers works differently in 5.1-micro
#
create table t1 (f1 time, f2 date, f3 datetime);
insert into t1 values ('11:22:33','2011-12-13','2011-12-13 11:22:33');
select cast(f1 as unsigned), cast(f2 as unsigned), cast(f3 as unsigned) from t1;
drop table t1;

View file

@ -149,7 +149,7 @@ public:
virtual bool str_needs_quotes() { return FALSE; }
virtual Item_result result_type () const=0;
virtual Item_result cmp_type () const { return result_type(); }
virtual Item_result cast_to_int_type () const { return result_type(); }
virtual Item_result cast_to_int_type () const { return cmp_type(); }
static bool type_can_have_key_part(enum_field_types);
static enum_field_types field_type_merge(enum_field_types, enum_field_types);
static Item_result result_merge_type(enum_field_types);