Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-15702

Remove the use of STRING_ITEM from Item_func_date_format::fix_length_and_dec()

Details

    Description

      We'll be replacing data type specific constants STRING_ITEM, INT_ITEM, REAL_ITEM, DECIMAL_ITEM, DATE_ITEM to LITERAL_ITEM soon (see MDEV-14630).

      Under terms of this task we'll remove usage of STRING_ITEM in Item_func_date_format::fix_length_and_dec() by replacing this condition:

        if (arg1->type() == STRING_ITEM)
      

      to

        StringBuffer<STRING_BUFFER_USUAL_SIZE> buffer;
        String *str;
        if (args[1]->basic_const_item() &&
            (str= args[1]->val_str(&buffer)))
      

      The main point in this condition is to catch constants (literals and bound Item_param instances), so calling val_str() can be done directly in fix_length_and_dec() to calculate the result max_length more precisely.

      As a good side effect, this change will allow constants of non-string types, to calculate max_length more precisely.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Description We'll be replacing data type specific constants STRING_ITEM, INT_ITEM, REAL_ITEM, DECIMAL_ITEM, DATE_ITEM to LITERAL_ITEM soon (see MDEV-14630).

            Under terms of this task we'll remove usage of {{STRING_ITEM}} in Item_func_date_format::fix_length_and_dec() by replacing this condition:

            {code:cpp}
              if (arg1->type() == STRING_ITEM)
            {code}
            to
            {code:cpp}
              StringBuffer<STRING_BUFFER_USUAL_SIZE> buffer;
              String *str;
              if (args[1]->basic_const_item() &&
                  (str= args[1]->val_str(&buffer)))
            {code}

            The main point in this condition is to catch constants (literals and bound Item_param), so calling {{val_str()}} can be done directly in {{fix_length_and_dec()}} to calculate the result {{max_length}} more precisely.

            As a good side effect, this change will allow constants of non-string types, to calculate {{max_length}} more precisely.
            We'll be replacing data type specific constants STRING_ITEM, INT_ITEM, REAL_ITEM, DECIMAL_ITEM, DATE_ITEM to LITERAL_ITEM soon (see MDEV-14630).

            Under terms of this task we'll remove usage of {{STRING_ITEM}} in Item_func_date_format::fix_length_and_dec() by replacing this condition:

            {code:cpp}
              if (arg1->type() == STRING_ITEM)
            {code}
            to
            {code:cpp}
              StringBuffer<STRING_BUFFER_USUAL_SIZE> buffer;
              String *str;
              if (args[1]->basic_const_item() &&
                  (str= args[1]->val_str(&buffer)))
            {code}

            The main point in this condition is to catch constants (literals and bound Item_param instances), so calling {{val_str()}} can be done directly in {{fix_length_and_dec()}} to calculate the result {{max_length}} more precisely.

            As a good side effect, this change will allow constants of non-string types, to calculate {{max_length}} more precisely.
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2018-03-28 07:27:40.0 2018-03-28 07:27:40.345
            bar Alexander Barkov made changes -
            Fix Version/s 10.3.6 [ 23003 ]
            Fix Version/s 10.3 [ 22126 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 86262 ] MariaDB v4 [ 133510 ]

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.