Re: pg_stat_statements: Fix nested tracking for implicitly closed cursors

Поиск
Список
Период
Сортировка
От Sami Imseih
Тема Re: pg_stat_statements: Fix nested tracking for implicitly closed cursors
Дата
Msg-id CAA5RZ0tDxGO-O+n+HomO9cmHkq34v7WgT0Q+HsED-cuqW+JUWA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: pg_stat_statements: Fix nested tracking for implicitly closed cursors  (Martin Huang <jjja5555@gmail.com>)
Ответы Re: pg_stat_statements: Fix nested tracking for implicitly closed cursors
Re: pg_stat_statements: Fix nested tracking for implicitly closed cursors
Список pgsql-hackers
Hi,

Thanks for the comment!

> Please add a `PG_TRY` and `PG_FINALLY` to make sure we always reset the nesting_level.
>
> Also this will break the following scenario
> ```
> BEGIN;
> COMMIT;
> SELECT 1; -- This will be stored as inner level because COMMIT sets is_txn_end flag
> ```
>
> Can we reset is_txn_end at executorStart to solve the problem?

Correct.Thanks for spotting this oversight. I think the is_txn_end flag must
be reset in all hook functions that call pgss_store, except in pgss_ExecutorEnd,
where we just have to check is_txn_end and increment the nesting_level. Also,
I added a PG_TRY/FINALLY inside pgss_ExecutorEnd to ensure we reset the
nesting_level is reset.

I added a test case for the query you mentioned above.

--
Sami Imseih
Amazon Web Services (AWS)

Вложения

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