diff options
author | Robert Haas <rhaas@postgresql.org> | 2022-02-08 15:52:40 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2022-02-08 15:53:19 -0500 |
commit | aa64f23b02924724eafbd9eadbf26d85df30a12b (patch) | |
tree | 54f72bfd7e36c2e879dc87149eb94db220d1cae3 /src/include/miscadmin.h | |
parent | 2da896182ce11240774af6c4d769777f90a09536 (diff) | |
download | postgresql-aa64f23b02924724eafbd9eadbf26d85df30a12b.tar.gz postgresql-aa64f23b02924724eafbd9eadbf26d85df30a12b.zip |
Remove MaxBackends variable in favor of GetMaxBackends() function.
Previously, it was really easy to write code that accessed MaxBackends
before we'd actually initialized it, especially when coding up an
extension. To make this less error-prune, introduce a new function
GetMaxBackends() which should be used to obtain the correct value.
This will ERROR if called too early. Demote the global variable to
a file-level static, so that nobody can peak at it directly.
Nathan Bossart. Idea by Andres Freund. Review by Greg Sabino Mullane,
by Michael Paquier (who had doubts about the approach), and by me.
Discussion: http://postgr.es/m/20210802224204.bckcikl45uezv5e4@alap3.anarazel.de
Diffstat (limited to 'src/include/miscadmin.h')
-rw-r--r-- | src/include/miscadmin.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 02276d3edd5..0abc3ad5405 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -172,7 +172,6 @@ extern PGDLLIMPORT char *DataDir; extern PGDLLIMPORT int data_directory_mode; extern PGDLLIMPORT int NBuffers; -extern PGDLLIMPORT int MaxBackends; extern PGDLLIMPORT int MaxConnections; extern PGDLLIMPORT int max_worker_processes; extern PGDLLIMPORT int max_parallel_workers; @@ -457,6 +456,8 @@ extern AuxProcType MyAuxProcType; /* in utils/init/postinit.c */ extern void pg_split_opts(char **argv, int *argcp, const char *optstr); extern void InitializeMaxBackends(void); +extern int GetMaxBackends(void); +extern void SetMaxBackends(int max_backends); extern void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, char *out_dbname, bool override_allow_connections); extern void BaseInit(void); |