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
b532e505
Commit
b532e505
authored
Aug 08, 2007
by
marko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
branches/zip: convert_error_code_to_mysql(): replace if-else with switch-case
parent
33bf9d50
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
41 deletions
+25
-41
handler/ha_innodb.cc
handler/ha_innodb.cc
+25
-41
No files found.
handler/ha_innodb.cc
View file @
b532e505
...
...
@@ -583,27 +583,24 @@ convert_error_code_to_mysql(
int
error
,
/* in: InnoDB error code */
THD
*
thd
)
/* in: user thread handle or NULL */
{
if
(
error
==
DB_SUCCESS
)
{
switch
(
error
)
{
case
DB_SUCCESS
:
return
(
0
);
}
else
if
(
error
==
(
int
)
DB_DUPLICATE_KEY
)
{
case
DB_ERROR
:
default:
return
(
-
1
);
/* unspecified error */
case
DB_DUPLICATE_KEY
:
return
(
HA_ERR_FOUND_DUPP_KEY
);
}
else
if
(
error
==
(
int
)
DB_FOREIGN_DUPLICATE_KEY
)
{
case
DB_FOREIGN_DUPLICATE_KEY
:
return
(
HA_ERR_FOREIGN_DUPLICATE_KEY
);
}
else
if
(
error
==
(
int
)
DB_RECORD_NOT_FOUND
)
{
case
DB_RECORD_NOT_FOUND
:
return
(
HA_ERR_NO_ACTIVE_RECORD
);
}
else
if
(
error
==
(
int
)
DB_ERROR
)
{
return
(
-
1
);
/* unspecified error */
}
else
if
(
error
==
(
int
)
DB_DEADLOCK
)
{
case
DB_DEADLOCK
:
/* Since we rolled back the whole transaction, we must
tell it also to MySQL so that MySQL knows to empty the
cached binlog for this transaction */
...
...
@@ -614,8 +611,7 @@ convert_error_code_to_mysql(
return
(
HA_ERR_LOCK_DEADLOCK
);
}
else
if
(
error
==
(
int
)
DB_LOCK_WAIT_TIMEOUT
)
{
case
DB_LOCK_WAIT_TIMEOUT
:
/* Starting from 5.0.13, we let MySQL just roll back the
latest SQL statement in a lock wait timeout. Previously, we
rolled back the whole transaction. */
...
...
@@ -626,50 +622,41 @@ convert_error_code_to_mysql(
return
(
HA_ERR_LOCK_WAIT_TIMEOUT
);
}
else
if
(
error
==
(
int
)
DB_NO_REFERENCED_ROW
)
{
case
DB_NO_REFERENCED_ROW
:
return
(
HA_ERR_NO_REFERENCED_ROW
);
}
else
if
(
error
==
(
int
)
DB_ROW_IS_REFERENCED
)
{
case
DB_ROW_IS_REFERENCED
:
return
(
HA_ERR_ROW_IS_REFERENCED
);
}
else
if
(
error
==
(
int
)
DB_CANNOT_ADD_CONSTRAINT
)
{
case
DB_CANNOT_ADD_CONSTRAINT
:
return
(
HA_ERR_CANNOT_ADD_FOREIGN
);
}
else
if
(
error
==
(
int
)
DB_CANNOT_DROP_CONSTRAINT
)
{
case
DB_CANNOT_DROP_CONSTRAINT
:
return
(
HA_ERR_ROW_IS_REFERENCED
);
/* TODO: This is a bit
misleading, a new MySQL error
code should be introduced */
}
else
if
(
error
==
(
int
)
DB_COL_APPEARS_TWICE_IN_INDEX
)
{
case
DB_COL_APPEARS_TWICE_IN_INDEX
:
case
DB_CORRUPTION
:
return
(
HA_ERR_CRASHED
);
}
else
if
(
error
==
(
int
)
DB_OUT_OF_FILE_SPACE
)
{
case
DB_OUT_OF_FILE_SPACE
:
return
(
HA_ERR_RECORD_FILE_FULL
);
}
else
if
(
error
==
(
int
)
DB_TABLE_IS_BEING_USED
)
{
case
DB_TABLE_IS_BEING_USED
:
return
(
HA_ERR_WRONG_COMMAND
);
}
else
if
(
error
==
(
int
)
DB_TABLE_NOT_FOUND
)
{
case
DB_TABLE_NOT_FOUND
:
return
(
HA_ERR_NO_SUCH_TABLE
);
}
else
if
(
error
==
(
int
)
DB_TOO_BIG_RECORD
)
{
case
DB_TOO_BIG_RECORD
:
return
(
HA_ERR_TO_BIG_ROW
);
}
else
if
(
error
==
(
int
)
DB_CORRUPTION
)
{
return
(
HA_ERR_CRASHED
);
}
else
if
(
error
==
(
int
)
DB_NO_SAVEPOINT
)
{
case
DB_NO_SAVEPOINT
:
return
(
HA_ERR_NO_SAVEPOINT
);
}
else
if
(
error
==
(
int
)
DB_LOCK_TABLE_FULL
)
{
case
DB_LOCK_TABLE_FULL
:
/* Since we rolled back the whole transaction, we must
tell it also to MySQL so that MySQL knows to empty the
cached binlog for this transaction */
...
...
@@ -679,11 +666,11 @@ convert_error_code_to_mysql(
}
return
(
HA_ERR_LOCK_TABLE_FULL
);
}
else
if
(
error
==
(
int
)
DB_CANNOT_DROP_FOREIGN_INDEX
)
{
case
DB_CANNOT_DROP_FOREIGN_INDEX
:
return
(
HA_ERR_DROP_INDEX_FK
);
}
else
if
(
error
==
DB_TOO_MANY_CONCURRENT_TRXS
)
{
case
DB_TOO_MANY_CONCURRENT_TRXS
:
/* Once MySQL add the appropriate code to errmsg.txt then
we can get rid of this #ifdef. NOTE: The code checked by
the #ifdef is the suggested name for the error condition
...
...
@@ -695,9 +682,6 @@ convert_error_code_to_mysql(
#else
return
(
HA_ERR_RECORD_FILE_FULL
);
#endif
}
else
{
return
(
-
1
);
// Unknown error
}
}
...
...
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