Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
6e5a9f2d
Commit
6e5a9f2d
authored
Dec 23, 2019
by
Benjamin Morel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document MySQL error codes
parent
1a9812bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
55 deletions
+118
-55
AbstractMySQLDriver.php
lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
+118
-55
No files found.
lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
View file @
6e5a9f2d
...
...
@@ -27,85 +27,148 @@ use function version_compare;
*/
abstract
class
AbstractMySQLDriver
implements
ExceptionConverterDriver
,
VersionAwarePlatformDriver
{
/**#@+
* MySQL server error codes.
*
* @link https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html
*/
private
const
ER_DBACCESS_DENIED_ERROR
=
1044
;
private
const
ER_ACCESS_DENIED_ERROR
=
1045
;
private
const
ER_NO_DB_ERROR
=
1046
;
private
const
ER_BAD_NULL_ERROR
=
1048
;
private
const
ER_BAD_DB_ERROR
=
1049
;
private
const
ER_TABLE_EXISTS_ERROR
=
1050
;
private
const
ER_BAD_TABLE_ERROR
=
1051
;
private
const
ER_NON_UNIQ_ERROR
=
1052
;
private
const
ER_BAD_FIELD_ERROR
=
1054
;
private
const
ER_DUP_FIELDNAME
=
1060
;
private
const
ER_DUP_ENTRY
=
1062
;
private
const
ER_PARSE_ERROR
=
1064
;
private
const
ER_KILL_DENIED_ERROR
=
1095
;
private
const
ER_FIELD_SPECIFIED_TWICE
=
1110
;
private
const
ER_NULL_COLUMN_IN_INDEX
=
1121
;
private
const
ER_INVALID_USE_OF_NULL
=
1138
;
private
const
ER_TABLEACCESS_DENIED_ERROR
=
1142
;
private
const
ER_COLUMNACCESS_DENIED_ERROR
=
1143
;
private
const
ER_NO_SUCH_TABLE
=
1146
;
private
const
ER_SYNTAX_ERROR
=
1149
;
private
const
ER_WRONG_COLUMN_NAME
=
1166
;
private
const
ER_PRIMARY_CANT_HAVE_NULL
=
1171
;
private
const
ER_LOCK_WAIT_TIMEOUT
=
1205
;
private
const
ER_LOCK_DEADLOCK
=
1213
;
private
const
ER_NO_REFERENCED_ROW
=
1216
;
private
const
ER_ROW_IS_REFERENCED
=
1217
;
private
const
ER_SPECIFIC_ACCESS_DENIED_ERROR
=
1227
;
private
const
ER_SPATIAL_CANT_HAVE_NULL
=
1252
;
private
const
ER_WARN_NULL_TO_NOTNULL
=
1263
;
private
const
ER_WARN_DEPRECATED_SYNTAX
=
1287
;
private
const
ER_FPARSER_BAD_HEADER
=
1341
;
private
const
ER_FPARSER_EOF_IN_COMMENT
=
1342
;
private
const
ER_FPARSER_ERROR_IN_PARAMETER
=
1343
;
private
const
ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER
=
1344
;
private
const
ER_NO_DEFAULT_FOR_FIELD
=
1364
;
private
const
ER_PROCACCESS_DENIED_ERROR
=
1370
;
private
const
ER_RESERVED_SYNTAX
=
1382
;
private
const
ER_CONNECT_TO_FOREIGN_DATA_SOURCE
=
1429
;
private
const
ER_ROW_IS_REFERENCED_2
=
1451
;
private
const
ER_NO_REFERENCED_ROW_2
=
1452
;
private
const
ER_PARTITION_REQUIRES_VALUES_ERROR
=
1479
;
private
const
ER_EVENT_DROP_FAILED
=
1541
;
private
const
ER_WARN_DEPRECATED_SYNTAX_WITH_VER
=
1554
;
private
const
ER_FOREIGN_DUPLICATE_KEY_OLD_UNUSED
=
1557
;
private
const
ER_NULL_IN_VALUES_LESS_THAN
=
1566
;
private
const
ER_DUP_ENTRY_AUTOINCREMENT_CASE
=
1569
;
private
const
ER_DUP_ENTRY_WITH_KEY_NAME
=
1586
;
private
const
ER_LOAD_DATA_INVALID_COLUMN
=
1611
;
private
const
ER_CONFLICT_FN_PARSE_ERROR
=
1626
;
private
const
ER_TRUNCATE_ILLEGAL_FK
=
1701
;
/**#@-*/
/**#@+
* MySQL client error codes.
*
* @link https://dev.mysql.com/doc/refman/8.0/en/client-error-reference.html
*/
private
const
CR_CONNECTION_ERROR
=
2002
;
private
const
CR_UNKNOWN_HOST
=
2005
;
/**#@-*/
/**
* {@inheritdoc}
*
* @link http://dev.mysql.com/doc/refman/5.7/en/error-messages-client.html
* @link http://dev.mysql.com/doc/refman/5.7/en/error-messages-server.html
*/
public
function
convertException
(
string
$message
,
DriverExceptionInterface
$exception
)
:
DriverException
{
switch
(
$exception
->
getCode
())
{
case
1213
:
case
self
::
ER_LOCK_DEADLOCK
:
return
new
Exception\DeadlockException
(
$message
,
$exception
);
case
1205
:
case
self
::
ER_LOCK_WAIT_TIMEOUT
:
return
new
Exception\LockWaitTimeoutException
(
$message
,
$exception
);
case
1050
:
case
self
::
ER_TABLE_EXISTS_ERROR
:
return
new
Exception\TableExistsException
(
$message
,
$exception
);
case
1051
:
case
1146
:
case
self
::
ER_BAD_TABLE_ERROR
:
case
self
::
ER_NO_SUCH_TABLE
:
return
new
Exception\TableNotFoundException
(
$message
,
$exception
);
case
1216
:
case
1217
:
case
1451
:
case
145
2
:
case
1701
:
case
self
::
ER_NO_REFERENCED_ROW
:
case
self
::
ER_ROW_IS_REFERENCED
:
case
self
::
ER_ROW_IS_REFERENCED_2
:
case
self
::
ER_NO_REFERENCED_ROW_
2
:
case
self
::
ER_TRUNCATE_ILLEGAL_FK
:
return
new
Exception\ForeignKeyConstraintViolationException
(
$message
,
$exception
);
case
1062
:
case
1557
:
case
1569
:
case
1586
:
case
self
::
ER_DUP_ENTRY
:
case
self
::
ER_FOREIGN_DUPLICATE_KEY_OLD_UNUSED
:
case
self
::
ER_DUP_ENTRY_AUTOINCREMENT_CASE
:
case
self
::
ER_DUP_ENTRY_WITH_KEY_NAME
:
return
new
Exception\UniqueConstraintViolationException
(
$message
,
$exception
);
case
1054
:
case
1166
:
case
1611
:
case
self
::
ER_BAD_FIELD_ERROR
:
case
self
::
ER_WRONG_COLUMN_NAME
:
case
self
::
ER_LOAD_DATA_INVALID_COLUMN
:
return
new
Exception\InvalidFieldNameException
(
$message
,
$exception
);
case
1052
:
case
1060
:
case
1110
:
case
self
::
ER_NON_UNIQ_ERROR
:
case
self
::
ER_DUP_FIELDNAME
:
case
self
::
ER_FIELD_SPECIFIED_TWICE
:
return
new
Exception\NonUniqueFieldNameException
(
$message
,
$exception
);
case
1064
:
case
1149
:
case
1287
:
case
1341
:
case
1342
:
case
1343
:
case
1344
:
case
1382
:
case
1479
:
case
1541
:
case
1554
:
case
1626
:
case
self
::
ER_PARSE_ERROR
:
case
self
::
ER_SYNTAX_ERROR
:
case
self
::
ER_WARN_DEPRECATED_SYNTAX
:
case
self
::
ER_FPARSER_BAD_HEADER
:
case
self
::
ER_FPARSER_EOF_IN_COMMENT
:
case
self
::
ER_FPARSER_ERROR_IN_PARAMETER
:
case
self
::
ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER
:
case
self
::
ER_RESERVED_SYNTAX
:
case
self
::
ER_PARTITION_REQUIRES_VALUES_ERROR
:
case
self
::
ER_EVENT_DROP_FAILED
:
case
self
::
ER_WARN_DEPRECATED_SYNTAX_WITH_VER
:
case
self
::
ER_CONFLICT_FN_PARSE_ERROR
:
return
new
Exception\SyntaxErrorException
(
$message
,
$exception
);
case
1044
:
case
1045
:
case
1046
:
case
1049
:
case
1095
:
case
1142
:
case
1143
:
case
1227
:
case
1370
:
case
1429
:
case
2002
:
case
2005
:
case
self
::
ER_DBACCESS_DENIED_ERROR
:
case
self
::
ER_ACCESS_DENIED_ERROR
:
case
self
::
ER_NO_DB_ERROR
:
case
self
::
ER_BAD_DB_ERROR
:
case
self
::
ER_KILL_DENIED_ERROR
:
case
self
::
ER_TABLEACCESS_DENIED_ERROR
:
case
self
::
ER_COLUMNACCESS_DENIED_ERROR
:
case
self
::
ER_SPECIFIC_ACCESS_DENIED_ERROR
:
case
self
::
ER_PROCACCESS_DENIED_ERROR
:
case
self
::
ER_CONNECT_TO_FOREIGN_DATA_SOURCE
:
case
self
::
CR_CONNECTION_ERROR
:
case
self
::
CR_UNKNOWN_HOST
:
return
new
Exception\ConnectionException
(
$message
,
$exception
);
case
1048
:
case
1121
:
case
1138
:
case
1171
:
case
1252
:
case
1263
:
case
1364
:
case
1566
:
case
self
::
ER_BAD_NULL_ERROR
:
case
self
::
ER_NULL_COLUMN_IN_INDEX
:
case
self
::
ER_INVALID_USE_OF_NULL
:
case
self
::
ER_PRIMARY_CANT_HAVE_NULL
:
case
self
::
ER_SPATIAL_CANT_HAVE_NULL
:
case
self
::
ER_WARN_NULL_TO_NOTNULL
:
case
self
::
ER_NO_DEFAULT_FOR_FIELD
:
case
self
::
ER_NULL_IN_VALUES_LESS_THAN
:
return
new
Exception\NotNullConstraintViolationException
(
$message
,
$exception
);
}
...
...
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