Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
10.5
-
None
Description
This was observed after fixing MDEV-32411.
CREATE TABLE t1 ( a int not null ) ; |
INSERT INTO t1 VALUES (EXISTS(SELECT avg(a) OVER (ORDER BY COUNT(DISTINCT a)))); |
There is a reference to column `a` in the ORDER BY COUNT(DISTINCT a) which cannot be resolved, however the query executes successfully.
Attachments
Issue Links
- relates to
-
MDEV-32411 Item_sum arguments incorrectly reset to temp table fields which causes crash
-
- Closed
-
Take-aways from yesterday call: It seems the above behavior was added intentionally, see:
commit c7320830a62b0ed3245c476f074c534d3cd20027
Author: Sergei Golubchik <serg@mariadb.org>
Date: Tue Sep 24 19:47:45 2019 +0200
outer references in subqueries in INSERT
remove inconsistent limitation
the meaning of
INSERT INTO t1 VALUES (t1_col);
is "insert a row with default value of t1_col1".
https://mariadb.com/kb/en/insert/ has this:
Does the last paragraph refer to INSERT ... SET syntax or INSERT ... VALUES syntax?
According to Igor, one cannot refer to inserted-into table from subquery.
However here 's a counter example from Rex:
MariaDB [test]> INSERT INTO t1 (t1a) values ( 1 + (select t1a from t2 where (select t3a from t3 where t3.t3a > t1.t1a) ) );
Query OK, 1 row affected (0.007 sec)