diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 8adfc34548b..ef46750bcca 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -1288,11 +1288,10 @@ PCSZ ha_connect::GetStringOption(PCSZ opname, PCSZ sdef) } else if (!stricmp(opname, "Query_String")) { // This escapes everything and returns a wrong query // opval = thd_query_string(table->in_use)->str; - size_t len = thd_query_string(table->in_use)->length; - - opval = (PCSZ)PlugSubAlloc(xp->g, NULL, len + 1); - sprintf((char*)opval, "%s", thd_query_string(table->in_use)->str); - ((char*)opval)[len] = 0; + 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")) { diff --git a/storage/connect/mysql-test/connect/r/tbl_thread.result b/storage/connect/mysql-test/connect/r/tbl_thread.result index 97f454720da..97787850361 100644 --- a/storage/connect/mysql-test/connect/r/tbl_thread.result +++ b/storage/connect/mysql-test/connect/r/tbl_thread.result @@ -144,10 +144,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/t/tbl_thread.test b/storage/connect/mysql-test/connect/t/tbl_thread.test index 914d23d67fe..3376a121c5c 100644 --- a/storage/connect/mysql-test/connect/t/tbl_thread.test +++ b/storage/connect/mysql-test/connect/t/tbl_thread.test @@ -97,7 +97,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/tabtbl.cpp b/storage/connect/tabtbl.cpp index a2b041b64d8..bb7eae9c256 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -669,6 +669,9 @@ bool TDBTBM::OpenTables(PGLOBAL g) // 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)); @@ -692,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