Thread: BUG #2172: Problem with query in order by

BUG #2172: Problem with query in order by

From
"Vic"
Date:
The following bug has been logged online:

Bug reference:      2172
Logged by:          Vic
Email address:      vic@stream.net.ua
PostgreSQL version: 8.0.6
Operating system:   FreeBSD 5.4/6.0
Description:        Problem with query in order by
Details:

when I send query
"select *
 from nets a,systbl
where a.type = systbl.tbl_
  and a.cid_ = 155
  and systbl.tblid = 'nettype'
order by a.endd, net; " - all working fine,
but
when I write in "order by" next: "order by nets.endd,net"
(I'm chane a. to nets. )
postgres returrn me linked "a" table with "systbl" by where phrase, and also
full link with nets table again

Sorry for my bad english :(,

I can send to email full describe tables and result of to select

Re: BUG #2172: Problem with query in order by

From
Stephan Szabo
Date:
On Mon, 16 Jan 2006, Vic wrote:

>
> The following bug has been logged online:
>
> Bug reference:      2172
> Logged by:          Vic
> Email address:      vic@stream.net.ua
> PostgreSQL version: 8.0.6
> Operating system:   FreeBSD 5.4/6.0
> Description:        Problem with query in order by
> Details:
>
> when I send query
> "select *
>  from nets a,systbl
> where a.type = systbl.tbl_
>   and a.cid_ = 155
>   and systbl.tblid = 'nettype'
> order by a.endd, net; " - all working fine,
> but
> when I write in "order by" next: "order by nets.endd,net"
> (I'm chane a. to nets. )
> postgres returrn me linked "a" table with "systbl" by where phrase, and also
> full link with nets table again

AFAIK, using nets.endd is incorrect, because it's name has been replaced
by the correlation name (a).

There's a GUC variable, add_missing_from that controls whether the table
is added to the from list again or that you get an error.