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

User variable loses its character set

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.5, 10.1, 10.2, 10.3, 10.4, 10.5
    • Fix Version/s: 10.5
    • Component/s: Data types, Variables
    • Labels:
      None

      Description

      SET @x=_utf8'ß';
      SELECT IF (0,@x:=10,@x), CHARSET(@x), @x;
      

      +------------------+-------------+------+
      | IF (0,@x:=10,@x) | CHARSET(@x) | @x   |
      +------------------+-------------+------+
      | ß               | latin1      | ß   |
      +------------------+-------------+------+
      

      Notice, the variable @x changed its character set from utf8 to latin1 and therefore returns a wrong value.

      The problem happens because Item_func_set_user_val::fix_length_and_dec(), performed for @x:=10, changes the character set of @x from utf8 to latin1.
      But the assignment of @x to 10 does not actually happen, because of the 0 in the first argument of IF.

      So the underlying code erroneously changes the variable character set separately from the value, which looks wrong.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bar Alexander Barkov
              Reporter:
              bar Alexander Barkov
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:

                  Git Integration

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