Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1c91dd

Browse files
committed
Switch pg_verify_checksums back to a blacklist
This basically reverts commitd55241a,leaving around a portion of the regression tests still adapted withempty relation files, and corrupted cases. This is also proving to befailing to check properly relation files located in a non-defaulttablespace path.Per discussion with various folks, including Stephen Frost, DavidSteele, Andres Freund, Michael Banck and myself.Reported-by: Michael BanckDiscussion:https://postgr.es/m/20181021134206.GA14282@paquier.xyzBackpatch-through: 11
1 parentd328991 commita1c91dd

File tree

2 files changed

+18
-78
lines changed

2 files changed

+18
-78
lines changed

‎src/bin/pg_verify_checksums/pg_verify_checksums.c

Lines changed: 18 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include"catalog/pg_control.h"
1717
#include"common/controldata_utils.h"
18-
#include"common/relpath.h"
1918
#include"getopt_long.h"
2019
#include"pg_getopt.h"
2120
#include"storage/bufpage.h"
@@ -50,69 +49,27 @@ usage(void)
5049
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
5150
}
5251

53-
/*
54-
* isRelFileName
55-
*
56-
* Check if the given file name is authorized for checksum verification.
57-
*/
52+
staticconstchar*constskip[]= {
53+
"pg_control",
54+
"pg_filenode.map",
55+
"pg_internal.init",
56+
"PG_VERSION",
57+
NULL,
58+
};
59+
5860
staticbool
59-
isRelFileName(constchar*fn)
61+
skipfile(constchar*fn)
6062
{
61-
intpos;
62-
63-
/*----------
64-
* Only files including data checksums are authorized for verification.
65-
* This is guessed based on the file name by reverse-engineering
66-
* GetRelationPath() so make sure to update both code paths if any
67-
* updates are done. The following file name formats are allowed:
68-
* <digits>
69-
* <digits>.<segment>
70-
* <digits>_<forkname>
71-
* <digits>_<forkname>.<segment>
72-
*
73-
* Note that temporary files, beginning with 't', are also skipped.
74-
*
75-
*----------
76-
*/
77-
78-
/* A non-empty string of digits should follow */
79-
for (pos=0;isdigit((unsignedchar)fn[pos]);++pos)
80-
;
81-
/* leave if no digits */
82-
if (pos==0)
83-
return false;
84-
/* good to go if only digits */
85-
if (fn[pos]=='\0')
86-
return true;
87-
88-
/* Authorized fork files can be scanned */
89-
if (fn[pos]=='_')
90-
{
91-
intforkchar=forkname_chars(&fn[pos+1],NULL);
92-
93-
if (forkchar <=0)
94-
return false;
63+
constchar*const*f;
9564

96-
pos+=forkchar+1;
97-
}
98-
99-
/* Check for an optional segment number */
100-
if (fn[pos]=='.')
101-
{
102-
intsegchar;
103-
104-
for (segchar=1;isdigit((unsignedchar)fn[pos+segchar]);++segchar)
105-
;
106-
107-
if (segchar <=1)
108-
return false;
109-
pos+=segchar;
110-
}
65+
if (strcmp(fn,".")==0||
66+
strcmp(fn,"..")==0)
67+
return true;
11168

112-
/* Now this should be the end */
113-
if (fn[pos]!='\0')
114-
returnfalse;
115-
returntrue;
69+
for (f=skip;*f;f++)
70+
if (strcmp(*f,fn)==0)
71+
returntrue;
72+
returnfalse;
11673
}
11774

11875
staticvoid
@@ -189,7 +146,7 @@ scan_directory(const char *basedir, const char *subdir)
189146
charfn[MAXPGPATH];
190147
structstatst;
191148

192-
if (!isRelFileName(de->d_name))
149+
if (skipfile(de->d_name))
193150
continue;
194151

195152
snprintf(fn,sizeof(fn),"%s/%s",path,de->d_name);

‎src/bin/pg_verify_checksums/t/002_actions.pl

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,6 @@
1717
qr/Data page checksum version:.*1/,
1818
'checksums enabled in control file');
1919

20-
# Add set of dummy files with some contents. These should not be scanned
21-
# by the tool.
22-
23-
# On Windows, file name "foo." == "foo", so skip that pattern there.
24-
append_to_file"$pgdata/global/123.","foo"unless$windows_os;
25-
append_to_file"$pgdata/global/123_","foo";
26-
append_to_file"$pgdata/global/123_.","foo"unless$windows_os;;
27-
append_to_file"$pgdata/global/123.12t","foo";
28-
append_to_file"$pgdata/global/foo","foo2";
29-
append_to_file"$pgdata/global/t123","bar";
30-
append_to_file"$pgdata/global/123a","bar2";
31-
append_to_file"$pgdata/global/.123","foobar";
32-
append_to_file"$pgdata/global/_fsm","foobar2";
33-
append_to_file"$pgdata/global/_init","foobar3";
34-
append_to_file"$pgdata/global/_vm.123","foohoge";
35-
append_to_file"$pgdata/global/123_vm.123t","foohoge2";
36-
3720
# These are correct but empty files, so they should pass through.
3821
append_to_file"$pgdata/global/99999","";
3922
append_to_file"$pgdata/global/99999.123","";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp