Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
5.5, 10.1, 10.2, 10.3, 10.4, 10.5
Description
Note: It may well be expected behavior. However, as recent experience has shown, it is counter-intuitive, so if it works so by design, it should be explicitly documented, probably here.
create table t1 (a int); |
create table if not exists t1 (b int); |
select @@warning_count or (select count(*) from t1); |
f56ff9a644 |
MariaDB [test]> create table t1 (a int); |
Query OK, 0 rows affected (0.234 sec) |
|
MariaDB [test]> create table if not exists t1 (b int); |
Query OK, 0 rows affected, 1 warning (0.001 sec) |
|
MariaDB [test]> select @@warning_count or (select count(*) from t1); |
+----------------------------------------------+ |
| @@warning_count or (select count(*) from t1) | |
+----------------------------------------------+ |
| 0 |
|
+----------------------------------------------+ |
1 row in set (0.003 sec) |
The intuitive expectation here is that when the SELECT is executed, the value of @warning_count is still 1, and SELECT will return true without even executing the right part of OR. However, it doesn't happen, at the moment of execution the value of @@warning_count is already 0. Apparently, it gets reset before SELECT starts.
Also reproducible on active versions of MySQL, but equally unclear from MySQL documentation whether it's expected behavior.