Re: BUG #4618: nolock changes first column name of query result set to 'nolock' - Mailing list pgsql-bugs

From Michael Fuhr
Subject Re: BUG #4618: nolock changes first column name of query result set to 'nolock'
Date
Msg-id 20090116132051.GA65350@winnie.fuhr.org
Whole thread Raw
In response to Re: BUG #4618: nolock changes first column name of query result set to 'nolock'  (Magnus Hagander <magnus@hagander.net>)
Responses Re: BUG #4618: nolock changes first column name of query result set to 'nolock'
List pgsql-bugs
On Fri, Jan 16, 2009 at 01:22:48PM +0100, Magnus Hagander wrote:
> brian wrote:
> > query1 works fine, first column in table is called movieid1:
> > select * from netflix.ratings where movieid = 1
> >
> > query2 is a bug and should work just fine, but gives error:
> > ERROR:  column "movieid" does not exist
> > LINE 2: select * from netflix.ratings with (nolock) where movieid = ...
>
> I don't know where you got "with (nolock)" from, but that's not
> PostgreSQL syntax - and AFAIK it's not standard SQL at all. Just remove
> it and you should be fine.

"with (nolock)" is a SQL Server-ism for improving performance by
using dirty reads.  Thanks to MVCC, PostgreSQL doesn't need such
nonsense.

The second query created a table alias for netflix.ratings named "with",
whose first column (presumably movieid) is aliased as "nolock".  The
following query probably would have worked (not that I'm recommending
it):

select * from netflix.ratings with (nolock) where nolock = ...

--
Michael Fuhr

pgsql-bugs by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: BUG #4618: nolock changes first column name of query result set to 'nolock'
Next
From: "Marshall, Steve"
Date:
Subject: Re: pg_listener entries deleted under heavy NOTIFY load only on Windows