mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
Fix for MDEV-533: Confusing error code when doing auto-increment insert for out-of-range values
create table t1 (a smallint primary key auto_increment); insert into t1 values(32767); insert into t1 values(NULL); ERROR 1062 (23000): Duplicate entry '32767' for key 'PRIMARY Now on always gets error HA_ERR_AUTOINC_RANGE=167 "Out of range value for column", independent of store engine, SQL Mode or number of inserted rows. This is an unique error that is easier to test for in replication. Another bug fix is that we now get an error when trying to insert a too big auto-generated value, even in non-strict mode. Before one get insted the max column value inserted. This patch also fixes some issues with inserting negative numbers in an auto-increment column. Fixed the ER_DUP_ENTRY and HA_ERR_AUTOINC_ERANGE are compared the same between master and slave. This ensures that replication works between an old server to a new slave for auto-increment overflow errors. Added SQLSTATE errors for handler errors Smaller bug fixes: * Added warnings for duplicate key errors when using INSERT IGNORE * Fixed bug when using --skip-log-bin followed by --log-bin, which did set log-bin to "0" * Allow one to see how cmake is called by using --just-print --just-configure BUILD/FINISH.sh: --just-print --just-configure now shows how cmake would be invoked. Good for understanding parameters to cmake. cmake/configure.pl: --just-print --just-configure now shows how cmake would be invoked. Good for understanding parameters to cmake. include/CMakeLists.txt: Added handler_state.h include/handler_state.h: SQLSTATE for handler error messages. Required for HA_ERR_AUTOINC_ERANGE, but solves also some other cases. mysql-test/extra/binlog_tests/binlog.test: Fixed old wrong behaviour Added more tests mysql-test/extra/binlog_tests/binlog_insert_delayed.test: Reset binary log to only print what's necessary in show_binlog_events mysql-test/extra/rpl_tests/rpl_auto_increment.test: Update to new error codes mysql-test/extra/rpl_tests/rpl_insert_delayed.test: Ignore warnings as this depends on how the test is run mysql-test/include/strict_autoinc.inc: On now gets an error on overflow mysql-test/r/auto_increment.result: Update results after fixing error message mysql-test/r/auto_increment_ranges_innodb.result: Test new behaviour mysql-test/r/auto_increment_ranges_myisam.result: Test new behaviour mysql-test/r/commit_1innodb.result: Added warnings for duplicate key error mysql-test/r/create.result: Added warnings for duplicate key error mysql-test/r/insert.result: Added warnings for duplicate key error mysql-test/r/insert_select.result: Added warnings for duplicate key error mysql-test/r/insert_update.result: Added warnings for duplicate key error mysql-test/r/mix2_myisam.result: Added warnings for duplicate key error mysql-test/r/myisam_mrr.result: Added warnings for duplicate key error mysql-test/r/null_key.result: Added warnings for duplicate key error mysql-test/r/replace.result: Update to new error codes mysql-test/r/strict_autoinc_1myisam.result: Update to new error codes mysql-test/r/strict_autoinc_2innodb.result: Update to new error codes mysql-test/r/strict_autoinc_3heap.result: Update to new error codes mysql-test/r/trigger.result: Added warnings for duplicate key error mysql-test/r/xtradb_mrr.result: Added warnings for duplicate key error mysql-test/suite/binlog/r/binlog_innodb_row.result: Updated result mysql-test/suite/binlog/r/binlog_row_binlog.result: Out of range data for auto-increment is not inserted anymore mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result: Updated result mysql-test/suite/binlog/r/binlog_stm_binlog.result: Out of range data for auto-increment is not inserted anymore mysql-test/suite/binlog/r/binlog_unsafe.result: Updated result mysql-test/suite/innodb/r/innodb-autoinc.result: Update to new error codes mysql-test/suite/innodb/r/innodb-lock.result: Updated results mysql-test/suite/innodb/r/innodb.result: Updated results mysql-test/suite/innodb/r/innodb_bug56947.result: Updated results mysql-test/suite/innodb/r/innodb_mysql.result: Updated results mysql-test/suite/innodb/t/innodb-autoinc.test: Update to new error codes mysql-test/suite/maria/maria3.result: Updated result mysql-test/suite/maria/mrr.result: Updated result mysql-test/suite/optimizer_unfixed_bugs/r/bug43617.result: Updated result mysql-test/suite/rpl/r/rpl_auto_increment.result: Update to new error codes mysql-test/suite/rpl/r/rpl_insert_delayed,stmt.rdiff: Updated results mysql-test/suite/rpl/r/rpl_loaddatalocal.result: Updated results mysql-test/t/auto_increment.test: Update to new error codes mysql-test/t/auto_increment_ranges.inc: Test new behaviour mysql-test/t/auto_increment_ranges_innodb.test: Test new behaviour mysql-test/t/auto_increment_ranges_myisam.test: Test new behaviour mysql-test/t/replace.test: Update to new error codes mysys/my_getopt.c: Fixed bug when using --skip-log-bin followed by --log-bin, which did set log-bin to "0" sql/handler.cc: Ignore negative values for signed auto-increment columns Always give an error if we get an overflow for an auto-increment-column (instead of inserting the max value) Ensure that the row number is correct for the out-of-range-value error message. ****** Fixed wrong printing of column namn for "Out of range value" errors Fixed that INSERT_ID is correctly replicated also for out-of-range autoincrement values Fixed that print_keydup_error() can also be used to generate warnings ****** Return HA_ERR_AUTOINC_ERANGE (167) instead of ER_WARN_DATA_OUT_OF_RANGE for auto-increment overflow sql/handler.h: Allow INSERT IGNORE to continue also after out-of-range inserts. Fixed that print_keydup_error() can also be used to generate warnings sql/log_event.cc: Added DBUG_PRINT Fixed the ER_AUTOINC_READ_FAILED, ER_DUP_ENTRY and HA_ERR_AUTOINC_ERANGE are compared the same between master and slave. This ensures that replication works between an old server to a new slave for auto-increment overflow errors. sql/sql_insert.cc: Add warnings for duplicate key errors when using INSERT IGNORE sql/sql_state.c: Added handler errors sql/sql_table.cc: Update call to print_keydup_error() storage/innobase/handler/ha_innodb.cc: Fixed increment handling of auto-increment columns to be consistent with rest of MariaDB. storage/xtradb/handler/ha_innodb.cc: Fixed increment handling of auto-increment columns to be consistent with rest of MariaDB.
This commit is contained in:
parent
32e4c7e138
commit
ae5bc05988
57 changed files with 1227 additions and 172 deletions
|
@ -21,6 +21,12 @@ extra_configs="$extra_configs $local_infile_configs $EXTRA_CONFIGS"
|
|||
|
||||
configure="./configure $base_configs $extra_configs"
|
||||
|
||||
if test "$just_print" = "1" -a "$just_configure" = "1"
|
||||
then
|
||||
just_print=""
|
||||
configure="$configure --print"
|
||||
fi
|
||||
|
||||
commands="\
|
||||
/bin/rm -rf configure;
|
||||
/bin/rm -rf CMakeCache.txt CMakeFiles/
|
||||
|
|
|
@ -25,6 +25,7 @@ my $cmakeargs = "";
|
|||
# Assume this script is in <srcroot>/cmake
|
||||
my $srcdir = dirname(dirname(abs_path($0)));
|
||||
my $cmake_install_prefix="";
|
||||
my $just_print= 0;
|
||||
|
||||
# Sets installation directory, bindir, libdir, libexecdir etc
|
||||
# the equivalent CMake variables are given without prefix
|
||||
|
@ -113,6 +114,11 @@ foreach my $option (@ARGV)
|
|||
system("cmake ${srcdir} -LH");
|
||||
exit(0);
|
||||
}
|
||||
if ($option =~ /print/)
|
||||
{
|
||||
$just_print=1;
|
||||
next;
|
||||
}
|
||||
if($option =~ /with-plugins=/)
|
||||
{
|
||||
my @plugins= split(/,/, substr($option,13));
|
||||
|
@ -223,6 +229,7 @@ foreach my $option (@ARGV)
|
|||
}
|
||||
|
||||
print("configure.pl : calling cmake $srcdir $cmakeargs\n");
|
||||
exit(0) if ($just_print);
|
||||
unlink("CMakeCache.txt");
|
||||
my $rc = system("cmake $srcdir $cmakeargs");
|
||||
exit($rc);
|
||||
|
|
|
@ -51,6 +51,7 @@ SET(HEADERS
|
|||
m_ctype.h
|
||||
my_attribute.h
|
||||
my_compiler.h
|
||||
handler_state.h
|
||||
)
|
||||
|
||||
INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development)
|
||||
|
|
21
include/handler_state.h
Normal file
21
include/handler_state.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
Map handler error message to sql states. Note that this list MUST be in
|
||||
increasing order!
|
||||
See sql_state.c for usage
|
||||
*/
|
||||
|
||||
{ HA_ERR_KEY_NOT_FOUND, "02000", "" },
|
||||
{ HA_ERR_FOUND_DUPP_KEY, "23000", "" },
|
||||
{ HA_ERR_WRONG_COMMAND, "0A000", "" },
|
||||
{ HA_ERR_UNSUPPORTED, "0A000", "" },
|
||||
{ HA_WRONG_CREATE_OPTION, "0A000", "" },
|
||||
{ HA_ERR_FOUND_DUPP_UNIQUE, "23000", "" },
|
||||
{ HA_ERR_UNKNOWN_CHARSET, "0A000", "" },
|
||||
{ HA_ERR_READ_ONLY_TRANSACTION, "25000", "" },
|
||||
{ HA_ERR_LOCK_DEADLOCK, "40001", "" },
|
||||
{ HA_ERR_NO_REFERENCED_ROW, "23000", "" },
|
||||
{ HA_ERR_ROW_IS_REFERENCED, "23000", "" },
|
||||
{ HA_ERR_TABLE_EXIST, "42S01", "" },
|
||||
{ HA_ERR_FOREIGN_DUPLICATE_KEY, "23000", "" },
|
||||
{ HA_ERR_TABLE_READONLY, "25000", "" },
|
||||
{ HA_ERR_AUTOINC_ERANGE, "22003", "" },
|
|
@ -205,16 +205,55 @@ DROP PROCEDURE p4;
|
|||
|
||||
--echo End of 5.0 tests
|
||||
|
||||
# Test of a too big SET INSERT_ID: see if the truncated value goes
|
||||
# into binlog (right), or the too big value (wrong); we look at the
|
||||
# binlog further down with SHOW BINLOG EVENTS.
|
||||
# Test of a too big SET INSERT_ID.
|
||||
# This should generate an error and should not be put in binlog
|
||||
# We look at the binlog further down with SHOW BINLOG EVENTS.
|
||||
|
||||
reset master;
|
||||
create table t1 (id tinyint auto_increment primary key);
|
||||
insert into t1 values(5);
|
||||
set insert_id=128;
|
||||
insert into t1 values(null);
|
||||
--error 167
|
||||
insert into t1 values(null) /* Not binlogged */;
|
||||
|
||||
# The followin insert ignore will be put in binlog
|
||||
set insert_id=128;
|
||||
insert ignore into t1 values(null) /* Insert 128 */;
|
||||
|
||||
# Insert with duplicate key error should not go into binglo
|
||||
set insert_id=5;
|
||||
--error ER_DUP_ENTRY
|
||||
insert into t1 values(null) /* Not binlogged */;
|
||||
|
||||
# Insert with autogenerated key + duplicate key error should go into binlog
|
||||
set insert_id=5;
|
||||
insert ignore into t1 values(null) /* Insert 5 */;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
# Same tests but with 2 rows inserted at a time
|
||||
|
||||
create table t1 (id tinyint auto_increment primary key) engine=myisam;
|
||||
set insert_id=128;
|
||||
--error 167
|
||||
insert into t1 values(5),(null) /* Insert_id 128 */;
|
||||
|
||||
# The followin insert ignore will be put in binlog
|
||||
set insert_id=128;
|
||||
insert ignore into t1 values (4),(null) /* Insert_id 128 */;
|
||||
|
||||
# Insert with duplicate key error should not go into binglo
|
||||
set insert_id=5;
|
||||
--error ER_DUP_ENTRY
|
||||
insert into t1 values(3),(null) /* Insert_id 5 */;
|
||||
|
||||
# Insert with autogenerated key + duplicate key error should go into binlog
|
||||
set insert_id=5;
|
||||
insert ignore into t1 values(2),(null) /* Insert_id 5 */;
|
||||
select * from t1 order by id;
|
||||
drop table t1;
|
||||
|
||||
|
||||
# bug#22027
|
||||
create table t1 (a int);
|
||||
create table if not exists t2 select * from t1;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
# BUG#20627: INSERT DELAYED does not honour auto_increment_* variables
|
||||
# Bug in this test: BUG#38068: binlog_stm_binlog fails sporadically in pushbuild
|
||||
|
||||
reset master;
|
||||
|
||||
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ set auto_increment_increment=11;
|
|||
set auto_increment_offset=4;
|
||||
insert into t1 values(null);
|
||||
insert into t1 values(null);
|
||||
--error ER_DUP_ENTRY
|
||||
--error 167
|
||||
insert into t1 values(null);
|
||||
select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t1 order by a;
|
||||
|
||||
|
@ -120,6 +120,8 @@ create table t2 (a tinyint unsigned not null auto_increment primary key) engine=
|
|||
set auto_increment_increment=10;
|
||||
set auto_increment_offset=1;
|
||||
set insert_id=1000;
|
||||
insert into t2 values(10);
|
||||
--error 167
|
||||
insert into t2 values(null);
|
||||
select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t2 order by a;
|
||||
|
||||
|
@ -127,6 +129,7 @@ select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t2 orde
|
|||
create table t3 like t1;
|
||||
set auto_increment_increment=1000;
|
||||
set auto_increment_offset=700;
|
||||
--error 167
|
||||
insert into t3 values(null);
|
||||
select * from t3 order by a;
|
||||
sync_slave_with_master;
|
||||
|
|
|
@ -102,7 +102,9 @@ CREATE TABLE t1(a int, UNIQUE(a));
|
|||
--let $_start= query_get_value(SHOW MASTER STATUS, Position, 1)
|
||||
|
||||
INSERT DELAYED IGNORE INTO t1 VALUES(1);
|
||||
--disable_warnings
|
||||
INSERT DELAYED IGNORE INTO t1 VALUES(1);
|
||||
--enable_warnings
|
||||
flush table t1; # to wait for INSERT DELAYED to be done
|
||||
if (`SELECT @@global.binlog_format = 'STATEMENT'`)
|
||||
{
|
||||
|
|
|
@ -19,11 +19,12 @@ select count(*) from t1;
|
|||
|
||||
set auto_increment_increment=1000;
|
||||
set auto_increment_offset=700;
|
||||
--error ER_WARN_DATA_OUT_OF_RANGE
|
||||
--error 167
|
||||
insert into t1 values(null);
|
||||
select count(*) from t1;
|
||||
|
||||
set @@sql_mode=@org_mode;
|
||||
--error 167
|
||||
insert into t1 values(null);
|
||||
select * from t1;
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ select last_insert_id();
|
|||
last_insert_id()
|
||||
255
|
||||
insert into t1 set i = null;
|
||||
ERROR 23000: Duplicate entry '255' for key 'PRIMARY'
|
||||
ERROR 22003: Out of range value for column 'i' at row 1
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
|
@ -162,8 +162,7 @@ select last_insert_id();
|
|||
last_insert_id()
|
||||
255
|
||||
insert into t1 set i = null;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'i' at row 1
|
||||
ERROR 22003: Out of range value for column 'i' at row 1
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
|
@ -487,7 +486,7 @@ SELECT @@SESSION.AUTO_INCREMENT_OFFSET;
|
|||
@@SESSION.AUTO_INCREMENT_OFFSET
|
||||
1
|
||||
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
|
||||
ERROR 22003: Out of range value for column 't1' at row 167
|
||||
ERROR 22003: Out of range value for column 'c1' at row 2
|
||||
SELECT * FROM t1;
|
||||
c1
|
||||
1
|
||||
|
|
266
mysql-test/r/auto_increment_ranges_innodb.result
Normal file
266
mysql-test/r/auto_increment_ranges_innodb.result
Normal file
|
@ -0,0 +1,266 @@
|
|||
set default_storage_engine=innodb;
|
||||
drop table if exists t1;
|
||||
#
|
||||
# Testing ranges with smallint
|
||||
#
|
||||
create table t1 (a smallint primary key auto_increment);
|
||||
insert into t1 values(32767);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
truncate table t1;
|
||||
insert into t1 values(32767-1);
|
||||
insert into t1 values(NULL);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
32766
|
||||
32767
|
||||
truncate table t1;
|
||||
insert into t1 values(32767),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 2
|
||||
select * from t1;
|
||||
a
|
||||
truncate table t1;
|
||||
insert into t1 values(32767-1),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(32767+1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
32767
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
||||
#
|
||||
# Testing ranges with unsigned smallint
|
||||
#
|
||||
create table t1 (a smallint unsigned primary key auto_increment);
|
||||
insert into t1 values(65535);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
truncate table t1;
|
||||
insert into t1 values(65535-1);
|
||||
insert into t1 values(NULL);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
65534
|
||||
65535
|
||||
truncate table t1;
|
||||
insert into t1 values(65535),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 2
|
||||
select * from t1;
|
||||
a
|
||||
truncate table t1;
|
||||
insert into t1 values(65535-1),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(65535+1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
65535
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
||||
#
|
||||
# Testing ranges with integer
|
||||
#
|
||||
create table t1 (a int primary key auto_increment);
|
||||
insert into t1 values(2147483647);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
truncate table t1;
|
||||
insert into t1 values(2147483647-1);
|
||||
insert into t1 values(NULL);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
2147483646
|
||||
2147483647
|
||||
truncate table t1;
|
||||
insert into t1 values(2147483647),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 2
|
||||
select * from t1;
|
||||
a
|
||||
truncate table t1;
|
||||
insert into t1 values(2147483647-1),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(2147483647+1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
2147483647
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
||||
#
|
||||
# Testing ranges with unsigned integer
|
||||
#
|
||||
create table t1 (a int unsigned primary key auto_increment);
|
||||
insert into t1 values(4294967295);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
truncate table t1;
|
||||
insert into t1 values(4294967295-1);
|
||||
insert into t1 values(NULL);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
4294967294
|
||||
4294967295
|
||||
truncate table t1;
|
||||
insert into t1 values(4294967295),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 2
|
||||
select * from t1;
|
||||
a
|
||||
truncate table t1;
|
||||
insert into t1 values(4294967295-1),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(4294967295+1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
4294967295
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
||||
#
|
||||
# Testing ranges with bigint
|
||||
#
|
||||
create table t1 (a bigint primary key auto_increment);
|
||||
insert into t1 values(cast(9223372036854775807 as unsigned));
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
truncate table t1;
|
||||
insert into t1 values(cast(9223372036854775807 as unsigned)-1);
|
||||
insert into t1 values(NULL);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
9223372036854775806
|
||||
9223372036854775807
|
||||
truncate table t1;
|
||||
insert into t1 values(cast(9223372036854775807 as unsigned)),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 2
|
||||
select * from t1;
|
||||
a
|
||||
truncate table t1;
|
||||
insert into t1 values(cast(9223372036854775807 as unsigned)-1),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(cast(9223372036854775807 as unsigned)+1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
9223372036854775807
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
||||
#
|
||||
# Testing ranges with unsigned bigint
|
||||
#
|
||||
create table t1 (a bigint unsigned primary key auto_increment);
|
||||
insert into t1 values(18446744073709551615-1);
|
||||
insert into t1 values(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
insert into t1 values(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
truncate table t1;
|
||||
insert into t1 values(18446744073709551615-1);
|
||||
insert into t1 values(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
insert into t1 values(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
select * from t1;
|
||||
a
|
||||
18446744073709551614
|
||||
truncate table t1;
|
||||
insert into t1 values(18446744073709551615),(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
select * from t1;
|
||||
a
|
||||
truncate table t1;
|
||||
insert into t1 values(18446744073709551615-1),(NULL),(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
drop table t1;
|
||||
#
|
||||
# Test IGNORE and strict mode
|
||||
#
|
||||
create table t1 (a smallint primary key auto_increment);
|
||||
insert ignore into t1 values(32766),(NULL),(NULL),(1);
|
||||
Warnings:
|
||||
Warning 167 Out of range value for column 'a' at row 3
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
32766
|
||||
32767
|
||||
truncate table t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
set @@sql_mode='ansi,traditional';
|
||||
insert ignore into t1 values(32766),(NULL),(NULL);
|
||||
Warnings:
|
||||
Warning 167 Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(32766),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
set @@sql_mode=@org_mode;
|
||||
drop table t1;
|
||||
#
|
||||
# Test auto increment with negative numbers
|
||||
#
|
||||
CREATE TABLE t1 (a INTEGER AUTO_INCREMENT, PRIMARY KEY (a));
|
||||
INSERT INTO t1 VALUES (NULL), (2), (-5), (NULL);
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
-5
|
||||
1
|
||||
2
|
||||
3
|
||||
5
|
||||
TRUNCATE TABLE t1;
|
||||
INSERT INTO t1 VALUES (-5), (NULL);
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
-5
|
||||
1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Test inserting a value out-of-range into an auto increment column
|
||||
#
|
||||
CREATE TABLE t1 (a smallint AUTO_INCREMENT, PRIMARY KEY (a));
|
||||
INSERT INTO t1 VALUES (2);
|
||||
INSERT INTO t1 VALUES (32768);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
2
|
||||
32767
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Test old behaviour
|
||||
#
|
||||
create table t1 (a smallint primary key auto_increment);
|
||||
insert into t1 values(32766),(NULL);
|
||||
delete from t1 where a=32767;
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
272
mysql-test/r/auto_increment_ranges_myisam.result
Normal file
272
mysql-test/r/auto_increment_ranges_myisam.result
Normal file
|
@ -0,0 +1,272 @@
|
|||
set default_storage_engine=MYISAM;
|
||||
drop table if exists t1;
|
||||
#
|
||||
# Testing ranges with smallint
|
||||
#
|
||||
create table t1 (a smallint primary key auto_increment);
|
||||
insert into t1 values(32767);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
truncate table t1;
|
||||
insert into t1 values(32767-1);
|
||||
insert into t1 values(NULL);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
32766
|
||||
32767
|
||||
truncate table t1;
|
||||
insert into t1 values(32767),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 2
|
||||
select * from t1;
|
||||
a
|
||||
32767
|
||||
truncate table t1;
|
||||
insert into t1 values(32767-1),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(32767+1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
32767
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
||||
#
|
||||
# Testing ranges with unsigned smallint
|
||||
#
|
||||
create table t1 (a smallint unsigned primary key auto_increment);
|
||||
insert into t1 values(65535);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
truncate table t1;
|
||||
insert into t1 values(65535-1);
|
||||
insert into t1 values(NULL);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
65534
|
||||
65535
|
||||
truncate table t1;
|
||||
insert into t1 values(65535),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 2
|
||||
select * from t1;
|
||||
a
|
||||
65535
|
||||
truncate table t1;
|
||||
insert into t1 values(65535-1),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(65535+1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
65535
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
||||
#
|
||||
# Testing ranges with integer
|
||||
#
|
||||
create table t1 (a int primary key auto_increment);
|
||||
insert into t1 values(2147483647);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
truncate table t1;
|
||||
insert into t1 values(2147483647-1);
|
||||
insert into t1 values(NULL);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
2147483646
|
||||
2147483647
|
||||
truncate table t1;
|
||||
insert into t1 values(2147483647),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 2
|
||||
select * from t1;
|
||||
a
|
||||
2147483647
|
||||
truncate table t1;
|
||||
insert into t1 values(2147483647-1),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(2147483647+1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
2147483647
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
||||
#
|
||||
# Testing ranges with unsigned integer
|
||||
#
|
||||
create table t1 (a int unsigned primary key auto_increment);
|
||||
insert into t1 values(4294967295);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
truncate table t1;
|
||||
insert into t1 values(4294967295-1);
|
||||
insert into t1 values(NULL);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
4294967294
|
||||
4294967295
|
||||
truncate table t1;
|
||||
insert into t1 values(4294967295),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 2
|
||||
select * from t1;
|
||||
a
|
||||
4294967295
|
||||
truncate table t1;
|
||||
insert into t1 values(4294967295-1),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(4294967295+1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
4294967295
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
||||
#
|
||||
# Testing ranges with bigint
|
||||
#
|
||||
create table t1 (a bigint primary key auto_increment);
|
||||
insert into t1 values(cast(9223372036854775807 as unsigned));
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
truncate table t1;
|
||||
insert into t1 values(cast(9223372036854775807 as unsigned)-1);
|
||||
insert into t1 values(NULL);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
9223372036854775806
|
||||
9223372036854775807
|
||||
truncate table t1;
|
||||
insert into t1 values(cast(9223372036854775807 as unsigned)),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 2
|
||||
select * from t1;
|
||||
a
|
||||
9223372036854775807
|
||||
truncate table t1;
|
||||
insert into t1 values(cast(9223372036854775807 as unsigned)-1),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(cast(9223372036854775807 as unsigned)+1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
9223372036854775807
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
||||
#
|
||||
# Testing ranges with unsigned bigint
|
||||
#
|
||||
create table t1 (a bigint unsigned primary key auto_increment);
|
||||
insert into t1 values(18446744073709551615-1);
|
||||
insert into t1 values(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
insert into t1 values(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
truncate table t1;
|
||||
insert into t1 values(18446744073709551615-1);
|
||||
insert into t1 values(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
insert into t1 values(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
select * from t1;
|
||||
a
|
||||
18446744073709551614
|
||||
truncate table t1;
|
||||
insert into t1 values(18446744073709551615),(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
select * from t1;
|
||||
a
|
||||
18446744073709551615
|
||||
truncate table t1;
|
||||
insert into t1 values(18446744073709551615-1),(NULL),(NULL);
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
drop table t1;
|
||||
#
|
||||
# Test IGNORE and strict mode
|
||||
#
|
||||
create table t1 (a smallint primary key auto_increment);
|
||||
insert ignore into t1 values(32766),(NULL),(NULL),(1);
|
||||
Warnings:
|
||||
Warning 167 Out of range value for column 'a' at row 3
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
32766
|
||||
32767
|
||||
truncate table t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
set @@sql_mode='ansi,traditional';
|
||||
insert ignore into t1 values(32766),(NULL),(NULL);
|
||||
Warnings:
|
||||
Warning 167 Out of range value for column 'a' at row 3
|
||||
truncate table t1;
|
||||
insert into t1 values(32766),(NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 3
|
||||
set @@sql_mode=@org_mode;
|
||||
drop table t1;
|
||||
#
|
||||
# Test auto increment with negative numbers
|
||||
#
|
||||
CREATE TABLE t1 (a INTEGER AUTO_INCREMENT, PRIMARY KEY (a));
|
||||
INSERT INTO t1 VALUES (NULL), (2), (-5), (NULL);
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
-5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
TRUNCATE TABLE t1;
|
||||
INSERT INTO t1 VALUES (-5), (NULL);
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
-5
|
||||
1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Test inserting a value out-of-range into an auto increment column
|
||||
#
|
||||
CREATE TABLE t1 (a smallint AUTO_INCREMENT, PRIMARY KEY (a));
|
||||
INSERT INTO t1 VALUES (2);
|
||||
INSERT INTO t1 VALUES (32768);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
2
|
||||
32767
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Test old behaviour
|
||||
#
|
||||
create table t1 (a smallint primary key auto_increment);
|
||||
insert into t1 values(32766),(NULL);
|
||||
delete from t1 where a=32767;
|
||||
insert into t1 values(NULL);
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
drop table t1;
|
|
@ -529,6 +529,8 @@ SUCCESS
|
|||
# 13. Read-write statement: INSERT IGNORE, change 0 rows.
|
||||
#
|
||||
insert ignore t1 set a=2;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '2' for key 'a'
|
||||
call p_verify_status_increment(2, 2, 1, 0);
|
||||
SUCCESS
|
||||
|
||||
|
|
|
@ -2396,6 +2396,8 @@ a b
|
|||
drop table t1;
|
||||
create table if not exists t1 (a int unique, b int)
|
||||
ignore select 1 as a, 1 as b union select 1 as a, 2 as b;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '1' for key 'a'
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
|
|
|
@ -327,9 +327,11 @@ select row_count();
|
|||
row_count()
|
||||
3
|
||||
insert ignore into t1 values (1, 1);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
|
||||
select row_count();
|
||||
row_count()
|
||||
0
|
||||
-1
|
||||
replace into t1 values (1, 11);
|
||||
select row_count();
|
||||
row_count()
|
||||
|
@ -371,7 +373,15 @@ drop table t1,t2;
|
|||
create table t1 (id int primary key auto_increment, data int, unique(data));
|
||||
insert ignore into t1 values(NULL,100),(NULL,110),(NULL,120);
|
||||
insert ignore into t1 values(NULL,10),(NULL,20),(NULL,110),(NULL,120),(NULL,100),(NULL,90);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '110' for key 'data'
|
||||
Warning 1062 Duplicate entry '120' for key 'data'
|
||||
Warning 1062 Duplicate entry '100' for key 'data'
|
||||
insert ignore into t1 values(NULL,130),(NULL,140),(500,110),(550,120),(450,100),(NULL,150);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '110' for key 'data'
|
||||
Warning 1062 Duplicate entry '120' for key 'data'
|
||||
Warning 1062 Duplicate entry '100' for key 'data'
|
||||
select * from t1 order by id;
|
||||
id data
|
||||
1 100
|
||||
|
|
|
@ -6,6 +6,10 @@ insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
|
|||
insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
||||
ERROR 23000: Duplicate entry '16' for key 'PRIMARY'
|
||||
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '16' for key 'PRIMARY'
|
||||
Warning 1062 Duplicate entry '16' for key 'PRIMARY'
|
||||
Warning 1062 Duplicate entry '22' for key 'PRIMARY'
|
||||
select * from t2;
|
||||
payoutID
|
||||
1
|
||||
|
|
|
@ -172,11 +172,15 @@ DROP TABLE t2;
|
|||
create table t1 (a int not null unique) engine=myisam;
|
||||
insert into t1 values (1),(2);
|
||||
insert ignore into t1 select 1 on duplicate key update a=2;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '2' for key 'a'
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
insert ignore into t1 select a from t1 as t2 on duplicate key update a=t1.a+1 ;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '2' for key 'a'
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
|
|
|
@ -702,6 +702,8 @@ id
|
|||
2
|
||||
99
|
||||
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '1-1' for key 'PRIMARY'
|
||||
commit;
|
||||
select id,id3 from t1;
|
||||
id id3
|
||||
|
|
|
@ -278,6 +278,8 @@ bb-1 NULL cc-2 NULL-1
|
|||
drop table t1, t2, t3, t4;
|
||||
create table t1 (a int, b int not null,unique key (a,b),index(b));
|
||||
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '6-6' for key 'a'
|
||||
create table t2 like t1;
|
||||
insert into t2 select * from t1;
|
||||
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
drop table if exists t1,t2;
|
||||
create table t1 (a int, b int not null,unique key (a,b),index(b)) engine=myisam;
|
||||
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '6-6' for key 'a'
|
||||
explain select * from t1 where a is null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 3 Using where; Using index
|
||||
|
|
|
@ -13,9 +13,9 @@ drop table t1;
|
|||
create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
|
||||
insert into t1 values (126,"first"),(63, "middle"),(0,"last");
|
||||
insert into t1 values (0,"error");
|
||||
ERROR 23000: Duplicate entry '127' for key 'PRIMARY'
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
replace into t1 values (0,"error");
|
||||
ERROR 23000: Duplicate entry '127' for key 'PRIMARY'
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
replace into t1 values (126,"first updated");
|
||||
replace into t1 values (63,default);
|
||||
select * from t1;
|
||||
|
|
|
@ -20,9 +20,7 @@ count(*)
|
|||
0
|
||||
set @@sql_mode=@org_mode;
|
||||
insert into t1 values(null);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
127
|
||||
drop table t1;
|
||||
|
|
|
@ -20,9 +20,7 @@ count(*)
|
|||
0
|
||||
set @@sql_mode=@org_mode;
|
||||
insert into t1 values(null);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
127
|
||||
drop table t1;
|
||||
|
|
|
@ -20,9 +20,7 @@ count(*)
|
|||
0
|
||||
set @@sql_mode=@org_mode;
|
||||
insert into t1 values(null);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t1;
|
||||
a
|
||||
127
|
||||
drop table t1;
|
||||
|
|
|
@ -165,6 +165,8 @@ select @log;
|
|||
(BEFORE_INSERT: new=(id=1, data=1))(AFTER_INSERT: new=(id=1, data=1))
|
||||
set @log:= "";
|
||||
insert ignore t1 values (1, 2);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
|
||||
select @log;
|
||||
@log
|
||||
(BEFORE_INSERT: new=(id=1, data=2))
|
||||
|
|
|
@ -276,6 +276,8 @@ bb-1 NULL cc-2 NULL-1
|
|||
drop table t1, t2, t3, t4;
|
||||
create table t1 (a int, b int not null,unique key (a,b),index(b));
|
||||
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '6-6' for key 'a'
|
||||
create table t2 like t1;
|
||||
insert into t2 select * from t1;
|
||||
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
|
||||
|
|
|
@ -69,6 +69,8 @@ INSERT INTO t1 VALUES (1);
|
|||
START TRANSACTION;
|
||||
INSERT INTO t2 VALUES (1);
|
||||
INSERT IGNORE INTO t1 VALUES (1);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
|
||||
COMMIT;
|
||||
INSERT INTO t1 VALUES (2);
|
||||
START TRANSACTION;
|
||||
|
|
|
@ -578,13 +578,46 @@ DROP PROCEDURE p4;
|
|||
End of 5.0 tests
|
||||
reset master;
|
||||
create table t1 (id tinyint auto_increment primary key);
|
||||
insert into t1 values(5);
|
||||
set insert_id=128;
|
||||
insert into t1 values(null);
|
||||
insert into t1 values(null) /* Not binlogged */;
|
||||
ERROR 22003: Out of range value for column 'id' at row 1
|
||||
set insert_id=128;
|
||||
insert ignore into t1 values(null) /* Insert 128 */;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'id' at row 1
|
||||
Warning 167 Out of range value for column 'id' at row 1
|
||||
set insert_id=5;
|
||||
insert into t1 values(null) /* Not binlogged */;
|
||||
ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
|
||||
set insert_id=5;
|
||||
insert ignore into t1 values(null) /* Insert 5 */;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '5' for key 'PRIMARY'
|
||||
select * from t1;
|
||||
id
|
||||
127
|
||||
5
|
||||
drop table t1;
|
||||
create table t1 (id tinyint auto_increment primary key) engine=myisam;
|
||||
set insert_id=128;
|
||||
insert into t1 values(5),(null) /* Insert_id 128 */;
|
||||
ERROR 22003: Out of range value for column 'id' at row 2
|
||||
set insert_id=128;
|
||||
insert ignore into t1 values (4),(null) /* Insert_id 128 */;
|
||||
Warnings:
|
||||
Warning 167 Out of range value for column 'id' at row 2
|
||||
set insert_id=5;
|
||||
insert into t1 values(3),(null) /* Insert_id 5 */;
|
||||
ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
|
||||
set insert_id=5;
|
||||
insert ignore into t1 values(2),(null) /* Insert_id 5 */;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '5' for key 'PRIMARY'
|
||||
select * from t1 order by id;
|
||||
id
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
create table if not exists t2 select * from t1;
|
||||
|
@ -603,6 +636,24 @@ master-bin.000001 # Table_map # # table_id: # (test.t1)
|
|||
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key) engine=myisam
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
||||
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
||||
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
||||
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
||||
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (a int)
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Query # # use `test`; CREATE TABLE IF NOT EXISTS `t2` (
|
||||
|
@ -625,6 +676,7 @@ master-bin.000001 # Table_map # # table_id: # (mysql.user)
|
|||
master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
drop table t1,t2,t3,tt1;
|
||||
reset master;
|
||||
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
|
||||
insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
|
||||
insert /*! delayed */ into t1 values (null);
|
||||
|
@ -632,35 +684,6 @@ insert delayed into t1 values (300);
|
|||
FLUSH TABLES;
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key)
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
||||
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (a int)
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Query # # use `test`; CREATE TABLE IF NOT EXISTS `t2` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
)
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # use `test`; CREATE TABLE IF NOT EXISTS `t3` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
)
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (mysql.user)
|
||||
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (mysql.user)
|
||||
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (mysql.user)
|
||||
master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `tt1` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE `t1`,`t2`,`t3` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
reset master;
|
||||
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
|
||||
insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
|
||||
insert /*! delayed */ into t1 values (null);
|
||||
|
@ -5,9 +6,6 @@ insert delayed into t1 values (300);
|
|||
FLUSH TABLES;
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Query # # use `mtr`; INSERT INTO test_suppressions (pattern) VALUES ( NAME_CONST('pattern',_latin1'Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT' COLLATE 'latin1_swedish_ci'))
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Query # # use `test`; insert /* before delayed */ /* after delayed */ into t1 values (207)
|
||||
|
|
|
@ -387,13 +387,46 @@ DROP PROCEDURE p4;
|
|||
End of 5.0 tests
|
||||
reset master;
|
||||
create table t1 (id tinyint auto_increment primary key);
|
||||
insert into t1 values(5);
|
||||
set insert_id=128;
|
||||
insert into t1 values(null);
|
||||
insert into t1 values(null) /* Not binlogged */;
|
||||
ERROR 22003: Out of range value for column 'id' at row 1
|
||||
set insert_id=128;
|
||||
insert ignore into t1 values(null) /* Insert 128 */;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'id' at row 1
|
||||
Warning 167 Out of range value for column 'id' at row 1
|
||||
set insert_id=5;
|
||||
insert into t1 values(null) /* Not binlogged */;
|
||||
ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
|
||||
set insert_id=5;
|
||||
insert ignore into t1 values(null) /* Insert 5 */;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '5' for key 'PRIMARY'
|
||||
select * from t1;
|
||||
id
|
||||
127
|
||||
5
|
||||
drop table t1;
|
||||
create table t1 (id tinyint auto_increment primary key) engine=myisam;
|
||||
set insert_id=128;
|
||||
insert into t1 values(5),(null) /* Insert_id 128 */;
|
||||
ERROR 22003: Out of range value for column 'id' at row 2
|
||||
set insert_id=128;
|
||||
insert ignore into t1 values (4),(null) /* Insert_id 128 */;
|
||||
Warnings:
|
||||
Warning 167 Out of range value for column 'id' at row 2
|
||||
set insert_id=5;
|
||||
insert into t1 values(3),(null) /* Insert_id 5 */;
|
||||
ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
|
||||
set insert_id=5;
|
||||
insert ignore into t1 values(2),(null) /* Insert_id 5 */;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '5' for key 'PRIMARY'
|
||||
select * from t1 order by id;
|
||||
id
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
create table if not exists t2 select * from t1;
|
||||
|
@ -408,8 +441,33 @@ show binlog events from <binlog_start>;
|
|||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key)
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Intvar # # INSERT_ID=127
|
||||
master-bin.000001 # Query # # use `test`; insert into t1 values(null)
|
||||
master-bin.000001 # Query # # use `test`; insert into t1 values(5)
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Intvar # # INSERT_ID=128
|
||||
master-bin.000001 # Query # # use `test`; insert ignore into t1 values(null) /* Insert 128 */
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Intvar # # INSERT_ID=5
|
||||
master-bin.000001 # Query # # use `test`; insert ignore into t1 values(null) /* Insert 5 */
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key) engine=myisam
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Intvar # # INSERT_ID=128
|
||||
master-bin.000001 # Query # # use `test`; insert into t1 values(5),(null) /* Insert_id 128 */
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Intvar # # INSERT_ID=128
|
||||
master-bin.000001 # Query # # use `test`; insert ignore into t1 values (4),(null) /* Insert_id 128 */
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Intvar # # INSERT_ID=5
|
||||
master-bin.000001 # Query # # use `test`; insert into t1 values(3),(null) /* Insert_id 5 */
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Intvar # # INSERT_ID=5
|
||||
master-bin.000001 # Query # # use `test`; insert ignore into t1 values(2),(null) /* Insert_id 5 */
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (a int)
|
||||
|
@ -426,6 +484,7 @@ master-bin.000001 # Query # # BEGIN
|
|||
master-bin.000001 # Query # # use `mysql`; DELETE FROM user WHERE host='localhost' AND user='@#@'
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
drop table t1,t2,t3,tt1;
|
||||
reset master;
|
||||
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
|
||||
insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
|
||||
insert /*! delayed */ into t1 values (null);
|
||||
|
@ -433,27 +492,6 @@ insert delayed into t1 values (300);
|
|||
FLUSH TABLES;
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key)
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Intvar # # INSERT_ID=127
|
||||
master-bin.000001 # Query # # use `test`; insert into t1 values(null)
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (a int)
|
||||
master-bin.000001 # Query # # use `test`; create table if not exists t2 select * from t1
|
||||
master-bin.000001 # Query # # use `test`; create temporary table tt1 (a int)
|
||||
master-bin.000001 # Query # # use `test`; create table if not exists t3 like tt1
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Query # # use `mysql`; INSERT INTO user SET host='localhost', user='@#@', password=password('Just a test')
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Query # # use `mysql`; UPDATE user SET password=password('Another password') WHERE host='localhost' AND user='@#@'
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Query # # use `mysql`; DELETE FROM user WHERE host='localhost' AND user='@#@'
|
||||
master-bin.000001 # Query # # COMMIT
|
||||
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE `tt1` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE `t1`,`t2`,`t3` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
||||
|
|
|
@ -2682,6 +2682,7 @@ CREATE TABLE insert_2_keys (a INT UNIQUE KEY, b INT UNIQUE KEY);
|
|||
INSERT INTO insert_2_keys values (1, 1);
|
||||
INSERT IGNORE INTO insert_table SELECT * FROM filler_table;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT IGNORE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave.
|
||||
TRUNCATE TABLE insert_table;
|
||||
INSERT INTO insert_table SELECT * FROM filler_table ON DUPLICATE KEY UPDATE a = 1;
|
||||
|
|
|
@ -2,7 +2,7 @@ drop table if exists t1;
|
|||
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (9223372036854775807, null);
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
Got one of the listed errors
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
9223372036854775807 NULL
|
||||
|
@ -10,7 +10,7 @@ DROP TABLE t1;
|
|||
CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (127, null);
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
Got one of the listed errors
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
127 NULL
|
||||
|
@ -18,7 +18,7 @@ DROP TABLE t1;
|
|||
CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (255, null);
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
Got one of the listed errors
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
255 NULL
|
||||
|
@ -26,7 +26,7 @@ DROP TABLE t1;
|
|||
CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (32767, null);
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
Got one of the listed errors
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
32767 NULL
|
||||
|
@ -34,7 +34,7 @@ DROP TABLE t1;
|
|||
CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (65535, null);
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
Got one of the listed errors
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
65535 NULL
|
||||
|
@ -42,7 +42,7 @@ DROP TABLE t1;
|
|||
CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (8388607, null);
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
Got one of the listed errors
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
8388607 NULL
|
||||
|
@ -50,7 +50,7 @@ DROP TABLE t1;
|
|||
CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (16777215, null);
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
Got one of the listed errors
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
16777215 NULL
|
||||
|
@ -58,7 +58,7 @@ DROP TABLE t1;
|
|||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (2147483647, null);
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
Got one of the listed errors
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
2147483647 NULL
|
||||
|
@ -66,7 +66,7 @@ DROP TABLE t1;
|
|||
CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (4294967295, null);
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
Got one of the listed errors
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
4294967295 NULL
|
||||
|
@ -74,7 +74,7 @@ DROP TABLE t1;
|
|||
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (9223372036854775807, null);
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
Got one of the listed errors
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
9223372036854775807 NULL
|
||||
|
@ -567,7 +567,7 @@ Variable_name Value
|
|||
auto_increment_increment 65535
|
||||
auto_increment_offset 65535
|
||||
INSERT INTO t1 VALUES (NULL),(NULL);
|
||||
ERROR 22003: Out of range value for column 't1' at row 167
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
SELECT * FROM t1;
|
||||
c1
|
||||
1
|
||||
|
@ -858,7 +858,7 @@ PRIMARY KEY) ENGINE=InnoDB;
|
|||
INSERT INTO t2 SELECT c1 FROM t1;
|
||||
Got one of the listed errors
|
||||
INSERT INTO t2 SELECT NULL FROM t1;
|
||||
Got one of the listed errors
|
||||
ERROR 22003: Out of range value for column 'c1' at row 1
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
|
|
|
@ -98,8 +98,12 @@ CREATE TABLE t1 (a INT PRIMARY KEY, b INT NOT NULL) ENGINE=InnoDB;
|
|||
INSERT INTO t1 VALUES(3,1);
|
||||
BEGIN;
|
||||
INSERT IGNORE INTO t1 VALUES(3,14);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '3' for key 'PRIMARY'
|
||||
BEGIN;
|
||||
INSERT IGNORE INTO t1 VALUES(3,23);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '3' for key 'PRIMARY'
|
||||
SELECT * FROM t1 FOR UPDATE;
|
||||
COMMIT;
|
||||
a b
|
||||
|
|
|
@ -816,6 +816,8 @@ id
|
|||
1
|
||||
2
|
||||
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '1-1' for key 'PRIMARY'
|
||||
commit;
|
||||
select id,id3 from t1;
|
||||
id id3
|
||||
|
|
|
@ -3,6 +3,6 @@ SET GLOBAL innodb_file_per_table=0;
|
|||
create table bug56947(a int not null) engine = innodb;
|
||||
CREATE TABLE `bug56947#1`(a int) ENGINE=InnoDB;
|
||||
alter table bug56947 add unique index (a);
|
||||
ERROR HY000: Table 'test.bug56947#1' already exists
|
||||
ERROR 42S01: Table 'test.bug56947#1' already exists
|
||||
drop table `bug56947#1`;
|
||||
drop table bug56947;
|
||||
|
|
|
@ -1480,10 +1480,15 @@ k a c
|
|||
1 6 2
|
||||
2 7 NULL
|
||||
insert ignore into t2 values (null,6,1),(10,8,1);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '6' for key 'idx_1'
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
0
|
||||
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '6' for key 'idx_1'
|
||||
Warning 1062 Duplicate entry '8' for key 'idx_1'
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
11
|
||||
|
|
|
@ -11,7 +11,7 @@ drop table if exists t1;
|
|||
#
|
||||
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (9223372036854775807, null);
|
||||
-- error ER_DUP_ENTRY,1062
|
||||
-- error 167
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
@ -22,14 +22,14 @@ DROP TABLE t1;
|
|||
# TINYINT
|
||||
CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (127, null);
|
||||
-- error ER_DUP_ENTRY,1062
|
||||
-- error 167
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (255, null);
|
||||
-- error ER_DUP_ENTRY,1062
|
||||
-- error 167
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
@ -38,14 +38,14 @@ DROP TABLE t1;
|
|||
#
|
||||
CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (32767, null);
|
||||
-- error ER_DUP_ENTRY,1062
|
||||
-- error 167
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (65535, null);
|
||||
-- error ER_DUP_ENTRY,1062
|
||||
-- error 167
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
@ -54,14 +54,14 @@ DROP TABLE t1;
|
|||
#
|
||||
CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (8388607, null);
|
||||
-- error ER_DUP_ENTRY,1062
|
||||
-- error 167
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (16777215, null);
|
||||
-- error ER_DUP_ENTRY,1062
|
||||
-- error 167
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
@ -70,14 +70,14 @@ DROP TABLE t1;
|
|||
#
|
||||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (2147483647, null);
|
||||
-- error ER_DUP_ENTRY,1062
|
||||
-- error 167
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (4294967295, null);
|
||||
-- error ER_DUP_ENTRY,1062
|
||||
-- error 167
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
@ -86,7 +86,7 @@ DROP TABLE t1;
|
|||
#
|
||||
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (9223372036854775807, null);
|
||||
-- error ER_DUP_ENTRY,1062
|
||||
-- error 167
|
||||
INSERT INTO t1 (c2) VALUES ('innodb');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
@ -349,7 +349,7 @@ INSERT INTO t1 VALUES (18446744073709551610); #-- 2^64 - 2
|
|||
SELECT * FROM t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
--error ER_WARN_DATA_OUT_OF_RANGE
|
||||
--error 167
|
||||
INSERT INTO t1 VALUES (NULL),(NULL);
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
@ -437,7 +437,7 @@ CREATE TABLE t2(
|
|||
PRIMARY KEY) ENGINE=InnoDB;
|
||||
-- error ER_DUP_ENTRY,1062
|
||||
INSERT INTO t2 SELECT c1 FROM t1;
|
||||
-- error ER_DUP_ENTRY,1467
|
||||
-- error 167
|
||||
INSERT INTO t2 SELECT NULL FROM t1;
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
|
|
|
@ -452,6 +452,8 @@ SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
|
|||
CREATE TABLE t1 (id int(11) PRIMARY KEY auto_increment,f1 varchar(10) NOT NULL UNIQUE);
|
||||
INSERT IGNORE INTO t1 (f1) VALUES ("test1");
|
||||
INSERT IGNORE INTO t1 (f1) VALUES ("test1");
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry 'test1' for key 'f1'
|
||||
INSERT IGNORE INTO t1 (f1) VALUES ("test2");
|
||||
SELECT * FROM t1;
|
||||
id f1
|
||||
|
|
|
@ -277,6 +277,8 @@ bb-1 NULL cc-2 NULL-1
|
|||
drop table t1, t2, t3, t4;
|
||||
create table t1 (a int, b int not null,unique key (a,b),index(b));
|
||||
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '6-6' for key 'a'
|
||||
create table t2 like t1;
|
||||
insert into t2 select * from t1;
|
||||
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
|
||||
|
|
|
@ -38,7 +38,11 @@ c1 c2 c3 c4
|
|||
2008-01-01 00:00:00 NULL 2008-01-02 2008-01-03 00:00:00
|
||||
2009-01-29 11:11:27 2009-01-29 00:00:00 2009-01-29 2009-01-29 00:00:00
|
||||
INSERT IGNORE INTO t1(c1,c2) VALUES('20070525','20070527') /* doesnt throw error */;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '2007-05-25 00:00:00' for key 'PRIMARY'
|
||||
INSERT IGNORE INTO t1(c1,c2) VALUES(19840905,830907) /* doesnt throw error */;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '1983-09-07 00:00:00' for key 'c2'
|
||||
SELECT * FROM t1 WHERE c1='20070527' /* Returns no rows */;
|
||||
c1 c2 c3 c4
|
||||
INSERT INTO t1(c1) VALUES('20070525') ON DUPLICATE KEY UPDATE c1='20070527';
|
||||
|
|
|
@ -125,6 +125,10 @@ insert into t1 values(600),(NULL),(NULL);
|
|||
ERROR 23000: Duplicate entry '600' for key 'PRIMARY'
|
||||
set @@insert_id=600;
|
||||
insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL);
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '600' for key 'PRIMARY'
|
||||
Warning 1062 Duplicate entry '600' for key 'PRIMARY'
|
||||
Warning 1062 Duplicate entry '600' for key 'PRIMARY'
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
|
@ -186,7 +190,7 @@ set auto_increment_offset=4;
|
|||
insert into t1 values(null);
|
||||
insert into t1 values(null);
|
||||
insert into t1 values(null);
|
||||
ERROR 23000: Duplicate entry '125' for key 'PRIMARY'
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t1 order by a;
|
||||
a mod(a-@@auto_increment_offset,@@auto_increment_increment)
|
||||
103 0
|
||||
|
@ -196,21 +200,19 @@ create table t2 (a tinyint unsigned not null auto_increment primary key) engine=
|
|||
set auto_increment_increment=10;
|
||||
set auto_increment_offset=1;
|
||||
set insert_id=1000;
|
||||
insert into t2 values(10);
|
||||
insert into t2 values(null);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t2 order by a;
|
||||
a mod(a-@@auto_increment_offset,@@auto_increment_increment)
|
||||
251 0
|
||||
10 9
|
||||
create table t3 like t1;
|
||||
set auto_increment_increment=1000;
|
||||
set auto_increment_offset=700;
|
||||
insert into t3 values(null);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'a' at row 1
|
||||
ERROR 22003: Out of range value for column 'a' at row 1
|
||||
select * from t3 order by a;
|
||||
a
|
||||
127
|
||||
select * from t1 order by a;
|
||||
a
|
||||
103
|
||||
|
@ -218,10 +220,9 @@ a
|
|||
125
|
||||
select * from t2 order by a;
|
||||
a
|
||||
251
|
||||
10
|
||||
select * from t3 order by a;
|
||||
a
|
||||
127
|
||||
drop table t1,t2,t3;
|
||||
set auto_increment_increment=1;
|
||||
set auto_increment_offset=1;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
--- suite/rpl/r/rpl_insert_delayed.result 2012-02-06 21:37:21.000000000 +0100
|
||||
+++ suite/rpl/r/rpl_insert_delayed,stmt.reject 2012-02-06 23:12:55.000000000 +0100
|
||||
--- suite/rpl/r/rpl_insert_delayed.result 2012-09-18 01:37:45.317521958 +0300
|
||||
+++ suite/rpl/r/rpl_insert_delayed,stmt.reject 2012-09-18 01:36:16.637514667 +0300
|
||||
@@ -15,17 +15,17 @@
|
||||
insert delayed into t1 values(10, "my name");
|
||||
flush table t1;
|
||||
|
|
|
@ -14,6 +14,8 @@ select * into outfile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1;
|
|||
drop table t1;
|
||||
create table t1(a int primary key);
|
||||
load data local infile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1;
|
||||
Warnings:
|
||||
Warning 1062 Duplicate entry '2' for key 'PRIMARY'
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
a
|
||||
1
|
||||
|
|
|
@ -104,7 +104,7 @@ explain extended select last_insert_id();
|
|||
--error ER_DUP_ENTRY
|
||||
insert into t1 set i = 254;
|
||||
select last_insert_id();
|
||||
--error ER_DUP_ENTRY
|
||||
--error 167
|
||||
insert into t1 set i = null;
|
||||
select last_insert_id();
|
||||
drop table t1;
|
||||
|
@ -113,6 +113,7 @@ create table t1 (i tinyint unsigned not null auto_increment, key (i));
|
|||
insert into t1 set i = 254;
|
||||
insert into t1 set i = null;
|
||||
select last_insert_id();
|
||||
--error 167
|
||||
insert into t1 set i = null;
|
||||
select last_insert_id();
|
||||
drop table t1;
|
||||
|
@ -353,7 +354,7 @@ INSERT INTO t1 VALUES (18446744073709551601);
|
|||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=10;
|
||||
|
||||
SELECT @@SESSION.AUTO_INCREMENT_OFFSET;
|
||||
--error ER_WARN_DATA_OUT_OF_RANGE
|
||||
--error 167
|
||||
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
|
||||
SELECT * FROM t1;
|
||||
|
||||
|
|
240
mysql-test/t/auto_increment_ranges.inc
Normal file
240
mysql-test/t/auto_increment_ranges.inc
Normal file
|
@ -0,0 +1,240 @@
|
|||
#
|
||||
# Test of auto_increment at end of range
|
||||
#
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
--echo #
|
||||
--echo # Testing ranges with smallint
|
||||
--echo #
|
||||
let $type=smallint;
|
||||
let $range_max=32767;
|
||||
|
||||
eval create table t1 (a $type primary key auto_increment);
|
||||
eval insert into t1 values($range_max);
|
||||
--error 167
|
||||
insert into t1 values(NULL);
|
||||
truncate table t1;
|
||||
eval insert into t1 values($range_max-1);
|
||||
insert into t1 values(NULL);
|
||||
--error 167
|
||||
insert into t1 values(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error 167
|
||||
eval insert into t1 values($range_max),(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error 167
|
||||
eval insert into t1 values($range_max-1),(NULL),(NULL);
|
||||
truncate table t1;
|
||||
eval insert into t1 values($range_max+1);
|
||||
select * from t1;
|
||||
--error 167
|
||||
eval insert into t1 values(NULL);
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # Testing ranges with unsigned smallint
|
||||
--echo #
|
||||
|
||||
let $type=smallint unsigned;
|
||||
let $range_max=65535;
|
||||
|
||||
eval create table t1 (a $type primary key auto_increment);
|
||||
eval insert into t1 values($range_max);
|
||||
--error 167
|
||||
insert into t1 values(NULL);
|
||||
truncate table t1;
|
||||
eval insert into t1 values($range_max-1);
|
||||
insert into t1 values(NULL);
|
||||
--error 167
|
||||
insert into t1 values(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error 167
|
||||
eval insert into t1 values($range_max),(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error 167
|
||||
eval insert into t1 values($range_max-1),(NULL),(NULL);
|
||||
truncate table t1;
|
||||
eval insert into t1 values($range_max+1);
|
||||
select * from t1;
|
||||
--error 167
|
||||
eval insert into t1 values(NULL);
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # Testing ranges with integer
|
||||
--echo #
|
||||
|
||||
let $type=int;
|
||||
let $range_max=2147483647;
|
||||
|
||||
eval create table t1 (a $type primary key auto_increment);
|
||||
eval insert into t1 values($range_max);
|
||||
--error 167
|
||||
insert into t1 values(NULL);
|
||||
truncate table t1;
|
||||
eval insert into t1 values($range_max-1);
|
||||
insert into t1 values(NULL);
|
||||
--error 167
|
||||
insert into t1 values(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error 167
|
||||
eval insert into t1 values($range_max),(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error 167
|
||||
eval insert into t1 values($range_max-1),(NULL),(NULL);
|
||||
truncate table t1;
|
||||
eval insert into t1 values($range_max+1);
|
||||
select * from t1;
|
||||
--error 167
|
||||
eval insert into t1 values(NULL);
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # Testing ranges with unsigned integer
|
||||
--echo #
|
||||
|
||||
let $type=int unsigned;
|
||||
let $range_max=4294967295;
|
||||
|
||||
eval create table t1 (a $type primary key auto_increment);
|
||||
eval insert into t1 values($range_max);
|
||||
--error 167
|
||||
insert into t1 values(NULL);
|
||||
truncate table t1;
|
||||
eval insert into t1 values($range_max-1);
|
||||
insert into t1 values(NULL);
|
||||
--error 167
|
||||
insert into t1 values(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error 167
|
||||
eval insert into t1 values($range_max),(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error 167
|
||||
eval insert into t1 values($range_max-1),(NULL),(NULL);
|
||||
truncate table t1;
|
||||
eval insert into t1 values($range_max+1);
|
||||
select * from t1;
|
||||
--error 167
|
||||
eval insert into t1 values(NULL);
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # Testing ranges with bigint
|
||||
--echo #
|
||||
|
||||
let $type=bigint;
|
||||
let $range_max=cast(9223372036854775807 as unsigned);
|
||||
|
||||
eval create table t1 (a $type primary key auto_increment);
|
||||
eval insert into t1 values($range_max);
|
||||
--error 167
|
||||
insert into t1 values(NULL);
|
||||
truncate table t1;
|
||||
eval insert into t1 values($range_max-1);
|
||||
insert into t1 values(NULL);
|
||||
--error 167
|
||||
insert into t1 values(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error 167
|
||||
eval insert into t1 values($range_max),(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error 167
|
||||
eval insert into t1 values($range_max-1),(NULL),(NULL);
|
||||
truncate table t1;
|
||||
eval insert into t1 values($range_max+1);
|
||||
select * from t1;
|
||||
--error 167
|
||||
eval insert into t1 values(NULL);
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # Testing ranges with unsigned bigint
|
||||
--echo #
|
||||
|
||||
let $type=bigint unsigned;
|
||||
let $range_max=18446744073709551615;
|
||||
|
||||
eval create table t1 (a $type primary key auto_increment);
|
||||
eval insert into t1 values($range_max-1);
|
||||
--error ER_AUTOINC_READ_FAILED
|
||||
insert into t1 values(NULL);
|
||||
--error ER_AUTOINC_READ_FAILED
|
||||
insert into t1 values(NULL);
|
||||
truncate table t1;
|
||||
eval insert into t1 values($range_max-1);
|
||||
--error ER_AUTOINC_READ_FAILED
|
||||
insert into t1 values(NULL);
|
||||
--error ER_AUTOINC_READ_FAILED
|
||||
insert into t1 values(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error ER_AUTOINC_READ_FAILED
|
||||
eval insert into t1 values($range_max),(NULL);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
--error ER_AUTOINC_READ_FAILED
|
||||
eval insert into t1 values($range_max-1),(NULL),(NULL);
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # Test IGNORE and strict mode
|
||||
--echo #
|
||||
create table t1 (a smallint primary key auto_increment);
|
||||
insert ignore into t1 values(32766),(NULL),(NULL),(1);
|
||||
select * from t1;
|
||||
truncate table t1;
|
||||
|
||||
set @org_mode=@@sql_mode;
|
||||
set @@sql_mode='ansi,traditional';
|
||||
insert ignore into t1 values(32766),(NULL),(NULL);
|
||||
truncate table t1;
|
||||
--error 167
|
||||
insert into t1 values(32766),(NULL),(NULL);
|
||||
set @@sql_mode=@org_mode;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # Test auto increment with negative numbers
|
||||
--echo #
|
||||
CREATE TABLE t1 (a INTEGER AUTO_INCREMENT, PRIMARY KEY (a));
|
||||
INSERT INTO t1 VALUES (NULL), (2), (-5), (NULL);
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
SELECT * FROM t1;
|
||||
TRUNCATE TABLE t1;
|
||||
INSERT INTO t1 VALUES (-5), (NULL);
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Test inserting a value out-of-range into an auto increment column
|
||||
--echo #
|
||||
CREATE TABLE t1 (a smallint AUTO_INCREMENT, PRIMARY KEY (a));
|
||||
INSERT INTO t1 VALUES (2);
|
||||
INSERT INTO t1 VALUES (32768);
|
||||
--error 167
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Test old behaviour
|
||||
--echo #
|
||||
create table t1 (a smallint primary key auto_increment);
|
||||
insert into t1 values(32766),(NULL);
|
||||
delete from t1 where a=32767;
|
||||
--error 167
|
||||
insert into t1 values(NULL);
|
||||
drop table t1;
|
7
mysql-test/t/auto_increment_ranges_innodb.test
Normal file
7
mysql-test/t/auto_increment_ranges_innodb.test
Normal file
|
@ -0,0 +1,7 @@
|
|||
#
|
||||
# Test of auto_increment at end of range
|
||||
#
|
||||
|
||||
--source include/have_innodb.inc
|
||||
set default_storage_engine=innodb;
|
||||
--source auto_increment_ranges.inc
|
7
mysql-test/t/auto_increment_ranges_myisam.test
Normal file
7
mysql-test/t/auto_increment_ranges_myisam.test
Normal file
|
@ -0,0 +1,7 @@
|
|||
#
|
||||
# Test of auto_increment at end of range
|
||||
#
|
||||
|
||||
set default_storage_engine=MYISAM;
|
||||
--source auto_increment_ranges.inc
|
||||
|
|
@ -25,9 +25,9 @@ drop table t1;
|
|||
|
||||
create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
|
||||
insert into t1 values (126,"first"),(63, "middle"),(0,"last");
|
||||
--error ER_DUP_ENTRY
|
||||
--error 167
|
||||
insert into t1 values (0,"error");
|
||||
--error ER_DUP_ENTRY
|
||||
--error 167
|
||||
replace into t1 values (0,"error");
|
||||
replace into t1 values (126,"first updated");
|
||||
replace into t1 values (63,default);
|
||||
|
|
|
@ -691,15 +691,13 @@ static int setval(const struct my_option *opts, void *value, char *argument,
|
|||
*((double*) value)= getopt_double(argument, opts, &err);
|
||||
break;
|
||||
case GET_STR:
|
||||
if (argument == enabled_my_option)
|
||||
break; /* string options don't use this default of "1" */
|
||||
*((char**) value)= argument;
|
||||
/* If no argument or --enable-string-option, set string to "" */
|
||||
*((char**) value)= argument == enabled_my_option ? (char*) "" : argument;
|
||||
break;
|
||||
case GET_STR_ALLOC:
|
||||
if (argument == enabled_my_option)
|
||||
break; /* string options don't use this default of "1" */
|
||||
my_free(*((char**) value));
|
||||
if (!(*((char**) value)= my_strdup(argument, MYF(MY_WME))))
|
||||
if (!(*((char**) value)= my_strdup(argument == enabled_my_option ? "" :
|
||||
argument, MYF(MY_WME))))
|
||||
{
|
||||
res= EXIT_OUT_OF_MEMORY;
|
||||
goto ret;
|
||||
|
|
|
@ -2502,6 +2502,8 @@ int handler::update_auto_increment()
|
|||
bool append= FALSE;
|
||||
THD *thd= table->in_use;
|
||||
struct system_variables *variables= &thd->variables;
|
||||
int result=0, tmp;
|
||||
enum enum_check_fields save_count_cuted_fields;
|
||||
DBUG_ENTER("handler::update_auto_increment");
|
||||
|
||||
/*
|
||||
|
@ -2519,8 +2521,10 @@ int handler::update_auto_increment()
|
|||
statement (case of INSERT VALUES(null),(3763),(null):
|
||||
the last NULL needs to insert 3764, not the value of the first NULL plus
|
||||
1).
|
||||
Ignore negative values.
|
||||
*/
|
||||
adjust_next_insert_id_after_explicit_value(nr);
|
||||
if ((longlong) nr > 0 || (table->next_number_field->flags & UNSIGNED_FLAG))
|
||||
adjust_next_insert_id_after_explicit_value(nr);
|
||||
insert_id_for_cur_row= 0; // didn't generate anything
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
@ -2579,7 +2583,6 @@ int handler::update_auto_increment()
|
|||
else
|
||||
nb_desired_values= AUTO_INC_DEFAULT_NB_MAX;
|
||||
}
|
||||
/* This call ignores all its parameters but nr, currently */
|
||||
get_auto_increment(variables->auto_increment_offset,
|
||||
variables->auto_increment_increment,
|
||||
nb_desired_values, &nr,
|
||||
|
@ -2616,29 +2619,23 @@ int handler::update_auto_increment()
|
|||
}
|
||||
|
||||
if (unlikely(nr == ULONGLONG_MAX))
|
||||
DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
|
||||
DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
|
||||
|
||||
DBUG_PRINT("info",("auto_increment: %lu", (ulong) nr));
|
||||
|
||||
if (unlikely(table->next_number_field->store((longlong) nr, TRUE)))
|
||||
/* Store field without warning (Warning will be printed by insert) */
|
||||
save_count_cuted_fields= thd->count_cuted_fields;
|
||||
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
|
||||
tmp= table->next_number_field->store((longlong) nr, TRUE);
|
||||
thd->count_cuted_fields= save_count_cuted_fields;
|
||||
|
||||
if (unlikely(tmp)) // Out of range value in store
|
||||
{
|
||||
/*
|
||||
first test if the query was aborted due to strict mode constraints
|
||||
It's better to return an error here than getting a confusing
|
||||
'duplicate key error' later.
|
||||
*/
|
||||
if (killed_mask_hard(thd->killed) == KILL_BAD_DATA)
|
||||
DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
|
||||
|
||||
/*
|
||||
field refused this value (overflow) and truncated it, use the result of
|
||||
the truncation (which is going to be inserted); however we try to
|
||||
decrease it to honour auto_increment_* variables.
|
||||
That will shift the left bound of the reserved interval, we don't
|
||||
bother shifting the right bound (anyway any other value from this
|
||||
interval will cause a duplicate key).
|
||||
*/
|
||||
nr= prev_insert_id(table->next_number_field->val_int(), variables);
|
||||
if (unlikely(table->next_number_field->store((longlong) nr, TRUE)))
|
||||
nr= table->next_number_field->val_int();
|
||||
result= HA_ERR_AUTOINC_ERANGE;
|
||||
}
|
||||
if (append)
|
||||
{
|
||||
|
@ -2660,6 +2657,10 @@ int handler::update_auto_increment()
|
|||
already set.
|
||||
*/
|
||||
insert_id_for_cur_row= nr;
|
||||
|
||||
if (result) // overflow
|
||||
DBUG_RETURN(result);
|
||||
|
||||
/*
|
||||
Set next insert id to point to next auto-increment value to be able to
|
||||
handle multi-row statements.
|
||||
|
@ -2783,7 +2784,7 @@ void handler::ha_release_auto_increment()
|
|||
}
|
||||
|
||||
|
||||
void handler::print_keydup_error(uint key_nr, const char *msg)
|
||||
void handler::print_keydup_error(uint key_nr, const char *msg, myf errflag)
|
||||
{
|
||||
/* Write the duplicated key in the error message */
|
||||
char key[MAX_KEY_LENGTH];
|
||||
|
@ -2793,7 +2794,7 @@ void handler::print_keydup_error(uint key_nr, const char *msg)
|
|||
{
|
||||
/* Key is unknown */
|
||||
str.copy("", 0, system_charset_info);
|
||||
my_printf_error(ER_DUP_ENTRY, msg, MYF(0), str.c_ptr(), "*UNKNOWN*");
|
||||
my_printf_error(ER_DUP_ENTRY, msg, errflag, str.c_ptr(), "*UNKNOWN*");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2806,7 +2807,7 @@ void handler::print_keydup_error(uint key_nr, const char *msg)
|
|||
str.append(STRING_WITH_LEN("..."));
|
||||
}
|
||||
my_printf_error(ER_DUP_ENTRY, msg,
|
||||
MYF(0), str.c_ptr_safe(), table->key_info[key_nr].name);
|
||||
errflag, str.c_ptr_safe(), table->key_info[key_nr].name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2874,7 +2875,7 @@ void handler::print_error(int error, myf errflag)
|
|||
uint key_nr=get_dup_key(error);
|
||||
if ((int) key_nr >= 0)
|
||||
{
|
||||
print_keydup_error(key_nr, ER(ER_DUP_ENTRY_WITH_KEY_NAME));
|
||||
print_keydup_error(key_nr, ER(ER_DUP_ENTRY_WITH_KEY_NAME), errflag);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
}
|
||||
|
@ -3037,7 +3038,10 @@ void handler::print_error(int error, myf errflag)
|
|||
textno= ER_AUTOINC_READ_FAILED;
|
||||
break;
|
||||
case HA_ERR_AUTOINC_ERANGE:
|
||||
textno= ER_WARN_DATA_OUT_OF_RANGE;
|
||||
textno= error;
|
||||
my_error(textno, errflag, table->next_number_field->field_name,
|
||||
table->in_use->warning_info->current_row_for_warning());
|
||||
DBUG_VOID_RETURN;
|
||||
break;
|
||||
case HA_ERR_TOO_MANY_CONCURRENT_TRXS:
|
||||
textno= ER_TOO_MANY_CONCURRENT_TRXS;
|
||||
|
|
|
@ -1957,7 +1957,7 @@ public:
|
|||
|
||||
void adjust_next_insert_id_after_explicit_value(ulonglong nr);
|
||||
int update_auto_increment();
|
||||
void print_keydup_error(uint key_nr, const char *msg);
|
||||
void print_keydup_error(uint key_nr, const char *msg, myf errflag);
|
||||
virtual void print_error(int error, myf errflag);
|
||||
virtual bool get_error_message(int error, String *buf);
|
||||
uint get_dup_key(int error);
|
||||
|
@ -2006,7 +2006,8 @@ public:
|
|||
if (!error ||
|
||||
((flags & HA_CHECK_DUP_KEY) &&
|
||||
(error == HA_ERR_FOUND_DUPP_KEY ||
|
||||
error == HA_ERR_FOUND_DUPP_UNIQUE)))
|
||||
error == HA_ERR_FOUND_DUPP_UNIQUE)) ||
|
||||
error == HA_ERR_AUTOINC_ERANGE)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -1086,6 +1086,9 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
|
|||
ulong now;
|
||||
bool ret;
|
||||
DBUG_ENTER("Log_event::write_header");
|
||||
DBUG_PRINT("enter", ("filepos: %lld length: %lu type: %d",
|
||||
(longlong) my_b_tell(file), event_data_length,
|
||||
(int) get_type_code()));
|
||||
|
||||
/* Store number of bytes that will be written by this event */
|
||||
data_written= event_data_length + sizeof(header);
|
||||
|
@ -3512,6 +3515,34 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli)
|
|||
return do_apply_event(rli, query, q_len);
|
||||
}
|
||||
|
||||
/**
|
||||
Compare if two errors should be regarded as equal.
|
||||
This is to handle the case when you can get slightly different errors
|
||||
on master and slave for the same thing.
|
||||
@param
|
||||
expected_error Error we got on master
|
||||
actual_error Error we got on slave
|
||||
|
||||
@return
|
||||
1 Errors are equal
|
||||
0 Errors are different
|
||||
*/
|
||||
|
||||
bool test_if_equal_repl_errors(int expected_error, int actual_error)
|
||||
{
|
||||
if (expected_error == actual_error)
|
||||
return 1;
|
||||
switch (expected_error) {
|
||||
case ER_DUP_ENTRY:
|
||||
case ER_AUTOINC_READ_FAILED:
|
||||
return (actual_error == ER_AUTOINC_READ_FAILED ||
|
||||
actual_error == HA_ERR_AUTOINC_ERANGE);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@todo
|
||||
|
@ -3824,7 +3855,8 @@ compare_errors:
|
|||
DBUG_PRINT("info",("expected_error: %d sql_errno: %d",
|
||||
expected_error, actual_error));
|
||||
|
||||
if ((expected_error && expected_error != actual_error &&
|
||||
if ((expected_error &&
|
||||
!test_if_equal_repl_errors(expected_error, actual_error) &&
|
||||
!concurrency_error_code(expected_error)) &&
|
||||
!ignored_error_code(actual_error) &&
|
||||
!ignored_error_code(expected_error))
|
||||
|
@ -3846,7 +3878,7 @@ Default database: '%s'. Query: '%s'",
|
|||
If we get the same error code as expected and it is not a concurrency
|
||||
issue, or should be ignored.
|
||||
*/
|
||||
else if ((expected_error == actual_error &&
|
||||
else if ((test_if_equal_repl_errors(expected_error, actual_error) &&
|
||||
!concurrency_error_code(expected_error)) ||
|
||||
ignored_error_code(actual_error))
|
||||
{
|
||||
|
|
|
@ -1598,7 +1598,10 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
|
|||
report error as usual. We will not do any duplicate key processing.
|
||||
*/
|
||||
if (info->ignore)
|
||||
{
|
||||
table->file->print_error(error, MYF(ME_JUST_WARNING));
|
||||
goto ok_or_after_trg_err; /* Ignoring a not fatal error, return 0 */
|
||||
}
|
||||
goto err;
|
||||
}
|
||||
if ((int) (key_nr = table->file->get_dup_key(error)) < 0)
|
||||
|
@ -1688,6 +1691,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
|
|||
if (info->ignore &&
|
||||
!table->file->is_fatal_error(error, HA_CHECK_DUP_KEY))
|
||||
{
|
||||
table->file->print_error(error, MYF(ME_JUST_WARNING));
|
||||
goto ok_or_after_trg_err;
|
||||
}
|
||||
goto err;
|
||||
|
@ -1803,6 +1807,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
|
|||
if (!info->ignore ||
|
||||
table->file->is_fatal_error(error, HA_CHECK_DUP))
|
||||
goto err;
|
||||
table->file->print_error(error, MYF(ME_JUST_WARNING));
|
||||
table->file->restore_auto_increment(prev_insert_id);
|
||||
goto ok_or_after_trg_err;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <my_global.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <my_base.h>
|
||||
|
||||
struct st_map_errno_to_sqlstate
|
||||
{
|
||||
|
@ -27,6 +28,7 @@ struct st_map_errno_to_sqlstate
|
|||
|
||||
struct st_map_errno_to_sqlstate sqlstate_map[]=
|
||||
{
|
||||
#include <handler_state.h>
|
||||
#include <sql_state.h>
|
||||
};
|
||||
|
||||
|
|
|
@ -7476,7 +7476,7 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to,
|
|||
(to->key_info[0].key_part[0].field->flags &
|
||||
AUTO_INCREMENT_FLAG))
|
||||
err_msg= ER(ER_DUP_ENTRY_AUTOINCREMENT_CASE);
|
||||
to->file->print_keydup_error(key_nr, err_msg);
|
||||
to->file->print_keydup_error(key_nr, err_msg, MYF(0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1474,6 +1474,15 @@ innobase_next_autoinc(
|
|||
ut_a(block > 0);
|
||||
ut_a(max_value > 0);
|
||||
|
||||
/*
|
||||
Allow auto_increment to go over max_value up to max ulonglong.
|
||||
This allows us to detect that all values are exhausted.
|
||||
If we don't do this, we will return max_value several times
|
||||
and get duplicate key errors instead of auto increment value
|
||||
out of range.
|
||||
*/
|
||||
max_value= (~(ulonglong) 0);
|
||||
|
||||
/* Current value should never be greater than the maximum. */
|
||||
ut_a(current <= max_value);
|
||||
|
||||
|
@ -5236,7 +5245,10 @@ no_commit:
|
|||
goto report_error;
|
||||
}
|
||||
|
||||
/* MySQL errors are passed straight back. */
|
||||
/* MySQL errors are passed straight back. except for
|
||||
HA_ERR_AUTO_INC_READ_FAILED. This can only happen
|
||||
for values out of range.
|
||||
*/
|
||||
error_result = (int) error;
|
||||
goto func_exit;
|
||||
}
|
||||
|
@ -10264,13 +10276,16 @@ ha_innobase::get_auto_increment(
|
|||
/* Not in the middle of a mult-row INSERT. */
|
||||
} else if (prebuilt->autoinc_last_value == 0) {
|
||||
set_if_bigger(*first_value, autoinc);
|
||||
/* Check for -ve values. */
|
||||
} else if (*first_value > col_max_value && trx->n_autoinc_rows > 0) {
|
||||
/* Set to next logical value. */
|
||||
ut_a(autoinc > trx->n_autoinc_rows);
|
||||
*first_value = (autoinc - trx->n_autoinc_rows) - 1;
|
||||
}
|
||||
|
||||
if (*first_value > col_max_value)
|
||||
{
|
||||
/* Out of range number. Let handler::update_auto_increment()
|
||||
take care of this */
|
||||
prebuilt->autoinc_last_value = 0;
|
||||
dict_table_autoinc_unlock(prebuilt->table);
|
||||
return;
|
||||
}
|
||||
*nb_reserved_values = trx->n_autoinc_rows;
|
||||
|
||||
/* With old style AUTOINC locking we only update the table's
|
||||
|
@ -10279,7 +10294,7 @@ ha_innobase::get_auto_increment(
|
|||
ulonglong current;
|
||||
ulonglong next_value;
|
||||
|
||||
current = *first_value > col_max_value ? autoinc : *first_value;
|
||||
current = *first_value;
|
||||
|
||||
/* Compute the last value in the interval */
|
||||
next_value = innobase_next_autoinc(
|
||||
|
|
|
@ -1664,6 +1664,15 @@ innobase_next_autoinc(
|
|||
ut_a(block > 0);
|
||||
ut_a(max_value > 0);
|
||||
|
||||
/*
|
||||
Allow auto_increment to go over max_value up to max ulonglong.
|
||||
This allows us to detect that all values are exhausted.
|
||||
If we don't do this, we will return max_value several times
|
||||
and get duplicate key errors instead of auto increment value
|
||||
out of range.
|
||||
*/
|
||||
max_value= (~(ulonglong) 0);
|
||||
|
||||
/* Current value should never be greater than the maximum. */
|
||||
ut_a(current <= max_value);
|
||||
|
||||
|
@ -5999,7 +6008,10 @@ no_commit:
|
|||
goto report_error;
|
||||
}
|
||||
|
||||
/* MySQL errors are passed straight back. */
|
||||
/* MySQL errors are passed straight back. except for
|
||||
HA_ERR_AUTO_INC_READ_FAILED. This can only happen
|
||||
for values out of range.
|
||||
*/
|
||||
error_result = (int) error;
|
||||
goto func_exit;
|
||||
}
|
||||
|
@ -11205,13 +11217,16 @@ ha_innobase::get_auto_increment(
|
|||
/* Not in the middle of a mult-row INSERT. */
|
||||
} else if (prebuilt->autoinc_last_value == 0) {
|
||||
set_if_bigger(*first_value, autoinc);
|
||||
/* Check for -ve values. */
|
||||
} else if (*first_value > col_max_value && trx->n_autoinc_rows > 0) {
|
||||
/* Set to next logical value. */
|
||||
ut_a(autoinc > trx->n_autoinc_rows);
|
||||
*first_value = (autoinc - trx->n_autoinc_rows) - 1;
|
||||
}
|
||||
|
||||
if (*first_value > col_max_value)
|
||||
{
|
||||
/* Out of range number. Let handler::update_auto_increment()
|
||||
take care of this */
|
||||
prebuilt->autoinc_last_value = 0;
|
||||
dict_table_autoinc_unlock(prebuilt->table);
|
||||
return;
|
||||
}
|
||||
*nb_reserved_values = trx->n_autoinc_rows;
|
||||
|
||||
/* With old style AUTOINC locking we only update the table's
|
||||
|
@ -11220,7 +11235,7 @@ ha_innobase::get_auto_increment(
|
|||
ulonglong current;
|
||||
ulonglong next_value;
|
||||
|
||||
current = *first_value > col_max_value ? autoinc : *first_value;
|
||||
current = *first_value;
|
||||
|
||||
/* Compute the last value in the interval */
|
||||
next_value = innobase_next_autoinc(
|
||||
|
|
Loading…
Reference in a new issue