dolt
dolt copied to clipboard
Incorrect results for virtual column in `WHERE` or `ORDER BY`
Example 1:
create table test(pk int primary key, j int, value int as (pk*pk));
insert into test(pk, j) values (-1, 1), (2, 1), (-3, 1);
select value from test order by value;
Expected output:
+-------+
| value |
+-------+
| 1 |
| 4 |
| 9 |
+-------+
Actual output:
+-------+
| value |
+-------+
| NULL |
| NULL |
| NULL |
+-------+
Example 2:
create table test(pk int primary key, j int, k int, value int as (pk*pk));
insert into test(pk, j) values (-1, 1, 2), (2, 1, 2), (-3, 1, 2);
select value from test order by value;
Expected output:
+-------+
| value |
+-------+
| 1 |
| 4 |
| 9 |
+-------+
Actual output:
unable to find field with index 2 in row of 2 columns
In both cases, columns j and k are unused, but affect the outcome. If there are no non-virtual value columns, the query behaves correctly. Adding a second virtual column causes queries on both virtual columns to behave correctly.