diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2019-08-17 16:58:58 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2019-08-17 16:58:58 +0200 |
commit | 4d93c7f3b0bfc59da369702c2eca725f1e362305 (patch) | |
tree | 83ea1ff5f3e4d4b7df712679132fd42771fda76e /storage/connect/mycat.cc | |
parent | d302cb3534f4b4e8a5ae6e293b6ef2c2c9180862 (diff) | |
download | mariadb-git-4d93c7f3b0bfc59da369702c2eca725f1e362305.tar.gz |
In CONNECT version 1.6.10 NOSQL facility is enhanced by a new way to retrieve NOSQL data.
In addition to files and Mongo collections, JSON as well as XML and CSV data can be retrieved
from the net as answers from REST queries. Because it uses and external package (cpprestsdk)
this is currently available only to MariaDB servers compiled from source.
-- Add compile flags needed on Windows /MD or /MDd (debug)
-- Also include some changes needed on Linux
modified: storage/connect/CMakeLists.txt
- Add the xtrc tracing function
modified: storage/connect/global.h
modified: storage/connect/plugutil.cpp
- Modify tracing to use xtrc and some typo
modified: storage/connect/array.cpp
modified: storage/connect/block.h
modified: storage/connect/restget.cpp
- Fix compilation error when ZIP is not supported
modified: storage/connect/ha_connect.cc
modified: storage/connect/tabfmt.cpp
- Add some tracing + typo
modified: storage/connect/mycat.cc
modified: storage/connect/tabjson.cpp
- Add conditional code based on MARIADB
This to be able to use the same code in CONNECT and EOM modules
modified: storage/connect/osutil.h
modified: storage/connect/tabrest.cpp
- Replace PlugSetPath by some concat (crashed on Fedora) + typo
modified: storage/connect/reldef.cpp
- Try to fix test failures
modified: zlib/CMakeLists.txt
Diffstat (limited to 'storage/connect/mycat.cc')
-rw-r--r-- | storage/connect/mycat.cc | 161 |
1 files changed, 86 insertions, 75 deletions
diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index 5c67b92ec36..b1d23b8c5e2 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /*************** Mycat CC Program Source Code File (.CC) ***************/ /* PROGRAM NAME: MYCAT */ @@ -95,7 +95,7 @@ #endif // ZIP_SUPPORT #if defined(REST_SUPPORT) #include "tabrest.h" -#endif // REST_SUPPORT +#endif // Rest_SUPPORT #include "mycat.h" /***********************************************************************/ @@ -104,11 +104,9 @@ #if defined(__WIN__) extern "C" HINSTANCE s_hModule; // Saved module handle #endif // !__WIN__ - #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) bool MongoEnabled(void); #endif // JAVA_SUPPORT || CMGO_SUPPORT - PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); /***********************************************************************/ @@ -124,11 +122,11 @@ char *GetPluginDir(void) /***********************************************************************/ TABTYPE GetTypeID(const char *type) { - return (!type) ? TAB_UNDEF + return (!type) ? TAB_UNDEF : (!stricmp(type, "DOS")) ? TAB_DOS : (!stricmp(type, "FIX")) ? TAB_FIX : (!stricmp(type, "BIN")) ? TAB_BIN - : (!stricmp(type, "CSV")) ? TAB_CSV + : (!stricmp(type, "CSV")) ? TAB_CSV : (!stricmp(type, "FMT")) ? TAB_FMT : (!stricmp(type, "DBF")) ? TAB_DBF #if defined(XML_SUPPORT) @@ -140,30 +138,30 @@ TABTYPE GetTypeID(const char *type) : (!stricmp(type, "ODBC")) ? TAB_ODBC #endif #if defined(JAVA_SUPPORT) - : (!stricmp(type, "JDBC")) ? TAB_JDBC + : (!stricmp(type, "JDBC")) ? TAB_JDBC #endif #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) - : (!stricmp(type, "MONGO") && MongoEnabled()) ? TAB_MONGO + : (!stricmp(type, "MONGO") && MongoEnabled()) ? TAB_MONGO #endif - : (!stricmp(type, "MYSQL")) ? TAB_MYSQL + : (!stricmp(type, "MYSQL")) ? TAB_MYSQL : (!stricmp(type, "MYPRX")) ? TAB_MYSQL : (!stricmp(type, "DIR")) ? TAB_DIR #if defined(__WIN__) - : (!stricmp(type, "MAC")) ? TAB_MAC - : (!stricmp(type, "WMI")) ? TAB_WMI + : (!stricmp(type, "MAC")) ? TAB_MAC + : (!stricmp(type, "WMI")) ? TAB_WMI #endif - : (!stricmp(type, "TBL")) ? TAB_TBL - : (!stricmp(type, "XCOL")) ? TAB_XCL - : (!stricmp(type, "OCCUR")) ? TAB_OCCUR + : (!stricmp(type, "TBL")) ? TAB_TBL + : (!stricmp(type, "XCOL")) ? TAB_XCL + : (!stricmp(type, "OCCUR")) ? TAB_OCCUR : (!stricmp(type, "CATLG")) ? TAB_PRX // Legacy : (!stricmp(type, "PROXY")) ? TAB_PRX : (!stricmp(type, "PIVOT")) ? TAB_PIVOT : (!stricmp(type, "VIR")) ? TAB_VIR : (!stricmp(type, "JSON")) ? TAB_JSON #if defined(ZIP_SUPPORT) - : (!stricmp(type, "ZIP")) ? TAB_ZIP + : (!stricmp(type, "ZIP")) ? TAB_ZIP #endif - : (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY; + : (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY; } // end of GetTypeID /***********************************************************************/ @@ -173,19 +171,19 @@ bool IsFileType(TABTYPE type) { bool isfile; - switch (type) { + switch (type) { case TAB_DOS: case TAB_FIX: case TAB_BIN: - case TAB_CSV: + case TAB_CSV: case TAB_FMT: case TAB_DBF: case TAB_XML: case TAB_INI: case TAB_VEC: case TAB_JSON: - case TAB_REST: -// case TAB_ZIP: + case TAB_REST: + // case TAB_ZIP: isfile= true; break; default: @@ -203,7 +201,7 @@ bool IsExactType(TABTYPE type) { bool exact; - switch (type) { + switch (type) { case TAB_FIX: case TAB_BIN: case TAB_DBF: @@ -228,7 +226,7 @@ bool IsTypeNullable(TABTYPE type) { bool nullable; - switch (type) { + switch (type) { case TAB_MAC: case TAB_DIR: nullable= false; @@ -248,7 +246,7 @@ bool IsTypeFixed(TABTYPE type) { bool fix; - switch (type) { + switch (type) { case TAB_FIX: case TAB_BIN: case TAB_VEC: @@ -270,7 +268,7 @@ bool IsTypeIndexable(TABTYPE type) { bool idx; - switch (type) { + switch (type) { case TAB_DOS: case TAB_CSV: case TAB_FMT: @@ -296,7 +294,7 @@ int GetIndexType(TABTYPE type) { int xtyp; - switch (type) { + switch (type) { case TAB_DOS: case TAB_CSV: case TAB_FMT: @@ -309,9 +307,9 @@ int GetIndexType(TABTYPE type) break; case TAB_MYSQL: case TAB_ODBC: - case TAB_JDBC: - case TAB_MONGO: - xtyp= 2; + case TAB_JDBC: + case TAB_MONGO: + xtyp= 2; break; case TAB_VIR: xtyp= 3; @@ -383,7 +381,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info) return NULL; } else PlugSetPath(soname, module, GetPluginDir()); - + // The exported name is always in uppercase for (int i = 0; ; i++) { c = subtype[i]; @@ -460,7 +458,7 @@ CATALOG::CATALOG(void) memset(&Ctb, 0, sizeof(CURTAB)); Cbuf= NULL; Cblen= 0; - DefHuge= false; + DefHuge= false; } // end of CATALOG constructor /* -------------------------- Class MYCAT ---------------------------- */ @@ -470,7 +468,7 @@ CATALOG::CATALOG(void) /***********************************************************************/ MYCAT::MYCAT(PHC hc) : CATALOG() { - Hc= hc; + Hc= hc; DefHuge= false; } // end of MYCAT constructor @@ -487,16 +485,23 @@ void MYCAT::Reset(void) /***********************************************************************/ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR type, PRELDEF *) - { - if (trace(1)) - printf("GetTableDesc: name=%s am=%s\n", tablep->GetName(), SVP(type)); +{ + PRELDEF tdp= NULL; - // If not specified get the type of this table + if (trace(1)) + htrc("GetTableDesc: name=%s am=%s\n", tablep->GetName(), SVP(type)); + + // If not specified get the type of this table //if (!type) // type= Hc->GetStringOption("Type","*"); - return MakeTableDesc(g, tablep, type); - } // end of GetTableDesc + tdp= MakeTableDesc(g, tablep, type); + + if (trace(1)) + htrc("GetTableDesc: tdp=%p\n", tdp); + + return tdp; +} // end of GetTableDesc /***********************************************************************/ /* MakeTableDesc: make a table/view description. */ @@ -505,22 +510,22 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, PTABLE tablep, PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am) { TABTYPE tc; - LPCSTR name= (PSZ)PlugDup(g, tablep->GetName()); - LPCSTR schema= (PSZ)PlugDup(g, tablep->GetSchema()); + LPCSTR name= (PSZ)PlugDup(g, tablep->GetName()); + LPCSTR schema= (PSZ)PlugDup(g, tablep->GetSchema()); PRELDEF tdp= NULL; - if (trace(1)) - printf("MakeTableDesc: name=%s schema=%s am=%s\n", - name, SVP(schema), SVP(am)); + if (trace(1)) + htrc("MakeTableDesc: name=%s schema=%s am=%s\n", + name, SVP(schema), SVP(am)); /*********************************************************************/ /* Get a unique enum identifier for types. */ /*********************************************************************/ - if (!am) { - tc = Hc->GetRealType(); - am = Hc->GetStringOption("Type", "*"); - } else - tc = GetTypeID(am); + if (!am) { + tc= Hc->GetRealType(); + am= Hc->GetStringOption("Type","*"); + } else + tc= GetTypeID(am); switch (tc) { case TAB_FIX: @@ -535,49 +540,52 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am) case TAB_XML: tdp= new(g) XMLDEF; break; #endif // XML_SUPPORT #if defined(VCT_SUPPORT) - case TAB_VEC: tdp = new(g) VCTDEF; break; + case TAB_VEC: tdp = new(g) VCTDEF; break; #endif // VCT_SUPPORT #if defined(ODBC_SUPPORT) case TAB_ODBC: tdp= new(g) ODBCDEF; break; #endif // ODBC_SUPPORT #if defined(JAVA_SUPPORT) - case TAB_JDBC: tdp= new(g) JDBCDEF; break; + case TAB_JDBC: tdp= new(g) JDBCDEF; break; #endif // JAVA_SUPPORT #if defined(__WIN__) case TAB_MAC: tdp= new(g) MACDEF; break; case TAB_WMI: tdp= new(g) WMIDEF; break; #endif // __WIN__ case TAB_OEM: tdp= new(g) OEMDEF; break; - case TAB_TBL: tdp= new(g) TBLDEF; break; - case TAB_XCL: tdp= new(g) XCLDEF; break; - case TAB_PRX: tdp= new(g) PRXDEF; break; - case TAB_OCCUR: tdp= new(g) OCCURDEF; break; - case TAB_MYSQL: tdp= new(g) MYSQLDEF; break; + case TAB_TBL: tdp= new(g) TBLDEF; break; + case TAB_XCL: tdp= new(g) XCLDEF; break; + case TAB_PRX: tdp= new(g) PRXDEF; break; + case TAB_OCCUR: tdp= new(g) OCCURDEF; break; + case TAB_MYSQL: tdp= new(g) MYSQLDEF; break; case TAB_PIVOT: tdp= new(g) PIVOTDEF; break; case TAB_VIR: tdp= new(g) VIRDEF; break; case TAB_JSON: tdp= new(g) JSONDEF; break; #if defined(ZIP_SUPPORT) - case TAB_ZIP: tdp= new(g) ZIPDEF; break; + case TAB_ZIP: tdp = new(g) ZIPDEF; break; #endif // ZIP_SUPPORT #if defined(REST_SUPPORT) - case TAB_REST: tdp= new(g) RESTDEF; break; + case TAB_REST: tdp= new (g) RESTDEF; break; #endif // REST_SUPPORT #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) - case TAB_MONGO: - if (MongoEnabled()) { - tdp = new(g) MGODEF; - break; - } // endif enabled - // fall through + case TAB_MONGO: + if (MongoEnabled()) { + tdp = new(g) MGODEF; + break; + } // endif enabled + // fall through #endif // JAVA_SUPPORT || CMGO_SUPPORT - default: - sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name); + default: + sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name); } // endswitch // Do make the table/view definition if (tdp && tdp->Define(g, this, name, schema, am)) tdp= NULL; + if (trace(1)) + htrc("Table %s made\n", am); + return tdp; } // end of MakeTableDesc @@ -590,26 +598,29 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type) PTDB tdbp= NULL; // LPCSTR name= tablep->GetName(); - if (trace(1)) - printf("GetTableDB: name=%s\n", tablep->GetName()); + if (trace(1)) + htrc("GetTableDB: name=%s\n", tablep->GetName()); // Look for the description of the requested table tdp= GetTableDesc(g, tablep, type); if (tdp) { - if (trace(1)) - printf("tdb=%p type=%s\n", tdp, tdp->GetType()); + if (trace(1)) + htrc("tdb=%p type=%s\n", tdp, tdp->GetType()); + + if (tablep->GetSchema()) + tdp->Database = SetPath(g, tablep->GetSchema()); + + if (trace(2)) + htrc("Going to get table...\n"); - if (tablep->GetSchema()) - tdp->Database = SetPath(g, tablep->GetSchema()); - tdbp= tdp->GetTable(g, mode); - } // endif tdp + } // endif tdp if (tdbp) { - if (trace(1)) - printf("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(), - tdbp->GetAmType()); + if (trace(1)) + htrc("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(), + tdbp->GetAmType()); tablep->SetTo_Tdb(tdbp); tdbp->SetTable(tablep); tdbp->SetMode(mode); |