v1-add-missing-initialization-steps.patch
text/x-diff
Filename: v1-add-missing-initialization-steps.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| src/backend/bootstrap/bootstrap.c | 11 | 0 |
| src/backend/tcop/postgres.c | 15 | 0 |
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index a5217773ff..cffd63dcc0 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -334,6 +334,12 @@ BootstrapModeMain(int argc, char *argv[], bool check_only) CreateSharedMemoryAndSemaphores(); + /* + * Estimate number of openable files. This is essential too in --check + * mode, because on some platforms semaphores count as open files. + */ + set_max_safe_fds(); + /* * XXX: It might make sense to move this into its own function at some * point. Right now it seems like it'd cause more code duplication than @@ -346,6 +352,11 @@ BootstrapModeMain(int argc, char *argv[], bool check_only) abort(); } + /* + * Set reference point for stack-depth checking. + */ + (void) set_stack_base(); + /* * Do backend-like initialization for bootstrap mode */ diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index e0a603f42b..20554e0277 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -4238,8 +4238,23 @@ PostgresSingleUserMain(int argc, char *argv[], */ InitializeWalConsistencyChecking(); + /* + * Create shared memory etc. (Nothing's really "shared" in single-user + * mode, but we must have these data structures anyway.) + */ CreateSharedMemoryAndSemaphores(); + /* + * Estimate number of openable files. This must happen after setting up + * semaphores, because on some platforms semaphores count as open files. + */ + set_max_safe_fds(); + + /* + * Set reference point for stack-depth checking. + */ + (void) set_stack_base(); + /* * Remember stand-alone backend startup time,roughly at the same point * during startup that postmaster does so.