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

Illegal mix of collation with a PS parameter

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.3.12, 5.5.39, 10.0.13
    • 10.0.14
    • None
    • None

    Description

      This is similar to MDEV-6688 (Illegal mix of collation with bit string B'01100001'),
      but now for PS parameters:

      SET NAMES utf8;
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a INT, b VARCHAR(10) CHARACTER SET latin1);
      INSERT INTO t1 VALUES (1,'a');
      SELECT CONCAT(b,IF(a,'b','b')) FROM t1;
       
      PREPARE stmt FROM "SELECT CONCAT(b,IF(a,?,?)) FROM t1";
      SET @b='b'; 
      EXECUTE stmt USING @b,@b;

      correctly returns 'ab' for the first SELECT with string literals,
      but returns an error for the second SELECT with PS parameters:

      ERROR 1267 (HY000): Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat'

      It should return 'ab' for the second SELECT, because the parameter value
      is pure ASCII and therefore should be safely concatenated with a Latin1
      field.

      Attachments

        Activity

          bar Alexander Barkov created issue -
          bar Alexander Barkov made changes -
          Field Original Value New Value
          Description This is similar to MDEV-6688 (Illegal mix of collation with bit string B'01100001'),
          but now for PS parameters:

          {code:sql}
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a INT, b VARCHAR(10) CHARACTER SET latin1);
          INSERT INTO t1 VALUES (1,'a');
          SELECT CONCAT(b,IF(a,'b','b')) FROM t1;

          PREPARE stmt FROM "SELECT CONCAT(b,IF(a,?,?)) FROM t1";
          SET @b='b';
          EXECUTE stmt USING @b,@b;
          {code}

          correctly returns 'ab' for the first SELECT with string literals,
          but returns an error for the second SELECT with PS parameters:

          {noformat}
          ERROR 1267 (HY000): Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat'
          {noformat}

          It should return 'ab' for the second SELECT, because the parameter value
          is pure ASCII and therefore should be safely concatenated with a Latin1
          field.
          This is similar to MDEV-6688 (Illegal mix of collation with bit string B'01100001'),
          but now for PS parameters:

          {code:sql}
          SET NAMES utf8;
          DROP TABLE IF EXISTS t1;
          CREATE TABLE t1 (a INT, b VARCHAR(10) CHARACTER SET latin1);
          INSERT INTO t1 VALUES (1,'a');
          SELECT CONCAT(b,IF(a,'b','b')) FROM t1;

          PREPARE stmt FROM "SELECT CONCAT(b,IF(a,?,?)) FROM t1";
          SET @b='b';
          EXECUTE stmt USING @b,@b;
          {code}

          correctly returns 'ab' for the first SELECT with string literals,
          but returns an error for the second SELECT with PS parameters:

          {noformat}
          ERROR 1267 (HY000): Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat'
          {noformat}

          It should return 'ab' for the second SELECT, because the parameter value
          is pure ASCII and therefore should be safely concatenated with a Latin1
          field.
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0 [ 16000 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5 [ 15800 ]
          bar Alexander Barkov made changes -
          Fix Version/s 10.0.14 [ 17101 ]
          Fix Version/s 5.5 [ 15800 ]
          Fix Version/s 10.0 [ 16000 ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Workflow MariaDB v2 [ 53724 ] MariaDB v3 [ 64659 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 64659 ] MariaDB v4 [ 148196 ]

          People

            bar Alexander Barkov
            bar Alexander Barkov
            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.