Subject: drop postmaster symlink

From: Peter Eisentraut <[email-masked]>
Date: Wed, 23 Nov 2022 08:52:43 +0100

A little while ago we discussed briefly over in the meson thread whether 
we could remove the postmaster symlink [0].  The meson build system 
currently does not install a postmaster symlink.  (AFAICT, the MSVC 
build system does not either.)  So if we want to elevate the meson build 
system, we either need to add the postmaster symlink, or remove it from 
the other build system(s) as well.  Seeing that it's been deprecated for 
a long time, I propose we just remove it.  See attached patches.

[0]: 
https://www.postgresql.org/message-id/[email-masked]

From 179eaab96dc5215970b2b3485cf77f1a58f9d337 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email-masked]>
Date: Sun, 13 Nov 2022 20:52:00 +0100
Subject: [PATCH 1/2] Remove gratuitous references to postmaster instead of
 postgres

---
 contrib/start-scripts/freebsd | 2 +-
 contrib/start-scripts/linux   | 2 +-
 src/port/path.c               | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/start-scripts/freebsd b/contrib/start-scripts/freebsd
index 3323237a54b4..5e22b2d2f0e4 100644
--- a/contrib/start-scripts/freebsd
+++ b/contrib/start-scripts/freebsd
@@ -29,7 +29,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
 # What to use to start up the postmaster.  (If you want the script to wait
 # until the server has started, you could use "pg_ctl start" here.)
-DAEMON="$prefix/bin/postmaster"
+DAEMON="$prefix/bin/postgres"
 
 # What to use to shut down the postmaster
 PGCTL="$prefix/bin/pg_ctl"
diff --git a/contrib/start-scripts/linux b/contrib/start-scripts/linux
index a7757162fc4b..9292855df716 100644
--- a/contrib/start-scripts/linux
+++ b/contrib/start-scripts/linux
@@ -61,7 +61,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
 # What to use to start up the postmaster.  (If you want the script to wait
 # until the server has started, you could use "pg_ctl start" here.)
-DAEMON="$prefix/bin/postmaster"
+DAEMON="$prefix/bin/postgres"
 
 # What to use to shut down the postmaster
 PGCTL="$prefix/bin/pg_ctl"
diff --git a/src/port/path.c b/src/port/path.c
index 05fe812f757b..fb64873c7a43 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -651,7 +651,7 @@ dir_strcmp(const char *s1, const char *s2)
  * For example:
  *		target_path  = '/usr/local/share/postgresql'
  *		bin_path	 = '/usr/local/bin'
- *		my_exec_path = '/opt/pgsql/bin/postmaster'
+ *		my_exec_path = '/opt/pgsql/bin/postgres'
  * Given these inputs, the common prefix is '/usr/local/', the tail of
  * bin_path is 'bin' which does match the last directory component of
  * my_exec_path, so we would return '/opt/pgsql/share/postgresql'
-- 
2.38.1

From 6118b4098a50b78ca7437938117cc3ab41b72e08 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email-masked]>
Date: Sun, 13 Nov 2022 20:52:56 +0100
Subject: [PATCH 2/2] Don't install postmaster symlink anymore

Also remove man page.
---
 doc/src/sgml/ref/postmaster.sgml | 44 --------------------------------
 doc/src/sgml/reference.sgml      |  1 -
 src/backend/Makefile             |  8 +-----
 3 files changed, 1 insertion(+), 52 deletions(-)
 delete mode 100644 doc/src/sgml/ref/postmaster.sgml

diff --git a/doc/src/sgml/ref/postmaster.sgml b/doc/src/sgml/ref/postmaster.sgml
deleted file mode 100644
index 7b544ed0b613..000000000000
--- a/doc/src/sgml/ref/postmaster.sgml
+++ /dev/null
@@ -1,44 +0,0 @@
-<!--
-doc/src/sgml/ref/postmaster.sgml
-PostgreSQL documentation
--->
-
-<refentry id="app-postmaster">
- <indexterm zone="app-postmaster">
-  <primary>postmaster</primary>
- </indexterm>
-
- <refmeta>
-  <refentrytitle><application>postmaster</application></refentrytitle>
-  <manvolnum>1</manvolnum>
-  <refmiscinfo>Application</refmiscinfo>
- </refmeta>
-
- <refnamediv>
-  <refname>postmaster</refname>
-  <refpurpose><productname>PostgreSQL</productname> database server</refpurpose>
- </refnamediv>
-
- <refsynopsisdiv>
-  <cmdsynopsis>
-   <command>postmaster</command>
-   <arg rep="repeat"><replaceable>option</replaceable></arg>
-  </cmdsynopsis>
- </refsynopsisdiv>
-
- <refsect1>
-  <title>Description</title>
-
-  <para>
-   <command>postmaster</command> is a deprecated alias of <command>postgres</command>.
-  </para>
- </refsect1>
-
- <refsect1>
-  <title>See Also</title>
-
-  <para>
-   <xref linkend="app-postgres"/>
-  </para>
- </refsect1>
-</refentry>
diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml
index a3b743e8c1e7..e11b4b613075 100644
--- a/doc/src/sgml/reference.sgml
+++ b/doc/src/sgml/reference.sgml
@@ -289,7 +289,6 @@ <title>PostgreSQL Server Applications</title>
    &pgupgrade;
    &pgwaldump;
    &postgres;
-   &postmaster;
 
  </reference>
 
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 181c217fae4c..ed364543b74e 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -208,12 +208,6 @@ endif
 
 install-bin: postgres $(POSTGRES_IMP) installdirs
 	$(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)'
-ifneq ($(PORTNAME), win32)
-	@rm -f '$(DESTDIR)$(bindir)/postmaster$(X)'
-	ln -s postgres$(X) '$(DESTDIR)$(bindir)/postmaster$(X)'
-else
-	$(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postmaster$(X)'
-endif
 ifeq ($(MAKE_EXPORTS), true)
 	$(INSTALL_DATA) $(POSTGRES_IMP) '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
 	$(INSTALL_PROGRAM) $(MKLDEXPORT) '$(DESTDIR)$(pgxsdir)/$(MKLDEXPORT_DIR)/mkldexport.sh'
@@ -242,7 +236,7 @@ endif
 ##########################################################################
 
 uninstall:
-	rm -f '$(DESTDIR)$(bindir)/postgres$(X)' '$(DESTDIR)$(bindir)/postmaster'
+	rm -f '$(DESTDIR)$(bindir)/postgres$(X)'
 ifeq ($(MAKE_EXPORTS), true)
 	rm -f '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
 	rm -f '$(DESTDIR)$(pgxsdir)/$(MKLDEXPORT_DIR)/mkldexport.sh'
-- 
2.38.1

---

From: Joe Conway <[email-masked]>
Date: Wed, 23 Nov 2022 09:18:30 -0500

> a long time, I propose we just remove it.  See attached patches.

I am a big +1 on removing the symlink, however it is worth pointing out 
that the PGDG RPMs still use the symlink in the included systemd service 
file:

8<----------
ExecStart=/usr/pgsql-15/bin/postmaster -D ${PGDATA}
8<----------

-- 
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

---

From: Devrim Gündüz <[email-masked]>
Date: Wed, 23 Nov 2022 14:28:32 +0000

Hi,

> that the PGDG RPMs still use the symlink in the included systemd

...and it helps us to find the "main" process a bit easily.

Regards,
-- 
Devrim Gündüz
Open Source Solution Architect, Red Hat Certified Engineer
Twitter: @DevrimGunduz , @DevrimGunduzTR

---

From: Tom Lane <[email-masked]>
Date: Wed, 23 Nov 2022 10:07:49 -0500

> ...and it helps us to find the "main" process a bit easily.

Hmm, that's a nontrivial point perhaps.  It's certain that this
will break some other people's start scripts too.  On the whole,
is it really that hard to add the symlink to the meson build?

			regards, tom lane

---

From: Andres Freund <[email-masked]>
Date: Wed, 23 Nov 2022 11:50:10 -0800

Hi,

On 2022-11-23 10:07:49 -0500, Tom Lane wrote:
> will break some other people's start scripts too.

OTOH, postmaster has been deprecated for ~15 years.

> On the whole, is it really that hard to add the symlink to the meson build?

No. Meson has a builtin command for it, just not in the meson version we're
currently requiring. We can create the symlink ourselves instead. The problem
is just detecting systems where we can't symlink and what to fall back to
there.

Greetings,

Andres Freund

---

From: Robert Haas <[email-masked]>
Date: Wed, 23 Nov 2022 15:10:05 -0500

> OTOH, postmaster has been deprecated for ~15 years.

Yeah. Also, I don't think it's generally too hard to find the parent
process anyway, because at least on my system, the other ones end up
with ps display that looks like "postgres: logical replication
launcher" or whatever. The main process doesn't set the ps status
display, so that's the only one that shows a full path to the
executable in the ps status, which is how I usually spot it. That has
the advantage that it doesn't matter which name was used to launch it,
too.

I don't actually care very much whether we get rid of the postmaster
symlink or not, but if we aren't going to, we should stop calling it
deprecated. If 15 years isn't enough time to remove it, what ever will
be? I tend to think it's fairly pointless and perhaps also a bit
confusing, because the product is postgres not postmaster and people
can reasonably expect the binary name to match the product name. But
if we keep it, I don't think anything too dire will happen, either.

-- 
Robert Haas
EDB: http://www.enterprisedb.com

---

From: Joe Conway <[email-masked]>
Date: Wed, 23 Nov 2022 15:32:17 -0500

> the advantage that it doesn't matter which name was used to launch it,

Same here

> if we keep it, I don't think anything too dire will happen, either.

FWIW, the reason I took note of the postmaster symlink in the first 
place a few years ago was because selinux treats execution of programs 
from symlinks differently than from actual files.

---

From: Tom Lane <[email-masked]>
Date: Wed, 23 Nov 2022 15:48:04 -0500

> is just detecting systems where we can't symlink and what to fall back to

This isn't a hill I want to die on, either way.  But "it's a bit
more complicated in meson" seems like a poor reason for changing
the user-visible installed fileset.

			regards, tom lane

---

From: Andres Freund <[email-masked]>
Date: Wed, 23 Nov 2022 13:08:05 -0800

Hi,

> the user-visible installed fileset.

I wouldn't even have thought about proposing dropping the symlink if it hadn't
been deprecated forever, and I suspect Peter wouldn't have either...

I think this is a bit more more complicated than "changing the user-visible
installed fileset" because we didn't have logic to create 'postmaster' on
windows before, afaik the only OS without reliable symlink support.

Anyway, my current thinking is to have dumb OS dependent behaviour and create
a symlink everywhere but windows, where we'd just copy the file.

Or we could just continue to not install 'postmaster' on windows, because of
the potential confusion that 'postmaster.exe' differing from 'postgres.exe'
could cause.

Greetings,

Andres Freund

---

From: Daniel Gustafsson <[email-masked]>
Date: Thu, 24 Nov 2022 01:15:03 +0100

> On 23 Nov 2022, at 21:10, Robert Haas <[email-masked]> wrote:

> be?

+1.  If we actively add support for something then it isn't really all that
deprecated IMHO.

--
Daniel Gustafsson		https://vmware.com/