Fix some issues in pg_rewind.
* Remove invalid option character "N" from the third argument (valid option string) of getopt_long(). * Use pg_free() or pfree() to free the memory allocated by pg_malloc() or palloc() instead of always using free(). * Assume problem is no disk space if write() fails but doesn't set errno. * Fix several typos. Patch by me. Review by Michael Paquier.
This commit is contained in:
parent
aacb8b9277
commit
966c37fdb5
@ -43,7 +43,7 @@ traverse_datadir(const char *datadir, process_file_callback_t callback)
|
||||
/*
|
||||
* recursive part of traverse_datadir
|
||||
*
|
||||
* parent_path is the current subdirectory's path relative to datadir,
|
||||
* parentpath is the current subdirectory's path relative to datadir,
|
||||
* or NULL at the top level.
|
||||
*/
|
||||
static void
|
||||
@ -262,5 +262,5 @@ execute_pagemap(datapagemap_t *pagemap, const char *path)
|
||||
copy_file_range(path, offset, offset + BLCKSZ, false);
|
||||
/* Ok, this block has now been copied from new data dir to old */
|
||||
}
|
||||
free(iter);
|
||||
pg_free(iter);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ datapagemap_add(datapagemap_t *map, BlockNumber blkno)
|
||||
* Start iterating through all entries in the page map.
|
||||
*
|
||||
* After datapagemap_iterate, call datapagemap_next to return the entries,
|
||||
* until it returns NULL. After you're done, use free() to destroy the
|
||||
* until it returns false. After you're done, use pg_free() to destroy the
|
||||
* iterator.
|
||||
*/
|
||||
datapagemap_iterator_t *
|
||||
@ -122,5 +122,5 @@ datapagemap_print(datapagemap_t *map)
|
||||
while (datapagemap_next(iter, &blocknum))
|
||||
printf(" blk %u\n", blocknum);
|
||||
|
||||
free(iter);
|
||||
pg_free(iter);
|
||||
}
|
||||
|
@ -105,10 +105,16 @@ write_target_range(char *buf, off_t begin, size_t size)
|
||||
{
|
||||
int writelen;
|
||||
|
||||
errno = 0;
|
||||
writelen = write(dstfd, p, writeleft);
|
||||
if (writelen < 0)
|
||||
{
|
||||
/* if write didn't set errno, assume problem is no disk space */
|
||||
if (errno == 0)
|
||||
errno = ENOSPC;
|
||||
pg_fatal("could not write file \"%s\": %s\n",
|
||||
dstpath, strerror(errno));
|
||||
}
|
||||
|
||||
p += writelen;
|
||||
writeleft -= writelen;
|
||||
|
@ -114,7 +114,7 @@ process_source_file(const char *path, file_type_t type, size_t newsize,
|
||||
case FILE_TYPE_DIRECTORY:
|
||||
if (exists && !S_ISDIR(statbuf.st_mode))
|
||||
{
|
||||
/* it's a directory in target, but not in source. Strange.. */
|
||||
/* it's a directory in source, but not in target. Strange.. */
|
||||
pg_fatal("\"%s\" is not a directory\n", localpath);
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ process_source_file(const char *path, file_type_t type, size_t newsize,
|
||||
)
|
||||
{
|
||||
/*
|
||||
* It's a symbolic link in target, but not in source.
|
||||
* It's a symbolic link in source, but not in target.
|
||||
* Strange..
|
||||
*/
|
||||
pg_fatal("\"%s\" is not a symbolic link\n", localpath);
|
||||
@ -354,7 +354,7 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
|
||||
entry = *e;
|
||||
else
|
||||
entry = NULL;
|
||||
free(path);
|
||||
pfree(path);
|
||||
|
||||
if (entry)
|
||||
{
|
||||
@ -530,7 +530,7 @@ print_filemap(void)
|
||||
* Does it look like a relation data file?
|
||||
*
|
||||
* For our purposes, only files belonging to the main fork are considered
|
||||
* relation files. Other forks are alwayes copied in toto, because we cannot
|
||||
* relation files. Other forks are always copied in toto, because we cannot
|
||||
* reliably track changes to them, because WAL only contains block references
|
||||
* for the main fork.
|
||||
*/
|
||||
|
@ -69,7 +69,7 @@ libpqConnect(const char *connstr)
|
||||
pg_free(str);
|
||||
|
||||
/*
|
||||
* Also check that full_page-writes are enabled. We can get torn pages if
|
||||
* Also check that full_page_writes is enabled. We can get torn pages if
|
||||
* a page is modified while we read it with pg_read_binary_file(), and we
|
||||
* rely on full page images to fix them.
|
||||
*/
|
||||
@ -465,5 +465,5 @@ execute_pagemap(datapagemap_t *pagemap, const char *path)
|
||||
|
||||
fetch_file_range(path, offset, offset + BLCKSZ);
|
||||
}
|
||||
free(iter);
|
||||
pg_free(iter);
|
||||
}
|
||||
|
@ -32,4 +32,4 @@ extern void pg_fatal(const char *fmt,...) pg_attribute_printf(1, 2) pg_attribute
|
||||
|
||||
extern void progress_report(bool force);
|
||||
|
||||
#endif
|
||||
#endif /* PG_REWIND_LOGGING_H */
|
||||
|
@ -121,7 +121,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
while ((c = getopt_long(argc, argv, "D:NnP", long_options, &option_index)) != -1)
|
||||
while ((c = getopt_long(argc, argv, "D:nP", long_options, &option_index)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
@ -370,7 +370,7 @@ sanityChecks(void)
|
||||
if (ControlFile_target.data_checksum_version != PG_DATA_CHECKSUM_VERSION &&
|
||||
!ControlFile_target.wal_log_hints)
|
||||
{
|
||||
pg_fatal("target server need to use either data checksums or \"wal_log_hints = on\"\n");
|
||||
pg_fatal("target server needs to use either data checksums or \"wal_log_hints = on\"\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -450,7 +450,7 @@ findCommonAncestorTimeline(XLogRecPtr *recptr, TimeLineID *tli)
|
||||
*recptr = entry->end;
|
||||
*tli = entry->tli;
|
||||
|
||||
free(sourceHistory);
|
||||
pg_free(sourceHistory);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user