Skip to content

Commit

Permalink
- Fix MDEV-13621 JDBC UPDATE containing single or double quote chars …
Browse files Browse the repository at this point in the history
…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
  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/mysql-test/connect/r/updelx.result

- Add the GetCsName function
  modified:   storage/connect/reldef.h
  • Loading branch information
Buggynours committed Aug 27, 2017
1 parent 5f83a9b commit 5b998bf
Show file tree
Hide file tree
Showing 13 changed files with 484 additions and 309 deletions.
21 changes: 16 additions & 5 deletions storage/connect/ha_connect.cc
Expand Up @@ -1285,9 +1285,14 @@ 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;
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")) {
const CHARSET_INFO *chif= (tshp) ? tshp->table_charset
Expand Down Expand Up @@ -1501,8 +1506,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")) {
Expand Down Expand Up @@ -2114,6 +2120,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;
Expand Down
5 changes: 3 additions & 2 deletions storage/connect/myconn.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
64 changes: 61 additions & 3 deletions storage/connect/mysql-test/connect/r/tbl_thread.result
Expand Up @@ -28,6 +28,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
CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL
CONNECTION='mysql://root@127.0.0.1:MASTER_PORT/test/rt2';
SELECT * FROM t2;
Expand All @@ -44,11 +60,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
Expand All @@ -62,8 +102,8 @@ a b
1 test01
0 test00
DROP TABLE rt2;
DROP TABLE rt3;
DROP TABLE t1,t2,t3,total;
DROP TABLE rt3,rt4,rt5;
DROP TABLE t1,t2,t3,t4,t5,total;
#
# Old thread TBL tables test modified
#
Expand All @@ -84,6 +124,24 @@ 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';;
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;
DROP TABLE IF EXISTS connect.t1;
DROP DATABASE IF EXISTS connect;
DROP TABLE IF EXISTS connect.t1;
Expand Down

0 comments on commit 5b998bf

Please sign in to comment.