Re: BUG #15826: BUG: Where-Clause referring to unknown column in CTE is ignored in Update-statement

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Pantelis Theodosiou <ypercube(at)gmail(dot)com>
Cc: tom(dot)hantel(at)googlemail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15826: BUG: Where-Clause referring to unknown column in CTE is ignored in Update-statement
Date: 2019-05-31 13:45:22
Message-ID: CAKFQuwZoWShttJ-zz357Kn+cdtkVBDhj+Ta+gqnR7gvvbnqavA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, May 31, 2019 at 4:06 AM Pantelis Theodosiou <ypercube(at)gmail(dot)com>
wrote:

> On Fri, May 31, 2019 at 11:55 AM PG Bug reporting form <
> noreply(at)postgresql(dot)org> wrote:
>
>> The following bug has been logged on the website:
>>
>> Bug reference: 15826
>> Logged by: Thomas Hantel
>> Email address: tom(dot)hantel(at)googlemail(dot)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.
>

See also the FAQ entry for this question:

https://wiki.postgresql.org/wiki/FAQ#Why_doesn.27t_PostgreSQL_report_a_column_not_found_error_when_using_the_wrong_name_in_a_subquery.3F

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Juan José Santamaría Flecha 2019-05-31 14:11:37 Re: BUG #15789: libpq compilation with OpenSSL 1.1.1b fails on Windows with Visual Studio 2017
Previous Message Pantelis Theodosiou 2019-05-31 11:06:09 Re: BUG #15826: BUG: Where-Clause referring to unknown column in CTE is ignored in Update-statement