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
f6402642
Commit
f6402642
authored
Nov 14, 2010
by
Jimmy Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Bug #16290 Unclear error message when adding foreign key constraint
rb://502
approved by Sunny Bains
parent
a8266151
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
2 deletions
+37
-2
storage/innobase/dict/dict0dict.c
storage/innobase/dict/dict0dict.c
+2
-2
storage/innobase/handler/ha_innodb.cc
storage/innobase/handler/ha_innodb.cc
+25
-0
storage/innobase/include/db0err.h
storage/innobase/include/db0err.h
+6
-0
storage/innobase/ut/ut0ut.c
storage/innobase/ut/ut0ut.c
+4
-0
No files found.
storage/innobase/dict/dict0dict.c
View file @
f6402642
...
@@ -3483,7 +3483,7 @@ col_loop1:
...
@@ -3483,7 +3483,7 @@ col_loop1:
start_of_latest_foreign
);
start_of_latest_foreign
);
mutex_exit
(
&
dict_foreign_err_mutex
);
mutex_exit
(
&
dict_foreign_err_mutex
);
return
(
DB_C
ANNOT_ADD_CONSTRAINT
);
return
(
DB_C
HILD_NO_INDEX
);
}
}
ptr
=
dict_accept
(
cs
,
ptr
,
"REFERENCES"
,
&
success
);
ptr
=
dict_accept
(
cs
,
ptr
,
"REFERENCES"
,
&
success
);
...
@@ -3764,7 +3764,7 @@ try_find_index:
...
@@ -3764,7 +3764,7 @@ try_find_index:
start_of_latest_foreign
);
start_of_latest_foreign
);
mutex_exit
(
&
dict_foreign_err_mutex
);
mutex_exit
(
&
dict_foreign_err_mutex
);
return
(
DB_
CANNOT_ADD_CONSTRAINT
);
return
(
DB_
PARENT_NO_INDEX
);
}
}
}
else
{
}
else
{
ut_a
(
trx
->
check_foreigns
==
FALSE
);
ut_a
(
trx
->
check_foreigns
==
FALSE
);
...
...
storage/innobase/handler/ha_innodb.cc
View file @
f6402642
...
@@ -960,6 +960,8 @@ convert_error_code_to_mysql(
...
@@ -960,6 +960,8 @@ convert_error_code_to_mysql(
return
(
HA_ERR_ROW_IS_REFERENCED
);
return
(
HA_ERR_ROW_IS_REFERENCED
);
case
DB_CANNOT_ADD_CONSTRAINT
:
case
DB_CANNOT_ADD_CONSTRAINT
:
case
DB_CHILD_NO_INDEX
:
case
DB_PARENT_NO_INDEX
:
return
(
HA_ERR_CANNOT_ADD_FOREIGN
);
return
(
HA_ERR_CANNOT_ADD_FOREIGN
);
case
DB_CANNOT_DROP_CONSTRAINT
:
case
DB_CANNOT_DROP_CONSTRAINT
:
...
@@ -6977,6 +6979,29 @@ ha_innobase::create(
...
@@ -6977,6 +6979,29 @@ ha_innobase::create(
trx
,
stmt
,
stmt_len
,
norm_name
,
trx
,
stmt
,
stmt_len
,
norm_name
,
create_info
->
options
&
HA_LEX_CREATE_TMP_TABLE
);
create_info
->
options
&
HA_LEX_CREATE_TMP_TABLE
);
switch
(
error
)
{
case
DB_PARENT_NO_INDEX
:
push_warning_printf
(
thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
HA_ERR_CANNOT_ADD_FOREIGN
,
"Create table '%s' with foreign key constraint"
" failed. There is no index in the referenced"
" table where the referenced columns appear"
" as the first columns.
\n
"
,
norm_name
);
break
;
case
DB_CHILD_NO_INDEX
:
push_warning_printf
(
thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
HA_ERR_CANNOT_ADD_FOREIGN
,
"Create table '%s' with foreign key constraint"
" failed. There is no index in the referencing"
" table where referencing columns appear"
" as the first columns.
\n
"
,
norm_name
);
break
;
}
error
=
convert_error_code_to_mysql
(
error
,
flags
,
NULL
);
error
=
convert_error_code_to_mysql
(
error
,
flags
,
NULL
);
if
(
error
)
{
if
(
error
)
{
...
...
storage/innobase/include/db0err.h
View file @
f6402642
...
@@ -104,6 +104,12 @@ enum db_err {
...
@@ -104,6 +104,12 @@ enum db_err {
DB_FOREIGN_EXCEED_MAX_CASCADE
,
/* Foreign key constraint related
DB_FOREIGN_EXCEED_MAX_CASCADE
,
/* Foreign key constraint related
cascading delete/update exceeds
cascading delete/update exceeds
maximum allowed depth */
maximum allowed depth */
DB_CHILD_NO_INDEX
,
/* the child (foreign) table does not
have an index that contains the
foreign keys as its prefix columns */
DB_PARENT_NO_INDEX
,
/* the parent table does not
have an index that contains the
foreign keys as its prefix columns */
/* The following are partial failure codes */
/* The following are partial failure codes */
DB_FAIL
=
1000
,
DB_FAIL
=
1000
,
...
...
storage/innobase/ut/ut0ut.c
View file @
f6402642
...
@@ -715,6 +715,10 @@ ut_strerr(
...
@@ -715,6 +715,10 @@ ut_strerr(
return
(
"Zip overflow"
);
return
(
"Zip overflow"
);
case
DB_RECORD_NOT_FOUND
:
case
DB_RECORD_NOT_FOUND
:
return
(
"Record not found"
);
return
(
"Record not found"
);
case
DB_CHILD_NO_INDEX
:
return
(
"No index on referencing keys in referencing table"
);
case
DB_PARENT_NO_INDEX
:
return
(
"No index on referenced keys in referenced table"
);
case
DB_END_OF_INDEX
:
case
DB_END_OF_INDEX
:
return
(
"End of index"
);
return
(
"End of index"
);
/* do not add default: in order to produce a warning if new code
/* do not add default: in order to produce a warning if new code
...
...
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