![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm not sure if this is a bug or if it's displaying my ignorance of this corner of SQL... update a set name = ( select name from temp.a where temp.a.id = a.id ) |
#3
| |||
| |||
|
|
Chris Dunlop <chris (AT) onthe (DOT) net.au> writes: I'm not sure if this is a bug or if it's displaying my ignorance of this corner of SQL... =20 update a set name =3D ( select name from temp.a where temp.a.id =3D a.id ) =20 Postgres treats "FROM temp.a" the same as "FROM temp.a AS a", and then the "a.id" references that rather than the outer query's A. Try just "select name from temp.a where temp.a.id =3D a.id;" to see this in action. |
|
Looking at the SQL spec, I'm having a hard time finding any verbiage that either confirms or denies this interpretation. It says that a FROM item without a correlation name (ie, an AS alias) exposes the table name, and then a column reference can refer to the table name, but it's not at all clear whether the table name must be qualified or not in the reference. Comments anyone? |
|
update a correlationname set name =3D ( select name from temp.a where temp.a.id =3D correlationname.a.id ) |
#4
| |||
| |||
|
|
On Mon, 2006-10-02 at 11:38 -0400, Tom Lane wrote: Postgres treats "FROM temp.a" the same as "FROM temp.a AS a", [Which AFAICS doesn't follow SQL:2003, since a reference to temp.a should not be allowed following its redefinition as a.] |
#5
| |||
| |||
|
|
The comments for refnameRangeTblEntry indicate that at one time we thought we saw support for our approach in the spec: |
![]() |
| Thread Tools | |
| Display Modes | |
| |