Set the stack_base_ptr in main(), not in random other places.
Tom Lane <tgl@sss.pgh.pa.us>
Set the stack_base_ptr in main(), not in random other places. Previously we did this in PostmasterMain() and InitPostmasterChild(), which meant that stack depth checking was disabled in non-postmaster server processes, for instance in single-user mode. That seems like a fairly bad idea, since there's no a-priori restriction on the complexity of queries we will run in single-user mode. Moreover, this led to not having quite the same stack depth limit in all processes, which likely has no real-world effect but it offends my inner neatnik. Setting the depth in main() guarantees that check_stack_depth() is armed and has a consistent interpretation of stack depth in all forms of server processes. While at it, move the code associated with checking the stack depth out of tcop/postgres.c (which was never a great home for it) into a new file src/backend/utils/misc/stack_depth.c. Discussion: https://postgr.es/m/2081982.1734393311@sss.pgh.pa.us
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/main/main.c | modified | +6 −0 |
| src/backend/postmaster/postmaster.c | modified | +0 −5 |
| src/backend/tcop/postgres.c | modified | +0 −173 |
| src/backend/utils/init/miscinit.c | modified | +0 −7 |
| src/backend/utils/misc/Makefile | modified | +1 −0 |
| src/backend/utils/misc/meson.build | modified | +1 −0 |
| src/backend/utils/misc/stack_depth.c | added | +197 −0 |
| src/include/miscadmin.h | modified | +7 −1 |
| src/include/tcop/tcopprot.h | modified | +0 −5 |
Discussion
- Missing initialization steps in --check and --single modes 2 messages · 2024-12-16 → 2024-12-17