Re: Tighten up a few overly lax regexes in pg_dump's tap tests
Daniel Gustafsson <daniel@yesql.se>
From: Daniel Gustafsson <daniel@yesql.se>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: David Rowley <david.rowley@2ndquadrant.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-02-05T10:09:42Z
Lists: pgsql-hackers
> On 5 Feb 2019, at 06:55, David G. Johnston <david.g.johnston@gmail.com> wrote:
>
> On Monday, February 4, 2019, David Rowley <david.rowley@2ndquadrant.com <mailto:david.rowley@2ndquadrant.com>> wrote:
> On Tue, 5 Feb 2019 at 01:12, Daniel Gustafsson <daniel@yesql.se <mailto:daniel@yesql.se>> wrote:
> > We may also want to use the + metacharacter instead of * in a few places, since
> > the intent is to always match something, where matching nothing should be
> > considered an error:
> >
> > - qr/^ALTER TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 OWNER TO .*;/m,
> > + qr/^ALTER TEXT SEARCH DICTIONARY dump_test\.alt_ts_dict1 OWNER TO .*;/m,
>
> I looked for instances of * alone and didn't see any. I only saw ones
> prefixed with ".", in which case, isn't that matching 1 or more chars
> already?
>
> No. In Regex the following are equivalent:
>
> .* == .{0,}
> .+ == .{1,}
> . == .{1}
>
> A “*” by itself would either be an error or, assuming the preceding character is a space (so it visually looks alone) would be zero or more consecutive spaces.
Sorry for being a bit unclear in my original email, it’s as David says above:
.* matches zero or more characters and .+ matches 1 or more characters.
> In the above “...OWNER TO<space>;” is a valid match.
Indeed, so we should move to matching with .+ to force an owner.
cheers ./daniel
Commits
-
Align better test output regex with grammar in pg_dump TAP tests
- f339a998ffe6 12.0 landed
-
Tighten some regexes with proper character escaping in pg_dump TAP tests
- d07fb6810e51 12.0 landed