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

Virtual columns: No warning on data truncation

    XMLWordPrintable

    Details

      Description

      MariaDB [test]> SET sql_mode = '';
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> CREATE TABLE t1(a INT);
      Query OK, 0 rows affected (0.05 sec)
       
      MariaDB [test]> INSERT INTO t1 VALUES(2147483647);
      Query OK, 1 row affected (0.00 sec)
       
      MariaDB [test]> ALTER TABLE t1 ADD COLUMN b SMALLINT AS (a) VIRTUAL, ALGORITHM=COPY, LOCK=SHARED;
      Query OK, 1 row affected, 1 warning (0.16 sec)     
      Records: 1  Duplicates: 0  Warnings: 1
       
      MariaDB [test]> SHOW WARNINGS;
      +---------+------+--------------------------------------------+
      | Level   | Code | Message                                    |
      +---------+------+--------------------------------------------+
      | Warning | 1264 | Out of range value for column 'b' at row 1 |
      +---------+------+--------------------------------------------+
      1 row in set (0.00 sec)
       
      MariaDB [test]> ALTER TABLE t1 ADD COLUMN c SMALLINT AS (a) VIRTUAL;
      Query OK, 0 rows affected (0.10 sec)
      Records: 0  Duplicates: 0  Warnings: 0  <-- No warning
       
      MariaDB [test]> SELECT * FROM t1;
      +------------+-------+-------+
      | a          | b     | c     |
      +------------+-------+-------+
      | 2147483647 | 32767 | 32767 |
      +------------+-------+-------+
      1 row in set (0.00 sec)
      

      Note: This only happens with InnoDB.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              serg Sergei Golubchik
              Reporter:
              nirbhay_c Nirbhay Choubey (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: