Subject: Fix the error message when failing to restore the snapshot

From: "Zhijie Hou (Fujitsu)" <[email-masked]>
Date: Tue, 22 Aug 2023 12:39:09 +0000

Hi,

While testing the logical snapshot restore functionality, I noticed the
data size reported in the error message seems not correct.

I think it's because we used a const value here:

SnapBuildRestoreContents(int fd, char *dest, Size size, const char *path)
...
	readBytes = read(fd, dest, size);
	pgstat_report_wait_end();
	if (readBytes != size)
...
			ereport(ERROR,
					(errcode(ERRCODE_DATA_CORRUPTED),
					 errmsg("could not read file \"%s\": read %d of %zu",
**							path, readBytes, * sizeof(SnapBuild) *)));

I think we need to pass the size here.

Attach a small patch to fix this. BTW, the error message exists in HEAD ~ PG10.

Best Regards,
Hou zj

---

From: Amit Kapila <[email-masked]>
Date: Tue, 22 Aug 2023 18:37:44 +0530

> I think we need to pass the size here.

Good catch. I'll take care of this.

-- 
With Regards,
Amit Kapila.