From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Remove MaxBackends variable in favor of GetMaxBackends() functio
Date: Tue, 08 Feb 2022 21:12:19 +0000
Message-ID: <E1nHXmd-0007K1-CP@gemulon.postgresql.org> (raw)
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
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/aa64f23b02924724eafbd9eadbf26d85df30a12b
Modified Files
--------------
src/backend/access/nbtree/nbtutils.c | 4 +-
src/backend/access/transam/multixact.c | 31 +++++++---
src/backend/access/transam/twophase.c | 3 +-
src/backend/commands/async.c | 11 ++--
src/backend/libpq/pqcomm.c | 3 +-
src/backend/postmaster/auxprocess.c | 2 +-
src/backend/postmaster/postmaster.c | 4 +-
src/backend/storage/ipc/dsm.c | 2 +-
src/backend/storage/ipc/procarray.c | 25 +++++---
src/backend/storage/ipc/procsignal.c | 37 +++++++-----
src/backend/storage/ipc/sinvaladt.c | 4 +-
src/backend/storage/lmgr/deadlock.c | 31 +++++-----
src/backend/storage/lmgr/lock.c | 22 ++++----
src/backend/storage/lmgr/predicate.c | 10 ++--
src/backend/storage/lmgr/proc.c | 17 +++---
src/backend/utils/activity/backend_status.c | 88 ++++++++++++++++-------------
src/backend/utils/adt/lockfuncs.c | 4 +-
src/backend/utils/init/postinit.c | 50 ++++++++++++++--
src/include/miscadmin.h | 3 +-
19 files changed, 218 insertions(+), 133 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: rhaas@postgresql.org
Subject: Re: pgsql: Remove MaxBackends variable in favor of GetMaxBackends() functio
In-Reply-To: <E1nHXmd-0007K1-CP@gemulon.postgresql.org>
References: <E1nHXmd-0007K1-CP@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox