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

Converting INET6 to CHAR(39) produces garbage without a warning

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.5
    • 10.5.0
    • Data types
    • None

    Description

      CAST from INET6 to CHAR(39) works fine, so one could expect that ALTER TABLE works too. It does, without a warning, but resulting contents looks like garbage:

      CREATE OR REPLACE TABLE t1 (a INET6);
      INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
      SELECT CAST(a AS CHAR(39)) FROM t1;
      ALTER TABLE t1 MODIFY a CHAR(39);
      SELECT * FROM t1;
      

      MariaDB [test]> SELECT CAST(a AS CHAR(39)) FROM t1;
      +------------------------+
      | CAST(a AS CHAR(39))    |
      +------------------------+
      | 2001:db8::ff00:42:8329 |
      +------------------------+
      1 row in set (0.000 sec)
       
      MariaDB [test]> ALTER TABLE t1 MODIFY a CHAR(39);
      Query OK, 1 row affected (0.843 sec)               
      Records: 1  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> SELECT * FROM t1;
      +---------------------+
      | a                   |
      +---------------------+
      ¸      ÿ  Bƒ)    |
      +---------------------+
      1 row in set (0.001 sec)
      

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov added a comment - - edited

            It erroneously writes binary representation to the CHAR column:

            CREATE OR REPLACE TABLE t1 (a INET6);
            INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
            ALTER TABLE t1 MODIFY a CHAR(39);
            SELECT HEX(a) FROM t1; -- Notice HEX()
            

            +----------------------------------+
            | HEX(a)                           |
            +----------------------------------+
            | 20010DB8000000000000FF0000428329 |
            +----------------------------------+
            

            Should be changed to write text representation when altering to CHAR/TEXT.

            bar Alexander Barkov added a comment - - edited It erroneously writes binary representation to the CHAR column: CREATE OR REPLACE TABLE t1 (a INET6); INSERT INTO t1 VALUES ( '2001:db8::ff00:42:8329' ); ALTER TABLE t1 MODIFY a CHAR (39); SELECT HEX(a) FROM t1; -- Notice HEX() +----------------------------------+ | HEX(a) | +----------------------------------+ | 20010DB8000000000000FF0000428329 | +----------------------------------+ Should be changed to write text representation when altering to CHAR/TEXT.

            People

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