diff --git a/include/CopyDatabase.h b/include/CopyDatabase.h index 91a526c..07d3b1f 100644 --- a/include/CopyDatabase.h +++ b/include/CopyDatabase.h @@ -291,6 +291,9 @@ class CopyDatabase wyBool m_iscreatedb; DB_LIST *m_dblist; /* List of Db in temporary array */ + + int m_defaultdbindex; // variable to set the index of dropdown for target db + wyUInt32 m_countdb; private: diff --git a/include/CustGrid.h b/include/CustGrid.h index 8e58245..3004c55 100644 --- a/include/CustGrid.h +++ b/include/CustGrid.h @@ -56,6 +56,7 @@ #define GVN_LBUTTONMOUSEMOVE 0x00030 #define GVN_LBUTTONUP 0x00031 #define GVN_MOUSELEAVE 0x00032 +#define GVN_TOOLTIP 0x00071 #define GVN_PREVTABORDERITEM 0x00033 #define GVN_SPLITTERMOVE 0x00034 #define GVN_LBUTTONDOWN 0x00050 @@ -76,6 +77,7 @@ #define GVN_MOUSEWHEEL 0x00061 #define GVN_DRAWWATERMARK 0x00062 #define GVN_SETFOCUS 0x00063 +#define GVN_RESETDATAVIEWTOOLTIP 0x00065 #define GVKEY_HOME 36 #define GVKEY_END 35 @@ -288,6 +290,23 @@ class CCustGrid CCustGrid(HWND h); ~CCustGrid(); + + + + HWND m_hwndtooltip; + POINT m_mouseprevpt; + + /// Stucture containing tooltip info + TOOLINFO m_toolinfo; + + //tooltip string + wyString m_tooltipstr; + + VOID ToolTipInfo(HWND hwnd, LPNMTTDISPINFO lpnmtdi, wyString Text); + + // Tool tip Unique ID for the tooltip of data view + wyInt32 m_tooltipidindex; + /// Inserts the column in the grid view /** @param pgvcol : IN Column details @@ -559,6 +578,7 @@ class CCustGrid */ VOID SetMaxRowCount(LONG count); + /// Sets row long value data /** @param row : IN Row number @@ -886,8 +906,9 @@ class CCustGrid /// Gets the column header clicked /** @param pnt : IN Mouse points + @param rect : OUT Rectangle containing the row header */ - wyInt32 GetRowHeader(POINT *pnt); + wyInt32 GetRowHeader(POINT *pnt, RECT* rect = NULL); /// Gets the row and column when a drag and drop accures on the grid cell /** @@ -1042,6 +1063,8 @@ class CCustGrid ////////////////////////////////////////////////// void GetSelectColumn(POINT pnt); + wyInt32 GetHoveredColumn(); + /////////////////////////////////////////////// @@ -1814,7 +1837,7 @@ class CCustGrid */ void DrawRowButtons(HDC hdcmem, RECT *rect, RECT *recttemp, wyInt32 *rowcount); - /// Draws the grey rectangle for the cell + /// Draws the grey rectangle for the cell /** @param hdcmem : IN Device HANDLE @param greyrect : IN The grey rectangle @@ -2055,6 +2078,7 @@ class CCustGrid //whether the browse button is pressed wyBool m_ispressed; + wyBool g_bMouseTrack; }; #define GV_MARKTYPE_ICON 1 @@ -2083,6 +2107,7 @@ class CCustGrid #define GV_EX_NO_VER_BORDER 16 #define GV_EX_NO_HOR_BORDER 32 #define GV_EX_STRETCH_LAST_COL 64 +#define GV_EX_COL_TOOLTIP 128 #define GV_DEFWIDTH 25 #define GV_DEFHIGHT 18 @@ -2182,6 +2207,18 @@ wyInt32 CustomGrid_RowPerPage (HWND hwnd); */ wyInt32 CustomGrid_InsertColumn (HWND hwnd, PGVCOLUMN pgvcol, wyBool repaint = wyTrue); +/// +/*** +@param HWND : IN Grid Window Handle +@param int : IN index of the column +@param wyWChar* : IN Text to be set + +Tool tip for column header to be set initially while loading table data +***/ +void SetToolTipForDataView(HWND, int, wyWChar*); + +void RemoveToolTipForDataView(HWND); + /// Inserts a row in between /** @param hwnd : IN Grid Window Handle diff --git a/include/DataView.h b/include/DataView.h index 594a4ee..bb39f8c 100644 --- a/include/DataView.h +++ b/include/DataView.h @@ -825,6 +825,10 @@ class DataView */ void OnSplitterMove(wyInt32 col); + void OnColNameMouseHover(WPARAM wparam, wyString&); + + void ResetDataViewTooltip(); + ////void ResettingTooltip(WPARAM wparam,LPARAM lparam); ///Function creates the outer frame window /** @returns void diff --git a/include/FrameWindow.h b/include/FrameWindow.h index fb06c1d..ac32c61 100644 --- a/include/FrameWindow.h +++ b/include/FrameWindow.h @@ -1725,7 +1725,12 @@ class FrameWindow wyBool m_mouseoverbuy; wyString m_trialtext; wyBool m_issessionedited; - +#ifndef COMMUNITY + wyInt32 m_closealltrans; + wyInt32 m_intransaction; + wyBool m_topromptonimplicit; + wyBool m_topromptonclose; +#endif }; /// Function to rstore connections diff --git a/include/FrameWindowHelper.h b/include/FrameWindowHelper.h index 3fd18ba..79e1d92 100644 --- a/include/FrameWindowHelper.h +++ b/include/FrameWindowHelper.h @@ -313,7 +313,7 @@ #define CELLBUTTONMINWIDTH 80 //for appending the list of child window names to window menu -#define MDISUBMENU 8 +#define MDISUBMENU 9 // #defines for telling the advproperties what to show. #define ADVPROP 1 @@ -562,7 +562,8 @@ wyInt32 compare (const void *arg1, const void *arg2); */ wyInt32 my_query(MDIWindow *wnd, Tunnel * tunnel, PMYSQL mysql, const wyChar *query, wyUInt32 length, wyBool batch = wyFalse, wyBool isend = wyFalse, wyInt32 *stop = 0, wyInt32 querycount = 0, wyBool profile = wyTrue, - wyBool currentwnd = wyTrue, bool isread = false, wyBool isimport = wyFalse, wyBool fksethttpimport = wyFalse); + wyBool currentwnd = wyTrue, bool isread = false, wyBool isimport = wyFalse, wyBool fksethttpimport = wyFalse, + HWND fortransactionprompt = NULL); /// Profiling the query or comment(SQLyog reconnected/failed) to history tab /** @@ -755,7 +756,9 @@ const wyChar *LeftPadText(const wyChar *text); @param changeincombo : IN To change in combo box or not */ wyBool ChangeContextDB(Tunnel * tunnel, PMYSQL mysql, const wyChar *query, wyBool changeincombo = wyTrue); - +#ifndef COMMUNITY +wyBool ChangeTransactionState(MDIWindow *wnd, const wyChar *query); +#endif /// Gets the database name from the query. /** @param query : IN Query string diff --git a/include/GUIHelper.h b/include/GUIHelper.h index 4322f4c..cd86f3d 100644 --- a/include/GUIHelper.h +++ b/include/GUIHelper.h @@ -719,6 +719,8 @@ wyInt32 GetKBShortcut(wyWChar *menustring, wyWChar *shortcut); */ wyBool ChangeCRToLF(wyChar * text); +wyBool AddCRToLF(wyChar * text, wyChar * temp); + //Handles On treeview item expand /** @param treeparam : IN trview node struct handle diff --git a/include/Global.h b/include/Global.h index eb83b48..84352a9 100644 --- a/include/Global.h +++ b/include/Global.h @@ -75,8 +75,9 @@ class wySQLite; #define MNUOBJ_INDEX 6 #define MNUTOOL_INDEX 7 #define MNUPTOOL_INDEX 8 -#define MNUWINDOW_INDEX 9 -#define MNUHELP_INDEX 10 +#define MNUTRANSACTION_INDEX 9 +#define MNUWINDOW_INDEX 10 +#define MNUHELP_INDEX 11 #define MNUENGINE_INDEX 20 #define DEF_TAB_SIZE 8 diff --git a/include/MDIWindow.h b/include/MDIWindow.h index 21f875a..fec0317 100644 --- a/include/MDIWindow.h +++ b/include/MDIWindow.h @@ -37,6 +37,7 @@ #ifndef COMMUNITY #include "ProfilerAdvisors.h" +#include "Transactions.h" #endif class TabMgmt; @@ -398,6 +399,12 @@ class MDIWindow */ void CreateQueryStatus (HWND hwnd); + ///create the handler for the transaction + /** + @param hwnd :Window HANDLE + @returns void + */ + void CreateTransactionhandler(HWND hwnd); /// Create the vertical splitter /** @param hwnd :Window HANDLE @@ -588,7 +595,7 @@ class MDIWindow @param hwnddlg : Dialog window HANDLE @returns wyTrue on success else wyFalse */ - wyBool ExecuteFlush(wyString query, HWND hwndedit, INT writetobin, HWND hwnddlg); + wyBool ExecuteFlush(wyString query, HWND hwndedit, INT writetobin, HWND hwnddlg, wyInt32 *isflush = NULL); /// Enables or disables the option in flush window. /** @@ -1028,8 +1035,13 @@ class MDIWindow /// Querytab object pointer CQueryObject *m_pcqueryobject; + ///announcements object Announcements *m_announcements; + ///transaction object pointer +#ifndef COMMUNITY + Transactions *m_ptransaction; +#endif /// TabModule object pointer TabModule *m_pctabmodule; diff --git a/include/MySQLVersionHelper.h b/include/MySQLVersionHelper.h index 30d05ac..1216b02 100644 --- a/include/MySQLVersionHelper.h +++ b/include/MySQLVersionHelper.h @@ -136,6 +136,9 @@ wyBool IsMySQL563(Tunnel * tunnel, PMYSQL mysql); //MySQL 5.6.4 wyBool IsMySQL564MariaDB53(Tunnel * tunnel, PMYSQL mysql); +//MySQL 5.5.3 or mariadb 5.5 +wyBool IsMySQL553MariaDB55(Tunnel * tunnel, PMYSQL mysql); + //MySQL 5.6.5 wyBool IsMySQL565MariaDB1001(Tunnel * tunnel, PMYSQL mysql); diff --git a/include/ObjectBrowser.h b/include/ObjectBrowser.h index faa3075..7125e12 100644 --- a/include/ObjectBrowser.h +++ b/include/ObjectBrowser.h @@ -1535,7 +1535,7 @@ class CCopyTable /** @param select : Selected items. */ - wyBool GetSelectStmt(wyString &select); + wyBool GetSelectStmt(wyString &select, wyString &alterQuery , wyWChar new_table[]); /// Function copies the initial field stmt. into the buffer. /** @@ -1640,7 +1640,7 @@ class CCopyTable @param primary : Primary key name. @param flgprimary : Primary flag. */ - wyBool GetKeysPrimeKeyCheck(MYSQL_ROW *myrow, MYSQL_RES *myres, wyString &primary); + wyBool GetKeysPrimeKeyCheck(MYSQL_ROW *myrow, MYSQL_RES *myres, wyString &primary ); /// Handles Include index for getkey() /** diff --git a/include/SQLMaker.h b/include/SQLMaker.h index 9aa4b4e..63973db 100644 --- a/include/SQLMaker.h +++ b/include/SQLMaker.h @@ -72,7 +72,8 @@ wyUInt32 GetSelectTableStmt(wyString &query, const wyChar *dbname); MYSQL_RES *ExecuteAndGetResult(MDIWindow *wnd, Tunnel *tunnel, PMYSQL mysql, wyString &query, wyBool isprofile = wyTrue, wyBool isbatch = wyFalse, wyBool currentwnd = wyTrue, bool isread = false, bool isforce = false, wyBool isimport = wyFalse, - wyInt32 *stop = 0, wyBool isimporthttp = wyFalse); + wyInt32 *stop = 0, wyBool isimporthttp = wyFalse, wyInt32 *isintransaction = NULL, + HWND fortransactionprompt = NULL); /// Executes the query and returns the result set /** diff --git a/include/SQLyog.rc b/include/SQLyog.rc index a1dc470..d47836a 100644 --- a/include/SQLyog.rc +++ b/include/SQLyog.rc @@ -721,6 +721,57 @@ BEGIN MENUITEM SEPARATOR MENUITEM "&Rebuild tags", ID_REBUILDTAGS END + POPUP "T&ransactions" + BEGIN + MENUITEM "Set Autocommit", ID_TRANSACTION_SETAUTOCOMMIT, CHECKED + POPUP "Isolation Level" + BEGIN + MENUITEM "Repeatable Read", ID_TRX_REPEATABLEREAD, CHECKED + MENUITEM "Read Committed", ID_TRX_READCOMMITED + MENUITEM "Read Uncommitted", ID_TRX_READUNCOMMITED + MENUITEM "Serializable", ID_TRX_SERIALIZABLE + END + MENUITEM SEPARATOR + POPUP "Start Transaction" + BEGIN + MENUITEM "With no modifier", ID_STARTTRANSACTION_WITHNOMODIFIER + POPUP "With Consistent Snapshot" + BEGIN + MENUITEM "Read only", ID_WITHCONSISTENTSNAPSHOT_READONLY + MENUITEM "Read Write", ID_WITHCONSISTENTSNAPSHOT_READWRITE + END + MENUITEM SEPARATOR + MENUITEM "Read only", ID_STARTTRANSACTION_READONLY + MENUITEM "Read Write", ID_STARTTRANSACTION_READWRITE + END + POPUP "Commit" + BEGIN + MENUITEM "With no modifier", ID_COMMIT_WITHNOMODIFIER + MENUITEM SEPARATOR + MENUITEM "And Chain", ID_COMMIT_ANDCHAIN + MENUITEM "And No Chain", ID_COMMIT_ANDNOCHAIN + MENUITEM SEPARATOR + MENUITEM "Release", ID_COMMIT_RELEASE + MENUITEM "No Release", ID_COMMIT_NORELEASE + END + POPUP "Rollback" + BEGIN + MENUITEM "To Savepoint", ID_ROLLBACK_TOSAVEPOINT + MENUITEM "Transaction", ID_ROLLBACK_TRANSACTION + MENUITEM SEPARATOR + MENUITEM "And Chain", ID_ROLLBACK_ANDCHAIN + MENUITEM "And No Chain", ID_ROLLBACK_ANDNOCHAIN + MENUITEM SEPARATOR + MENUITEM "Release", ID_ROLLBACK_RELEASE + MENUITEM "No Release", ID_ROLLBACK_NORELEASE + END + POPUP "Savepoint" + BEGIN + MENUITEM "Create Savepoint", ID_SAVEPOINT_CREATESAVEPOINT + MENUITEM SEPARATOR + MENUITEM "Release Savepoint", ID_SAVEPOINT_RELEASESAVEPOINT + END + END POPUP "&Window" BEGIN MENUITEM "&Cascade", IDM_WINDOW_CASCADE @@ -1583,7 +1634,7 @@ BEGIN LTEXT "&Blob viewer",IDC_EDITOR3,8,41,60,9 LTEXT " ",IDC_BLOBFONT,76,41,120,10,SS_WORDELLIPSIS PUSHBUTTON "Change...",IDC_BLOBCHANGE,205,40,41,12 - LTEXT "Ob&ject Browser",IDC_EDITOR5,8,54,60,10 + LTEXT "Ob&ject Browser",IDC_EDITOR5,8,54,60,10 LTEXT " ",IDC_OBFONT,76,54,120,10,SS_WORDELLIPSIS PUSHBUTTON "Change...",IDC_OBCHANGE,205,54,41,12 LTEXT "&Others",IDC_EDITOR4,8,68,60,10 @@ -1780,13 +1831,18 @@ BEGIN EDITTEXT IDC_HIGHLIMIT,95,141,49,12,ES_AUTOHSCROLL | ES_NUMBER CONTROL "Remember setting for each &query",IDC_RESUTTABPAGERETAIN, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,169,127,10 - GROUPBOX "Toolbar Size ",IDC_STATIC,4,185,80,29 - COMBOBOX IDC_ICONSIZE,8,195,71,44,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Theme ",IDC_STATIC,88,185,163,29 - COMBOBOX IDC_THEMECOMBO,93,195,153,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Toolbar Size ",IDC_STATIC,1,225,80,29 + COMBOBOX IDC_ICONSIZE,6,236,71,44,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Theme ",IDC_STATIC,85,225,163,29 + COMBOBOX IDC_THEMECOMBO,90,236,153,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Restore &All Defaults",IDC_OTHERSRESTOREALL,97,262,75,15 PUSHBUTTON "Restore &Tab Defaults",IDC_OTHERSRESTORETAB,176,262,75,15 CONTROL "R&estore session on startup",IDC_CONRESTORE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,74,216,9 + GROUPBOX "Transaction Options",IDC_TRANSACTION,4,185,247,36 + CONTROL "Prompt when query causing implicit commit is executed",IDC_PROMPTTRANSACTION, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,196,197,10 + CONTROL "Prompt when closing sessing or program if transaction is active.",IDC_PROMPTCLOSETRANSACTION, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,208,212,10 END IDD_PREFGENERAL DIALOGEX 0, 0, 255, 280 @@ -1810,8 +1866,7 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,71,225,10 CONTROL "&Show Warning(s) in Messages tab",IDC_SHOWWARNING, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,82,124,10 - CONTROL "Halt Execution of Queries on Error",IDC_HALTEXEC, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,93,124,10 + CONTROL "Halt Execution of Queries on Error",IDC_HALTEXEC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,93,124,10 GROUPBOX "Export Options ",IDC_STATIC,4,106,247,99 GROUPBOX "Max. size (in KB) for BULK INSERT statement(s)",IDC_STATIC,9,116,237,40 CONTROL "&Get server default",IDC_DEF_BULK_SIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,127,112,8 @@ -2158,6 +2213,39 @@ BEGIN LTEXT "",IDC_CONNECTION_NAME,7,7,302,8,SS_ENDELLIPSIS END +IDD_CREATESAVEPOINT DIALOGEX 0, 0, 206, 69 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION " Create Savepoint" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "&Enter new savepoint name",IDC_STATIC,7,7,130,8 + EDITTEXT IDC_SAVEPOINTEDIT,7,20,188,14,ES_AUTOHSCROLL + DEFPUSHBUTTON "&Create",IDOK,89,41,50,14 + PUSHBUTTON "Cance&l",IDCANCEL,145,42,50,14 +END + +IDD_RELEASESAVEPOINT DIALOGEX 0, 0, 174, 72 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Release Savepoint" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "&Release",IDC_STATIC,7,7,61,8 + COMBOBOX IDC_SAVEPOINTRELEASE_COMBO,7,22,155,14,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + DEFPUSHBUTTON "&Release",IDOK,56,44,50,14 + PUSHBUTTON "Cance&l",IDCANCEL,113,44,50,14 +END + +IDD_ROLLBACKTO DIALOGEX 0, 0, 171, 72 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Rollback to Savepoint" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "&Rollback To",IDC_STATIC,7,7,61,8 + COMBOBOX IDC_ROLLBACKTO_COMBO,7,23,154,14,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + DEFPUSHBUTTON "&Rollback",IDOK,55,44,50,14 + PUSHBUTTON "Cance&l",IDCANCEL,111,44,50,14 +END + ///////////////////////////////////////////////////////////////////////////// // @@ -2237,6 +2325,9 @@ IDI_TRUNCDB ICON "..\\include\\bitmaps\\truncated IDI_VIEWDATA ICON "..\\include\\bitmaps\\viewdata.ico" IDI_SORTASC ICON "..\\include\\bitmaps\\sortasc.ico" IDI_DBSYNC ICON "..\\include\\bitmaps\\dbsync.ico" +IDI_COMMIT ICON "..\\include\\bitmaps\\commit.ico" +IDI_ROLLBACK ICON "..\\include\\bitmaps\\rollback.ico" +IDI_START_TRANSACTION ICON "..\\include\\bitmaps\\start_transaction.ico" IDI_PREF ICON "..\\include\\bitmaps\\preferences.ico" IDI_REORDERCOL ICON "..\\include\\bitmaps\\reordercol.ico" IDI_EMPTYTABLE ICON "..\\include\\bitmaps\\emptytable.ico" @@ -2319,6 +2410,9 @@ IDI_FUNCTION ICON "bitmaps\\function.ico" IDI_CONNECT_16 ICON "bitmaps\\connect_16.ico" IDI_COPYDATABASE_16 ICON "bitmaps\\copy_data_16.ico" IDI_DBSYNC_16 ICON "bitmaps\\dbsync_16.ico" +IDI_COMMIT_16 ICON "bitmaps\\commit_16.ico" +IDI_ROLLBACK_16 ICON "bitmaps\\rollback_16.ico" +IDI_START_TRANSACTION_16 ICON "bitmaps\\start_transaction_16.ico" IDI_EXECUTEALL_16 ICON "bitmaps\\execall_16.ico" IDI_EXECUTE_16 ICON "bitmaps\\execute_16.ico" IDI_EXECUTEFORUPD_16 ICON "bitmaps\\execforupd_16.ico" @@ -2748,6 +2842,30 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 35 END + + IDD_CREATESAVEPOINT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 203 + TOPMARGIN, 7 + BOTTOMMARGIN, 62 + END + + IDD_RELEASESAVEPOINT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 171 + TOPMARGIN, 7 + BOTTOMMARGIN, 65 + END + + IDD_ROLLBACKTO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 168 + TOPMARGIN, 7 + BOTTOMMARGIN, 65 + END END #endif // APSTUDIO_INVOKED @@ -3370,6 +3488,13 @@ BEGIN ID_QUERYBUILDER "Add a new Query Builder" END +STRINGTABLE +BEGIN + ID_STARTTRANSACTION_WITHNOMODIFIER "Start a new Transaction" + ID_COMMIT_WITHNOMODIFIER "Commit the ongoing transacton" + ID_ROLLBACK_TRANSACTION "Rollback the transaction" +END + STRINGTABLE BEGIN IDM_EDIT_FINDNEXT " Find the next occurrence" diff --git a/include/TabIndexes.h b/include/TabIndexes.h index d2f8cfd..a34b0d7 100644 --- a/include/TabIndexes.h +++ b/include/TabIndexes.h @@ -37,6 +37,7 @@ struct IndexInfo wyString m_colsstr; List *m_listcolumns; wyString m_indextype; + wyString m_indexcomment; }; class IndexesStructWrapper : public wyElem @@ -78,6 +79,7 @@ class TabIndexes wyBool m_ismysql41; wyBool m_ismariadb52; + wyBool m_ismysql553; // used for Shift+Click functionality wyInt32 m_lastclickindgrid; @@ -169,7 +171,7 @@ class TabIndexes wyBool OnEndEditIndexName(WPARAM wParam, LPARAM lParam); wyBool OnEndEditIndexColumns(WPARAM wParam, LPARAM lParam); wyBool OnEndEditIndexType(WPARAM wParam, LPARAM lParam); - + wyBool OnEndEditIndexComment(WPARAM wParam, LPARAM lParam); /// Shows the Columns Dialog /** diff --git a/include/Version.h b/include/Version.h index 8df3595..677e50b 100644 --- a/include/Version.h +++ b/include/Version.h @@ -1,5 +1,5 @@ #define MAJOR_VERSION_INT 12 -#define MINOR_VERSION_INT 2 -#define UPDATE_VERSION_INT 6 +#define MINOR_VERSION_INT 3 +#define UPDATE_VERSION_INT 0 #define RELEASE_VERSION_INT 0 #define EXTRAINFO "" diff --git a/include/bitmaps/commit.ico b/include/bitmaps/commit.ico new file mode 100644 index 0000000..54004a6 Binary files /dev/null and b/include/bitmaps/commit.ico differ diff --git a/include/bitmaps/commit_16.ico b/include/bitmaps/commit_16.ico new file mode 100644 index 0000000..861e0a1 Binary files /dev/null and b/include/bitmaps/commit_16.ico differ diff --git a/include/bitmaps/rollback.ico b/include/bitmaps/rollback.ico new file mode 100644 index 0000000..6abd577 Binary files /dev/null and b/include/bitmaps/rollback.ico differ diff --git a/include/bitmaps/rollback_16.ico b/include/bitmaps/rollback_16.ico new file mode 100644 index 0000000..1bff52e Binary files /dev/null and b/include/bitmaps/rollback_16.ico differ diff --git a/include/bitmaps/start_transaction.ico b/include/bitmaps/start_transaction.ico new file mode 100644 index 0000000..a37cf8e Binary files /dev/null and b/include/bitmaps/start_transaction.ico differ diff --git a/include/bitmaps/start_transaction_16.ico b/include/bitmaps/start_transaction_16.ico new file mode 100644 index 0000000..0640e15 Binary files /dev/null and b/include/bitmaps/start_transaction_16.ico differ diff --git a/include/resource.h b/include/resource.h index d9e3677..c10daa3 100644 --- a/include/resource.h +++ b/include/resource.h @@ -202,6 +202,9 @@ #define IDI_SDTABLEVIEW 813 #define IDI_EXPORTASIMG 815 #define IDI_SDPRINT 816 +#define IDI_COMMIT 817 +#define IDI_ROLLBACK 818 +#define IDI_START_TRANSACTION 819 #define IDI_ADDTABLES 820 #define IDI_ALTERDB 821 #define IDI_PREVIOUS 824 @@ -214,6 +217,9 @@ #define IDI_EVENT 838 #define IDI_REFRESHCANVAS 839 #define IDR_TABLESMENU 840 +#define IDI_COMMIT_16 841 +#define IDI_ROLLBACK_16 842 +#define IDI_START_TRANSACTION_16 843 #define IDI_SDZOOMIN 845 #define IDI_SDZOOMOUT 846 #define IDI_ALTEREVENT 847 @@ -479,6 +485,7 @@ #define IDC_ENABLEUPGRADE 1064 #define IDD_GETSQLYOGULTIMATE 1064 #define IDD_OBCOLOR 1065 +#define IDC_TRANSACTION 1067 #define IDC_EXPORTFILENAME 1081 #define IDC_PROGRESS 1082 #define IDC_CHK_USEDBNAME 1083 @@ -944,6 +951,9 @@ #define IDC_ISCLEARTEXT 1708 #define IDC_NEVEROPEN 1708 #define IDC_SELCHECK 1708 +#define IDC_CH 1708 +#define IDC_PROMPTTRANSACTION 1708 +#define IDC_PROMPTCLOSETRANSACTION 1710 #define IDC_OPENSEL 1709 #define IDC_PROGRESS2 1712 #define IDC_RESTORE_PROGRESS 1712 @@ -955,6 +965,9 @@ #define IDC_TIMESTAMP_PREFIX 1751 #define IDC_FILE_TABLE 1752 #define IDC_ROWSIDBY 1753 +#define IDC_SAVEPOINTEDIT 1755 +#define IDC_SAVEPOINTRELEASE_COMBO 1756 +#define IDC_ROLLBACKTO_COMBO 1757 #define IDC_INITCOMMANDHELP 2644 #define IDC_COMBOCUSTOM 2645 #define ID_IMPORT_FROMXML 2655 @@ -1544,6 +1557,9 @@ #define ACCEL_INFOTAB 41748 #define ID_QUERYINFO_FIND 41748 #define ID_QUERYINFO_FINDNEXT 41749 +#define ID_TRANSACTION_SETAUTOCOMMIT 41751 +#define ID_TRANSACTION_TRX 41752 +#define ID_TRANSACTION_STARTTRANSACTION 41753 #define ID_OPEN_SELECT 41754 #define ID_OPEN_COPYALL 41755 #define ID_OPEN_SELECTALL41756 41756 @@ -1564,6 +1580,33 @@ #define ID_EDIT_EXPLAIN 41791 #define ID_VDDTOOL 41793 #define ACCEL_VDDTOOL 41796 +#define ID_TRX_REPEATABLEREAD 41797 +#define ID_TRX_READCOMMITED 41798 +#define ID_TRX_READUNCOMMITED 41799 +#define ID_TRX_SERIALIZABLE 41800 +#define ID_STARTTRANSACTION_WITHNOMODIFIER 41801 +#define ID_STARTTRANSACTION_WITHCONSISTENTSNAPSHOT 41802 +#define ID_WITHCONSISTENTSNAPSHOT_READONLY 41803 +#define ID_WITHCONSISTENTSNAPSHOT_READWRITE 41804 +#define ID_STARTTRANSACTION_READONLY 41805 +#define ID_STARTTRANSACTION_READWRITE 41806 +#define ID_TRANSACTIONS_COMMIT 41807 +#define ID_COMMIT_WITHNOMODIFIER 41808 +#define ID_COMMIT_ANDCHAIN 41809 +#define ID_COMMIT_ANDNOCHAIN 41810 +#define ID_COMMIT_RELEASE 41811 +#define ID_COMMIT_NORELEASE 41812 +#define ID_TRANSACTIONS_ROLLBACK 41813 +#define ID_ROLLBACK_TOSAVEPOINT 41814 +#define ID_ROLLBACK_TRANSACTION 41815 +#define ID_ROLLBACK_ANDCHAIN 41816 +#define ID_ROLLBACK_ANDNOCHAIN 41817 +#define ID_ROLLBACK_RELEASE 41818 +#define ID_ROLLBACK_NORELEASE 41819 +#define ID_TRANSACTIONS_SAVEPOINT 41820 +#define ID_SAVEPOINT_CREATESAVEPOINT 41821 +#define ID_SAVEPOINT_RELEASESAVEPOINT 41822 +#define ID_Menu 41823 #define IDC_INITCOMMAND 44114 #define IDC_EDITINITCOMMAND 44115 #define IDC_INVISIBLE 44116 @@ -1588,6 +1631,9 @@ #define ACCEL_ENDSESSION 44135 #define ACCEL_CREATETABLE 44136 #define ID_UNSORT 44137 +#define IDD_CREATESAVEPOINT 44140 +#define IDD_RELEASESAVEPOINT 44141 +#define IDD_ROLLBACKTO 44142 // Next default values for new objects // @@ -1595,7 +1641,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 1018 -#define _APS_NEXT_COMMAND_VALUE 41797 +#define _APS_NEXT_COMMAND_VALUE 41825 #define _APS_NEXT_CONTROL_VALUE 1716 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/include/twilight_theme.xml b/include/twilight_theme.xml index 678c1b5..c4fdfbf 100644 --- a/include/twilight_theme.xml +++ b/include/twilight_theme.xml @@ -1,4 +1,4 @@ - + diff --git a/localization/Strings/String/en/file25.xml b/localization/Strings/String/en/file25.xml index 62b9ab7..049a885 100644 --- a/localization/Strings/String/en/file25.xml +++ b/localization/Strings/String/en/file25.xml @@ -27,5 +27,30 @@ Select Table and Columns To Import In XML Rows Identified by Replace - + T&ransactions + Set Autocommit + Isolation Level + Start Transaction + Commit + Rollback + Savepoint + Repeatable Read + Read Committed + Read Uncommitted + Serializable + With no modifier + With Consistent Snapshot + Read only + Read Write + And Chain + And No Chain + Release + No Release + To Savepoint + Transaction + Create Savepoint + Release Savepoint + Commit Transaction + Rollback Transaction + \ No newline at end of file diff --git a/localization/Strings/String/ja/file25.xml b/localization/Strings/String/ja/file25.xml index a803030..f807a64 100644 --- a/localization/Strings/String/ja/file25.xml +++ b/localization/Strings/String/ja/file25.xml @@ -27,4 +27,29 @@ テーブルとコラムを選択してXMLにインポートしてください。 ~によって判別される行 置換 + &取引 + 自動コミットを設定します。 + 分離レベル + トランザクション開始 + コミット + ロールバック + セーブポイント + 反復可能読み取り + コミット読みます + 非コミット読み取り + 直列化可能 + 無修飾剤 + 一貫性のあるスナップショットと + 読み取り専用 + 読み書き + そしてチェーン + そしてませチェーンはありません + リリース + いいえリリースはありません + セーブポイントへ + トランザクション + セーブポイントを作成します。 + リリースセーブポイント + トランザクションのコミット + ロールバックトランザクション \ No newline at end of file diff --git a/localization/Strings/String/ko/file25.xml b/localization/Strings/String/ko/file25.xml index c1c1cdc..3f35830 100644 --- a/localization/Strings/String/ko/file25.xml +++ b/localization/Strings/String/ko/file25.xml @@ -27,5 +27,30 @@ XML을 불러오기 위해 테이블과 칼럼을 선택 다음에 의해 식별된 열: 바꾸기 + &업무 + 자동 커밋 설정 + 격리 수준 + 시작 트랜잭션 + 범하다 + 롤백 + 세이브 포인트 + 반복 읽기 + 커밋 된 읽기 + 커밋되지 않은 읽기 + 직렬화 + 없는 수정과 + 일관된 스냅 샷으로 + 읽기 전용 + 읽기 쓰기 + 그리고 체인 + 그리고 어떤 체인 없음 + 해제 + 어떤 자료 없음 + 세이브 포인트하려면 + 트랜잭션 + 세이브 포인트를 만들기 + 릴리스 세이브 포인트 + 트랜잭션을 커밋 + 롤백 트랜잭션 \ No newline at end of file diff --git a/localization/Strings/String/zh-cn/file25.xml b/localization/Strings/String/zh-cn/file25.xml index b5f8703..1ad26eb 100644 --- a/localization/Strings/String/zh-cn/file25.xml +++ b/localization/Strings/String/zh-cn/file25.xml @@ -27,4 +27,29 @@ 选择表格和列在XML中导入 行标识方式: 替换 + &交易 + 設置自動提交 + 隔離級別 + 開始交易 + 承諾 + 回滾 + 保存點 + 可重複讀 + 讀已提交 + 未提交讀 + 序列化 + 由於沒有修改 + 有了一致的快照 + 只讀 + 讀寫 + 和鏈條 + 且無鏈 + 發布 + 沒有釋放 + 為了保存點 + 交易 + 創建保存點 + 發布保存點 + 提交事務 + 回滾事務 \ No newline at end of file diff --git a/src/ConnectionBase.cpp b/src/ConnectionBase.cpp index c9b655f..e45c711 100644 --- a/src/ConnectionBase.cpp +++ b/src/ConnectionBase.cpp @@ -1568,7 +1568,8 @@ ConnectionBase::CreateOtherToolButtons(HWND hwndsecondtool, HIMAGELIST hsecondim IDM_DATASYNC, IDC_DIFFTOOL, ID_IMPORT_EXTERNAL_DATA, IDC_TOOLS_NOTIFY, ID_POWERTOOLS_SCHEDULEEXPORT, ID_QUERYBUILDER, - ID_SCHEMADESIGNER + ID_SCHEMADESIGNER , IDM_SEPARATOR, ID_STARTTRANSACTION_WITHNOMODIFIER, + ID_COMMIT_WITHNOMODIFIER, ID_ROLLBACK_TRANSACTION, }; wyUInt32 states[][2] = { @@ -1579,14 +1580,17 @@ ConnectionBase::CreateOtherToolButtons(HWND hwndsecondtool, HIMAGELIST hsecondim {TBSTATE_ENABLED, TBSTYLE_BUTTON}, {TBSTATE_ENABLED, TBSTYLE_BUTTON}, {TBSTATE_ENABLED, TBSTYLE_BUTTON}, {TBSTATE_ENABLED, TBSTYLE_BUTTON}, {TBSTATE_ENABLED, TBSTYLE_BUTTON}, {TBSTATE_ENABLED, TBSTYLE_BUTTON}, - {TBSTATE_ENABLED, TBSTYLE_BUTTON}, {TBSTATE_ENABLED, TBSTYLE_BUTTON}}; + {TBSTATE_ENABLED, TBSTYLE_BUTTON}, {TBSTATE_ENABLED, TBSTYLE_BUTTON}, + {TBSTATE_ENABLED, BTNS_SEP}, {TBSTATE_ENABLED, TBSTYLE_BUTTON}, + {TBSTATE_ENABLED, TBSTYLE_BUTTON}, {TBSTATE_ENABLED, TBSTYLE_BUTTON}}; wyInt32 imgres[] = { IDI_USERMANAGER, IDI_EXPORTDATA, IDI_EXECBATCH, IDI_COPYDATABASE, IDI_XMLHTML, IDI_MANINDEX, IDI_MANREL, IDI_USERS, IDI_FORMATQUERY, IDI_DBSYNC, IDI_DIFFTOOL, IDI_ODBC, - IDI_NOTIFICATION, IDI_SCHDEXPORT, IDI_QUERYBUILDER, IDI_SCHEMADESIGNER + IDI_NOTIFICATION, IDI_SCHDEXPORT, IDI_QUERYBUILDER, IDI_SCHEMADESIGNER, + IDI_USERS, IDI_START_TRANSACTION, IDI_COMMIT, IDI_ROLLBACK }; @@ -1921,6 +1925,15 @@ ConnectionBase::OnToolTipInfo(LPNMTTDISPINFO lpnmtdi, wyWChar *string) case ID_SCHEMADESIGNER: wcscpy(string, _(L"New Schema Designer (Ctrl+Alt+D)")); break; + case ID_STARTTRANSACTION_WITHNOMODIFIER: + wcscpy(string, _(L"Start Transaction")); + break; + case ID_COMMIT_WITHNOMODIFIER: + wcscpy(string, _(L"Commit Transaction")); + break; + case ID_ROLLBACK_TRANSACTION: + wcscpy(string, _(L"Rollback Transaction")); + break; } return; @@ -1944,8 +1957,9 @@ ConnectionBase::EnableToolButtonsAndCombo(HWND hwndtool, HWND hwndsecondtool, HW ID_OBJECT_MAINMANINDEX, ACCEL_MANREL, ID_FORMATCURRENTQUERY, IDC_DIFFTOOL, ID_QUERYBUILDER, ID_SCHEMADESIGNER, - IDM_TOOL_ADDUSER - }; + IDM_TOOL_ADDUSER, ID_STARTTRANSACTION_WITHNOMODIFIER, + ID_COMMIT_WITHNOMODIFIER, ID_ROLLBACK_TRANSACTION + }; /* Enable/Disable all the toolbuttons */ for(itemcount = 0; itemcount < (sizeof(tbid)/sizeof(tbid[0])); itemcount++) diff --git a/src/ConnectionCommunity.cpp b/src/ConnectionCommunity.cpp index edb949f..dc3fc8e 100644 --- a/src/ConnectionCommunity.cpp +++ b/src/ConnectionCommunity.cpp @@ -1043,7 +1043,23 @@ ConnectionCommunity::CreateIconList(HWND hwndmain, wyUInt32 *numicons) ID_EDIT_LISTMATCHINGTAGS, ID_EDIT_LISTFUNCTIONANDROUTINEPARAMETERS, ID_OBJECT_COPY, ID_OBJECT_FIND, ID_OPEN_COPY, ID_QUERYINFO_FIND, - ID_OPEN_SAVEHISTORY, ID_VDDTOOL + ID_OPEN_SAVEHISTORY, ID_VDDTOOL, + ID_STARTTRANSACTION_WITHNOMODIFIER, + ID_COMMIT_WITHNOMODIFIER, ID_ROLLBACK_TRANSACTION, + ID_TRANSACTION_SETAUTOCOMMIT, ID_TRX_REPEATABLEREAD, + ID_TRX_READCOMMITED, ID_TRX_READUNCOMMITED, + ID_TRX_SERIALIZABLE, ID_WITHCONSISTENTSNAPSHOT_READONLY, + ID_WITHCONSISTENTSNAPSHOT_READWRITE, + ID_STARTTRANSACTION_READONLY, ID_STARTTRANSACTION_READWRITE, + ID_COMMIT_ANDCHAIN, ID_COMMIT_ANDNOCHAIN, + ID_COMMIT_RELEASE, ID_COMMIT_NORELEASE, + ID_ROLLBACK_TOSAVEPOINT, ID_ROLLBACK_TRANSACTION, + ID_ROLLBACK_ANDCHAIN, ID_ROLLBACK_RELEASE, + ID_ROLLBACK_ANDNOCHAIN, ID_ROLLBACK_NORELEASE, + ID_SAVEPOINT_CREATESAVEPOINT, ID_SAVEPOINT_RELEASESAVEPOINT + + + }; wyUInt32 iconid[] = { @@ -1115,8 +1131,19 @@ ConnectionCommunity::CreateIconList(HWND hwndmain, wyUInt32 *numicons) IDI_ENTMENU, IDI_ENTMENU, IDI_COPY, IDI_FIND, IDI_COPY, IDI_FIND, - IDI_SAVE, IDI_ENTMENU - + IDI_SAVE, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU, + IDI_ENTMENU, IDI_ENTMENU }; //From 7.0 version we are adding all the menus in Enterprise to Community. for this we are using IDI_ENTMENU. *numicons = size = sizeof(ids)/ sizeof(ids[0]); @@ -1303,6 +1330,34 @@ ConnectionCommunity::OnWmCommand(HWND hwndactive, MDIWindow *wnd, WPARAM wparam) m_powertoolsID = 0; } break; + case ID_TRANSACTION_SETAUTOCOMMIT: + case ID_TRX_REPEATABLEREAD: + case ID_TRX_READCOMMITED: + case ID_TRX_READUNCOMMITED: + case ID_TRX_SERIALIZABLE: + case ID_STARTTRANSACTION_WITHNOMODIFIER: + case ID_WITHCONSISTENTSNAPSHOT_READONLY: + case ID_WITHCONSISTENTSNAPSHOT_READWRITE: + case ID_STARTTRANSACTION_READONLY: + case ID_STARTTRANSACTION_READWRITE: + case ID_COMMIT_WITHNOMODIFIER: + case ID_COMMIT_ANDCHAIN: + case ID_COMMIT_ANDNOCHAIN: + case ID_COMMIT_RELEASE: + case ID_COMMIT_NORELEASE: + case ID_ROLLBACK_TOSAVEPOINT: + case ID_ROLLBACK_TRANSACTION: + case ID_ROLLBACK_ANDCHAIN: + case ID_ROLLBACK_ANDNOCHAIN: + case ID_ROLLBACK_RELEASE: + case ID_ROLLBACK_NORELEASE: + case ID_SAVEPOINT_CREATESAVEPOINT: + case ID_SAVEPOINT_RELEASESAVEPOINT: + { + GetSQLyogEntDialog(); + break; + } + } return wyFalse; } diff --git a/src/CopyDatabase.cpp b/src/CopyDatabase.cpp index b568401..c7f5e7a 100644 --- a/src/CopyDatabase.cpp +++ b/src/CopyDatabase.cpp @@ -82,6 +82,7 @@ CopyDatabase::CopyDatabase() m_iscopytrigger=wyFalse; m_dblist = NULL; m_countdb = 0; + m_defaultdbindex = 0; } CopyDatabase::~CopyDatabase() @@ -100,6 +101,7 @@ CopyDatabase::~CopyDatabase() { free(m_dblist); m_countdb=0; + m_defaultdbindex = 0; } } @@ -2388,9 +2390,10 @@ CopyDatabase::ExportData(LPGUI_COPYDB_UPDATE_ROUTINE gui_routine, void * lpParam virt_query.Sprintf("SHOW FIELDS FROM `%s`.`%s`",m_srcdb.GetString(), table->m_tablefld.GetString()); virt_res = SjaExecuteAndGetResult(m_newsrctunnel, &m_newsrcmysql, virt_query); + if(virt_res) no_rows = m_newsrctunnel->mysql_num_rows(virt_res); - if(!virt_res && no_rows == -1) + if(!virt_res || no_rows == -1) { ShowMySQLError(m_hwnddlg, m_newsrctunnel, &m_newsrcmysql); return wyFalse; @@ -3793,7 +3796,8 @@ CopyDatabase::CheckTargetDB(HWND m_hwnddlg) //m_iscreatedb = wyTrue; //} - SendMessage(m_hwndcombodb, CB_SETCURSEL , 0, 0); + SendMessage(m_hwndcombodb, CB_SETCURSEL , m_defaultdbindex , 0); + m_defaultdbindex = 0; VERIFY(m_targetmysql = lpdiff->mysql); VERIFY(m_targettunnel = lpdiff->tunnel); VERIFY(m_tgtinfo = lpdiff->info); @@ -3814,22 +3818,33 @@ CopyDatabase::CheckTargetDB(HWND m_hwnddlg) } void - CopyDatabase::FillDbList(){ - wyWChar lbStr[70] = {0}; - if(m_dblist) - { + CopyDatabase::FillDbList() +{ + wyString temp; + wyString temp1; + wyWChar lbStr[70] = {0}; + temp.SetAs(m_srcdb.GetString()); + + if(m_dblist) + { free(m_dblist); - m_countdb=0; - } + m_countdb = 0; + } + m_countdb = SendMessage(m_hwndcombodb, CB_GETCOUNT, 0, 0); m_dblist = (DB_LIST*)calloc(m_countdb,sizeof(DB_LIST)); - for(int i=0;i< m_countdb ; i++){ + for(int i=0;i< m_countdb ; i++) + { SendMessage(m_hwndcombodb, CB_GETLBTEXT , i, (LPARAM)lbStr); m_dblist[i].m_dbname.SetAs(lbStr); + temp1.SetAs(lbStr); m_dblist[i].m_dropdown = wyTrue; + if(temp.CompareI(temp1.GetString())==0) + { + m_defaultdbindex = i; + } } - } wyBool CopyDatabase::CreateTemporaryTables(const wyChar *db, const wyChar *view) diff --git a/src/CustGrid.cpp b/src/CustGrid.cpp index ce8d9a3..4a065af 100644 --- a/src/CustGrid.cpp +++ b/src/CustGrid.cpp @@ -164,7 +164,6 @@ HWND CreateCustomGrid(HWND hwndparent, wyInt32 x, wyInt32 y, wyInt32 width, { HWND hwndgrid; - hwndgrid = CreateWindowEx(WS_EX_WINDOWEDGE, customname, TEXT("Custom Grid Control"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, x, y, width, height, hwndparent, NULL, @@ -174,9 +173,7 @@ HWND CreateCustomGrid(HWND hwndparent, wyInt32 x, wyInt32 y, wyInt32 width, return NULL; SendMessage(hwndgrid, GVM_SETLONGDATA, 0, lparam); - CustomGrid_ShowGrid(hwndgrid, isvisible); - return hwndgrid; } @@ -184,7 +181,9 @@ HWND CreateCustomGridEx(HWND hwndparent, wyInt32 x, wyInt32 y, wyInt32 width, wy GVWNDPROC m_lpgvwndproc, DWORD styles, LPARAM lparam, wyBool isvisible, wyBool flip) { HWND hwndgrid; - + HWND pct; + CCustGrid *pcg; + TOOLINFO toolinfo; hwndgrid = CreateWindowEx(WS_EX_WINDOWEDGE, customname, TEXT("Custom Grid Control"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, x, y, width, height, hwndparent, NULL, @@ -199,6 +198,37 @@ HWND CreateCustomGridEx(HWND hwndparent, wyInt32 x, wyInt32 y, wyInt32 width, wy CustomGrid_ShowGrid(hwndgrid, isvisible); + + if(styles & GV_EX_COL_TOOLTIP) { + memset(&toolinfo, 0, sizeof(toolinfo)); + pcg = GetCustCtrlData(hwndgrid); + + pcg->m_hwndtooltip = CreateWindowEx(WS_EX_TOPMOST, + TOOLTIPS_CLASS, + NULL, + WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + hwndgrid, + NULL, + GetModuleHandle(0), + NULL); + + SetWindowPos(pcg->m_hwndtooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + + toolinfo.cbSize = sizeof(TOOLINFO); + toolinfo.uFlags = TTF_SUBCLASS | TTF_ABSOLUTE | TTF_IDISHWND; + toolinfo.hinst = GetModuleHandle(0); + toolinfo.hwnd = hwndgrid; + toolinfo.lpszText = LPSTR_TEXTCALLBACK; + toolinfo.uId = (UINT_PTR)hwndgrid; + GetClientRect(hwndgrid, &toolinfo.rect); + SendMessage(pcg->m_hwndtooltip, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO)&toolinfo); + SendMessage(pcg->m_hwndtooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, 800); + } + return hwndgrid; } @@ -894,11 +924,16 @@ CCustGrid::CCustGrid(HWND hwnd) m_pointlbuttondown.y = 0; m_ispressed = wyFalse; + g_bMouseTrack = wyFalse; m_tox = 0; m_selallinfo.checkstate = BST_UNCHECKED; m_checkcount = 0; m_hItalicsFont = NULL; + m_hwndtooltip = NULL; + m_mouseprevpt.x = 0; + m_mouseprevpt.y = 0; + m_tooltipidindex = 0; // Tooltip unique id is set to zero } CCustGrid::~CCustGrid() @@ -914,15 +949,24 @@ CCustGrid::~CCustGrid() if(m_hItalicsFont) DeleteObject(m_hItalicsFont); + + if(m_hwndtooltip) + DestroyWindow(m_hwndtooltip); + + m_tooltipidindex = 0; // restting the tooltip unique id to zero so they are reassigned from zero again } + LRESULT CALLBACK CCustGrid::CustomGridWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { + wyInt32 x; LRESULT ret; //retrieve the custom structure POINTER for THIS window CCustGrid *pcg = GetCustCtrlData(hwnd); wyBool ikeypressshandled = wyFalse; + wyWChar* tooltip = NULL; + RECT rect; switch(msg) { @@ -961,13 +1005,24 @@ CCustGrid::CustomGridWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) case WM_MOUSEMOVE: { pcg->GetMouseMovement(); - if(wparam & MK_LBUTTON) + if(wparam & MK_LBUTTON) { pcg->m_lpgvwndproc(hwnd, GVN_LBUTTONMOUSEMOVE, (WPARAM)0, (LPARAM)lparam); break; } - return pcg->OnMouseMove(wparam, lparam); + if(!pcg->g_bMouseTrack) + { + TRACKMOUSEEVENT tme = {0}; + DWORD dwPos = GetMessagePos(); + POINTS pts = MAKEPOINTS(dwPos); + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_HOVER | TME_LEAVE; + tme.hwndTrack = hwnd; + tme.dwHoverTime = 300;//HOVER_DEFAULT; + pcg->g_bMouseTrack = (wyBool)TrackMouseEvent(&tme); + } + return pcg->OnMouseMove(wparam, lparam); } case WM_NOTIFY: @@ -991,8 +1046,9 @@ CCustGrid::CustomGridWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) else ret = pcg->OnHScroll(hwnd, wparam, lparam); - pcg->m_lpgvwndproc(hwnd, GVN_HSCROLL, wparam, lparam); - return ret; + pcg->m_lpgvwndproc(hwnd, GVN_HSCROLL, wparam, lparam); + + return ret; case WM_LBUTTONDOWN: SetFocus(hwnd); @@ -1064,6 +1120,15 @@ CCustGrid::CustomGridWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) case WM_MOUSELEAVE: pcg->m_lpgvwndproc(hwnd, GVN_MOUSELEAVE, wparam, lparam); + pcg->g_bMouseTrack = wyFalse; + /*if(pcg->m_hwndtooltip) + { + // SendMessage(pcg->m_hwndtooltip, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &pcg->m_toolinfo); + // pcg->m_hwndtooltip = NULL; + } + // DestroyWindow(pcg->m_hwndtooltip); + // pcg->m_hwndtooltip = NULL; + */ break; case WM_SIZE: @@ -1090,7 +1155,19 @@ CCustGrid::CustomGridWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) void CCustGrid::GetMouseMovement() { - TRACKMOUSEEVENT te; + POINT pnt; + TRACKMOUSEEVENT te; + + if(m_hwndtooltip) + { + GetCursorPos(&pnt); + ScreenToClient(m_hwnd, &pnt); + + if(pnt.x != m_mouseprevpt.x || pnt.y != m_mouseprevpt.y) { + m_mouseprevpt = pnt; + SendMessage(m_hwndtooltip, TTM_POP, 0, 0); + } + } //Here Throwing the WM_MOUSELEAVE Message te.cbSize = sizeof(TRACKMOUSEEVENT); @@ -1210,6 +1287,7 @@ CCustGrid::SplitterWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) case WM_LBUTTONUP: pcg->OnSplitterButtonUp(wparam, lparam); ReleaseCapture(); + pcg->m_lpgvwndproc(hwnd, GVN_RESETDATAVIEWTOOLTIP, 0, 0); // To Reset the tooltip break; } return(DefWindowProc(hwnd, msg, wparam, lparam)); @@ -1737,8 +1815,11 @@ LRESULT CCustGrid::OnWMNotify(WPARAM wparam, LPARAM lparam) { LPNMLVKEYDOWN lpnmlv =(LPNMLVKEYDOWN)lparam; + LPNMTTDISPINFO lpnmttd = (LPNMTTDISPINFO)lparam; LONG ret; wyString moldcoltextstr; + wyInt32 x; + RECT rect; if(lpnmlv->hdr.code == LVN_KEYDOWN) { @@ -1771,6 +1852,14 @@ CCustGrid::OnWMNotify(WPARAM wparam, LPARAM lparam) ShowWindow(m_hwndcurcombo, FALSE); //ProcessTabPress(); } + } else if(lpnmlv->hdr.code == TTN_GETDISPINFO) { + x = GetHoveredColumn(); + lpnmttd->szText[0] = '\0'; + + if(x != -1) + { + m_lpgvwndproc(m_hwnd, GVN_TOOLTIP, x, (LPARAM)&lpnmttd->lpszText); + } } return 0; @@ -2971,7 +3060,7 @@ CCustGrid::DrawRowButtons(HDC hdcmem, RECT *rect, RECT *recttemp, wyInt32 *rowco } } } - + wyInt32 CCustGrid::GetRemainingRows(PRECT rectwin) { @@ -4263,6 +4352,28 @@ CCustGrid::OnSplitterButtonUp(WPARAM wparam, LPARAM lparam) return 1; } +wyInt32 CCustGrid::GetHoveredColumn() + { + POINT pnt; + wyInt32 x; + + GetCursorPos(&pnt); + ScreenToClient(m_hwnd, &pnt); + + if(m_flip == wyTrue) + x = m_maxwidth; + else + x = GV_DEFWIDTH; + + if(pnt.y <= m_hight && pnt.x > x) + { + return GetRowHeader(&pnt); + } + + return -1; + } + + LRESULT CCustGrid::OnLButtonDown(WPARAM wparam, LPARAM lparam) @@ -9013,7 +9124,7 @@ CCustGrid::GetLinesToScrollUserSetting() wyInt32 -CCustGrid::GetRowHeader(POINT *pnt) +CCustGrid::GetRowHeader(POINT *pnt, RECT* rect) { PGVCOLNODE pgvnode = m_collist; PGVROWNODE pgvrownode = m_rowlist; @@ -9039,8 +9150,16 @@ CCustGrid::GetRowHeader(POINT *pnt) count = 0; while(pgvrownode != NULL) { - if(pnt->x >= x && pnt->x <= x + pgvrownode->rowcx) + if(pnt->x >= x && pnt->x <= x + pgvrownode->rowcx) { + if(rect) { + rect->left = x; + rect->right = x + pgvrownode->rowcx; + rect->top = 0; + rect->bottom = m_hight; + } + return m_initrow + count; + } count++; @@ -9061,8 +9180,16 @@ CCustGrid::GetRowHeader(POINT *pnt) count = 0; while(pgvnode != NULL) { - if(pgvnode && pgvnode->isshow == wyTrue && pnt->x >= x && pnt->x <= x + pgvnode->pColumn.cx) + if(pgvnode && pgvnode->isshow == wyTrue && pnt->x >= x && pnt->x <= x + pgvnode->pColumn.cx) { + if(rect) { + rect->left = x; + rect->right = x + pgvnode->pColumn.cx; + rect->top = 0; + rect->bottom = m_hight; + } + return m_initcol + count; + } count++; diff --git a/src/DataView.cpp b/src/DataView.cpp index 8663d20..7725bd2 100644 --- a/src/DataView.cpp +++ b/src/DataView.cpp @@ -1511,7 +1511,7 @@ DataView::CreateGrid() m_hwndgrid = CreateCustomGridEx(m_hwndframe, 0, 0, 0, 0, m_gridwndproc, - GV_EX_ROWCHECKBOX | GV_EX_OWNERDATA, (LPARAM)this); + GV_EX_ROWCHECKBOX | GV_EX_OWNERDATA | GV_EX_COL_TOOLTIP, (LPARAM)this); CustomGrid_SetOwnerData(m_hwndgrid, wyTrue); SetGridFont(); @@ -2872,6 +2872,18 @@ DataView::ThreadStopStatus(wyInt32 stop) wyBool DataView::Stop(wyInt32 buttonid) { + wyInt32 presult = 6; +#ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0 && m_wnd->m_ptransaction && !m_wnd->m_ptransaction->m_starttransactionenabled) + { + presult = MessageBox(m_wnd->m_pcqueryobject->m_hwnd, _(L"The session has an active transaction. Stopping the execution will cause transaction to rollback and end. Do you want to continue?"), + _(L"Warning"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + if(presult == 6) + m_wnd->m_ptransaction->CallOnCommit(); + } + if(presult != 6) + return wyFalse; //dosent matter for professional, as initial value of presult is 6 +#endif //set the thread stop status and disable the button ThreadStopStatus(1); EnableToolButton(wyFalse, buttonid); @@ -7039,6 +7051,7 @@ DataView::CreateColumns(wyBool isupdate) //get the original column name GetColumnName(column, k); + //if we are recreating the columns if(isupdate == wyFalse) { @@ -7552,9 +7565,18 @@ LRESULT CALLBACK DataView::GridWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { DataView* pviewdata = (DataView*)CustomGrid_GetLongData(hwnd); + static wyString tooltip; switch(message) { + case GVN_MOUSELEAVE: + return TRUE; + + case GVN_TOOLTIP: + pviewdata->OnColNameMouseHover(wparam, tooltip); + *((wyWChar**)lparam) = tooltip.GetAsWideChar(); + return TRUE; + //handle draw select all check case GVN_DRAWSELECTALL: pviewdata->OnDrawSelectAllCheck(lparam); @@ -7708,11 +7730,28 @@ DataView::GridWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) //handle sys key down case GVN_SYSKEYDOWN: return pviewdata->OnSysKeyDown(wparam, lparam); + break; } return TRUE; } +void +DataView::OnColNameMouseHover(WPARAM wparam, wyString& column) +{ + wyString columntype; + GetColumnName(column, wparam); + + if(!m_data->m_fieldres) + return; + + columntype.SetAs(GetDataType(m_wnd->m_tunnel, m_data->m_fieldres, (wyChar*)column.GetString())); + if(columntype.GetLength() == 0) + return; + column.AddSprintf("-"); + column.AddSprintf(columntype.GetString()); +} + //function to persist the width of a column, typically called when the splitter in grid moves void DataView::OnSplitterMove(wyInt32 col) diff --git a/src/EditorProcs.cpp b/src/EditorProcs.cpp index da6e897..b19c398 100644 --- a/src/EditorProcs.cpp +++ b/src/EditorProcs.cpp @@ -151,9 +151,12 @@ EditorProcs::ExecuteAllQuery(wyInt32 * stop) GetCompleteText(query); wyChar *tmp = AllocateBuff(query.GetLength() + 1); strcpy(tmp,query.GetString()); - ChangeCRToLF(tmp); - query.SetAs(tmp); + wyChar *tmp1 = AllocateBuff(query.GetLength() * 2 + 1); + AddCRToLF(tmp, tmp1); + //ChangeCRToLF(tmp); + query.SetAs(tmp1); free(tmp); + free(tmp1); /* set the flag to executing */ wnd->SetExecuting(wyTrue); *stop = 0; diff --git a/src/FrameWindow.cpp b/src/FrameWindow.cpp index 4f668ea..d4062d4 100644 --- a/src/FrameWindow.cpp +++ b/src/FrameWindow.cpp @@ -69,6 +69,7 @@ #include "DatabaseSearch.h" #include "VisualDataDiff.h" #include "QueryAnalyzerEnt.h" +#include "Transactions.h" #endif #ifdef COMMUNITY @@ -95,6 +96,8 @@ extern PGLOBALS pGlobals; #define MNU_SCHEMADESIGNER 9 #define MNU_REBUILDTAGS 12 #define ZERO 0 +#define TRIAL_DAYS_LEFT 14 +#define IN_TRANSACTION -10 #define FIRSTTOOLICONCOUNT 6 @@ -155,7 +158,10 @@ FrameWindow::FrameWindow(HINSTANCE hinstance) pGlobals->m_prefpersist=wyIni::IniGetInt(GENERALPREFA, "PrefPersist", GENERALPREF_PAGE, dirstr.GetString()); wyIni::IniGetString(GENERALPREFA, "EdgeColumn", "0", §ion, dirstr.GetString()); m_editorcolumnline = section.GetAsInt32(); - +#ifndef COMMUNITY + m_topromptonimplicit = wyIni::IniGetInt(GENERALPREFA, "PromptinTransaction", 1, dirstr.GetString())? wyTrue: wyFalse; + m_topromptonclose = wyIni::IniGetInt(GENERALPREFA, "PromptinTransactionClose", 1, dirstr.GetString())? wyTrue: wyFalse; +#endif wyIni::IniGetString("UserInterface", "Language", "en", §ion, dirstr.GetString()); count = GetModuleFileName(NULL, directory, MAX_PATH - 1); directory[count - pGlobals->m_modulenamelength] = '\0'; @@ -219,6 +225,10 @@ FrameWindow::FrameWindow(HINSTANCE hinstance) m_trialtextfont = NULL; m_trialbuyfont = NULL; m_mouseoverbuy = wyFalse; +#ifndef COMMUNITY + m_closealltrans = 0; + m_intransaction = 0; +#endif #ifdef COMMUNITY m_commribbon = NULL; #endif @@ -872,6 +882,11 @@ FrameWindow::CreateMainWindow(HINSTANCE hinstance) MoveToInitPos(hwnd); val = m_connection->CheckRegistration(m_hwndmain, this); + + if(!pGlobals->m_entlicense.CompareI("Professional")) + { + RemoveMenu(GetMenu(hwnd), MNUTRANSACTION_INDEX - 1, MF_BYPOSITION); + } ///Handle UUID for upgrade check m_connection->HandleApplicationUUID(); @@ -1717,7 +1732,7 @@ FrameWindow::CreateToolBarWindow() wyUInt32 exstyle = NULL; wyUInt32 style = TBSTYLE_CUSTOMERASE | WS_CHILD | CCS_NORESIZE | CCS_NOPARENTALIGN | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT | CCS_NODIVIDER; WNDPROC wndproc; - wyUInt32 daysleft = 14; + wyUInt32 daysleft = TRIAL_DAYS_LEFT; static const char * (CDECL *pwine_get_version)(void); HMODULE hntdll; //Make sure destroy all toolbar resources during the chage of icon size @@ -2451,6 +2466,7 @@ FrameWindow::OnWmCommand(WPARAM wParam) HMENU hmenu; #ifndef COMMUNITY TabDbSearch *ptabdbsearch = NULL; + Transactions *ptransaction = NULL; #endif if(hwndactive) @@ -2481,6 +2497,8 @@ FrameWindow::OnWmCommand(WPARAM wParam) { ptabdbsearch = (TabDbSearch*) pcquerywnd->m_pctabmodule->GetActiveTabType(); } + ptransaction = (Transactions*) GetActiveWin()->m_ptransaction; + #endif //connection tab object @@ -2626,7 +2644,67 @@ FrameWindow::OnWmCommand(WPARAM wParam) case IDC_TOOLCOMBO: HandleToolCombo(wParam); break; +#ifndef COMMUNITY + + case ID_TRANSACTION_SETAUTOCOMMIT: + VERIFY(hmenu = GetMenu(m_hwndmain)); + ptransaction->EnabledisableAutoCommit(hmenu, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql); + break; + + case ID_TRX_REPEATABLEREAD: + case ID_TRX_READCOMMITED: + case ID_TRX_READUNCOMMITED: + case ID_TRX_SERIALIZABLE: + VERIFY(hmenu = GetMenu(m_hwndmain)); + ptransaction->HandletrxIsolationmode(LOWORD(wParam), hmenu, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql); + + break; + + case ID_STARTTRANSACTION_WITHNOMODIFIER: + case ID_WITHCONSISTENTSNAPSHOT_READONLY: + case ID_WITHCONSISTENTSNAPSHOT_READWRITE: + case ID_STARTTRANSACTION_READONLY: + case ID_STARTTRANSACTION_READWRITE: + ptransaction->HandleStartTransaction(LOWORD(wParam), pcquerywnd->m_tunnel, &pcquerywnd->m_mysql); + + break; + + case ID_COMMIT_WITHNOMODIFIER: + case ID_COMMIT_ANDCHAIN: + case ID_COMMIT_ANDNOCHAIN: + case ID_COMMIT_RELEASE: + case ID_COMMIT_NORELEASE: + VERIFY(hmenu = GetMenu(m_hwndmain)); + ptransaction->HandleCommit(LOWORD(wParam), hmenu, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql); + + break; + + case ID_ROLLBACK_TRANSACTION: + case ID_ROLLBACK_ANDCHAIN: + case ID_ROLLBACK_ANDNOCHAIN: + case ID_ROLLBACK_RELEASE: + case ID_ROLLBACK_NORELEASE: + VERIFY(hmenu = GetMenu(m_hwndmain)); + ptransaction->HandleRollback(LOWORD(wParam), hmenu, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql); + + break; + + case ID_SAVEPOINT_CREATESAVEPOINT: + + if(hwndactive) + { + ptransaction->HandleCreateSavepoint(hwndactive, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql); + } + break; + + case ID_SAVEPOINT_RELEASESAVEPOINT: + ptransaction->HandleReleaseSavepoint(hwndactive, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql); + break; + case ID_ROLLBACK_TOSAVEPOINT: + ptransaction->HandleRollbackTo(hwndactive, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql); + break; +#endif case IDM_EXECUTE: case ACCEL_QUERYUPDATE: case ACCEL_QUERYUPDATE_KEY: @@ -2732,8 +2810,27 @@ FrameWindow::OnWmCommand(WPARAM wParam) } break; case ACCEL_OPENSESSION: - case ID_OPENSESSION: - //Dialog to save current session + case ID_OPENSESSION: + { +#ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0) + { + MDIWindow *wnd = GetActiveWin(); + wyInt32 presult = 6; + if(wnd && wnd->m_ptransaction && wnd->m_ptransaction->m_starttransactionenabled == wyFalse && pGlobals->m_pcmainwin->m_topromptonclose == wyTrue) + { + presult = MessageBox(wnd->m_hwnd , _(L"One or more session(s) have (a) transaction(s) running. Do you still want to continue? The transaction will be rolled back by the server."), + _(L"Warning"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + if(presult != 6) + { + break; + } + pGlobals->m_pcmainwin->m_closealltrans = IN_TRANSACTION; + pGlobals->m_pcmainwin->m_intransaction = 0; + } + } +#endif + //Dialog to save current session wyInt32 msgreturn; if(hwndactive) if(WaitForSingleObject(m_sessionchangeevent, 0) == WAIT_OBJECT_0) @@ -2749,15 +2846,43 @@ FrameWindow::OnWmCommand(WPARAM wParam) break; } OpenSessionFile(); +#ifndef COMMUNITY +pGlobals->m_pcmainwin->m_closealltrans = 1; +#endif + } break; case ACCEL_ENDSESSION: case ID_CLOSESESSION: + { + #ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0) + { + MDIWindow *wnd = GetActiveWin(); + wyInt32 presult = 6; + if(wnd && wnd->m_ptransaction && pGlobals->m_pcmainwin->m_intransaction != 0 && wnd->m_ptransaction->m_starttransactionenabled == wyFalse && pGlobals->m_pcmainwin->m_topromptonclose == wyTrue) + { + presult = MessageBox(wnd->m_hwnd , _(L"One or more session(s) have (a) transaction(s) running. Do you still want to continue? The transaction will be rolled back by the server."), + _(L"Warning"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + if(presult != 6) + { + break; + } + pGlobals->m_pcmainwin->m_closealltrans = IN_TRANSACTION; + pGlobals->m_pcmainwin->m_intransaction = 0; + } + } +#endif m_sessionfile.Clear(); m_sessionname.Clear(); VERIFY(hmenu = GetMenu(m_hwndmain)); EnableMenuItem(hmenu, ID_CLOSESESSION, MF_GRAYED | MF_BYCOMMAND); if(hwndactive) pcquerywnd->SetQueryWindowTitle(); + +#ifndef COMMUNITY +pGlobals->m_pcmainwin->m_closealltrans = 1; +#endif + } break; case ID_FILE_CLOSETAB: case ACCEL_CLOSETAB: @@ -4829,7 +4954,13 @@ FrameWindow::OnActiveConn() ID_OBJECT_DROPFIELD, ID_COLUMNS_DROPINDEX, ID_OBJECT_MAINMANINDEX, IDM_TABLE_RELATION, IDM_WINDOW_CASCADE, IDM_WINDOW_TILE, IDM_WINDOWS_ICONARRANGE, ID_OPEN_COPYTABLE, ID_IMPORTEXPORT_DBEXPORTTABLES2, ID_IMEX_TEXTFILE2, ID_REBUILDTAGS, ID_ORGANIZEFAVORITES, ID_REFRESHFAVORITES, - ID_EXPORT_EXPORTTABLEDATA, ID_OBJECT_EXPORTVIEW, IDM_DB_REFRESHOBJECT, ID_DATASEARCH}; + ID_EXPORT_EXPORTTABLEDATA, ID_OBJECT_EXPORTVIEW, IDM_DB_REFRESHOBJECT, ID_DATASEARCH, ID_TRANSACTION_SETAUTOCOMMIT, ID_TRX_REPEATABLEREAD, ID_TRX_READCOMMITED, ID_TRX_READUNCOMMITED, + ID_TRX_SERIALIZABLE, ID_WITHCONSISTENTSNAPSHOT_READONLY, + ID_WITHCONSISTENTSNAPSHOT_READWRITE, ID_STARTTRANSACTION_READONLY, ID_STARTTRANSACTION_READWRITE, + ID_COMMIT_ANDCHAIN, ID_COMMIT_ANDNOCHAIN, ID_COMMIT_RELEASE, + ID_COMMIT_NORELEASE, ID_ROLLBACK_TOSAVEPOINT, ID_ROLLBACK_ANDCHAIN, + ID_ROLLBACK_ANDNOCHAIN, ID_ROLLBACK_RELEASE, ID_ROLLBACK_NORELEASE, ID_SAVEPOINT_CREATESAVEPOINT, + ID_SAVEPOINT_RELEASESAVEPOINT}; if(pGlobals->m_conncount == 0) { @@ -4847,6 +4978,10 @@ FrameWindow::OnActiveConn() EnableMenuItem(hmenu, ID_QUERYBUILDER, MF_GRAYED | MF_BYCOMMAND); EnableMenuItem(hmenu, ID_SCHEMADESIGNER, MF_GRAYED | MF_BYCOMMAND); + EnableMenuItem(hmenu, ID_STARTTRANSACTION_WITHNOMODIFIER, MF_GRAYED | MF_BYCOMMAND); + EnableMenuItem(hmenu, ID_COMMIT_WITHNOMODIFIER, MF_GRAYED | MF_BYCOMMAND); + EnableMenuItem(hmenu, ID_ROLLBACK_TRANSACTION, MF_GRAYED | MF_BYCOMMAND); + //disable format query options EnableMenuItem(hmenu, ACCEL_FORMATALLQUERIES, MF_GRAYED | MF_BYCOMMAND); EnableMenuItem(hmenu, ACCEL_FORMATCURRENTQUERY, MF_GRAYED | MF_BYCOMMAND); @@ -4912,6 +5047,21 @@ FrameWindow::OnActiveConn() wyBool FrameWindow::StopQuery(HWND hwndactive, MDIWindow * wnd) { +#ifndef COMMUNITY + wyInt32 presult = 6; + + if(pGlobals->m_entlicense.CompareI("Professional") != 0 && wnd->m_ptransaction && !wnd->m_ptransaction->m_starttransactionenabled) + { + presult = MessageBox(wnd->m_pcqueryobject->m_hwnd, _(L"The session has an active transaction. Stopping the execution will cause transaction to rollback and end. Do you want to continue?"), + _(L"Warning"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + if(presult == 6) + wnd->m_ptransaction->CallOnCommit(); + } + if(presult != 6) //dosent matter for professional, as initial value of presult is 6 + { + return wyFalse; + } +#endif VERIFY(SetCursor(LoadCursor(NULL, IDC_WAIT))); if(hwndactive && wnd->m_executing && wnd->m_tunnel->IsTunnel()) @@ -5333,6 +5483,7 @@ FrameWindow::HandleCreateDatabase(HWND hwnd, MDIWindow *pcquerywnd, wyWChar *dbn wyString query; wyString dbnamestr, tempcharset; MDIWindow *wnd = NULL; + wyInt32 isintransaction = 1; VERIFY(wnd = GetActiveWin()); if(!wnd) @@ -5376,13 +5527,18 @@ FrameWindow::HandleCreateDatabase(HWND hwnd, MDIWindow *pcquerywnd, wyWChar *dbn query.AddSprintf("collate %s", pcquerywnd->m_pcqueryobject->m_dbcollation.GetString()); } - res = ExecuteAndGetResult(pcquerywnd, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql, query); + res = ExecuteAndGetResult(pcquerywnd, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, + 0, wyFalse, &isintransaction, hwnd); + + if(isintransaction == 1) + return wyFalse; + if(!res && pcquerywnd->m_tunnel->mysql_affected_rows(pcquerywnd->m_mysql)== -1) { ShowMySQLError(hwnd, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql, query.GetString()); return wyFalse; } - + pcquerywnd->m_tunnel->mysql_free_result(res); ///New db select and insert into db combo only if database(s) not specified in Con.window @@ -5433,6 +5589,7 @@ FrameWindow::HandleAlterDatabase(HWND hwnd, MDIWindow *pcquerywnd, wyWChar *dbna MYSQL_RES *res; wyString query; wyString dbnamestr, tempcharset; + wyInt32 isintransaction = 1; hwndedit = GetDlgItem(hwnd, IDC_DBEDIT); CQueryObject *pcqueryobject=pcquerywnd->m_pcqueryobject; @@ -5457,9 +5614,12 @@ FrameWindow::HandleAlterDatabase(HWND hwnd, MDIWindow *pcquerywnd, wyWChar *dbna pcqueryobject->m_dbcollation.CompareI(STR_DEFAULT) != 0) { query.AddSprintf("collate %s", pcqueryobject->m_dbcollation.GetString()); - } + } - res = ExecuteAndGetResult(pcquerywnd, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql, query); + res = ExecuteAndGetResult(pcquerywnd, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, + 0, wyFalse, &isintransaction, GetActiveWindow()); + if(isintransaction == 1) + return wyFalse; if(!res && pcquerywnd->m_tunnel->mysql_affected_rows(pcquerywnd->m_mysql) == -1) { @@ -5756,9 +5916,7 @@ FrameWindow::PrepareCreateProcedure(MDIWindow *pcquerywnd, const wyChar *procedu | [NOT] DETERMINISTIC\r\n\ | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }\r\n\ | SQL SECURITY { DEFINER | INVOKER }\r\n\ - | COMMENT 'string'*/\r\n\ - BEGIN\r\n\r\n\ - END", + | COMMENT 'string'*/\r\n\tBEGIN\r\n\r\n\tEND", db.GetString(), procedurename, db.GetString(), procedurename); return; @@ -6819,6 +6977,8 @@ FrameWindow::OnWmClose(HWND hwnd) #ifndef COMMUNITY HWND hwndvdd; wyString vddmsg; + if(pGlobals->m_pcmainwin->m_closealltrans != IN_TRANSACTION); + pGlobals->m_pcmainwin->m_closealltrans = 1; #endif wyBool retval = wyTrue; @@ -6953,10 +7113,10 @@ FrameWindow::OnWmInitPopup(WPARAM wparam, LPARAM lparam) } RecursiveMenuEnable((HMENU)wparam, iswindowmenu, MF_ENABLED); - if(wyTheme::m_theme->IsSysmenuEnabled()) - m_connection->HandleMenu(menuindex, (HMENU)wparam);//if system menu is not enabled we need to move one extra in menu + if(wyTheme::m_theme->IsSysmenuEnabled(GetActiveWin()->m_hwnd)) + m_connection->HandleMenu(menuindex, (HMENU)wparam);//if system menu is not enabled we need to move one extra in menu else - m_connection->HandleMenu(menuindex+1, (HMENU)wparam); + m_connection->HandleMenu(menuindex+1, (HMENU)wparam); } @@ -7064,7 +7224,18 @@ FrameWindow::HandleMenuOnNoConnection(WPARAM wparam, LPARAM lparam) RemoveMenu((HMENU)wparam, ID_VDDTOOL, MF_BYCOMMAND); } } - + else if((LOWORD(lparam)) == MNUTRANSACTION_INDEX - 1) + { + wyUInt32 mitems[] ={ID_TRANSACTION_SETAUTOCOMMIT, ID_TRX_REPEATABLEREAD, ID_TRX_READCOMMITED, ID_TRX_READUNCOMMITED, + ID_TRX_SERIALIZABLE, ID_STARTTRANSACTION_WITHNOMODIFIER, ID_WITHCONSISTENTSNAPSHOT_READONLY, + ID_WITHCONSISTENTSNAPSHOT_READWRITE, ID_STARTTRANSACTION_READONLY, ID_STARTTRANSACTION_READWRITE, + ID_COMMIT_WITHNOMODIFIER, ID_COMMIT_ANDCHAIN, ID_COMMIT_ANDNOCHAIN, ID_COMMIT_RELEASE, + ID_COMMIT_NORELEASE, ID_ROLLBACK_TOSAVEPOINT, ID_ROLLBACK_TRANSACTION, ID_ROLLBACK_ANDCHAIN, + ID_ROLLBACK_ANDNOCHAIN, ID_ROLLBACK_RELEASE, ID_ROLLBACK_NORELEASE, ID_SAVEPOINT_CREATESAVEPOINT, + ID_SAVEPOINT_RELEASESAVEPOINT}; + for(int i = 0; mitems[i] != NULL; i++) + EnableMenuItem((HMENU)wparam, mitems[i], MF_GRAYED); + } return; } @@ -8975,7 +9146,10 @@ FrameWindow::EnableToolButtonsAndCombo(HWND hwndtool, HWND hwndsecondtool, HWND ID_FORMATCURRENTQUERY, IDC_DIFFTOOL, ID_QUERYBUILDER, - ID_SCHEMADESIGNER + ID_SCHEMADESIGNER, + ID_ROLLBACK_TRANSACTION, + ID_STARTTRANSACTION_WITHNOMODIFIER, + ID_COMMIT_WITHNOMODIFIER }; wyInt32 tb3id[] = { IDM_DATASYNC, ID_IMPORT_EXTERNAL_DATA, IDC_TOOLS_NOTIFY, ID_POWERTOOLS_SCHEDULEEXPORT}; @@ -9031,7 +9205,27 @@ FrameWindow::EnableToolButtonsAndCombo(HWND hwndtool, HWND hwndsecondtool, HWND state = TBSTATE_INDETERMINATE; } } - +#ifndef COMMUNITY + else if(tb2id[i] == ID_STARTTRANSACTION_WITHNOMODIFIER || tb2id[i] == ID_ROLLBACK_TRANSACTION || tb2id[i] == ID_COMMIT_WITHNOMODIFIER ) + { + HWND hwnd = wnd->GetHwnd(); + if(wnd->m_ptransaction) + { + if(tb2id[i] == ID_STARTTRANSACTION_WITHNOMODIFIER) + { + if(wnd->m_ptransaction->m_starttransactionenabled) + state = TBSTATE_ENABLED; + else + state = TBSTATE_INDETERMINATE; + } + else + if(!wnd->m_ptransaction->m_starttransactionenabled) + state = TBSTATE_ENABLED; + else + state = TBSTATE_INDETERMINATE; + } + } +#endif SendMessage(hwndsecondtool, TB_SETSTATE, (WPARAM)tb2id[i], state); } diff --git a/src/FrameWindowHelper.cpp b/src/FrameWindowHelper.cpp index 5e4f4b5..cfac91d 100644 --- a/src/FrameWindowHelper.cpp +++ b/src/FrameWindowHelper.cpp @@ -50,8 +50,9 @@ #define ZERO 0 #define ONE 1 #define TWO 2 +#define IN_TRANSACTION -10 -extern PGLOBALS pGlobals; +extern PGLOBALS pGlobals; extern HACCEL g_accel; // Function to compare two values sent by the qsort and binarysearch function. @@ -66,9 +67,9 @@ wyInt32 compare(const void *arg1, const void *arg2) wyInt32 my_query(MDIWindow *wnd, Tunnel * tunnel, PMYSQL mysql, const wyChar *query, wyUInt32 length, wyBool batch, wyBool isend, wyInt32 * stop, wyInt32 querycount, wyBool profile, wyBool currentwnd, - bool isread, wyBool isimport, wyBool fksethttpimport) + bool isread, wyBool isimport, wyBool fksethttpimport, HWND fortransactionprompt) { - wyInt32 ret = 0, pos = 0; + wyInt32 ret = 0, pos = 0, transactioncheck = -1, presult = 6; wyChar *newquery = 0; const wyChar *oldquery = query; wyString str, Query; @@ -103,6 +104,21 @@ wyInt32 my_query(MDIWindow *wnd, Tunnel * tunnel, PMYSQL mysql, const wyChar *qu } str.Clear(); } + #ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0) + { + if(wnd->m_ptransaction && (wnd->m_ptransaction->m_starttransactionenabled == wyFalse)) + { + if(newquery) + str.SetAs(newquery); + else + str.SetAs(query); + transactioncheck = wnd->m_ptransaction->TransactionContinue(&str, fortransactionprompt); + } + } + if(transactioncheck == 0) //dosent matter for professional, as initial value of transactioncheck is != 0 + return IN_TRANSACTION; + #endif //Its needed for encoding scheme with HTTP tunneling only if(tunnel && tunnel->IsTunnel() == true) isbadforxml = IsBadforXML(query); @@ -138,26 +154,86 @@ wyInt32 my_query(MDIWindow *wnd, Tunnel * tunnel, PMYSQL mysql, const wyChar *qu { //total time elapsed for reconnecting and execution(failed execution) tsrecon = timetaken + (GetHighPrecisionTickCount() - tsrecon); - recstr.SetAs(_(" SQLyog reconnected")); + #ifndef COMMUNITY + + if(pGlobals->m_entlicense.CompareI("Professional") != 0 && wnd->m_ptransaction && (wnd->m_ptransaction->m_starttransactionenabled == wyFalse)) + recstr.SetAs(_(" SQLyog reconnected. The transaction has been rolled back due to connection error.")); + else + #endif + recstr.SetAs(_(" SQLyog reconnected")); //profile comment to history my_queryprofile(wnd, tsrecon, recstr.GetString(), wyTrue); } - - /* try to reexecute the query */ - return my_query(wnd, tunnel, mysql, query, length, batch, isend, stop, 1, profile); +#ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0) + { + if(wnd->m_ptransaction) + { + wnd->m_ptransaction->m_autocommit = wyTrue; + wnd->m_ptransaction->m_isolationmode = ID_TRX_REPEATABLEREAD; + } + if(wnd->m_ptransaction && (wnd->m_ptransaction->m_starttransactionenabled == wyFalse)) + { + wnd->m_ptransaction->CallOnCommit(); + presult = MessageBox(wnd->GetHwnd() , _(L"SQLyog reconnected. The transaction has been rolled back due to connection error."), + _(L"Warning"), MB_ICONWARNING | MB_OK | MB_DEFBUTTON2); + } + } +#endif + /* try to reexecute the query */ + return my_query(wnd, tunnel, mysql, query, length, batch, isend, stop, 1, profile); + } if(profile == wyTrue)//profile the history tab with comment'SQLyog reconnect failed' { //total time elapsed for reconnecting and execution(failed execution) tsrecon = timetaken + (GetHighPrecisionTickCount() - tsrecon); + #ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0 && wnd->m_ptransaction) + { + wnd->m_ptransaction->m_autocommit = wyTrue; + wnd->m_ptransaction->m_isolationmode = ID_TRX_REPEATABLEREAD; + } + if(pGlobals->m_entlicense.CompareI("Professional") != 0 && wnd->m_ptransaction && (wnd->m_ptransaction->m_starttransactionenabled == wyFalse)) + { + //wnd->m_ptransaction->CallOnCommit(); + recstr.SetAs(_(" SQLyog reconnect failed. The Transaction has been rolled back due to connection error.")); + } + else + #endif recstr.SetAs(_(" SQLyog reconnect failed")); //profile comment to history my_queryprofile(wnd, tsrecon, recstr.GetString(), wyTrue); - } + } +#ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0) + { + if(wnd->m_ptransaction) + { + wnd->m_ptransaction->m_autocommit = wyTrue; + wnd->m_ptransaction->m_isolationmode = ID_TRX_REPEATABLEREAD; + } + if(wnd->m_ptransaction && (wnd->m_ptransaction->m_starttransactionenabled == wyFalse)) + { + presult = MessageBox(wnd->GetHwnd() , _(L"SQLyog reconnect Failed. The Transaction has been rolled back due to connection error."), + _(L"Warning"), MB_ICONWARNING | MB_OK | MB_DEFBUTTON2); + wnd->m_ptransaction->CallOnCommit(); + } + } +#endif } + #ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0 && !ret && wnd->m_ptransaction) + { + if(transactioncheck != -1 && !wnd->m_ptransaction->m_starttransactionenabled && wnd->m_ptransaction->m_autocommit) + { + wnd->m_ptransaction->CallOnCommit(); + } + } + #endif /* now we add the query for profiling */ /* if its tunneling then we dont add the profiling as it will be wrong */ @@ -179,6 +255,7 @@ wyInt32 my_query(MDIWindow *wnd, Tunnel * tunnel, PMYSQL mysql, const wyChar *qu } } + free(newquery); } @@ -1404,7 +1481,143 @@ LeftPadText(const wyChar *text) return temp; } +#ifndef COMMUNITY +wyBool +ChangeTransactionState(MDIWindow *wnd, const wyChar *query) +{ + SQLFormatter formatter; + wyString queryStr, newquery; + queryStr.SetAs(query); + formatter.GetQueryWtOutComments(&queryStr, &newquery); + newquery.RTrim(); + newquery.LTrim(); + + if(newquery.GetLength() != -1 && (newquery.FindI("START") == 0 || newquery.FindI("SET") == 0 || newquery.FindI("BEGIN") == 0 || newquery.FindI("COMMIT") == 0 || newquery.FindI("ROLLBACK") == 0)) + { + newquery.SetAs(wnd->m_ptransaction->RemoveExtraSpaces(newquery.GetString())); + + if(newquery.FindI("START") != -1 ) + { + if(newquery.FindI("TRANSACTION") == 6) + wnd->m_ptransaction->CallOnStart(); + } + else if(newquery.FindI("COMMIT") == 0 && newquery.GetLength() > 7) + { + wyString tempquery = newquery.Substr(7, newquery.GetLength() - 7); + newquery.SetAs(wnd->m_ptransaction->RemoveExtraSpaces(tempquery.GetString())); + if(newquery.FindI("AND CHAIN") == 0) + { + wnd->m_ptransaction->CallOnCommit(); + wnd->m_ptransaction->CallOnStart(); + } + } + else if(newquery.FindI("ROLLBACK") == 0 && newquery.GetLength() > 9) + { + wyString tempquery = newquery.Substr(9, newquery.GetLength() - 9); + newquery.SetAs(wnd->m_ptransaction->RemoveExtraSpaces(tempquery.GetString())); + if(newquery.FindI("AND CHAIN") == 0) + { + wnd->m_ptransaction->CallOnCommit(); + wnd->m_ptransaction->CallOnStart(); + } + else if(newquery.FindI("TO") != -1) + { + if(newquery.FindI("TO") == 0) + wnd->m_ptransaction->HandleRollbackEditor(&newquery, 3); + else if(newquery.FindI("WORK") == 0) + { + wyString tempstr; + tempstr.SetAs(newquery.Substr(0, newquery.GetLength() - 0)); + newquery.SetAs(wnd->m_ptransaction->RemoveExtraSpaces(tempstr.GetString())); + if(newquery.FindI("TO") == 5) + wnd->m_ptransaction->HandleRollbackEditor(&newquery, 8); + } + } + } + else if(newquery.FindI("BEGIN") != -1) + { + if(wnd->m_ptransaction->HandleBegin(newquery.GetString())) + wnd->m_ptransaction->CallOnStart(); + } + else + { + if(newquery.FindI("autocommit") == 4) + { + if(!wnd->m_ptransaction->m_autocommit) + { + if(newquery.FindI("=") != -1 && newquery.FindI("1") != -1) + { + wnd->m_ptransaction->m_autocommit = wyTrue; + wnd->m_ptransaction->CallOnCommit(); + } + } + else + { + if(newquery.FindI("=") != -1 && newquery.FindI("0") != -1) + { + wnd->m_ptransaction->m_autocommit = wyFalse; + wnd->m_ptransaction->CallOnStart(); + } + } + } + else if(newquery.FindI("SESSION") == 4 && newquery.FindI("TRANSACTION") != -1 && + newquery.FindI("ISOLATION") != -1 && newquery.FindI("LEVEL") != -1) + { + if(newquery.FindI("REPEATABLE") != -1 && newquery.FindI("READ") != -1) + { + wnd->m_ptransaction->m_isolationmode = ID_TRX_REPEATABLEREAD; + } + else if(newquery.FindI("COMMITTED") != -1 && newquery.FindI("READ") != -1 && newquery.FindI("UNCOMMITTED") == -1) + { + wnd->m_ptransaction->m_isolationmode = ID_TRX_READCOMMITED; + } + else if(newquery.FindI("UNCOMMITTED") != -1 && newquery.FindI("READ") != -1) + { + wnd->m_ptransaction->m_isolationmode = ID_TRX_READUNCOMMITED; + } + else if(newquery.FindI("SERIALIZABLE") != -1) + { + wnd->m_ptransaction->m_isolationmode = ID_TRX_SERIALIZABLE; + } + } + } + + } + else if(wnd->m_ptransaction->m_starttransactionenabled == wyFalse && newquery.GetLength() != -1 && (newquery.FindI("SAVEPOINT") == 0 || newquery.FindI("RELEASE") == 0)) + { + if(newquery.FindI("SAVEPOINT") == 0) + { + SQLFormatter formatter; + wyString queryStr, newquery; + queryStr.SetAs(query); + formatter.GetQueryWtOutComments(&queryStr, &newquery); + newquery.RTrim(); + newquery.LTrim(); + newquery.SetAs(wnd->m_ptransaction->RemoveExtraSpaces(newquery.GetString())); + wnd->m_ptransaction->HandleSavepointEditor(newquery.GetString()); + } + else if(newquery.FindI("RELEASE") == 0) + { + SQLFormatter formatter; + wyString queryStr, newquery; + queryStr.SetAs(query); + formatter.GetQueryWtOutComments(&queryStr, &newquery); + newquery.RTrim(); + newquery.LTrim(); + newquery.SetAs(wnd->m_ptransaction->RemoveExtraSpaces(newquery.GetString())); + queryStr.SetAs(newquery); + newquery.SetAs(queryStr.Substr(8, queryStr.GetLength() - 8)); + if(newquery.FindI("SAVEPOINT") == 0) + { + newquery.SetAs(wnd->m_ptransaction->RemoveExtraSpaces(newquery.GetString())); + wnd->m_ptransaction->HandleReleaseEditor(&newquery, 10); + } + } + } + return wyTrue; +} +#endif wyBool ChangeContextDB(Tunnel * tunnel, PMYSQL mysql, const wyChar *query, wyBool changeincombo) { @@ -2332,10 +2545,15 @@ GetColumnName(wyWChar *field) int IsColumnTypeJson(wyWChar *field) { wchar_t* result=wcschr(field,L', '); - if(wcsncmp(result,L", json",6)) + if(result) + { + if(wcsncmp(result,L", json",6)) + return 0; + else + return 1; + } + else return 0; - else - return 1; } wyBool diff --git a/src/GUIHelper.cpp b/src/GUIHelper.cpp index ed3cb6c..9a52875 100644 --- a/src/GUIHelper.cpp +++ b/src/GUIHelper.cpp @@ -1091,6 +1091,9 @@ HandleFileMenuOptionsProEnt(HMENU hmenu) { RemoveMenu(hmenu, ID_QUERYBUILDER, MF_BYCOMMAND); RemoveMenu(hmenu, ID_SCHEMADESIGNER, MF_BYCOMMAND); + RemoveMenu(hmenu, ID_STARTTRANSACTION_WITHNOMODIFIER, MF_BYCOMMAND); + RemoveMenu(hmenu, ID_COMMIT_WITHNOMODIFIER, MF_BYCOMMAND); + RemoveMenu(hmenu, ID_ROLLBACK_TRANSACTION, MF_BYCOMMAND); } if(pGlobals->m_pcmainwin->m_connection->m_enttype == ENT_PRO || pGlobals->m_pcmainwin->m_connection->m_enttype == ENT_NORMAL) @@ -2872,6 +2875,25 @@ ChangeCRToLF(wyChar * text) return wyTrue; } +wyBool +AddCRToLF(wyChar * text, wyChar * temp) +{ + wyUInt32 i=0; + wyUInt32 j=0; + + while(text[i]) + { + temp[j++] = text[i]; + if(text[i+1]) + { + if(text[i+1] == C_NEWLINE && text[i] != C_CARRIAGE) + temp[j++] = '\r'; + } + i++; + } + return wyTrue; +} + wyBool OnItemExpanding(TREEVIEWPARAMS &treeparam, wyBool isrefreshnode, wyBool iscalledfromusermanager) { @@ -7885,10 +7907,15 @@ SeekCurrentRowFromMySQLResult(MYSQL_RES *res, MYSQL_ROWS **rowswalker, Tunnel *t wyBool OnDrawConnNameCombo(HWND hwndcombo, LPDRAWITEMSTRUCT lpds, wyBool isconndbname) { - wyInt32 ncount, i, j; + wyInt32 ncount, i, j, ret; wyString connstr, dirstr, conncount; wyInt32 topindex; + wyWChar directory[MAX_PATH + 1], *lpfileport=0; + ret = SearchFilePath(L"sqlyog", L".ini", MAX_PATH, directory, &lpfileport); + if(ret == 0) + return wyFalse; + dirstr.SetAs(directory); //fill the combobox with options ncount = SendMessage(hwndcombo, CB_GETCOUNT, 0, 0); @@ -7906,7 +7933,7 @@ OnDrawConnNameCombo(HWND hwndcombo, LPDRAWITEMSTRUCT lpds, wyBool isconndbname) topindex = 0; j = ncount; } - + pGlobals->m_pcmainwin->m_connection->PopulateColorArray(hwndcombo, &dirstr); for(i = topindex; i < j; i++) { if(isconndbname == wyTrue) diff --git a/src/ImportBatch.cpp b/src/ImportBatch.cpp index f652102..f431805 100644 --- a/src/ImportBatch.cpp +++ b/src/ImportBatch.cpp @@ -146,7 +146,32 @@ ImportBatch::OnWMCommand(HWND hwnd, WPARAM wParam) break; case IDOK: - ImportDump(); + { +#ifndef COMMUNITY + MDIWindow* wnd = GetActiveWin(); + wyInt32 presult = 6; + wyInt32 isintransaction = 1; + + if(wnd->m_ptransaction && wnd->m_ptransaction->m_starttransactionenabled == wyFalse) + { + if(pGlobals->m_pcmainwin->m_topromptonimplicit) + presult = MessageBox(GetActiveWindow(), _(L"You have an active transaction. This operation will cause Transaction to commit and end. Do you want to Continue?"), + _(L"Warning"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + if(presult == 6) + { + wyString query; + query.Sprintf("COMMIT"); + ExecuteAndGetResult(wnd, wnd->m_tunnel, &wnd->m_mysql, query, wyFalse, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + break; + } + } + if(presult == 6) +#endif + ImportDump(); + } + break; case IDDONE: diff --git a/src/MDIWindow.cpp b/src/MDIWindow.cpp index 9d6405b..ebfb569 100644 --- a/src/MDIWindow.cpp +++ b/src/MDIWindow.cpp @@ -143,6 +143,9 @@ MDIWindow::MDIWindow(HWND hwnd, ConnectionInfo * conninfo, wyString &dbname, wyS #ifndef COMMUNITY m_constatusparm = NULL; + + + m_ptransaction = NULL; #endif m_acinitevent = NULL; m_threadidinit = NULL; @@ -173,6 +176,10 @@ MDIWindow::~MDIWindow() // delete m_listtabeditor; if(m_tunnel) delete m_tunnel; +#ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0 ) + delete m_ptransaction; +#endif // Release resources used by the critical section object. DeleteCriticalSection(&m_cs); @@ -240,8 +247,43 @@ MDIWindow::Create(wyBool iscon_res, ConnectionInfo* conninfo) else if(m_tunnel->IsTunnel()) { m_keepaliveinterval = 0; + } +#ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0) + { + wyString query, resstr; + MYSQL_RES* myres; + MYSQL_ROW row; + MDIWindow* wnd; + wnd = GetActiveWin(); + + query.Sprintf("SHOW GLOBAL VARIABLES WHERE variable_name = \"AUTOCOMMIT\""); + myres = ExecuteAndGetResult(wnd, m_tunnel, &m_mysql, query); + if(!myres && m_tunnel->mysql_affected_rows(m_mysql) == -1) + { + } + row = m_tunnel->mysql_fetch_row(myres); + if(!row) + { + if(myres) + wnd->m_tunnel->mysql_free_result(myres); + resstr.SetAs("ON"); + } + else + { + resstr.SetAs(row[1], IsMySQL41(m_tunnel, &m_mysql)); + mysql_free_result(myres); + } + if(resstr.CompareI("ON") == 0) + { + wnd->m_ptransaction->m_autocommit = wyTrue; + } + else if(resstr.CompareI("OFF") == 0) + { + wnd->m_ptransaction->m_autocommit = wyFalse; + } } - +#endif return wyTrue; } @@ -799,7 +841,6 @@ MDIWindow::OnWmCreate(HWND hwnd) SetWindowPositions(); pGlobals->m_pcmainwin->AddTextInCombo(m_database.GetAsWideChar()); PostMessage(hwnd, UM_REFRESHOBJECT, 0, 0); - if(m_pctabmodule->GetActiveTabEditor()) { peditorbase = m_pctabmodule->GetActiveTabEditor()->m_peditorbase; @@ -811,13 +852,50 @@ MDIWindow::OnWmCreate(HWND hwnd) ShowCursor(TRUE); } } - + #ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0 ) + CreateTransactionhandler(hwnd); +#endif return; } wyInt32 MDIWindow::OnWmClose(HWND hwnd) { + wyInt32 presult = 6; + MDIWindow *wnd = GetActiveWin(); +#ifndef COMMUNITY + FrameWindow* pcmainwin = (FrameWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + if(pGlobals->m_entlicense.CompareI("Professional") != 0) + { + if(pGlobals->m_pcmainwin->m_closealltrans == 1 && pGlobals->m_pcmainwin->m_intransaction > 0 && wnd->m_ptransaction && pGlobals->m_pcmainwin->m_topromptonclose == wyTrue) + { + presult = MessageBox(wnd->GetHwnd() , _(L"One or more session(s) have (a) transaction(s) running. Do you still want to close SQLyog? The transaction will be rolled back by the server."), + _(L"Warning"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + if(presult != 6) + { + pGlobals->m_pcmainwin->m_closealltrans = 0; + return 0; + } + else + pGlobals->m_pcmainwin->m_closealltrans = -1; + } + if(wnd->m_ptransaction && wnd->m_ptransaction->m_starttransactionenabled == wyFalse && pGlobals->m_pcmainwin->m_closealltrans == 0 && pGlobals->m_pcmainwin->m_topromptonclose == wyTrue ) + { + presult = MessageBox(wnd->GetHwnd() , _(L"The session has an active transaction. Do you want to close the connection? The transaction will be rolled back by the server. "), + _(L"Warning"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + + if(presult == 6) + pGlobals->m_pcmainwin->m_intransaction --; + } + } + if(presult != 6) + { + pGlobals->m_pcmainwin->m_closealltrans = 0; + return 0; + } + +#endif m_ismdiclosealltabs = wyTrue; wyInt32 tabcount, count; @@ -947,7 +1025,7 @@ MDIWindow::OnWmClose(HWND hwnd) SetCursor(LoadCursor(NULL, IDC_ARROW)); - return 1; + return 1; } wyInt32 @@ -1491,7 +1569,14 @@ MDIWindow::CreateTabController(HWND hwnd) return; } - +#ifndef COMMUNITY +void +MDIWindow::CreateTransactionhandler(HWND hwnd) +{ + m_ptransaction = new Transactions(); + return; +} +#endif void MDIWindow::CreateQueryStatus(HWND hwnd) { @@ -3185,7 +3270,36 @@ MDIWindow::FlushWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) switch(LOWORD(wparam)) { case IDOK: - return pcquerywnd->OnFlushOK(hwnd); + { +#ifndef COMMUNITY +wyInt32 presult = 6; +wyInt32 isintransaction = 1; + + if(pcquerywnd->m_ptransaction && pcquerywnd->m_ptransaction->m_starttransactionenabled == wyFalse) + { + if(pGlobals->m_pcmainwin->m_topromptonimplicit) + presult = MessageBox(GetActiveWindow(), _(L"You have an active transaction. This operation will cause Transaction to commit and end. Do you want to Continue?"), + _(L"Warning"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + if(presult == 6) + { + wyString query; + query.Sprintf("COMMIT"); + ExecuteAndGetResult(pcquerywnd, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql, query, wyFalse, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + break; + } + } + if(presult == 6) + { +#endif + return pcquerywnd->OnFlushOK(hwnd); + +#ifndef COMMUNITY + } +#endif + break; + } case IDC_FLUSH_ALL: /* if all is checked we need to enable disable all the buttons */ @@ -3228,13 +3342,14 @@ MDIWindow::FlushAll(HWND hwnd, HWND hwndtext, wyInt32 writetobin) "tables", "status", "des_key_file", "query cache", "user_resources", "tables with read lock" }; + wyInt32 isflush = 1; size = sizeof(flushquery) / sizeof(flushquery[0]); for(count = 0; count < size; count++) { - rc = ExecuteFlush(flushquery[count], hwndtext, writetobin, hwnd); - if(rc == wyFalse) + rc = ExecuteFlush(flushquery[count], hwndtext, writetobin, hwnd, &isflush); + if(rc == wyFalse || isflush == 1) { success = wyFalse; return 1; @@ -3266,36 +3381,37 @@ MDIWindow::FlushSpecific(HWND hwnd, HWND hwndtext, wyInt32 writetobin) { MYSQL_RES *res; wyString query; + wyInt32 isflush = 1; - if((IsDlgButtonChecked(hwnd, IDC_FL_LOGS))== BST_CHECKED) - ExecuteFlush("logs", hwndtext, writetobin, hwnd); + if((IsDlgButtonChecked(hwnd, IDC_FL_LOGS))== BST_CHECKED && isflush != -1) + ExecuteFlush("logs", hwndtext, writetobin, hwnd, &isflush); - if((IsDlgButtonChecked(hwnd, IDC_FL_HOSTS))== BST_CHECKED) - ExecuteFlush("hosts", hwndtext, writetobin, hwnd); + if((IsDlgButtonChecked(hwnd, IDC_FL_HOSTS))== BST_CHECKED && isflush != -1) + ExecuteFlush("hosts", hwndtext, writetobin, hwnd, &isflush); - if((IsDlgButtonChecked(hwnd, IDC_FL_PRIV))== BST_CHECKED) - ExecuteFlush("privileges", hwndtext, writetobin, hwnd); + if((IsDlgButtonChecked(hwnd, IDC_FL_PRIV))== BST_CHECKED && isflush != -1) + ExecuteFlush("privileges", hwndtext, writetobin, hwnd, &isflush); - if((IsDlgButtonChecked(hwnd, IDC_FL_TABLES))== BST_CHECKED) - ExecuteFlush("tables", hwndtext, writetobin, hwnd); + if((IsDlgButtonChecked(hwnd, IDC_FL_TABLES))== BST_CHECKED && isflush != -1) + ExecuteFlush("tables", hwndtext, writetobin, hwnd, &isflush); - if((IsDlgButtonChecked(hwnd, IDC_FL_STATUS))== BST_CHECKED) - ExecuteFlush("status", hwndtext, writetobin, hwnd); + if((IsDlgButtonChecked(hwnd, IDC_FL_STATUS))== BST_CHECKED && isflush != -1) + ExecuteFlush("status", hwndtext, writetobin, hwnd, &isflush); - if((IsDlgButtonChecked(hwnd, IDC_FL_DES))== BST_CHECKED) - ExecuteFlush("des_key_file", hwndtext, writetobin, hwnd); + if((IsDlgButtonChecked(hwnd, IDC_FL_DES))== BST_CHECKED && isflush != -1) + ExecuteFlush("des_key_file", hwndtext, writetobin, hwnd, &isflush); - if((IsDlgButtonChecked(hwnd, IDC_FL_CACHE))== BST_CHECKED) - ExecuteFlush("query cache", hwndtext, writetobin, hwnd); + if((IsDlgButtonChecked(hwnd, IDC_FL_CACHE))== BST_CHECKED && isflush != -1) + ExecuteFlush("query cache", hwndtext, writetobin, hwnd, &isflush); - if((IsDlgButtonChecked(hwnd, IDC_FL_RESOURCE))== BST_CHECKED) - ExecuteFlush("user_resources", hwndtext, writetobin, hwnd); + if((IsDlgButtonChecked(hwnd, IDC_FL_RESOURCE))== BST_CHECKED && isflush != -1) + ExecuteFlush("user_resources", hwndtext, writetobin, hwnd, &isflush); - if((IsDlgButtonChecked(hwnd, IDC_FL_TABLESREAD))== BST_CHECKED) + if((IsDlgButtonChecked(hwnd, IDC_FL_TABLESREAD))== BST_CHECKED && isflush != -1) { if(IsNewMySQL(m_tunnel, &m_mysql)) { - ExecuteFlush("tables with read lock", hwndtext, writetobin, hwnd); + ExecuteFlush("tables with read lock", hwndtext, writetobin, hwnd, &isflush); /* if everything is ok then we need to unlock table for flush tables with read lock */ @@ -3313,7 +3429,7 @@ MDIWindow::FlushSpecific(HWND hwnd, HWND hwndtext, wyInt32 writetobin) } else - ExecuteFlush("tables", hwndtext, BST_UNCHECKED, hwnd); + ExecuteFlush("tables", hwndtext, BST_UNCHECKED, hwnd, &isflush); } return 1; } @@ -3438,18 +3554,27 @@ MDIWindow::AddFlushPersistence(HWND hwnd) // whose HWND is sent as parameter. wyBool MDIWindow::ExecuteFlush(wyString flushquery, HWND hwndEdit, - wyInt32 writetobin, HWND hwnddlg) + wyInt32 writetobin, HWND hwnddlg, wyInt32 *isflush) { wyString query; MYSQL_RES *res; + wyInt32 isintransaction = 1; + + if(isflush) + *isflush = 0; SetCursor(LoadCursor(NULL, IDC_WAIT)); query.Sprintf("flush %s",(BST_CHECKED==writetobin)?("NO_WRITE_TO_BINLOG "):("")); query.Add(flushquery.GetString()); - res = ExecuteAndGetResult(this, m_tunnel, &(m_mysql), query); + res = ExecuteAndGetResult(this, m_tunnel, &(m_mysql), query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + if(isintransaction == 1) + { + *isflush = -1; + return wyFalse; + } if(!res && m_tunnel->mysql_affected_rows(m_mysql)== -1) { ShowMySQLError(hwnddlg, m_tunnel, &(m_mysql), query.GetString()); @@ -4497,6 +4622,9 @@ MDIWindow::LoadQueryTabPlusMenu(LPARAM lparam) case ENT_PRO: DeleteMenu(htrackmenu, ID_QUERYBUILDER, MF_BYCOMMAND); DeleteMenu(htrackmenu, ID_SCHEMADESIGNER, MF_BYCOMMAND); + DeleteMenu(htrackmenu, ID_STARTTRANSACTION_WITHNOMODIFIER, MF_BYCOMMAND); + DeleteMenu(htrackmenu, ID_COMMIT_WITHNOMODIFIER, MF_BYCOMMAND); + DeleteMenu(htrackmenu, ID_ROLLBACK_TRANSACTION, MF_BYCOMMAND); case ENT_NORMAL: DeleteMenu(htrackmenu, ID_DATASEARCH, MF_BYCOMMAND); } @@ -4505,6 +4633,9 @@ MDIWindow::LoadQueryTabPlusMenu(LPARAM lparam) { EnableMenuItem(htrackmenu, ID_QUERYBUILDER, MF_DISABLED); EnableMenuItem(htrackmenu, ID_SCHEMADESIGNER, MF_DISABLED); + EnableMenuItem(htrackmenu, ID_STARTTRANSACTION_WITHNOMODIFIER, MF_DISABLED); + EnableMenuItem(htrackmenu, ID_COMMIT_WITHNOMODIFIER, MF_DISABLED); + EnableMenuItem(htrackmenu, ID_ROLLBACK_TRANSACTION, MF_DISABLED); EnableMenuItem(htrackmenu, ID_DATASEARCH, MF_DISABLED); EnableMenuItem(htrackmenu, ID_NEW_EDITOR, MF_DISABLED); EnableMenuItem(htrackmenu, ID_HISTORY, MF_DISABLED); diff --git a/src/MySQLVersionHelper.cpp b/src/MySQLVersionHelper.cpp index 1b0b076..cae6d44 100644 --- a/src/MySQLVersionHelper.cpp +++ b/src/MySQLVersionHelper.cpp @@ -417,6 +417,19 @@ IsMySQL564MariaDB53(Tunnel *tunnel, PMYSQL mysql) return wyFalse; } +wyBool +IsMySQL553MariaDB55(Tunnel *tunnel, PMYSQL mysql) +{ + long me = mysql_get_server_version(*mysql);/* Only available from MySQLv4.1*/ + const char *dbString = mysql_get_server_info(*mysql); + + if((me >= 50503 && !strstr(dbString, "MariaDB"))||(me >= 50500 && strstr(dbString, "MariaDB"))) + return wyTrue; + else + return wyFalse; +} + + void GetVersionInfoforAutoComplete(MYSQL *mysql, wyString &VersionS) { long me = mysql_get_server_version(mysql); diff --git a/src/ObjectBrowser.cpp b/src/ObjectBrowser.cpp index 678a747..b1da8b6 100644 --- a/src/ObjectBrowser.cpp +++ b/src/ObjectBrowser.cpp @@ -1731,6 +1731,7 @@ CQueryObject::DropDatabase(Tunnel * tunnel, PMYSQL mysql) HTREEITEM hitem; MYSQL_RES *res; MDIWindow *wnd = GetActiveWin(); + wyInt32 isintransaction = 1; item = GetSelectionImage(); VERIFY(hitem = TreeView_GetSelection(m_hwnd)); @@ -1786,7 +1787,11 @@ CQueryObject::DropDatabase(Tunnel * tunnel, PMYSQL mysql) // prepare drop database query query.Sprintf("drop database `%s`", m_seldatabase.GetString()); - res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query); + res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { ShowMySQLError(m_hwnd, tunnel, mysql, query.GetString()); @@ -1823,6 +1828,7 @@ CQueryObject::DropTable(Tunnel * tunnel, PMYSQL mysql) wyString query, message; HTREEITEM hitem, hitemdb = NULL; MYSQL_RES *res; + wyInt32 isintransaction = 1; VERIFY(hitem = TreeView_GetSelection(m_hwnd)); item = GetSelectionImage(); @@ -1873,7 +1879,11 @@ CQueryObject::DropTable(Tunnel * tunnel, PMYSQL mysql) // prepare drop table query. query.Sprintf("drop table `%s`.`%s`", m_seldatabase.GetString(), m_seltable.GetString()); - res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query); + res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { ShowMySQLError(m_hwnd, tunnel, mysql, query.GetString()); @@ -1897,7 +1907,7 @@ CQueryObject::DropTable(Tunnel * tunnel, PMYSQL mysql) wyBool CQueryObject::DropField(Tunnel * tunnel, PMYSQL mysql) { - wyInt32 ret, tabicon = 0; + wyInt32 ret, tabicon = 0, isintransaction = 1; wyString query, message, fieldstr; wyWChar field[SIZE_512] = {0}; TVITEM tvi; @@ -1959,7 +1969,11 @@ CQueryObject::DropField(Tunnel * tunnel, PMYSQL mysql) // prepare drop table query. query.Sprintf("alter table `%s`.`%s` drop `%s`", m_seldatabase.GetString(), m_seltable.GetString(), fieldname.GetString()); - res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query); + res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { ShowMySQLError(m_hwnd, tunnel, mysql, query.GetString()); @@ -2016,7 +2030,7 @@ CQueryObject::DropField(Tunnel * tunnel, PMYSQL mysql) wyBool CQueryObject::DropIndex(Tunnel * tunnel, PMYSQL mysql) { - wyInt32 ret, indexcounter, tabicon = 0; + wyInt32 ret, indexcounter, tabicon = 0, isintransaction = 1; wyString query, message, indexstr; wyWChar index[SIZE_512] = {0}; TVITEM tvi; @@ -2074,7 +2088,11 @@ CQueryObject::DropIndex(Tunnel * tunnel, PMYSQL mysql) // prepare drop table query. query.Sprintf("alter table `%s`.`%s` drop index `%s`", m_seldatabase.GetString(), m_seltable.GetString(), indexstr.GetString()); - res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query); + res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { ShowMySQLError(m_hwnd, tunnel, mysql, query.GetString()); @@ -2122,7 +2140,7 @@ CQueryObject::DropIndex(Tunnel * tunnel, PMYSQL mysql) wyBool CQueryObject::EmptyTable(Tunnel * tunnel, PMYSQL mysql) { - wyInt32 ret,item; + wyInt32 ret,item, isintransaction = 1; wyString query, message; HTREEITEM hitem; MYSQL_RES* res; @@ -2177,7 +2195,11 @@ CQueryObject::EmptyTable(Tunnel * tunnel, PMYSQL mysql) query.Sprintf("truncate table `%s`.`%s`", m_seldatabase.GetString(), m_seltable.GetString()); SetCursor(LoadCursor(NULL, IDC_WAIT)); - res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query); + res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { ShowMySQLError(m_hwnd, tunnel, mysql, query.GetString()); @@ -5414,7 +5436,7 @@ CQueryObject::OnDBLClick(WPARAM wParam, LPARAM lParam) wyBool CQueryObject::ChangeTableType(Tunnel * tunnel, PMYSQL mysql, const wyWChar *newtabletype) { - wyInt32 item = 0; + wyInt32 item = 0, isintransaction = 1; wyString query; HTREEITEM hitem; MYSQL_RES *res = NULL; @@ -5437,7 +5459,11 @@ CQueryObject::ChangeTableType(Tunnel * tunnel, PMYSQL mysql, const wyWChar *newt else query.Sprintf("alter table `%s`.`%s` type = %s", m_seldatabase.GetString(), m_seltable.GetString(), newtabtypestr.GetString()); - res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query); + res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { ShowMySQLError(m_hwnd, tunnel, mysql, query.GetString()); @@ -5815,12 +5841,16 @@ CQueryObject::HandleExecuteQuery(Tunnel *tunnel, PMYSQL mysql, wyString &query, { MYSQL_RES *res; wyBool force, batch, isfkchbatch; + wyInt32 isintransaction = 1; force = batch = isfkchbatch = ((istunnel == wyTrue) ? wyTrue : wyFalse); //For http batch = true, force = true, isimporthtttp = true(thia makes SET SQL-MODE and SET FK-CHECK add to each script) res = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query, wyTrue, batch, wyTrue, - false, force, wyFalse, 0, isfkchbatch); + false, force, wyFalse, 0, isfkchbatch, &isintransaction); + + if(isintransaction == 1) + return wyFalse; if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { @@ -5846,7 +5876,7 @@ CQueryObject::DropViews(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyChar * MYSQL_RES *res; MDIWindow *wnd = GetActiveWin(); wyBool ismysql41 = IsMySQL41(tunnel, mysql); - wyInt32 count = 0; + wyInt32 count = 0, isintransaction = 1; wyString dbname(db); GetSelectViewStmt(db, query); @@ -5864,7 +5894,10 @@ CQueryObject::DropViews(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyChar * { myrowstr.SetAs(myrow[0], ismysql41); query.Sprintf("drop view `%s`.`%s`", m_seldatabase.GetString(), myrowstr.GetString()); - res = ExecuteAndGetResult(wnd, tunnel, mysql, query); + res = ExecuteAndGetResult(wnd, tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return count; if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { @@ -5888,7 +5921,7 @@ CQueryObject::DropProcedures(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyC MYSQL_RES *myres, *res; MYSQL_ROW myrow; wyString query, myrowstr; - wyInt32 count = 0 ; + wyInt32 count = 0, isintransaction = 1; MDIWindow *wnd = GetActiveWin(); wyString dbname(db); wyBool ismysql41 = IsMySQL41(tunnel, mysql); @@ -5911,7 +5944,10 @@ CQueryObject::DropProcedures(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyC { myrowstr.SetAs(myrow[0], ismysql41); query.Sprintf("drop procedure `%s`.`%s`", m_seldatabase.GetString(), myrowstr.GetString()); - res = ExecuteAndGetResult(wnd, tunnel, mysql, query); + res = ExecuteAndGetResult(wnd, tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return count; if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { ShowMySQLError(m_hwnd, tunnel, mysql, query.GetString()); @@ -5930,7 +5966,7 @@ CQueryObject::DropProcedures(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyC wyInt32 CQueryObject::DropEvents(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyChar *db) { - wyInt32 count = 0; + wyInt32 count = 0, isintransaction = 1; MYSQL_RES *myres, *res; MYSQL_ROW myrow; wyBool ismysql41 = IsMySQL41(tunnel, mysql); @@ -5958,7 +5994,10 @@ CQueryObject::DropEvents(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyChar { myrowstr.SetAs(myrow[0], ismysql41); query.Sprintf("drop event `%s`.`%s`", m_seldatabase.GetString(), myrowstr.GetString()); - res = ExecuteAndGetResult(wnd, tunnel, mysql, query); + res = ExecuteAndGetResult(wnd, tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return count; if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { @@ -5979,7 +6018,7 @@ CQueryObject::DropEvents(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyChar wyInt32 CQueryObject::DropFunctions(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyChar *db) { - wyInt32 count = 0; + wyInt32 count = 0, isintransaction = 1; MYSQL_RES *myres, *res; MYSQL_ROW myrow; wyBool ismysql41 = IsMySQL41(tunnel, mysql); @@ -6007,7 +6046,10 @@ CQueryObject::DropFunctions(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyCh { myrowstr.SetAs(myrow[0], ismysql41); query.Sprintf("drop function `%s`.`%s`", m_seldatabase.GetString(), myrowstr.GetString()); - res = ExecuteAndGetResult(wnd, tunnel, mysql, query); + res = ExecuteAndGetResult(wnd, tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return count; if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { @@ -6407,7 +6449,7 @@ CQueryObject::DropDatabaseObject(Tunnel * tunnel, PMYSQL mysql, wyChar *objectty { MYSQL_RES *myres; wyString query; - wyInt32 ret; + wyInt32 ret, isintransaction = 1; HTREEITEM hitem, hitemtemp; wyString objectname; @@ -6431,7 +6473,11 @@ CQueryObject::DropDatabaseObject(Tunnel * tunnel, PMYSQL mysql, wyChar *objectty query.Sprintf("drop %s `%s`.`%s`",objectname.GetString(), m_seldatabase.GetString(), m_seltable.GetString()); - myres = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query); + myres = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!myres && tunnel->mysql_affected_rows(*mysql)== -1) { SetCursor(LoadCursor(NULL, IDC_ARROW)); @@ -6454,7 +6500,7 @@ CQueryObject::DropTrigger(Tunnel * tunnel, PMYSQL mysql) { MYSQL_RES *myres; wyString query; - wyInt32 ret; + wyInt32 ret, isintransaction = 1; HTREEITEM hitem, hitemtemp; VERIFY(hitem = TreeView_GetSelection(m_hwnd)); @@ -6476,7 +6522,11 @@ CQueryObject::DropTrigger(Tunnel * tunnel, PMYSQL mysql) query.Sprintf("drop trigger /*!50032 if exists */ `%s`.`%s`", m_seldatabase.GetString(), m_seltable.GetString()); - myres = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query); + myres = ExecuteAndGetResult(GetActiveWin(), tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!myres && tunnel->mysql_affected_rows(*mysql)== -1) { SetCursor(LoadCursor(NULL, IDC_ARROW)); @@ -6502,6 +6552,7 @@ CQueryObject::EndRenameTable(LPNMTVDISPINFO ptvdi) MYSQL_RES *myres; wyString itemtextstr; TabEditor *ptabeditor = NULL; + wyInt32 isintransaction = 1; MDIWindow* wnd = (MDIWindow*)GetWindowLongPtr(m_hwndparent, GWLP_USERDATA); _ASSERT(wnd); @@ -6512,7 +6563,11 @@ CQueryObject::EndRenameTable(LPNMTVDISPINFO ptvdi) m_seldatabase.GetString(), m_seltable.GetString(), m_seldatabase.GetString(), itemtextstr.GetString()); - myres = ExecuteAndGetResult(wnd, wnd->m_tunnel, &wnd->m_mysql, query); + myres = ExecuteAndGetResult(wnd, wnd->m_tunnel, &wnd->m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!myres && wnd->m_tunnel->mysql_affected_rows(wnd->m_mysql)== -1) { ShowMySQLError(m_hwnd, wnd->m_tunnel, &wnd->m_mysql, query.GetString()); @@ -6619,7 +6674,12 @@ and you are not the DEFINER"), pGlobals->m_appname.GetAsWideChar(), MB_ICONERROR strview.Sprintf("create view `%s`.`%s` as %s", m_seldatabase.GetString(), myrowstr.GetString(), myrowsecstr.GetString()); - res = ExecuteAndGetResult(wnd, wnd->m_tunnel, &wnd->m_mysql, strview); + wyInt32 isintransaction = 1; + + res = ExecuteAndGetResult(wnd, wnd->m_tunnel, &wnd->m_mysql, strview, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; if(!res && wnd->m_tunnel->mysql_affected_rows(wnd->m_mysql)== -1) { @@ -6649,6 +6709,8 @@ CQueryObject::EndRenameEvent(LPNMTVDISPINFO ptvdi) MYSQL_RES *res; wyBool iscollate = wyFalse; MDIWindow* wnd = (MDIWindow*)GetWindowLongPtr(m_hwndparent, GWLP_USERDATA); + wyInt32 isintransaction = 1; + _ASSERT(wnd); if(GetmySQLCaseVariable(wnd) == 0) @@ -6683,7 +6745,11 @@ CQueryObject::EndRenameEvent(LPNMTVDISPINFO ptvdi) query.Sprintf("alter event `%s`.`%s` rename to `%s`.`%s`", m_seldatabase.GetString(), m_seltable.GetString(), m_seldatabase.GetString(), renameevent.GetString()); - res = ExecuteAndGetResult(wnd, wnd->m_tunnel, &wnd->m_mysql, query); + res = ExecuteAndGetResult(wnd, wnd->m_tunnel, &wnd->m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!res && wnd->m_tunnel->mysql_affected_rows(wnd->m_mysql)== -1) { @@ -6833,7 +6899,11 @@ CQueryObject::EndRenameTrigger(LPNMTVDISPINFO ptvdi) /* Drop trigger otherwise you may not create another with same constraint */ dropquery.Sprintf("drop trigger /*!50032 if exists */ `%s`.`%s`", m_seldatabase.GetString(), m_seltrigger.GetString()); - res = ExecuteAndGetResult(wnd, wnd->m_tunnel, &wnd->m_mysql, dropquery); + wyInt32 isintransaction = 1; + res = ExecuteAndGetResult(wnd, wnd->m_tunnel, &wnd->m_mysql, dropquery, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; if(!res && wnd->m_tunnel->mysql_affected_rows(wnd->m_mysql)== -1) { @@ -7538,7 +7608,7 @@ CQueryObject::DropTriggers(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyCha MYSQL_RES *res; MDIWindow *wnd = GetActiveWin(); wyBool ismysql41 = IsMySQL41(tunnel, mysql); - wyInt32 count = 0; + wyInt32 count = 0, isintransaction = 1; wyString dbname(db); GetSelectTriggerStmt(db, query); @@ -7556,7 +7626,10 @@ CQueryObject::DropTriggers(HWND hwnd, Tunnel * tunnel, PMYSQL mysql, const wyCha { myrowstr.SetAs(myrow[0], ismysql41); query.Sprintf("drop trigger `%s`.`%s`", m_seldatabase.GetString(), myrowstr.GetString()); - res = ExecuteAndGetResult(wnd, tunnel, mysql, query); + res = ExecuteAndGetResult(wnd, tunnel, mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return count; if(!res && tunnel->mysql_affected_rows(*mysql)== -1) { diff --git a/src/ObjectInfo.cpp b/src/ObjectInfo.cpp index 08c13d7..03b8497 100644 --- a/src/ObjectInfo.cpp +++ b/src/ObjectInfo.cpp @@ -3153,8 +3153,10 @@ ObjectInfo::AddColumnDataInformation(wyString &strindex, wyInt32 keytype, wyStri { data.SetAs(myrow[index], wnd->m_ismysql41); - //Conver the 'Rows' & 'Avg_Row_Lengt' numeric values to Format(T, G, M, K) - if(isnumericdata == wyTrue && obj == OBJECT_TABLES && stricmp(tok, "0") != 0) + //Convert the 'Rows' & 'Avg_Row_Lengt' numeric values to Format(T, G, M, K) + // stricmp(tok, "4") added to fix the issue with display of no. of rows. From now we will show no. of rows + // as it is + if(isnumericdata == wyTrue && obj == OBJECT_TABLES && stricmp(tok, "0") != 0 && stricmp(tok, "4") != 0) { valueint = data.GetAsInt64(); diff --git a/src/OtherDialogs.cpp b/src/OtherDialogs.cpp index df122c8..afb33a1 100644 --- a/src/OtherDialogs.cpp +++ b/src/OtherDialogs.cpp @@ -1914,9 +1914,9 @@ CCopyTable::FillData() wyBool CCopyTable::DoCopy() { - wyInt32 fieldcount; + wyInt32 fieldcount, query_for_virtuality_length, isintransaction = 1;; wyBool relation, isssel, isindex, success, ret; - wyString query, keys, select; + wyString query, keys, select, query_for_virtuality; MYSQL_RES *res; wyWChar newtable[SIZE_512]={0}; wyChar *tbuff; @@ -1957,20 +1957,32 @@ CCopyTable::DoCopy() } } - ret = GetSelectStmt(select); + ret = GetSelectStmt(select, query_for_virtuality,newtable); if(!ret) { SetCursor(LoadCursor(NULL, IDC_ARROW)); return wyFalse; } + query_for_virtuality_length = query_for_virtuality.GetLength(); + if(query_for_virtuality_length) + { + query_for_virtuality.Strip(2); + query.AddSprintf("%s)", query_for_virtuality.GetString()); + } if(keys.GetLength() == 0) - { + { + if(query_for_virtuality_length == 0) query.Strip(2); } else + { + query.Strip(1); + if(query_for_virtuality_length) + query.Add(","); query.AddSprintf("%s", keys.GetString()); - + } + //Collation, Engine type, Create table options(min_rows, max_rows, checksum, delay_key_write, row_format) if(IsMySQL41(m_tunnel, m_mysql)) query.AddSprintf("engine=%s %s collate = %s comment = '%s' ", m_type.GetString(), m_createoptions.GetString(), m_collate.GetString(), m_comment.GetString()); @@ -1979,7 +1991,13 @@ CCopyTable::DoCopy() query.AddSprintf("%s", select.GetString()); - res = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query); + res = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + + if(isintransaction == 1) + return wyFalse; + + +// res = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query); if(!res && m_tunnel->mysql_affected_rows(*m_mysql)== -1) { @@ -1987,6 +2005,7 @@ CCopyTable::DoCopy() SetCursor(LoadCursor(NULL, IDC_ARROW)); return wyFalse; } + query.Clear(); success = AddTimestampDefault(m_newtable.GetString()); if(!success) @@ -2044,7 +2063,7 @@ CCopyTable::AddTimestampDefault(const wyChar *newtable) wyString query, primary; MYSQL_RES *myres, *res; MYSQL_ROW myrow; - wyInt32 typeval, defaultval, index, ret, fieldno = 0; + wyInt32 typeval, defaultval, index, ret, fieldno = 0, isintransaction = 1; wyChar *escapecomment; wyString strcreate = ""; @@ -2089,7 +2108,11 @@ CCopyTable::AddTimestampDefault(const wyChar *newtable) free(escapecomment); } - res = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, primary); + res = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, primary, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!res && m_tunnel->mysql_affected_rows(*m_mysql)== -1) { ShowMySQLError(m_hwnd, m_tunnel, m_mysql, primary.GetString()); @@ -2117,6 +2140,7 @@ CCopyTable::CopyTriggers(const wyChar *database, const wyChar *table, const wyCh wyString query, triggername; wyString name_buff; wyString msg; + wyInt32 isintransaction = 1; query.Sprintf("show triggers from `%s` like %s", database, quote_for_like(table,(wyChar *)name_buff.GetString())); @@ -2135,7 +2159,10 @@ CCopyTable::CopyTriggers(const wyChar *database, const wyChar *table, const wyCh newtable, row[3] /* Statement */); - res1 = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query); + res1 = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; if(!res1 && m_tunnel->mysql_affected_rows(*m_mysql)== -1) { @@ -2362,7 +2389,7 @@ CCopyTable::AddExtraInfo(const wyChar *newtable) wyString query, primary; MYSQL_RES *myres, *res; MYSQL_ROW myrow; - wyInt32 extraval, index, ret; + wyInt32 extraval, index, ret, isintransaction = 1; wyChar *escapecomment; wyString myrowstr, myrowstr1; wyBool ismysql41 = IsMySQL41(m_tunnel, m_mysql); @@ -2402,7 +2429,11 @@ CCopyTable::AddExtraInfo(const wyChar *newtable) m_db.GetString(), newtable, myrowstr.GetString(), myrowstr.GetString(), myrowstr1.GetString()); } - res = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, primary, wyFalse); + res = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, primary, wyFalse, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + if(!res && m_tunnel->mysql_affected_rows(*m_mysql)== -1) { ShowMySQLError(m_hwnd, m_tunnel, m_mysql, primary.GetString()); @@ -2420,26 +2451,93 @@ CCopyTable::AddExtraInfo(const wyChar *newtable) return wyTrue; } + // Function prepares the select stmt and stores it in the buffer passed as parameter. wyBool -CCopyTable::GetSelectStmt(wyString &select) +CCopyTable::GetSelectStmt(wyString &select, wyString &query_for_virtuality,wyWChar new_table[]) { - wyInt32 state, count, itemcount; + wyInt32 state, count, itemcount, extraval, pos1 = 0, pos2 = 0, comment_index; wyWChar temptext[SIZE_512] = {0}; - wyString tempstr; + wyString tempstr, query, create_query; + MYSQL_RES *myres, *myres1; + MYSQL_ROW myrow; + query.Sprintf("show full fields from `%s`.`%s`", m_db.GetString(), m_table.GetString()); + myres = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query); + + if(!myres) + { + ShowMySQLError(m_hwnd, m_tunnel, m_mysql, query.GetString()); + return wyFalse; + } + + query.Sprintf("Show create table `%s`.`%s`",m_db.GetString(), m_table.GetString()); + myres1 = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query); + + if(!myres) + { + ShowMySQLError(m_hwnd, m_tunnel, m_mysql, query.GetString()); + return wyFalse; + } + extraval = GetFieldIndex(myres, "extra", m_tunnel, m_mysql); + comment_index = GetFieldIndex(myres, "Comment", m_tunnel, m_mysql); + myrow=m_tunnel ->mysql_fetch_row(myres1); + create_query.Sprintf(myrow[1]); + state = SendMessage(m_hwndallfield, BM_GETCHECK, 0, 0); itemcount = ListView_GetItemCount(m_hwndlist); select.SetAs("select "); for(count = 0; count < itemcount; count++) - { + { + myrow = m_tunnel->mysql_fetch_row(myres); state = ListView_GetCheckState(m_hwndlist, count); - + /* + Refer this if some issue comes regarding backticks http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_sql_quote_show_create + execute the required query , save the previous state and execute it again + issue may come only when sql_quote_show_create is set to 0 + + */ if(state) { ListView_GetItemText(m_hwndlist, count, 0, temptext, SIZE_512-1); tempstr.SetAs(temptext); + if(strstr(myrow[extraval], "VIRTUAL") || strstr(myrow[extraval], "VIRTUAL GENERATED") || strstr(myrow[extraval], "STORED GENERATED") || strstr(myrow[extraval], "STORED") || strstr(myrow[extraval], "PERSISTENT")) + { + wyString temp(""); + temp.AddSprintf("`%s`",tempstr.GetString()); + pos1 = create_query.Find(temp.GetString(),pos2+1); + wyInt32 temp_length = temp.GetLength(); + pos2 = pos1 + temp_length; + if(strstr(myrow[extraval], "VIRTUAL")|| strstr(myrow[extraval], "VIRTUAL GENERATED")) + pos2 = create_query.Find("VIRTUAL",pos2); + else if (strstr(myrow[extraval], "STORED GENERATED") || strstr(myrow[extraval], "STORED")) + pos2 = create_query.Find("STORED",pos2); + else + pos2 = create_query.Find("PERSISTENT",pos2); + + //pos2 = create_query.Find("Comment",pos1+1); + wyInt32 pos3 = create_query.FindChar(',',pos2); + wyInt32 pos4 = create_query.FindChar(')',pos2); + //pos2 = ( (pos3 < pos2) && (pos3 >= 0) ) ? pos3 : pos2; + if( comment_index >=0 ) + { + temp.SetAs(myrow[comment_index]); + int comment_length = temp.GetLength(); + if(comment_length) + { + pos2 = (create_query.Find(temp.GetString(),pos2)) + comment_length; + } + else + pos2 = ( (pos3 < pos4) && (pos3 > 0) ) ? (pos3-1) : (pos4-1); + } + else + pos2 = ( (pos3 < pos4) && (pos3 > 0) ) ? (pos3-1) : (pos4-1); + + + query_for_virtuality.AddSprintf("%s, ",create_query.Substr(pos1, pos2-pos1+1)); + continue; + } select.AddSprintf("`%s`, ", tempstr.GetString()); } } @@ -2450,6 +2548,9 @@ CCopyTable::GetSelectStmt(wyString &select) // now see if only structure is selected or not. state = SendMessage(m_hwndstrucdata, BM_GETCHECK, 0, 0); + mysql_free_result(myres); + mysql_free_result(myres1); + // this causes only structure to be copied. if(!(state & BST_CHECKED)) select.Add(" where 1 = 0"); @@ -2513,6 +2614,7 @@ CCopyTable::AddRelation() wyChar seps[] = ";"; MYSQL_RES *res; wyString newtextstr; + wyInt32 isintransaction = 1; if(m_type.CompareI("InnoDB") != 0 && m_type.CompareI("pbxt") != 0 && m_type.CompareI("soliddb") != 0 ) return wyTrue; @@ -2542,7 +2644,10 @@ CCopyTable::AddRelation() query.Sprintf("alter table `%s`.`%s` add foreign key %s", m_db.GetString(), m_newtable.GetString(), newtextstr.GetString()); - res = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query); + res = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; if(!res && m_tunnel->mysql_affected_rows(*m_mysql)) { if(comment) @@ -3065,7 +3170,7 @@ TableDiag::GetDBName(wyString &dbname) wyBool TableDiag::DiagOptimize() { - wyInt32 count, ret, itemcount, checkeditemcount = 0, binlog; + wyInt32 count, ret, itemcount, checkeditemcount = 0, binlog, isintransaction = 1; wyString query, dbname, tablestr; wyWChar table[SIZE_512]= {0}; LVITEM lvi; @@ -3107,7 +3212,10 @@ TableDiag::DiagOptimize() query.Strip(2); SetCursor(LoadCursor(NULL, IDC_WAIT)); - myres = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query); + myres = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + + if(isintransaction == 1) + return wyFalse; if(!myres) { ShowMySQLError(m_hwndparent, m_tunnel, m_mysql, query.GetString()); @@ -3128,7 +3236,7 @@ TableDiag::DiagOptimize() wyBool TableDiag::DiagAnalyze() { - wyInt32 count, ret, itemcount, checkeditemcount = 0, binlog; + wyInt32 count, ret, itemcount, checkeditemcount = 0, binlog, isintransaction = 1; wyString query, dbname, tablestr; wyWChar table[SIZE_512] = {0}; LVITEM lvi; @@ -3166,7 +3274,10 @@ TableDiag::DiagAnalyze() query.Strip(2); SetCursor(LoadCursor(NULL, IDC_WAIT)); - myres = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query); + myres = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + + if(isintransaction == 1) + return wyFalse; if(!myres) { ShowMySQLError(m_hwndparent, m_tunnel, m_mysql, query.GetString()); @@ -3236,7 +3347,7 @@ TableDiag::DiagCheckAddOptions(wyString &query, CShowInfo *csi) { // now add the option things. // but first we get the text. - wyInt32 cursel; + wyInt32 cursel, isintransaction = 1; wyWChar option[SIZE_512]; MYSQL_RES *myres; wyString optionstr; @@ -3254,7 +3365,11 @@ TableDiag::DiagCheckAddOptions(wyString &query, CShowInfo *csi) SetCursor(LoadCursor(NULL, IDC_WAIT)); - myres = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query); + myres = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + + if(isintransaction == 1) + return wyFalse; + if(!myres) { ShowMySQLError(m_hwndparent, m_tunnel, m_mysql, query.GetString()); @@ -3343,6 +3458,7 @@ MYSQL_RES * TableDiag::DiagRepairOther(wyString &query) { MYSQL_RES *myres; + wyInt32 isintransaction = 1; if(SendMessage(GetDlgItem(m_hwnd, IDC_DIAG_QUICKREPAIR), BM_GETCHECK, 0, 0)) query.Add(" QUICK "); @@ -3355,7 +3471,10 @@ TableDiag::DiagRepairOther(wyString &query) SetCursor(LoadCursor(NULL, IDC_WAIT)); - myres = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query); + myres = ExecuteAndGetResult(GetActiveWin(), m_tunnel, m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + + if(isintransaction == 1) + return NULL; if(!myres) { @@ -4425,6 +4544,27 @@ EmptyDB::EmptyDatabase() pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONINFORMATION); return wyFalse; } +#ifndef COMMUNITY + wyInt32 presult = 6; + if(wnd->m_ptransaction && wnd->m_ptransaction->m_starttransactionenabled == wyFalse) + { + if(pGlobals->m_pcmainwin->m_topromptonimplicit) + presult = MessageBox(GetActiveWindow(), _(L"You have an active transaction. This operation will cause Transaction to commit and end. Do you want to Continue?"), + _(L"Warning"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + if(presult == 6) + { + wyString query; + wyInt32 isintransaction = 1; + query.Sprintf("COMMIT"); + ExecuteAndGetResult(wnd, m_tunnel, m_mysql, query, wyFalse, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction); + + if(isintransaction == 1) + return wyFalse; + } + else + return wyFalse; + } +#endif SetCursor(LoadCursor(NULL, IDC_WAIT)); SetGroupProcess(wnd, wyTrue); diff --git a/src/PreferenceBase.cpp b/src/PreferenceBase.cpp index 3f6e47b..a5ea3d2 100644 --- a/src/PreferenceBase.cpp +++ b/src/PreferenceBase.cpp @@ -46,20 +46,22 @@ extern PGLOBALS pGlobals; #define HISTORY_POS_DEFAULT 0 //Other Preference Default Values -#define COLUMNWIDTH_DEFAULT 0 -#define REFRESHTABLEDATA_DEFAULT 0 -#define GETINFOALWAYS_DEFAULT 0 -#define GETINFOKW_DEFAULT 1 -#define SWITCHSHORTCUT_DEFAULT 0 -#define OPENTABLES_DEFAULT 0 -#define CONRESTORE_DEFAULT 1 -#define ENABLEUPGRADE_DEFAULT 1 -#define UPDATEPROMPT_DEFAULT 1 -#define SHOWALLINTABLEDATA_DEFAULT 0 -#define LOWLIMIT_DEFAULT 0 -#define RETAINCOLUMNWIDTH_DEFAULT 1 -#define RESULTTABPAGE_DEFAULT 1 -#define RESULTRETAINPAGE_DEFAULT 1 +#define COLUMNWIDTH_DEFAULT 0 +#define REFRESHTABLEDATA_DEFAULT 0 +#define GETINFOALWAYS_DEFAULT 0 +#define GETINFOKW_DEFAULT 1 +#define SWITCHSHORTCUT_DEFAULT 0 +#define OPENTABLES_DEFAULT 0 +#define CONRESTORE_DEFAULT 1 +#define ENABLEUPGRADE_DEFAULT 1 +#define UPDATEPROMPT_DEFAULT 1 +#define PROMPTTRANSACTION_DEFAULT 1 +#define PROMPTTRANSACTIONCLOSE_DEFAULT 1 +#define SHOWALLINTABLEDATA_DEFAULT 0 +#define LOWLIMIT_DEFAULT 0 +#define RETAINCOLUMNWIDTH_DEFAULT 1 +#define RESULTTABPAGE_DEFAULT 1 +#define RESULTRETAINPAGE_DEFAULT 1 @@ -1060,6 +1062,28 @@ PreferenceBase::OthersPrefHandleWmCommand(HWND hwnd, WPARAM wParam) { switch(LOWORD(wParam)) { +#ifndef COMMUNITY + case IDC_PROMPTTRANSACTION: + { + if(Button_GetCheck(GetDlgItem(hwnd, IDC_PROMPTTRANSACTION)) == BST_CHECKED) + { + pGlobals->m_pcmainwin->m_topromptonimplicit = wyTrue; + } + else + pGlobals->m_pcmainwin->m_topromptonimplicit = wyFalse; + } + break; + case IDC_PROMPTCLOSETRANSACTION: + { + if(Button_GetCheck(GetDlgItem(hwnd, IDC_PROMPTCLOSETRANSACTION)) == BST_CHECKED) + { + pGlobals->m_pcmainwin->m_topromptonclose = wyTrue; + } + else + pGlobals->m_pcmainwin->m_topromptonclose = wyFalse; + } + break; +#endif case IDC_OTHERSRESTORETAB: SetOthersPrefDefaultValues(hwnd); break; @@ -1496,6 +1520,21 @@ PreferenceBase::InitOthersPrefValues() GetOthersPrefSizeValues(m_hwnd); + if(pGlobals->m_pcmainwin->m_connection->m_enttype != ENT_NORMAL && pGlobals->m_pcmainwin->m_connection->m_enttype != ENT_ULTIMATE && pGlobals->m_pcmainwin->m_connection->m_enttype != ENT_TRIAL) + { + SetWindowText(GetDlgItem(m_hwnd, IDC_TRANSACTION), _(L"Transaction options (Enterprise/Ultimate only)")); + EnableWindow(GetDlgItem(m_hwnd, IDC_PROMPTTRANSACTION), FALSE); + EnableWindow(GetDlgItem(m_hwnd, IDC_PROMPTCLOSETRANSACTION), FALSE); + return; + } + else + { + truncdata = wyIni::IniGetInt(GENERALPREFA, "PromptinTransaction", PROMPTTRANSACTION_DEFAULT, dirstr.GetString()); + SendMessage(GetDlgItem(m_hwnd, IDC_PROMPTTRANSACTION), BM_SETCHECK, truncdata, 0); + truncdata = wyIni::IniGetInt(GENERALPREFA, "PromptinTransactionClose", PROMPTTRANSACTIONCLOSE_DEFAULT, dirstr.GetString()); + SendMessage(GetDlgItem(m_hwnd, IDC_PROMPTCLOSETRANSACTION), BM_SETCHECK, truncdata, 0); + } + return; } @@ -1716,8 +1755,14 @@ PreferenceBase::SaveOthersPreferences(HWND hwndbase, wyInt32 page) SetBoolProfileString(hwnd, GENERALPREF, L"UpdateCheck", IDC_ENABLEUPGRADE); SetBoolProfileString(hwnd, GENERALPREF, L"PromptUpdate", IDC_UPDATEPROMPT); - /* starting from 4.0 RC1 we support lowlimit and high limit also */ - +#ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0) + { + SetBoolProfileString(hwnd, GENERALPREF, L"PromptinTransaction", IDC_PROMPTTRANSACTION); + + SetBoolProfileString(hwnd, GENERALPREF, L"PromptinTransactionClose", IDC_PROMPTCLOSETRANSACTION); + }/* starting from 4.0 RC1 we support lowlimit and high limit also */ +#endif SetIntProfileString(hwnd, GENERALPREF, L"ResulttabPageRows", IDC_HIGHLIMIT); SetBoolProfileString(hwnd, GENERALPREF, L"ResuttabPaging", IDC_RESUTTABPAGE); SetBoolProfileString(hwnd, GENERALPREF, L"ResuttabRetainsPage", IDC_RESUTTABPAGERETAIN); @@ -1813,6 +1858,15 @@ PreferenceBase::SetBoolProfileString(HWND hwnd, wyWChar *appname, wyWChar *keyna switch(id) { +#ifndef COMMUNITY + case IDC_PROMPTTRANSACTION: + pGlobals->m_pcmainwin->m_topromptonimplicit = (status ? wyTrue : wyFalse); + break; + + case IDC_PROMPTCLOSETRANSACTION: + pGlobals->m_pcmainwin->m_topromptonclose = (status ? wyTrue : wyFalse); + break; +#endif case IDC_RESUTTABPAGE: pGlobals->m_resuttabpageenabled = (status ? wyTrue : wyFalse); break; @@ -2184,7 +2238,14 @@ PreferenceBase::SetOthersPrefDefaultValues(HWND hwnd) SendMessage(GetDlgItem(hwnd, IDC_REFRESHTABLEDATA), BM_SETCHECK, REFRESHTABLEDATA_DEFAULT, 0); SendMessage(GetDlgItem(hwnd, IDC_UPDATEPROMPT), BM_SETCHECK, UPDATEPROMPT_DEFAULT, 0); +#ifndef community + if(pGlobals->m_entlicense.CompareI("Professional") != 0) + { + SendMessage(GetDlgItem(hwnd, IDC_PROMPTTRANSACTION), BM_SETCHECK, PROMPTTRANSACTION_DEFAULT, 0); + SendMessage(GetDlgItem(hwnd, IDC_PROMPTCLOSETRANSACTION), BM_SETCHECK, PROMPTTRANSACTIONCLOSE_DEFAULT, 0); + } +#endif //Iconsize combo box iconsize.SetAs(TOOLBARICONSIZE_DEFAULT); //default theme @@ -2445,6 +2506,10 @@ PreferenceBase::SaveDefaultOthersPreferences() wyIni::IniWriteInt(GENERALPREFA, "RefreshTableData", REFRESHTABLEDATA_DEFAULT, dirstr.GetString()); wyIni::IniWriteInt(GENERALPREFA, "PromptUpdate", UPDATEPROMPT_DEFAULT, dirstr.GetString()); + + wyIni::IniWriteInt(GENERALPREFA, "PromptinTransaction", PROMPTTRANSACTION_DEFAULT, dirstr.GetString()); + + wyIni::IniWriteInt(GENERALPREFA, "PromptinTransactionClose", PROMPTTRANSACTION_DEFAULT, dirstr.GetString()); wyIni::IniWriteInt(GENERALPREFA, "ResulttabPageRows", HIGHLIMIT_DEFAULT, dirstr.GetString()); pGlobals->m_highlimitglobal = HIGHLIMIT_DEFAULT; diff --git a/src/QueryThread.cpp b/src/QueryThread.cpp index 442a5fd..6c9af7a 100644 --- a/src/QueryThread.cpp +++ b/src/QueryThread.cpp @@ -33,6 +33,8 @@ extern PGLOBALS pGlobals; #define WARNINGMSG _("Note: To see complete list of warning(s), enable Tools -> Preferences -> General -> Show Warning(s) in Messages Tab") #define SPACE_15 15 #define NO_QUERY_EXECUTED _("No query(s) were executed. Please enter a query in the SQL window or place the cursor inside a query.") +#define NO_QUERY_EXECUTED_TRANS _("No query(s) were executed.") +#define IN_TRANSACTION -10 void AddErrorOrMsg(wyInt32 errstatus, wyString& buffer, Tunnel * tunnel, PMYSQL mysql, const wyChar* query, @@ -209,7 +211,8 @@ HelperExecuteQuery(QUERYTHREADPARAMS * param, const wyChar* query,wyBool ismulti ret = my_query(param->wnd, param->tunnel, param->mysql, querytemp.GetString(), querytemp.GetLength(), wyFalse, wyFalse, param->stop); param->wnd->SetThreadBusy(wyFalse); - + if(ret == IN_TRANSACTION) + return IN_TRANSACTION; if(ret) { elem = new QueryResultElem; @@ -321,7 +324,12 @@ HelperExecuteQuery(QUERYTHREADPARAMS * param, const wyChar* query,wyBool ismulti } ChangeContextDB(param->tunnel, param->mysql, query, wyTrue); - + #ifndef COMMUNITY + if(pGlobals->m_entlicense.CompareI("Professional") != 0) + { + ChangeTransactionState(param->wnd, query); + } + #endif /* add the element to the linked list of result */ param->list->Insert(elem); @@ -506,7 +514,12 @@ ExecuteQuery(QUERYTHREADPARAMS * param) if(param->m_iseditor == wyTrue && pGlobals->m_resuttabpageenabled == wyTrue) HandleLimitWithSelectQuery(dump2, param); - if(HelperExecuteQuery(param, dump2,ismultiplequeries)) + wyInt32 r = HelperExecuteQuery(param, dump2,ismultiplequeries); + if(r == IN_TRANSACTION) + { + break; + } + else if(r) { (*param->error)++; param->wnd->m_isselectquery = wyFalse; @@ -844,6 +857,12 @@ AddQueryResults(QueryResultList * queryresult, wyString &str, TabMgmt * tab, wyI if(str.GetLength() == 0) { +#ifndef COMMUNITY + if(wnd->m_ptransaction && (wnd->m_ptransaction->m_stopquerytransaction == wyTrue) + && (wnd->m_ptransaction->m_starttransactionenabled == wyFalse)) + str.SetAs(NO_QUERY_EXECUTED_TRANS); + else +#endif str.SetAs(NO_QUERY_EXECUTED); } else diff --git a/src/SQLMaker.cpp b/src/SQLMaker.cpp index 2a359c9..09e28d9 100644 --- a/src/SQLMaker.cpp +++ b/src/SQLMaker.cpp @@ -27,6 +27,8 @@ #include "FrameWindowHelper.h" #include "ClientMySQLWrapper.h" +#define IN_TRANSACTION -10 + wyUInt32 GetTableStatusStmt(wyString &query, const wyChar *dbname) @@ -72,10 +74,13 @@ GetSelectTableStmt(wyString &query, const wyChar *dbname) MYSQL_RES * ExecuteAndGetResult(MDIWindow *wnd, Tunnel *tunnel, PMYSQL mysql, wyString &query, wyBool isprofile, wyBool isbatch, wyBool currentwnd, bool isread, - bool isforce, wyBool isimport, wyInt32 *stop, wyBool isimporthttp) + bool isforce, wyBool isimport, wyInt32 *stop, wyBool isimporthttp, + wyInt32 *isintransaction, HWND fortransactionprompt) { wyInt32 retcode; MYSQL_RES *myres = NULL; + if(isintransaction) + *isintransaction = 0; if(wnd) wnd->SetThreadBusy(wyTrue); @@ -83,7 +88,7 @@ ExecuteAndGetResult(MDIWindow *wnd, Tunnel *tunnel, PMYSQL mysql, wyString &quer //if(isprofile == wyTrue) //{ retcode = my_query(wnd, tunnel, mysql, query.GetString(), query.GetLength(), isbatch, - wyFalse, stop, 0, isprofile, currentwnd, isread, isimport, isimporthttp); + wyFalse, stop, 0, isprofile, currentwnd, isread, isimport, isimporthttp, fortransactionprompt); //} /*else { @@ -91,8 +96,15 @@ ExecuteAndGetResult(MDIWindow *wnd, Tunnel *tunnel, PMYSQL mysql, wyString &quer retcode = HandleMySQLRealQuery(tunnel, *mysql, query.GetString(), query.GetLength(), isbadforxml ? true : false, isbatch, false, 0, isread); }*/ - - if(retcode) + + if(retcode == IN_TRANSACTION && isintransaction) + { + *isintransaction = 1; + if(wnd) + wnd->SetThreadBusy(wyFalse); + return myres; + } + if(retcode) { if(wnd) wnd->SetThreadBusy(wyFalse); diff --git a/src/TabIndexes.cpp b/src/TabIndexes.cpp index 78d59a4..db867f4 100644 --- a/src/TabIndexes.cpp +++ b/src/TabIndexes.cpp @@ -31,6 +31,8 @@ extern PGLOBALS pGlobals; #define INDEXNAME 0 #define INDEXCOLUMNS 1 #define INDEXTYPE 2 +#define INDEXCOMMENT 3 + #define UM_SETINITFOCUS 545 #define HNDLEIDXMGWD 400 @@ -133,6 +135,7 @@ TabIndexes::TabIndexes(HWND hwnd, TableTabInterfaceTabMgmt* ptabmgmt) m_ptabmgmt = ptabmgmt; m_ismysql41 = IsMySQL41(m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql)); m_ismariadb52 = IsMySQL564MariaDB53(m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql)); + m_ismysql553 = IsMySQL553MariaDB55(m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql)); m_automatedindexrow = -1; m_lastclickindgrid = -1; @@ -175,14 +178,15 @@ TabIndexes::FetchIndexValuesIntoWrapper() MYSQL_RES *myres; MYSQL_ROW myrow; wyString tblname(""), dbname(""); - wyString colstr, indexname(""), indcolsstr(""), indexlength(""); + wyString colstr, indexname(""), indcolsstr(""), indexlength(""),indexcomment(""); wyBool isunique = wyFalse, isfulltext = wyFalse; - wyInt32 ind_keyname = -1, ind_colname = -1, ind_subpart = -1, ind_nonunique = -1, ind_indextype = -1; + wyInt32 ind_keyname = -1, ind_colname = -1, ind_subpart = -1, ind_nonunique = -1, ind_indextype = -1,ind_indexcomment= -1; IndexesStructWrapper *cwrapobj = NULL; IndexInfo *iindex = NULL; IndexColumn *indcols = NULL; List *listindcols = NULL; FieldStructWrapper *fieldswrap = NULL; + wyChar* temp; //..Escaping table name and database name tblname.SetAs(m_ptabmgmt->m_tabinterfaceptr->m_origtblname); @@ -206,6 +210,7 @@ TabIndexes::FetchIndexValuesIntoWrapper() ind_subpart = GetFieldIndex(myres,"sub_part", m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql)); ind_nonunique = GetFieldIndex(myres,"non_unique", m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql)); ind_indextype = GetFieldIndex(myres,"index_type", m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql)); + ind_indexcomment= GetFieldIndex(myres,"Index_comment", m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql)); while(myrow = m_mdiwnd->m_tunnel->mysql_fetch_row(myres)) { @@ -239,6 +244,8 @@ TabIndexes::FetchIndexValuesIntoWrapper() listindcols = new List(); listindcols->Insert(indcols); + // if(m_ismysql553 && myrow[ind_indexcomment]) + // indexcomment.SetAs(myrow[ind_indexcomment]); } else { @@ -250,7 +257,8 @@ TabIndexes::FetchIndexValuesIntoWrapper() indexname.SetAs(myrow[ind_keyname], m_ismysql41); colstr.SetAs(myrow[ind_colname], m_ismysql41); - + if(m_ismysql553 && myrow[ind_indexcomment]) + indexcomment.SetAs(myrow[ind_indexcomment], m_ismysql41); fieldswrap = m_ptabmgmt->m_tabfields->GetWrapperObjectPointer(colstr); //..If fieldwrapper not found, then return false if(!fieldswrap) @@ -298,7 +306,10 @@ TabIndexes::FetchIndexValuesIntoWrapper() iindex->m_name.SetAs(indexname); iindex->m_colsstr.SetAs(indcolsstr); iindex->m_listcolumns = listindcols; - if(isunique) + if(m_ismysql553) + iindex->m_indexcomment.SetAs(indexcomment.GetString()); + + if(isunique) { if(iindex->m_name.CompareI("PRIMARY") == 0) iindex->m_indextype.SetAs("PRIMARY"); @@ -314,6 +325,7 @@ TabIndexes::FetchIndexValuesIntoWrapper() indcolsstr.Clear(); indexname.Clear(); + indexcomment.Clear(); isunique = wyFalse; isfulltext = wyFalse; @@ -324,6 +336,11 @@ TabIndexes::FetchIndexValuesIntoWrapper() indexname.SetAs(myrow[ind_keyname], m_ismysql41); colstr.SetAs(myrow[ind_colname], m_ismysql41); + if(m_ismysql553) + { + temp = (wyChar *) myrow[ind_indexcomment]; + indexcomment.SetAs(temp, m_ismysql41); + } fieldswrap = m_ptabmgmt->m_tabfields->GetWrapperObjectPointer(colstr); //..If fieldwrapper not found, then return false if(!fieldswrap) @@ -375,6 +392,8 @@ TabIndexes::FetchIndexValuesIntoWrapper() iindex->m_name.SetAs(indexname); iindex->m_colsstr.SetAs(indcolsstr); iindex->m_listcolumns = listindcols; + if(m_ismysql553) + iindex->m_indexcomment.SetAs(indexcomment.GetString()); //..Sets the index type if(isunique) { @@ -399,14 +418,14 @@ TabIndexes::InitGrid() wyInt32 counter; // normal counter wyInt32 num_cols; // number of columns GVCOLUMN gvcol; // structure used to create columns for grid - wyChar *heading[] = { _("Index Name"), _("Columns"), _("Index Type")}; - wyInt32 mask[] = { GVIF_TEXT, GVIF_TEXTBUTTON , GVIF_LIST}; + wyChar *heading[] = { _("Index Name"), _("Columns"), _("Index Type"), _("Comment")}; + wyInt32 mask[] = { GVIF_TEXT, GVIF_TEXTBUTTON , GVIF_LIST, GVIF_TEXT}; wyWChar type[][20] = { L"UNIQUE", L"PRIMARY", L"FULLTEXT"}; - VOID *listtype[] = { NULL, NULL, (VOID*)type}; - wyInt32 elemsize[] = {0, 10, sizeof(type[0]) }; - wyInt32 elemcount[] = {0, 8, sizeof(type)/sizeof(type[0]) }; - wyInt32 cx[] = { 150, 150, 150}; - wyInt32 format[] = { GVIF_LEFT, GVIF_LEFT, GVIF_LEFT }; + VOID *listtype[] = { NULL, NULL, (VOID*)type, NULL}; + wyInt32 elemsize[] = {0, 10, sizeof(type[0]), 0 }; + wyInt32 elemcount[] = {0, 8, sizeof(type)/sizeof(type[0]), 0 }; + wyInt32 cx[] = { 150, 150, 150 , 150}; + wyInt32 format[] = { GVIF_LEFT, GVIF_LEFT, GVIF_LEFT, GVIF_LEFT }; wyInt32 width = 0; wyString colname, dbname(RETAINWIDTH_DBNAME), tblname("__create_table"); @@ -416,6 +435,8 @@ TabIndexes::InitGrid() hfont = CustomGrid_GetColumnFont(m_hgridindexes); num_cols = sizeof (heading)/sizeof(heading[0]); + if(! m_ismysql553) + num_cols--; for (counter=0; counter < num_cols ; counter++ ) { @@ -444,15 +465,15 @@ TabIndexes::InitGrid() void TabIndexes::InitDlgGrid() { - wyInt32 i; + wyInt32 i,num_cols; GVCOLUMN gvcol; - wyChar *heading[] = {_("Column"), _("Data Type"), _("Length")}; - wyInt32 elemsize[] = {0 ,0 ,0 }; - wyInt32 elemcount[] = {0, 0, 0 }; - wyInt32 mask[] = {GVIF_TEXT, GVIF_TEXT, GVIF_TEXT }; - wyInt32 cx[] = {195, 98, 85 }; - wyInt32 fmt[] = {GVIF_LEFT, GVIF_LEFT, GVIF_LEFT }; + wyChar *heading[] = {_("Column"), _("Data Type"), _("Length"), _("Comment")}; + wyInt32 elemsize[] = {0 ,0 ,0, 0}; + wyInt32 elemcount[] = {0, 0, 0, 0 }; + wyInt32 mask[] = {GVIF_TEXT, GVIF_TEXT, GVIF_TEXT, GVIF_TEXT }; + wyInt32 cx[] = {195, 98, 85, 200}; + wyInt32 fmt[] = {GVIF_LEFT, GVIF_LEFT, GVIF_LEFT, GVIF_LEFT }; wyInt32 width = 0; wyString colname, dbname(RETAINWIDTH_DBNAME), tblname("__create_index"); @@ -461,8 +482,11 @@ TabIndexes::InitDlgGrid() m_ptabmgmt->m_tabinterfaceptr->SetFont(m_hdlggrid); hfont = CustomGrid_GetRowFont(m_hdlggrid); + num_cols = sizeof(heading)/ sizeof(heading[0]); + if(! m_ismysql553) + num_cols-- ; - for(i=0; i < sizeof(heading)/ sizeof(heading[0]); i++) + for(i=0; i < num_cols ; i++) { //if retain user modified width(prefernce option) is checked or not //if(isretaincolumnwidth == wyTrue) @@ -717,12 +741,14 @@ TabIndexes::OnGVNBeginLabelEdit(HWND hwnd, WPARAM wParam, LPARAM lParam) wyUInt32 row = wParam; wyUInt32 col = lParam; wyUInt32 count = -1; - wyString celldata, indnamestr, indcolsstr; + wyString celldata, indnamestr, indcolsstr, indexcomment; GetGridCellData(m_hgridindexes, row, INDEXNAME, indnamestr); GetGridCellData(m_hgridindexes, row, INDEXCOLUMNS, indcolsstr); GetGridCellData(m_hgridindexes, row, INDEXTYPE, celldata); + + GetGridCellData(m_hgridindexes, row, INDEXCOMMENT, indexcomment); //..Stoping user from setting the index-name of the PRIMARY index if(col == INDEXNAME && celldata.CompareI("primary") == 0) @@ -826,6 +852,10 @@ TabIndexes::ScanEntireRow(wyUInt32 currentrow, wyInt32 currentcol, wyString& cu origtext.SetAs(indexes->m_indextype); break; + case INDEXCOMMENT: + origtext.SetAs(indexes->m_indexcomment); + break; + default: origtext.SetAs(""); } @@ -875,12 +905,16 @@ TabIndexes::OnGVNEndLabelEdit(WPARAM wParam, LPARAM lParam) wyUInt32 row, col; wyString currentdata; wyString indexnamestr(""), indexcolsstr(""); - + wyUInt32 no_of_columns; row = LOWORD(wParam); col = HIWORD(wParam); + if(m_ismysql553) + no_of_columns = 3; + else + no_of_columns = 2; //..Work-around to the cutsomgrid issue - if(!(col >= 0 && col <= 2)) + if(!(col >= 0 && col <= no_of_columns)) return wyTrue; if(!(row >= 0 && row <= CustomGrid_GetRowCount(m_hgridindexes))) @@ -912,6 +946,11 @@ TabIndexes::OnGVNEndLabelEdit(WPARAM wParam, LPARAM lParam) if(!OnEndEditIndexType(wParam, lParam)) return wyFalse; break; + + case INDEXCOMMENT: + if(!OnEndEditIndexComment(wParam, lParam)) + return wyFalse; + break; } if(!m_ptabmgmt->m_tabinterfaceptr->m_dirtytab) @@ -1226,7 +1265,7 @@ TabIndexes::OnEndEditIndexName(WPARAM wParam, LPARAM lParam) cwrapobj = (IndexesStructWrapper*) CustomGrid_GetRowLongData(m_hgridindexes, row); - //..If no wrapper is attached + //..If no wrapper is attached if(!cwrapobj) { iindexes = new IndexInfo(); @@ -1234,7 +1273,8 @@ TabIndexes::OnEndEditIndexName(WPARAM wParam, LPARAM lParam) iindexes->m_indextype.Clear(); iindexes->m_listcolumns = NULL; iindexes->m_name.Clear(); - + if(m_ismysql553) + iindexes->m_indexcomment.Clear(); cwrapobj = new IndexesStructWrapper(iindexes, wyTrue); m_listwrapperstruct.Insert(cwrapobj); } @@ -1299,10 +1339,10 @@ TabIndexes::OnEndEditIndexName(WPARAM wParam, LPARAM lParam) GetGridCellData(m_hgridindexes, row, INDEXTYPE, cwrapobj->m_newval->m_indextype); cwrapobj->m_newval->m_colsstr.Clear(); cwrapobj->m_newval->m_listcolumns = new List; + cwrapobj->m_newval->m_indexcomment.Clear(); } } } - CustomGrid_SetRowLongData(m_hgridindexes, row, (LONG) cwrapobj); CustomGrid_SetItemLongValue(m_hgridindexes, row, col, (LONG) (cwrapobj && cwrapobj->m_newval ? cwrapobj->m_newval->m_listcolumns : NULL)); @@ -1315,6 +1355,109 @@ TabIndexes::OnEndEditIndexName(WPARAM wParam, LPARAM lParam) return wyTrue; } + +wyBool + TabIndexes::OnEndEditIndexComment(WPARAM wParam, LPARAM lParam) +{ + wyChar *data = (wyChar*)lParam; + wyUInt32 row, col; + wyString currentdata(""); + IndexesStructWrapper *cwrapobj = NULL; + IndexInfo *iindexes = NULL; + wyString indexcommstr(""); + wyString indexcolsstr(""); + + row = LOWORD(wParam); + col = HIWORD(wParam); + GetGridCellData(m_hgridindexes, row, INDEXCOLUMNS, indexcolsstr); + GetGridCellData(m_hgridindexes, row, INDEXCOMMENT, indexcommstr); + + cwrapobj = (IndexesStructWrapper*) CustomGrid_GetRowLongData(m_hgridindexes, row); + + if(data) + currentdata.SetAs(data); + + currentdata.RTrim(); + cwrapobj = (IndexesStructWrapper*) CustomGrid_GetRowLongData(m_hgridindexes, row); + + //..If no wrapper is attached + if(!cwrapobj) + { + iindexes = new IndexInfo(); + iindexes->m_colsstr.Clear(); + iindexes->m_indextype.Clear(); + iindexes->m_listcolumns = NULL; + iindexes->m_name.Clear(); + if(m_ismysql553) + iindexes->m_indexcomment.Clear(); + cwrapobj = new IndexesStructWrapper(iindexes, wyTrue); + m_listwrapperstruct.Insert(cwrapobj); + } + else + { + //..If the index-name is erased + if(!currentdata.GetLength()) + { + //..If user has deleted index-name and index-columns values from existing index, this condition will be false + // we need to proceed only when user has not cleared Existing index + if(cwrapobj->m_newval) + { + //..If Index-Columns are not selected, then set m_newval to NULL. + //.. if the index is new, then remove it from the m_listwrapper. + if(!indexcolsstr.GetLength()) + { + //..existing index (Alter table) + if(cwrapobj->m_oldval) + { + if(cwrapobj->m_oldval != cwrapobj->m_newval) //..true, if existing index is already modified + delete cwrapobj->m_newval; + cwrapobj->m_newval = NULL; + } + //..newly added index + else if(cwrapobj->m_newval) + { + m_listwrapperstruct.Remove(cwrapobj); + delete cwrapobj; + cwrapobj = NULL; + } + } + //.. If index-columns are selected, + else + { + if(cwrapobj->m_newval == cwrapobj->m_oldval) + { + cwrapobj->m_newval = GetDuplicateIndexesStruct(cwrapobj->m_oldval); + CustomGrid_SetItemLongValue(m_hgridindexes, row, INDEXCOLUMNS, (LONG)cwrapobj->m_newval->m_listcolumns); + } + } + } + } + //.. if something is there as index-name + else + { + //..If user has not deleted all index-values from grid row + if(cwrapobj->m_newval) + { + //..If existing index is not yet modified + if(cwrapobj->m_newval == cwrapobj->m_oldval) + { + cwrapobj->m_newval = GetDuplicateIndexesStruct(cwrapobj->m_oldval); + CustomGrid_SetItemLongValue(m_hgridindexes, row, INDEXCOLUMNS, (LONG)cwrapobj->m_newval->m_listcolumns); + } + } + } + } + CustomGrid_SetRowLongData(m_hgridindexes, row, (LONG) cwrapobj); + CustomGrid_SetItemLongValue(m_hgridindexes, row, col, (LONG) (cwrapobj && cwrapobj->m_newval ? cwrapobj->m_newval->m_listcolumns : NULL)); + + if(cwrapobj && cwrapobj->m_newval) + cwrapobj->m_newval->m_indexcomment.SetAs(currentdata); + + ScanEntireRow(row, col, currentdata); + + return wyTrue; +} + void TabIndexes::RemoveIndexWrappersFromFieldsWrappers(IndexColumn *indcol, IndexesStructWrapper* indexwrap) { @@ -1351,7 +1494,8 @@ TabIndexes::GetDuplicateIndexesStruct(IndexInfo* duplicateof) //..Setting index_name and index_type indexes->m_name.SetAs(duplicateof->m_name); indexes->m_indextype.SetAs(duplicateof->m_indextype); - + if(m_ismysql553) + indexes->m_indexcomment.SetAs(duplicateof->m_indexcomment); //..Setting list_columns backup_copy and working_copy icols = (IndexColumn*) duplicateof->m_listcolumns->GetFirst(); while(icols) @@ -1384,6 +1528,10 @@ TabIndexes::SetValueToStructure(wyUInt32 row, wyUInt32 col, wyChar* data) case INDEXTYPE: cwrap->m_newval->m_indextype.SetAs(data); break; + + case INDEXCOMMENT: + cwrap->m_newval->m_indexcomment.SetAs(data); + break; } } @@ -1772,6 +1920,10 @@ TabIndexes::FillInitValues() CustomGrid_SetItemLongValue(m_hgridindexes, row, INDEXCOLUMNS, (LPARAM)cwrapobj->m_oldval->m_listcolumns); CustomGrid_SetText(m_hgridindexes, row, INDEXTYPE, cwrapobj->m_oldval->m_indextype.GetString()); + + if(m_ismysql553) + CustomGrid_SetText(m_hgridindexes, row, INDEXCOMMENT,cwrapobj->m_oldval->m_indexcomment.GetString()); + CustomGrid_SetRowLongData(m_hgridindexes, row, (LPARAM) cwrapobj); if(cwrapobj->m_oldval->m_indextype.CompareI("PRIMARY KEY") == 0 || cwrapobj->m_oldval->m_name.CompareI("PRIMARY") == 0) @@ -2281,7 +2433,7 @@ TabIndexes::GetNewAndModifiedIndexes(wyString &query, wyBool execute) { wyInt32 count=0; wyBool validflg = wyTrue; - wyString tempstr(""), celldata, indexnamestr, temp, indextypestr, columnsstr; + wyString tempstr(""), celldata, indexnamestr, temp, indextypestr, columnsstr, indexcomment= ""; wyString droppk(""), addpk(""); IndexesStructWrapper *pwrapobj = NULL; @@ -2314,7 +2466,8 @@ TabIndexes::GetNewAndModifiedIndexes(wyString &query, wyBool execute) GetGridCellData(m_hgridindexes, row, INDEXNAME, indexnamestr); GetGridCellData(m_hgridindexes, row, INDEXCOLUMNS, columnsstr); GetGridCellData(m_hgridindexes, row, INDEXTYPE, indextypestr); - + if(m_ismysql553) + GetGridCellData(m_hgridindexes, row, INDEXCOMMENT, indexcomment); if(!indextypestr.GetLength()) indextypestr.SetAs("index"); else @@ -2326,15 +2479,26 @@ TabIndexes::GetNewAndModifiedIndexes(wyString &query, wyBool execute) if(indextypestr.CompareI("primary") == 0) { if(columnsstr.GetLength()) - addpk.AddSprintf("\r\n add primary key (%s),", columnsstr.GetString()); + addpk.AddSprintf("\r\n add primary key (%s)", columnsstr.GetString()); + if(m_ismysql553 && indexcomment.GetLength()) + { + addpk.AddSprintf("Comment \"%s\" ", indexcomment.GetString()); + } + addpk.AddSprintf(","); } else { indexnamestr.FindAndReplace("`", "``"); - if(indexnamestr.GetLength()) - tempstr.AddSprintf("\r\n add %s `%s` (%s),", indextypestr.GetString(), indexnamestr.GetString(), columnsstr.GetString()); + if(indexnamestr.GetLength()) + tempstr.AddSprintf("\r\n add %s `%s` (%s)", indextypestr.GetString(), indexnamestr.GetString(), columnsstr.GetString()); else - tempstr.AddSprintf("\r\n add %s (%s),", indextypestr.GetString(), columnsstr.GetString()); + tempstr.AddSprintf("\r\n add %s (%s)", indextypestr.GetString(), columnsstr.GetString()); + if(m_ismysql553 && indexcomment.GetLength()) + { + indexcomment.LTrim(); + tempstr.AddSprintf(" Comment \"%s\" ",indexcomment.GetString()); + } + tempstr.AddSprintf(","); } if(pwrapobj->m_errmsg) { @@ -2385,8 +2549,10 @@ TabIndexes::OnIDOK(HWND hwnd) indexstruct->m_name.SetAs(""); indexstruct->m_colsstr.SetAs(""); indexstruct->m_indextype.SetAs(""); + indexstruct->m_indexcomment.SetAs(""); indexstruct->m_listcolumns = listindexcolumns; + //..Creating a new wrapper cindexeswrap = new IndexesStructWrapper(indexstruct, wyTrue); m_listwrapperstruct.Insert(cindexeswrap); @@ -2453,8 +2619,12 @@ TabIndexes::OnIDOK(HWND hwnd) refcols.RTrim(); wyString indexnamestr(""); + wyString indexcomment(""); GetGridCellData(m_hgridindexes, row, INDEXNAME, indexnamestr); + if(m_ismysql553) + GetGridCellData(m_hgridindexes, row, INDEXCOMMENT, indexcomment); + //..if no index name is there on the row and no ref-columns are selected, then treat that index as deleted if(!refcols.GetLength() && !indexnamestr.GetLength()) { @@ -2485,13 +2655,14 @@ TabIndexes::OnIDOK(HWND hwnd) CustomGrid_SetText(m_hgridindexes, row, col, refcols.GetString()); cindexeswrap->m_newval->m_colsstr.SetAs(refcols); cindexeswrap->m_newval->m_listcolumns = listindexcolumns; - + cindexeswrap->m_newval->m_indexcomment.SetAs(indexcomment); //..This section checks for the equality of new and old values of index. If both are same, then we shall delete the newval and newval = oldval //..Applicable to Alter table only { if(cindexeswrap->m_oldval && cindexeswrap->m_newval && //..If all newval and oldval values are equal, then drop the newval; cindexeswrap->m_oldval->m_name.CompareI(cindexeswrap->m_newval->m_name) == 0 && - cindexeswrap->m_oldval->m_indextype.CompareI(cindexeswrap->m_newval->m_indextype) == 0 + cindexeswrap->m_oldval->m_indextype.CompareI(cindexeswrap->m_newval->m_indextype) == 0 && + (m_ismysql553?(cindexeswrap->m_oldval->m_indexcomment.CompareI(cindexeswrap->m_newval->m_indexcomment) == 0) : 1) ) { IndexColumn *indcol = NULL, *tmpindcol = NULL; diff --git a/src/TableTabInterface.cpp b/src/TableTabInterface.cpp index b2a90cf..e7a0b12 100644 --- a/src/TableTabInterface.cpp +++ b/src/TableTabInterface.cpp @@ -1290,8 +1290,12 @@ wyBool TableTabInterface::ExecuteQuery(wyString &query) { MYSQL_RES *res; + wyInt32 isintransaction = 1; - res = ExecuteAndGetResult(m_mdiwnd, m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql), query); + res = ExecuteAndGetResult(m_mdiwnd, m_mdiwnd->m_tunnel, &(m_mdiwnd->m_mysql), query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + + if(isintransaction == 1) + return wyFalse; if(!res && m_mdiwnd->m_tunnel->mysql_affected_rows(m_mdiwnd->m_mysql) == -1) { @@ -2444,7 +2448,8 @@ TableTabInterface::IsTableInnoDB(wyBool& error) MDIWindow *wnd = NULL; VERIFY(wnd = GetActiveWin()); - + if(!m_myrestablestatus) + return wyFalse; m_mdiwnd->m_tunnel->mysql_data_seek(m_myrestablestatus, 0); VERIFY(mystatusrow = m_mdiwnd->m_tunnel->mysql_fetch_row(m_myrestablestatus)); diff --git a/src/TableView.cpp b/src/TableView.cpp index 49416e0..4186191 100644 --- a/src/TableView.cpp +++ b/src/TableView.cpp @@ -570,4 +570,4 @@ TableView::GetAutoIncrIndex() } return -1; -} \ No newline at end of file +} diff --git a/src/UserManager.cpp b/src/UserManager.cpp index 3a49964..f02f724 100644 --- a/src/UserManager.cpp +++ b/src/UserManager.cpp @@ -888,7 +888,7 @@ UserManager::OnWMCommand(WPARAM wparam, LPARAM lparam) return wyTrue; } if(m_initcompleted == wyTrue && - (HIWORD(wparam) == CBN_SELCHANGE)) + (HIWORD(wparam) == CBN_SELCHANGE && LOWORD(wparam) == IDC_USERCOMBO)) { if(!SendMessage(GetDlgItem(m_hwnd,IDC_USERCOMBO), CB_GETDROPPEDSTATE, NULL, NULL)) OnUserComboChange(); @@ -2257,7 +2257,7 @@ wyBool UserManager::ApplyLimitations() { wyString query, tempuser, temphost; - wyInt32 temp[4], i; + wyInt32 temp[4], i, isintransaction = 1; wyBool flag = wyFalse; wyChar* limitations[] = { @@ -2293,7 +2293,10 @@ UserManager::ApplyLimitations() } SetCursor(LoadCursor(NULL, IDC_WAIT)); - ExecuteAndGetResult(m_hmdi, m_hmdi->m_tunnel, &m_hmdi->m_mysql, query); + ExecuteAndGetResult(m_hmdi, m_hmdi->m_tunnel, &m_hmdi->m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + + if(isintransaction == 1) + return wyFalse; if(m_hmdi->m_tunnel->mysql_affected_rows(m_hmdi->m_mysql)) { @@ -2549,12 +2552,17 @@ UserManager::PrepareGrantRevokeQuery(sqlite3_stmt** privstmt, sqlite3_stmt** pri wyBool UserManager::ExecuteGrantRevoke(wyString* grantquery, wyString* revokequery) { + wyInt32 isintransaction = 1; + SetCursor(LoadCursor(NULL, IDC_WAIT)); //if grant query is present if(grantquery && grantquery->GetLength()) { - ExecuteAndGetResult(m_hmdi, m_hmdi->m_tunnel, &m_hmdi->m_mysql, *grantquery);; + ExecuteAndGetResult(m_hmdi, m_hmdi->m_tunnel, &m_hmdi->m_mysql, *grantquery, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + + if(isintransaction == 1) + return wyFalse; if(m_hmdi->m_tunnel->mysql_affected_rows(m_hmdi->m_mysql)) { @@ -2566,7 +2574,11 @@ UserManager::ExecuteGrantRevoke(wyString* grantquery, wyString* revokequery) //if revoke query is present if(revokequery && revokequery->GetLength()) { - ExecuteAndGetResult(m_hmdi, m_hmdi->m_tunnel, &m_hmdi->m_mysql, *revokequery);; + isintransaction = 1; + ExecuteAndGetResult(m_hmdi, m_hmdi->m_tunnel, &m_hmdi->m_mysql, *revokequery, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + + if(isintransaction == 1) + return wyFalse; if(m_hmdi->m_tunnel->mysql_affected_rows(m_hmdi->m_mysql)) { @@ -2856,9 +2868,13 @@ wyBool UserManager::ExecuteUMQuery(wyString& query) { MYSQL_RES* myres; + wyInt32 isintransaction = 1; SetCursor(LoadCursor(NULL, IDC_WAIT)); - myres = ExecuteAndGetResult(m_hmdi, m_hmdi->m_tunnel, &m_hmdi->m_mysql, query); + myres = ExecuteAndGetResult(m_hmdi, m_hmdi->m_tunnel, &m_hmdi->m_mysql, query, wyTrue, wyFalse, wyTrue, false, false, wyFalse, 0, wyFalse, &isintransaction, GetActiveWindow()); + + if(isintransaction == 1) + return wyFalse; if(!myres && m_hmdi->m_tunnel->mysql_affected_rows(m_hmdi->m_mysql) == -1) {