Skip to content

Commit 97ee956

Browse files
committed
Fix version comparison in Version.pm
Version strings with unequal numbers of parts were being compared incorrectly. We cure this by treating a missing part in the shorter version as 0. per complaint from Jehan-Guillaume de Rorthais, but the fix is mine, not his. Discussion: https://postgr.es/m/20220628225325.53d97b8d@karst Backpatch to release 14 where this code was introduced.
1 parent 83eccb8 commit 97ee956

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/test/perl/PostgreSQL/Version.pm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,12 @@ sub _version_cmp
123123

124124
for (my $idx = 0;; $idx++)
125125
{
126-
return 0 unless (defined $an->[$idx] && defined $bn->[$idx]);
127-
return $an->[$idx] <=> $bn->[$idx]
128-
if ($an->[$idx] <=> $bn->[$idx]);
126+
return 0
127+
if ($idx >= @$an && $idx >= @$bn);
128+
# treat a missing number as 0
129+
my ($anum, $bnum) = ($an->[$idx] || 0, $bn->[$idx] || 0);
130+
return $anum <=> $bnum
131+
if ($anum <=> $bnum);
129132
}
130133
}
131134

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy