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

From Kristofer Munn
Subject Re: [HACKERS] SELECT...FOR UPDATE OF class_name
Date
Msg-id Pine.LNX.4.04.10001161027160.711-100000@munn.com
Whole thread Raw
In response to Re: [HACKERS] SELECT...FOR UPDATE OF class_name  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [HACKERS] SELECT...FOR UPDATE OF class_name
List pgsql-hackers
Tom Lane wrote:
>
> > ERROR:  FOR UPDATE: relation tbl2 not found in FROM clause
> 
> I believe the error message is correct; you should have written
> 
> select 1 from tbl2 t2, tbl1 t1 where t1.id1 = t2.id1 and 
>     t2.id1 = 7 for update of t2;
> 
> A lot of people do not realize that writing an alias for a table
> in FROM means that as far as all the rest of that query is concerned,
> that alias *is* the name of the table.  
>
> [ additional comments and self-join example clipped ]

Ok, that sounds like a fine rule except for non-self-joins:

mail=> select 1 from tbl2 t2, tbl1 t1 where tbl1.id1 = t2.id1 and t2.id1 = 7 ;                             ^^^^^^^
^^^^
 
Does not give any error.  I had expected that behavior to be consistent
which is why I ran into the error.  However, I have no problem with that
explanation.

- K

Kristofer Munn * KMI * 973-509-9414 * AIM KrMunn * http://www.munn.com/



pgsql-hackers by date:

Previous
From: "Oliver Elphick"
Date:
Subject: Re: [HACKERS] Problem with foreign keys and inheritance
Next
From: "Adrian Pach"
Date:
Subject: Credit Card ???????????