Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-707

[GH-447] Fix IBM DB2 implementation / ibm_db2 driver

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      This issue is created automatically through a Github pull request on behalf of deeky666:

      Url: https://github.com/doctrine/dbal/pull/447

      Message:

      This PR is a first approach towards officially supporting IBM DB2 platform in DBAL. The current implementation of the platform and schema manager are very outdated, buggy and incomplete. There is no platform test case yet and running the general DBAL test suite shows a lot of errors.
      The focus of this PR is to bring back the DB2 platform and schema manager into sync mit the abstract classes so that at least the test suite runs. Furthermore this PR adds a platform test case. Along with achieving this, a lot of bugs needed to be fixed. The following changes have been made:

      • Add support for `\PDO::FETCH_CLASS` and `\PDO::FETCH_OBJ` fetch modes in `ibm_db2` driver
      • Optimize table indexes introspection (cleaner list SQL statement and codebase in schema manager)
      • Fix foreign key constraints introspection (also cleaned up codebase in schema manager)
      • Introduce BLOB type column support
      • Fix `TRUNCATE TABLE` statement generation
      • Fix SQL snippets for current date/time/timestamp constants
      • Add date arithmetic expressions
      • Fix bit operator expressions
      • Add support for portability connection
      • Fix default value declarations
      • Fix renaming columns
      • Fix renaming tables
      • Fix autoincrement column introspection
      • Fix required table reorganization after table alteration
      • Fix `DROP DATABASE` statement generation
      • Remove unnecessary method overrides in the platform
      • Add platform test case

      The complete test suite now runs fine on `ibm_db2` driver except for `TypeConversionTest::testIdempotentDataConversion`:

      ```bash
      There was 1 failure:

      1) Doctrine\Tests\DBAL\Functional\TypeConversionTest::testIdempotentDataConversion with data set #13 ('decimal', 1.55, 'string')
      Conversion between values should produce the same out as in value, but doesnt!
      Failed asserting that '1,55' matches expected 1.55.

      /home/deeky/dev/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php:94
      ```

      I have tried to find a solution for this issue but apparently this is a driver issue as the decimal separator seems to depend on the system's locale settings. Unfortunately there is no driver option where we could set the desired decimal separator. For now it seems we have to live with it and I guess it works on english locale systems.

      The `pdo_ibm` driver reveals more problems as it is still buggy (for years now). The driver still [segfaults on decoding CLOB/BLOB resources](http://pecl.php.net/bugs/bug.php?id=17199). So every test that uses BLOBs in any way does not run. The second issue I encountered was a test where a table is referenced quoted in a `SELECT` statement:

      ```bash
      There was 1 error:

      1) Doctrine\Tests\DBAL\Functional\DataAccessTest::testPrepareWithQuoted
      Doctrine\DBAL\DBALException: An exception occurred while executing 'SELECT test_int, test_string FROM "fetch_table" WHERE test_int = '1' AND test_string = 'foo'':

      SQLSTATE[42S02]: Base table or view not found: -204 [IBM][CLI Driver][DB2/LINUXX8664] SQL0204N "DB2INST1.fetch_table" is an undefined name. SQLSTATE=42704
      (SQLNumResultCols[-204] at /home/deeky/db2/PDO_IBM-1.3.3/ibm_driver.c:153)

      /home/deeky/dev/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:110
      /home/deeky/dev/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:50
      /home/deeky/dev/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:86
      /home/deeky/dev/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:702
      /home/deeky/dev/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php:154
      ```

      This is weird and I couldn't find out why this does not work on `pdo_ibm` but works on `ibm_db2`.
      Besides those issues `pdo_ibm` runs fine.

      This PR does not make the IBM DB2 implementation perfect yet but it is a good start which is already usable. If we decide on officially supporting this vendor, I would do further work on this.

        Activity

        Hide
        Doctrine Bot added a comment -

        A related Github Pull-Request [GH-447] was closed:
        https://github.com/doctrine/dbal/pull/447

        Show
        Doctrine Bot added a comment - A related Github Pull-Request [GH-447] was closed: https://github.com/doctrine/dbal/pull/447

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Doctrine Bot
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: