Permalink
Browse files

Fix version detection on PostgreSQL, when there is no third segment i…

…n the version string. Closes #137.
  • Loading branch information...
ansgarbecker committed Feb 13, 2018
1 parent 00c3904 commit 0dee2d35bab45650ba9b48377c6699d2fa4a9035
Showing with 10 additions and 2 deletions.
  1. +10 −2 source/dbconnection.pas
@@ -3319,12 +3319,12 @@ function TPgConnection.GetLastError: String;
function TDBConnection.ServerVersionInt: Integer;
var
rx: TRegExpr;
v1, v2: String;
v1, v2, v3: String;
begin
Result := 0;
rx := TRegExpr.Create;
case FParameters.NetTypeGroup of
ngMySQL, ngPgSQL: begin
ngMySQL: begin
rx.Expression := '(\d+)\.(\d+)\.(\d+)';
if rx.Exec(FServerVersionUntouched) then begin
Result := StrToIntDef(rx.Match[1], 0) *10000 +
@@ -3352,6 +3352,14 @@ function TDBConnection.ServerVersionInt: Integer;
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;

2 comments on commit 0dee2d3

@rentalhost

This comment has been minimized.

Collaborator

rentalhost replied Feb 14, 2018

Why not just use the same new regular expression that you created on PG to Mysql? It seems works for both now.
And what does v3 variable here? (I don't know if is some Delphi thing hehe)

@ansgarbecker

This comment has been minimized.

Collaborator

ansgarbecker replied Feb 14, 2018

MySQL sometimes has additional versions in that string, and I didn't want to catch the wrong ones, so I left it as it is for MySQL. v3 is superflous :) Thanks_

Please sign in to comment.