Re: BUG #12276: Using old name of a renamed or dropped column in a sub-query does not throw error

Поиск
Список
Период
Сортировка
От Collin Peters
Тема Re: BUG #12276: Using old name of a renamed or dropped column in a sub-query does not throw error
Дата
Msg-id CAG_j9uxe-LZ+GBAHOk0fC7esnHpKSxPfut-9zkUYuThBs36Qqg@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #12276: Using old name of a renamed or dropped column in a sub-query does not throw error  (collin.peters@gmail.com)
Ответы Re: BUG #12276: Using old name of a renamed or dropped column in a sub-query does not throw error
Список pgsql-bugs
Wow, an amazing 'feature' for sure. Is there any use case where it actually
makes sense? I'm just wondering if this is a case where it is better to
stray from the spec? Would almost prefer a 'NOTICE' if you use an
unqualified column reference in a sub-query.

In any case... fun stuff!!  I'm glad it didn't delete something important
for us :)

On Thu Dec 18 2014 at 13:54:57 Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:

> collin.peters@gmail.com wrote:
>
> > Basically if you rename a column, and then use the original name in a
> > subquery, that sub-query does not complain that the column no longer
> exists,
> > and seems to complete ok. This will cause whatever SELECT or DELETE tha=
t
> is
> > using the sub-query to continue on its merry way and cause havoc.
>
> It's not using the old name of the column --- it's using the name of the
> OTHER column, that is, the column of the same name in the other table.
> In essence, your subquery always returns true.
>
> > -- select on value of 'bar' and orders for user 1
> > -- FAIL - returns all three order lines of 'bar'
> > SELECT        *
> > FROM    order_lines
> > WHERE   value =3D 'bar'
> > AND     order_id IN (
> >       -- THIS SHOULD FAIL!! THIS COLUMN NAME DOES NOT EXIST ANYMORE
> >       SELECT  order_id
> >       FROM    users
> >       WHERE   user_id =3D 1
> > );
> >
> > -- same delete as above, except value of 'bar'
> > DELETE
> > FROM    order_lines
> > WHERE   value =3D 'bar'
> > AND     order_id IN (
> >       -- THIS SHOULD FAIL!! THIS COLUMN NAME DOES NOT EXIST ANYMORE
> >       SELECT  order_id
> >       FROM    users
> >       WHERE   user_id =3D 1
> > );
>
>
> --
> =C3=81lvaro Herrera                http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: BUG #12276: Using old name of a renamed or dropped column in a sub-query does not throw error
Следующее
От: David G Johnston
Дата:
Сообщение: Re: BUG #12276: Using old name of a renamed or dropped column in a sub-query does not throw error