Small fixes for incorrect error messages

Started by zengmanabout 1 month ago8 messages
Jump to latest
#1zengman
zengman@halodbtech.com

Hi all,

I found a few easily overlooked error messages worth fixing, as follows:

01
```
 	if (!is_absolute_path(tsmap->new_dir))
-		pg_fatal("old directory is not an absolute path in tablespace mapping: %s",
+		pg_fatal("new directory is not an absolute path in tablespace mapping: %s",
 				 tsmap->new_dir);
```
02
```
 	if (rb < 0)
-		pg_fatal("could not read from file \"%s\": %m", dst);
+		pg_fatal("could not read from file \"%s\": %m", src);
```
03
```
 	if (fstat(fd, &statbuf) < 0)
-		pg_fatal("could not open file \"%s\" for reading: %m",
+		pg_fatal("could not stat file \"%s\" for reading: %m",
 				 fullpath);
```

--
regards,
Man Zeng

Attachments:

0001-Fix-error-message-for-non-absolute-new-directory-in-.patchapplication/octet-stream; charset=ISO-8859-1; name=0001-Fix-error-message-for-non-absolute-new-directory-in-.patchDownload+1-2
0002-Fix-error-message-in-copy_file_blocks-to-reference-s.patchapplication/octet-stream; charset=ISO-8859-1; name=0002-Fix-error-message-in-copy_file_blocks-to-reference-s.patchDownload+1-2
0003-Fix-error-message-in-slurpFile-to-clarify-file-statu.patchapplication/octet-stream; charset=ISO-8859-1; name=0003-Fix-error-message-in-slurpFile-to-clarify-file-statu.patchDownload+1-2
#2Michael Paquier
michael@paquier.xyz
In reply to: zengman (#1)
Re: Small fixes for incorrect error messages

On Thu, Feb 05, 2026 at 02:51:05PM +0800, zengman wrote:

I found a few easily overlooked error messages worth fixing, as follows:

Good catches. Obviously a copy-pasto for the first and third ones,
and a thinko for the second one.
--
Michael

#3Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#2)
Re: Small fixes for incorrect error messages

On Thu, Feb 05, 2026 at 07:28:00PM +0900, Michael Paquier wrote:

Good catches. Obviously a copy-pasto for the first and third ones,
and a thinko for the second one.

Fixed these ones.
--
Michael

#4zengman
zengman@halodbtech.com
In reply to: Michael Paquier (#3)
Re: Small fixes for incorrect error messages

Fixed these ones.

Thanks a lot for your help with this! I previously reported another similar issue – could you please take a moment to look at it? Maybe we could fix it along the way.

/messages/by-id/tencent_6D253E6F517F8F85796F0D9D@qq.com

--
regards,
Man Zeng

#5Peter Eisentraut
peter_e@gmx.net
In reply to: zengman (#1)
Re: Small fixes for incorrect error messages

On 05.02.26 07:51, zengman wrote:

```
if (fstat(fd, &statbuf) < 0)
-		pg_fatal("could not open file \"%s\" for reading: %m",
+		pg_fatal("could not stat file \"%s\" for reading: %m",
fullpath);
```

It doesn't make sense to "stat a file for reading". The changed message
should probably just be

Show quoted text

+ pg_fatal("could not stat file \"%s\": %m",
fullpath);

#6zengman
zengman@halodbtech.com
In reply to: Peter Eisentraut (#5)
Re: Small fixes for incorrect error messages

It doesn't make sense to "stat a file for reading". The changed message
should probably just be
+ pg_fatal("could not stat file \"%s\": %m",
fullpath);

You're right. I was careless earlier, my apologies.

--
regards,
Man Zeng

#7Peter Eisentraut
peter_e@gmx.net
In reply to: zengman (#6)
Re: Small fixes for incorrect error messages

On 07.02.26 10:24, zengman wrote:

It doesn't make sense to "stat a file for reading". The changed message
should probably just be
+ pg_fatal("could not stat file \"%s\": %m",
fullpath);

You're right. I was careless earlier, my apologies.

Ok, I have fixed this.

#8Michael Paquier
michael@paquier.xyz
In reply to: Peter Eisentraut (#7)
Re: Small fixes for incorrect error messages

On Sat, Feb 07, 2026 at 11:03:36PM +0100, Peter Eisentraut wrote:

On 07.02.26 10:24, zengman wrote:

You're right. I was careless earlier, my apologies.

Ok, I have fixed this.

Thanks for the fix. (I was away from my laptop.)
--
Michael