Re: Patches for TODO item: Avoid truncating empty OCDR temp tables on COMMIT

Поиск
Список
Период
Сортировка
От Gurjeet Singh
Тема Re: Patches for TODO item: Avoid truncating empty OCDR temp tables on COMMIT
Дата
Msg-id CABwTF4Ugm0XZg57peUu_jiDrDbBCKy2d_04N_X=J=9tptGLBMQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Patches for TODO item: Avoid truncating empty OCDR temp tables on COMMIT  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Patches for TODO item: Avoid truncating empty OCDR temp tables on COMMIT  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Mon, Jan 14, 2013 at 10:33 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Gurjeet Singh <singh.gurjeet@gmail.com> writes:
> Please find attached two patches, implementing two different approaches to
> fix the issue of COMMIT truncating empty TEMP tables that have the ON
> COMMIT DELETE ROWS attribute.

> v2.patch: This approach introduces a boolean 'rd_rows_inserted' in
> RelationData struct, and sets this struct to true for every TEMP table in
> which a row is inserted. During commit, we avoid truncating those OCDR temp
> tables that haven't been inserted into in this transaction.

I think this is unacceptable on its face.  It essentially supposes that
relcache entries are reliable storage.  They are not.  There are some
places where we rely on relcache entries preserving state information
for optimization purposes --- but in this case, discarding a relcache
entry would result in visibly incorrect behavior, not just some
performance loss.

Would it be acceptable if we inverted the meaning of the struct member, and named it to  rd_rows_not_inserted. When registering an ON COMMIT action, we can set this member to true, and set it to false when inserting a row into it. The pre-commit hook will truncate any relation that doesn't have this member set to true.

With that in place, even if the relcache entry is discarded midway through the transaction, the cleanup code will truncate the relation, preserving the correct behaviour.
--

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: count(*) of zero rows returns 1
Следующее
От: Gurjeet Singh
Дата:
Сообщение: Re: count(*) of zero rows returns 1