mariadb/mysql-test/suite/optimizer_unfixed_bugs/r/bug43617.result
Michael Widenius ae5bc05988 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.
2012-09-18 15:14:19 +03:00

102 lines
5.8 KiB
Text

set storage_engine=innodb;
set @save_time_zone= @@time_zone;
set time_zone='+03:00';
set session debug_dbug="+d,optimizer_innodb_icp";
CREATE TABLE t1(c1 TIMESTAMP NOT NULL, c2 TIMESTAMP NULL, c3 DATE, c4 DATETIME, PRIMARY KEY(c1), UNIQUE INDEX(c2));
INSERT INTO t1 VALUES('98-12-31 11:30:45','98.12.31 11+30+45','98-12-31 11:30:45','98.12.31 11+30+45'),('98/12/30 11*30*45','98@12@30 11^30^45','98/12/30 11*30*45','98@12@30 11^30^45'),('98-12-29','98.12.29','98-12-29','98.12.29'),('98/12/28','98@12@28','98/12/28','98@12@28');
Warnings:
Note 1265 Data truncated for column 'c3' at row 1
Note 1265 Data truncated for column 'c3' at row 2
INSERT INTO t1 VALUES('20070523091528','070523091528','20070524091528','070524091528'),('20070525','070525','20070526','070526');
Warnings:
Note 1265 Data truncated for column 'c3' at row 1
INSERT INTO t1 VALUES(19830905132800,830905132800,19830906132800,830906132800),(19830907,830907,19830908,830908);
Warnings:
Note 1265 Data truncated for column 'c3' at row 1
SET TIMESTAMP=1233216687;
INSERT INTO t1 VALUES(NOW(),CURRENT_DATE,NOW(),CURRENT_DATE);
Warnings:
Note 1265 Data truncated for column 'c3' at row 1
INSERT INTO t1 VALUES('2008-01-01',NULL,'08-01-02','08/01/03');
INSERT INTO t1(c1,c2) VALUES('08/01/17',NULL);
DELETE FROM t1 WHERE c1='08/01/17' AND c2 IS NULL;
INSERT INTO t1 VALUES('','','08-01-04','08/01/05') /* Inserts zero dates for '' strings */;
Warnings:
Warning 1265 Data truncated for column 'c1' at row 1
Warning 1265 Data truncated for column 'c2' at row 1
SELECT * FROM t1;
c1 c2 c3 c4
0000-00-00 00:00:00 0000-00-00 00:00:00 2008-01-04 2008-01-05 00:00:00
1983-09-05 13:28:00 1983-09-05 13:28:00 1983-09-06 1983-09-06 13:28:00
1983-09-07 00:00:00 1983-09-07 00:00:00 1983-09-08 1983-09-08 00:00:00
1998-12-28 00:00:00 1998-12-28 00:00:00 1998-12-28 1998-12-28 00:00:00
1998-12-29 00:00:00 1998-12-29 00:00:00 1998-12-29 1998-12-29 00:00:00
1998-12-30 11:30:45 1998-12-30 11:30:45 1998-12-30 1998-12-30 11:30:45
1998-12-31 11:30:45 1998-12-31 11:30:45 1998-12-31 1998-12-31 11:30:45
2007-05-23 09:15:28 2007-05-23 09:15:28 2007-05-24 2007-05-24 09:15:28
2007-05-25 00:00:00 2007-05-25 00:00:00 2007-05-26 2007-05-26 00:00:00
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';
SELECT * FROM t1 WHERE c1='20070527' /* Returns 1 row with c1=2007-05-27 */;
c1 c2 c3 c4
2007-05-27 00:00:00 2007-05-25 00:00:00 2007-05-26 2007-05-26 00:00:00
SELECT * FROM t1 WHERE c1=19830909 AND c2=830910 /* Returns no rows */;
c1 c2 c3 c4
INSERT INTO t1(c1,c2) VALUES(19840905,830907) ON DUPLICATE KEY UPDATE c1=19830909,c2=830910;
SELECT * FROM t1 WHERE c1=19830909 AND c2=830910 /* Returns 1 row */;
c1 c2 c3 c4
1983-09-09 00:00:00 1983-09-10 00:00:00 1983-09-08 1983-09-08 00:00:00
INSERT INTO t1 SET c1='1999-01-01',c2='1999-01-01';
SELECT * FROM t1 WHERE c1='1999-01-01' AND c2='1999-01-01' /* Returns 1 row with values for other column as NULL */;
c1 c2 c3 c4
1999-01-01 00:00:00 1999-01-01 00:00:00 NULL NULL
INSERT INTO t1 VALUES('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02'),('1990-01-01 00:00:01','2000-01-01 00:00:01','2009-01-03','2009-01-04'),('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06');
DELETE FROM t1 WHERE c1=NOW() /* because the row with current timestamp exists */;
INSERT INTO t1 VALUES(NULL,NOW(),NOW(),NOW());
Warnings:
Note 1265 Data truncated for column 'c3' at row 1
SELECT * FROM t1 WHERE c1 IS NULL /* returns no rows */;
c1 c2 c3 c4
SELECT * FROM t1 WHERE c1=NOW() /* returns 1 row */;
c1 c2 c3 c4
2009-01-29 11:11:27 2009-01-29 11:11:27 2009-01-29 2009-01-29 11:11:27
SELECT * FROM t1;
c1 c2 c3 c4
0000-00-00 00:00:00 0000-00-00 00:00:00 2008-01-04 2008-01-05 00:00:00
1971-01-01 00:00:01 1980-01-01 00:00:01 2009-01-01 2009-01-02 00:00:00
1983-09-05 13:28:00 1983-09-05 13:28:00 1983-09-06 1983-09-06 13:28:00
1983-09-09 00:00:00 1983-09-10 00:00:00 1983-09-08 1983-09-08 00:00:00
1990-01-01 00:00:01 2000-01-01 00:00:01 2009-01-03 2009-01-04 00:00:00
1998-12-28 00:00:00 1998-12-28 00:00:00 1998-12-28 1998-12-28 00:00:00
1998-12-29 00:00:00 1998-12-29 00:00:00 1998-12-29 1998-12-29 00:00:00
1998-12-30 11:30:45 1998-12-30 11:30:45 1998-12-30 1998-12-30 11:30:45
1998-12-31 11:30:45 1998-12-31 11:30:45 1998-12-31 1998-12-31 11:30:45
1999-01-01 00:00:00 1999-01-01 00:00:00 NULL NULL
2007-05-23 09:15:28 2007-05-23 09:15:28 2007-05-24 2007-05-24 09:15:28
2007-05-27 00:00:00 2007-05-25 00:00:00 2007-05-26 2007-05-26 00:00:00
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 11:11:27 2009-01-29 2009-01-29 11:11:27
2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
SELECT * FROM t1 WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') ORDER BY c2;
c1 c2 c3 c4
2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
SELECT * FROM t1 WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') ORDER BY c2 LIMIT 2;
c1 c2 c3 c4
2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
SELECT * FROM t1 WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') ORDER BY c2 DESC;
c1 c2 c3 c4
2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
SELECT * FROM t1 WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') ORDER BY c2 DESC LIMIT 2;
c1 c2 c3 c4
2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
DROP TABLE t1;
set time_zone= @save_time_zone;