Commit 438211a1 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix MDEV-13621 Replace sprintf by strcpy for opval

  modified:   storage/connect/ha_connect.cc

- Add test output to tbl_thread.test tryng to understand failure
  modified:   storage/connect/mysql-test/connect/r/tbl_thread.result
  modified:   storage/connect/mysql-test/connect/t/tbl_thread.test
  modified:   storage/connect/tabtbl.cpp
parent 614611d7
......@@ -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")) {
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
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