PG and Citus behave differently on CTE insert/delete
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
- create two tables with the same schema, and distributed one of them
```sql
create table l1(a int, b int);
create table t1(a int, b int);
select create_distributed_table('t1', 'a');
```
- run the following query on both tables
```sql
with new_rows as (insert into l1 values (-2, -1) returning *) delete from l1 where a < 0;
DELETE 0
with new_rows as (insert into t1 values (-2, -1) returning *) delete from t1 where a < 0;
DELETE 1
```
- the newly inserted rows are not deleted from regular table, but deleted from distributed table.
```sql
select * from l1;
a | b
----+----
-2 | -1
(1 row)
select * from t1;
a | b
---+---
(0 rows)
```
PG documentation says that this behavior is [unpredictable](https://www.postgresql.org/docs/10/static/queries-with.html). Nevertheless we behave differently from PG here.
Contributor guide
Assessment
This issue has not been assessed yet.