Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-64427

Primary Index can not be retrieved by OCI driver if index name does not match constraint name

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.9.4
    • 5.5.0, 5.8.0, 5.10.0 Beta 4
    • SQL Support
    • Qt 5.5 (also checked driver implementation of Qt 5.8 and Qt 5.10 beta 4, but did not test)

      should behave like this on any OS and compiler
    • 3dab19ffed61a69166045d6e90e1e114d81f85a8

    Description

      I am using a database modelling tool which generates a primary key constraint and a unique index with differing names, which is allowed by Oracle 10g and 11g at least.

      In this situation, the QOCIDriver::primaryIndex method in qsql_oci.cpp fails to determine the primary key since the line "and b.index_name = a.constraint_name" obviously fails (see attached statements for further details).

      I believe this join should be done on a.index_name (which is also available in the all_constraints) table. I have attached an example script which can be executed in e.g. Oracle SQL Developer on any Oracle 10g/11g database. It will show that the currently implemented query delivers no rows on a perfectly valid database, while the statement with our adaptation is able to retrieve the primary key.

       

      Further Note: The fallback solution, where a combination of all fields is used as a primary key replacement does not work if e.g. CLOB fields are part of the table (as they would appear in the WHERE part of the query, which is not allowed).

      Attachments

        For Gerrit Dashboard: QTBUG-64427
        # Subject Branch Project Status CR V

        Activity

          People

            andysh Andy Shaw
            hummel Stefan Hummel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes