Re: change the order of FROM selection to make query work

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Thomas Peter <thomas(at)braindumped(dot)com>, pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: change the order of FROM selection to make query work
Date: 2006-09-27 18:55:44
Message-ID: 1159383344.26848.103.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2006-09-26 at 09:19, Tom Lane wrote:
> "Thomas Peter" <thomas(at)braindumped(dot)com> writes:
> > the full code that does produce the error (and this error can be resolved
> > as in OP described) is:
>
> Never oversimplify a bug report.
>
> > FROM ticket as t, permission as perm, enum as p
> > LEFT OUTER JOIN ticket_custom c ON (t.id = c.ticket AND c.name =
> > 'fachabteilung')
>
> The above is, plain and simple, wrong. According to the SQL spec,
> JOIN binds more tightly than comma in a FROM-list, so what you had was
>
> FROM ..., (enum as p
> LEFT OUTER JOIN ticket_custom c ON (t.id = c.ticket AND c.name =
> 'fachabteilung'))
>
> which of course fails because only p and c are visible in the JOIN's
> ON condition. You fixed it by moving "t" to become part of the JOIN
> structure.
>
> I was aware that MySQL parses this sort of structure wrongly, but it's
> disappointing to hear that sqlite does too :-(

And I think MySQL fixed this abberant behaviour in the newest beta.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2006-09-27 18:57:00 Re: Postgresql reindex hangs when table is being updated
Previous Message Steve Wampler 2006-09-27 18:28:51 Re: How to create nightly backups in Linux