Re: BUG #6723: Exception for correct query - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #6723: Exception for correct query
Date
Msg-id 1768.1341893283@sss.pgh.pa.us
Whole thread Raw
In response to BUG #6723: Exception for correct query  (heiko.helmbrecht@xclinical.com)
List pgsql-bugs
heiko.helmbrecht@xclinical.com writes:
> The optimizer is using a where condition for a full table, not to the
> results of a join/subselect result, that's why it is tried to use casts,
> that cannot work on the whole table, here are the easy steps to reproduce
> the problems:

This is not a bug.  The optimizer is allowed to push conditions down
into subqueries; many people would be exceedingly unhappy if it failed
to do that.

There is a workaround you can use if you need it to not work like that,
though: add an "OFFSET 0" to the subquery.  LIMIT and OFFSET clauses
on subqueries serve as optimization fences, because the planner can't
push a WHERE condition down through one for fear of changing the set of
rows selected.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: BUG #6724: EXCEPTION syntax not recgonised
Next
From: Maciek Sakrejda
Date:
Subject: Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created