Bug reference: 15826 Logged by: Thomas Hantel Email address: tom.hantel@googlemail.com PostgreSQL version: 11.3 Operating system: Fedora Linux Description:
We are currently seeing the following unexpected effect:
In one of our services there is a statement that first sets up a CTE to filter the data and then an UPDATE-statement that refers to that data. If the WHERE-clause in the update refers to a column that is not selected in the CTE, the whole clause is ignored so that all of the rows in the table get updated. [..] We would expect an error to be thrown in all cases where undefined columns are referenced.
This is not a bug. It may seem weird but it is expected behaviour under scope resolution.
The cte does not have an id column but dummy has, so it is used.