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

Wrong results with combination of CONCAT, SUBSTR and CONVERT in subquery

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 5.3.12, 5.5.48, 10.0.24, 10.1.11
    • 10.0.32
    • Optimizer
    • None
    • Linux
    • 10.0.30

    Description

      There seems to be a problem with the combination of CONCAT, SUBSTR and CONVERT in subquery. Simplest test case so far that reproduces this is:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (t VARCHAR(10) CHARSET latin1);
       
      INSERT INTO t1 VALUES('1234567');
       
      SELECT CONCAT(SUBSTR(t2, 1, 3), SUBSTR(t2, 5)) c1
                  , CONCAT(SUBSTR(t2,1,3),'---',SUBSTR(t2,5)) c2
         FROM (SELECT CONVERT(t USING latin1) t2 FROM t1) sub;
      

      Expected result, produced by MariaDB 5.1.x and 5.2.x, and all tested versions of MySQL:

      +--------+-----------+
      | c1     | c2        |
      +--------+-----------+
      | 123567 | 123---567 |
      +--------+-----------+
      

      MariaDB 5.3.x result:

      +--------+-----------+
      | c1     | c2        |
      +--------+-----------+
      | 123567 | 123456567 |
      +--------+-----------+
      

      MariaDB 5.5.x - 10.1.x:

      +--------+-----------+
      | c1     | c2        |
      +--------+-----------+
      | 12356  | 123456567 |
      +--------+-----------+
      

      Attachments

        Issue Links

          Activity

            People

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