cockroachdb / cockroachdb/cockroach
postgresql 18 compatibility: support `OLD`/`NEW` syntax in `RETURNING` clause for modified rows
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
This is a feature [recently added in PostgreSQL 18](https://www.postgresql.org/docs/18/dml-returning.html
).
Simple example:
```sql
UPDATE products SET price = price * 1.10
WHERE price <= 99.99
RETURNING name, old.price AS old_price, new.price AS new_price,
new.price - old.price AS price_change;
```
**Is your feature request related to a problem? Please describe.**
My usecase makes heavy use of computed expressions in returning clauses with a large number of nodes, and I've run into the case where I need to compare with older data (especially when updating rows).
**Describe alternatives you've considered**
Subqueries, fetching the data beforehand in a serializable transaction. These both come with downsides, seems pretty clear.
Jira issue: CRDB-58213
Contributor guide
Assessment
This issue has not been assessed yet.