Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
1e130ba6
Commit
1e130ba6
authored
Mar 03, 2008
by
sunny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
branches/5.1: Fix Bug# 34920. We need to use/inherit the passed in autoinc
counter for ALTER TABLE statements too.
parent
30ee677a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
2 deletions
+51
-2
handler/ha_innodb.cc
handler/ha_innodb.cc
+9
-2
mysql-test/innodb.result
mysql-test/innodb.result
+19
-0
mysql-test/innodb.test
mysql-test/innodb.test
+23
-0
No files found.
handler/ha_innodb.cc
View file @
1e130ba6
...
...
@@ -5109,8 +5109,15 @@ ha_innobase::create(
DBUG_ASSERT
(
innobase_table
!=
0
);
if
((
create_info
->
used_fields
&
HA_CREATE_USED_AUTO
)
&&
(
create_info
->
auto_increment_value
!=
0
))
{
/* Note: We can't call update_thd() as prebuilt will not be
setup at this stage and so we use thd. */
/* We need to copy the AUTOINC value from the old table if
this is an ALTER TABLE. */
if
(((
create_info
->
used_fields
&
HA_CREATE_USED_AUTO
)
||
thd_sql_command
(
thd
)
==
SQLCOM_ALTER_TABLE
)
&&
create_info
->
auto_increment_value
!=
0
)
{
/* Query was ALTER TABLE...AUTO_INCREMENT = x; or
CREATE TABLE ...AUTO_INCREMENT = x; Find out a table
...
...
mysql-test/innodb.result
View file @
1e130ba6
...
...
@@ -3231,3 +3231,22 @@ a
2
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE t1 (
c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
c2 VARCHAR(128) NOT NULL,
PRIMARY KEY(c1)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
CREATE TABLE t2 (
c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
c2 INT(10) UNSIGNED DEFAULT NULL,
PRIMARY KEY(c1)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200;
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
AUTO_INCREMENT
200
ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1);
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
AUTO_INCREMENT
200
DROP TABLE t2;
DROP TABLE t1;
mysql-test/innodb.test
View file @
1e130ba6
...
...
@@ -2415,6 +2415,29 @@ DROP TABLE t2;
DISCONNECT
c1
;
DISCONNECT
c2
;
#
# Bug 34920 test
#
CONNECTION
default
;
CREATE
TABLE
t1
(
c1
INT
(
10
)
UNSIGNED
NOT
NULL
AUTO_INCREMENT
,
c2
VARCHAR
(
128
)
NOT
NULL
,
PRIMARY
KEY
(
c1
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
AUTO_INCREMENT
=
100
;
CREATE
TABLE
t2
(
c1
INT
(
10
)
UNSIGNED
NOT
NULL
AUTO_INCREMENT
,
c2
INT
(
10
)
UNSIGNED
DEFAULT
NULL
,
PRIMARY
KEY
(
c1
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
AUTO_INCREMENT
=
200
;
SELECT
AUTO_INCREMENT
FROM
INFORMATION_SCHEMA
.
TABLES
WHERE
table_name
=
't2'
;
ALTER
TABLE
t2
ADD
CONSTRAINT
t1_t2_1
FOREIGN
KEY
(
c1
)
REFERENCES
t1
(
c1
);
SELECT
AUTO_INCREMENT
FROM
INFORMATION_SCHEMA
.
TABLES
WHERE
table_name
=
't2'
;
DROP
TABLE
t2
;
DROP
TABLE
t1
;
# End 34920 test
#######################################################################
# #
# Please, DO NOT TOUCH this file as well as the innodb.result file. #
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment