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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
5f0c98c1
Commit
5f0c98c1
authored
Apr 07, 2014
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-5743 Server crashes in mysql_alter_table on an attempt to add a primary key to InnoDB table
parent
e82a82ee
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletion
+21
-1
mysql-test/r/alter_table_trans.result
mysql-test/r/alter_table_trans.result
+8
-0
mysql-test/t/alter_table_trans.test
mysql-test/t/alter_table_trans.test
+12
-0
sql/sql_table.cc
sql/sql_table.cc
+1
-1
No files found.
mysql-test/r/alter_table_trans.result
View file @
5f0c98c1
...
@@ -16,3 +16,11 @@ insert t1 values (repeat('3', 8193),3,1,1);
...
@@ -16,3 +16,11 @@ insert t1 values (repeat('3', 8193),3,1,1);
ALTER TABLE t1 ADD PRIMARY KEY (col4(10)) , ADD UNIQUE KEY uidx (col3);
ALTER TABLE t1 ADD PRIMARY KEY (col4(10)) , ADD UNIQUE KEY uidx (col3);
ERROR 23000: Duplicate entry '1' for key 'uidx'
ERROR 23000: Duplicate entry '1' for key 'uidx'
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (a INT) ENGINE = InnoDB;
INSERT INTO t1 VALUES (2);
ALTER TABLE t1 ADD PRIMARY KEY (a);
ALTER TABLE t1 DROP PRIMARY KEY;
INSERT INTO t1 VALUES (2);
ALTER TABLE t1 ADD PRIMARY KEY (a);
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
DROP TABLE t1;
mysql-test/t/alter_table_trans.test
View file @
5f0c98c1
...
@@ -32,4 +32,16 @@ insert t1 values (repeat('3', 8193),3,1,1);
...
@@ -32,4 +32,16 @@ insert t1 values (repeat('3', 8193),3,1,1);
ALTER
TABLE
t1
ADD
PRIMARY
KEY
(
col4
(
10
))
,
ADD
UNIQUE
KEY
uidx
(
col3
);
ALTER
TABLE
t1
ADD
PRIMARY
KEY
(
col4
(
10
))
,
ADD
UNIQUE
KEY
uidx
(
col3
);
DROP
TABLE
t1
;
DROP
TABLE
t1
;
#
# MDEV-5743 Server crashes in mysql_alter_table on an attempt to add a primary key to InnoDB table
#
CREATE
TABLE
t1
(
a
INT
)
ENGINE
=
InnoDB
;
INSERT
INTO
t1
VALUES
(
2
);
ALTER
TABLE
t1
ADD
PRIMARY
KEY
(
a
);
ALTER
TABLE
t1
DROP
PRIMARY
KEY
;
INSERT
INTO
t1
VALUES
(
2
);
--
error
ER_DUP_ENTRY
ALTER
TABLE
t1
ADD
PRIMARY
KEY
(
a
);
DROP
TABLE
t1
;
sql/sql_table.cc
View file @
5f0c98c1
...
@@ -6908,7 +6908,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
...
@@ -6908,7 +6908,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
if
(
is_PK
(
key_info
))
if
(
is_PK
(
key_info
))
{
{
merged
[
0
]
=
key_info
[
0
];
merged
[
0
]
=
key_info
[
0
];
if
(
is_PK
(
table
->
key_info
))
if
(
table
->
key_info
&&
is_PK
(
table
->
key_info
))
{
{
old_cnt
--
;
old_cnt
--
;
table
->
key_info
++
;
table
->
key_info
++
;
...
...
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