Re: Document behaviour of failed sub queries - Mailing list pgsql-docs

From David G. Johnston
Subject Re: Document behaviour of failed sub queries
Date
Msg-id CAKFQuwbiDS7M8qNDwQeUm401ZU4aUUAwXoEC=E8xVjmO1pj0QA@mail.gmail.com
Whole thread Raw
In response to Document behaviour of failed sub queries  (PG Doc comments form <noreply@postgresql.org>)
Responses Re: Document behaviour of failed sub queries  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-docs
On Mon, Jun 28, 2021 at 8:34 AM PG Doc comments form <noreply@postgresql.org> wrote:
For example:
UPDATE table1 SET status='expired' WHERE id in (SELECT wrong_id IN table2)

This will update every row in table1if wrong_id doesn't exist, ignoring the
ERROR:  column "wrong_id" does not exist from the subquery.

The subquery never provokes that error by virtue of the fact it is a subquery.  It's only if you run that as a standalone query do you see the error.  This is because correlated subqueries are a thing (and, yes, they are documented).


David J.

pgsql-docs by date:

Previous
From: PG Doc comments form
Date:
Subject: SETOF specification and default behavior (CREATE FUNCTION)
Next
From: "David G. Johnston"
Date:
Subject: Re: Document behaviour of failed sub queries