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

Incorrect character set / collation for user variables

    XMLWordPrintable

Details

    Description

      The values of this query differs from MariaDB 10.3 and MariaDB 10.4.

      MariaDB 10.5 initially casts these user variables as latin1 instead of the server character set or collation. This leads to errors like "Error Code: 1267. Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'if'" when attempting to use such user variables in subsequent comparisons and calculations, which otherwise work perfectly on MariaDB 10.3 and MariaDB 10.4.

      SET character_set_server = 'utf8mb4';
      SET collation_server = 'utf8mb4_general_ci';
      SELECT 
         @literalNULL:=NULL, CHARSET(@literalNULL), /* Correct as binary. */
         @literalINTEGER:=123, CHARSET(@literalINTEGER), /* latin1 then binary: Should be utf8 then binary on subsequent query. */
         @literalFLOAT:=1.23e40, CHARSET(@literalFLOAT), /* latin1 then binary: Should be utf8 then binary on subsequent query. */
         @literalTRUE:=TRUE, CHARSET(@literalTRUE), /* latin1 then binary: Should be utf8 then binary on subsequent query. */
         @literalFALSE:=FALSE, CHARSET(@literalFALSE), /* latin1 then binary: Should be utf8 then binary on subsequent query. */
         @literalDATE:= DATE '2001-01-01', CHARSET(@literalDATE), /* latin1 then latin1: Should be utf8 then utf8 on subsequent query. */
         @literalTIME:= TIME '13:01:02', CHARSET(@literalTIME), /* latin1 then latin1: Should be utf8 then utf8 on subsequent query. */
         @literalDATETIME:= TIMESTAMP '2001-01-01 13:01:02', CHARSET(@literalDATETIME), /* latin1 then latin1: Should be utf8 then utf8 on subsequent query. */
         @literalCHAR:='abc', CHARSET(@literalCHAR), /* Correct as utf8. */
         
         @calcCHAR:=CONCAT(NOW(), ' and then'), CHARSET(@calcCHAR), /* Correct as utf8. */
         
         @castCHAR:=CAST(NOW() AS CHAR), CHARSET(@castCHAR), /* Correct as utf8. */
         @castINT:=CAST(123 AS INTEGER), CHARSET(@castINT), /* latin1 then binary: Should be utf8 then binary on subsequent query. */
         @castDOUBLE:=CAST(1.23e40 AS DOUBLE), CHARSET(@castDOUBLE), /* latin1 then binary: Should be utf8 then binary on subsequent query. */
         @castDECIMAL:=CAST(1.23e4 AS DECIMAL), CHARSET(@castDECIMAL), /* latin1 then binary: Should be utf8 then binary on subsequent query. */
         @castDATE:=CAST(NOW() AS DATE), CHARSET(@castDATE), /* latin1 then latin1: Should be utf8 then utf8 on subsequent query. */
         @castTIME:=CAST(NOW() AS TIME), CHARSET(@castTIME), /* latin1 then latin1: Should be utf8 then utf8 on subsequent query. */
         @castDATETIME:=CAST(NOW() AS DATETIME), CHARSET(@castDATETIME) /* latin1 then latin1: Should be utf8 then utf8 on subsequent query. */
      

      Attachments

        Issue Links

          Activity

            People

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