Skip to content

Commit

Permalink
- Fix MDEV-9603 compiler error.
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
Buggynours committed Mar 16, 2016
1 parent 69042ff commit 7829cef
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 41 deletions.
29 changes: 21 additions & 8 deletions storage/connect/ha_connect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@
#define JSONMAX 10 // JSON Default max grp size

extern "C" {
char version[]= "Version 1.04.0005 January 24, 2016";
char version[]= "Version 1.04.0006 March 12, 2016";
#if defined(__WIN__)
char compver[]= "Version 1.04.0005 " __DATE__ " " __TIME__;
char compver[]= "Version 1.04.0006 " __DATE__ " " __TIME__;
char slash= '\\';
#else // !__WIN__
char slash= '/';
Expand Down Expand Up @@ -5160,7 +5160,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
fncn= topt->catfunc;
fnc= GetFuncID(fncn);
sep= topt->separator;
spc= (!sep) ? ',' : (!strcmp(sep, "\\t")) ? '\t' : *sep;
spc= (!sep) ? ',' : *sep;
qch= topt->qchar ? *topt->qchar : (signed)topt->quoted >= 0 ? '"' : 0;
hdr= (int)topt->header;
tbl= topt->tablist;
Expand Down Expand Up @@ -5227,7 +5227,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
goto err;
} // endif rc


if (!tab) {
if (ttp == TAB_TBL) {
// Make tab the first table of the list
Expand Down Expand Up @@ -5296,8 +5295,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
case TAB_CSV:
if (!fn && fnc != FNC_NO)
sprintf(g->Message, "Missing %s file name", topt->type);
else
ok= true;
else if (sep && strlen(sep) > 1)
sprintf(g->Message, "Invalid separator %s", sep);
else
ok= true;

break;
case TAB_MYSQL:
Expand Down Expand Up @@ -5978,7 +5979,19 @@ int ha_connect::create(const char *name, TABLE *table_arg,
DBUG_RETURN(rc);
} // endif lrecl

} // endif type
} // endif type JSON

if (type == TAB_CSV) {
const char *sep = options->separator;

if (sep && strlen(sep) > 1) {
sprintf(g->Message, "Invalid separator %s", sep);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR;
DBUG_RETURN(rc);
} // endif sep

} // endif type CSV

// Check column types
for (field= table_arg->field; *field; field++) {
Expand Down Expand Up @@ -6766,7 +6779,7 @@ maria_declare_plugin(connect)
0x0104, /* version number (1.04) */
NULL, /* status variables */
connect_system_variables, /* system variables */
"1.04.0005", /* string version */
"1.04.0006", /* string version */
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
}
maria_declare_plugin_end;
45 changes: 32 additions & 13 deletions storage/connect/mysql-test/connect/r/tbl.result
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ ta message
1 Testing
2 myisam table
3 t4
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';
select * from total;
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';
SELECT * FROM total;
tabname ta message
t1 1 Testing
t1 2 dos table
Expand All @@ -59,27 +59,27 @@ t3 3 t3
t4 1 Testing
t4 2 myisam table
t4 3 t4
select * from total where tabname = 't2';
SELECT * FROM total WHERE tabname = 't2';
tabname ta message
t2 1 Testing
t2 2 NULL
t2 3 t2
select * from total where tabname = 't2' and ta = 3;
SELECT * FROM total WHERE tabname = 't2' AND ta = 3;
tabname ta message
t2 3 t2
select * from total where tabname in ('t1','t4');
SELECT * FROM total WHERE tabname IN ('t1','t4');
tabname ta message
t1 1 Testing
t1 2 dos table
t1 3 t1
t4 1 Testing
t4 2 myisam table
t4 3 t4
select * from total where ta = 3 and tabname in ('t1','t2');
SELECT * FROM total WHERE ta = 3 AND tabname IN ('t1','t2');
tabname ta message
t1 3 t1
t2 3 t2
select * from total where tabname <> 't2';
SELECT * FROM total WHERE tabname <> 't2';
tabname ta message
t1 1 Testing
t1 2 dos table
Expand All @@ -90,24 +90,24 @@ t3 3 t3
t4 1 Testing
t4 2 myisam table
t4 3 t4
select * from total where tabname != 't2' and ta = 3;
SELECT * FROM total WHERE tabname != 't2' AND ta = 3;
tabname ta message
t1 3 t1
t3 3 t3
t4 3 t4
select * from total where tabname not in ('t2','t3');
SELECT * FROM total WHERE tabname NOT IN ('t2','t3');
tabname ta message
t1 1 Testing
t1 2 dos table
t1 3 t1
t4 1 Testing
t4 2 myisam table
t4 3 t4
select * from total where ta = 3 and tabname in ('t2','t3');
SELECT * FROM total WHERE ta = 3 AND tabname IN ('t2','t3');
tabname ta message
t2 3 t2
t3 3 t3
select * from total where ta = 3 or tabname in ('t2','t4');
SELECT * FROM total WHERE ta = 3 OR tabname IN ('t2','t4');
tabname ta message
t1 3 t1
t2 1 Testing
Expand All @@ -117,7 +117,7 @@ t3 3 t3
t4 1 Testing
t4 2 myisam table
t4 3 t4
select * from total where not tabname = 't2';
SELECT * FROM total WHERE NOT tabname = 't2';
tabname ta message
t1 1 Testing
t1 2 dos table
Expand All @@ -128,7 +128,7 @@ t3 3 t3
t4 1 Testing
t4 2 myisam table
t4 3 t4
select * from total where tabname = 't2' or tabname = 't1';
SELECT * FROM total WHERE tabname = 't2' OR tabname = 't1';
tabname ta message
t1 1 Testing
t1 2 dos table
Expand All @@ -141,3 +141,22 @@ DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;
#
# Checking thread TBL tables
#
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;
v
22
11
DROP TABLE total;
DROP TABLE t1;
DROP TABLE t2;
45 changes: 31 additions & 14 deletions storage/connect/mysql-test/connect/t/tbl.test
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,40 @@ INSERT INTO t4 (message) VALUES ('Testing'),('myisam table'),('t4');
SELECT * FROM t4;

--replace_result $PORT PORT
--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'

select * from total;
select * from total where tabname = 't2';
select * from total where tabname = 't2' and ta = 3;
select * from total where tabname in ('t1','t4');
select * from total where ta = 3 and tabname in ('t1','t2');
select * from total where tabname <> 't2';
select * from total where tabname != 't2' and ta = 3;
select * from total where tabname not in ('t2','t3');
select * from total where ta = 3 and tabname in ('t2','t3');
select * from total where ta = 3 or tabname in ('t2','t4');
select * from total where not tabname = 't2';
select * from total where tabname = 't2' or tabname = 't1';
--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'

SELECT * FROM total;
SELECT * FROM total WHERE tabname = 't2';
SELECT * FROM total WHERE tabname = 't2' AND ta = 3;
SELECT * FROM total WHERE tabname IN ('t1','t4');
SELECT * FROM total WHERE ta = 3 AND tabname IN ('t1','t2');
SELECT * FROM total WHERE tabname <> 't2';
SELECT * FROM total WHERE tabname != 't2' AND ta = 3;
SELECT * FROM total WHERE tabname NOT IN ('t2','t3');
SELECT * FROM total WHERE ta = 3 AND tabname IN ('t2','t3');
SELECT * FROM total WHERE ta = 3 OR tabname IN ('t2','t4');
SELECT * FROM total WHERE NOT tabname = 't2';
SELECT * FROM total WHERE tabname = 't2' OR tabname = 't1';

DROP TABLE total;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;

--echo #
--echo # Checking thread TBL tables
--echo #
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;

--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;

DROP TABLE total;
DROP TABLE t1;
DROP TABLE t2;
9 changes: 6 additions & 3 deletions storage/connect/odbconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,19 +1758,22 @@ bool ODBConn::BindParam(ODBCCOL *colp)
SQLLEN *strlen = colp->GetStrLen();
SQLRETURN rc;

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

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

} catch(DBX *x) {
sprintf(m_G->Message, "%s: %s", x->m_Msg, x->GetErrorMessage(0));
#endif // 0
colsize = colp->GetPrecision();
sqlt = GetSQLType(buftype);
dec = IsTypeChar(buftype) ? 0 : colp->GetScale();
nul = SQL_NULLABLE_UNKNOWN;
} // end try/catch
dec = IsTypeNum(buftype) ? colp->GetScale() : 0;
nul = colp->IsNullable() ? SQL_NULLABLE : SQL_NO_NULLS;
//} // end try/catch

buf = colp->GetBuffer(0);
len = IsTypeChar(buftype) ? colp->GetBuflen() : 0;
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/tabmysql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
Delayed = !!GetIntCatInfo("Delayed", 0);
} else {
// MYSQL access from a PROXY table
Database = GetStringCatInfo(g, "Database", Schema ? Schema : "*");
Database = GetStringCatInfo(g, "Database", Schema ? Schema : (PSZ)"*");
Isview = GetBoolCatInfo("View", false);

// We must get other connection parms from the calling table
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/tabodbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2000-2015 */
/* (C) Copyright to the author Olivier BERTRAND 2000-2016 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
Expand Down
3 changes: 2 additions & 1 deletion storage/connect/tabtbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ class DllExport TDBTBM : public TDBTBL {
virtual void ResetDB(void);

// Database routines
virtual int GetMaxSize(PGLOBAL g) {return 10;} // Temporary
virtual int Cardinality(PGLOBAL g) { return 10; }
virtual int GetMaxSize(PGLOBAL g) { return 10; } // Temporary
virtual int RowNumber(PGLOBAL g, bool b = FALSE);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
Expand Down

0 comments on commit 7829cef

Please sign in to comment.