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

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Alex Bolenok <quassnoi(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Joins of data-modifying CTE with the target table
Date: 2023-04-19 16:42:45
Message-ID: e8ad8aca-c0e4-65f8-e51c-fde543db62fa@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 as terse
> as possible?

Not so much terse as possible as not as verbose as possible. The
difference being that documenting every possible usage would turn the
page into an eye glazing experience. At that point folks would really
just move on. The documentation expectations(as I see it) are that: 1)
People can work from basic principles to specific usage. 2) They also
actually test/verify what they run.

What you are after is more on the lines of a separate enhanced tutorial.
That has been discussed on this list and elsewhere. So far it has not
progressed beyond discussion.

>
> To answer your question, by "explicitly" I mean mentioning this very
> pattern, where you join the returned id with the target table. People
> often try to use this pattern for queries like "add an item to the order
> in a CTE, select the order total in the main query", and often don't
> notice that the order total doesn't include the new item until it hits
> production.
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2023-04-19 16:53:14 Re: Joins of data-modifying CTE with the target table
Previous Message Alex Bolenok 2023-04-19 16:09:12 Re: Joins of data-modifying CTE with the target table