Uploaded image for project: 'MariaDB Connector/ODBC'
  1. MariaDB Connector/ODBC
  2. ODBC-435

SQLPrimaryKeys call returns incorrect KEY_SEQ field

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.2.2
    • 3.1.21, 3.2.3
    • General
    • None
    • Windows 32 bit

    Description

      I have defined PRIMARY KEY on table, which consists of 4 columns.
      When I call ODBC API SQLPrimaryKeys these 4 columns are returned in order how they appear in table definition, not in primary key definition.
      SQLPrimaryKeys returns 4 rows, where 5th column - KEY_SEQ - return:
      2,
      5,
      6,
      9

      But https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlprimarykeys-function states, that:
      KEY_SEQ: "Column sequence number in key (starting with 1)"

      So KEY_SEQ should be sequence in key not in table ...

      Attachments

        Activity

          LacaK Ladislav added a comment -

          Simplified example:

          create table test (
          c1 int not null,
          c2 int not null,
          c3 int not null,
          c4 int not null,
          CONSTRAINT PK_test PRIMARY KEY (c3,c2)
          );

          Call to SQLPrimaryKeys returns these two rows:
          #1: COLUMN_NAME=c2, KEY_SEQ=2, PK_NAME=PRIMARY
          #2: COLUMN_NAME=c3, KEY_SEQ=3, PK_NAME=PRIMARY

          But should return:
          #1: COLUMN_NAME=c3, KEY_SEQ=1, PK_NAME=PRIMARY
          #2: COLUMN_NAME=c2, KEY_SEQ=2, PK_NAME=PRIMARY

          LacaK Ladislav added a comment - Simplified example: create table test ( c1 int not null, c2 int not null, c3 int not null, c4 int not null, CONSTRAINT PK_test PRIMARY KEY (c3,c2) ); Call to SQLPrimaryKeys returns these two rows: #1: COLUMN_NAME=c2, KEY_SEQ=2, PK_NAME=PRIMARY #2: COLUMN_NAME=c3, KEY_SEQ=3, PK_NAME=PRIMARY But should return: #1: COLUMN_NAME=c3, KEY_SEQ=1, PK_NAME=PRIMARY #2: COLUMN_NAME=c2, KEY_SEQ=2, PK_NAME=PRIMARY

          Thank you for your report - the fix and the testcase have been pushed

          Lawrin Lawrin Novitsky added a comment - Thank you for your report - the fix and the testcase have been pushed

          Just noticed that the commit erroneously marked as ODBC-436(1a3157b5e80af63847e083a2a43719fbe8b005da) That's why it's not linked to the ticket

          Lawrin Lawrin Novitsky added a comment - Just noticed that the commit erroneously marked as ODBC-436 (1a3157b5e80af63847e083a2a43719fbe8b005da) That's why it's not linked to the ticket

          People

            Lawrin Lawrin Novitsky
            LacaK Ladislav
            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.