Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic exception handling for IBM DB2 #4929

Merged
merged 2 commits into from
Oct 25, 2021

Conversation

morozov
Copy link
Member

@morozov morozov commented Oct 24, 2021

Q A
Type improvement
BC Break no

MySQL

After the changes in #4928, the build on PHP 7.3 and MySQL 8 started failing with:

1) Doctrine\DBAL\Tests\Functional\ExceptionTest::testInvalidUserName
Failed asserting that exception of type "Doctrine\DBAL\Exception\DriverException" matches expected exception "Doctrine\DBAL\Exception\ConnectionException". Message was: "An exception occurred in the driver: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client" at

I cannot reproduce it locally and it didn't fail previously, but we need to fix it in order to let the build pass on this PR.

IBM DB2

  1. Although there's no statement resource available during db2_exec(), if it fails, the error information will be available via db2_stmt_*(), not db2_conn_*(). The driver will use the latest executed statement which is available to the driver internally.
  2. The call to @db2_execute needs to be error-suppressed since otherwise, it may trigger a warning.
  3. The SQLSTATE exposed via db2_(conn|stmt)_error() doesn't uniquely identify a given error type, so it cannot be used for instantiation of error-specific exceptions.
  4. The SQLSTATE and SQLCODE that do uniquely identify a given error type are only available as part of the error message, so we have to parse it to get the code.
  5. Since each factory method accepts a message and has to instantiate its own class, we need a factory that parses the message and instantiates the exception with the corresponding code.
  6. VALUE is a reserved keyword in IBM DB2, so we have to use another name in the integration test.

@morozov morozov added the MySQL label Oct 24, 2021
@morozov morozov marked this pull request as ready for review October 24, 2021 21:12
@derrabus derrabus merged commit 96125a3 into doctrine:3.2.x Oct 25, 2021
@morozov morozov deleted the ibm-db2-exception-handler branch October 25, 2021 16:22
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants