mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Merge from mysql-5.1-innodb to mysql-5.5-innodb. Test was adjusted.
This commit is contained in:
26
mysql-test/suite/innodb/r/innodb-autoinc-18274.result
Normal file
26
mysql-test/suite/innodb/r/innodb-autoinc-18274.result
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
drop table if exists t1;
|
||||||
|
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||||
|
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 VALUES (null);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`c1` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
PRIMARY KEY (`c1`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
|
||||||
|
DELETE FROM t1;
|
||||||
|
OPTIMIZE TABLE t1;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
|
||||||
|
test.t1 optimize status OK
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`c1` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
PRIMARY KEY (`c1`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
|
||||||
|
INSERT INTO t1 VALUES(null);
|
||||||
|
SELECT * FROM t1;
|
||||||
|
c1
|
||||||
|
2
|
||||||
|
DROP TABLE t1;
|
26
mysql-test/suite/innodb/t/innodb-autoinc-18274.test
Normal file
26
mysql-test/suite/innodb/t/innodb-autoinc-18274.test
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
-- source include/have_innodb.inc
|
||||||
|
# embedded server ignores 'delayed', so skip this
|
||||||
|
-- source include/not_embedded.inc
|
||||||
|
|
||||||
|
--disable_warnings
|
||||||
|
drop table if exists t1;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #18274 InnoDB auto_increment field reset on OPTIMIZE TABLE
|
||||||
|
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||||
|
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 VALUES (null);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
DELETE FROM t1;
|
||||||
|
OPTIMIZE TABLE t1;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
INSERT INTO t1 VALUES(null);
|
||||||
|
SELECT * FROM t1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# restore environment to the state it was before this test execution
|
||||||
|
#
|
||||||
|
|
||||||
|
-- disable_query_log
|
@@ -7036,23 +7036,25 @@ ha_innobase::create(
|
|||||||
setup at this stage and so we use thd. */
|
setup at this stage and so we use thd. */
|
||||||
|
|
||||||
/* We need to copy the AUTOINC value from the old table if
|
/* We need to copy the AUTOINC value from the old table if
|
||||||
this is an ALTER TABLE or CREATE INDEX because CREATE INDEX
|
this is an ALTER|OPTIMIZE TABLE or CREATE INDEX because CREATE INDEX
|
||||||
does a table copy too. */
|
does a table copy too. If query was one of :
|
||||||
|
|
||||||
if (((create_info->used_fields & HA_CREATE_USED_AUTO)
|
|
||||||
|| thd_sql_command(thd) == SQLCOM_ALTER_TABLE
|
|
||||||
|| thd_sql_command(thd) == SQLCOM_CREATE_INDEX)
|
|
||||||
&& create_info->auto_increment_value > 0) {
|
|
||||||
|
|
||||||
/* Query was one of :
|
|
||||||
CREATE TABLE ...AUTO_INCREMENT = x; or
|
CREATE TABLE ...AUTO_INCREMENT = x; or
|
||||||
ALTER TABLE...AUTO_INCREMENT = x; or
|
ALTER TABLE...AUTO_INCREMENT = x; or
|
||||||
|
OPTIMIZE TABLE t; or
|
||||||
CREATE INDEX x on t(...);
|
CREATE INDEX x on t(...);
|
||||||
|
|
||||||
Find out a table definition from the dictionary and get
|
Find out a table definition from the dictionary and get
|
||||||
the current value of the auto increment field. Set a new
|
the current value of the auto increment field. Set a new
|
||||||
value to the auto increment field if the value is greater
|
value to the auto increment field if the value is greater
|
||||||
than the maximum value in the column. */
|
than the maximum value in the column. */
|
||||||
|
|
||||||
|
if (((create_info->used_fields & HA_CREATE_USED_AUTO)
|
||||||
|
|| thd_sql_command(thd) == SQLCOM_ALTER_TABLE
|
||||||
|
|| thd_sql_command(thd) == SQLCOM_OPTIMIZE
|
||||||
|
|| thd_sql_command(thd) == SQLCOM_CREATE_INDEX)
|
||||||
|
&& create_info->auto_increment_value > 0) {
|
||||||
|
|
||||||
auto_inc_value = create_info->auto_increment_value;
|
auto_inc_value = create_info->auto_increment_value;
|
||||||
|
|
||||||
dict_table_autoinc_lock(innobase_table);
|
dict_table_autoinc_lock(innobase_table);
|
||||||
|
Reference in New Issue
Block a user