Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
10.5.5
-
None
Description
Documentation for default function says:
"If the column has no default value, NULL is returned."
https://mariadb.com/kb/en/default/
A test shows that:
- [snippet 1] If the column has no default and it is NULLable and the table is empty, no row is returned, even if we are also selecting another expression.
- [snippet 2] If the column has no default value and it's not NULLable, an error is returned.
MariaDB [test]> CREATE OR REPLACE TABLE t (x INT NULL, y INT NOT NULL); |
Query OK, 0 rows affected (0.013 sec) |
|
MariaDB [test]> SELECT DEFAULT(x), 1 FROM t; |
Empty set (0.001 sec) |
This looks like a bug to me.
MariaDB [test]> SELECT @@sql_mode; |
+------------+ |
| @@sql_mode |
|
+------------+ |
| |
|
+------------+ |
1 row in set (0.000 sec) |
|
MariaDB [test]> SELECT DEFAULT(y) FROM t; |
ERROR 1364 (HY000): Field 'y' doesn't have a default value |
This makes sense to me because no default != NULL, but in that case the docs should be adjusted.