diff --git a/storage/connect/jdbconn.cpp b/storage/connect/jdbconn.cpp index 7a508cd989b..a8c0b193dcd 100644 --- a/storage/connect/jdbconn.cpp +++ b/storage/connect/jdbconn.cpp @@ -2081,7 +2081,7 @@ bool JDBConn::SetParam(JDBCCOL *colp) if (!m_Rows) { strcpy(g->Message, "Void result"); return NULL; - } // endif m_Res + } // endif m_Rows /*********************************************************************/ /* Allocate the result storage for future retrieval. */ diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 0bc964d7351..e94d3817926 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -1,6 +1,6 @@ /****************** jsonudf C++ Program Source Code File (.CPP) ******************/ -/* PROGRAM NAME: jsonudf Version 1.3 */ -/* (C) Copyright to the author Olivier BERTRAND 2015 */ +/* PROGRAM NAME: jsonudf Version 1.4 */ +/* (C) Copyright to the author Olivier BERTRAND 2015-2016 */ /* This program are the JSON User Defined Functions . */ /*********************************************************************************/ diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index b844d68e1cd..644ca019e4a 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2007-2015 */ +/* (C) Copyright to the author Olivier BERTRAND 2007-2016 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -401,8 +401,10 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db, MYSQLC::MYSQLC(void) { m_DB = NULL; - m_Stmt = NULL; - m_Res = NULL; +#if defined (MYSQL_PREPARED_STATEMENTS) + m_Stmt = NULL; +#endif // MYSQL_PREPARED_STATEMENTS + m_Res = NULL; m_Rows = -1; m_Row = NULL; m_Fields = -1; @@ -444,7 +446,10 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, return RC_FX; } // endif m_DB - // Removed to do like FEDERATED do + if (trace) + htrc("MYSQLC Open: m_DB=%.4X size=%d\n", m_DB, (int)sizeof(*m_DB)); + + // Removed to do like FEDERATED do //mysql_options(m_DB, MYSQL_READ_DEFAULT_GROUP, "client-mariadb"); mysql_options(m_DB, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL); mysql_options(m_DB, MYSQL_OPT_CONNECT_TIMEOUT, &cto); @@ -701,6 +706,11 @@ int MYSQLC::ExecSQL(PGLOBAL g, const char *query, int *w) } else { m_Fields = mysql_num_fields(m_Res); m_Rows = (!m_Use) ? (int)mysql_num_rows(m_Res) : 0; + + if (trace) + htrc("ExecSQL: m_Res=%.4X size=%d m_Fields=%d m_Rows=%d\n", + m_Res, sizeof(*m_Res), m_Fields, m_Rows); + } // endif m_Res } else { @@ -1017,7 +1027,11 @@ int MYSQLC::ExecSQLcmd(PGLOBAL g, const char *query, int *w) void MYSQLC::Close(void) { FreeResult(); - mysql_close(m_DB); + + if (trace) + htrc("MYSQLC Close: m_DB=%.4X\n", m_DB); + + mysql_close(m_DB); m_DB = NULL; } // end of Close diff --git a/storage/connect/myconn.h b/storage/connect/myconn.h index 79f095f5c93..9ebd37527a6 100644 --- a/storage/connect/myconn.h +++ b/storage/connect/myconn.h @@ -90,8 +90,10 @@ class DllItem MYSQLC { // Members MYSQL *m_DB; // The return from MySQL connection - MYSQL_STMT *m_Stmt; // Prepared statement handle - MYSQL_RES *m_Res; // Points to MySQL Result +#if defined (MYSQL_PREPARED_STATEMENTS) + MYSQL_STMT *m_Stmt; // Prepared statement handle +#endif // MYSQL_PREPARED_STATEMENTS + MYSQL_RES *m_Res; // Points to MySQL Result MYSQL_ROW m_Row; // Point to current row int m_Rows; // The number of rows of the result int N; diff --git a/storage/connect/mysql-test/connect/r/jdbc_new.result b/storage/connect/mysql-test/connect/r/jdbc_new.result index 794ab050f05..e5356edd5d8 100644 --- a/storage/connect/mysql-test/connect/r/jdbc_new.result +++ b/storage/connect/mysql-test/connect/r/jdbc_new.result @@ -17,7 +17,7 @@ ERROR HY000: Got error 174 'Connecting: java.sql.SQLException: Access denied for DROP TABLE t1; CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/unknown?user=root'; -ERROR HY000: Connecting: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'unknown' rc=-2 +ERROR HY000: Connecting: java.sql.SQLSyntaxErrorException: Unknown database 'unknown' rc=-2 CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='unknown' CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root'; ERROR HY000: Cannot get columns from unknown @@ -32,13 +32,15 @@ t1 CREATE TABLE `t1` ( `y` char(10) DEFAULT NULL ) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`=JDBC SELECT * FROM t1; -ERROR HY000: Got error 174 'ExecuteQuery: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'x' in 'field list'' from CONNECT +ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Unknown column 'x' in 'field list' +Query is : SELECT x, y FROM t1' from CONNECT DROP TABLE t1; CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root'; ALTER TABLE t1 RENAME t1backup; SELECT * FROM t1; -ERROR HY000: Got error 174 'ExecuteQuery: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.t1' doesn't exist' from CONNECT +ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Table 'test.t1' doesn't exist +Query is : SELECT a, b FROM t1' from CONNECT ALTER TABLE t1backup RENAME t1; DROP TABLE t1; # @@ -206,7 +208,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`='JDBC' SELECT * FROM t1; a b c d e -2003-05-27 2003-05-27 10:45:23 10:45:23 2003-05-27 10:45:23 2003-01-01 +2003-05-27 2003-05-27 10:45:23 10:45:23 2003-05-27 10:45:23 1970-01-01 DROP TABLE t1; DROP TABLE t1; SET GLOBAL connect_jvm_path=NULL; diff --git a/storage/connect/tabcol.cpp b/storage/connect/tabcol.cpp index 662c0b514cf..fde1baa6317 100644 --- a/storage/connect/tabcol.cpp +++ b/storage/connect/tabcol.cpp @@ -50,7 +50,7 @@ XTAB::XTAB(PTABLE tp) : Name(tp->Name) Qualifier = tp->Qualifier; if (trace) - htrc(" making copy TABLE %s %s\n", Name, Srcdef); + htrc(" making copy TABLE %s %s\n", Name, SVP(Srcdef)); } // end of XTAB constructor diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 36849146746..e3baf7c3da5 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -569,6 +569,9 @@ pthread_handler_t ThreadOpen(void *p) if (!my_thread_init()) { set_current_thd(cmp->Thd); + if (trace) + htrc("ThreadOpen: Thd=%d\n", cmp->Thd); + // Try to open the connection if (!cmp->Tap->GetTo_Tdb()->OpenDB(cmp->G)) { cmp->Ready = true; @@ -604,9 +607,14 @@ void TDBTBM::ResetDB(void) if (colp->GetAmType() == TYPE_AM_TABID) colp->COLBLK::Reset(); + // Local tables for (PTABLE tabp = Tablist; tabp; tabp = tabp->GetNext()) ((PTDBASE)tabp->GetTo_Tdb())->ResetDB(); + // Remote tables + for (PTBMT tp = Tmp; tp; tp = tp->Next) + ((PTDBASE)tp->Tap->GetTo_Tdb())->ResetDB(); + Tdbp = (Tablist) ? (PTDBASE)Tablist->GetTo_Tdb() : NULL; Crp = 0; } // end of ResetDB