Re: pgsql: Add TAP tests for pg_verify_checksums
Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
From: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Michael Banck <michael.banck@credativ.de>,
Andres Freund <andres@anarazel.de>,
Postgres hackers <pgsql-hackers@postgresql.org>,
Daniel Gustafsson <daniel@yesql.se>, Magnus Hagander <magnus@hagander.net>
Date: 2018-10-14T14:24:55Z
Lists: pgsql-hackers
On 10/13/2018 09:59 PM, Michael Paquier wrote:
> On Sat, Oct 13, 2018 at 05:53:00PM -0400, Andrew Dunstan wrote:
>> It occurred to me that a pretty simple fix could just be to blacklist
>> everything that didn't start with a digit. The whitelist approach is
>> probably preferable... depends how urgent we see this as.
> Yeah, possibly, still that's not a correct long-term fix. So attached
> is what I think we should do for HEAD and REL_11_STABLE with an approach
> using a whitelist. I have added positive and negative tests on top of
> the existing TAP tests, as suggested by Michael B, and I made the code
> use relpath.h to make sure that we don't miss any fork types.
>
> Any objections to this patch?
This code now seems redundant:
if (strcmp(fn, ".") == 0 ||
strcmp(fn, "..") == 0)
return true;
I would probably reverse the order of these two tests. It might not make
any difference, assuming fn is never an empty string, but it seems more
logical to me.
+ /* good to go if only digits */
+ if (fn[pos] == '\0')
+ return false;
+ /* leave if no digits */
+ if (pos == 0)
+ return true;
It also looks to me like the check for a segment number doesn't ensure there is at least one digit, so "123." might pass, but I could be wrong. In any case, there isn't a test for that, and there probably should be.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Fix issues with TAP tests of pg_verify_checksums
- 9685d7383ab4 12.0 landed
-
Use whitelist to choose files scanned with pg_verify_checksums
- cc7f27eae888 11.1 landed
- d55241af7056 12.0 landed
-
Add TAP tests for pg_verify_checksums
- b34e84f160a4 12.0 cited
-
Work around Msys weakness in Testlib.pm's command_like()
- efd7f8e36553 10.0 cited