Re: BUG #4618: nolock changes first column name of query result set to 'nolock'

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: brian <b4kramer(at)yahoo(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4618: nolock changes first column name of query result set to 'nolock'
Date: 2009-01-16 13:20:51
Message-ID: 20090116132051.GA65350@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Marshall, Steve 2009-01-16 13:27:07 Re: pg_listener entries deleted under heavy NOTIFY load only on Windows
Previous Message Magnus Hagander 2009-01-16 12:22:48 Re: BUG #4618: nolock changes first column name of query result set to 'nolock'