diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2021-04-24 09:37:20 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2021-04-24 09:37:20 -0400 |
commit | aa271209f6d995488fc5cba9731415f974823990 (patch) | |
tree | 04bdcf99645acdd527d488cad1be91012da051fa /src/test/perl/PostgresVersion.pm | |
parent | 9b5558e7ad4706bbd53947e5b4d7c06e150390a5 (diff) | |
download | postgresql-aa271209f6d995488fc5cba9731415f974823990.tar.gz postgresql-aa271209f6d995488fc5cba9731415f974823990.zip |
Teach PostgresVersion all the ways to mark non-release code
As well as 'devel' version_stamp.pl provides for 'alphaN'
'betaN' and 'rcN', so teach PostgresVersion about those.
Also stash the version string instead of trying to reconstruct it during
stringification.
Discussion: https://postgr.es/m/YIHlw5nSgAHs4dK1@paquier.xyz
Diffstat (limited to 'src/test/perl/PostgresVersion.pm')
-rw-r--r-- | src/test/perl/PostgresVersion.pm | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/test/perl/PostgresVersion.pm b/src/test/perl/PostgresVersion.pm index 3f3744ccfa9..7ce9e62b798 100644 --- a/src/test/perl/PostgresVersion.pm +++ b/src/test/perl/PostgresVersion.pm @@ -79,18 +79,24 @@ sub new # postgres command line tool my $devel; ($arg,$devel) = ($1, $2) - if ($arg =~ m/^(?:\(?PostgreSQL\)? )?(\d+(?:\.\d+)*)(devel)?/); + if ($arg =~ + m!^ # beginning of line + (?:\(?PostgreSQL\)?\s)? # ignore PostgreSQL marker + (\d+(?:\.\d+)*) # version number, dotted notation + (devel|(?:alpha|beta|rc)\d+)? # dev marker - see version_stamp.pl + !x); # Split into an array - my @result = split(/\./, $arg); + my @numbers = 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); + push @numbers, -1 if ($devel); - return bless \@result, $class; -} + $devel ||= ""; + return bless { str => "$arg$devel", num => \@numbers }, $class; +} # Routine which compares the _pg_version_array obtained for the two # arguments and returns -1, 0, or 1, allowing comparison between two @@ -108,27 +114,21 @@ sub _version_cmp $b = __PACKAGE__->new($b) unless blessed($b); + my ($an, $bn) = ($a->{num}, $b->{num}); + for (my $idx = 0;; $idx++) { - return 0 unless (defined $a->[$idx] && defined $b->[$idx]); - return $a->[$idx] <=> $b->[$idx] - if ($a->[$idx] <=> $b->[$idx]); + return 0 unless (defined $an->[$idx] && defined $bn->[$idx]); + return $an->[$idx] <=> $bn->[$idx] + if ($an->[$idx] <=> $bn->[$idx]); } } -# Render the version number in the standard "joined by dots" notation if -# interpolated into a string. Put back 'devel' if we previously turned it -# into a -1. +# Render the version number using the saved string. sub _stringify { my $self = shift; - my @sections = @$self; - if ($sections[-1] == -1) - { - pop @sections; - $sections[-1] = "$sections[-1]devel"; - } - return join('.', @sections); + return $self->{str}; } 1; |