Loading libmysqld/lib_sql.cc +8 −14 Original line number Diff line number Diff line Loading @@ -69,10 +69,14 @@ void embedded_get_error(MYSQL *mysql) static void emb_free_rows(THD *thd) { if (!thd->data) return; if (thd->current_stmt) free_root(&thd->data->alloc,MYF(0)); else free_rows(thd->data); thd->data= NULL; } Loading @@ -86,11 +90,8 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, THD *thd=(THD *) mysql->thd; NET *net= &mysql->net; if (thd->data) { emb_free_rows(thd); thd->data= 0; } /* Check that we are calling the client functions in right order */ if (mysql->status != MYSQL_STATUS_READY) { Loading Loading @@ -143,13 +144,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, static void emb_flush_use_result(MYSQL *mysql) { MYSQL_DATA *data= ((THD*)(mysql->thd))->data; if (data) { free_rows(data); ((THD*)(mysql->thd))->data= NULL; } emb_free_rows((THD*) (mysql->thd)); } static MYSQL_DATA * Loading Loading @@ -304,7 +299,6 @@ int emb_unbuffered_fetch(MYSQL *mysql, char **row) static void emb_free_embedded_thd(MYSQL *mysql) { THD *thd= (THD*)mysql->thd; if (thd->data) emb_free_rows(thd); thread_count--; delete thd; Loading mysql-test/r/type_datetime.result +3 −0 Original line number Diff line number Diff line Loading @@ -166,3 +166,6 @@ dt 0000-00-00 00:00:00 0000-00-00 00:00:00 drop table t1; select cast('2006-12-05 22:10:10' as datetime) + 0; cast('2006-12-05 22:10:10' as datetime) + 0 20061205221010.000000 mysql-test/t/type_datetime.test +6 −0 Original line number Diff line number Diff line Loading @@ -113,4 +113,10 @@ insert into t1 values ("00-00-00"), ("00-00-00 00:00:00"); select * from t1; drop table t1; # # Bug #16546 DATETIME+0 not always coerced the same way # select cast('2006-12-05 22:10:10' as datetime) + 0; # End of 4.1 tests sql/item_timefunc.h +7 −0 Original line number Diff line number Diff line Loading @@ -751,12 +751,19 @@ class Item_datetime_typecast :public Item_typecast_maybe_null String *val_str(String *str); const char *cast_type() const { return "datetime"; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } void fix_length_and_dec() { Item_typecast_maybe_null::fix_length_and_dec(); decimals= DATETIME_DEC; } Field *tmp_table_field(TABLE *t_arg) { return (new Field_datetime(maybe_null, name, t_arg, &my_charset_bin)); } bool result_as_longlong() { return TRUE; } longlong val_int(); double val() { return (double) val_int(); } }; class Item_func_makedate :public Item_str_func Loading sql/sql_class.cc +6 −8 Original line number Diff line number Diff line Loading @@ -1048,7 +1048,6 @@ bool select_export::send_data(List<Item> &items) } row_count++; Item *item; char *buff_ptr=buff; uint used_length=0,items_left=items.elements; List_iterator_fast<Item> li(items); Loading Loading @@ -1148,20 +1147,19 @@ bool select_export::send_data(List<Item> &items) goto err; } } buff_ptr=buff; // Place separators here if (res && (!exchange->opt_enclosed || result_type == STRING_RESULT)) { memcpy(buff_ptr,exchange->enclosed->ptr(),exchange->enclosed->length()); buff_ptr+=exchange->enclosed->length(); if (my_b_write(&cache, (byte*) exchange->enclosed->ptr(), exchange->enclosed->length())) goto err; } if (--items_left) { memcpy(buff_ptr,exchange->field_term->ptr(),field_term_length); buff_ptr+=field_term_length; } if (my_b_write(&cache,(byte*) buff,(uint) (buff_ptr-buff))) if (my_b_write(&cache, (byte*) exchange->field_term->ptr(), field_term_length)) goto err; } } if (my_b_write(&cache,(byte*) exchange->line_term->ptr(), exchange->line_term->length())) goto err; Loading Loading
libmysqld/lib_sql.cc +8 −14 Original line number Diff line number Diff line Loading @@ -69,10 +69,14 @@ void embedded_get_error(MYSQL *mysql) static void emb_free_rows(THD *thd) { if (!thd->data) return; if (thd->current_stmt) free_root(&thd->data->alloc,MYF(0)); else free_rows(thd->data); thd->data= NULL; } Loading @@ -86,11 +90,8 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, THD *thd=(THD *) mysql->thd; NET *net= &mysql->net; if (thd->data) { emb_free_rows(thd); thd->data= 0; } /* Check that we are calling the client functions in right order */ if (mysql->status != MYSQL_STATUS_READY) { Loading Loading @@ -143,13 +144,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, static void emb_flush_use_result(MYSQL *mysql) { MYSQL_DATA *data= ((THD*)(mysql->thd))->data; if (data) { free_rows(data); ((THD*)(mysql->thd))->data= NULL; } emb_free_rows((THD*) (mysql->thd)); } static MYSQL_DATA * Loading Loading @@ -304,7 +299,6 @@ int emb_unbuffered_fetch(MYSQL *mysql, char **row) static void emb_free_embedded_thd(MYSQL *mysql) { THD *thd= (THD*)mysql->thd; if (thd->data) emb_free_rows(thd); thread_count--; delete thd; Loading
mysql-test/r/type_datetime.result +3 −0 Original line number Diff line number Diff line Loading @@ -166,3 +166,6 @@ dt 0000-00-00 00:00:00 0000-00-00 00:00:00 drop table t1; select cast('2006-12-05 22:10:10' as datetime) + 0; cast('2006-12-05 22:10:10' as datetime) + 0 20061205221010.000000
mysql-test/t/type_datetime.test +6 −0 Original line number Diff line number Diff line Loading @@ -113,4 +113,10 @@ insert into t1 values ("00-00-00"), ("00-00-00 00:00:00"); select * from t1; drop table t1; # # Bug #16546 DATETIME+0 not always coerced the same way # select cast('2006-12-05 22:10:10' as datetime) + 0; # End of 4.1 tests
sql/item_timefunc.h +7 −0 Original line number Diff line number Diff line Loading @@ -751,12 +751,19 @@ class Item_datetime_typecast :public Item_typecast_maybe_null String *val_str(String *str); const char *cast_type() const { return "datetime"; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } void fix_length_and_dec() { Item_typecast_maybe_null::fix_length_and_dec(); decimals= DATETIME_DEC; } Field *tmp_table_field(TABLE *t_arg) { return (new Field_datetime(maybe_null, name, t_arg, &my_charset_bin)); } bool result_as_longlong() { return TRUE; } longlong val_int(); double val() { return (double) val_int(); } }; class Item_func_makedate :public Item_str_func Loading
sql/sql_class.cc +6 −8 Original line number Diff line number Diff line Loading @@ -1048,7 +1048,6 @@ bool select_export::send_data(List<Item> &items) } row_count++; Item *item; char *buff_ptr=buff; uint used_length=0,items_left=items.elements; List_iterator_fast<Item> li(items); Loading Loading @@ -1148,20 +1147,19 @@ bool select_export::send_data(List<Item> &items) goto err; } } buff_ptr=buff; // Place separators here if (res && (!exchange->opt_enclosed || result_type == STRING_RESULT)) { memcpy(buff_ptr,exchange->enclosed->ptr(),exchange->enclosed->length()); buff_ptr+=exchange->enclosed->length(); if (my_b_write(&cache, (byte*) exchange->enclosed->ptr(), exchange->enclosed->length())) goto err; } if (--items_left) { memcpy(buff_ptr,exchange->field_term->ptr(),field_term_length); buff_ptr+=field_term_length; } if (my_b_write(&cache,(byte*) buff,(uint) (buff_ptr-buff))) if (my_b_write(&cache, (byte*) exchange->field_term->ptr(), field_term_length)) goto err; } } if (my_b_write(&cache,(byte*) exchange->line_term->ptr(), exchange->line_term->length())) goto err; Loading