Commit 74009534 authored by Olivier Bertrand's avatar Olivier Bertrand

- Possibly fix MDEV-10179 Reset remote tables when re-opening

  modified:   storage/connect/tabtbl.cpp

- Add trace and make m_Stmt conditional
  modified:   storage/connect/myconn.cpp
  modified:   storage/connect/myconn.h

- Protect trace from null string (for Linux)
  modified:   storage/connect/tabcol.cpp

- Record error changes
  modified:   storage/connect/mysql-test/connect/r/jdbc_new.result

- Typo
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/jsonudf.cpp
parent 613680a0
......@@ -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. */
......
/****************** 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 . */
/*********************************************************************************/
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment