summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2017-08-26 11:02:53 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2017-08-26 11:02:53 +0200
commit614611d7c09dc3866078c46c6685ec34f33c8443 (patch)
tree00872e86cba07dd1bdde655a75ca3f8010d89251
parent2db52e1704af53ae2c0f421f82a8b8cb26128dfc (diff)
downloadmariadb-git-614611d7c09dc3866078c46c6685ec34f33c8443.tar.gz
- Fix MDEV-13621 JDBC UPDATE containing single or double quote chars produces wrong result
in ha_connect::GetStringOption modified: storage/connect/ha_connect.cc - Begin implement data type BINARY modified: storage/connect/ha_connect.cc modified: storage/connect/myutil.cpp modified: storage/connect/valblk.cpp modified: storage/connect/valblk.h modified: storage/connect/value.cpp - Fix MDEV-12422 CONNECT Engine to support CHECK TABLE Adding a fake check function returning HA_ADMIN_OK. modified: storage/connect/ha_connect.h - Treat TBL (thread) as local when connected to the current server and return by timeout when a TBL remote table connection fail (Thread only) modified: storage/connect/myconn.cpp modified: storage/connect/tabmysql.h modified: storage/connect/tabtbl.cpp modified: storage/connect/tabtbl.h - Update some tests and result files modified: storage/connect/mysql-test/connect/r/tbl_thread.result modified: storage/connect/mysql-test/connect/t/tbl_thread.test modified: storage/connect/mysql-test/connect/r/updelx.result - Add the GetCsName function modified: storage/connect/reldef.h
-rw-r--r--storage/connect/ha_connect.cc22
-rw-r--r--storage/connect/ha_connect.h7
-rw-r--r--storage/connect/myconn.cpp5
-rw-r--r--storage/connect/mysql-test/connect/r/tbl_thread.result62
-rw-r--r--storage/connect/mysql-test/connect/r/updelx.result474
-rw-r--r--storage/connect/mysql-test/connect/t/tbl_thread.test46
-rw-r--r--storage/connect/myutil.cpp4
-rw-r--r--storage/connect/reldef.h1
-rw-r--r--storage/connect/tabmysql.h1
-rw-r--r--storage/connect/tabtbl.cpp50
-rw-r--r--storage/connect/tabtbl.h1
-rw-r--r--storage/connect/valblk.cpp13
-rw-r--r--storage/connect/valblk.h6
-rw-r--r--storage/connect/value.cpp97
14 files changed, 481 insertions, 308 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index ab718878da9..8adfc34548b 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -1285,9 +1285,15 @@ 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;
+ 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;
+ } else if (!stricmp(opname, "Partname"))
opval= partname;
else if (!stricmp(opname, "Table_charset")) {
const CHARSET_INFO *chif= (tshp) ? tshp->table_charset
@@ -1501,8 +1507,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 +2121,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;
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/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/tbl_thread.result b/storage/connect/mysql-test/connect/r/tbl_thread.result
index 12e90ad5580..97f454720da 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,35 @@ 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';
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
@@ -72,9 +112,9 @@ a b
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
#
@@ -95,6 +135,22 @@ DROP TABLE t1,t2,total;
#
# 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;
+v
+11
+CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 22 as v';
+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';;
+SELECT * FROM total order by v desc;
+v
+22
+11
+DROP TABLE total;
+DROP TABLE t1;
+DROP TABLE t2;
connection master;
DROP TABLE IF EXISTS connect.t1;
DROP DATABASE IF EXISTS connect;
diff --git a/storage/connect/mysql-test/connect/r/updelx.result b/storage/connect/mysql-test/connect/r/updelx.result
index 2aed1e06928..4b8441a6cde 100644
--- a/storage/connect/mysql-test/connect/r/updelx.result
+++ b/storage/connect/mysql-test/connect/r/updelx.result
@@ -986,108 +986,108 @@ DELETE FROM t1;
INSERT INTO t1 VALUES(4, 'four'),(7,'seven'),(10,'ten'),(40,'forty'),(60,'sixty'),(81,'eighty one'),(72,'seventy two'),(11,'eleven'),(1,'one'),(35,'thirty five'),(8,'eight');
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 sixty
-81 eighty one
-72 seventy two
-11 eleven
-1 one
-35 thirty five
-8 eight
+4 four
+7 seven
+10 ten
+40 forty
+60 sixty
+81 eighty one
+72 seventy two
+11 eleven
+1 one
+35 thirty five
+8 eight
UPDATE t1 SET msg = 'bof' WHERE id = 35;
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 sixty
-81 eighty one
-72 seventy two
-11 eleven
-1 one
-35 bof
-8 eight
+4 four
+7 seven
+10 ten
+40 forty
+60 sixty
+81 eighty one
+72 seventy two
+11 eleven
+1 one
+35 bof
+8 eight
UPDATE t1 SET msg = 'big' WHERE id > 50;
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 big
-81 big
-72 big
-11 eleven
-1 one
-35 bof
-8 eight
+4 four
+7 seven
+10 ten
+40 forty
+60 big
+81 big
+72 big
+11 eleven
+1 one
+35 bof
+8 eight
UPDATE t1 SET msg = 'updated' WHERE id IN (8,35,60,72);
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 updated
-81 big
-72 updated
-11 eleven
-1 one
-35 updated
-8 updated
+4 four
+7 seven
+10 ten
+40 forty
+60 updated
+81 big
+72 updated
+11 eleven
+1 one
+35 updated
+8 updated
UPDATE t1 SET msg = 'twin' WHERE id IN (81,10);
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 twin
-40 forty
-60 updated
-81 twin
-72 updated
-11 eleven
-1 one
-35 updated
-8 updated
+4 four
+7 seven
+10 twin
+40 forty
+60 updated
+81 twin
+72 updated
+11 eleven
+1 one
+35 updated
+8 updated
UPDATE t1 SET msg = 'sixty' WHERE id = 60;
SELECT * FROM t1 WHERE id = 60;
id msg
-60 sixty
+60 sixty
DELETE FROM t1 WHERE id = 4;
SELECT * FROM t1;
id msg
-7 seven
-10 twin
-40 forty
-60 sixty
-81 twin
-72 updated
-11 eleven
-1 one
-35 updated
-8 updated
+7 seven
+10 twin
+40 forty
+60 sixty
+81 twin
+72 updated
+11 eleven
+1 one
+35 updated
+8 updated
DELETE FROM t1 WHERE id IN (40,11,35);
SELECT * FROM t1;
id msg
-7 seven
-10 twin
-60 sixty
-81 twin
-72 updated
-1 one
-8 updated
+7 seven
+10 twin
+60 sixty
+81 twin
+72 updated
+1 one
+8 updated
DELETE FROM t1 WHERE id IN (4,60,1);
SELECT msg FROM t1;
msg
-seven
-twin
-twin
-updated
-updated
+seven
+twin
+twin
+updated
+updated
DELETE FROM t1 WHERE id IN (81,72);
SELECT id FROM t1;
id
@@ -1097,7 +1097,7 @@ id
DELETE FROM t1 WHERE id IN (7,10);
SELECT * FROM t1;
id msg
-8 updated
+8 updated
DELETE FROM t1 WHERE id = 8;
SELECT * FROM t1;
id msg
@@ -1106,108 +1106,108 @@ DELETE FROM t1;
INSERT INTO t1 VALUES(4, 'four'),(7,'seven'),(10,'ten'),(40,'forty'),(60,'sixty'),(81,'eighty one'),(72,'seventy two'),(11,'eleven'),(1,'one'),(35,'thirty five'),(8,'eight');
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 sixty
-81 eighty one
-72 seventy two
-11 eleven
-1 one
-35 thirty five
-8 eight
+4 four
+7 seven
+10 ten
+40 forty
+60 sixty
+81 eighty one
+72 seventy two
+11 eleven
+1 one
+35 thirty five
+8 eight
UPDATE t1 SET msg = 'bof' WHERE id = 35;
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 sixty
-81 eighty one
-72 seventy two
-11 eleven
-1 one
-35 bof
-8 eight
+4 four
+7 seven
+10 ten
+40 forty
+60 sixty
+81 eighty one
+72 seventy two
+11 eleven
+1 one
+35 bof
+8 eight
UPDATE t1 SET msg = 'big' WHERE id > 50;
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 big
-81 big
-72 big
-11 eleven
-1 one
-35 bof
-8 eight
+4 four
+7 seven
+10 ten
+40 forty
+60 big
+81 big
+72 big
+11 eleven
+1 one
+35 bof
+8 eight
UPDATE t1 SET msg = 'updated' WHERE id IN (8,35,60,72);
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 updated
-81 big
-72 updated
-11 eleven
-1 one
-35 updated
-8 updated
+4 four
+7 seven
+10 ten
+40 forty
+60 updated
+81 big
+72 updated
+11 eleven
+1 one
+35 updated
+8 updated
UPDATE t1 SET msg = 'twin' WHERE id IN (81,10);
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 twin
-40 forty
-60 updated
-81 twin
-72 updated
-11 eleven
-1 one
-35 updated
-8 updated
+4 four
+7 seven
+10 twin
+40 forty
+60 updated
+81 twin
+72 updated
+11 eleven
+1 one
+35 updated
+8 updated
UPDATE t1 SET msg = 'sixty' WHERE id = 60;
SELECT * FROM t1 WHERE id = 60;
id msg
-60 sixty
+60 sixty
DELETE FROM t1 WHERE id = 4;
SELECT * FROM t1;
id msg
-7 seven
-10 twin
-40 forty
-60 sixty
-81 twin
-72 updated
-11 eleven
-1 one
-35 updated
-8 updated
+7 seven
+10 twin
+40 forty
+60 sixty
+81 twin
+72 updated
+11 eleven
+1 one
+35 updated
+8 updated
DELETE FROM t1 WHERE id IN (40,11,35);
SELECT * FROM t1;
id msg
-7 seven
-10 twin
-60 sixty
-81 twin
-72 updated
-1 one
-8 updated
+7 seven
+10 twin
+60 sixty
+81 twin
+72 updated
+1 one
+8 updated
DELETE FROM t1 WHERE id IN (4,60,1);
SELECT msg FROM t1;
msg
-seven
-twin
-twin
-updated
-updated
+seven
+twin
+twin
+updated
+updated
DELETE FROM t1 WHERE id IN (81,72);
SELECT id FROM t1;
id
@@ -1217,7 +1217,7 @@ id
DELETE FROM t1 WHERE id IN (7,10);
SELECT * FROM t1;
id msg
-8 updated
+8 updated
DELETE FROM t1 WHERE id = 8;
SELECT * FROM t1;
id msg
@@ -1226,108 +1226,108 @@ DELETE FROM t1;
INSERT INTO t1 VALUES(4, 'four'),(7,'seven'),(10,'ten'),(40,'forty'),(60,'sixty'),(81,'eighty one'),(72,'seventy two'),(11,'eleven'),(1,'one'),(35,'thirty five'),(8,'eight');
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 sixty
-81 eighty one
-72 seventy two
-11 eleven
-1 one
-35 thirty five
-8 eight
+4 four
+7 seven
+10 ten
+40 forty
+60 sixty
+81 eighty one
+72 seventy two
+11 eleven
+1 one
+35 thirty five
+8 eight
UPDATE t1 SET msg = 'bof' WHERE id = 35;
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 sixty
-81 eighty one
-72 seventy two
-11 eleven
-1 one
-35 bof
-8 eight
+4 four
+7 seven
+10 ten
+40 forty
+60 sixty
+81 eighty one
+72 seventy two
+11 eleven
+1 one
+35 bof
+8 eight
UPDATE t1 SET msg = 'big' WHERE id > 50;
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 big
-81 big
-72 big
-11 eleven
-1 one
-35 bof
-8 eight
+4 four
+7 seven
+10 ten
+40 forty
+60 big
+81 big
+72 big
+11 eleven
+1 one
+35 bof
+8 eight
UPDATE t1 SET msg = 'updated' WHERE id IN (8,35,60,72);
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 ten
-40 forty
-60 updated
-81 big
-72 updated
-11 eleven
-1 one
-35 updated
-8 updated
+4 four
+7 seven
+10 ten
+40 forty
+60 updated
+81 big
+72 updated
+11 eleven
+1 one
+35 updated
+8 updated
UPDATE t1 SET msg = 'twin' WHERE id IN (81,10);
SELECT * FROM t1;
id msg
-4 four
-7 seven
-10 twin
-40 forty
-60 updated
-81 twin
-72 updated
-11 eleven
-1 one
-35 updated
-8 updated
+4 four
+7 seven
+10 twin
+40 forty
+60 updated
+81 twin
+72 updated
+11 eleven
+1 one
+35 updated
+8 updated
UPDATE t1 SET msg = 'sixty' WHERE id = 60;
SELECT * FROM t1 WHERE id = 60;
id msg
-60 sixty
+60 sixty
DELETE FROM t1 WHERE id = 4;
SELECT * FROM t1;
id msg
-7 seven
-10 twin
-40 forty
-60 sixty
-81 twin
-72 updated
-11 eleven
-1 one
-35 updated
-8 updated
+7 seven
+10 twin
+40 forty
+60 sixty
+81 twin
+72 updated
+11 eleven
+1 one
+35 updated
+8 updated
DELETE FROM t1 WHERE id IN (40,11,35);
SELECT * FROM t1;
id msg
-7 seven
-10 twin
-60 sixty
-81 twin
-72 updated
-1 one
-8 updated
+7 seven
+10 twin
+60 sixty
+81 twin
+72 updated
+1 one
+8 updated
DELETE FROM t1 WHERE id IN (4,60,1);
SELECT msg FROM t1;
msg
-seven
-twin
-twin
-updated
-updated
+seven
+twin
+twin
+updated
+updated
DELETE FROM t1 WHERE id IN (81,72);
SELECT id FROM t1;
id
@@ -1337,7 +1337,7 @@ id
DELETE FROM t1 WHERE id IN (7,10);
SELECT * FROM t1;
id msg
-8 updated
+8 updated
DELETE FROM t1 WHERE id = 8;
SELECT * FROM t1;
id msg
diff --git a/storage/connect/mysql-test/connect/t/tbl_thread.test b/storage/connect/mysql-test/connect/t/tbl_thread.test
index 0b919f88cd5..914d23d67fe 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,9 +42,19 @@ 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';
SELECT * FROM total order by a desc;
@@ -48,11 +64,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
@@ -73,18 +89,18 @@ DROP TABLE t1,t2,total;
--echo #
--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;
+CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 11 as v';
+SELECT * FROM t1;
-#CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 22 as v';
-#SELECT * FROM t2;
+CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 22 as v';
+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';
-#SELECT * FROM total order by v desc;
+--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';
+SELECT * FROM total order by v desc;
-#DROP TABLE total;
-#DROP TABLE t1;
-#DROP TABLE t2;
+DROP TABLE total;
+DROP TABLE t1;
+DROP TABLE t2;
-- source myconn_cleanup.inc
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.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/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..a2b041b64d8 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,7 +665,7 @@ 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;
@@ -788,7 +809,7 @@ int TDBTBM::ReadDB(PGLOBAL g)
/***********************************************************************/
int TDBTBM::ReadNextRemote(PGLOBAL g)
{
- bool b = false;
+ bool b;
if (Tdbp)
Tdbp->CloseDB(g);
@@ -796,17 +817,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/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 11298355d9d..51c422389ca 100644
--- a/storage/connect/value.cpp
+++ b/storage/connect/value.cpp
@@ -236,6 +236,7 @@ bool IsTypeChar(int type)
switch (type) {
case TYPE_STRING:
case TYPE_DECIM:
+ case TYPE_BIN:
return true;
} // endswitch type
@@ -1857,8 +1858,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);
@@ -1991,10 +1993,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();
@@ -2011,10 +2018,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();
@@ -2030,9 +2042,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;
@@ -2052,14 +2069,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
@@ -2070,7 +2092,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);
@@ -2083,7 +2108,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);
@@ -2096,7 +2124,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);
@@ -2109,7 +2140,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);
@@ -2122,7 +2156,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);
@@ -2135,7 +2172,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);
@@ -2146,6 +2186,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;
@@ -2162,7 +2205,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
@@ -2171,7 +2217,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
@@ -2181,6 +2230,7 @@ void BINVAL::SetValue(uchar c)
void BINVAL::SetBinValue(void *p)
{
memcpy(Binp, p, Clen);
+ Len = Clen;
} // end of SetBinValue
/***********************************************************************/
@@ -2206,10 +2256,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
/***********************************************************************/