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

This commit is contained in:
Ansgar Becker
2020-04-23 20:37:24 +02:00
parent 5e2d6b3c93
commit 849a50c4f3
2 changed files with 7 additions and 6 deletions

View File

@@ -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;

View File

@@ -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;