From 3a5917f0802bfab3cc85bdebf6f652bb8e4fca7e Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 30 Nov 2015 10:56:34 +0000 Subject: [PATCH] Add menu item "Run SQL file", as a complement to "Load SQL files". See http://www.heidisql.com/forum.php?t=19982 --- out/locale/en/LC_MESSAGES/default.po | 8 ++- source/main.dfm | 90 +++++++++++++++------------- source/main.pas | 23 ++++--- 3 files changed, 71 insertions(+), 50 deletions(-) diff --git a/out/locale/en/LC_MESSAGES/default.po b/out/locale/en/LC_MESSAGES/default.po index 06d121a1..e78f06e5 100644 --- a/out/locale/en/LC_MESSAGES/default.po +++ b/out/locale/en/LC_MESSAGES/default.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: HeidiSQL\n" "POT-Creation-Date: 2012-11-05 21:40\n" -"PO-Revision-Date: 2015-11-26 21:27+0100\n" +"PO-Revision-Date: 2015-11-30 11:54+0100\n" "Last-Translator: Ansgar Becker \n" "Language-Team: English (http://www.transifex.com/projects/p/heidisql/" "language/en/)\n" @@ -1880,6 +1880,12 @@ msgstr "Dump database objects to an SQL file" msgid "Load SQL file..." msgstr "Load SQL file..." +msgid "Run SQL file..." +msgstr "Run SQL file..." + +msgid "Run SQL file(s) directly, without loading into the editor" +msgstr "Run SQL file(s) directly, without loading into the editor" + #. MainForm..ActionList1..actDropObjects..Caption #: main.dfm:2045 msgid "Drop ..." diff --git a/source/main.dfm b/source/main.dfm index 9c6afd8a..7ce92cd4 100644 --- a/source/main.dfm +++ b/source/main.dfm @@ -1824,6 +1824,9 @@ object MainForm: TMainForm object LoadSQLfile2: TMenuItem Action = actLoadSQL end + object RunSQLfiles1: TMenuItem + Action = actRunSQL + end object Save1: TMenuItem Action = actSaveSQL end @@ -2176,6 +2179,13 @@ object MainForm: TMainForm ShortCut = 16463 OnExecute = actLoadSQLExecute end + object actRunSQL: TAction + Category = 'SQL' + Caption = 'Run SQL file...' + Hint = 'Run SQL file(s) directly, without loading into the editor' + ImageIndex = 189 + OnExecute = actLoadSQLExecute + end object actDropObjects: TAction Category = 'Database' Caption = 'Drop ...' @@ -2800,117 +2810,117 @@ object MainForm: TMainForm Left = 504 Top = 104 Bitmap = { - 494C0101BD005001F80310001000FFFFFFFF2110FFFFFFFFFFFFFFFF424D3600 + 494C0101BE005001180410001000FFFFFFFF2110FFFFFFFFFFFFFFFF424D3600 0000000000003600000028000000400000000003000001002000000000000000 0300000000000000000000000000000000000000000000000000000000000000 00000000000000000004000000080000000C0000000C00000008000000030000 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000681AEB0279 + 1CFF000000040000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0004000000110202001D04040128211C0C69614F25B27D602BCF66451AC0311E 0A8904030129000000040000000B000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000006E23EB41A0 + 5DFF004E13CC0000000600000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000200000000000000060101 00190504012B120F04503E361591C7A12DFFC69E28FFC29722FFBB881AFFAF6D 13FF6E481BCA0000003100000057000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000001F944EFD198E46FD138C40FD0E8839FD389E5CFF7EC0 + 95FF44A260FF005314D100000007000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000291C077F51310FB3302411843329 1287624F1CB8BFA03BF9554C23A6D6BA52FFD4B849FFD0B03DFFCAA52FFFC093 - 20FFAF7C28FA0504012D00000010000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 20FFAF7C28FA0504012D0000001000000000000000000819297012395CA62470 + B5EA297FCAF7297FCAF7279A59FF8FCAA8FF8CC8A4FF89C5A0FF87C49DFF68B5 + 84FF81C196FF46A464FF036C2BEE000000090000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000D0A0346A96211FFBC891BFFC9A3 2DFFD3B443FFDCC566FF7C723BC4C8B775F3E4D38CFFDFCA73FFD6BA4DFFCBA8 - 33FFC19423FF26200D720000000F000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 33FFC19423FF26200D720000000F00000000000000002872B0E6C3D4DDF0A4D9 + F0FD9DDBF4FF95DAF3FF2F9E61FF93CDACFF6DB98DFF69B788FF64B584FF5FB2 + 7EFF65B481FF82C197FF3A9F5AFF007722F90000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000FA6771FF3C49A24FFD0B0 3CFFDDC669FFE7D89AFFBFB381EC9B905AD9F0E6BEFFEBDEAAFFE2CF80FFD4B8 - 49FFC8A12BFF61501EB40202001B000000030000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 49FFC8A12BFF61501EB40202001B00000003000000003089CCF7EFFAFEFFA0E9 + F9FF90E5F8FF80E1F7FF35A269FF95CEAFFF93CDACFF90CBA9FF8FCBA7FF72BB + 8FFF89C7A0FF44A466FF078636FF000000010000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000A69531BBCC9A32DFFD6BB 4EFFE4D38CFFEEE4B9FFEDE4C2FE887A3AD2EFE8C7FFB6A970EA827439CD705D - 25C27C6322CD91772FDD04030027000000070000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 25C27C6322CD91772FDD0403002700000007000000003291CEF8F2FAFDFFB2ED + FAFFA3E9F9FF94E6F8FF3BA46DFF36A36DFF32A167FF2E9D61FF53AE7AFF90CB + A9FF4DAA72FF189046FF308DCBF7000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000E322C1281CBA732FFD9C0 5BFFE8D99CFFF1E9C6FFF5EFD6FF968944DC8A782CD8A18F57E1CDBD88F5CDB6 - 72F8A6873AE8665221B90C0A03400000000B0000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 72F8A6873AE8665221B90C0A03400000000B000000003298D0F9F6FCFEFFC8F2 + FCFFB8EFFBFFABECFAFF9BE8F9FF8AE3F7FF7AE0F6FF6ADCF6FF32A36CFF58B2 + 80FF269755FFD0F3FCFF3094CCF7000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000E0908023A524015AA9680 39DBC5B36CF3BEB478ED948C4CD87D6E23D1BDB07CEEF4EED2FFEEE4B9FFE3D1 - 86FFD4B747FFC7A02AFF3A2B13900000000B0000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 86FFD4B747FFC7A02AFF3A2B13900000000B00000000339FD1FAFEFFFFFFF8FD + FFFFF6FDFFFFF5FCFFFFF3FCFEFFD8F6FCFF93E6F8FF84E3F7FF3AA774FF2F9E + 63FF5AD8F4FFD7F4FCFF3099CCF7000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000A040401298F7530DA8B76 34D675652BC6867439D3BFA97DF2E1D8B7FA938A4DD7F2EAC9FFEBDFAAFFDFCB - 75FFD1B23FFFC49B25FF785820CE000000080000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 75FFD1B23FFFC49B25FF785820CE000000080000000031A4D1FAE8F6FBFF93D4 + EFFF87CEEEFF71C0E9FFC9E9F6FFF2FCFEFFF3FCFEFFF2FCFEFFF0FCFEFFEFFB + FEFFEEFBFEFFFEFFFFFF31A0CCF7000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000050202001F544417A6CFAF 3BFFDFC971FFEBDEAAFFF2E9C7FFF3ECCEFF796F35C5EADEADFFE4D38AFFD8BE - 55FFCCA934FFBF901EFFAC7224FB0101001A0000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 55FFCCA934FFBF901EFFAC7224FB0101001A000000002F98C4F2F1FAFDFF93DE + F5FF92DCF4FF80D5F2FF68CAEDFF6ACBEAFF84D3EFFF7ED2EFFF78D0EFFF74CF + EEFF70CFEEFFE9F7FBFF2E9DC6F3000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000001010000131E190964C9A3 2EFFD4B849FFE0CC79FFE8D99DFFEBDEA9FF857C48C9C0AD66F0D9C059FFCFAF - 3AFFC59C26FFB67C17FFA55911FF1913085E0000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 3AFFC59C26FFB67C17FFA55911FF1913085E000000002D9AC1F0F7FCFEFF8DE4 + F8FF90DEF5FF9EE0F5FFABE1F6FFEFFBFEFFF4FDFEFFF3FCFEFFF1FCFEFFEFFB + FEFFEEFBFEFFEEF1F3F9247896D4000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000503030024B38C 2BF4C9A42EFFD2B342FFD9BF58FFDBC463FFAF9B4DE674652BC1A98F33E8493E - 159C241D09702219077142270BA23B2B13920000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 159C241D09702219077142270BA23B2B13920000000032A8CEF8FDFEFEFFFEFF + FFFFFEFEFFFFFDFEFFFFFEFFFFFFEAF7FBFF65BDD9F963BCD7F863BCD7F863BC + D7F86FC0D8F7589DB2E105131856000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000085F46 1AB7BB871AFFC49A25FFC9A42EFFCBA732FFC1A03AFA1E1B09660C0B03410504 - 012B010100180000000600000000000000020000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 012B0101001800000006000000000000000200000000227790D058B9D8FA5ABA + D9FA5ABAD9FA5ABAD9FA59BAD9FA2C88A4DD000101160000000F0000000F0000 + 000F0000000F0000000F00000004000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 diff --git a/source/main.pas b/source/main.pas index 07761787..7bd3cccf 100644 --- a/source/main.pas +++ b/source/main.pas @@ -615,6 +615,8 @@ type N11: TMenuItem; N12: TMenuItem; menuDoubleClickInsertsNodeText: TMenuItem; + actRunSQL: TAction; + RunSQLfiles1: TMenuItem; procedure actCreateDBObjectExecute(Sender: TObject); procedure menuConnectionsPopup(Sender: TObject); procedure actExitApplicationExecute(Sender: TObject); @@ -1057,7 +1059,7 @@ type procedure SetSnippetFilenames; function TreeClickHistoryPrevious(MayBeNil: Boolean=False): PVirtualNode; procedure OperationRunning(Runs: Boolean); - function RunQueryFiles(Filenames: TStrings; Encoding: TEncoding): Boolean; + function RunQueryFiles(Filenames: TStrings; Encoding: TEncoding; ForceRun: Boolean): Boolean; procedure RunQueryFile(Filename: String; Encoding: TEncoding); procedure SetLogToFile(Value: Boolean); procedure StoreLastSessions; @@ -1935,7 +1937,7 @@ begin end; // Load SQL file(s) by command line - if not RunQueryFiles(FileNames, nil) then begin + if not RunQueryFiles(FileNames, nil, false) then begin for i:=0 to FileNames.Count-1 do begin Tab := ActiveOrEmptyQueryTab(False); Tab.LoadContents(FileNames[i], True, nil); @@ -3232,7 +3234,7 @@ begin Dialog.EncodingIndex := 0; if Dialog.Execute then begin Encoding := GetEncodingByName(Dialog.Encodings[Dialog.EncodingIndex]); - if not RunQueryFiles(Dialog.Files, Encoding) then begin + if not RunQueryFiles(Dialog.Files, Encoding, Sender=actRunSQL) then begin ConsiderActiveTab := True; for i:=0 to Dialog.Files.Count-1 do begin Tab := ActiveOrEmptyQueryTab(ConsiderActiveTab); @@ -3247,7 +3249,7 @@ begin end; -function TMainForm.RunQueryFiles(Filenames: TStrings; Encoding: TEncoding): Boolean; +function TMainForm.RunQueryFiles(Filenames: TStrings; Encoding: TEncoding; ForceRun: Boolean): Boolean; var i: Integer; Filesize, FilesizeSum: Int64; @@ -3272,7 +3274,7 @@ begin end; end; // Check if one or more files are large - DoRunFiles := False; + DoRunFiles := ForceRun; PopupFileList := TStringList.Create; FilesizeSum := 0; for i:=0 to Filenames.Count-1 do begin @@ -3283,7 +3285,10 @@ begin end; if DoRunFiles then begin - if (Win32MajorVersion >= 6) and StyleServices.Enabled then begin + if ForceRun then begin + // Don't ask, just run files + DialogResult := mrYes; + end else if (Win32MajorVersion >= 6) and StyleServices.Enabled then begin Dialog := TTaskDialog.Create(Self); Dialog.Caption := _('Opening large files'); Dialog.Text := f_('Selected files have a size of %s', [FormatByteNumber(FilesizeSum, 1)]); @@ -4209,7 +4214,7 @@ begin end; FileList := TStringList.Create; FileList.Add(Filename); - if not RunQueryFiles(FileList, nil) then begin + if not RunQueryFiles(FileList, nil, false) then begin Tab := ActiveOrEmptyQueryTab(True); Tab.LoadContents(Filename, True, nil); SetMainTab(Tab.TabSheet); @@ -5974,7 +5979,7 @@ var begin // One or more files from explorer or somewhere else was dropped onto the // query-memo - load their contents into seperate tabs - if not RunQueryFiles(AFiles, nil) then begin + if not RunQueryFiles(AFiles, nil, False) then begin for i:=0 to AFiles.Count-1 do begin Tab := ActiveOrEmptyQueryTab(False); Tab.LoadContents(AFiles[i], False, nil); @@ -10830,7 +10835,7 @@ begin LogSQL(f_('Preventing second application instance - disabled in %s > %s > %s.', [_('Tools'), _('Preferences'), _('General')]), lcInfo); ConnectionParams := nil; ParseCommandLine(ParamBlobToStr(Msg.CopyDataStruct.lpData), ConnectionParams, FileNames); - if not RunQueryFiles(FileNames, nil) then begin + if not RunQueryFiles(FileNames, nil, False) then begin for i:=0 to FileNames.Count-1 do begin Tab := ActiveOrEmptyQueryTab(False); Tab.LoadContents(FileNames[i], True, nil);