Re: multi-install PostgresNode fails with older postgres versions - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: multi-install PostgresNode fails with older postgres versions
Date
Msg-id 8e693422-e113-e545-8cae-cd69c9e16120@dunslane.net
Whole thread Raw
In response to Re: multi-install PostgresNode fails with older postgres versions  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: multi-install PostgresNode fails with older postgres versions
List pgsql-hackers
On 4/22/21 11:09 AM, Alvaro Herrera wrote:
> 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.


How about this?


        # Accept standard formats, in case caller has handed us the
    output of a
        # postgres command line tool
        my $devel;
        ($arg,$devel) = ($1, $2)
          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.
        push @result, -1 if ($devel);

        return bless \@result, $class;


cheers


andrew






-- 

Andrew Dunstan
EDB: https://www.enterprisedb.com




pgsql-hackers by date:

Previous
From: Andy Fan
Date:
Subject: Re: Converting NOT IN to anti-joins during planning
Next
From: Robert Haas
Date:
Subject: Re: decoupling table and index vacuum