Re: pg_stat_statements: add missing tests for nesting_level
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: Sami Imseih <samimseih@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-01-25T07:41:22Z
Lists: pgsql-hackers
Attachments
- 0001-Fix-PGSS-test.patch (text/x-diff) patch 0001
On Sun, Jan 25, 2026 at 08:00:00AM +0200, Alexander Lakhin wrote: > I can reproduce this locally with no extra tricks. Could you please adjust > the test for this mode? Reproduced here. That was trickier than it looks. A trick with debug_discard_caches cannot help, because with a CLOBBER_CACHE_ALWAYS build we would still do a GetCachedPlan() -> RevalidateCachedQuery() that goes through the post-parse analyze hook where the query would still be normalized, showing up in the output anyway. So I have come up with a plan B. If we do a DISCARD PLANS before the *first* function call, we can force the test to revalidate the cached query without caring about CLOBBER_CACHE_ALWAYS, meaning that we would always store a normalized version of the inner query. The point of the test is to check after the nesting level calculation in the planner hook, and the test is still able to check that correctly. If I remove the nesting_level bits from the code while the DISCARD is around, the entry is stored as a top level entry incorrectly, but it should be stored as toplevel=false. I'll go apply the attached shortly, after some more checks.. -- Michael
Commits
-
pg_stat_statements: Fix test instability with cache-clobbering builds
- 72e3abd082c3 19 (unreleased) landed
-
pg_stat_statements: Add more tests for level tracking
- 1572ea96e657 19 (unreleased) landed