Re: [HACKERS] SELECT...FOR UPDATE OF class_name - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] SELECT...FOR UPDATE OF class_name
Date
Msg-id 20595.948042114@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] SELECT...FOR UPDATE OF class_name  (Kristofer Munn <kmunn@munn.com>)
List pgsql-hackers
Kristofer Munn <kmunn@munn.com> writes:
> select 1 from tbl2 t2, tbl1 t1 where tbl1.id1 = t2.id1 and t2.id1 = 7 ;
>                        ^^^^^^^       ^^^^
> Does not give any error.

What that's doing is giving you a *three way* join --- Postgres silently
adds an implicit FROM clause for the unaliased tbl1, as if you'd writtenFROM tbl2 t2, tbl1 t1, tbl1

This behavior has confused a lot of people; moreover it's not SQL
standard (I think it's a leftover from Berkeley's old POSTQUEL
language).  There's been a good deal of talk about removing it,
or at least giving a NOTICE when an implicit FROM clause is added.

FOR UPDATE seems to be set up to not allow implicit FROM clause
addition, which is probably a good thing --- it wouldn't make much
sense to say FOR UPDATE on a table not appearing anywhere else in
the query...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] pg_dump not in very good shape
Next
From: Peter Eisentraut
Date:
Subject: Re: psql variables fixed (?)