From 849a50c4f396af3ef86ba57e5004c173fa1556ee Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Thu, 23 Apr 2020 20:37:24 +0200 Subject: [PATCH] Make regular expressions for detecting attributes in EXTRA column of IS.COLUMNS slightly more lose, so a "default_generated" does not break detection of "on update ...". Also allow case insensitive searching. See https://www.heidisql.com/forum.php?t=36100 --- source/apphelpers.pas | 7 ++++--- source/dbconnection.pas | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source/apphelpers.pas b/source/apphelpers.pas index 451677ee..3f860ae1 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -297,7 +297,7 @@ type function FormatNumber( flt: Double; decimals: Integer = 0; Thousands: Boolean=True): String; Overload; procedure ShellExec(cmd: String; path: String=''; params: String=''); function getFirstWord(text: String; MustStartWithWordChar: Boolean=True): String; - function RegExprGetMatch(Expression: String; var Input: String; ReturnMatchNum: Integer; DeleteFromSource: Boolean): String; Overload; + function RegExprGetMatch(Expression: String; var Input: String; ReturnMatchNum: Integer; DeleteFromSource, CaseInsensitive: Boolean): String; Overload; function RegExprGetMatch(Expression: String; Input: String; ReturnMatchNum: Integer): String; Overload; function FormatByteNumber( Bytes: Int64; Decimals: Byte = 1 ): String; Overload; function FormatByteNumber( Bytes: String; Decimals: Byte = 1 ): String; Overload; @@ -1000,12 +1000,13 @@ begin end; -function RegExprGetMatch(Expression: String; var Input: String; ReturnMatchNum: Integer; DeleteFromSource: Boolean): String; +function RegExprGetMatch(Expression: String; var Input: String; ReturnMatchNum: Integer; DeleteFromSource, CaseInsensitive: Boolean): String; var rx: TRegExpr; begin Result := ''; rx := TRegExpr.Create; + rx.ModifierI := CaseInsensitive; rx.Expression := Expression; if rx.Exec(Input) then begin if rx.SubExprMatchCount >= ReturnMatchNum then begin @@ -1023,7 +1024,7 @@ end; function RegExprGetMatch(Expression: String; Input: String; ReturnMatchNum: Integer): String; begin // Version without possibility to delete captured match from input - Result := RegExprGetMatch(Expression, Input, ReturnMatchNum, False); + Result := RegExprGetMatch(Expression, Input, ReturnMatchNum, False, False); end; diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 899a68c7..60858725 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -4775,12 +4775,12 @@ begin Col.Expression := ColQuery.Col('GENERATION_EXPRESSION', True); // PG has no extra: ExtraText := ColQuery.Col('EXTRA', True); - Col.Virtuality := RegExprGetMatch('^(\w+)\s+generated$', ExtraText.ToLowerInvariant, 1); + Col.Virtuality := RegExprGetMatch('\b(\w+)\s+generated\b', ExtraText.ToLowerInvariant, 1); Col.AllowNull := ColQuery.Col('IS_NULLABLE').ToLowerInvariant = 'yes'; DefText := ColQuery.Col('COLUMN_DEFAULT'); Col.OnUpdateType := cdtNothing; - if ExecRegExpr('^auto_increment$', ExtraText.ToLowerInvariant) then begin + if ExecRegExpr('\bauto_increment\b', ExtraText.ToLowerInvariant) then begin Col.DefaultType := cdtAutoInc; Col.DefaultText := 'AUTO_INCREMENT'; end else if DefText.ToLowerInvariant = 'null' then begin @@ -4797,7 +4797,7 @@ begin Col.DefaultType := cdtExpression; Col.DefaultText := DefText; end; - Col.OnUpdateText := RegExprGetMatch('^on update (.*)$', ExtraText, 1); + Col.OnUpdateText := RegExprGetMatch('\bon update (.*)$', ExtraText, 1, False, True); if not Col.OnUpdateText.IsEmpty then begin Col.OnUpdateType := cdtExpression; end;