@@ -2605,7 +2605,7 @@ sub run_command {
2605
2605
else {
2606
2606
$string = $arg -> {oldstring } || $arg -> {string };
2607
2607
for my $row (@{$arg -> {version }}) {
2608
- if ($row !~ s / ^([<>]?)(\d +\. ?\d +)\s +// ) {
2608
+ if ($row !~ s / ^([<>]?)(\d +\. ?\d +|1 \d + )\s +// ) {
2609
2609
ndie msg(' die-badversion' , $row );
2610
2610
}
2611
2611
my ($mod ,$ver ) = ($1 ||' ' ,$2 );
@@ -2728,7 +2728,7 @@ sub run_command {
2728
2728
if ($db -> {error }) {
2729
2729
ndie $db -> {error };
2730
2730
}
2731
- if ($db -> {slurp } !~ / (\d +\. ?\d +)/ ) {
2731
+ if ($db -> {slurp } !~ / (\d +(?: \. ?\d +))? / ) {
2732
2732
ndie msg(' die-badversion' , $db -> {slurp });
2733
2733
}
2734
2734
$db -> {version } = $1 ;
@@ -2979,8 +2979,7 @@ sub verify_version {
2979
2979
my $limit = $testaction {lc $action } || ' ' ;
2980
2980
2981
2981
my $versiononly = shift || 0;
2982
-
2983
- return if ! $limit and ! $versiononly ;
2982
+ return if ! $limit and ! $versiononly and !defined wantarray ;
2984
2983
2985
2984
# # We almost always need the version, so just grab it for any limitation
2986
2985
$SQL = q{ SELECT setting FROM pg_settings WHERE name = 'server_version'} ;
@@ -2998,8 +2997,11 @@ sub verify_version {
2998
2997
}
2999
2998
3000
2999
my ($sver ,$smaj ,$smin );
3000
+ if (
3001
+ $info -> {db }[0]{slurp }[0]{setting } !~ / ^(([2-9])\. (\d +))/ &&
3002
+ $info -> {db }[0]{slurp }[0]{setting } !~ / ^((1\d +)())/
3003
+ ){
3001
3004
3002
- if ($info -> {db }[0]{slurp }[0]{setting } !~ / ^((\d +)(\. (:?\d +))?)/ ) {
3003
3005
ndie msg(' die-badversion' , $SQL );
3004
3006
}
3005
3007
else {
@@ -5779,14 +5781,9 @@ sub find_new_version {
5779
5781
my $version = verify_version();
5780
5782
5781
5783
# # The format is X.Y.Z [optional message]
5782
- my $versionre = qr { ((\d +)\. (\d +)\. (\d +))\s *(.*)} ;
5783
- my ($cversion ,$cmajor ,$cminor ,$crevision ,$cmessage ) = (' ' ,' ' ,' ' ,' ' ,' ' );
5784
+ my $versionre = qr { ((\d +)\. (\d +)(?:\. (\d +))?)(?:\s +(.*))?} ;
5784
5785
5785
- # # If we're running on PG10, then format is X.Y [optional message]
5786
- if ($version >= 10) {
5787
- $versionre = qr { ((\d +)\. (\d +))\s *(.*)} ;
5788
- ($cversion ,$cmajor ,$cminor ,$cmessage ) = (' ' ,' ' ,' ' ,' ' );
5789
- }
5786
+ my ($cversion ,$cmajor ,$cminor ,$crevision ,$cmessage ) = (' ' ,' ' ,' ' ,' ' ,' ' );
5790
5787
5791
5788
my $found = 0;
5792
5789
@@ -5799,24 +5796,21 @@ sub find_new_version {
5799
5796
# # Postgres is slightly different
5800
5797
if ($program eq ' Postgres' ) {
5801
5798
$cmajor = {};
5802
- if ($version >= 10) {
5803
- while ($info =~ / <title>(\d +)\. (\d +)/g ) {
5804
- $found = 1;
5805
- $cmajor -> {" $1 " } = $2 ;
5806
- }
5807
- }
5808
- else {
5809
- while ($info =~ / <title>(\d +)\. (\d +)\. (\d +)/g ) {
5810
- $found = 1;
5799
+ while ($info =~ / <title>(\d +)\. (\d +)(?:\. (\d +))?/g ) {
5800
+ $found = 1;
5801
+ if (defined $3 ) {
5811
5802
$cmajor -> {" $1 .$2 " } = $3 ;
5812
5803
}
5804
+ else {
5805
+ $cmajor -> {$1 } = $2 ;
5806
+ }
5813
5807
}
5814
5808
}
5815
5809
elsif ($info =~ $versionre ) {
5816
5810
$found = 1;
5817
5811
($cversion ,$cmajor ,$cminor ,$crevision ,$cmessage ) = ($1 , int $2 , int $3 , int $4 , $5 );
5812
+ $info =~ s /\s +$// s ;
5818
5813
if ($VERBOSE >= 1) {
5819
- $info =~ s /\s +$// s ;
5820
5814
warn " Remote version string: $info \n " ;
5821
5815
warn " Remote version: $cversion \n " ;
5822
5816
}
@@ -5854,30 +5848,30 @@ sub find_new_version {
5854
5848
return ;
5855
5849
}
5856
5850
my ($lversion ,$lmajor ,$lminor ,$lrevision ) = (' ' ,0,0,0);
5857
- if ($version >= 10) {
5858
- ($lversion , $lmajor , $lminor ) = ($1 , int $2 , int $3 );
5851
+ if ($2 >= 10 && $program eq ' Postgres ' ) {
5852
+ ($lversion ,$lmajor ,$lrevision ) = ($1 , int $2 , int $3 );
5859
5853
} else {
5860
5854
($lversion ,$lmajor ,$lminor ,$lrevision ) = ($1 , int $2 , int $3 , int $4 );
5861
5855
}
5862
5856
5857
+ $output =~ s /\s +$// s ;
5863
5858
if ($VERBOSE >= 1) {
5864
- $output =~ s /\s +$// s ;
5865
5859
warn " Local version string: $output \n " ;
5866
5860
warn " Local version: $lversion \n " ;
5867
5861
}
5868
5862
5869
5863
# # Postgres is a special case
5870
5864
if ($program eq ' Postgres' ) {
5871
- my $lver = " $lmajor .$lminor " ;
5865
+ my $lver = $lmajor >= 10 ? $lmajor : " $lmajor .$lminor " ;
5872
5866
if (! exists $cmajor -> {$lver }) {
5873
5867
add_unknown msg(' new-ver-nocver' , $program );
5874
5868
return ;
5875
5869
}
5876
5870
$crevision = $cmajor -> {$lver };
5877
5871
$cmajor = $lmajor ;
5878
5872
$cminor = $lminor ;
5879
- if ($version >= 10) {
5880
- $cversion = " $cmajor .$cminor " ;
5873
+ if ($lmajor >= 10) {
5874
+ $cversion = " $cmajor .$crevision " ;
5881
5875
} else {
5882
5876
$cversion = " $cmajor .$cminor .$crevision " ;
5883
5877
}
@@ -5954,7 +5948,7 @@ sub check_new_version_pg {
5954
5948
my $info = run_command(' SELECT version() AS version' );
5955
5949
my $lversion = $info -> {db }[0]{slurp }[0]{version };
5956
5950
# # Make sure it is parseable and check for development versions
5957
- if ($lversion !~ / \d +\.\d +\.\d +/ ) {
5951
+ if ($lversion !~ / 1 \d + \.\d +| \d +\.\d +\.\d +/ ) {
5958
5952
if ($lversion =~ / (\d +\.\d +\S +)/ ) {
5959
5953
add_ok msg(' new-ver-dev' , ' Postgres' , $1 );
5960
5954
return ;
@@ -8351,7 +8345,7 @@ sub check_version {
8351
8345
8352
8346
my ($warning , $critical ) = validate_range({type => ' version' , forcemrtg => 1});
8353
8347
8354
- my ($warnfull , $critfull ) = (($warning =~ / ^\d +\. ? \d +$ / ? 0 : 1),($critical =~ / ^\d +\. ? \d +$ / ? 0 : 1));
8348
+ my ($warnfull , $critfull ) = (($warning =~ / ^(?:1 \d +|[8-9] \. \d +) $ / ? 0 : 1),($critical =~ / ^(?:1 \d +|[8-9] \. \d +) $ / ? 0 : 1));
8355
8349
8356
8350
my $info = run_command(' SELECT version() AS version' );
8357
8351
0 commit comments