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

INSERT silently truncates too long value for a virtual column without warnings or errors

    XMLWordPrintable

Details

    Description

      CREATE TABLE t1 (a VARCHAR(3), v VARCHAR(3) AS (CONCAT('x-',a)) VIRTUAL);
      INSERT INTO t1 (a) VALUES ('foo');
      SELECT * FROM t1;
      

      10.2 ab271ee7

      INSERT INTO t1 (a) VALUES ('foo');
      SELECT * FROM t1;
      a	v
      foo	x-f
      

      Reproducible on all of 5.5-10.6.

      The expected result would be a warning with non-strict SQL mode and an error with the strict mode. MySQL does exactly that:

      MySQL 5.7 3701bd36be with sql-mode=''

      INSERT INTO t1 (a) VALUES ('foo');
      Warnings:
      Warning	1265	Data truncated for column 'v' at row 1
      SELECT * FROM t1;
      a	v
      foo	x-f
      

      MySQL 5.7 3701bd36be with sql-mode='STRICT_ALL_TABLES'

      mysqltest: At line 2: query 'INSERT INTO t1 (a) VALUES ('foo')' failed: 1406: Data too long for column 'v' at row 1
      

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              elenst Elena Stepanova
              Votes:
              1 Vote for this issue
              Watchers:
              5 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.