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

DEFAULT on an optional-length string column is silently truncated to the empty string

    XMLWordPrintable

Details

    • Not for Release Notes

    Description

      CREATE TABLE t1 (a VARCHAR DEFAULT 'x');
      # shows `a` text DEFAULT '' , but expected DEFAULT 'x' in CREATE TABLE statement
      SHOW CREATE TABLE t1;       
      INSERT INTO t1 () VALUES ();
      # returns '' , 0 , but expected result set is 'x' , 1
      SELECT a, LENGTH(a) FROM t1;     
      DROP TABLE t1;
      

      13.0.1-opt>CREATE TABLE t1 (a VARCHAR DEFAULT 'x');
      Query OK, 0 rows affected (0.012 sec)
       
      13.0.1-opt>SHOW CREATE TABLE t1\G
      *************************** 1. row ***************************
             Table: t1
      Create Table: CREATE TABLE `t1` (
        `a` text DEFAULT ''
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
      1 row in set (0.000 sec)
       
      13.0.1-opt>INSERT INTO t1 () VALUES ();
      Query OK, 1 row affected (0.002 sec)
       
      13.0.1-opt>SELECT a, LENGTH(a) FROM t1;
      +------+-----------+
      | a    | LENGTH(a) |
      +------+-----------+
      |      |         0 |
      +------+-----------+
      1 row in set (0.000 sec)
       
      13.0.1-opt>DROP TABLE t1;
      Query OK, 0 rows affected (0.007 sec)
       
      13.0.1-opt>
      

      Attachments

        Issue Links

          Activity

            People

              gkodinov Georgi Kodinov
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.