PG-2014 Initalize nested query stack to fix crash on DDL#584
Merged
artemgavrilov merged 1 commit intopercona:release-2.3.1from Nov 21, 2025
Merged
PG-2014 Initalize nested query stack to fix crash on DDL#584artemgavrilov merged 1 commit intopercona:release-2.3.1from
artemgavrilov merged 1 commit intopercona:release-2.3.1from
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-2.3.1 #584 +/- ##
=================================================
+ Coverage 85.46% 85.48% +0.01%
=================================================
Files 3 3
Lines 1342 1343 +1
Branches 215 215
=================================================
+ Hits 1147 1148 +1
Misses 92 92
Partials 103 103 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dutow
approved these changes
Nov 20, 2025
8ad7096 to
ee5f374
Compare
The pgsm_ProcessUtility() which handles DDL increments nesting_level but does not put a query text on the next_queries stack while pgsm_ExecutorRun() does both. It is unclear to me if this is a mistake or by design but since readers of the query check for is the query text pointer is NULL and pgsm_ExecutorRun() reset the pointer to NULL before returning it is safe as long as we initialize the stack to all NULL pointers, which we did not. This bug was found by our test suite in Jenkins on some RHEL based distro version and seems to mostly happen when the first query of a backend is CREATE EXTENSION and we have enabled query normalization but it is entirely possible that it could happen under other circumstances too. The use of calloc() over palloc0() is to keep the patch small since the previous code used malloc().
ee5f374 to
3a9975d
Compare
artemgavrilov
approved these changes
Nov 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
pgsm_ProcessUtility()which handles DDL increments nesting_level but does not put a query text on the next_queries stack whilepgsm_ExecutorRun()does both. It is unclear to me if this is a mistake or by design but since readers of the query check for is the query text pointer isNULLandpgsm_ExecutorRun()reset the pointer toNULLbefore returning it is safe as long as we initialize the stack to allNULLpointers, which we did not.This bug was found by our test suite in Jenkins on some RHEL based distro version and seems to mostly happen when the first query of a backend is
CREATE EXTENSIONand we have enabled query normalization but it is entirely possible that it could happen under other circumstances too.The use of
calloc()overpalloc0()is to keep the patch small since the previous code usedmalloc().