Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.4.14, 10.5.9, 10.6.1, 10.3(EOL), 10.4(EOL), 10.5
-
None
-
Linux CentOS 7.9
Description
When a table has an INVISIBLE column with a computed default, said default is only used in an INSERT if said column is not specified, but other columns are. Best illustrated with an example:
MariaDB> CREATE TABLE t1(c1 INT NOT NULL PRIMARY KEY, c2 INTEGER NOT NULL DEFAULT (c1 + 1) INVISIBLE); |
MariaDB> INSERT INTO t1 VALUES(1),(2); |
MariaDB> INSERT INTO t1(c1) VALUES(3),(4); |
MariaDB> INSERT INTO t1 VALUES(5),(6); |
MariaDB [test]> SELECT c1, c2 FROM t1; |
+----+----+ |
| c1 | c2 |
|
+----+----+ |
| 1 | 0 |
|
| 2 | 0 |
|
| 3 | 4 |
|
| 4 | 5 |
|
| 5 | 0 |
|
| 6 | 0 |
|
+----+----+ |
As can be seen, when doing an INSERT without specifying the columns, 0 is inserted and the defined DEFAULT is ignored. If an INSERT specifying which columns to insert though, the DEFAULT is computed appropriately.
Attachments
Issue Links
- relates to
-
MDEV-15085 Invisible Column Non-constant Default value results wrong values
- Closed