From a2c76e7e5f2d21f491ef95433a3b25dd23e70486 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 27 May 2014 13:44:19 +0000 Subject: [PATCH] Detect DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP in column definitions. See http://www.heidisql.com/forum.php?t=15768 --- source/dbconnection.pas | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 911b4a06..fd101ed9 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -4209,22 +4209,25 @@ begin // Default value Col.DefaultType := cdtNothing; Col.DefaultText := ''; - rxCol.Expression := 'CURRENT_TIMESTAMP(\(\d+\))?(\s+ON\s+UPDATE\s+CURRENT_TIMESTAMP(\(\d+\))?)?'; + rxCol.Expression := '(NULL|CURRENT_TIMESTAMP(\(\d+\))?)(\s+ON\s+UPDATE\s+CURRENT_TIMESTAMP(\(\d+\))?)?'; if UpperCase(Copy(ColSpec, 1, 14)) = 'AUTO_INCREMENT' then begin Col.DefaultType := cdtAutoInc; Col.DefaultText := 'AUTO_INCREMENT'; Delete(ColSpec, 1, 15); end else if UpperCase(Copy(ColSpec, 1, 8)) = 'DEFAULT ' then begin Delete(ColSpec, 1, 8); - if UpperCase(Copy(ColSpec, 1, 4)) = 'NULL' then begin - Col.DefaultType := cdtNull; - Col.DefaultText := 'NULL'; - Delete(ColSpec, 1, 5); - end else if rxCol.Exec(ColSpec) then begin - Col.DefaultType := cdtCurTS; - Col.DefaultText := 'CURRENT_TIMESTAMP'; - if rxCol.Match[2] <> '' then - Col.DefaultType := cdtCurTSUpdateTS; + if rxCol.Exec(ColSpec) then begin + if rxCol.Match[1] = 'NULL' then begin + Col.DefaultType := cdtNull; + Col.DefaultText := 'NULL'; + if rxCol.Match[3] <> '' then + Col.DefaultType := cdtNullUpdateTS; + end else begin + Col.DefaultType := cdtCurTS; + Col.DefaultText := 'CURRENT_TIMESTAMP'; + if rxCol.Match[3] <> '' then + Col.DefaultType := cdtCurTSUpdateTS; + end; Delete(ColSpec, 1, rxCol.MatchLen[0]); end else if (ColSpec[1] = '''') or (Copy(ColSpec, 1, 2) = 'b''') then begin InLiteral := True;