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

Unsused variable leads to unnecessary if condition in ma_string.c (and possibly bugs)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.15
    • Fix Version/s: 3.1.16
    • Component/s: General
    • Labels:
      None

      Description

      In the file https://github.com/mariadb-corporation/mariadb-connector-odbc/blob/master/ma_string.c there a two lines who contradict each other:
      On https://github.com/mariadb-corporation/mariadb-connector-odbc/blob/852f63465b03045dba73cc36fc5710aea0f55b5c/ma_string.c#L213 the int variable Flag is created with an initial value of 0 and in https://github.com/mariadb-corporation/mariadb-connector-odbc/blob/852f63465b03045dba73cc36fc5710aea0f55b5c/ma_string.c#L257 the condition is true if the Flag value is 0, which is always the case, since the Flag value never changes after initialization.

      As far as i can tell the value of flag should depend on the values of PrimaryCount and/or UniqueCount, to avoid to compare all columns and not just the primary key/unique columns.

      A quick fix is to set the value of Flag prior to the for loop (line 262):

      ...
      if(PrimaryCount)
      {
          Flag = PRI_KEY_FLAG;
      }
      else if(UniqueCount) 
      {
          Flag = UNIQUE_KEY_FLAG;
      }
      for (i= 0; i < MADB_STMT_COLUMN_COUNT(Stmt); i++)
      {
      ...
      

      I have attached a "corrected" version of ma_string.c for comparison.

        Attachments

          Activity

            People

            Assignee:
            Lawrin Lawrin Novitsky
            Reporter:
            Softwert Robert Pellmann
            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.