From 52c3fb43a2d3cc45fa424822d64839f9ba472b60 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Wed, 14 Feb 2018 07:43:57 +0100 Subject: [PATCH] Fix detection of PostgreSQL version ignoring the 3rd version segment, and use the same logic as for MySQL again. See issue #137. --- source/dbconnection.pas | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index a31686f7..08d20518 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -3319,17 +3319,17 @@ end; function TDBConnection.ServerVersionInt: Integer; var rx: TRegExpr; - v1, v2, v3: String; + v1, v2: String; begin Result := 0; rx := TRegExpr.Create; case FParameters.NetTypeGroup of - ngMySQL: begin - rx.Expression := '(\d+)\.(\d+)\.(\d+)'; + ngMySQL, ngPgSQL: begin + rx.Expression := '(\d+)\.(\d+)(\.(\d+))?'; if rx.Exec(FServerVersionUntouched) then begin Result := StrToIntDef(rx.Match[1], 0) *10000 + StrToIntDef(rx.Match[2], 0) *100 + - StrToIntDef(rx.Match[3], 0); + StrToIntDef(rx.Match[4], 0); end; end; ngMSSQL: begin @@ -3352,14 +3352,6 @@ begin end; end; end; - ngPgSQL: begin - rx.Expression := '(\d+)\.(\d+)(\.(\d+))?'; - if rx.Exec(FServerVersionUntouched) then begin - Result := StrToIntDef(rx.Match[1], 0) *10000 + - StrToIntDef(rx.Match[2], 0) *100 + - StrToIntDef(rx.Match[3], 0); - end; - end; end; rx.Free; end;