Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-1178

DatabaseMetaData.getImportedKeys returns different results based on useCatalogTerm

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.3.3
    • 3.4.1
    • metadata
    • None
    • Tested with
      database in docker (mariadb:latest and mariadb:10.6.5)
      database drivers: 3.3.3
      java: OpenJDK Runtime Environment (build 17.0.10+7-Ubuntu-123.10.1)

    Description

      I started an empty docker image.
      I created a database and added the two tables in the attached script.
      I then compiled and ran the attached java program.
      The goal of the java program is to use the getExportedKeys and getImportedKeys to find the foreign key reference between the two tables.

      Looking at the result we see that depending on how we connect to the database and what properties we set we get different results for the PK_NAME field: sometimes we get null, sometimes we get the index name that the foreign key uses.

      IF we look at the javadoc for DatabaseMetaData we see that the field PK_NAME is supposed to return "PK_NAME String => primary key name (may be null)" so returning an index name is a bit odd, but more useful than returning null.

      Wanted/Expected:
      That getExportedKeys and getImportedKeys return matching results.

      Other:
      Looking in the driver we see that it looks at a flag and decides to either use show-tables or a query on the key_column_usage to find the results.

      Attachments

        1. App.java
          2 kB
        2. output.txt
          2 kB
        3. pom.xml
          3 kB
        4. setup_tables.sql
          0.7 kB

        Issue Links

          Activity

            People

              diego dupin Diego Dupin
              robert-dbvis Robert Olofsson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.