Switch pg_verify_checksums back to a blacklist
This basically reverts commit d55241af705667d4503638e3f77d3689fd6be31, leaving around a portion of the regression tests still adapted with empty relation files, and corrupted cases. This is also proving to be failing to check properly relation files located in a non-default tablespace path. Per discussion with various folks, including Stephen Frost, David Steele, Andres Freund, Michael Banck and myself. Reported-by: Michael Banck Discussion: https://postgr.es/m/20181021134206.GA14282@paquier.xyz Backpatch-through: 11
This commit is contained in:
parent
d328991578
commit
a1c91dd110
src/bin/pg_verify_checksums
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#include "catalog/pg_control.h"
|
#include "catalog/pg_control.h"
|
||||||
#include "common/controldata_utils.h"
|
#include "common/controldata_utils.h"
|
||||||
#include "common/relpath.h"
|
|
||||||
#include "getopt_long.h"
|
#include "getopt_long.h"
|
||||||
#include "pg_getopt.h"
|
#include "pg_getopt.h"
|
||||||
#include "storage/bufpage.h"
|
#include "storage/bufpage.h"
|
||||||
@ -50,69 +49,27 @@ usage(void)
|
|||||||
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
|
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static const char *const skip[] = {
|
||||||
* isRelFileName
|
"pg_control",
|
||||||
*
|
"pg_filenode.map",
|
||||||
* Check if the given file name is authorized for checksum verification.
|
"pg_internal.init",
|
||||||
*/
|
"PG_VERSION",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
isRelFileName(const char *fn)
|
skipfile(const char *fn)
|
||||||
{
|
{
|
||||||
int pos;
|
const char *const *f;
|
||||||
|
|
||||||
/*----------
|
if (strcmp(fn, ".") == 0 ||
|
||||||
* Only files including data checksums are authorized for verification.
|
strcmp(fn, "..") == 0)
|
||||||
* This is guessed based on the file name by reverse-engineering
|
|
||||||
* GetRelationPath() so make sure to update both code paths if any
|
|
||||||
* updates are done. The following file name formats are allowed:
|
|
||||||
* <digits>
|
|
||||||
* <digits>.<segment>
|
|
||||||
* <digits>_<forkname>
|
|
||||||
* <digits>_<forkname>.<segment>
|
|
||||||
*
|
|
||||||
* Note that temporary files, beginning with 't', are also skipped.
|
|
||||||
*
|
|
||||||
*----------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* A non-empty string of digits should follow */
|
|
||||||
for (pos = 0; isdigit((unsigned char) fn[pos]); ++pos)
|
|
||||||
;
|
|
||||||
/* leave if no digits */
|
|
||||||
if (pos == 0)
|
|
||||||
return false;
|
|
||||||
/* good to go if only digits */
|
|
||||||
if (fn[pos] == '\0')
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* Authorized fork files can be scanned */
|
for (f = skip; *f; f++)
|
||||||
if (fn[pos] == '_')
|
if (strcmp(*f, fn) == 0)
|
||||||
{
|
return true;
|
||||||
int forkchar = forkname_chars(&fn[pos + 1], NULL);
|
return false;
|
||||||
|
|
||||||
if (forkchar <= 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
pos += forkchar + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for an optional segment number */
|
|
||||||
if (fn[pos] == '.')
|
|
||||||
{
|
|
||||||
int segchar;
|
|
||||||
|
|
||||||
for (segchar = 1; isdigit((unsigned char) fn[pos + segchar]); ++segchar)
|
|
||||||
;
|
|
||||||
|
|
||||||
if (segchar <= 1)
|
|
||||||
return false;
|
|
||||||
pos += segchar;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now this should be the end */
|
|
||||||
if (fn[pos] != '\0')
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -189,7 +146,7 @@ scan_directory(const char *basedir, const char *subdir)
|
|||||||
char fn[MAXPGPATH];
|
char fn[MAXPGPATH];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (!isRelFileName(de->d_name))
|
if (skipfile(de->d_name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
snprintf(fn, sizeof(fn), "%s/%s", path, de->d_name);
|
snprintf(fn, sizeof(fn), "%s/%s", path, de->d_name);
|
||||||
|
@ -17,23 +17,6 @@ command_like(['pg_controldata', $pgdata],
|
|||||||
qr/Data page checksum version:.*1/,
|
qr/Data page checksum version:.*1/,
|
||||||
'checksums enabled in control file');
|
'checksums enabled in control file');
|
||||||
|
|
||||||
# Add set of dummy files with some contents. These should not be scanned
|
|
||||||
# by the tool.
|
|
||||||
|
|
||||||
# On Windows, file name "foo." == "foo", so skip that pattern there.
|
|
||||||
append_to_file "$pgdata/global/123.", "foo" unless $windows_os;
|
|
||||||
append_to_file "$pgdata/global/123_", "foo";
|
|
||||||
append_to_file "$pgdata/global/123_.", "foo" unless $windows_os;;
|
|
||||||
append_to_file "$pgdata/global/123.12t", "foo";
|
|
||||||
append_to_file "$pgdata/global/foo", "foo2";
|
|
||||||
append_to_file "$pgdata/global/t123", "bar";
|
|
||||||
append_to_file "$pgdata/global/123a", "bar2";
|
|
||||||
append_to_file "$pgdata/global/.123", "foobar";
|
|
||||||
append_to_file "$pgdata/global/_fsm", "foobar2";
|
|
||||||
append_to_file "$pgdata/global/_init", "foobar3";
|
|
||||||
append_to_file "$pgdata/global/_vm.123", "foohoge";
|
|
||||||
append_to_file "$pgdata/global/123_vm.123t", "foohoge2";
|
|
||||||
|
|
||||||
# These are correct but empty files, so they should pass through.
|
# These are correct but empty files, so they should pass through.
|
||||||
append_to_file "$pgdata/global/99999", "";
|
append_to_file "$pgdata/global/99999", "";
|
||||||
append_to_file "$pgdata/global/99999.123", "";
|
append_to_file "$pgdata/global/99999.123", "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user