Re: BUG #17754: Subquery IN clause returns row matches where subquery is invalid - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17754: Subquery IN clause returns row matches where subquery is invalid
Date
Msg-id 4191911.1674157368@sss.pgh.pa.us
Whole thread Raw
In response to BUG #17754: Subquery IN clause returns row matches where subquery is invalid  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> A subquery that has an incorrect column name, that happens to match a column
> name in the outer query evaluates as true for all rows in the outer query.

Such a reference is called an "outer reference", and it's a required
feature in the SQL standard.  The reason you get "true" is that the
expression

> where a in ( select a from btable where c = 10) ;

is basically reducing to "a = a".


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

            regards, tom lane



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #17754: Subquery IN clause returns row matches where subquery is invalid
Next
From: Tom Lane
Date:
Subject: Re: BUG #17753: pg_dump --if-exists bug