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
812d1521
Commit
812d1521
authored
May 18, 2006
by
holyfoot@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk@192.168.21.1:mysql-5.1-kt
into mysql.com:/home/hf/work/mysql-5.1.14573
parents
3f694eae
e5f04160
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
12 deletions
+54
-12
mysql-test/r/auto_increment.result
mysql-test/r/auto_increment.result
+6
-0
mysql-test/t/auto_increment.test
mysql-test/t/auto_increment.test
+11
-0
sql/handler.cc
sql/handler.cc
+19
-12
sql/handler.h
sql/handler.h
+1
-0
sql/share/errmsg.txt
sql/share/errmsg.txt
+3
-0
sql/sql_table.cc
sql/sql_table.cc
+14
-0
No files found.
mysql-test/r/auto_increment.result
View file @
812d1521
...
...
@@ -418,3 +418,9 @@ a val
2 1
3 1
drop table t1;
CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10));
INSERT INTO t1 VALUES(0, 0);
INSERT INTO t1 VALUES(1, 1);
ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
ERROR 23000: ALTER TABLE causes auto_increment resequencing, causing Duplicate entry '1' for key 'PRIMARY'
DROP TABLE t1;
mysql-test/t/auto_increment.test
View file @
812d1521
...
...
@@ -275,3 +275,14 @@ update t1 set a=2 where a=1;
insert
into
t1
(
val
)
values
(
1
);
select
*
from
t1
;
drop
table
t1
;
#
# Test key duplications with auto-increment in ALTER TABLE
# bug #14573
#
CREATE
TABLE
t1
(
t1
INT
(
10
)
PRIMARY
KEY
,
t2
INT
(
10
));
INSERT
INTO
t1
VALUES
(
0
,
0
);
INSERT
INTO
t1
VALUES
(
1
,
1
);
--
error
ER_DUP_ENTRY
ALTER
TABLE
t1
CHANGE
t1
t1
INT
(
10
)
auto_increment
;
DROP
TABLE
t1
;
sql/handler.cc
View file @
812d1521
...
...
@@ -1818,6 +1818,24 @@ ulonglong handler::get_auto_increment()
}
void
handler
::
print_keydupp_error
(
uint
key_nr
,
const
char
*
msg
)
{
/* Write the duplicated key in the error message */
char
key
[
MAX_KEY_LENGTH
];
String
str
(
key
,
sizeof
(
key
),
system_charset_info
);
/* Table is opened and defined at this point */
key_unpack
(
&
str
,
table
,(
uint
)
key_nr
);
uint
max_length
=
MYSQL_ERRMSG_SIZE
-
(
uint
)
strlen
(
msg
);
if
(
str
.
length
()
>=
max_length
)
{
str
.
length
(
max_length
-
4
);
str
.
append
(
STRING_WITH_LEN
(
"..."
));
}
my_printf_error
(
ER_DUP_ENTRY
,
msg
,
MYF
(
0
),
str
.
c_ptr
(),
table
->
key_info
[
key_nr
].
name
);
}
/*
Print error that we got from handler function
...
...
@@ -1857,18 +1875,7 @@ void handler::print_error(int error, myf errflag)
uint
key_nr
=
get_dup_key
(
error
);
if
((
int
)
key_nr
>=
0
)
{
/* Write the duplicated key in the error message */
char
key
[
MAX_KEY_LENGTH
];
String
str
(
key
,
sizeof
(
key
),
system_charset_info
);
/* Table is opened and defined at this point */
key_unpack
(
&
str
,
table
,(
uint
)
key_nr
);
uint
max_length
=
MYSQL_ERRMSG_SIZE
-
(
uint
)
strlen
(
ER
(
ER_DUP_ENTRY
));
if
(
str
.
length
()
>=
max_length
)
{
str
.
length
(
max_length
-
4
);
str
.
append
(
STRING_WITH_LEN
(
"..."
));
}
my_error
(
ER_DUP_ENTRY
,
MYF
(
0
),
str
.
c_ptr
(),
table
->
key_info
[
key_nr
].
name
);
print_keydupp_error
(
key_nr
,
ER
(
ER_DUP_ENTRY
));
DBUG_VOID_RETURN
;
}
textno
=
ER_DUP_KEY
;
...
...
sql/handler.h
View file @
812d1521
...
...
@@ -865,6 +865,7 @@ class handler :public Sql_alloc
virtual
int
ha_initialise
();
int
ha_open
(
TABLE
*
table
,
const
char
*
name
,
int
mode
,
int
test_if_locked
);
bool
update_auto_increment
();
void
print_keydupp_error
(
uint
key_nr
,
const
char
*
msg
);
virtual
void
print_error
(
int
error
,
myf
errflag
);
virtual
bool
get_error_message
(
int
error
,
String
*
buf
);
uint
get_dup_key
(
int
error
);
...
...
sql/share/errmsg.txt
View file @
812d1521
...
...
@@ -5842,3 +5842,6 @@ ER_WRONG_PARTITION_NAME
swe "Felaktigt partitionsnamn"
ER_CANT_CHANGE_TX_ISOLATION 25001
eng "Transaction isolation level can't be changed while a transaction is in progress"
ER_DUP_ENTRY_AUTOINCREMENT_CASE
eng "ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '%-.64s' for key '%-.64s'"
sql/sql_table.cc
View file @
812d1521
...
...
@@ -6332,6 +6332,20 @@ copy_data_between_tables(TABLE *from,TABLE *to,
(
error
!=
HA_ERR_FOUND_DUPP_KEY
&&
error
!=
HA_ERR_FOUND_DUPP_UNIQUE
))
{
if
(
error
==
HA_ERR_FOUND_DUPP_KEY
)
{
uint
key_nr
=
to
->
file
->
get_dup_key
(
error
);
if
((
int
)
key_nr
>=
0
)
{
const
char
*
err_msg
=
ER
(
ER_DUP_ENTRY
);
if
(
key_nr
==
0
&&
(
to
->
key_info
[
0
].
key_part
[
0
].
field
->
flags
&
AUTO_INCREMENT_FLAG
))
err_msg
=
ER
(
ER_DUP_ENTRY_AUTOINCREMENT_CASE
);
to
->
file
->
print_keydupp_error
(
key_nr
,
err_msg
);
break
;
}
}
to
->
file
->
print_error
(
error
,
MYF
(
0
));
break
;
}
...
...
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