Fix the error message when failing to restore the snapshot.
authorAmit Kapila <[email protected]>
Thu, 24 Aug 2023 09:07:29 +0000 (14:37 +0530)
committerAmit Kapila <[email protected]>
Thu, 24 Aug 2023 09:07:29 +0000 (14:37 +0530)
The SnapBuildRestoreContents() used a const value in the error message to
indicate the size in bytes it was expecting to read from the serialized
snapshot file. Fix it by reporting the size that was actually passed.

Author: Hou Zhijie
Reviewed-by: Amit Kapila
Back-through: 16
Discussion: http://postgr.es/m/OS0PR01MB5716D408364F7DF32221C08D941FA@OS0PR01MB5716.jpnprd01.prod.outlook.com

src/backend/replication/logical/snapbuild.c

index 843ceba840bb8d4339a67b8c8f55592d32f92a3c..fec190a8b2f7086b3854bb6216e419ada64f695b 100644 (file)
@@ -2039,7 +2039,7 @@ SnapBuildRestoreContents(int fd, char *dest, Size size, const char *path)
            ereport(ERROR,
                    (errcode(ERRCODE_DATA_CORRUPTED),
                     errmsg("could not read file \"%s\": read %d of %zu",
-                           path, readBytes, sizeof(SnapBuild))));
+                           path, readBytes, size)));
    }
 }