Skip to content

Commit

Permalink
SQLyog 12.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
maryamwy committed Feb 12, 2016
1 parent 15c76e7 commit 1f4aa59
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 46 deletions.
9 changes: 2 additions & 7 deletions include/AppInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions include/CopyDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion include/DataView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
/**
Expand Down
4 changes: 2 additions & 2 deletions include/Version.h
Original file line number Diff line number Diff line change
@@ -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 ""
Binary file modified lib/Keywords.db
Binary file not shown.
76 changes: 66 additions & 10 deletions src/CopyDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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("),(");
}
Expand All @@ -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)
Expand Down
82 changes: 61 additions & 21 deletions src/DataView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -136,6 +137,12 @@ MySQLDataEx::FreeAllocatedResources()
m_oldrow = NULL;
}

if(m_colvirtual)
{
delete m_colvirtual;
m_colvirtual = NULL;
}

//free warnings
if(m_warningres)
{
Expand Down Expand Up @@ -169,6 +176,7 @@ MySQLDataEx::Free()
m_pmdi->m_tunnel->mysql_free_result(m_fieldres);
}


//free key result
if(m_keyres)
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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());
Expand Down
Loading

0 comments on commit 1f4aa59

Please sign in to comment.