diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2017-09-19 15:07:32 +0300 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2017-09-19 15:13:53 +0300 |
commit | 5b9c32ede096e19d751537c6421563a7fb71c0db (patch) | |
tree | bde97f7b7a37ae77ee42203c9e77b080317cbb57 | |
parent | 22c322c649d5a15e3bb731d6751a0d80c8ec23b0 (diff) | |
parent | bf34e9db7be5baf64d131ce7c793be77172e4ed2 (diff) | |
download | mariadb-git-bb-10.2-vicentiu2.tar.gz |
Merge remote-tracking branch 'connect/10.2' into 10.2bb-10.2-vicentiu2
32 files changed, 440 insertions, 214 deletions
diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 2fabd12dcd0..a1594f8797c 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -245,7 +245,7 @@ int main() { ENDIF(CONNECT_WITH_ODBC) # -# JDBC and MongoDB Java Driver +# JDBC with MongoDB Java Driver included but disabled # OPTION(CONNECT_WITH_MONGO "Compile CONNECT storage engine with MONGO support" ON) OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine with JDBC support" ON) @@ -265,13 +265,13 @@ IF(CONNECT_WITH_JDBC) MysqlInterface.java OracleInterface.java PostgresqlInterface.java JavaWrappers.jar) add_definitions(-DJDBC_SUPPORT) - IF(CONNECT_WITH_MONGO) + IF(CONNECT_WITH_MONGO) SET(CONNECT_SOURCES ${CONNECT_SOURCES} jmgfam.cpp jmgoconn.cpp mongo.cpp tabjmg.cpp jmgfam.h jmgoconn.h mongo.h tabjmg.h Mongo2Interface.java Mongo3Interface.java) - add_definitions(-DMONGO_SUPPORT) - ENDIF() + add_definitions(-DMONGO_SUPPORT -DMONGO_ENABLED=0) + ENDIF() ELSE() SET(JDBC_LIBRARY "") ENDIF() @@ -290,33 +290,36 @@ IF(CONNECT_WITH_ZIP) ENDIF(CONNECT_WITH_ZIP) # -# MONGO C Driver (CMAKE NOT YET WORKING) +# MONGO C Driver # -#IF(CONNECT_WITH_MONGO) -# IF(WIN32) -# # Adding some typical places to search in -# SET(PC_MONGO_INCLUDE_DIRS -# C:/mongo-c-driver/include -# D:/mongo-c-driver/include) -# SET(PC_MONGO_LIBRARY_DIRS -# C:/mongo-c-driver/lib -# D:/mongo-c-driver/lib) -# ENDIF(WIN32) -# FIND_PACKAGE(libmongoc 1.7) -# IF (MONGO_FOUND) -# INCLUDE_DIRECTORIES(${MONGO_INCLUDE_DIR}) -# SET(MONGO_LIBRARY ${MONGO_LIBRARIES}) -# SET(CONNECT_SOURCES ${CONNECT_SOURCES} -# cmgoconn.cpp cmgfam.cpp tabcmg.cpp -# cmgoconn.h cmgfam.h tabcmg.h) -# add_definitions(-DCMGO_SUPPORT) -# IF (NOT JAVA_FOUND AND JNI_FOUND) -# SET(CONNECT_SOURCES ${CONNECT_SOURCES} mongo.cpp mongo.h) -# add_definitions(-DMONGO_SUPPORT) -# ENDIF (NOT JAVA_FOUND AND JNI_FOUND) -# ENDIF(MONGO_FOUND) -#ENDIF(CONNECT_WITH_MONGO) +IF(CONNECT_WITH_MONGO) + IF(WIN32) + # Adding some typical places to search in + SET(PC_MONGO_INCLUDE_DIRS + C:/mongo-c-driver/include + D:/mongo-c-driver/include) + SET(PC_MONGO_LIBRARY_DIRS + C:/mongo-c-driver/lib + D:/mongo-c-driver/lib) + ENDIF(WIN32) + FIND_PACKAGE(libmongoc-1.0 1.7) + IF (libmongoc-1.0_FOUND) + INCLUDE_DIRECTORIES(${MONGOC_INCLUDE_DIRS}) + SET(MONGOC_LIBRARY ${MONGOC_LIBRARIES}) + SET(CONNECT_SOURCES ${CONNECT_SOURCES} + cmgoconn.cpp cmgfam.cpp tabcmg.cpp + cmgoconn.h cmgfam.h tabcmg.h) + add_definitions(-DCMGO_SUPPORT) + IF (NOT JAVA_FOUND AND JNI_FOUND) + SET(CONNECT_SOURCES ${CONNECT_SOURCES} mongo.cpp mongo.h) + add_definitions(-DMONGO_SUPPORT -DMONGO_ENABLED=1) + ELSE () + remove_definitions(-DMONGO_ENABLED=0) + add_definitions(-DMONGO_ENABLED=1) + ENDIF (NOT JAVA_FOUND AND JNI_FOUND) + ENDIF(libmongoc-1.0_FOUND) +ENDIF(CONNECT_WITH_MONGO) # @@ -337,9 +340,25 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES} STORAGE_ENGINE COMPONENT connect-engine RECOMPILE_FOR_EMBEDDED -# LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} $(MONGO_LIBRARY) LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} - ${ODBC_LIBRARY} ${JDBC_LIBRARY} ${IPHLPAPI_LIBRARY}) + ${ODBC_LIBRARY} ${JDBC_LIBRARY} ${MONGOC_LIBRARY} ${IPHLPAPI_LIBRARY}) + +IF(NOT TARGET connect) + RETURN() +ENDIF() + +# Install some extra files that belong to connect engine +IF(WIN32) + # install ha_connect.lib + GET_TARGET_PROPERTY(CONNECT_LOCATION connect LOCATION) + STRING(REPLACE "dll" "lib" CONNECT_LIB ${CONNECT_LOCATION}) + IF(CMAKE_CONFIGURATION_TYPES) + STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" + CONNECT_LIB ${CONNECT_LIB}) + ENDIF() + INSTALL(FILES ${CONNECT_LIB} + DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) +ENDIF(WIN32) IF(NOT TARGET connect) RETURN() @@ -368,4 +387,3 @@ IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND) ${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) ENDIF() - diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 458369cd981..768e19fbaaf 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -171,9 +171,9 @@ #define JSONMAX 10 // JSON Default max grp size extern "C" { - char version[]= "Version 1.06.0001 April 17, 2017"; + char version[]= "Version 1.06.0004 September 03, 2017"; #if defined(__WIN__) - char compver[]= "Version 1.06.0001 " __DATE__ " " __TIME__; + char compver[]= "Version 1.06.0004 " __DATE__ " " __TIME__; char slash= '\\'; #else // !__WIN__ char slash= '/'; @@ -359,6 +359,13 @@ static MYSQL_THDVAR_STR(java_wrapper, NULL, NULL, "wrappers/JdbcInterface"); #endif // JDBC_SUPPORT +#if defined(MONGO_SUPPORT) +// Enabling MONGO table type +static MYSQL_THDVAR_BOOL(enable_mongo, PLUGIN_VAR_RQCMDARG, + "Enabling the MongoDB access", + NULL, NULL, MONGO_ENABLED); +#endif // MONGO_SUPPORT + #if defined(XMSG) || defined(NEWMSG) const char *language_names[]= { @@ -419,6 +426,10 @@ char *GetJavaWrapper(void) {return connect_hton ? THDVAR(current_thd, java_wrapper) : (char*)"wrappers/JdbcInterface";} #endif // JDBC_SUPPORT +#if defined(MONGO_SUPPORT) +bool MongoEnabled(void) { return THDVAR(current_thd, enable_mongo); } +#endif // MONGO_SUPPORT + extern "C" const char *msglang(void) { #if defined(FRENCH) @@ -1285,9 +1296,14 @@ PCSZ ha_connect::GetStringOption(PCSZ opname, PCSZ sdef) else opval= GetListOption(xp->g, opname, options->oplist); - } else if (!stricmp(opname, "Query_String")) - opval= thd_query_string(table->in_use)->str; - else if (!stricmp(opname, "Partname")) + } else if (!stricmp(opname, "Query_String")) { +// This escapes everything and returns a wrong query +// opval = thd_query_string(table->in_use)->str; + opval = (PCSZ)PlugSubAlloc(xp->g, NULL, + thd_query_string(table->in_use)->length + 1); + strcpy((char*)opval, thd_query_string(table->in_use)->str); +// sprintf((char*)opval, "%s", thd_query_string(table->in_use)->str); + } else if (!stricmp(opname, "Partname")) opval= partname; else if (!stricmp(opname, "Table_charset")) { const CHARSET_INFO *chif= (tshp) ? tshp->table_charset @@ -1433,7 +1449,7 @@ PFOS ha_connect::GetFieldOptionStruct(Field *fdp) void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf) { const char *cp; - char *chset, v; + char *chset, v = 0; ha_field_option_struct *fop; Field* fp; Field* *fldp; @@ -1486,7 +1502,6 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf) } // endif fop chset = (char *)fp->charset()->name; - v = (!strcmp(chset, "binary")) ? 'B' : 0; switch (fp->type()) { case MYSQL_TYPE_BLOB: @@ -1501,8 +1516,9 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf) switch (pcf->Type) { case TYPE_STRING: - // Do something for case - cp= fp->charset()->name; + case TYPE_BIN: + // Do something for case + cp= chset; // Find if collation name ends by _ci if (!strcmp(cp + strlen(cp) - 3, "_ci")) { @@ -2114,6 +2130,11 @@ int ha_connect::MakeRecord(char *buf) charset= tdbp->data_charset(); rc= fp->store(p, strlen(p), charset, CHECK_FIELD_WARN); break; + case TYPE_BIN: + p = value->GetCharValue(); + charset = &my_charset_bin; + rc = fp->store(p, strlen(p), charset, CHECK_FIELD_WARN); + break; case TYPE_DOUBLE: rc= fp->store(value->GetFloatValue()); break; @@ -5163,7 +5184,8 @@ static bool add_field(String *sql, const char *field_name, int typ, int len, error|= sql->append("` "); error|= sql->append(type); - if (len && typ != TYPE_DATE && (typ != TYPE_DOUBLE || dec >= 0)) { + if (typ == TYPE_STRING || + (len && typ != TYPE_DATE && (typ != TYPE_DOUBLE || dec >= 0))) { error|= sql->append('('); error|= sql->append_ulonglong(len); @@ -6389,6 +6411,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_STRING: +#if 0 if (!fp->field_length) { sprintf(g->Message, "Unsupported 0 length for column %s", fp->field_name); @@ -6398,7 +6421,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, MYF(0), fp->field_name); DBUG_RETURN(rc); } // endif fp - +#endif // 0 break; // To be checked case MYSQL_TYPE_BIT: case MYSQL_TYPE_NULL: @@ -7166,7 +7189,10 @@ static struct st_mysql_sys_var* connect_system_variables[]= { MYSQL_SYSVAR(class_path), MYSQL_SYSVAR(java_wrapper), #endif // JDBC_SUPPORT - NULL +#if defined(MONGO_SUPPORT) + MYSQL_SYSVAR(enable_mongo), +#endif // MONGO_SUPPORT +NULL }; maria_declare_plugin(connect) @@ -7175,14 +7201,14 @@ maria_declare_plugin(connect) &connect_storage_engine, "CONNECT", "Olivier Bertrand", - "Management of External Data (SQL/MED), including many file formats", + "Management of External Data (SQL/NOSQL/MED), including many file formats", PLUGIN_LICENSE_GPL, connect_init_func, /* Plugin Init */ connect_done_func, /* Plugin Deinit */ 0x0106, /* version number (1.05) */ NULL, /* status variables */ connect_system_variables, /* system variables */ - "1.06.0001", /* string version */ - MariaDB_PLUGIN_MATURITY_BETA /* maturity */ + "1.06.0004", /* string version */ + MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ } maria_declare_plugin_end; diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h index a5dcd4f65f1..e839590dbc8 100644 --- a/storage/connect/ha_connect.h +++ b/storage/connect/ha_connect.h @@ -348,6 +348,13 @@ const char *GetValStr(OPVAL vop, bool neg); PFIL CondFilter(PGLOBAL g, Item *cond); //PFIL CheckFilter(PGLOBAL g); +/** admin commands - called from mysql_admin_table */ +virtual int check(THD* thd, HA_CHECK_OPT* check_opt) +{ + // TODO: implement it + return HA_ADMIN_OK; // Just to avoid error message with checktables +} // end of check + /** Number of rows in table. It will only be called if (table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0 diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 00627669d60..9b6db947806 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -539,7 +539,7 @@ PVAL JSNX::CalculateArray(PGLOBAL g, PJAR arp, int n) SetJsonValue(g, MulVal, jvp, n); if (!MulVal->IsNull()) { - switch (op) { + switch (op) { case OP_CNC: if (Nodes[n].CncVal) { val[0] = Nodes[n].CncVal; diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index 23005db5272..0f8d7b76b60 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -111,6 +111,9 @@ extern "C" HINSTANCE s_hModule; // Saved module handle #endif // !__WIN__ +#if defined(MONGO_SUPPORT) +bool MongoEnabled(void); +#endif // MONGO_SUPPORT PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); /***********************************************************************/ @@ -558,7 +561,13 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am) case TAB_VIR: tdp= new(g) VIRDEF; break; case TAB_JSON: tdp= new(g) JSONDEF; break; #if defined(MONGO_SUPPORT) - case TAB_MONGO: tdp = new(g) MGODEF; break; + case TAB_MONGO: + if (MongoEnabled()) + tdp = new(g) MGODEF; + else + strcpy(g->Message, "MONGO type not enabled"); + + break; #endif // MONGO_SUPPORT #if defined(ZIP_SUPPORT) case TAB_ZIP: tdp= new(g) ZIPDEF; break; diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index d2d55f33611..08bb24e14df 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -472,7 +472,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, int pt, const char *csname) { const char *pipe = NULL; - uint cto = 6000, nrt = 12000; + uint cto = 10, nrt = 20; my_bool my_true= 1; m_DB = mysql_init(NULL); @@ -525,7 +525,8 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, mysql_options(m_DB, MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY, (char*)&my_true); - if (!mysql_real_connect(m_DB, host, user, pwd, db, pt, pipe, CLIENT_MULTI_RESULTS)) { + if (!mysql_real_connect(m_DB, host, user, pwd, db, pt, pipe, + CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS)) { #if defined(_DEBUG) sprintf(g->Message, "mysql_real_connect failed: (%d) %s", mysql_errno(m_DB), mysql_error(m_DB)); diff --git a/storage/connect/mysql-test/connect/r/json_java_2.result b/storage/connect/mysql-test/connect/r/json_java_2.result index 83272ec00ce..96c58221b24 100644 --- a/storage/connect/mysql-test/connect/r/json_java_2.result +++ b/storage/connect/mysql-test/connect/r/json_java_2.result @@ -1,4 +1,5 @@ SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo2.jar'; +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -25,7 +26,6 @@ address_street 1 CHAR 38 38 0 0 address.street address_zipcode 1 CHAR 5 5 0 0 address.zipcode borough 1 CHAR 13 13 0 0 cuisine 1 CHAR 64 64 0 0 -grades 1 CHAR 0 0 0 1 grades_date 1 CHAR 256 256 0 1 grades.0.date grades_grade 1 CHAR 14 14 0 1 grades.0.grade grades_score 5 BIGINT 2 2 0 1 grades.0.score @@ -72,7 +72,6 @@ t1 CREATE TABLE `t1` ( `address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode', `borough` char(13) NOT NULL, `cuisine` char(64) NOT NULL, - `grades` char(1) DEFAULT NULL, `grades_date` varchar(256) DEFAULT NULL `FIELD_FORMAT`='grades.0.date', `grades_grade` char(14) DEFAULT NULL `FIELD_FORMAT`='grades.0.grade', `grades_score` bigint(2) DEFAULT NULL `FIELD_FORMAT`='grades.0.score', @@ -80,12 +79,12 @@ t1 CREATE TABLE `t1` ( `restaurant_id` char(8) NOT NULL ) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='mongodb://localhost:27017' `TABLE_TYPE`='JSON' `TABNAME`='restaurants' `OPTION_LIST`='Level=1,Driver=Java,Version=2' `DATA_CHARSET`='utf8' `LRECL`=4096 SELECT * FROM t1 LIMIT 5; -_id address_building address_coord address_street address_zipcode borough cuisine grades grades_date grades_grade grades_score name restaurant_id -58ada47de5a51ddfcd5ed51c 1007 -73.856077 Morris Park Ave 10462 Bronx Bakery 2 2014-03-03T00:00:00.000Z A 2 Morris Park Bake Shop 30075445 -58ada47de5a51ddfcd5ed51d 469 -73.961704 Flatbush Avenue 11225 Brooklyn Hamburgers 2 2014-12-30T00:00:00.000Z A 8 Wendy'S 30112340 -58ada47de5a51ddfcd5ed51e 351 -73.98513559999999 West 57 Street 10019 Manhattan Irish 2 2014-09-06T00:00:00.000Z A 2 Dj Reynolds Pub And Restaurant 30191841 -58ada47de5a51ddfcd5ed51f 2780 -73.98241999999999 Stillwell Avenue 11224 Brooklyn American 2 2014-06-10T00:00:00.000Z A 5 Riviera Caterer 40356018 -58ada47de5a51ddfcd5ed520 97-22 -73.8601152 63 Road 11374 Queens Jewish/Kosher 2 2014-11-24T00:00:00.000Z Z 20 Tov Kosher Kitchen 40356068 +_id address_building address_coord address_street address_zipcode borough cuisine grades_date grades_grade grades_score name restaurant_id +58ada47de5a51ddfcd5ed51c 1007 -73.856077 Morris Park Ave 10462 Bronx Bakery 2014-03-03T00:00:00.000Z A 2 Morris Park Bake Shop 30075445 +58ada47de5a51ddfcd5ed51d 469 -73.961704 Flatbush Avenue 11225 Brooklyn Hamburgers 2014-12-30T00:00:00.000Z A 8 Wendy'S 30112340 +58ada47de5a51ddfcd5ed51e 351 -73.98513559999999 West 57 Street 10019 Manhattan Irish 2014-09-06T00:00:00.000Z A 2 Dj Reynolds Pub And Restaurant 30191841 +58ada47de5a51ddfcd5ed51f 2780 -73.98241999999999 Stillwell Avenue 11224 Brooklyn American 2014-06-10T00:00:00.000Z A 5 Riviera Caterer 40356018 +58ada47de5a51ddfcd5ed520 97-22 -73.8601152 63 Road 11374 Queens Jewish/Kosher 2014-11-24T00:00:00.000Z Z 20 Tov Kosher Kitchen 40356068 DROP TABLE t1; # # Dropping a column @@ -259,7 +258,6 @@ t1 CREATE TABLE `t1` ( `address_street` char(38) NOT NULL `FIELD_FORMAT`='address.street', `address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode', `borough` char(13) NOT NULL, - `grades` char(1) DEFAULT NULL, `grades_date` char(24) DEFAULT NULL `FIELD_FORMAT`='grades.0.date', `grades_grade` char(14) DEFAULT NULL `FIELD_FORMAT`='grades.0.grade', `grades_score` bigint(2) DEFAULT NULL `FIELD_FORMAT`='grades.0.score', @@ -384,3 +382,4 @@ planner 167 41.75 postcard 23 5.75 DROP TABLE t1; true +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/r/json_java_3.result b/storage/connect/mysql-test/connect/r/json_java_3.result index 563bcef7321..09901452975 100644 --- a/storage/connect/mysql-test/connect/r/json_java_3.result +++ b/storage/connect/mysql-test/connect/r/json_java_3.result @@ -1,4 +1,5 @@ SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo3.jar'; +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -25,7 +26,6 @@ address_street 1 CHAR 38 38 0 0 address.street address_zipcode 1 CHAR 5 5 0 0 address.zipcode borough 1 CHAR 13 13 0 0 cuisine 1 CHAR 64 64 0 0 -grades 1 CHAR 0 0 0 1 grades_date 1 CHAR 256 256 0 1 grades.0.date grades_grade 1 CHAR 14 14 0 1 grades.0.grade grades_score 5 BIGINT 2 2 0 1 grades.0.score @@ -72,7 +72,6 @@ t1 CREATE TABLE `t1` ( `address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode', `borough` char(13) NOT NULL, `cuisine` char(64) NOT NULL, - `grades` char(1) DEFAULT NULL, `grades_date` varchar(256) DEFAULT NULL `FIELD_FORMAT`='grades.0.date', `grades_grade` char(14) DEFAULT NULL `FIELD_FORMAT`='grades.0.grade', `grades_score` bigint(2) DEFAULT NULL `FIELD_FORMAT`='grades.0.score', @@ -80,12 +79,12 @@ t1 CREATE TABLE `t1` ( `restaurant_id` char(8) NOT NULL ) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='mongodb://localhost:27017' `TABLE_TYPE`='JSON' `TABNAME`='restaurants' `OPTION_LIST`='Level=1,Driver=Java,Version=3' `DATA_CHARSET`='utf8' `LRECL`=4096 SELECT * FROM t1 LIMIT 5; -_id address_building address_coord address_street address_zipcode borough cuisine grades grades_date grades_grade grades_score name restaurant_id -58ada47de5a51ddfcd5ed51c 1007 -73.856077 Morris Park Ave 10462 Bronx Bakery 1 1393804800 A 2 Morris Park Bake Shop 30075445 -58ada47de5a51ddfcd5ed51d 469 -73.961704 Flatbush Avenue 11225 Brooklyn Hamburgers 1 1419897600 A 8 Wendy'S 30112340 -58ada47de5a51ddfcd5ed51e 351 -73.98513559999999 West 57 Street 10019 Manhattan Irish 1 1409961600 A 2 Dj Reynolds Pub And Restaurant 30191841 -58ada47de5a51ddfcd5ed51f 2780 -73.98241999999999 Stillwell Avenue 11224 Brooklyn American 1 1402358400 A 5 Riviera Caterer 40356018 -58ada47de5a51ddfcd5ed520 97-22 -73.8601152 63 Road 11374 Queens Jewish/Kosher 1 1416787200 Z 20 Tov Kosher Kitchen 40356068 +_id address_building address_coord address_street address_zipcode borough cuisine grades_date grades_grade grades_score name restaurant_id +58ada47de5a51ddfcd5ed51c 1007 -73.856077 Morris Park Ave 10462 Bronx Bakery 1393804800 A 2 Morris Park Bake Shop 30075445 +58ada47de5a51ddfcd5ed51d 469 -73.961704 Flatbush Avenue 11225 Brooklyn Hamburgers 1419897600 A 8 Wendy'S 30112340 +58ada47de5a51ddfcd5ed51e 351 -73.98513559999999 West 57 Street 10019 Manhattan Irish 1409961600 A 2 Dj Reynolds Pub And Restaurant 30191841 +58ada47de5a51ddfcd5ed51f 2780 -73.98241999999999 Stillwell Avenue 11224 Brooklyn American 1402358400 A 5 Riviera Caterer 40356018 +58ada47de5a51ddfcd5ed520 97-22 -73.8601152 63 Road 11374 Queens Jewish/Kosher 1416787200 Z 20 Tov Kosher Kitchen 40356068 DROP TABLE t1; # # Dropping a column @@ -259,7 +258,6 @@ t1 CREATE TABLE `t1` ( `address_street` char(38) NOT NULL `FIELD_FORMAT`='address.street', `address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode', `borough` char(13) NOT NULL, - `grades` char(1) DEFAULT NULL, `grades_date` bigint(13) DEFAULT NULL `FIELD_FORMAT`='grades.0.date', `grades_grade` char(14) DEFAULT NULL `FIELD_FORMAT`='grades.0.grade', `grades_score` bigint(2) DEFAULT NULL `FIELD_FORMAT`='grades.0.score', @@ -384,3 +382,4 @@ planner 167 41.75 postcard 23 5.75 DROP TABLE t1; true +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/r/json_mongo_c.result b/storage/connect/mysql-test/connect/r/json_mongo_c.result index d3363f39eab..afcad8d2ea2 100644 --- a/storage/connect/mysql-test/connect/r/json_mongo_c.result +++ b/storage/connect/mysql-test/connect/r/json_mongo_c.result @@ -1,3 +1,4 @@ +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -24,7 +25,6 @@ address_street 1 CHAR 38 38 0 0 address.street address_zipcode 1 CHAR 5 5 0 0 address.zipcode borough 1 CHAR 13 13 0 0 cuisine 1 CHAR 64 64 0 0 -grades 1 CHAR 0 0 0 1 grades_date 1 CHAR 256 256 0 1 grades.0.date grades_grade 1 CHAR 14 14 0 1 grades.0.grade grades_score 5 BIGINT 2 2 0 1 grades.0.score @@ -71,7 +71,6 @@ t1 CREATE TABLE `t1` ( `address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode', `borough` char(13) NOT NULL, `cuisine` char(64) NOT NULL, - `grades` char(1) DEFAULT NULL, `grades_date` varchar(256) DEFAULT NULL `FIELD_FORMAT`='grades.0.date', `grades_grade` char(14) DEFAULT NULL `FIELD_FORMAT`='grades.0.grade', `grades_score` bigint(2) DEFAULT NULL `FIELD_FORMAT`='grades.0.score', @@ -79,12 +78,12 @@ t1 CREATE TABLE `t1` ( `restaurant_id` char(8) NOT NULL ) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='mongodb://localhost:27017' `TABLE_TYPE`='JSON' `TABNAME`='restaurants' `OPTION_LIST`='Level=1,Driver=C,Version=0' `DATA_CHARSET`='utf8' `LRECL`=1024 SELECT * FROM t1 LIMIT 5; -_id address_building address_coord address_street address_zipcode borough cuisine grades grades_date grades_grade grades_score name restaurant_id -58ada47de5a51ddfcd5ed51c 1007 -73.856076999999999089 Morris Park Ave 10462 Bronx Bakery 1 1393804800 A 2 Morris Park Bake Shop 30075445 -58ada47de5a51ddfcd5ed51d 469 -73.96170399999999745 Flatbush Avenue 11225 Brooklyn Hamburgers 1 1419897600 A 8 Wendy'S 30112340 -58ada47de5a51ddfcd5ed51e 351 -73.985135599999992451 West 57 Street 10019 Manhattan Irish 1 1409961600 A 2 Dj Reynolds Pub And Restaurant 30191841 -58ada47de5a51ddfcd5ed51f 2780 -73.982419999999990523 Stillwell Avenue 11224 Brooklyn American 1 1402358400 A 5 Riviera Caterer 40356018 -58ada47de5a51ddfcd5ed520 97-22 -73.860115199999995639 63 Road 11374 Queens Jewish/Kosher 1 1416787200 Z 20 Tov Kosher Kitchen 40356068 +_id address_building address_coord address_street address_zipcode borough cuisine grades_date grades_grade grades_score name restaurant_id +58ada47de5a51ddfcd5ed51c 1007 -73.856076999999999089 Morris Park Ave 10462 Bronx Bakery 1393804800 A 2 Morris Park Bake Shop 30075445 +58ada47de5a51ddfcd5ed51d 469 -73.96170399999999745 Flatbush Avenue 11225 Brooklyn Hamburgers 1419897600 A 8 Wendy'S 30112340 +58ada47de5a51ddfcd5ed51e 351 -73.985135599999992451 West 57 Street 10019 Manhattan Irish 1409961600 A 2 Dj Reynolds Pub And Restaurant 30191841 +58ada47de5a51ddfcd5ed51f 2780 -73.982419999999990523 Stillwell Avenue 11224 Brooklyn American 1402358400 A 5 Riviera Caterer 40356018 +58ada47de5a51ddfcd5ed520 97-22 -73.860115199999995639 63 Road 11374 Queens Jewish/Kosher 1416787200 Z 20 Tov Kosher Kitchen 40356068 DROP TABLE t1; # # Dropping a column @@ -258,7 +257,6 @@ t1 CREATE TABLE `t1` ( `address_street` char(38) NOT NULL `FIELD_FORMAT`='address.street', `address_zipcode` char(5) NOT NULL `FIELD_FORMAT`='address.zipcode', `borough` char(13) NOT NULL, - `grades` char(1) DEFAULT NULL, `grades_date` bigint(13) DEFAULT NULL `FIELD_FORMAT`='grades.0.date', `grades_grade` char(14) DEFAULT NULL `FIELD_FORMAT`='grades.0.grade', `grades_score` bigint(2) DEFAULT NULL `FIELD_FORMAT`='grades.0.score', @@ -383,3 +381,4 @@ planner 167 41.75 postcard 23 5.75 DROP TABLE t1; true +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/r/mongo_c.result b/storage/connect/mysql-test/connect/r/mongo_c.result index da0832994c2..f90f3a94b44 100644 --- a/storage/connect/mysql-test/connect/r/mongo_c.result +++ b/storage/connect/mysql-test/connect/r/mongo_c.result @@ -1,3 +1,4 @@ +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -376,3 +377,4 @@ planner 167 41.750000 postcard 23 5.750000 DROP TABLE t1; true +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/r/mongo_java_2.result b/storage/connect/mysql-test/connect/r/mongo_java_2.result index b1e9ea74f72..02b8ae09d34 100644 --- a/storage/connect/mysql-test/connect/r/mongo_java_2.result +++ b/storage/connect/mysql-test/connect/r/mongo_java_2.result @@ -1,4 +1,5 @@ SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo2.jar'; +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -377,3 +378,4 @@ planner 167 41.75 postcard 23 5.75 DROP TABLE t1; true +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/r/mongo_java_3.result b/storage/connect/mysql-test/connect/r/mongo_java_3.result index e2fe584620f..c4387bfa5b1 100644 --- a/storage/connect/mysql-test/connect/r/mongo_java_3.result +++ b/storage/connect/mysql-test/connect/r/mongo_java_3.result @@ -1,4 +1,5 @@ SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo3.jar'; +set connect_enable_mongo=1; # # Test the MONGO table type # @@ -377,3 +378,4 @@ planner 167 41.75 postcard 23 5.75 DROP TABLE t1; true +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/r/odbc_oracle.result b/storage/connect/mysql-test/connect/r/odbc_oracle.result index db7f78f67cd..8dc7dc07bb1 100644 --- a/storage/connect/mysql-test/connect/r/odbc_oracle.result +++ b/storage/connect/mysql-test/connect/r/odbc_oracle.result @@ -72,11 +72,11 @@ TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtr' CATFUNC=Columns; SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks -NULL MTR T1 A 3 DECIMAL 38 40 0 10 1 NULL -NULL MTR T1 B 6 NUMBER 38 40 NULL NULL 1 NULL -NULL MTR T2 A 12 VARCHAR2 64 64 NULL NULL 1 NULL -NULL MTR V1 A 3 DECIMAL 38 40 0 10 1 NULL -NULL MTR V1 B 6 NUMBER 38 40 NULL NULL 1 NULL + MTR T1 A 3 DECIMAL 38 40 0 10 1 + MTR T1 B 6 NUMBER 38 40 NULL NULL 1 + MTR T2 A 12 VARCHAR2 64 64 NULL NULL 1 + MTR V1 A 3 DECIMAL 38 40 0 10 1 + MTR V1 B 6 NUMBER 38 40 NULL NULL 1 DROP TABLE t1; # All columns in all schemas (limited with WHERE) CREATE TABLE t1 ENGINE=CONNECT @@ -84,18 +84,18 @@ TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%'; SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks -NULL MTR T1 A 3 DECIMAL 38 40 0 10 1 NULL -NULL MTR T1 B 6 NUMBER 38 40 NULL NULL 1 NULL -NULL MTR T2 A 12 VARCHAR2 64 64 NULL NULL 1 NULL -NULL MTR V1 A 3 DECIMAL 38 40 0 10 1 NULL -NULL MTR V1 B 6 NUMBER 38 40 NULL NULL 1 NULL + MTR T1 A 3 DECIMAL 38 40 0 10 1 + MTR T1 B 6 NUMBER 38 40 NULL NULL 1 + MTR T2 A 12 VARCHAR2 64 64 NULL NULL 1 + MTR V1 A 3 DECIMAL 38 40 0 10 1 + MTR V1 B 6 NUMBER 38 40 NULL NULL 1 DROP TABLE t1; # All tables "T1" in all schemas (limited with WHERE) CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.T1'; SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks -NULL MTR T1 A 3 DECIMAL 38 40 0 10 1 NULL -NULL MTR T1 B 6 NUMBER 38 40 NULL NULL 1 NULL + MTR T1 A 3 DECIMAL 38 40 0 10 1 + MTR T1 B 6 NUMBER 38 40 NULL NULL 1 DROP TABLE t1; # Table "T1" in the schema "MTR" CREATE TABLE t1 ENGINE=CONNECT @@ -103,8 +103,8 @@ TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='MTR.T1'; SELECT * FROM t1 ORDER BY Table_Schema, Table_Name; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks -NULL MTR T1 A 3 DECIMAL 38 40 0 10 1 NULL -NULL MTR T1 B 6 NUMBER 38 40 NULL NULL 1 NULL + MTR T1 A 3 DECIMAL 38 40 0 10 1 + MTR T1 B 6 NUMBER 38 40 NULL NULL 1 DROP TABLE t1; # All tables "T1" in all schemas (filtered with WHERE) CREATE TABLE t1 ENGINE=CONNECT @@ -112,8 +112,8 @@ TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineOracle;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.T1'; SELECT * FROM t1 WHERE Table_Schema='MTR' ORDER BY Table_Schema, Table_Name; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks -NULL MTR T1 A 3 DECIMAL 38 40 0 10 1 NULL -NULL MTR T1 B 6 NUMBER 38 40 NULL NULL 1 NULL + MTR T1 A 3 DECIMAL 38 40 0 10 1 + MTR T1 B 6 NUMBER 38 40 NULL NULL 1 DROP TABLE t1; # # Checking tables diff --git a/storage/connect/mysql-test/connect/r/tbl_thread.result b/storage/connect/mysql-test/connect/r/tbl_thread.result index ef6439462bb..f53ccd25b97 100644 --- a/storage/connect/mysql-test/connect/r/tbl_thread.result +++ b/storage/connect/mysql-test/connect/r/tbl_thread.result @@ -35,6 +35,22 @@ a b 9 test09 10 test10 11 test11 +CREATE TABLE rt4 (a int, b char(10)); +INSERT INTO rt4 VALUES (12,'test12'),(13,'test13'),(14,'test14'),(15,'test15'); +SELECT * FROM rt4; +a b +12 test12 +13 test13 +14 test14 +15 test15 +CREATE TABLE rt5 (a int, b char(10)); +INSERT INTO rt5 VALUES (16,'test16'),(17,'test17'),(18,'test18'),(19,'test19'); +SELECT * FROM rt5; +a b +16 test16 +17 test17 +18 test18 +19 test19 connection default; CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@127.0.0.1:MASTER_PORT/test/rt2'; @@ -52,11 +68,36 @@ a b 9 test09 10 test10 11 test11 +CREATE TABLE t4 ENGINE=CONNECT TABLE_TYPE=MYSQL +CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/rt4'; +SELECT * FROM t4; +a b +12 test12 +13 test13 +14 test14 +15 test15 +CREATE TABLE t5 ENGINE=CONNECT TABLE_TYPE=MYSQL +CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/rt5'; +SELECT * FROM t5; +a b +16 test16 +17 test17 +18 test18 +19 test19 CREATE TABLE total (a int, b char(10)) -ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3' +ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3,t4,t5' OPTION_LIST='thread=yes,port=PORT'; +set connect_xtrace=1; SELECT * FROM total order by a desc; a b +19 test19 +18 test18 +17 test17 +16 test16 +15 test15 +14 test14 +13 test13 +12 test12 11 test11 10 test10 9 test09 @@ -69,12 +110,13 @@ a b 2 test02 1 test01 0 test00 +set connect_xtrace=0; connection master; DROP TABLE rt2; connection slave; -DROP TABLE rt3; +DROP TABLE rt3,rt4,rt5; connection default; -DROP TABLE t1,t2,t3,total; +DROP TABLE t1,t2,t3,t4,t5,total; # # Old thread TBL tables test modified # @@ -87,13 +129,15 @@ SELECT * FROM t2; v 22 CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=PORT';; +set connect_xtrace=1; SELECT * FROM total order by v desc; v 22 11 +set connect_xtrace=0; DROP TABLE t1,t2,total; # -# Old thread TBL tables test not modified +# Old thread TBL tables test not modified (suppressed until MDEV-10179 is fixed) # CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 11 as v'; SELECT * FROM t1; @@ -104,10 +148,12 @@ SELECT * FROM t2; v 22 CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=PORT';; +set connect_xtrace=1; SELECT * FROM total order by v desc; v 22 11 +set connect_xtrace=0; DROP TABLE total; DROP TABLE t1; DROP TABLE t2; diff --git a/storage/connect/mysql-test/connect/std_data/Mongo2.jar b/storage/connect/mysql-test/connect/std_data/Mongo2.jar Binary files differindex d019bf6906b..9be654bd4c8 100644 --- a/storage/connect/mysql-test/connect/std_data/Mongo2.jar +++ b/storage/connect/mysql-test/connect/std_data/Mongo2.jar diff --git a/storage/connect/mysql-test/connect/std_data/Mongo3.jar b/storage/connect/mysql-test/connect/std_data/Mongo3.jar Binary files differindex 73eb3571290..2850177a668 100644 --- a/storage/connect/mysql-test/connect/std_data/Mongo3.jar +++ b/storage/connect/mysql-test/connect/std_data/Mongo3.jar diff --git a/storage/connect/mysql-test/connect/t/mongo_test.inc b/storage/connect/mysql-test/connect/t/mongo_test.inc index c223e70f719..c728b85fd2f 100644 --- a/storage/connect/mysql-test/connect/t/mongo_test.inc +++ b/storage/connect/mysql-test/connect/t/mongo_test.inc @@ -1,3 +1,5 @@ +set connect_enable_mongo=1; + --echo # --echo # Test the MONGO table type --echo # @@ -201,3 +203,5 @@ OPTION_LIST='Driver=$DRV,Version=$VERS,Pipeline=YES' $CONN; SELECT * FROM t1; DROP TABLE t1; --exec $MONGO --eval "db.testcoll.drop()" --quiet + +set connect_enable_mongo=0; diff --git a/storage/connect/mysql-test/connect/t/tbl_thread.test b/storage/connect/mysql-test/connect/t/tbl_thread.test index abc1ef34729..68a0ebcd44d 100644 --- a/storage/connect/mysql-test/connect/t/tbl_thread.test +++ b/storage/connect/mysql-test/connect/t/tbl_thread.test @@ -2,8 +2,6 @@ connection default; -let $PORT= `select @@port`; - --echo # --echo # Checking thread TBL tables --echo # @@ -24,6 +22,14 @@ CREATE TABLE rt3 (a int, b char(10)); INSERT INTO rt3 VALUES (8,'test08'),(9,'test09'),(10,'test10'),(11,'test11'); SELECT * FROM rt3; +CREATE TABLE rt4 (a int, b char(10)); +INSERT INTO rt4 VALUES (12,'test12'),(13,'test13'),(14,'test14'),(15,'test15'); +SELECT * FROM rt4; + +CREATE TABLE rt5 (a int, b char(10)); +INSERT INTO rt5 VALUES (16,'test16'),(17,'test17'),(18,'test18'),(19,'test19'); +SELECT * FROM rt5; + connection default; --replace_result $MASTER_MYPORT MASTER_PORT @@ -36,11 +42,23 @@ eval CREATE TABLE t3 ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/rt3'; SELECT * FROM t3; +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval CREATE TABLE t4 ENGINE=CONNECT TABLE_TYPE=MYSQL +CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/rt4'; +SELECT * FROM t4; + +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval CREATE TABLE t5 ENGINE=CONNECT TABLE_TYPE=MYSQL +CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/rt5'; +SELECT * FROM t5; + --replace_result $PORT PORT eval CREATE TABLE total (a int, b char(10)) -ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3' +ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3,t4,t5' OPTION_LIST='thread=yes,port=$PORT'; +set connect_xtrace=1; SELECT * FROM total order by a desc; +set connect_xtrace=0; connection master; @@ -48,11 +66,11 @@ DROP TABLE rt2; connection slave; -DROP TABLE rt3; +DROP TABLE rt3,rt4,rt5; connection default; -DROP TABLE t1,t2,t3,total; +DROP TABLE t1,t2,t3,t4,t5,total; --echo # --echo # Old thread TBL tables test modified @@ -67,11 +85,13 @@ SELECT * FROM t2; --replace_result $PORT PORT --eval CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=$PORT'; +set connect_xtrace=1; SELECT * FROM total order by v desc; +set connect_xtrace=0; DROP TABLE t1,t2,total; --echo # ---echo # Old thread TBL tables test not modified +--echo # Old thread TBL tables test not modified (suppressed until MDEV-10179 is fixed) --echo # CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 11 as v'; SELECT * FROM t1; @@ -81,7 +101,9 @@ SELECT * FROM t2; --replace_result $PORT PORT --eval CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=$PORT'; +set connect_xtrace=1; SELECT * FROM total order by v desc; +set connect_xtrace=0; DROP TABLE total; DROP TABLE t1; diff --git a/storage/connect/myutil.cpp b/storage/connect/myutil.cpp index c2053f1c832..338a79d9455 100644 --- a/storage/connect/myutil.cpp +++ b/storage/connect/myutil.cpp @@ -218,7 +218,7 @@ int MYSQLtoPLG(int mytype, char *var) case MYSQL_TYPE_VARCHAR: #endif // !ALPHA) case MYSQL_TYPE_STRING: - type = TYPE_STRING; + type = (*var == 'B') ? TYPE_BIN : TYPE_STRING; break; case MYSQL_TYPE_BLOB: case MYSQL_TYPE_TINY_BLOB: @@ -232,7 +232,7 @@ int MYSQLtoPLG(int mytype, char *var) type = TYPE_STRING; *var = 'X'; } else - type = TYPE_ERROR; + type = TYPE_BIN; break; case TPC_SKIP: diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index 95069baf76e..031fdebe650 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -789,7 +789,7 @@ int COLDEF::Define(PGLOBAL g, void *, PCOLINFO cfp, int poff) Poff = poff; Buf_Type = cfp->Type; - if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) <= 0) { + if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) < 0) { sprintf(g->Message, MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name); return -1; } // endswitch diff --git a/storage/connect/reldef.h b/storage/connect/reldef.h index 8b19a413ade..84ae2a491f0 100644 --- a/storage/connect/reldef.h +++ b/storage/connect/reldef.h @@ -94,6 +94,7 @@ public: virtual void SetIndx(PIXDEF) {} virtual bool IsHuge(void) {return false;} const CHARSET_INFO *data_charset() {return m_data_charset;} + const char *GetCsName(void) {return csname;} // Methods int GetColCatInfo(PGLOBAL g); diff --git a/storage/connect/tabext.cpp b/storage/connect/tabext.cpp index 8f6e610dfc2..a75b373b564 100644 --- a/storage/connect/tabext.cpp +++ b/storage/connect/tabext.cpp @@ -279,10 +279,57 @@ int TDBEXT::Decode(PCSZ txt, char *buf, size_t n) } // end of Decode /***********************************************************************/ -/* MakeSQL: make the SQL statement use with remote connection. */ -/* TODO: when implementing remote filtering, column only used in */ -/* local filter should be removed from column list. */ +/* MakeSrcdef: make the SQL statement from SRDEF option. */ /***********************************************************************/ +bool TDBEXT::MakeSrcdef(PGLOBAL g) +{ + char *catp = strstr(Srcdef, "%s"); + + if (catp) { + char *fil1, *fil2; + PCSZ ph = ((EXTDEF*)To_Def)->Phpos; + + if (!ph) + ph = (strstr(catp + 2, "%s")) ? "WH" : "W"; + + if (stricmp(ph, "H")) { + fil1 = (To_CondFil && *To_CondFil->Body) + ? To_CondFil->Body : PlugDup(g, "1=1"); + } // endif ph + + if (stricmp(ph, "W")) { + fil2 = (To_CondFil && To_CondFil->Having && *To_CondFil->Having) + ? To_CondFil->Having : PlugDup(g, "1=1"); + } // endif ph + + if (!stricmp(ph, "W")) { + Query = new(g)STRING(g, strlen(Srcdef) + strlen(fil1)); + Query->SetLength(sprintf(Query->GetStr(), Srcdef, fil1)); + } else if (!stricmp(ph, "WH")) { + Query = new(g)STRING(g, strlen(Srcdef) + strlen(fil1) + strlen(fil2)); + Query->SetLength(sprintf(Query->GetStr(), Srcdef, fil1, fil2)); + } else if (!stricmp(ph, "H")) { + Query = new(g)STRING(g, strlen(Srcdef) + strlen(fil2)); + Query->SetLength(sprintf(Query->GetStr(), Srcdef, fil2)); + } else if (!stricmp(ph, "HW")) { + Query = new(g)STRING(g, strlen(Srcdef) + strlen(fil1) + strlen(fil2)); + Query->SetLength(sprintf(Query->GetStr(), Srcdef, fil2, fil1)); + } else { + strcpy(g->Message, "MakeSQL: Wrong place holders specification"); + return true; + } // endif's ph + + } else + Query = new(g)STRING(g, 0, Srcdef); + + return false; +} // end of MakeSrcdef + + /***********************************************************************/ + /* MakeSQL: make the SQL statement use with remote connection. */ + /* TODO: when implementing remote filtering, column only used in */ + /* local filter should be removed from column list. */ + /***********************************************************************/ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt) { PCSZ schmp = NULL; @@ -292,46 +339,8 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt) PTABLE tablep = To_Table; PCOL colp; - if (Srcdef) { - if ((catp = strstr(Srcdef, "%s"))) { - char *fil1, *fil2; - PCSZ ph = ((EXTDEF*)To_Def)->Phpos; - - if (!ph) - ph = (strstr(catp + 2, "%s")) ? "WH" : "W"; - - if (stricmp(ph, "H")) { - fil1 = (To_CondFil && *To_CondFil->Body) - ? To_CondFil->Body : PlugDup(g, "1=1"); - } // endif ph - - if (stricmp(ph, "W")) { - fil2 = (To_CondFil && To_CondFil->Having && *To_CondFil->Having) - ? To_CondFil->Having : PlugDup(g, "1=1"); - } // endif ph - - if (!stricmp(ph, "W")) { - Query = new(g)STRING(g, strlen(Srcdef) + strlen(fil1)); - Query->SetLength(sprintf(Query->GetStr(), Srcdef, fil1)); - } else if (!stricmp(ph, "WH")) { - Query = new(g)STRING(g, strlen(Srcdef) + strlen(fil1) + strlen(fil2)); - Query->SetLength(sprintf(Query->GetStr(), Srcdef, fil1, fil2)); - } else if (!stricmp(ph, "H")) { - Query = new(g)STRING(g, strlen(Srcdef) + strlen(fil2)); - Query->SetLength(sprintf(Query->GetStr(), Srcdef, fil2)); - } else if (!stricmp(ph, "HW")) { - Query = new(g)STRING(g, strlen(Srcdef) + strlen(fil1) + strlen(fil2)); - Query->SetLength(sprintf(Query->GetStr(), Srcdef, fil2, fil1)); - } else { - strcpy(g->Message, "MakeSQL: Wrong place holders specification"); - return true; - } // endif's ph - - } else - Query = new(g)STRING(g, 0, Srcdef); - - return false; - } // endif Srcdef + if (Srcdef) + return MakeSrcdef(g); // Allocate the string used to contain the Query Query = new(g)STRING(g, 1023, "SELECT "); diff --git a/storage/connect/tabext.h b/storage/connect/tabext.h index 7ddf2a68117..6b67c2ab5ed 100644 --- a/storage/connect/tabext.h +++ b/storage/connect/tabext.h @@ -126,6 +126,7 @@ public: protected: // Internal functions + virtual bool MakeSrcdef(PGLOBAL g); virtual bool MakeSQL(PGLOBAL g, bool cnt); //virtual bool MakeInsert(PGLOBAL g); virtual bool MakeCommand(PGLOBAL g); diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 76a3d5e9988..401441520da 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -136,6 +136,7 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0; tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2); tdp->Xcol = GetStringTableOption(g, topt, "Expand", NULL); + tdp->Accept = GetBooleanTableOption(g, topt, "Accept", false); tdp->Uri = (dsn && *dsn ? dsn : NULL); if (!tdp->Fn && !tdp->Uri) { @@ -365,7 +366,7 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) jcp->Scale = MY_MAX(jcp->Scale, jcol.Scale); jcp->Cbn |= jcol.Cbn; jcp->Found = true; - } else { + } else if (jcol.Type != TYPE_UNKNOWN || tdp->Accept) { // New column jcp = (PJCL)PlugSubAlloc(g, NULL, sizeof(JCOL)); *jcp = jcol; @@ -448,8 +449,8 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) /* Now get the results into blocks. */ /*********************************************************************/ for (i = 0, jcp = fjcp; jcp; i++, jcp = jcp->Next) { - if (jcp->Type == TYPE_UNKNOWN) // Void column - jcp->Type = TYPE_STRING; + if (jcp->Type == TYPE_UNKNOWN) + jcp->Type = TYPE_STRING; // Void column crp = qrp->Colresp; // Column Name crp->Kdata->SetValue(jcp->Name, i); diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index bdddcf64ca8..d1e2ae69608 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -513,18 +513,8 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g, bool mx) if (Query) return false; // already done - if (Srcdef) { - if (strstr(Srcdef, "%s")) { - char *fil; - - fil = (To_CondFil) ? To_CondFil->Body : PlugDup(g, "1=1"); - Query = new(g)STRING(g, strlen(Srcdef) + strlen(fil)); - Query->SetLength(sprintf(Query->GetStr(), Srcdef, fil)); - } else - Query = new(g)STRING(g, 0, Srcdef); - - return false; - } // endif Srcdef + if (Srcdef) + return MakeSrcdef(g); // Allocate the string used to contain Query Query = new(g) STRING(g, 1023, "SELECT "); @@ -1270,7 +1260,8 @@ MYSQLCOL::MYSQLCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PCSZ am) : COLBLK(NULL, tdbp, i) { const char *chset = get_charset_name(fld->charsetnr); - char v = (!strcmp(chset, "binary")) ? 'B' : 0; +//char v = (!strcmp(chset, "binary")) ? 'B' : 0; + char v = 0; Name = fld->name; Opt = 0; diff --git a/storage/connect/tabmysql.h b/storage/connect/tabmysql.h index 3c37ae5bf3b..39fba87bcc9 100644 --- a/storage/connect/tabmysql.h +++ b/storage/connect/tabmysql.h @@ -69,6 +69,7 @@ class MYSQLDEF : public EXTDEF {/* Logical table description */ /***********************************************************************/ class TDBMYSQL : public TDBEXT { friend class MYSQLCOL; + friend class TDBTBM; public: // Constructor TDBMYSQL(PMYDEF tdp); diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index b567e9aecd4..bb7eae9c256 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -578,10 +578,19 @@ pthread_handler_t ThreadOpen(void *p) // Try to open the connection if (!cmp->Tap->GetTo_Tdb()->OpenDB(cmp->G)) { pthread_mutex_lock(&tblmut); + if (trace) + htrc("Table %s ready\n", cmp->Tap->GetName()); + cmp->Ready = true; pthread_mutex_unlock(&tblmut); - } else - cmp->Rc = RC_FX; + } else { + pthread_mutex_lock(&tblmut); + if (trace) + htrc("Opening %s failed\n", cmp->Tap->GetName()); + + cmp->Rc = RC_FX; + pthread_mutex_unlock(&tblmut); + } // endif OpenDB my_thread_end(); } else @@ -633,6 +642,18 @@ int TDBTBM::RowNumber(PGLOBAL g, bool b) } // end of RowNumber /***********************************************************************/ +/* Returns true if this MYSQL table refers to a local table. */ +/***********************************************************************/ +bool TDBTBM::IsLocal(PTABLE tbp) +{ + TDBMYSQL *tdbp = (TDBMYSQL*)tbp->GetTo_Tdb(); + + return ((!stricmp(tdbp->Host, "localhost") || + !strcmp(tdbp->Host, "127.0.0.1")) && + tdbp->Port == GetDefaultPort()); +} // end of IsLocal + +/***********************************************************************/ /* Initialyze table parallel processing. */ /***********************************************************************/ bool TDBTBM::OpenTables(PGLOBAL g) @@ -644,10 +665,13 @@ bool TDBTBM::OpenTables(PGLOBAL g) // Allocates the TBMT blocks for the tables for (tabp = Tablist; tabp; tabp = tabp->Next) - if (tabp->GetTo_Tdb()->GetAmType() == TYPE_AM_MYSQL) { + if (tabp->GetTo_Tdb()->GetAmType() == TYPE_AM_MYSQL && !IsLocal(tabp)) { // Remove remote table from the local list *ptabp = tabp->Next; + if (trace) + htrc("=====> New remote table %s\n", tabp->GetName()); + // Make the remote table block tp = (PTBMT)PlugSubAlloc(g, NULL, sizeof(TBMT)); memset(tp, 0, sizeof(TBMT)); @@ -671,7 +695,10 @@ bool TDBTBM::OpenTables(PGLOBAL g) ptp = &tp->Next; Nrc++; // Number of remote connections } else { - ptabp = &tabp->Next; + if (trace) + htrc("=====> Local table %s\n", tabp->GetName()); + + ptabp = &tabp->Next; Nlc++; // Number of local connections } // endif Type @@ -788,7 +815,7 @@ int TDBTBM::ReadDB(PGLOBAL g) /***********************************************************************/ int TDBTBM::ReadNextRemote(PGLOBAL g) { - bool b = false; + bool b; if (Tdbp) Tdbp->CloseDB(g); @@ -796,17 +823,22 @@ int TDBTBM::ReadNextRemote(PGLOBAL g) Cmp = NULL; retry: - // Search for a remote table having its result set + b = false; + + // Search for a remote table having its result set pthread_mutex_lock(&tblmut); for (PTBMT tp = Tmp; tp; tp = tp->Next) - if (tp->Ready) { - if (!tp->Complete) { - Cmp = tp; - break; - } // endif Complete + if (tp->Rc != RC_FX) { + if (tp->Ready) { + if (!tp->Complete) { + Cmp = tp; + break; + } // endif Complete - } else - b = true; + } else + b = true; + + } // endif Rc pthread_mutex_unlock(&tblmut); diff --git a/storage/connect/tabtbl.h b/storage/connect/tabtbl.h index 3a5ec45d025..f02bf620aae 100644 --- a/storage/connect/tabtbl.h +++ b/storage/connect/tabtbl.h @@ -146,6 +146,7 @@ class DllExport TDBTBM : public TDBTBL { protected: // Internal functions + bool IsLocal(PTABLE tbp); bool OpenTables(PGLOBAL g); int ReadNextRemote(PGLOBAL g); diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 574cef28ea3..a2c04e2cf62 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -186,7 +186,8 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, crp->Kdata->SetValue(colname, i); chset = (char *)fp->charset()->name; - v = (!strcmp(chset, "binary")) ? 'B' : 0; +// v = (!strcmp(chset, "binary")) ? 'B' : 0; + v = 0; if ((type = MYSQLtoPLG(fp->type(), &v)) == TYPE_ERROR) { if (v == 'K') { diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp index 5b98f3eb425..018c7ee3fe1 100644 --- a/storage/connect/valblk.cpp +++ b/storage/connect/valblk.cpp @@ -59,11 +59,12 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len, switch (type) { case TYPE_STRING: + case TYPE_BIN: case TYPE_DECIM: if (len) - blkp = new(g) CHRBLK(mp, nval, len, prec, blank); + blkp = new(g) CHRBLK(mp, nval, type, len, prec, blank); else - blkp = new(g) STRBLK(g, mp, nval); + blkp = new(g) STRBLK(g, mp, nval, type); break; case TYPE_SHORT: @@ -615,8 +616,8 @@ int TYPBLK<TYPE>::GetMaxLength(void) /***********************************************************************/ /* Constructor. */ /***********************************************************************/ -CHRBLK::CHRBLK(void *mp, int nval, int len, int prec, bool blank) - : VALBLK(mp, TYPE_STRING, nval), Chrp((char*&)Blkp) +CHRBLK::CHRBLK(void *mp, int nval, int type, int len, int prec, bool blank) + : VALBLK(mp, type, nval), Chrp((char*&)Blkp) { Valp = NULL; Blanks = blank; @@ -1008,8 +1009,8 @@ int CHRBLK::GetMaxLength(void) /***********************************************************************/ /* Constructor. */ /***********************************************************************/ -STRBLK::STRBLK(PGLOBAL g, void *mp, int nval) - : VALBLK(mp, TYPE_STRING, nval), Strp((PSZ*&)Blkp) +STRBLK::STRBLK(PGLOBAL g, void *mp, int nval, int type) + : VALBLK(mp, type, nval), Strp((PSZ*&)Blkp) { Global = g; Nullable = true; diff --git a/storage/connect/valblk.h b/storage/connect/valblk.h index 38a73424985..a3d7bf30fcf 100644 --- a/storage/connect/valblk.h +++ b/storage/connect/valblk.h @@ -214,7 +214,7 @@ class TYPBLK : public VALBLK { class CHRBLK : public VALBLK { public: // Constructors - CHRBLK(void *mp, int size, int len, int prec, bool b); + CHRBLK(void *mp, int size, int type, int len, int prec, bool b); // Implementation virtual bool Init(PGLOBAL g, bool check); @@ -267,7 +267,7 @@ class CHRBLK : public VALBLK { class STRBLK : public VALBLK { public: // Constructors - STRBLK(PGLOBAL g, void *mp, int size); + STRBLK(PGLOBAL g, void *mp, int size, int type); // Implementation virtual void SetNull(int n, bool b) {if (b) {Strp[n] = NULL;}} @@ -345,7 +345,7 @@ class PTRBLK : public STRBLK { bool, bool, bool); protected: // Constructors - PTRBLK(PGLOBAL g, void *mp, int size) : STRBLK(g, mp, size) {} + PTRBLK(PGLOBAL g, void *mp, int size) : STRBLK(g, mp, size, TYPE_PCHAR) {} // Implementation diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index 60d1c2f459c..a80da808548 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -176,7 +176,7 @@ int GetTypeSize(int type, int len) case TYPE_DOUBLE: len = sizeof(double); break; case TYPE_TINY: len = sizeof(char); break; case TYPE_PCHAR: len = sizeof(char*); break; - default: len = 0; + default: len = -1; } // endswitch type return len; @@ -236,6 +236,7 @@ bool IsTypeChar(int type) switch (type) { case TYPE_STRING: case TYPE_DECIM: + case TYPE_BIN: return true; } // endswitch type @@ -1369,7 +1370,7 @@ bool TYPVAL<PSZ>::SetValue_char(const char *cp, int n) if (!cp || n == 0) { Reset(); - Null = Nullable; + Null = (cp) ? false : Nullable; } else if (cp != Strp) { const char *p = cp + n - 1; @@ -1858,8 +1859,9 @@ int DECVAL::CompareValue(PVAL vp) BINVAL::BINVAL(PGLOBAL g, void *p, int cl, int n) : VALUE(TYPE_BIN) { assert(g); - Len = n; - Clen = cl; +//Len = n; + Len = (g) ? n : (p) ? strlen((char*)p) : 0; + Clen = cl; Binp = PlugSubAlloc(g, NULL, Clen + 1); memset(Binp, 0, Clen + 1); @@ -1992,10 +1994,15 @@ bool BINVAL::SetValue_pval(PVAL valp, bool chktype) return true; if (!(Null = valp->IsNull() && Nullable)) { - if ((rc = (Len = valp->GetSize()) > Clen)) + int len = Len; + + if ((rc = (Len = valp->GetSize()) > Clen)) Len = Clen; + else if (len > Len) + memset(Binp, 0, len); memcpy(Binp, valp->GetTo_Val(), Len); + ((char*)Binp)[Len] = 0; } else Reset(); @@ -2012,10 +2019,15 @@ bool BINVAL::SetValue_char(const char *p, int n) bool rc; if (p && n > 0) { - rc = n > Clen; - Len = MY_MIN(n, Clen); - memcpy(Binp, p, Len); - Null = false; + int len = Len; + + if (len > (Len = MY_MIN(n, Clen))) + memset(Binp, 0, len); + + memcpy(Binp, p, Len); + ((char*)Binp)[Len] = 0; + rc = n > Clen; + Null = false; } else { rc = false; Reset(); @@ -2031,9 +2043,14 @@ bool BINVAL::SetValue_char(const char *p, int n) void BINVAL::SetValue_psz(PCSZ s) { if (s) { - Len = MY_MIN(Clen, (signed)strlen(s)); - memcpy(Binp, s, Len); - Null = false; + int len = Len; + + if (len > (Len = MY_MIN(Clen, (signed)strlen(s)))) + memset(Binp, 0, len); + + memcpy(Binp, s, Len); + ((char*)Binp)[Len] = 0; + Null = false; } else { Reset(); Null = Nullable; @@ -2053,14 +2070,19 @@ void BINVAL::SetValue_pvblk(PVBLK blk, int n) Reset(); Null = Nullable; } else if (vp != Binp) { + int len = Len; + if (blk->GetType() == TYPE_STRING) Len = strlen((char*)vp); else Len = blk->GetVlen(); - Len = MY_MIN(Clen, Len); + if (len > (Len = MY_MIN(Clen, Len))) + memset(Binp, 0, len); + memcpy(Binp, vp, Len); - Null = false; + ((char*)Binp)[Len] = 0; + Null = false; } // endif vp } // end of SetValue_pvblk @@ -2071,7 +2093,10 @@ void BINVAL::SetValue_pvblk(PVBLK blk, int n) void BINVAL::SetValue(int n) { if (Clen >= 4) { - *((int*)Binp) = n; + if (Len > 4) + memset(Binp, 0, Len); + + *((int*)Binp) = n; Len = 4; } else SetValue((short)n); @@ -2084,7 +2109,10 @@ void BINVAL::SetValue(int n) void BINVAL::SetValue(uint n) { if (Clen >= 4) { - *((uint*)Binp) = n; + if (Len > 4) + memset(Binp, 0, Len); + + *((uint*)Binp) = n; Len = 4; } else SetValue((ushort)n); @@ -2097,7 +2125,10 @@ void BINVAL::SetValue(uint n) void BINVAL::SetValue(short i) { if (Clen >= 2) { - *((int*)Binp) = i; + if (Len > 2) + memset(Binp, 0, Len); + + *((int*)Binp) = i; Len = 2; } else SetValue((char)i); @@ -2110,7 +2141,10 @@ void BINVAL::SetValue(short i) void BINVAL::SetValue(ushort i) { if (Clen >= 2) { - *((uint*)Binp) = i; + if (Len > 2) + memset(Binp, 0, Len); + + *((uint*)Binp) = i; Len = 2; } else SetValue((uchar)i); @@ -2123,7 +2157,10 @@ void BINVAL::SetValue(ushort i) void BINVAL::SetValue(longlong n) { if (Clen >= 8) { - *((longlong*)Binp) = n; + if (Len > 8) + memset(Binp, 0, Len); + + *((longlong*)Binp) = n; Len = 8; } else SetValue((int)n); @@ -2136,7 +2173,10 @@ void BINVAL::SetValue(longlong n) void BINVAL::SetValue(ulonglong n) { if (Clen >= 8) { - *((ulonglong*)Binp) = n; + if (Len > 8) + memset(Binp, 0, Len); + + *((ulonglong*)Binp) = n; Len = 8; } else SetValue((uint)n); @@ -2147,6 +2187,9 @@ void BINVAL::SetValue(ulonglong n) /***********************************************************************/ void BINVAL::SetValue(double n) { + if (Len > 8) + memset(Binp, 0, Len); + if (Clen >= 8) { *((double*)Binp) = n; Len = 8; @@ -2163,7 +2206,10 @@ void BINVAL::SetValue(double n) /***********************************************************************/ void BINVAL::SetValue(char c) { - *((char*)Binp) = c; + if (Len > 1) + memset(Binp, 0, Len); + + *((char*)Binp) = c; Len = 1; } // end of SetValue @@ -2172,7 +2218,10 @@ void BINVAL::SetValue(char c) /***********************************************************************/ void BINVAL::SetValue(uchar c) { - *((uchar*)Binp) = c; + if (Len > 1) + memset(Binp, 0, Len); + + *((uchar*)Binp) = c; Len = 1; } // end of SetValue @@ -2182,6 +2231,7 @@ void BINVAL::SetValue(uchar c) void BINVAL::SetBinValue(void *p) { memcpy(Binp, p, Clen); + Len = Clen; } // end of SetBinValue /***********************************************************************/ @@ -2207,10 +2257,11 @@ bool BINVAL::GetBinValue(void *buf, int buflen, bool go) /***********************************************************************/ char *BINVAL::ShowValue(char *buf, int len) { - int n = MY_MIN(Len, len / 2); + //int n = MY_MIN(Len, len / 2); - sprintf(buf, GetXfmt(), n, Binp); - return buf; + //sprintf(buf, GetXfmt(), n, Binp); + //return buf; + return (char*)Binp; } // end of ShowValue /***********************************************************************/ |