Incorrect results for virtual column in `WHERE` or `ORDER BY`
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 873
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 108
Description
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.