Re: [HACKERS] SELECT...FOR UPDATE OF class_name

From: Kristofer Munn <kmunn(at)munn(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] SELECT...FOR UPDATE OF class_name
Date: 2000-01-16 15:30:27
Message-ID: Pine.LNX.4.04.10001161027160.711-100000@munn.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Adrian Pach 2000-01-16 15:36:52 Credit Card ???????????
Previous Message Oliver Elphick 2000-01-16 15:10:34 Re: [HACKERS] Problem with foreign keys and inheritance