-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix hint stack corruption on ERROR when setting GUCs from Set hints
The planner hook uses a PG_TRY/PG_CATCH block to handle the hint stack available for a given query. push_hint() is in charge of updating the stack with a new set in the planner hook, and pop_hint() would reset the stack to its previous state. It happens that the code was not cleaning up the stack between push_hint() and the PG_TRY/PG_CATCH block, and that it was possible to trigger ERRORs, corrupting the hint stack hold in a backend. Based on report #141, setting pg_hint_plan.parse_messages TO ERROR with an incorrect Set hint would be one case where the stack would get corrupted, because the GUCs defined in such hints are loaded after the hint stack update and before PG_TRY(). Any errors happening before PG_TRY() would be enough to corrupt the stack, like a palloc() failing on OOM, though this is very unlikely. This commit takes care of this bug by removing completely the window where the stack could get corrupted, by moving PG_TRY a little bit earlier. A regression test is added, provided by reporter. The patch is from me. Per report #141, from Egor Chindyaskin. Backpatch-through: 11
- Loading branch information
Showing
3 changed files
with
57 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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