mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
Report the current value of the AUTO_INCREMENT counter to MySQL.
(Bug #23313, Bug #21404) ha_innobase::update_create_info(): New function, to report the auto_increment_value.
This commit is contained in:
parent
ba4a168cd0
commit
52438c3572
4 changed files with 60 additions and 0 deletions
|
@ -4769,6 +4769,20 @@ create_clustered_index_when_no_primary(
|
|||
return(error);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Update create_info. Used in SHOW CREATE TABLE et al. */
|
||||
|
||||
void
|
||||
ha_innobase::update_create_info(
|
||||
/*============================*/
|
||||
HA_CREATE_INFO* create_info) /* in/out: create info */
|
||||
{
|
||||
if (!(create_info->used_fields & HA_CREATE_USED_AUTO)) {
|
||||
ha_innobase::info(HA_STATUS_AUTO);
|
||||
create_info->auto_increment_value = stats.auto_increment_value;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Creates a new table to an InnoDB database. */
|
||||
|
||||
|
|
|
@ -150,6 +150,7 @@ class ha_innobase: public handler
|
|||
*max_key);
|
||||
ha_rows estimate_rows_upper_bound();
|
||||
|
||||
void update_create_info(HA_CREATE_INFO* create_info);
|
||||
int create(const char *name, register TABLE *form,
|
||||
HA_CREATE_INFO *create_info);
|
||||
int delete_all_rows();
|
||||
|
|
|
@ -3159,6 +3159,31 @@ t2 CREATE TABLE `t2` (
|
|||
CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2, t1;
|
||||
CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
|
||||
AUTO_INCREMENT=42;
|
||||
INSERT INTO t1 VALUES (0),(347),(0);
|
||||
SELECT * FROM t1;
|
||||
id
|
||||
42
|
||||
347
|
||||
348
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
|
||||
CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES(42),(347),(348);
|
||||
ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `t1_t2` FOREIGN KEY (`id`) REFERENCES `t2` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
|
||||
CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
|
|
|
@ -2320,6 +2320,26 @@ INSERT INTO t1 VALUES ('DDD');
|
|||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #23313 (AUTO_INCREMENT=# not reported back for InnoDB tables)
|
||||
# Bug #21404 (AUTO_INCREMENT value reset when Adding FKEY (or ALTER?))
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
|
||||
AUTO_INCREMENT=42;
|
||||
|
||||
INSERT INTO t1 VALUES (0),(347),(0);
|
||||
SELECT * FROM t1;
|
||||
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES(42),(347),(348);
|
||||
ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
#######################################################################
|
||||
# #
|
||||
# Please, DO NOT TOUCH this file as well as the innodb.result file. #
|
||||
|
|
Loading…
Reference in a new issue