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

Commitaa27120

Browse files
committed
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 duringstringification.Discussion:https://postgr.es/m/YIHlw5nSgAHs4dK1@paquier.xyz
1 parent9b5558e commitaa27120

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

‎src/test/perl/PostgresVersion.pm

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,24 @@ sub new
7979
# postgres command line tool
8080
my$devel;
8181
($arg,$devel) = ($1,$2)
82-
if ($arg =~m/^(?:\(?PostgreSQL\)? )?(\d+(?:\.\d+)*)(devel)?/);
82+
if ($arg =~
83+
m!^ # beginning of line
84+
(?:\(?PostgreSQL\)?\s)? # ignore PostgreSQL marker
85+
(\d+(?:\.\d+)*) # version number, dotted notation
86+
(devel|(?:alpha|beta|rc)\d+)? # dev marker - see version_stamp.pl
87+
!x);
8388

8489
# Split into an array
85-
my@result =split(/\./,$arg);
90+
my@numbers =split(/\./,$arg);
8691

8792
# Treat development versions as having a minor/micro version one less than
8893
# the first released version of that branch.
89-
push@result, -1if ($devel);
94+
push@numbers, -1if ($devel);
9095

91-
returnbless \@result,$class;
92-
}
96+
$devel ||="";
9397

98+
returnbless {str=>"$arg$devel",num=> \@numbers },$class;
99+
}
94100

95101
# Routine which compares the _pg_version_array obtained for the two
96102
# arguments and returns -1, 0, or 1, allowing comparison between two
@@ -108,27 +114,21 @@ sub _version_cmp
108114

109115
$b =__PACKAGE__->new($b)unless blessed($b);
110116

117+
my ($an,$bn) = ($a->{num},$b->{num});
118+
111119
for (my$idx = 0;;$idx++)
112120
{
113-
return 0unless (defined$a->[$idx] &&defined$b->[$idx]);
114-
return$a->[$idx]<=>$b->[$idx]
115-
if ($a->[$idx]<=>$b->[$idx]);
121+
return 0unless (defined$an->[$idx] &&defined$bn->[$idx]);
122+
return$an->[$idx]<=>$bn->[$idx]
123+
if ($an->[$idx]<=>$bn->[$idx]);
116124
}
117125
}
118126

119-
# Render the version number in the standard "joined by dots" notation if
120-
# interpolated into a string. Put back 'devel' if we previously turned it
121-
# into a -1.
127+
# Render the version number using the saved string.
122128
sub_stringify
123129
{
124130
my$self =shift;
125-
my@sections =@$self;
126-
if ($sections[-1] == -1)
127-
{
128-
pop@sections;
129-
$sections[-1] ="$sections[-1]devel";
130-
}
131-
returnjoin('.',@sections);
131+
return$self->{str};
132132
}
133133

134134
1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp