Remove support for old realpath() API

Started by Peter Eisentrautover 1 year ago11 messages
#1Peter Eisentraut
peter@eisentraut.org
1 attachment(s)

The now preferred way to call realpath() is by passing NULL as the
second argument and get a malloc'ed result. We still supported the
old way of providing our own buffer as a second argument, for some
platforms that didn't support the new way yet. Those were only
Solaris less than version 11 and some older AIX versions (7.1 and
newer appear to support the new variant). We don't support those
platforms versions anymore, so we can remove this extra code.

Attachments:

0001-Remove-support-for-old-realpath-API.patchtext/plain; charset=UTF-8; name=0001-Remove-support-for-old-realpath-API.patchDownload
From aba5b5b6017eff0baa59698de665058843fe1d05 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 5 Aug 2024 07:50:27 +0200
Subject: [PATCH] Remove support for old realpath() API

The now preferred way to call realpath() is by passing NULL as the
second argument and get a malloc'ed result.  We still supported the
old way of providing our own buffer as a second argument, for some
platforms that didn't support the new way yet.  Those were only
Solaris less than version 11 and some older AIX versions (7.1 and
newer appear to support the new variant).  We don't support those
platforms versions anymore, so we can remove this extra code.
---
 src/common/exec.c | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/src/common/exec.c b/src/common/exec.c
index 0bee19c1e53..32fd56532aa 100644
--- a/src/common/exec.c
+++ b/src/common/exec.c
@@ -285,25 +285,6 @@ pg_realpath(const char *fname)
 
 #ifndef WIN32
 	path = realpath(fname, NULL);
-	if (path == NULL && errno == EINVAL)
-	{
-		/*
-		 * Cope with old-POSIX systems that require a user-provided buffer.
-		 * Assume MAXPGPATH is enough room on all such systems.
-		 */
-		char	   *buf = malloc(MAXPGPATH);
-
-		if (buf == NULL)
-			return NULL;		/* assume errno is set */
-		path = realpath(fname, buf);
-		if (path == NULL)		/* don't leak memory */
-		{
-			int			save_errno = errno;
-
-			free(buf);
-			errno = save_errno;
-		}
-	}
 #else							/* WIN32 */
 
 	/*
-- 
2.46.0

#2Heikki Linnakangas
hlinnaka@iki.fi
In reply to: Peter Eisentraut (#1)
Re: Remove support for old realpath() API

On 05/08/2024 09:12, Peter Eisentraut wrote:

The now preferred way to call realpath() is by passing NULL as the
second argument and get a malloc'ed result.  We still supported the
old way of providing our own buffer as a second argument, for some
platforms that didn't support the new way yet.  Those were only
Solaris less than version 11 and some older AIX versions (7.1 and
newer appear to support the new variant).  We don't support those
platforms versions anymore, so we can remove this extra code.

+1

We don't seem to have any mentions of POSIX or SuS in docs, in the
installation sections. There are a few mentions of POSIX-1.2008 and
POSIX-1.2001 it in the commit log, though, where we require features
specified by those. Can we rely on everything from POSIX-1-2008
nowadays, or is it more on a case-by-case basis, depending on which
parts of POSIX are supported by various platforms?

--
Heikki Linnakangas
Neon (https://neon.tech)

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Heikki Linnakangas (#2)
Re: Remove support for old realpath() API

Heikki Linnakangas <hlinnaka@iki.fi> writes:

We don't seem to have any mentions of POSIX or SuS in docs, in the
installation sections. There are a few mentions of POSIX-1.2008 and
POSIX-1.2001 it in the commit log, though, where we require features
specified by those. Can we rely on everything from POSIX-1-2008
nowadays, or is it more on a case-by-case basis, depending on which
parts of POSIX are supported by various platforms?

I'd say it's still case-by-case. Perhaps everything in POSIX-1.2008
is supported now on every platform we care about, but perhaps not.

regards, tom lane

#4Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#3)
Re: Remove support for old realpath() API

On Mon, Aug 05, 2024 at 10:08:04AM -0400, Tom Lane wrote:

Heikki Linnakangas <hlinnaka@iki.fi> writes:

We don't seem to have any mentions of POSIX or SuS in docs, in the
installation sections. There are a few mentions of POSIX-1.2008 and
POSIX-1.2001 it in the commit log, though, where we require features
specified by those. Can we rely on everything from POSIX-1-2008
nowadays, or is it more on a case-by-case basis, depending on which
parts of POSIX are supported by various platforms?

I'd say it's still case-by-case. Perhaps everything in POSIX-1.2008
is supported now on every platform we care about, but perhaps not.

Just pointing at the message where this has been discussed previously,
for reference:
/messages/by-id/1457809.1662232534@sss.pgh.pa.us

Leaving Solaris aside because there is nothing older than 11 in the
buildfarm currently, I am dubious that it is a good idea to remove
this code knowing that we have a thread from a few months ago about
the fact that we have folks complaining about AIX support and that we
should bring it back:
/messages/by-id/CY5PR11MB63928CC05906F27FB10D74D0FD322@CY5PR11MB6392.namprd11.prod.outlook.com
--
Michael

#5Daniel Gustafsson
daniel@yesql.se
In reply to: Michael Paquier (#4)
Re: Remove support for old realpath() API

On 6 Aug 2024, at 07:43, Michael Paquier <michael@paquier.xyz> wrote:

I am dubious that it is a good idea to remove
this code knowing that we have a thread from a few months ago about
the fact that we have folks complaining about AIX support and that we
should bring it back:

According to upthread it is supported since AIX 7.1 which shipped in 2010 so
even if support materializes for AIX it still wouldn't be needed.

--
Daniel Gustafsson

#6Peter Eisentraut
peter@eisentraut.org
In reply to: Heikki Linnakangas (#2)
Re: Remove support for old realpath() API

On 05.08.24 09:41, Heikki Linnakangas wrote:

On 05/08/2024 09:12, Peter Eisentraut wrote:

The now preferred way to call realpath() is by passing NULL as the
second argument and get a malloc'ed result.  We still supported the
old way of providing our own buffer as a second argument, for some
platforms that didn't support the new way yet.  Those were only
Solaris less than version 11 and some older AIX versions (7.1 and
newer appear to support the new variant).  We don't support those
platforms versions anymore, so we can remove this extra code.

+1

committed

#7Thomas Munro
thomas.munro@gmail.com
In reply to: Peter Eisentraut (#6)
Re: Remove support for old realpath() API

On Mon, Aug 12, 2024 at 6:18 PM Peter Eisentraut <peter@eisentraut.org> wrote:

On 05.08.24 09:41, Heikki Linnakangas wrote:

On 05/08/2024 09:12, Peter Eisentraut wrote:

The now preferred way to call realpath() is by passing NULL as the
second argument and get a malloc'ed result. We still supported the
old way of providing our own buffer as a second argument, for some
platforms that didn't support the new way yet. Those were only
Solaris less than version 11 and some older AIX versions (7.1 and
newer appear to support the new variant). We don't support those
platforms versions anymore, so we can remove this extra code.

I checked this in the AIX 7.3 manual and the POSIX 2008 way does not
appear to be mentioned there:

https://www.ibm.com/docs/en/aix/7.3?topic=r-realpath-subroutine

That's a bit confusing, or maybe there are just too many versioning
systems to keep track of and I've made a mistake, because it looks
like AIX 7.2.5+ has actual certification for Unix V7 AKA SUSv4 AKA
POSIX 2008... Or maybe the documentation is wrong and it does
actually work. I guess the IBM crew will be forced to look into this
as they continue to work on their PostgreSQL/AIX patch, if it doesn't
work...

#8Peter Eisentraut
peter@eisentraut.org
In reply to: Thomas Munro (#7)
Re: Remove support for old realpath() API

On 12.08.24 08:47, Thomas Munro wrote:

On Mon, Aug 12, 2024 at 6:18 PM Peter Eisentraut <peter@eisentraut.org> wrote:

On 05.08.24 09:41, Heikki Linnakangas wrote:

On 05/08/2024 09:12, Peter Eisentraut wrote:

The now preferred way to call realpath() is by passing NULL as the
second argument and get a malloc'ed result. We still supported the
old way of providing our own buffer as a second argument, for some
platforms that didn't support the new way yet. Those were only
Solaris less than version 11 and some older AIX versions (7.1 and
newer appear to support the new variant). We don't support those
platforms versions anymore, so we can remove this extra code.

I checked this in the AIX 7.3 manual and the POSIX 2008 way does not
appear to be mentioned there:

https://www.ibm.com/docs/en/aix/7.3?topic=r-realpath-subroutine

That's a bit confusing, or maybe there are just too many versioning
systems to keep track of and I've made a mistake, because it looks
like AIX 7.2.5+ has actual certification for Unix V7 AKA SUSv4 AKA
POSIX 2008... Or maybe the documentation is wrong and it does
actually work. I guess the IBM crew will be forced to look into this
as they continue to work on their PostgreSQL/AIX patch, if it doesn't
work...

Tom had tested this on and found that it does actually work on AIX 7.1
and 7.3 but the documentation is wrong.

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#8)
Re: Remove support for old realpath() API

Peter Eisentraut <peter@eisentraut.org> writes:

On 12.08.24 08:47, Thomas Munro wrote:

I checked this in the AIX 7.3 manual and the POSIX 2008 way does not
appear to be mentioned there:
https://www.ibm.com/docs/en/aix/7.3?topic=r-realpath-subroutine

Tom had tested this on and found that it does actually work on AIX 7.1
and 7.3 but the documentation is wrong.

I too have a distinct recollection of having tested this (using the
gcc compile farm machines), but I cannot find anything saying so in
the mailing list archives. I can go check it again, I guess.

regards, tom lane

#10Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom Lane (#9)
1 attachment(s)
Re: Remove support for old realpath() API

I wrote:

Peter Eisentraut <peter@eisentraut.org> writes:

Tom had tested this on and found that it does actually work on AIX 7.1
and 7.3 but the documentation is wrong.

I too have a distinct recollection of having tested this (using the
gcc compile farm machines), but I cannot find anything saying so in
the mailing list archives. I can go check it again, I guess.

I can confirm that the attached program works on cfarm111 (AIX 7.1)
and cfarm119 (AIX 7.3), though "man realpath" denies it on both
systems.

I also found leftover test files demonstrating that I checked this
same point on Apr 26 2024, so I'm not sure why that didn't turn up
in a mail list search.

regards, tom lane

Attachments:

testrealpath.ctext/x-c; charset=us-ascii; name=testrealpath.cDownload
#11Thomas Munro
thomas.munro@gmail.com
In reply to: Tom Lane (#10)
Re: Remove support for old realpath() API

On Tue, Aug 13, 2024 at 2:35 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:

I can confirm that the attached program works on cfarm111 (AIX 7.1)
and cfarm119 (AIX 7.3), though "man realpath" denies it on both
systems.

Another example of this phenomenon: they have nl_langinfo_l(), a POSIX
2008 feature we want in a nearby thread, but the online documentation
and man pages also deny that.