Re: Bug #938: Wrong UPDATE if exist INNER JOIN and alias

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Bug #938: Wrong UPDATE if exist INNER JOIN and alias
Дата
Msg-id 20030408074342.S50584-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Bug #938: Wrong UPDATE if exist INNER JOIN and alias for table  (pgsql-bugs@postgresql.org)
Ответы Re: Bug #938: Wrong UPDATE if exist INNER JOIN and alias
Список pgsql-bugs
On Tue, 8 Apr 2003 pgsql-bugs@postgresql.org wrote:

> Sergey Tikhonenko (tserge@dms.omskcity.com) reports a bug with a severity of 2
> The lower the number the more severe it is.
>
> Short Description
> Wrong UPDATE if exist INNER JOIN and alias for table
>
> Long Description
> UPDATE test1 SET value = 10 FROM test1 t1 INNER JOIN test2 ON t1.extid=test2.extid WHERE t1.id=1;
>
> This expression update all record i table "test1". Must update only 2 records. See example.

No, this must update all records.  The outer test1 in not constrained by
anything in your from/where.  You're joining a second copy of test1
(aliased t1) with test2 and then joining to test1 with no condition so all
rows in test1 are affected.

If you need to use it in this form (rather than the from test2 form) you
need to constrain test1 as well (for example  t1.id=test1.id and
t1.extid=test1.extid)

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Bug #938: Wrong UPDATE if exist INNER JOIN and alias for table
Следующее
От: "Donald Fraser"
Дата:
Сообщение: pg_catalog