Bug #33256: CREATE ... SELECT creates obsolete table

 w/ Field_date instead of Field_newdate
  
Field_date was still used in temp table creation.
Fixed by using Field_newdate consistently throughout the server
except when reading tables defined with older MySQL version.
No test suite is possible because both Field_date and Field_newdate
return the same values in all the metadata calls. 
parent 284d8c71
...@@ -786,10 +786,6 @@ from (select 1 as s,'t' as t union select null, null ) as sub1; ...@@ -786,10 +786,6 @@ from (select 1 as s,'t' as t union select null, null ) as sub1;
select group_concat(t) from t1 group by week(date)/10; select group_concat(t) from t1 group by week(date)/10;
group_concat(t) group_concat(t)
t t
Warnings:
Warning 1292 Truncated incorrect datetime value: '0000-00-00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00'
drop table t1; drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
qty decimal(16,6) default NULL, qty decimal(16,6) default NULL,
......
...@@ -961,6 +961,10 @@ public: ...@@ -961,6 +961,10 @@ public:
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg, :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg, cs) unireg_check_arg, field_name_arg, table_arg, cs)
{} {}
Field_newdate(bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg, CHARSET_INFO *cs)
:Field_str((char*) 0,10, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg, cs) {}
enum_field_types type() const { return FIELD_TYPE_DATE;} enum_field_types type() const { return FIELD_TYPE_DATE;}
enum_field_types real_type() const { return FIELD_TYPE_NEWDATE; } enum_field_types real_type() const { return FIELD_TYPE_NEWDATE; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; }
......
...@@ -4384,7 +4384,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table) ...@@ -4384,7 +4384,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table)
name, table, 0, unsigned_flag); name, table, 0, unsigned_flag);
case MYSQL_TYPE_NEWDATE: case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_DATE: case MYSQL_TYPE_DATE:
return new Field_date(maybe_null, name, table, &my_charset_bin); return new Field_newdate(maybe_null, name, table, &my_charset_bin);
case MYSQL_TYPE_TIME: case MYSQL_TYPE_TIME:
return new Field_time(maybe_null, name, table, &my_charset_bin); return new Field_time(maybe_null, name, table, &my_charset_bin);
case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
......
...@@ -628,7 +628,7 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table, ...@@ -628,7 +628,7 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table,
*/ */
switch (args[0]->field_type()) { switch (args[0]->field_type()) {
case MYSQL_TYPE_DATE: case MYSQL_TYPE_DATE:
return new Field_date(maybe_null, name, table, collation.collation); return new Field_newdate(maybe_null, name, table, collation.collation);
case MYSQL_TYPE_TIME: case MYSQL_TYPE_TIME:
return new Field_time(maybe_null, name, table, collation.collation); return new Field_time(maybe_null, name, table, collation.collation);
case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
......
...@@ -3303,7 +3303,7 @@ Field *Item_func_str_to_date::tmp_table_field(TABLE *t_arg) ...@@ -3303,7 +3303,7 @@ Field *Item_func_str_to_date::tmp_table_field(TABLE *t_arg)
if (cached_field_type == MYSQL_TYPE_TIME) if (cached_field_type == MYSQL_TYPE_TIME)
return (new Field_time(maybe_null, name, t_arg, &my_charset_bin)); return (new Field_time(maybe_null, name, t_arg, &my_charset_bin));
if (cached_field_type == MYSQL_TYPE_DATE) if (cached_field_type == MYSQL_TYPE_DATE)
return (new Field_date(maybe_null, name, t_arg, &my_charset_bin)); return (new Field_newdate(maybe_null, name, t_arg, &my_charset_bin));
if (cached_field_type == MYSQL_TYPE_DATETIME) if (cached_field_type == MYSQL_TYPE_DATETIME)
return (new Field_datetime(maybe_null, name, t_arg, &my_charset_bin)); return (new Field_datetime(maybe_null, name, t_arg, &my_charset_bin));
return (new Field_string(max_length, maybe_null, name, t_arg, &my_charset_bin)); return (new Field_string(max_length, maybe_null, name, t_arg, &my_charset_bin));
......
...@@ -340,7 +340,7 @@ public: ...@@ -340,7 +340,7 @@ public:
} }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (new Field_date(maybe_null, name, t_arg, &my_charset_bin)); return (new Field_newdate(maybe_null, name, t_arg, &my_charset_bin));
} }
bool result_as_longlong() { return TRUE; } bool result_as_longlong() { return TRUE; }
my_decimal *val_decimal(my_decimal *decimal_value) my_decimal *val_decimal(my_decimal *decimal_value)
...@@ -784,7 +784,7 @@ public: ...@@ -784,7 +784,7 @@ public:
enum_field_types field_type() const { return MYSQL_TYPE_DATE; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (new Field_date(maybe_null, name, t_arg, &my_charset_bin)); return (new Field_newdate(maybe_null, name, t_arg, &my_charset_bin));
} }
void fix_length_and_dec() void fix_length_and_dec()
{ {
...@@ -884,7 +884,7 @@ public: ...@@ -884,7 +884,7 @@ public:
} }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (new Field_date(maybe_null, name, t_arg, &my_charset_bin)); return (new Field_newdate(maybe_null, name, t_arg, &my_charset_bin));
} }
longlong val_int(); longlong val_int();
my_decimal *val_decimal(my_decimal *decimal_value) my_decimal *val_decimal(my_decimal *decimal_value)
......
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