From 464947e6323dc1e473532b641335e903a36c1d6c Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 22 Mar 2015 11:31:10 +0100 Subject: [PATCH] - Fix a bug that caused a crash when doing delete on a json table with wrong syntax file - Suppress MYSQL_SUPPORT preprocessor variable --- .gitignore | 1 + storage/connect/CMakeLists.txt | 39 +++++++++++++--------------------- storage/connect/ha_connect.cc | 10 ++++----- storage/connect/mycat.cc | 6 ------ storage/connect/tabjson.cpp | 16 +++++--------- storage/connect/taboccur.cpp | 2 -- storage/connect/tabtbl.cpp | 2 -- storage/connect/tabutil.cpp | 20 +++-------------- storage/connect/tabxcl.cpp | 2 -- 9 files changed, 28 insertions(+), 70 deletions(-) diff --git a/.gitignore b/.gitignore index e3df21eb17b..ee5216caf7b 100644 --- a/.gitignore +++ b/.gitignore @@ -293,6 +293,7 @@ storage/mroonga/vendor/groonga/src/suggest/groonga-suggest-create-dataset [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ +[Rr]eleaseWithDebInfo/ x64/ x86/ build/ diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 2b1e458e242..02fe5ee8dad 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -21,18 +21,18 @@ ha_connect.cc connect.cc user_connect.cc mycat.cc fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h array.cpp blkfil.cpp colblk.cpp csort.cpp filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamvct.cpp filamzip.cpp -filter.cpp json.cpp jsonudf.cpp maputil.cpp myutil.cpp plgdbutl.cpp reldef.cpp -tabcol.cpp tabdos.cpp tabfix.cpp tabfmt.cpp tabjson.cpp table.cpp tabmul.cpp -taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp tabutil.cpp tabvct.cpp -tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp +filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp +reldef.cpp tabcol.cpp tabdos.cpp tabfix.cpp tabfmt.cpp tabjson.cpp table.cpp +tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp tabutil.cpp +tabvct.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp array.h blkfil.h block.h catalog.h checklvl.h colblk.h connect.h csort.h engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamvct.h filamzip.h filter.h global.h ha_connect.h inihandl.h json.h maputil.h msgid.h mycat.h -myutil.h os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h resource.h -tabcol.h tabdos.h tabfix.h tabfmt.h tabjson.h tabmul.h taboccur.h tabpivot.h -tabsys.h tabtbl.h tabutil.h tabvct.h tabvir.h tabxcl.h user_connect.h -valblk.h value.h xindex.h xobject.h xtable.h) +myconn.h myutil.h os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h +resource.h tabcol.h tabdos.h tabfix.h tabfmt.h tabjson.h tabmul.h tabmysql.h +taboccur.h tabpivot.h tabsys.h tabtbl.h tabutil.h tabvct.h tabvir.h tabxcl.h +user_connect.h valblk.h value.h xindex.h xobject.h xtable.h) # # Definitions that are shared for all OSes @@ -166,24 +166,15 @@ IF(LIBXML2_FOUND OR MSXML_FOUND) ENDIF() # -# MySQL +# MySQL is now included unconditionnally # -OPTION(CONNECT_WITH_MYSQL - "Compile CONNECT storage engine with remote MySQL connection support" - ON) - -IF(CONNECT_WITH_MYSQL) - SET(CONNECT_SOURCES ${CONNECT_SOURCES} - myconn.cpp myconn.h tabmysql.cpp tabmysql.h) - add_definitions(-DMYSQL_SUPPORT) - IF(NOT UNIX) - # - # TODO: remove this - # change to use "#include "../../include/mysql.h" in the sources. - INCLUDE_DIRECTORIES("../../include/mysql") - ENDIF(NOT UNIX) -ENDIF(CONNECT_WITH_MYSQL) +IF(NOT UNIX) + # + # TODO: remove this + # change to use "#include "../../include/mysql.h" in the sources. + INCLUDE_DIRECTORIES("../../include/mysql") +ENDIF(NOT UNIX) # diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 8d7ab3a7652..1cf18a94d22 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -130,10 +130,8 @@ #if defined(ODBC_SUPPORT) #include "odbccat.h" #endif // ODBC_SUPPORT -#if defined(MYSQL_SUPPORT) #include "xtable.h" #include "tabmysql.h" -#endif // MYSQL_SUPPORT #include "filamdbf.h" #include "tabxcl.h" #include "tabfmt.h" @@ -5147,7 +5145,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ok= true; break; -#if defined(MYSQL_SUPPORT) case TAB_MYSQL: ok= true; @@ -5187,14 +5184,15 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ok= false; break; -#endif // MYSQL_SUPPORT #if defined(WIN32) case TAB_WMI: ok= true; break; #endif // WIN32 +#if defined(PIVOT_SUPPORT) case TAB_PIVOT: supfnc= FNC_NO; +#endif // PIVOT_SUPPORT case TAB_PRX: case TAB_TBL: case TAB_XCL: @@ -5293,12 +5291,10 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, break; #endif // ODBC_SUPPORT -#if defined(MYSQL_SUPPORT) case TAB_MYSQL: qrp= MyColumns(g, thd, host, db, user, pwd, tab, NULL, port, fnc == FNC_COL); break; -#endif // MYSQL_SUPPORT case TAB_CSV: qrp= CSVColumns(g, dpath, fn, spc, qch, hdr, mxe, fnc == FNC_COL); break; @@ -5324,9 +5320,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, } // endif OcrColumns break; +#if defined(PIVOT_SUPPORT) case TAB_PIVOT: qrp= PivotColumns(g, tab, src, pic, fcl, skc, host, db, user, pwd, port); break; +#endif // PIVOT_SUPPORT case TAB_VIR: qrp= VirColumns(g, tab, (char*)db, fnc == FNC_COL); break; diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index 0ae0537ba6f..a4986da4089 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -78,9 +78,7 @@ #include "tabxml.h" #endif // XML_SUPPORT #include "tabmul.h" -#if defined(MYSQL_SUPPORT) #include "tabmysql.h" -#endif // MYSQL_SUPPORT #if defined(ODBC_SUPPORT) #define NODBC #include "tabodbc.h" @@ -122,10 +120,8 @@ TABTYPE GetTypeID(const char *type) #ifdef ODBC_SUPPORT : (!stricmp(type, "ODBC")) ? TAB_ODBC #endif -#ifdef MYSQL_SUPPORT : (!stricmp(type, "MYSQL")) ? TAB_MYSQL : (!stricmp(type, "MYPRX")) ? TAB_MYSQL -#endif : (!stricmp(type, "DIR")) ? TAB_DIR #ifdef WIN32 : (!stricmp(type, "MAC")) ? TAB_MAC @@ -537,9 +533,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) case TAB_XCL: tdp= new(g) XCLDEF; break; case TAB_PRX: tdp= new(g) PRXDEF; break; case TAB_OCCUR: tdp= new(g) OCCURDEF; break; -#if defined(MYSQL_SUPPORT) case TAB_MYSQL: tdp= new(g) MYSQLDEF; break; -#endif // MYSQL_SUPPORT #if defined(PIVOT_SUPPORT) case TAB_PIVOT: tdp= new(g) PIVOTDEF; break; #endif // PIVOT_SUPPORT diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 9ffa1d6cc78..af33adc69b0 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -1540,12 +1540,11 @@ int TDBJSON::MakeNewDoc(PGLOBAL g) int TDBJSON::MakeDocument(PGLOBAL g) { char filename[_MAX_PATH]; + int rc = RC_OK; DWORD drc; if (Done) return RC_OK; - else - Done = true; // Now open the JSON file PlugSetPath(filename, Txfp->To_File, GetPath()); @@ -1553,16 +1552,11 @@ int TDBJSON::MakeDocument(PGLOBAL g) /*********************************************************************/ /* Get top of the parsed tree and the inside table document. */ /*********************************************************************/ - Top = MakeJsonTree(g, filename, Objname, Pretty, Doc, drc); + if (!(Top = MakeJsonTree(g, filename, Objname, Pretty, Doc, drc))) + rc = (drc == ENOENT && Mode == MODE_INSERT) ? MakeNewDoc(g) : RC_FX; - if (!Top) { - if (drc != ENOENT || Mode != MODE_INSERT) - return RC_FX; - - return MakeNewDoc(g); - } // endif !Top - - return RC_OK; + Done = (rc == RC_OK); + return rc; } // end of MakeDocument #if 0 diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index 82c4f888833..5ef0ee52653 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -45,9 +45,7 @@ #include "tabcol.h" #include "taboccur.h" #include "xtable.h" -#if defined(MYSQL_SUPPORT) #include "tabmysql.h" -#endif // MYSQL_SUPPORT #include "ha_connect.h" #include "mycat.h" diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index a33d6caa83a..64a9a176cca 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -70,9 +70,7 @@ #include "tabcol.h" #include "tabdos.h" // TDBDOS and DOSCOL class dcls #include "tabtbl.h" -#if defined(MYSQL_SUPPORT) #include "tabmysql.h" -#endif // MYSQL_SUPPORT #include "ha_connect.h" #include "mycat.h" // For GetHandler diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index c114497aa69..6c4760e763f 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -48,9 +48,7 @@ #include "resource.h" #include "reldef.h" #include "xtable.h" -#if defined(MYSQL_SUPPORT) #include "tabmysql.h" -#endif // MYSQL_SUPPORT #include "tabcol.h" #include "tabutil.h" #include "ha_connect.h" @@ -94,19 +92,13 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, if (!open_table_def(thd, s, GTS_TABLE | GTS_VIEW)) { if (!s->is_view) { - if (stricmp(plugin_name(s->db_plugin)->str, "connect")) { -#if defined(MYSQL_SUPPORT) + if (stricmp(plugin_name(s->db_plugin)->str, "connect")) mysql = true; -#else // !MYSQL_SUPPORT - sprintf(g->Message, "%s.%s is not a CONNECT table", db, name); - return NULL; -#endif // MYSQL_SUPPORT - } else + else mysql = false; - } else { + } else mysql = true; - } // endif is_view } else { if (thd->is_error()) @@ -428,7 +420,6 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) } // endif srcdef if (mysql) { -#if defined(MYSQL_SUPPORT) // Access sub-table via MySQL API if (!(tdbp= cat->GetTable(g, tabp, Mode, "MYPRX"))) { char buf[MAX_STR]; @@ -445,11 +436,6 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) if (Mode == MODE_UPDATE || Mode == MODE_DELETE) tdbp->SetName(Name); // For Make_Command -#else // !MYSQL_SUPPORT - sprintf(g->Message, "%s.%s is not a CONNECT table", - db, tblp->Name); - goto err; -#endif // MYSQL_SUPPORT } else { // Sub-table is a CONNECT table tabp->Next = To_Table; // For loop checking diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp index 0de01927c5a..454210b6e6a 100644 --- a/storage/connect/tabxcl.cpp +++ b/storage/connect/tabxcl.cpp @@ -51,9 +51,7 @@ #include "tabcol.h" #include "tabxcl.h" #include "xtable.h" -#if defined(MYSQL_SUPPORT) #include "tabmysql.h" -#endif // MYSQL_SUPPORT #include "ha_connect.h" #include "mycat.h"