Re: Remove trailing newlines from pg_upgrade's messages

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2022-07-12T19:45:43Z
Lists: pgsql-hackers
Kyotaro Horiguchi <horikyota.ntt@gmail.com> writes:
> FWIW, the following change makes sense to me according to the spec of
> validate_exec()...

> diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
> index fadeea12ca..3cff186213 100644
> --- a/src/bin/pg_upgrade/exec.c
> +++ b/src/bin/pg_upgrade/exec.c
> @@ -430,10 +430,10 @@ check_exec(const char *dir, const char *program, bool check_version)
>  	ret = validate_exec(path);
 
>  	if (ret == -1)
> -		pg_fatal("check for \"%s\" failed: not a regular file\n",
> +		pg_fatal("check for \"%s\" failed: does not exist or inexecutable\n",
>  				 path);
>  	else if (ret == -2)
> -		pg_fatal("check for \"%s\" failed: cannot execute (permission denied)\n",
> +		pg_fatal("check for \"%s\" failed: cannot read (permission denied)\n",
>  				 path);
 
>  	snprintf(cmd, sizeof(cmd), "\"%s\" -V", path);

I initially did this, but then I wondered why validate_exec() was
making it so hard: why can't we just report the failure with %m?
It turns out to take only a couple extra lines of code to ensure
that something more-or-less appropriate is returned, so we don't
need to guess about it here.  Pushed that way.

			regards, tom lane



Commits

  1. Improve error reporting from validate_exec().

  2. Remove trailing newlines in pg_upgrade's message strings.