Permalink
Browse files

Simplify regular expression for extracting column details in ParseTab…

…leStructure(), so it does not barf on huge length/set. Fixes issue #2.
  • Loading branch information...
ansgarbecker committed Nov 6, 2017
1 parent 4c9d332 commit 88bb7eb376d671691954601ab19b049f4e8595c7
Showing with 5 additions and 2 deletions.
  1. +5 −2 source/dbconnection.pas
View
@@ -4858,13 +4858,15 @@ procedure TDBConnection.ParseTableStructure(CreateTable: String; Columns: TTable
rx := TRegExpr.Create;
rx.ModifierS := False;
rx.ModifierM := True;
rx.Expression := '^\s+(['+Quotes+'].+),?$';
rx.Expression := '^\s+['+Quotes+']';
rxCol := TRegExpr.Create;
rxCol.ModifierI := True;
if rx.Exec(CreateTable) then while true do begin
if not Assigned(Columns) then
break;
ColSpec := rx.Match[1];
ColSpec := Copy(CreateTable, rx.MatchPos[0], SIZE_MB);
ColSpec := Copy(ColSpec, 1, Pos(#10, ColSpec));
ColSpec := Trim(ColSpec);
Col := TTableColumn.Create(Self);
Columns.Add(Col);
@@ -6354,6 +6356,7 @@ procedure TDBQuery.SetCol(Column: Integer; NewText: String; Null: Boolean; IsFun
(FCurrentUpdateRow[Column].NewIsNull <> FCurrentUpdateRow[Column].OldIsNull) or
(FCurrentUpdateRow[Column].NewIsFunction <> FCurrentUpdateRow[Column].OldIsFunction)
;
// TODO: check if column allows NULL, otherwise force .Modified
end;

0 comments on commit 88bb7eb

Please sign in to comment.