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

CONVERT produces a warning and result depends on strict mode

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5
    • 10.5
    • Character Sets, Data types
    • None

    Description

      MariaDB [test]> set sql_mode='';
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> select convert(_big5 0xC84041 using ucs2);
      +------------------------------------+
      | convert(_big5 0xC84041 using ucs2) |
      +------------------------------------+
      | ?A                                 |
      +------------------------------------+
      1 row in set, 1 warning (0.00 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+--------------------------------------------------+
      | Level   | Code | Message                                          |
      +---------+------+--------------------------------------------------+
      | Warning | 1977 | Cannot convert 'big5' character 0xC840 to 'ucs2' |
      +---------+------+--------------------------------------------------+
      1 row in set (0.00 sec)
      

      MariaDB [test]> set sql_mode='STRICT_ALL_TABLES';
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> select convert(_big5 0xC84041 using ucs2);
      +------------------------------------+
      | convert(_big5 0xC84041 using ucs2) |
      +------------------------------------+
      | NULL                               |
      +------------------------------------+
      1 row in set, 1 warning (0.01 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+--------------------------------------------------+
      | Level   | Code | Message                                          |
      +---------+------+--------------------------------------------------+
      | Warning | 1977 | Cannot convert 'big5' character 0xC840 to 'ucs2' |
      +---------+------+--------------------------------------------------+
      1 row in set (0.00 sec)
      

      I don't know whether it should produce the warning, but in any case I don't think it should return different results in strict/non-strict mode while producing the same warning in both.

      It started happening in 10.1.
      MariaDB 5.5, 10.0, MySQL 5.5-5.7 produce the non-null result without any warnings regardless the strict mode.

      Attachments

        Issue Links

          Activity

            Sergei told on slack:
            as we've discussed similar issues before, I don't think that STRICT_ALL_TABLES should affect anything when no tables are involved

            bar Alexander Barkov added a comment - Sergei told on slack: as we've discussed similar issues before, I don't think that STRICT_ALL_TABLES should affect anything when no tables are involved

            Similar thing with CHAR:

            MariaDB [test]> set sql_mode='';
            Query OK, 0 rows affected (0.00 sec)
             
            MariaDB [test]> select hex(char(0x01020304 using utf32));
            +-----------------------------------+
            | hex(char(0x01020304 using utf32)) |
            +-----------------------------------+
            |                                   |
            +-----------------------------------+
            1 row in set, 1 warning (0.00 sec)
             
            MariaDB [test]> show warnings;
            +---------+------+------------------------------------------+
            | Level   | Code | Message                                  |
            +---------+------+------------------------------------------+
            | Warning | 1300 | Invalid utf32 character string: '010203' |
            +---------+------+------------------------------------------+
            1 row in set (0.00 sec)
            

            MariaDB [test]> set sql_mode='STRICT_TRANS_TABLES';
            Query OK, 0 rows affected (0.00 sec)
             
            MariaDB [test]> select hex(char(0x01020304 using utf32));
            +-----------------------------------+
            | hex(char(0x01020304 using utf32)) |
            +-----------------------------------+
            | NULL                              |
            +-----------------------------------+
            1 row in set, 1 warning (0.00 sec)
             
            MariaDB [test]> show warnings;
            +---------+------+------------------------------------------+
            | Level   | Code | Message                                  |
            +---------+------+------------------------------------------+
            | Warning | 1300 | Invalid utf32 character string: '010203' |
            +---------+------+------------------------------------------+
            1 row in set (0.00 sec)
            

            elenst Elena Stepanova added a comment - Similar thing with CHAR : MariaDB [test]> set sql_mode= '' ; Query OK, 0 rows affected (0.00 sec)   MariaDB [test]> select hex( char (0x01020304 using utf32)); + -----------------------------------+ | hex( char (0x01020304 using utf32)) | + -----------------------------------+ | | + -----------------------------------+ 1 row in set , 1 warning (0.00 sec)   MariaDB [test]> show warnings; + ---------+------+------------------------------------------+ | Level | Code | Message | + ---------+------+------------------------------------------+ | Warning | 1300 | Invalid utf32 character string: '010203' | + ---------+------+------------------------------------------+ 1 row in set (0.00 sec) MariaDB [test]> set sql_mode= 'STRICT_TRANS_TABLES' ; Query OK, 0 rows affected (0.00 sec)   MariaDB [test]> select hex( char (0x01020304 using utf32)); + -----------------------------------+ | hex( char (0x01020304 using utf32)) | + -----------------------------------+ | NULL | + -----------------------------------+ 1 row in set , 1 warning (0.00 sec)   MariaDB [test]> show warnings; + ---------+------+------------------------------------------+ | Level | Code | Message | + ---------+------+------------------------------------------+ | Warning | 1300 | Invalid utf32 character string: '010203' | + ---------+------+------------------------------------------+ 1 row in set (0.00 sec)

            People

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