Re: BUG #17623: WHERE should be evaluated after FROM clause when operators may throw
От | Tom Lane |
---|---|
Тема | Re: BUG #17623: WHERE should be evaluated after FROM clause when operators may throw |
Дата | |
Msg-id | 3945739.1664375858@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: BUG #17623: WHERE should be evaluated after FROM clause when operators may throw ("David G. Johnston" <david.g.johnston@gmail.com>) |
Ответы |
Re: BUG #17623: WHERE should be evaluated after FROM clause when operators may throw
|
Список | pgsql-bugs |
"David G. Johnston" <david.g.johnston@gmail.com> writes: >> The SQL standard (Section 7.4 general rule 1) mandates that WHERE should be >> applied to the result of FROM so in the case above pushing filters below >> the join seems to violate the standard. > The failure to document such a deviation from the standard can be > considered a bug but not the deviation itself. That is intentional. In > terms of trade-offs the current behavior seems reasonable. Enforcing such a restriction would be absolutely disastrous for the performance of a large number of real-world queries. I doubt that any other RDBMS takes that spec wording literally either. I'd suggest something like CASE WHEN e.empno = 0 THEN NULL ELSE 10 / e.empno END if you need to program around the lack of guarantees about the order of evaluation. A WITH clause can also be used as an optimization fence when you need one. BTW, this *is* documented, see for example https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-EXPRESS-EVAL regards, tom lane
В списке pgsql-bugs по дате отправления: