diff --git a/include/AppInfo.h b/include/AppInfo.h index 344cd53..dd7c400 100644 --- a/include/AppInfo.h +++ b/include/AppInfo.h @@ -38,7 +38,7 @@ #define SQLITE_APPVERSION_MAJOR "10" #define SQLITE_APPVERSION_MINOR "5" -#define COMPANY_COPYRIGHT "(c) 2001-2022 Webyog Inc." +#define COMPANY_COPYRIGHT "(c) 2001-2023 Webyog Inc." #define FILEVER MAJOR_VERSION_INT ## , ## MINOR_VERSION_INT ## , ## UPDATE_VERSION_INT ## , ## RELEASE_VERSION_INT #define STRFILEVER MAJOR_VERSION "." MINOR_VERSION "." STRINGIZE(UPDATE_VERSION_INT) "." STRINGIZE(RELEASE_VERSION_INT) diff --git a/include/ExportAsSQL.h b/include/ExportAsSQL.h index 9d60f5f..0324fca 100644 --- a/include/ExportAsSQL.h +++ b/include/ExportAsSQL.h @@ -269,6 +269,12 @@ class MySQLDump */ wyBool DumpDatabaseOnUtf8(); + /// Dumps database with setting the utf8mb4 option + /** + @returns wyTrue + */ + wyBool DumpDatabaseOnUtf8mb4(); + /// Changes the current database /** @param db : IN Database name to change to diff --git a/include/Version.h b/include/Version.h index 843aaaf..8bc30e8 100644 --- a/include/Version.h +++ b/include/Version.h @@ -1,5 +1,5 @@ #define MAJOR_VERSION_INT 13 #define MINOR_VERSION_INT 2 -#define UPDATE_VERSION_INT 0 +#define UPDATE_VERSION_INT 1 #define RELEASE_VERSION_INT 0 #define EXTRAINFO "" diff --git a/lib/Keywords.db b/lib/Keywords.db index c259cb8..66e9213 100644 Binary files a/lib/Keywords.db and b/lib/Keywords.db differ diff --git a/src/CommonHelper.cpp b/src/CommonHelper.cpp index 2825516..6661da8 100644 --- a/src/CommonHelper.cpp +++ b/src/CommonHelper.cpp @@ -75,7 +75,7 @@ extern FILE *logfilehandle; static wyChar table64[]= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static CryptoPP::byte AESKey[16] = { };//provide any Key +static CryptoPP::byte AESKey[16] = {}; //Provide any Key static CryptoPP::byte AESiv[16] = {}; //Provide any IV Tunnel * @@ -1149,42 +1149,22 @@ wyBool GetCheckConstraintValue(wyChar * currentrow, wyString * expression) { return wyFalse; } - wyChar * find = "CHECK", *findcomment = "COMMENT"; + wyChar * find = "CHECK "; wyBool found = wyFalse; wyChar *ptr = strstr(currentrow, find); - wyChar *ptrc = strstr(currentrow, findcomment); - wyString s1, s2,s3; - s1.SetAs(currentrow); - s2.SetAs(""); - s3.SetAs("COMMENT"); wyInt32 index=0; if (ptr) { - if (ptrc) { - index = ptr - currentrow + 5; - s2.SetAs(s1.Substr(index, 7)); - while (s2.CompareI(s3)!=0)//(currentrow[index + 2] != 'C' && currentrow[index + 3] != 'O' && currentrow[index + 4] != 'M') - { - expression->AddSprintf("%c", currentrow[index]); - index++; - s2.SetAs(s1.Substr(index, 7)); - } - found = wyTrue; - } - else - { - index = ptr - currentrow + 5; + index = ptr - currentrow + 6; //length of "CHECK " - while (wyTrue) - { - if ((currentrow[index] == ',' && currentrow[index + 2] == ' ')|| (currentrow[index] == '\0' )) - break; + while (wyTrue) + { + if ((currentrow[index] == ',' && currentrow[index + 2] == ' ')|| (currentrow[index] == '\0' )) + break; - expression->AddSprintf("%c", currentrow[index]); - index++; - } - found = wyTrue; + expression->AddSprintf("%c", currentrow[index]); + index++; } - + found = wyTrue; } return found; @@ -1193,13 +1173,13 @@ wyBool GetCheckConstraintValue(wyChar * currentrow, wyString * expression) wyBool GettablelevelCheckConstraintValue(wyChar * currentrow, wyString * expression) { - wyChar * find = "CHECK"; + wyChar * find = "CHECK "; wyBool found = wyFalse;/*, withcomment = wyFalse, withoutcomment = wyFalse;*/ wyChar *ptr = strstr(currentrow, find); wyInt32 index=0; if (ptr) { found = wyTrue; - index =( ptr - currentrow) + 5; + index =( ptr - currentrow) + 6; //length of "CHECK " while (currentrow[index] != '\0') { /*if (currentrow[index] == '\0' && currentrow[index + 2] == ' ') @@ -4264,8 +4244,8 @@ InitConnectionDetails(ConnectionInfo *conn) conn->m_rgbconn = RGB(255, 255, 255); conn->m_rgbfgconn = RGB(0, 0, 0); #endif - conn->m_no_ca = wyFalse; + return; } @@ -4810,4 +4790,5 @@ GetConnectionId(Tunnel *tunnel, MYSQL *mysql) sja_mysql_free_result(tunnel, myres); return idstr.GetAsInt32(); + } diff --git a/src/ConnectionBase.cpp b/src/ConnectionBase.cpp index 5ba29c6..bc29cf3 100644 --- a/src/ConnectionBase.cpp +++ b/src/ConnectionBase.cpp @@ -908,6 +908,11 @@ ConnectionBase::ChangeConnName(HWND hdlg) hwndc = (HWND)SendMessage(hwndcombo, CCBM_GETCOMBOHWND, NULL, NULL); VERIFY ((cursel = SendMessage(hwndcombo, CB_GETCURSEL, 0, 0))!= CB_ERR); + + if (cursel == -1) { + cursel = SendMessage(hwndcombo, CB_GETCOUNT, cursel, 0) - 1; + } + VERIFY ((SendMessage(hwndc, CB_GETLBTEXT, cursel,(LPARAM)pconn.m_connname))); VERIFY((count = SendMessage(hwndcombo, CB_GETITEMDATA, cursel, 0))); @@ -1583,6 +1588,9 @@ ConnectionBase::GetInitialDetails(HWND hdlg) dirstr.SetAs(directory); count = SendMessage(hwndcombo, CB_GETCURSEL, 0, 0); + if (count == -1) { + count = SendMessage(hwndcombo, CB_GETCOUNT, count, 0) - 1; + } VERIFY(count != CB_ERR); count = SendMessage(hwndcombo, CB_GETITEMDATA, count, 0); conn.Sprintf("Connection %u", count); @@ -1799,6 +1807,9 @@ ConnectionBase::GetOtherValues(HWND hdlg, ConnectionInfo *coninfo) // now get the title. index = SendMessage(hcb,CB_GETCURSEL,0,0); + if (index == -1) { + index = SendMessage(hcb, CB_GETCOUNT, index, 0) - 1; + } SendMessage(hwndCombo,CB_GETLBTEXT, index, (LPARAM)title); SendMessage(GetDlgItem(hdlg, IDC_DLGCONNECT_DATABASE), WM_GETTEXT,(WPARAM)SIZE_512 - 1,(LPARAM)db); @@ -2908,6 +2919,10 @@ ConnectionBase::GetConnectionName(HWND hdlg, wyString *connnamestr, const wyChar VERIFY((index = SendMessage(hcb, CB_GETCURSEL, 0, 0))!= CB_ERR); + if (index == -1) { + index = SendMessage(hcb, CB_GETCOUNT, index, 0) - 1; + } + txtlen = (SendMessage(hcb, CB_GETLBTEXTLEN, index, 0)); conname = AllocateBuffWChar(txtlen + 1); diff --git a/src/ConnectionCommunity.cpp b/src/ConnectionCommunity.cpp index 8a641aa..045a538 100644 --- a/src/ConnectionCommunity.cpp +++ b/src/ConnectionCommunity.cpp @@ -1231,6 +1231,9 @@ ConnectionCommunity::CreateSourceInstance(CopyDatabase *copydb) VERIFY(!(copydb->m_newsrctunnel->mysql_options(tempmysql, MYSQL_INIT_COMMAND, "/*40030 SET net_write_timeout=3600 */"))); + if(copydb->m_srcinfo->m_initcommand.FindI("utf8mb4") >=0) + VERIFY(!(copydb->m_newsrctunnel->mysql_options(tempmysql, MYSQL_INIT_COMMAND, copydb->m_srcinfo->m_initcommand.GetString()))); + SetMySQLOptions(copydb->m_srcinfo, copydb->m_newsrctunnel, &tempmysql, wyTrue); newsrcmysql = copydb->m_newsrctunnel->mysql_real_connect(tempmysql, @@ -1269,7 +1272,10 @@ ConnectionCommunity::CreateTargetInstance(CopyDatabase *copydb) copydb->m_newtargettunnel = CreateTunnel((wyBool)copydb->m_targettunnel->IsTunnel()); VERIFY(tempmysql = copydb->m_newtargettunnel->mysql_init((MYSQL*)0)); - + + if (copydb->m_tgtinfo->m_initcommand.FindI("utf8mb4") >= 0) + VERIFY(!(copydb->m_newtargettunnel->mysql_options(tempmysql, MYSQL_INIT_COMMAND, copydb->m_tgtinfo->m_initcommand.GetString()))); + SetMySQLOptions(copydb->m_tgtinfo, copydb->m_newtargettunnel, &tempmysql); newtargetmysql = copydb->m_newtargettunnel->mysql_real_connect(tempmysql, diff --git a/src/CopyDatabase.cpp b/src/CopyDatabase.cpp index 7a8c219..29fe5ff 100644 --- a/src/CopyDatabase.cpp +++ b/src/CopyDatabase.cpp @@ -1582,7 +1582,8 @@ CopyDatabase::InitExportData(HWND hwndtree) else m_isremdefiner = wyFalse; InitTargetServer(); - SetNamesToUTF8(); + + SetNamesToUTF8(); return wyTrue; } @@ -2612,54 +2613,66 @@ CopyDatabase::RevertTargetServer() void CopyDatabase::SetNamesToUTF8() { - wyString query; - MYSQL_RES *res; + wyString query; + MYSQL_RES *res; - if(IsMySQL41(m_newsrctunnel, &m_newsrcmysql)&& IsMySQL41(m_newtargettunnel, &m_newtargetmysql)) + wyString srcUtf8CharType = "utf8"; + wyString trgtUtf8CharType = "utf8"; + + if (m_tgtinfo->m_initcommand.FindI("utf8mb4") >= 0) + { + trgtUtf8CharType = "utf8mb4"; + } + + if(m_srcinfo->m_initcommand.FindI("utf8mb4") >= 0) { - if(m_newsrctunnel->IsTunnel()) - m_newsrctunnel->SetCharset("utf8"); + srcUtf8CharType = "utf8mb4"; + } + + if (IsMySQL41(m_newsrctunnel, &m_newsrcmysql) && IsMySQL41(m_newtargettunnel, &m_newtargetmysql)) + { + if (m_newsrctunnel->IsTunnel()) + m_newsrctunnel->SetCharset(srcUtf8CharType.GetString()); else { - query.Sprintf("SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT"); + query.Sprintf("SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT"); res = SjaExecuteAndGetResult(m_newsrctunnel, &m_newsrcmysql, query); - if(res) + if (res) m_newsrctunnel->mysql_free_result(res); - query.Sprintf("SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS"); + query.Sprintf("SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS"); res = SjaExecuteAndGetResult(m_newsrctunnel, &m_newsrcmysql, query); - if(res) + if (res) m_newsrctunnel->mysql_free_result(res); - query.Sprintf("SET NAMES utf8"); + query.Sprintf("SET NAMES %s", srcUtf8CharType.GetString()); res = SjaExecuteAndGetResult(m_newsrctunnel, &m_newsrcmysql, query); - if(res) + if (res) m_newsrctunnel->mysql_free_result(res); } - if(m_newtargettunnel->IsTunnel()) - m_newtargettunnel->SetCharset("utf8"); + if (m_newtargettunnel->IsTunnel()) + m_newtargettunnel->SetCharset(trgtUtf8CharType.GetString()); else { - - query.Sprintf("SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT"); + query.Sprintf("SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT"); res = SjaExecuteAndGetResult(m_newtargettunnel, &m_newtargetmysql, query); - if(res) + if (res) m_newtargettunnel->mysql_free_result(res); - query.Sprintf("SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS"); + query.Sprintf("SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS"); res = SjaExecuteAndGetResult(m_newtargettunnel, &m_newtargetmysql, query); - if(res) + if (res) m_newtargettunnel->mysql_free_result(res); - query.Sprintf("SET NAMES utf8"); + query.Sprintf("SET NAMES %s", trgtUtf8CharType.GetString()); res = SjaExecuteAndGetResult(m_newtargettunnel, &m_newtargetmysql, query); - if(res) + if (res) m_newtargettunnel->mysql_free_result(res); } - } + } - return; + return; } void diff --git a/src/ExportAsSQL.cpp b/src/ExportAsSQL.cpp index f9b3916..a587fd4 100644 --- a/src/ExportAsSQL.cpp +++ b/src/ExportAsSQL.cpp @@ -2497,6 +2497,10 @@ MySQLDump::DumpDatabase(wyString * buffer, const wyChar *db, wyInt32 *fileerr) if(DumpDatabaseOnUtf8() == wyFalse) return wyFalse; + if (m_charset.CompareI("utf8mb4") == 0) + if (DumpDatabaseOnUtf8mb4() == wyFalse) + return wyFalse; + if(m_singletransaction == wyTrue) OnSingleTransaction(); @@ -2581,6 +2585,28 @@ MySQLDump::DumpDatabaseOnUtf8() return wyTrue; } +wyBool +MySQLDump::DumpDatabaseOnUtf8mb4() +{ + MYSQL_RES *res; + wyString query; + + query.SetAs("SET NAMES UTF8MB4"); + + res = SjaExecuteAndGetResult(m_tunnel, &m_mysql, query); + +#ifdef _WIN32 + + m_tunnel->SetCharset("utf8mb4"); + +#endif + + if (res) + sja_mysql_free_result(m_tunnel, res); + + return wyTrue; +} + wyBool MySQLDump::ChangeContextDatabase(const wyChar *db) { diff --git a/src/ExportBatch.cpp b/src/ExportBatch.cpp index a5d5782..31588fb 100644 --- a/src/ExportBatch.cpp +++ b/src/ExportBatch.cpp @@ -1490,6 +1490,7 @@ ExportBatch::SetOtherValues(MySQLDump *dump) wyString filename; wyString charset, query; wyBool ischunkinsert,isprifixtimestamp=wyFalse; + MDIWindow *wnd = GetActiveWin(); dump->SetDatabase(m_db.GetString()); dump->SetAllTables(m_alltables); @@ -1516,9 +1517,14 @@ ExportBatch::SetOtherValues(MySQLDump *dump) dump->SetChunkLimit(chunklimit); } } - - if(IsMySQL41(m_tunnel, m_mysql)) - dump->SetCharSet("utf8"); + + if (wnd->m_conninfo.m_initcommand.FindI("utf8mb4") >= 0) + dump->SetCharSet("utf8mb4"); + else if(IsMySQL41(m_tunnel, m_mysql)) + { + dump->SetCharSet("utf8"); + } + else { if(GetServerDefaultCharset(m_tunnel, *m_mysql, charset, query) == wyFalse) diff --git a/src/ExportImportConnectionDetails.cpp b/src/ExportImportConnectionDetails.cpp index 5c43fd1..39783a0 100644 --- a/src/ExportImportConnectionDetails.cpp +++ b/src/ExportImportConnectionDetails.cpp @@ -1369,7 +1369,11 @@ wyBool ExportImportConnection::LoadDataToLV(HWND hwnd) cono=atoi(tempconsecname+10); if(connnamestr.Compare("") == 0) - return wyFalse; + { + ++i; + tempconsecname = strtok(NULL, seps); + continue; + } AddRowsToListViewControl(m_hwndLV, cono, connnamestr.GetAsWideChar(), connhostnamestr.GetAsWideChar(), connusernamestr.GetAsWideChar(), connportstr.GetAsWideChar(),isSSH, isSSL, isHTTP); ++i; tempconsecname = strtok(NULL, seps); diff --git a/src/GUIHelper.cpp b/src/GUIHelper.cpp index 59b9291..a80d051 100644 --- a/src/GUIHelper.cpp +++ b/src/GUIHelper.cpp @@ -1859,6 +1859,10 @@ WriteConnDetails(HWND hdlg) VERIFY((index = SendMessage(hcb, CB_GETCURSEL, 0, 0))!= CB_ERR); + if (index == -1) { + index = SendMessage(hcb, CB_GETCOUNT, index, 0) - 1; + } + txtlen = (SendMessage(hcb, CB_GETLBTEXTLEN, index, 0)); conname = AllocateBuffWChar(txtlen + 1); diff --git a/src/MySQLVersionHelper.cpp b/src/MySQLVersionHelper.cpp index 2395072..24a6fc5 100644 --- a/src/MySQLVersionHelper.cpp +++ b/src/MySQLVersionHelper.cpp @@ -517,10 +517,10 @@ void GetVersionInfoforAutoComplete(MYSQL *mysql, wyString &VersionS) char *dbString = mysql_get_server_info(mysql); if(strstr(dbString, "MariaDB")) ///if its mariadb,check if the version is above 10.2 { - if(me >= 100200) + if(me >= 100200 && me < 100300) me = 50713;///if mariadb version is > 10.2 it supports JSON, hence include functions till mysql version 5.7.13 - else - me = 50066;///if mariadb version is < 10.2, include functions only for previous versons of mysql. + else if(me < 100200) + me = 50300;///if mariadb version is < 10.2, include functions only for previous versons of mysql. } VersionS.Sprintf("%ld", me); diff --git a/src/TabFields.cpp b/src/TabFields.cpp index 643effd..b0c8d5a 100644 --- a/src/TabFields.cpp +++ b/src/TabFields.cpp @@ -1989,6 +1989,9 @@ TabFields::GetDefaultValue(wyString& query, FieldStructWrapper* cwrapobj) { query.Add("'' "); } + else if (datatype.Compare("varchar") == 0 && ((defval.FindI("UUID()") != -1) || (defval.FindI("SYS_GUID()") != -1))) { + query.AddSprintf("%s ", defval.GetString()); + } else { if(defval.GetCharAt(0) == '`' && defval.GetCharAt(defval.GetLength() - 1) == '`' diff --git a/src/TabIndexes.cpp b/src/TabIndexes.cpp index 2e0f355..4ed4433 100644 --- a/src/TabIndexes.cpp +++ b/src/TabIndexes.cpp @@ -1742,14 +1742,12 @@ TabIndexes::FillColumnsGrid(HWND hwnd) } if(!tmpindcols) { - //add only thoes columns for index which are not virtual - if(!(m_ismariadb52 && cfieldswrapobj->m_newval->m_virtuality.CompareI("VIRTUAL")==0) ) - { - newrow = CustomGrid_InsertRow(m_hdlggrid); + //add only columns including virtual columns + + newrow = CustomGrid_InsertRow(m_hdlggrid); CustomGrid_SetText(m_hdlggrid, newrow, 0, (wyChar*)cfieldswrapobj->m_newval->m_name.GetString()); CustomGrid_SetText(m_hdlggrid, newrow, 1, (wyChar*)cfieldswrapobj->m_newval->m_datatype.GetString()); CustomGrid_SetRowLongData(m_hdlggrid, newrow, (LPARAM) cfieldswrapobj); - } } } cfieldswrapobj = (FieldStructWrapper*)cfieldswrapobj->m_next;