SQLite Forum

Crash when a RETURNING clause refers to a table in UPDATE FROM
Login
Looks good, but for one more minor item:

UPDATE target aliases are recognized in the statement itself, but not in the RETURNING clause (or subqueries):

```
sqlite> update x as t set x = 1 where x = 1 returning *, (select y from y where x == x.x);
QUERY PLAN
|--SCAN t (~524288 rows)
`--CORRELATED SCALAR SUBQUERY 1
   `--SCAN y (~262144 rows)
┌───┬──────────────────────────────────┐
│ x │ (select y from y where x == x.x) │
├───┼──────────────────────────────────┤
│ 1 │ 10                               │
└───┴──────────────────────────────────┘
sqlite> update x as t set x = 1 where t.x = 1 returning *, (select y from y where x == x.x);
QUERY PLAN
|--SCAN t (~524288 rows)
`--CORRELATED SCALAR SUBQUERY 1
   `--SCAN y (~262144 rows)
┌───┬──────────────────────────────────┐
│ x │ (select y from y where x == x.x) │
├───┼──────────────────────────────────┤
│ 1 │ 10                               │
└───┴──────────────────────────────────┘
sqlite> update x as t set x = 1 where t.x = 1 returning *, t.x, (select y from y where x == x.x);
Error: no such column: t.x
sqlite> update x as t set x = 1 where t.x = 1 returning *, sin(radians(t.x)), (select y from y where x == x.x);
Error: no such column: t.x
sqlite> update x as t set x = 1 where t.x = 1 returning *, (select y from y where x == t.x);
Error: no such column: t.x
sqlite>
```