@@ -237,7 +237,7 @@ read_page_from_file(pgFile *file, BlockNumber blknum,
237237 {
238238 int i ;
239239 /* Check if the page is zeroed. */
240- for (i = 0 ; i < BLCKSZ && page [i ] == 0 ; i ++ );
240+ for (i = 0 ; i < BLCKSZ && page [i ] == 0 ; i ++ );
241241
242242 /* Page is zeroed. No need to check header and checksum. */
243243 if (i == BLCKSZ )
@@ -271,9 +271,10 @@ read_page_from_file(pgFile *file, BlockNumber blknum,
271271 * should be a pointer to allocated BLCKSZ of bytes.
272272 *
273273 * Prints appropriate warnings/errors/etc into log.
274- * Returns 0 if page was successfully retrieved
275- * SkipCurrentPage(-3) if we need to skip this page
274+ * Returns:
275+ * PageIsOk(0) if page was successfully retrieved
276276 * PageIsTruncated(-2) if the page was truncated
277+ * SkipCurrentPage(-3) if we need to skip this page
277278 * PageIsCorrupted(-4) if the page check mismatch
278279 */
279280static int32
@@ -312,9 +313,8 @@ prepare_page(ConnectionArgs *conn_arg,
312313 switch (result )
313314 {
314315 case 2 :
315- page_is_valid = true;
316316 elog (VERBOSE , "File: \"%s\" blknum %u, empty page" , from_fullpath , blknum );
317- break ;
317+ return PageIsOk ;
318318
319319 case 1 :
320320 page_is_valid = true;
@@ -393,6 +393,12 @@ prepare_page(ConnectionArgs *conn_arg,
393393 }
394394 }
395395
396+ /* Get page via ptrack interface from PostgreSQL shared buffer.
397+ * We do this in following cases:
398+ * 1. PTRACK backup of 1.x versions
399+ * 2. During backup, regardless of backup mode, of PostgreSQL instance
400+ * with ptrack support we encountered invalid page.
401+ */
396402 if ((backup_mode == BACKUP_MODE_DIFF_PTRACK
397403 && (ptrack_version_num >= 15 && ptrack_version_num < 20 ))
398404 || !page_is_valid )
@@ -434,7 +440,6 @@ prepare_page(ConnectionArgs *conn_arg,
434440 !parse_page (page , & page_lsn ))
435441 elog (ERROR , "Cannot parse page after pg_ptrack_get_block. "
436442 "Possible risk of a memory corruption" );
437-
438443 }
439444
440445 if (page_is_truncated )
@@ -1260,22 +1265,18 @@ create_empty_file(fio_location from_location, const char *to_root,
12601265 /* open file for write */
12611266 join_path_components (to_path , to_root , file -> rel_path );
12621267 out = fio_fopen (to_path , PG_BINARY_W , to_location );
1268+
12631269 if (out == NULL )
1264- {
1265- elog (ERROR , "cannot open destination file \"%s\": %s" ,
1270+ elog (ERROR , "Cannot open destination file \"%s\": %s" ,
12661271 to_path , strerror (errno ));
1267- }
12681272
12691273 /* update file permission */
12701274 if (fio_chmod (to_path , file -> mode , to_location ) == -1 )
1271- {
1272- fio_fclose (out );
1273- elog (ERROR , "cannot change mode of \"%s\": %s" , to_path ,
1275+ elog (ERROR , "Cannot change mode of \"%s\": %s" , to_path ,
12741276 strerror (errno ));
1275- }
12761277
12771278 if (fio_fclose (out ))
1278- elog (ERROR , "cannot close \"%s\": %s" , to_path , strerror (errno ));
1279+ elog (ERROR , "Cannot close \"%s\": %s" , to_path , strerror (errno ));
12791280
12801281 return true;
12811282}
0 commit comments