Re: Incorrect UPDATE trigger invocation in the UPDATE clause of an UPSERT statement.

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: Incorrect UPDATE trigger invocation in the UPDATE clause of an UPSERT statement.
Дата
Msg-id CAM3SWZSiX3_6H149ZH6QF8Y9LuaYgpg1218bbF9_cjvyykaK4w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Incorrect UPDATE trigger invocation in the UPDATE clause of an UPSERT statement.  (Peter Geoghegan <pg@heroku.com>)
Ответы Re: Incorrect UPDATE trigger invocation in the UPDATE clause of an UPSERT statement.  (Michael Paquier <michael.paquier@gmail.com>)
Re: Incorrect UPDATE trigger invocation in the UPDATE clause of an UPSERT statement.  (Stanislav Grozev <tacho@daemonz.org>)
Re: Incorrect UPDATE trigger invocation in the UPDATE clause of an UPSERT statement.  (Andres Freund <andres@anarazel.de>)
Список pgsql-bugs
On Thu, Dec 3, 2015 at 1:10 PM, Peter Geoghegan <pg@heroku.com> wrote:
> I'll need to think about a fix.

The problem was with the pointer we pass to ExecUpdate().

It's a pointer to the target tuple in shared memory. So the field
"tuple.t_data->t_ctid" within ExecOnConflictUpdate() starts out
pointing to an ItemPointerData with the correct ctid (when it
initially points to the current/target tuple, since as an
about-to-be-upserted tuple the "t_ctid" field must be a pointer to the
self-same tuple). Then, it is modified in-place in shared memory by
heap_update(), within its critical section.

The fix is to take a deep copy (pass a pointer to an ItemPointerData
on the stack), as in the attached. I've also fixed up the tests, which
should have caught this, but didn't. Mea culpa.

Many thanks to Stanislav for the report! While I didn't adopt his
suggestion, he certainly almost had it right.

--
Peter Geoghegan

Вложения

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

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: Incorrect UPDATE trigger invocation in the UPDATE clause of an UPSERT statement.
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: pg_rewind exiting with error code 1 when source and target are on the same timeline