diff --git a/include/AppInfo.h b/include/AppInfo.h index afb83f7..3a8c239 100644 --- a/include/AppInfo.h +++ b/include/AppInfo.h @@ -34,16 +34,11 @@ #define PLATFORM_STRING " (32 bit)" #endif -#if UPDATE_VERSION_INT > 0 -#define APPVERSION "v" MAJOR_VERSION "." MINOR_VERSION UPDATE_VERSION EXTRAINFO PLATFORM_STRING -#else -#define APPVERSION "v" MAJOR_VERSION "." MINOR_VERSION EXTRAINFO PLATFORM_STRING -#endif - +#define APPVERSION "v" MAJOR_VERSION "." MINOR_VERSION "." UPDATE_VERSION EXTRAINFO PLATFORM_STRING #define SQLITE_APPVERSION_MAJOR "10" #define SQLITE_APPVERSION_MINOR "5" -#define COMPANY_COPYRIGHT "(c) 2001-2015 Webyog Inc." +#define COMPANY_COPYRIGHT "(c) 2001-2016 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/CopyDatabase.h b/include/CopyDatabase.h index 1618cc5..91a526c 100644 --- a/include/CopyDatabase.h +++ b/include/CopyDatabase.h @@ -566,7 +566,7 @@ class CopyDatabase @param table: IN table to be copied @returns wyBool, wyTrue is SUCCESS, otherwise wyFalse */ - wyBool ExportActualData(wyChar *table); + wyBool ExportActualData(wyChar *table, wyBool *isvirtual); /// adding field values of a row to the query /** @param myres : Mysql result pointer @@ -578,7 +578,7 @@ class CopyDatabase */ void GetInsertQuery(MYSQL_RES *myres, MYSQL_ROW myrow, wyString &insertstmt, wyInt32 nfilelds, - wyBool ismysql41); + wyBool ismysql41,wyBool *isvirtual); /// Execute Bulk query or Single query /** @param myres : Mysql result pointer diff --git a/include/DataView.h b/include/DataView.h index 4c63c4d..0a6b078 100644 --- a/include/DataView.h +++ b/include/DataView.h @@ -300,6 +300,9 @@ class MySQLDataEx //Currently selected column, valid only when setting/resetting/refreshing the data wyInt32 m_selcol; + //whether column is virtual or not + wyInt32* m_colvirtual; + //Active database wyString m_db; @@ -1248,7 +1251,7 @@ class DataView wyBool IsColumnReadOnly(wyInt32 col); //function to check whether a column is virtual or not - wyBool IsColumnVirtual(wyInt32 col); + wyInt32 IsColumnVirtual(wyInt32 col); ///Generic function to add data to query, for update, delete and duplicate check /** diff --git a/include/Version.h b/include/Version.h index b4fa49d..eb8d10d 100644 --- a/include/Version.h +++ b/include/Version.h @@ -1,5 +1,5 @@ #define MAJOR_VERSION_INT 12 -#define MINOR_VERSION_INT 1 -#define UPDATE_VERSION_INT 9 +#define MINOR_VERSION_INT 2 +#define UPDATE_VERSION_INT 0 #define RELEASE_VERSION_INT 0 #define EXTRAINFO "" diff --git a/lib/Keywords.db b/lib/Keywords.db index 19b4d41..2a36b9f 100644 Binary files a/lib/Keywords.db and b/lib/Keywords.db differ diff --git a/src/CopyDatabase.cpp b/src/CopyDatabase.cpp index 7f30052..6208b59 100644 --- a/src/CopyDatabase.cpp +++ b/src/CopyDatabase.cpp @@ -2299,12 +2299,17 @@ CopyDatabase::ExportData(LPGUI_COPYDB_UPDATE_ROUTINE gui_routine, void * lpParam RelTableFldInfo *table; HWND hwndtree = NULL; HTREEITEM hrootitem = NULL; - wyInt32 bulksize = 0; + wyInt32 bulksize = 0,j=0; wyString msg; wyUInt32 maxallowedsize = 0; m_gui_routine = gui_routine; m_gui_lparam = lpParam; + MYSQL_RES *virt_res = NULL; + MYSQL_ROW virt_row; + wyBool *isvirtual = NULL; + wyInt32 no_rows; + wyString virt_query; if(m_exportdata == wyTrue)//Checking struct & data option selected { @@ -2374,10 +2379,52 @@ CopyDatabase::ExportData(LPGUI_COPYDB_UPDATE_ROUTINE gui_routine, void * lpParam if(ret == wyFalse || (IsCopyStopped() == wyTrue)) return ret; + if(m_exportdata == wyTrue) { m_copiedcount = 0; - ret = ExportActualData((wyChar*)table->m_tablefld.GetString()); + + //---------------------------Virtuality------------------------------// + + virt_query.Sprintf("SHOW FIELDS FROM `%s`.`%s`",m_srcdb.GetString(), table->m_tablefld.GetString()); + virt_res = SjaExecuteAndGetResult(m_newsrctunnel, &m_newsrcmysql, virt_query); + no_rows = m_newsrctunnel->mysql_num_rows(virt_res); + + if(!virt_res && no_rows == -1) + { + ShowMySQLError(m_hwnddlg, m_newsrctunnel, &m_newsrcmysql); + return wyFalse; + } + + isvirtual = (wyBool *)calloc(no_rows,sizeof(wyBool)); + + virt_row = m_newsrctunnel->mysql_fetch_row(virt_res); + j=0; + while(virt_row) + { + if(strstr(virt_row[5], "VIRTUAL") || strstr(virt_row[5], "PERSISTENT") || strstr(virt_row[5], "STORED")) + { + isvirtual[j++] = wyTrue; + } + else + { + isvirtual[j++]= wyFalse; + } + virt_row = sja_mysql_fetch_row(m_newsrctunnel, virt_res); + } + + m_newsrctunnel->mysql_free_result(virt_res); + //-------------------------------------Virtuality----------------------------// + + + ret = ExportActualData((wyChar*)table->m_tablefld.GetString(),isvirtual); + + + if(isvirtual != NULL) + { + free(isvirtual); + isvirtual = NULL; + } //for showing the total no of rows copied in a table m_gui_routine((void*)m_gui_lparam,(wyChar*)table->m_tablefld.GetString(), m_copiedcount, wyTrue, TABLECOPIED ); @@ -2968,7 +3015,7 @@ CopyDatabase::ExecuteInsertQuery(MYSQL_RES *myres, wyString &insertstmt, wyChar // usung these function getting single insert or bulkinsert(adding row values to the query) void CopyDatabase::GetInsertQuery(MYSQL_RES *myres, MYSQL_ROW myrow, wyString &insertstmt, wyInt32 nfilelds, - wyBool ismysql41) + wyBool ismysql41,wyBool *isvirtual) { wyULong *lengths; wyChar *temp; @@ -2980,6 +3027,9 @@ CopyDatabase::GetInsertQuery(MYSQL_RES *myres, MYSQL_ROW myrow, wyString &insert for(j = 0; j < nfilelds; j++) { + if(isvirtual[j]==wyTrue) + continue; + VERIFY(myfield = m_newsrctunnel->mysql_fetch_field_direct(myres, j)); // Write NULL if NULL value. if(myrow[j] == NULL) @@ -3025,7 +3075,7 @@ CopyDatabase::GetInsertQuery(MYSQL_RES *myres, MYSQL_ROW myrow, wyString &insert // Function creates insert statement and executes in the targetmysql. wyBool -CopyDatabase::ExportActualData(wyChar * table) +CopyDatabase::ExportActualData(wyChar * table,wyBool *isvirtual) { wyInt32 ret; wyString query, msg, insertstmt, myrowstr; @@ -3039,7 +3089,7 @@ CopyDatabase::ExportActualData(wyChar * table) wyString bulkquery, fieldval, errmsg; wyBool flag = wyTrue; wyInt32 querylength = 0; - wyInt32 rowscopied = 0; + wyInt32 rowscopied = 0,i=0; MDIWindow *wnd = GetActiveWin(); wyInt32 chunklimit; wyBool ischunkinsert; @@ -3102,9 +3152,14 @@ CopyDatabase::ExportActualData(wyChar * table) // insert field names in bulkinsert query while(fieldnames = m_newsrctunnel->mysql_fetch_field(myres)) { - //bulkquery.AddSprintf("`%s`,", fieldnames->name); + if(isvirtual[i]== wyTrue) + { + i++; + continue; + } fieldval.SetAs(fieldnames->name, ismysql41); bulkquery.AddSprintf("`%s`,", fieldval.GetString()); + i++; } bulkquery.Strip(1); @@ -3143,7 +3198,7 @@ CopyDatabase::ExportActualData(wyChar * table) insertstmt.SetAs(""); insertstmt.SetAs(bulkquery.GetString()); } - GetInsertQuery(myres, myrow, insertstmt, nfilelds, ismysql41); + GetInsertQuery(myres, myrow, insertstmt, nfilelds, ismysql41,isvirtual); insertstmt.Strip(2); insertstmt.Add("),("); } @@ -3164,12 +3219,13 @@ CopyDatabase::ExportActualData(wyChar * table) } else { + i = 0; while(myrow = m_newsrctunnel->mysql_fetch_row(myres)) { exportedrowcount ++; - // get the length of the row so that we can place some binary data as - insertstmt.Sprintf("insert into `%s`.`%s` values(", m_targetdb.GetString(), table); - GetInsertQuery(myres, myrow, insertstmt, nfilelds, ismysql41); + // get the length of the row so that we can place some binary data as + insertstmt.SetAs(bulkquery.GetString()); + GetInsertQuery(myres, myrow, insertstmt, nfilelds, ismysql41,isvirtual); insertstmt.Strip(2); insertstmt.Add(")"); if(IsCopyStopped() == wyTrue) diff --git a/src/DataView.cpp b/src/DataView.cpp index 9ecf87c..b86dbf4 100644 --- a/src/DataView.cpp +++ b/src/DataView.cpp @@ -84,6 +84,7 @@ MySQLDataEx::Initialize() m_datares = NULL; m_keyres = NULL; m_fieldres = NULL; + m_colvirtual = NULL; m_oldrow = NULL; m_modifiedrow = -1; m_checkcount = 0; @@ -136,6 +137,12 @@ MySQLDataEx::FreeAllocatedResources() m_oldrow = NULL; } + if(m_colvirtual) + { + delete m_colvirtual; + m_colvirtual = NULL; + } + //free warnings if(m_warningres) { @@ -169,6 +176,7 @@ MySQLDataEx::Free() m_pmdi->m_tunnel->mysql_free_result(m_fieldres); } + //free key result if(m_keyres) { @@ -953,29 +961,49 @@ DataView::IsColumnReadOnly(wyInt32 col) } //function to check whether a column is virtual or not -wyBool +wyInt32 DataView::IsColumnVirtual(wyInt32 col) { wyString query,db, table,column; MYSQL_RES *fieldres = NULL; - wyBool flag = wyFalse; - //get the db and table name - if(GetDBName(db, col) == wyTrue && GetTableName(table, col) == wyTrue && GetColumnName(column, col) == wyTrue) - { - query.Sprintf("show full fields from `%s`.`%s` WHERE FIELD=\"%s\" AND (Extra LIKE \"%%VIRTUAL%%\" OR Extra LIKE \"%%STORED%%\" OR Extra LIKE \"%%PERSISTENT%%\")", db.GetString(), table.GetString(),column.GetString()); - fieldres = SjaExecuteAndGetResult(m_wnd->m_tunnel,&m_wnd->m_mysql,query); + if(m_data->m_colvirtual) + { + if(m_data->m_colvirtual[col]!=-1) + { + return m_data->m_colvirtual[col]; + } - if(fieldres) + else { - if(fieldres->row_count == 1) - flag = wyTrue; + //get the db and table name + if(GetDBName(db, col) == wyTrue && GetTableName(table, col) == wyTrue && GetColumnName(column, col) == wyTrue) + { + query.Sprintf("show full fields from `%s`.`%s` WHERE FIELD=\"%s\" AND (Extra LIKE \"%%VIRTUAL%%\" OR Extra LIKE \"%%STORED%%\" OR Extra LIKE \"%%PERSISTENT%%\")", db.GetString(), table.GetString(),column.GetString()); + fieldres = SjaExecuteAndGetResult(m_wnd->m_tunnel,&m_wnd->m_mysql,query); - m_wnd->m_tunnel->mysql_free_result(fieldres); - } + if(fieldres) + { + if(fieldres->row_count == 1) + { + m_data->m_colvirtual[col] = 1; + } + else + { + m_data->m_colvirtual[col] = 0; + } + + m_wnd->m_tunnel->mysql_free_result(fieldres); + } - } - return flag; + } + + } + + } + + else + return 0; } //function to check whether a column is of type binary @@ -7223,7 +7251,7 @@ DataView::GetTableDetails() { wyString query; MYSQL_RES *myres = NULL, *fieldres = NULL, *keyres = NULL; - MYSQL_ROW myrow; + MYSQL_ROW myrow=NULL; //we can be sure that the form view need to be refreshed SetRefreshStatus(wyTrue, FORMVIEW_REFRESHED); @@ -7275,6 +7303,7 @@ DataView::GetTableDetails() return TE_ERROR; } + //get the key res query.Sprintf("show keys from `%s`.`%s`", m_data->m_db.GetString(), m_data->m_table.GetString()); keyres = ExecuteQuery(query); @@ -7467,15 +7496,26 @@ DataView::GridWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) //whether to draw white background case GVN_ISWHITEBKGND: //if the column is readonly then we dont draw white background - return (pviewdata->IsColumnReadOnly(lparam)||pviewdata->IsColumnVirtual(lparam)) ? FALSE : TRUE; - + if(pviewdata->IsColumnReadOnly(lparam)) + { + return FALSE; + } + if(pviewdata->IsColumnVirtual(lparam)==1) + { + return FALSE; + } + return TRUE; //begin label edit case GVN_BEGINLABELEDIT: //allow only if the column is not read-only - if(pviewdata->IsColumnReadOnly(lparam)||pviewdata->IsColumnVirtual(lparam)) + if(pviewdata->IsColumnReadOnly(lparam)) { return FALSE; } + if(pviewdata->IsColumnVirtual(lparam)==1) + { + return FALSE; + } pviewdata->OnGvnBeginLabelEdit(wparam, lparam); return TRUE; @@ -7599,9 +7639,9 @@ void DataView::ShowContextMenu(wyInt32 row, wyInt32 col, LPPOINT pt) { HMENU hmenu, htrackmenu; - wyBool iscolreadonly = wyTrue,iscolvirtual = wyFalse, iscolnullable = wyFalse, iscolhasdefault = wyFalse; + wyBool iscolreadonly = wyTrue, iscolnullable = wyFalse, iscolhasdefault = wyFalse; wyString column; - wyInt32 copymenupos = 14,i; + wyInt32 copymenupos = 14,i,iscolvirtual=0; HWND hwndtoolbar; wyBool isunsort = wyFalse; @@ -7662,7 +7702,7 @@ DataView::ShowContextMenu(wyInt32 row, wyInt32 col, LPPOINT pt) GetColumnName(column, col); //if the column is not read-only - if((iscolreadonly = IsColumnReadOnly(col)) == wyFalse && (iscolvirtual = IsColumnVirtual(col)) == wyFalse ) + if((iscolreadonly = IsColumnReadOnly(col)) == wyFalse && (iscolvirtual = IsColumnVirtual(col)) == 0 ) { //check whether the column is nullable iscolnullable = IsNullable(m_wnd->m_tunnel, m_data->m_fieldres, (wyChar*)column.GetString()); diff --git a/src/ResultView.cpp b/src/ResultView.cpp index b47efed..d79b741 100644 --- a/src/ResultView.cpp +++ b/src/ResultView.cpp @@ -507,7 +507,7 @@ void ResultView::EndTableComboChange(ThreadExecStatus te) { ResultTabTableElem* pelem; - wyInt32 row, prevseltable, rowcount, temp; + wyInt32 row, prevseltable, rowcount, temp,no_row; HWND hwndfocus = GetActiveDispWindow(); //if the operation was succesfull @@ -568,6 +568,16 @@ ResultView::EndTableComboChange(ThreadExecStatus te) return; } + no_row = m_wnd->m_tunnel->mysql_num_fields(m_mydata->m_datares); + + if(!m_data->m_colvirtual) + { + m_data->m_colvirtual = (wyInt32*)calloc(no_row, sizeof(wyInt32)); + memset(m_data->m_colvirtual,-1,no_row * sizeof(wyInt32)); + } + + + //we are here means, the operation was succesful //if it was not the original db @@ -816,7 +826,7 @@ ResultView::RefreshDataView() wyString query; wyInt32 ret; MySQLDataEx* pdata; - + //set the query query.SetAs(m_mydata->GetQuery()); diff --git a/src/TableView.cpp b/src/TableView.cpp index f31c5e2..49416e0 100644 --- a/src/TableView.cpp +++ b/src/TableView.cpp @@ -331,8 +331,9 @@ wyInt32 TableView::ExecuteTableData() { wyString query; - wyInt32 ret; + wyInt32 ret,extraindex,j=0,no_row; MySQLDataEx* pdata; + MYSQL_ROW fieldrow; query.Sprintf("select * from `%s`.`%s`", m_mydata->m_db.GetString(), m_mydata->m_table.GetString()); @@ -368,6 +369,23 @@ TableView::ExecuteTableData() delete pdata; return ret; } + extraindex = GetFieldIndex(m_wnd->m_tunnel, m_data->m_fieldres, "Extra"); + no_row = m_wnd->m_tunnel->mysql_num_rows(m_data->m_fieldres); + m_data->m_colvirtual = (wyInt32*)calloc(no_row, sizeof(wyInt32)); + + while(fieldrow = m_wnd->m_tunnel->mysql_fetch_row(m_data->m_fieldres)){ + + if(!strstr(fieldrow[extraindex], "VIRTUAL") && !strstr(fieldrow[extraindex], "PERSISTENT") && !strstr(fieldrow[extraindex], "STORED")) + { + m_data->m_colvirtual[j++] = 0; + } + + else + { + m_data->m_colvirtual[j++] = 1; + } + + } //add new row in the end AddNewRow();