From 680bbcf0acb338308d84e8018ae474ab00234c24 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 30 Nov 2009 22:42:08 +0000 Subject: [PATCH] Automatically remove AUTO_INCREMENT=x clause from CREATE TABLE statement for SQL export. Fixes issue #1110. --- source/tabletools.pas | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/tabletools.pas b/source/tabletools.pas index 2505f32a..f43f9b95 100644 --- a/source/tabletools.pas +++ b/source/tabletools.pas @@ -11,7 +11,7 @@ interface uses Windows, SysUtils, Classes, Controls, Forms, StdCtrls, ComCtrls, Buttons, Dialogs, StdActns, WideStrings, WideStrUtils, VirtualTrees, ExtCtrls, mysql_connection, Contnrs, Graphics, TntStdCtrls, - PngSpeedButton, helpers; + PngSpeedButton, SynRegExpr, helpers; type TToolMode = (tmMaintenance, tmFind, tmSQLExport, tmBulkTableEdit); @@ -836,6 +836,7 @@ var RowCount, MaxRowsInChunk, RowsInChunk, Limit, Offset, ResultCount: Int64; StartTime: Cardinal; Data: TMySQLQuery; + rx: TRegExpr; // Short version of Mainform.Mask() function m(s: WideString): WideString; @@ -960,6 +961,12 @@ begin try Struc := Mainform.Connection.GetVar('SHOW CREATE TABLE '+m(db)+'.'+m(obj), 1); Struc := fixNewlines(Struc); + // Remove AUTO_INCREMENT clause + rx := TRegExpr.Create; + rx.ModifierI := True; + rx.Expression := '\sAUTO_INCREMENT\s*\=\s*\d+\s'; + Struc := rx.Replace(Struc, ' '); + rx.Free; if NodeType = lntTable then Insert('IF NOT EXISTS ', Struc, Pos('TABLE', Struc) + 6); if ToDb then begin