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)
v2-0001-pg_stat_statements-Fix-nested-tracking-for-implic.patch
Description: Binary data
