Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit038512f

Browse files
committed
Fix version comparison in Version.pm
Version strings with unequal numbers of parts were being comparedincorrectly. We cure this by treating a missing part in the shorterversion as 0.per complaint from Jehan-Guillaume de Rorthais, but the fix is mine, nothis.Discussion:https://postgr.es/m/20220628225325.53d97b8d@karstBackpatch to release 14 where this code was introduced.
1 parent32d5a49 commit038512f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

‎src/test/perl/PostgresVersion.pm

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

121121
for (my$idx = 0;;$idx++)
122122
{
123-
return 0unless (defined$an->[$idx] &&defined$bn->[$idx]);
124-
return$an->[$idx]<=>$bn->[$idx]
125-
if ($an->[$idx]<=>$bn->[$idx]);
123+
return 0
124+
if ($idx >=@$an &&$idx >=@$bn);
125+
# treat a missing number as 0
126+
my ($anum,$bnum) = ($an->[$idx] || 0,$bn->[$idx] || 0);
127+
return$anum<=>$bnum
128+
if ($anum<=>$bnum);
126129
}
127130
}
128131

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp