Re: multi-install PostgresNode fails with older postgres versions

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: multi-install PostgresNode fails with older postgres versions
Date: 2021-04-22 15:09:54
Message-ID: 20210422150954.GA9206@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021-Apr-21, Andrew Dunstan wrote:

> +=head1 DESCRIPTION
> +
> +PostgresVersion encapsulated Postgres version numbers, providing parsing
> +of common version formats and comparison operations.

Small typo here: should be "encapsulates"

> + # Accept standard formats, in case caller has handed us the output of a
> + # postgres command line tool
> + $arg = $1
> + if ($arg =~ m/\(?PostgreSQL\)? (\d+(?:\.\d+)*(?:devel)?)/);
> +
> + # Split into an array
> + my @result = split(/\./, $arg);
> +
> + # Treat development versions as having a minor/micro version one less than
> + # the first released version of that branch.
> + if ($result[$#result] =~ m/^(\d+)devel$/)
> + {
> + pop(@result);
> + push(@result, $1, -1);
> + }

It's a bit weird to parse the "devel" bit twice. Would it work to leave
(?:devel)? out of the capturing parens that becomes $1 in the first
regex and make it capturing itself, so you get "devel" in $2, and decide
based on its presence/absence? Then you don't have to pop and push a -1.

> + my $res = [ @result ];

Hmm, isn't this just \(at)result? So you could do
return bless \(at)result, $class;

--
Álvaro Herrera 39°49'30"S 73°17'W

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2021-04-22 15:13:20 Re: multi-install PostgresNode fails with older postgres versions
Previous Message Zhihong Yu 2021-04-22 14:41:06 Re: TRUNCATE on foreign table