Commit 12fbe241 authored by unknown's avatar unknown

Setting MODE_NO_AUTO_VALUE_ON_ZERO at copying in copy_data_between_tables

parent a64953ed
......@@ -72,6 +72,21 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8
1 100 3 4 5 PENDING 0000-00-00 00:00:00
1 101 3 4 5 PENDING 0000-00-00 00:00:00
2 102 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00
delete from t1;
insert into t1 values (0,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
SET SQL_MODE='';
insert into t1 values (1,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
select * from t1 order by col1;
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
0 0 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00
1 103 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00
alter table t1 drop column col4_5;
insert into t1 values (2,0,4,3,5,"PENDING","EXTRA",'2004-01-01 00:00:00');
select * from t1 order by col1;
col6 col1 col3 fourth col4 col5 col7 col8
0 0 4 3 5 PENDING EXTRA 2004-01-01 00:00:00
1 103 4 3 5 PENDING EXTRA 2004-01-01 00:00:00
2 104 4 3 5 PENDING EXTRA 2004-01-01 00:00:00
drop table t1;
CREATE TABLE t1 (
a INT NOT NULL,
......
......@@ -47,6 +47,14 @@ select * from t1 order by col1;
insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
show table status;
select * from t1 order by col1;
delete from t1;
insert into t1 values (0,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
SET SQL_MODE='';
insert into t1 values (1,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
select * from t1 order by col1;
alter table t1 drop column col4_5;
insert into t1 values (2,0,4,3,5,"PENDING","EXTRA",'2004-01-01 00:00:00');
select * from t1 order by col1;
drop table t1;
......
......@@ -3303,6 +3303,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
List<Item> all_fields;
ha_rows examined_rows;
bool auto_increment_field_copied= 0;
ulong old_sql_mode;
bool no_auto_on_zero;
DBUG_ENTER("copy_data_between_tables");
if (!(copy= new Copy_field[to->fields]))
......@@ -3361,6 +3363,11 @@ copy_data_between_tables(TABLE *from,TABLE *to,
goto err;
}
/* Turn on NO_AUTO_VALUE_ON_ZERO if not already on */
old_sql_mode= thd->variables.sql_mode;
if (!(no_auto_on_zero= thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO))
thd->variables.sql_mode|= MODE_NO_AUTO_VALUE_ON_ZERO;
/* Handler must be told explicitly to retrieve all columns, because
this function does not set field->query_id in the columns to the
current query id */
......@@ -3417,6 +3424,11 @@ copy_data_between_tables(TABLE *from,TABLE *to,
to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
ha_enable_transaction(thd,TRUE);
/* Turn off NO_AUTO_VALUE_ON_ZERO if it was not already off */
if (!no_auto_on_zero)
thd->variables.sql_mode= old_sql_mode;
/*
Ensure that the new table is saved properly to disk so that we
can do a rename
......
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