[PATCH] Using named captures in Catalog::ParseHeader()

Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>

From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Peter Eisentraut <peter@eisentraut.org>
Date: 2023-06-01T12:12:22Z
Lists: pgsql-hackers

Attachments

Hi Hackers,

Peter's patch set for autogenerating syscache info
(https://postgr.es/m/75ae5875-3abc-dafc-8aec-73247ed41cde%40eisentraut.org)
touched on one of my least favourite parts of Catalog.pm: the
parenthesis-counting nightmare that is the parsing of catalog header
directives.

However, now that we require Perl 5.14, we can use the named capture
feature (introduced in Perl 5.10) to make that a lot clearer, as in the
attached patch.

While I was rewriting the regexes I noticed that they were inconsistent
about whether they accepted whitespace in the parameter lists, so I took
the liberty to make them consistently allow whitespace after the opening
paren and the commas, which is what most of them already did.

I've verified that the generated postgres.bki is identical to before,
and all tests pass.

- ilmari

Commits

  1. Use named captures in Catalog::ParseHeader()