Skip to content

Commit 7829cef

Browse files
committed
- Fix MDEV-9603 compiler error.
modified: storage/connect/tabmysql.cpp - Test invalid CSV separator when creating the table (MDEV-9714) modified: storage/connect/ha_connect.cc - Stop using SQLDescribeParam anymore modified: storage/connect/odbconn.cpp - Fix MDEV-9723 Regression due to calling Cardinality instead of GetMaxSize in info. modified: storage/connect/tabtbl.h modified: storage/connect/mysql-test/connect/r/tbl.result modified: storage/connect/mysql-test/connect/t/tbl.test - Typo modified: storage/connect/tabodbc.cpp
1 parent 69042ff commit 7829cef

File tree

7 files changed

+94
-41
lines changed

7 files changed

+94
-41
lines changed

storage/connect/ha_connect.cc

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@
169169
#define JSONMAX 10 // JSON Default max grp size
170170

171171
extern "C" {
172-
char version[]= "Version 1.04.0005 January 24, 2016";
172+
char version[]= "Version 1.04.0006 March 12, 2016";
173173
#if defined(__WIN__)
174-
char compver[]= "Version 1.04.0005 " __DATE__ " " __TIME__;
174+
char compver[]= "Version 1.04.0006 " __DATE__ " " __TIME__;
175175
char slash= '\\';
176176
#else // !__WIN__
177177
char slash= '/';
@@ -5160,7 +5160,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
51605160
fncn= topt->catfunc;
51615161
fnc= GetFuncID(fncn);
51625162
sep= topt->separator;
5163-
spc= (!sep) ? ',' : (!strcmp(sep, "\\t")) ? '\t' : *sep;
5163+
spc= (!sep) ? ',' : *sep;
51645164
qch= topt->qchar ? *topt->qchar : (signed)topt->quoted >= 0 ? '"' : 0;
51655165
hdr= (int)topt->header;
51665166
tbl= topt->tablist;
@@ -5227,7 +5227,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
52275227
goto err;
52285228
} // endif rc
52295229

5230-
52315230
if (!tab) {
52325231
if (ttp == TAB_TBL) {
52335232
// Make tab the first table of the list
@@ -5296,8 +5295,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
52965295
case TAB_CSV:
52975296
if (!fn && fnc != FNC_NO)
52985297
sprintf(g->Message, "Missing %s file name", topt->type);
5299-
else
5300-
ok= true;
5298+
else if (sep && strlen(sep) > 1)
5299+
sprintf(g->Message, "Invalid separator %s", sep);
5300+
else
5301+
ok= true;
53015302

53025303
break;
53035304
case TAB_MYSQL:
@@ -5978,7 +5979,19 @@ int ha_connect::create(const char *name, TABLE *table_arg,
59785979
DBUG_RETURN(rc);
59795980
} // endif lrecl
59805981

5981-
} // endif type
5982+
} // endif type JSON
5983+
5984+
if (type == TAB_CSV) {
5985+
const char *sep = options->separator;
5986+
5987+
if (sep && strlen(sep) > 1) {
5988+
sprintf(g->Message, "Invalid separator %s", sep);
5989+
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
5990+
rc= HA_ERR_INTERNAL_ERROR;
5991+
DBUG_RETURN(rc);
5992+
} // endif sep
5993+
5994+
} // endif type CSV
59825995

59835996
// Check column types
59845997
for (field= table_arg->field; *field; field++) {
@@ -6766,7 +6779,7 @@ maria_declare_plugin(connect)
67666779
0x0104, /* version number (1.04) */
67676780
NULL, /* status variables */
67686781
connect_system_variables, /* system variables */
6769-
"1.04.0005", /* string version */
6782+
"1.04.0006", /* string version */
67706783
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
67716784
}
67726785
maria_declare_plugin_end;

storage/connect/mysql-test/connect/r/tbl.result

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ ta message
4444
1 Testing
4545
2 myisam table
4646
3 t4
47-
CREATE TABLE total (tabname CHAR(8) NOT NULL SPECIAL='TABID', ta TINYINT NOT NULL FLAG=1, message CHAR(20)) engine=CONNECT table_type=TBL table_list='t1,t2,t3,t4' option_list='port=PORT';
48-
select * from total;
47+
CREATE TABLE total (tabname CHAR(8) NOT NULL SPECIAL='TABID', ta TINYINT NOT NULL FLAG=1, message CHAR(20)) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3,t4' OPTION_LIST='port=PORT';
48+
SELECT * FROM total;
4949
tabname ta message
5050
t1 1 Testing
5151
t1 2 dos table
@@ -59,27 +59,27 @@ t3 3 t3
5959
t4 1 Testing
6060
t4 2 myisam table
6161
t4 3 t4
62-
select * from total where tabname = 't2';
62+
SELECT * FROM total WHERE tabname = 't2';
6363
tabname ta message
6464
t2 1 Testing
6565
t2 2 NULL
6666
t2 3 t2
67-
select * from total where tabname = 't2' and ta = 3;
67+
SELECT * FROM total WHERE tabname = 't2' AND ta = 3;
6868
tabname ta message
6969
t2 3 t2
70-
select * from total where tabname in ('t1','t4');
70+
SELECT * FROM total WHERE tabname IN ('t1','t4');
7171
tabname ta message
7272
t1 1 Testing
7373
t1 2 dos table
7474
t1 3 t1
7575
t4 1 Testing
7676
t4 2 myisam table
7777
t4 3 t4
78-
select * from total where ta = 3 and tabname in ('t1','t2');
78+
SELECT * FROM total WHERE ta = 3 AND tabname IN ('t1','t2');
7979
tabname ta message
8080
t1 3 t1
8181
t2 3 t2
82-
select * from total where tabname <> 't2';
82+
SELECT * FROM total WHERE tabname <> 't2';
8383
tabname ta message
8484
t1 1 Testing
8585
t1 2 dos table
@@ -90,24 +90,24 @@ t3 3 t3
9090
t4 1 Testing
9191
t4 2 myisam table
9292
t4 3 t4
93-
select * from total where tabname != 't2' and ta = 3;
93+
SELECT * FROM total WHERE tabname != 't2' AND ta = 3;
9494
tabname ta message
9595
t1 3 t1
9696
t3 3 t3
9797
t4 3 t4
98-
select * from total where tabname not in ('t2','t3');
98+
SELECT * FROM total WHERE tabname NOT IN ('t2','t3');
9999
tabname ta message
100100
t1 1 Testing
101101
t1 2 dos table
102102
t1 3 t1
103103
t4 1 Testing
104104
t4 2 myisam table
105105
t4 3 t4
106-
select * from total where ta = 3 and tabname in ('t2','t3');
106+
SELECT * FROM total WHERE ta = 3 AND tabname IN ('t2','t3');
107107
tabname ta message
108108
t2 3 t2
109109
t3 3 t3
110-
select * from total where ta = 3 or tabname in ('t2','t4');
110+
SELECT * FROM total WHERE ta = 3 OR tabname IN ('t2','t4');
111111
tabname ta message
112112
t1 3 t1
113113
t2 1 Testing
@@ -117,7 +117,7 @@ t3 3 t3
117117
t4 1 Testing
118118
t4 2 myisam table
119119
t4 3 t4
120-
select * from total where not tabname = 't2';
120+
SELECT * FROM total WHERE NOT tabname = 't2';
121121
tabname ta message
122122
t1 1 Testing
123123
t1 2 dos table
@@ -128,7 +128,7 @@ t3 3 t3
128128
t4 1 Testing
129129
t4 2 myisam table
130130
t4 3 t4
131-
select * from total where tabname = 't2' or tabname = 't1';
131+
SELECT * FROM total WHERE tabname = 't2' OR tabname = 't1';
132132
tabname ta message
133133
t1 1 Testing
134134
t1 2 dos table
@@ -141,3 +141,22 @@ DROP TABLE t1;
141141
DROP TABLE t2;
142142
DROP TABLE t3;
143143
DROP TABLE t4;
144+
#
145+
# Checking thread TBL tables
146+
#
147+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 11 as v';
148+
SELECT * FROM t1;
149+
v
150+
11
151+
CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 22 as v';
152+
SELECT * FROM t2;
153+
v
154+
22
155+
CREATE TABLE total (v BIGINT(20) UNSIGNED NOT NULL) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2' OPTION_LIST='thread=yes,port=PORT';;
156+
SELECT * FROM total;
157+
v
158+
22
159+
11
160+
DROP TABLE total;
161+
DROP TABLE t1;
162+
DROP TABLE t2;

storage/connect/mysql-test/connect/t/tbl.test

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,40 @@ INSERT INTO t4 (message) VALUES ('Testing'),('myisam table'),('t4');
3131
SELECT * FROM t4;
3232

3333
--replace_result $PORT PORT
34-
--eval CREATE TABLE total (tabname CHAR(8) NOT NULL SPECIAL='TABID', ta TINYINT NOT NULL FLAG=1, message CHAR(20)) engine=CONNECT table_type=TBL table_list='t1,t2,t3,t4' option_list='port=$PORT'
35-
36-
select * from total;
37-
select * from total where tabname = 't2';
38-
select * from total where tabname = 't2' and ta = 3;
39-
select * from total where tabname in ('t1','t4');
40-
select * from total where ta = 3 and tabname in ('t1','t2');
41-
select * from total where tabname <> 't2';
42-
select * from total where tabname != 't2' and ta = 3;
43-
select * from total where tabname not in ('t2','t3');
44-
select * from total where ta = 3 and tabname in ('t2','t3');
45-
select * from total where ta = 3 or tabname in ('t2','t4');
46-
select * from total where not tabname = 't2';
47-
select * from total where tabname = 't2' or tabname = 't1';
34+
--eval CREATE TABLE total (tabname CHAR(8) NOT NULL SPECIAL='TABID', ta TINYINT NOT NULL FLAG=1, message CHAR(20)) ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3,t4' OPTION_LIST='port=$PORT'
35+
36+
SELECT * FROM total;
37+
SELECT * FROM total WHERE tabname = 't2';
38+
SELECT * FROM total WHERE tabname = 't2' AND ta = 3;
39+
SELECT * FROM total WHERE tabname IN ('t1','t4');
40+
SELECT * FROM total WHERE ta = 3 AND tabname IN ('t1','t2');
41+
SELECT * FROM total WHERE tabname <> 't2';
42+
SELECT * FROM total WHERE tabname != 't2' AND ta = 3;
43+
SELECT * FROM total WHERE tabname NOT IN ('t2','t3');
44+
SELECT * FROM total WHERE ta = 3 AND tabname IN ('t2','t3');
45+
SELECT * FROM total WHERE ta = 3 OR tabname IN ('t2','t4');
46+
SELECT * FROM total WHERE NOT tabname = 't2';
47+
SELECT * FROM total WHERE tabname = 't2' OR tabname = 't1';
4848

4949
DROP TABLE total;
5050
DROP TABLE t1;
5151
DROP TABLE t2;
5252
DROP TABLE t3;
5353
DROP TABLE t4;
54+
55+
--echo #
56+
--echo # Checking thread TBL tables
57+
--echo #
58+
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 11 as v';
59+
SELECT * FROM t1;
60+
61+
CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL SRCDEF='select 22 as v';
62+
SELECT * FROM t2;
63+
64+
--replace_result $PORT PORT
65+
--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';
66+
SELECT * FROM total;
67+
68+
DROP TABLE total;
69+
DROP TABLE t1;
70+
DROP TABLE t2;

storage/connect/odbconn.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,19 +1758,22 @@ bool ODBConn::BindParam(ODBCCOL *colp)
17581758
SQLLEN *strlen = colp->GetStrLen();
17591759
SQLRETURN rc;
17601760

1761+
#if 0
17611762
try {
1763+
// This function is often not or badly implemented by data sources
17621764
rc = SQLDescribeParam(m_hstmt, n, &sqlt, &colsize, &dec, &nul);
17631765

17641766
if (!Check(rc))
17651767
ThrowDBX(rc, "SQLDescribeParam", m_hstmt);
17661768

17671769
} catch(DBX *x) {
17681770
sprintf(m_G->Message, "%s: %s", x->m_Msg, x->GetErrorMessage(0));
1771+
#endif // 0
17691772
colsize = colp->GetPrecision();
17701773
sqlt = GetSQLType(buftype);
1771-
dec = IsTypeChar(buftype) ? 0 : colp->GetScale();
1772-
nul = SQL_NULLABLE_UNKNOWN;
1773-
} // end try/catch
1774+
dec = IsTypeNum(buftype) ? colp->GetScale() : 0;
1775+
nul = colp->IsNullable() ? SQL_NULLABLE : SQL_NO_NULLS;
1776+
//} // end try/catch
17741777

17751778
buf = colp->GetBuffer(0);
17761779
len = IsTypeChar(buftype) ? colp->GetBuflen() : 0;

storage/connect/tabmysql.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
334334
Delayed = !!GetIntCatInfo("Delayed", 0);
335335
} else {
336336
// MYSQL access from a PROXY table
337-
Database = GetStringCatInfo(g, "Database", Schema ? Schema : "*");
337+
Database = GetStringCatInfo(g, "Database", Schema ? Schema : (PSZ)"*");
338338
Isview = GetBoolCatInfo("View", false);
339339

340340
// We must get other connection parms from the calling table

storage/connect/tabodbc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* */
66
/* COPYRIGHT: */
77
/* ---------- */
8-
/* (C) Copyright to the author Olivier BERTRAND 2000-2015 */
8+
/* (C) Copyright to the author Olivier BERTRAND 2000-2016 */
99
/* */
1010
/* WHAT THIS PROGRAM DOES: */
1111
/* ----------------------- */

storage/connect/tabtbl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ class DllExport TDBTBM : public TDBTBL {
138138
virtual void ResetDB(void);
139139

140140
// Database routines
141-
virtual int GetMaxSize(PGLOBAL g) {return 10;} // Temporary
141+
virtual int Cardinality(PGLOBAL g) { return 10; }
142+
virtual int GetMaxSize(PGLOBAL g) { return 10; } // Temporary
142143
virtual int RowNumber(PGLOBAL g, bool b = FALSE);
143144
virtual bool OpenDB(PGLOBAL g);
144145
virtual int ReadDB(PGLOBAL g);

0 commit comments

Comments
 (0)