From d19c65ae4a574e2630e44e4f3d06466b7a87aa14 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Mon, 20 Jul 2026 10:12:59 -0400 Subject: [PATCH v1 8/8] Remove postgres_exec_path. This variable is populated with find_other_exec(..., "postgres", ...) but just before it's set, my_exec_path is set to what should be the same value by calling find_my_exec(). Having two variables that do the same thing seems silly, so remove one of them. This results in a minor behavior change that is worth highlighting: find_my_exec() only does pathname canonicalization, but find_other_exec() actually tries to run the binary it finds with the -V option to verify the version number. Removing the call to find_other_exec() means that sanity-check, which exists today only in EXEC_BACKEND builds, is lost. XXX: Are we OK with the behavior change described in the previous paragraph? If not, we can drop this commit. As far as I can see, that sanity check has value only if find_my_exec() is not actually reliable, so it seems like it should be OK, but I wonder if someone else can spot a problem. --- src/backend/postmaster/launch_backend.c | 6 +++--- src/backend/postmaster/postmaster.c | 9 --------- src/backend/utils/init/globals.c | 6 ------ src/include/miscadmin.h | 4 ---- 4 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/postmaster/launch_backend.c b/src/backend/postmaster/launch_backend.c index 56e2f1a3d02..ee121df7b9a 100644 --- a/src/backend/postmaster/launch_backend.c +++ b/src/backend/postmaster/launch_backend.c @@ -367,11 +367,11 @@ internal_forkexec(BackendType child_kind, int child_slot, /* Fire off execv in child */ if ((pid = fork_process()) == 0) { - if (execv(postgres_exec_path, argv) < 0) + if (execv(my_exec_path, argv) < 0) { ereport(LOG, (errmsg("could not execute server process \"%s\": %m", - postgres_exec_path))); + my_exec_path))); /* We're already in the child process here, can't return */ exit(1); } @@ -452,7 +452,7 @@ retry: sprintf(paramHandleStr, "%lu", (DWORD) paramHandle); #endif l = snprintf(cmdLine, sizeof(cmdLine) - 1, "\"%s\" --forkchild=%d %s", - postgres_exec_path, (int) child_kind, paramHandleStr); + my_exec_path, (int) child_kind, paramHandleStr); if (l >= sizeof(cmdLine)) { ereport(LOG, diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 90c7c4528e8..4c3ce7f6924 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -1482,15 +1482,6 @@ getInstallationPaths(const char *argv0) ereport(FATAL, (errmsg("%s: could not locate my own executable path", argv0))); -#ifdef EXEC_BACKEND - /* Locate executable backend before we change working directory */ - if (find_other_exec(argv0, "postgres", PG_BACKEND_VERSIONSTR, - postgres_exec_path) < 0) - ereport(FATAL, - (errmsg("%s: could not locate matching postgres executable", - argv0))); -#endif - /* * Locate the pkglib directory --- this has to be set early in case we try * to load any modules from it in response to postgresql.conf entries. diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index bbd28d14d99..5c0c089bf10 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -83,12 +83,6 @@ char OutputFileName[MAXPGPATH]; /* debugging output file */ char my_exec_path[MAXPGPATH]; /* full path to my executable */ char pkglib_path[MAXPGPATH]; /* full path to lib directory */ -#ifdef EXEC_BACKEND -char postgres_exec_path[MAXPGPATH]; /* full path to backend */ - -/* note: currently this is not valid in backend processes */ -#endif - ProcNumber MyProcNumber = INVALID_PROC_NUMBER; ProcNumber ParallelLeaderProcNumber = INVALID_PROC_NUMBER; diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 0fc59af02b9..e623a818fcf 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -203,10 +203,6 @@ extern PGDLLIMPORT char OutputFileName[]; extern PGDLLIMPORT char my_exec_path[]; extern PGDLLIMPORT char pkglib_path[]; -#ifdef EXEC_BACKEND -extern PGDLLIMPORT char postgres_exec_path[]; -#endif - extern PGDLLIMPORT Oid MyDatabaseId; extern PGDLLIMPORT Oid MyDatabaseTableSpace; -- 2.50.1 (Apple Git-155)