Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-04-07 00:13:27+04:00, evgen@stripped +3 -0
Bug#27586: Wrong autoinc value assigned by LOAD DATA in the
NO_AUTO_VALUE_ON_ZERO mode.
The table->auto_increment_field_not_null variable wasn't reset after
reading a row which may lead to inserting a wrong value to the auto-increment
field to the following row.
The table->auto_increment_field_not_null variable is reset now right after a
row is being written in the read_fixed_length() and the read_sep_field()
functions.
Removed wrong setting of the table->auto_increment_field_not_null variable in
the read_sep_field() function.
mysql-test/r/loaddata.result@stripped, 2007-04-07 00:10:58+04:00, evgen@stripped +9 -0
Added a test case for the bug#27586: Wrong autoinc value assigned by LOAD DATA in the
NO_AUTO_VALUE_ON_ZERO mode.
mysql-test/t/loaddata.test@stripped, 2007-04-07 00:10:56+04:00, evgen@stripped +16 -0
Added a test case for the bug#27586: Wrong autoinc value assigned by LOAD DATA in the
NO_AUTO_VALUE_ON_ZERO mode.
sql/sql_load.cc@stripped, 2007-04-07 00:11:45+04:00, evgen@stripped +8 -7
Bug#27586: Wrong autoinc value assigned by LOAD DATA in the
NO_AUTO_VALUE_ON_ZERO mode.
The table->auto_increment_field_not_null variable is reset now right after a
row is being written in the read_fixed_length() and the read_sep_field()
functions.
Remove wrong setting of the table->auto_increment_field_not_null variable in
the read_sep_field() function.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: evgen
# Host: moonbone.local
# Root: /mnt/gentoo64/work/27586-bug-5.0-opt-mysql
--- 1.110/sql/sql_load.cc 2007-03-30 18:09:33 +04:00
+++ 1.111/sql/sql_load.cc 2007-04-07 00:11:45 +04:00
@@ -532,7 +532,7 @@
Item_field *sql_field;
TABLE *table= table_list->table;
ulonglong id;
- bool no_trans_update;
+ bool no_trans_update, err;
DBUG_ENTER("read_fixed_length");
id= 0;
@@ -624,7 +624,9 @@
DBUG_RETURN(-1);
}
- if (write_record(thd, table, &info))
+ err= write_record(thd, table, &info);
+ table->auto_increment_field_not_null= FALSE;
+ if (err)
DBUG_RETURN(1);
thd->no_trans_update= no_trans_update;
@@ -669,7 +671,7 @@
TABLE *table= table_list->table;
uint enclosed_length;
ulonglong id;
- bool no_trans_update;
+ bool no_trans_update, err;
DBUG_ENTER("read_sep_field");
enclosed_length=enclosed.length();
@@ -716,8 +718,6 @@
DBUG_RETURN(1);
}
field->set_null();
- if (field == table->next_number_field)
- table->auto_increment_field_not_null= TRUE;
if (!field->maybe_null())
{
if (field->type() == FIELD_TYPE_TIMESTAMP)
@@ -803,8 +803,9 @@
DBUG_RETURN(-1);
}
-
- if (write_record(thd, table, &info))
+ err= write_record(thd, table, &info);
+ table->auto_increment_field_not_null= FALSE;
+ if (err)
DBUG_RETURN(1);
/*
If auto_increment values are used, save the first one for
--- 1.26/mysql-test/r/loaddata.result 2007-03-16 21:56:11 +03:00
+++ 1.27/mysql-test/r/loaddata.result 2007-04-07 00:10:58 +04:00
@@ -156,3 +156,12 @@
load_file("MYSQL_TEST_DIR/t/loaddata.test")
NULL
drop table t1, t2;
+create table t1(f1 int);
+insert into t1 values(1),(null);
+create table t2(f2 int auto_increment primary key);
+select * from t2;
+f2
+1
+2
+SET @@SQL_MODE=@OLD_SQL_MODE;
+drop table t1,t2;
--- 1.20/mysql-test/t/loaddata.test 2007-03-16 21:56:11 +03:00
+++ 1.21/mysql-test/t/loaddata.test 2007-04-07 00:10:56 +04:00
@@ -136,4 +136,20 @@
# cleanup
drop table t1, t2;
+#
+# Bug#27586: Wrong autoinc value assigned by LOAD DATA in the
+# NO_AUTO_VALUE_ON_ZERO mode
+#
+create table t1(f1 int);
+insert into t1 values(1),(null);
+create table t2(f2 int auto_increment primary key);
+disable_query_log;
+eval select * into outfile '$MYSQLTEST_VARDIR/tmp/t1' from t1;
+SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
+eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t2;
+enable_query_log;
+select * from t2;
+--exec rm $MYSQLTEST_VARDIR/tmp/t1
+SET @@SQL_MODE=@OLD_SQL_MODE;
+drop table t1,t2;
# End of 5.0 tests
Thread |
---|
• bk commit into 5.0 tree (evgen:1.2432) BUG#27586 | eugene | 6 Apr |