diff options
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index b991215d30a..c29394ed88d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -18,6 +18,7 @@ /* drop and alter of tables */ +#include <my_global.h> #include "sql_priv.h" #include "unireg.h" #include "debug_sync.h" @@ -3025,10 +3026,6 @@ int prepare_create_field(Create_field *sql_field, (sql_field->decimals << FIELDFLAG_DEC_SHIFT)); break; } - if (sql_field->flags & NOT_NULL_FLAG) - DBUG_PRINT("info", ("1")); - if (sql_field->vcol_info) - DBUG_PRINT("info", ("2")); if (!(sql_field->flags & NOT_NULL_FLAG) || (sql_field->vcol_info)) /* Make virtual columns allow NULL values */ sql_field->pack_flag|= FIELDFLAG_MAYBE_NULL; @@ -8713,6 +8710,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, */ altered_table->column_bitmaps_set_no_signal(&altered_table->s->all_set, &altered_table->s->all_set); + restore_record(altered_table, s->default_values); // Create empty record + if (altered_table->default_field && altered_table->update_default_fields()) + goto err_new_table_cleanup; // Ask storage engine whether to use copy or in-place enum_alter_inplace_result inplace_supported= @@ -9338,14 +9338,14 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, to->use_all_columns(); to->mark_virtual_columns_for_write(TRUE); if (init_read_record(&info, thd, from, (SQL_SELECT *) 0, 1, 1, FALSE)) - { - error= 1; goto err; - } + if (ignore && !alter_ctx->fk_error_if_delete_row) to->file->extra(HA_EXTRA_IGNORE_DUP_KEY); thd->get_stmt_da()->reset_current_row_for_warning(); restore_record(to, s->default_values); // Create empty record + if (to->default_field && to->update_default_fields()) + goto err; thd->progress.max_counter= from->file->records(); time_to_report_progress= MY_HOW_OFTEN_TO_WRITE/10; @@ -9388,11 +9388,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, prev_insert_id= to->file->next_insert_id; if (to->vfield) update_virtual_fields(thd, to, VCOL_UPDATE_FOR_WRITE); - if (to->default_field && to->update_default_fields()) - { - error= 1; - break; - } if (thd->is_error()) { error= 1; |