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
1c732a23
Commit
1c732a23
authored
Sep 21, 2006
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #21072 Duplicate key error in NDB references wrong key: use MAX_KEY to signal unknown key
parent
dccd2c90
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
14 deletions
+31
-14
mysql-test/r/ndb_charset.result
mysql-test/r/ndb_charset.result
+2
-2
mysql-test/r/ndb_index_unique.result
mysql-test/r/ndb_index_unique.result
+5
-5
mysql-test/r/ndb_update.result
mysql-test/r/ndb_update.result
+1
-1
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+8
-1
sql/handler.cc
sql/handler.cc
+15
-5
No files found.
mysql-test/r/ndb_charset.result
View file @
1c732a23
...
@@ -78,9 +78,9 @@ unique key(a)
...
@@ -78,9 +78,9 @@ unique key(a)
) engine=ndb;
) engine=ndb;
insert into t1 values(1, 'aAa');
insert into t1 values(1, 'aAa');
insert into t1 values(2, 'aaa');
insert into t1 values(2, 'aaa');
ERROR 23000: Duplicate entry '
2' for key 1
ERROR 23000: Duplicate entry '
' for key 0
insert into t1 values(3, 'AAA');
insert into t1 values(3, 'AAA');
ERROR 23000: Duplicate entry '
3' for key 1
ERROR 23000: Duplicate entry '
' for key 0
select * from t1 order by p;
select * from t1 order by p;
p a
p a
1 aAa
1 aAa
...
...
mysql-test/r/ndb_index_unique.result
View file @
1c732a23
...
@@ -22,7 +22,7 @@ select * from t1 where b = 4 order by a;
...
@@ -22,7 +22,7 @@ select * from t1 where b = 4 order by a;
a b c
a b c
3 4 6
3 4 6
insert into t1 values(8, 2, 3);
insert into t1 values(8, 2, 3);
ERROR 23000: Duplicate entry '
8' for key 1
ERROR 23000: Duplicate entry '
' for key 0
select * from t1 order by a;
select * from t1 order by a;
a b c
a b c
1 2 3
1 2 3
...
@@ -89,7 +89,7 @@ a b c
...
@@ -89,7 +89,7 @@ a b c
1 1 1
1 1 1
4 4 NULL
4 4 NULL
insert into t1 values(5,1,1);
insert into t1 values(5,1,1);
ERROR 23000: Duplicate entry '
5' for key 1
ERROR 23000: Duplicate entry '
' for key 0
drop table t1;
drop table t1;
CREATE TABLE t2 (
CREATE TABLE t2 (
a int unsigned NOT NULL PRIMARY KEY,
a int unsigned NOT NULL PRIMARY KEY,
...
@@ -112,7 +112,7 @@ select * from t2 where b = 4 order by a;
...
@@ -112,7 +112,7 @@ select * from t2 where b = 4 order by a;
a b c
a b c
3 4 6
3 4 6
insert into t2 values(8, 2, 3);
insert into t2 values(8, 2, 3);
ERROR 23000: Duplicate entry '
8' for key 1
ERROR 23000: Duplicate entry '
' for key 0
select * from t2 order by a;
select * from t2 order by a;
a b c
a b c
1 2 3
1 2 3
...
@@ -177,7 +177,7 @@ pk a
...
@@ -177,7 +177,7 @@ pk a
3 NULL
3 NULL
4 4
4 4
insert into t1 values (5,0);
insert into t1 values (5,0);
ERROR 23000: Duplicate entry '
5' for key 1
ERROR 23000: Duplicate entry '
' for key 0
select * from t1 order by pk;
select * from t1 order by pk;
pk a
pk a
-1 NULL
-1 NULL
...
@@ -210,7 +210,7 @@ pk a b c
...
@@ -210,7 +210,7 @@ pk a b c
0 NULL 18 NULL
0 NULL 18 NULL
1 3 19 abc
1 3 19 abc
insert into t2 values(2,3,19,'abc');
insert into t2 values(2,3,19,'abc');
ERROR 23000: Duplicate entry '
2' for key 1
ERROR 23000: Duplicate entry '
' for key 0
select * from t2 order by pk;
select * from t2 order by pk;
pk a b c
pk a b c
-1 1 17 NULL
-1 1 17 NULL
...
...
mysql-test/r/ndb_update.result
View file @
1c732a23
...
@@ -18,7 +18,7 @@ pk1 b c
...
@@ -18,7 +18,7 @@ pk1 b c
2 2 2
2 2 2
4 1 1
4 1 1
UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4;
UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4;
ERROR 23000: Duplicate entry '
1' for key 1
ERROR 23000: Duplicate entry '
' for key 0
select * from t1 order by pk1;
select * from t1 order by pk1;
pk1 b c
pk1 b c
0 0 0
0 0 0
...
...
sql/ha_ndbcluster.cc
View file @
1c732a23
...
@@ -454,7 +454,14 @@ int ha_ndbcluster::ndb_err(NdbConnection *trans)
...
@@ -454,7 +454,14 @@ int ha_ndbcluster::ndb_err(NdbConnection *trans)
if
(
res
==
HA_ERR_FOUND_DUPP_KEY
)
if
(
res
==
HA_ERR_FOUND_DUPP_KEY
)
{
{
if
(
m_rows_to_insert
==
1
)
if
(
m_rows_to_insert
==
1
)
m_dupkey
=
table
->
primary_key
;
{
/*
We can only distinguish between primary and non-primary
violations here, so we need to return MAX_KEY for non-primary
to signal that key is unknown
*/
m_dupkey
=
err
.
code
==
630
?
table
->
primary_key
:
MAX_KEY
;
}
else
else
{
{
/* We are batching inserts, offending key is not available */
/* We are batching inserts, offending key is not available */
...
...
sql/handler.cc
View file @
1c732a23
...
@@ -1102,12 +1102,22 @@ void handler::print_error(int error, myf errflag)
...
@@ -1102,12 +1102,22 @@ void handler::print_error(int error, myf errflag)
/* Write the dupplicated key in the error message */
/* Write the dupplicated key in the error message */
char
key
[
MAX_KEY_LENGTH
];
char
key
[
MAX_KEY_LENGTH
];
String
str
(
key
,
sizeof
(
key
),
system_charset_info
);
String
str
(
key
,
sizeof
(
key
),
system_charset_info
);
key_unpack
(
&
str
,
table
,(
uint
)
key_nr
);
uint
max_length
=
MYSQL_ERRMSG_SIZE
-
(
uint
)
strlen
(
ER
(
ER_DUP_ENTRY
));
if
(
key_nr
==
MAX_KEY
)
if
(
str
.
length
()
>=
max_length
)
{
/* Key is unknown */
str
.
length
(
0
);
key_nr
=
-
1
;
}
else
{
{
str
.
length
(
max_length
-
4
);
key_unpack
(
&
str
,
table
,(
uint
)
key_nr
);
str
.
append
(
"..."
);
uint
max_length
=
MYSQL_ERRMSG_SIZE
-
(
uint
)
strlen
(
ER
(
ER_DUP_ENTRY
));
if
(
str
.
length
()
>=
max_length
)
{
str
.
length
(
max_length
-
4
);
str
.
append
(
"..."
);
}
}
}
my_error
(
ER_DUP_ENTRY
,
MYF
(
0
),
str
.
c_ptr
(),
key_nr
+
1
);
my_error
(
ER_DUP_ENTRY
,
MYF
(
0
),
str
.
c_ptr
(),
key_nr
+
1
);
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
...
...
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