Re: Joins of data-modifying CTE with the target table

2023-04-19 Thread Tom Lane
Alex Bolenok writes: > To answer your question, by "explicitly" I mean mentioning this very > pattern, where you join the returned id with the target table. I do not see why this existing example isn't sufficient: ... An example of this is that in WITH t AS ( UPDATE products

Re: Joins of data-modifying CTE with the target table

2023-04-19 Thread Adrian Klaver
On 4/19/23 09:09, Alex Bolenok wrote: To reiterate, I (I personally) get why it's not working, but the documentation is something that is intended for people who don't. Technically, anyone can deduce it from reading the documentation thoroughly enough, but do we need the documentation to be

Re: Joins of data-modifying CTE with the target table

2023-04-19 Thread Alex Bolenok
To reiterate, I (I personally) get why it's not working, but the documentation is something that is intended for people who don't. Technically, anyone can deduce it from reading the documentation thoroughly enough, but do we need the documentation to be as terse as possible? To answer your

Re: Joins of data-modifying CTE with the target table

2023-04-19 Thread Adrian Klaver
On 4/19/23 08:37, Alex Bolenok wrote: Hi list, This popped up yesterday during a discussion at the Boston PostgreSQL group meetup, and Jesper Pedersen had advised that I post it here. Imagine this setup: CREATE TABLE IF NOT EXISTS mytable (id BIGSERIAL PRIMARY KEY, value TEXT NOT NULL);

Re: Joins of data-modifying CTE with the target table

2023-04-19 Thread Tom Lane
Alex Bolenok writes: > I get why it's not working (because the statement is not allowed to see the > tuples with its own cmin), but I was wondering if it was worth it at least > to spell it out explicitly in the documentation. What's not explicit about this? The sub-statements in WITH are

Joins of data-modifying CTE with the target table

2023-04-19 Thread Alex Bolenok
Hi list, This popped up yesterday during a discussion at the Boston PostgreSQL group meetup, and Jesper Pedersen had advised that I post it here. Imagine this setup: CREATE TABLE IF NOT EXISTS mytable (id BIGSERIAL PRIMARY KEY, value TEXT NOT NULL); WITHinsert_cte AS (