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

INET6 cannot be converted to BINARY(16) (requires clarification in documentation)

    XMLWordPrintable

Details

    Description

      The description of MDEV-274 says

      Values are stored as a 16-byte fixed length binary string <...>
      Storage engines see INET6 as BINARY(16)

      One could derive from that that INET6 can be converted into BINARY(16), but it's not the case:

      CREATE OR REPLACE TABLE t1 (a INET6);
      INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
      ALTER TABLE t1 MODIFY a BINARY(16);
      select cast(a as binary(16)) from t1;
      show warnings;
      

      MariaDB [test]> ALTER TABLE t1 MODIFY a BINARY(16);
      ERROR 1406 (22001): Data too long for column 'a' at row 1
      MariaDB [test]> select cast(a as binary(16)) from t1;
      +-----------------------+
      | cast(a as binary(16)) |
      +-----------------------+
      | 2001:db8::ff00:4      |
      +-----------------------+
      1 row in set, 1 warning (0.000 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+----------------------------------------------------------------+
      | Level   | Code | Message                                                        |
      +---------+------+----------------------------------------------------------------+
      | Warning | 1292 | Truncated incorrect BINARY(16) value: '2001:db8::ff00:42:8329' |
      +---------+------+----------------------------------------------------------------+
      1 row in set (0.000 sec)
      

      I assume it's expected, but it should probably be clarified in documentation.

      Attachments

        Issue Links

          Activity

            People

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