Commit d5a80519 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'connect/10.1' into 10.1

parents e984159e 59c4675c
...@@ -169,9 +169,9 @@ ...@@ -169,9 +169,9 @@
#define JSONMAX 10 // JSON Default max grp size #define JSONMAX 10 // JSON Default max grp size
extern "C" { extern "C" {
char version[]= "Version 1.04.0005 January 24, 2016"; char version[]= "Version 1.04.0006 March 12, 2016";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.04.0005 " __DATE__ " " __TIME__; char compver[]= "Version 1.04.0006 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
#else // !__WIN__ #else // !__WIN__
char slash= '/'; char slash= '/';
...@@ -5160,7 +5160,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5160,7 +5160,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
fncn= topt->catfunc; fncn= topt->catfunc;
fnc= GetFuncID(fncn); fnc= GetFuncID(fncn);
sep= topt->separator; sep= topt->separator;
spc= (!sep) ? ',' : (!strcmp(sep, "\\t")) ? '\t' : *sep; spc= (!sep) ? ',' : *sep;
qch= topt->qchar ? *topt->qchar : (signed)topt->quoted >= 0 ? '"' : 0; qch= topt->qchar ? *topt->qchar : (signed)topt->quoted >= 0 ? '"' : 0;
hdr= (int)topt->header; hdr= (int)topt->header;
tbl= topt->tablist; tbl= topt->tablist;
...@@ -5227,7 +5227,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5227,7 +5227,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
goto err; goto err;
} // endif rc } // endif rc
if (!tab) { if (!tab) {
if (ttp == TAB_TBL) { if (ttp == TAB_TBL) {
// Make tab the first table of the list // Make tab the first table of the list
...@@ -5296,6 +5295,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5296,6 +5295,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
case TAB_CSV: case TAB_CSV:
if (!fn && fnc != FNC_NO) if (!fn && fnc != FNC_NO)
sprintf(g->Message, "Missing %s file name", topt->type); sprintf(g->Message, "Missing %s file name", topt->type);
else if (sep && strlen(sep) > 1)
sprintf(g->Message, "Invalid separator %s", sep);
else else
ok= true; ok= true;
...@@ -5978,7 +5979,19 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -5978,7 +5979,19 @@ int ha_connect::create(const char *name, TABLE *table_arg,
DBUG_RETURN(rc); DBUG_RETURN(rc);
} // endif lrecl } // 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 // Check column types
for (field= table_arg->field; *field; field++) { for (field= table_arg->field; *field; field++) {
...@@ -6766,7 +6779,7 @@ maria_declare_plugin(connect) ...@@ -6766,7 +6779,7 @@ maria_declare_plugin(connect)
0x0104, /* version number (1.04) */ 0x0104, /* version number (1.04) */
NULL, /* status variables */ NULL, /* status variables */
connect_system_variables, /* system variables */ connect_system_variables, /* system variables */
"1.04.0005", /* string version */ "1.04.0006", /* string version */
MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */ MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */
} }
maria_declare_plugin_end; maria_declare_plugin_end;
...@@ -44,8 +44,8 @@ ta message ...@@ -44,8 +44,8 @@ ta message
1 Testing 1 Testing
2 myisam table 2 myisam table
3 t4 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'; 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;
tabname ta message tabname ta message
t1 1 Testing t1 1 Testing
t1 2 dos table t1 2 dos table
...@@ -59,15 +59,15 @@ t3 3 t3 ...@@ -59,15 +59,15 @@ t3 3 t3
t4 1 Testing t4 1 Testing
t4 2 myisam table t4 2 myisam table
t4 3 t4 t4 3 t4
select * from total where tabname = 't2'; SELECT * FROM total WHERE tabname = 't2';
tabname ta message tabname ta message
t2 1 Testing t2 1 Testing
t2 2 NULL t2 2 NULL
t2 3 t2 t2 3 t2
select * from total where tabname = 't2' and ta = 3; SELECT * FROM total WHERE tabname = 't2' AND ta = 3;
tabname ta message tabname ta message
t2 3 t2 t2 3 t2
select * from total where tabname in ('t1','t4'); SELECT * FROM total WHERE tabname IN ('t1','t4');
tabname ta message tabname ta message
t1 1 Testing t1 1 Testing
t1 2 dos table t1 2 dos table
...@@ -75,11 +75,11 @@ t1 3 t1 ...@@ -75,11 +75,11 @@ t1 3 t1
t4 1 Testing t4 1 Testing
t4 2 myisam table t4 2 myisam table
t4 3 t4 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 tabname ta message
t1 3 t1 t1 3 t1
t2 3 t2 t2 3 t2
select * from total where tabname <> 't2'; SELECT * FROM total WHERE tabname <> 't2';
tabname ta message tabname ta message
t1 1 Testing t1 1 Testing
t1 2 dos table t1 2 dos table
...@@ -90,12 +90,12 @@ t3 3 t3 ...@@ -90,12 +90,12 @@ t3 3 t3
t4 1 Testing t4 1 Testing
t4 2 myisam table t4 2 myisam table
t4 3 t4 t4 3 t4
select * from total where tabname != 't2' and ta = 3; SELECT * FROM total WHERE tabname != 't2' AND ta = 3;
tabname ta message tabname ta message
t1 3 t1 t1 3 t1
t3 3 t3 t3 3 t3
t4 3 t4 t4 3 t4
select * from total where tabname not in ('t2','t3'); SELECT * FROM total WHERE tabname NOT IN ('t2','t3');
tabname ta message tabname ta message
t1 1 Testing t1 1 Testing
t1 2 dos table t1 2 dos table
...@@ -103,11 +103,11 @@ t1 3 t1 ...@@ -103,11 +103,11 @@ t1 3 t1
t4 1 Testing t4 1 Testing
t4 2 myisam table t4 2 myisam table
t4 3 t4 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 tabname ta message
t2 3 t2 t2 3 t2
t3 3 t3 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 tabname ta message
t1 3 t1 t1 3 t1
t2 1 Testing t2 1 Testing
...@@ -117,7 +117,7 @@ t3 3 t3 ...@@ -117,7 +117,7 @@ t3 3 t3
t4 1 Testing t4 1 Testing
t4 2 myisam table t4 2 myisam table
t4 3 t4 t4 3 t4
select * from total where not tabname = 't2'; SELECT * FROM total WHERE NOT tabname = 't2';
tabname ta message tabname ta message
t1 1 Testing t1 1 Testing
t1 2 dos table t1 2 dos table
...@@ -128,7 +128,7 @@ t3 3 t3 ...@@ -128,7 +128,7 @@ t3 3 t3
t4 1 Testing t4 1 Testing
t4 2 myisam table t4 2 myisam table
t4 3 t4 t4 3 t4
select * from total where tabname = 't2' or tabname = 't1'; SELECT * FROM total WHERE tabname = 't2' OR tabname = 't1';
tabname ta message tabname ta message
t1 1 Testing t1 1 Testing
t1 2 dos table t1 2 dos table
...@@ -141,3 +141,22 @@ DROP TABLE t1; ...@@ -141,3 +141,22 @@ DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t3; DROP TABLE t3;
DROP TABLE t4; 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 order by v desc;
v
22
11
DROP TABLE total;
DROP TABLE t1;
DROP TABLE t2;
...@@ -31,23 +31,40 @@ INSERT INTO t4 (message) VALUES ('Testing'),('myisam table'),('t4'); ...@@ -31,23 +31,40 @@ INSERT INTO t4 (message) VALUES ('Testing'),('myisam table'),('t4');
SELECT * FROM t4; SELECT * FROM t4;
--replace_result $PORT PORT --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' --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;
select * from total where tabname = 't2'; SELECT * FROM total WHERE tabname = 't2';
select * from total where tabname = 't2' and ta = 3; SELECT * FROM total WHERE tabname = 't2' AND ta = 3;
select * from total where tabname in ('t1','t4'); SELECT * FROM total WHERE tabname IN ('t1','t4');
select * from total where ta = 3 and tabname in ('t1','t2'); SELECT * FROM total WHERE ta = 3 AND tabname IN ('t1','t2');
select * from total where tabname <> 't2'; SELECT * FROM total WHERE tabname <> 't2';
select * from total where tabname != 't2' and ta = 3; SELECT * FROM total WHERE tabname != 't2' AND ta = 3;
select * from total where tabname not in ('t2','t3'); 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 AND tabname IN ('t2','t3');
select * from total where ta = 3 or tabname in ('t2','t4'); SELECT * FROM total WHERE ta = 3 OR tabname IN ('t2','t4');
select * from total where not tabname = 't2'; SELECT * FROM total WHERE NOT tabname = 't2';
select * from total where tabname = 't2' or tabname = 't1'; SELECT * FROM total WHERE tabname = 't2' OR tabname = 't1';
DROP TABLE total; DROP TABLE total;
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t3; DROP TABLE t3;
DROP TABLE t4; 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 order by v desc;
DROP TABLE total;
DROP TABLE t1;
DROP TABLE t2;
...@@ -1758,7 +1758,9 @@ bool ODBConn::BindParam(ODBCCOL *colp) ...@@ -1758,7 +1758,9 @@ bool ODBConn::BindParam(ODBCCOL *colp)
SQLLEN *strlen = colp->GetStrLen(); SQLLEN *strlen = colp->GetStrLen();
SQLRETURN rc; SQLRETURN rc;
#if 0
try { try {
// This function is often not or badly implemented by data sources
rc = SQLDescribeParam(m_hstmt, n, &sqlt, &colsize, &dec, &nul); rc = SQLDescribeParam(m_hstmt, n, &sqlt, &colsize, &dec, &nul);
if (!Check(rc)) if (!Check(rc))
...@@ -1766,11 +1768,12 @@ bool ODBConn::BindParam(ODBCCOL *colp) ...@@ -1766,11 +1768,12 @@ bool ODBConn::BindParam(ODBCCOL *colp)
} catch(DBX *x) { } catch(DBX *x) {
sprintf(m_G->Message, "%s: %s", x->m_Msg, x->GetErrorMessage(0)); sprintf(m_G->Message, "%s: %s", x->m_Msg, x->GetErrorMessage(0));
#endif // 0
colsize = colp->GetPrecision(); colsize = colp->GetPrecision();
sqlt = GetSQLType(buftype); sqlt = GetSQLType(buftype);
dec = IsTypeChar(buftype) ? 0 : colp->GetScale(); dec = IsTypeNum(buftype) ? colp->GetScale() : 0;
nul = SQL_NULLABLE_UNKNOWN; nul = colp->IsNullable() ? SQL_NULLABLE : SQL_NO_NULLS;
} // end try/catch //} // end try/catch
buf = colp->GetBuffer(0); buf = colp->GetBuffer(0);
len = IsTypeChar(buftype) ? colp->GetBuflen() : 0; len = IsTypeChar(buftype) ? colp->GetBuflen() : 0;
......
...@@ -334,7 +334,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int) ...@@ -334,7 +334,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
Delayed = !!GetIntCatInfo("Delayed", 0); Delayed = !!GetIntCatInfo("Delayed", 0);
} else { } else {
// MYSQL access from a PROXY table // MYSQL access from a PROXY table
Database = GetStringCatInfo(g, "Database", Schema ? Schema : (char*)"*"); Database = GetStringCatInfo(g, "Database", Schema ? Schema : PlugDup(g, "*"));
Isview = GetBoolCatInfo("View", false); Isview = GetBoolCatInfo("View", false);
// We must get other connection parms from the calling table // We must get other connection parms from the calling table
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2000-2015 */ /* (C) Copyright to the author Olivier BERTRAND 2000-2016 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
......
...@@ -607,7 +607,7 @@ void TDBTBM::ResetDB(void) ...@@ -607,7 +607,7 @@ void TDBTBM::ResetDB(void)
for (PTABLE tabp = Tablist; tabp; tabp = tabp->GetNext()) for (PTABLE tabp = Tablist; tabp; tabp = tabp->GetNext())
((PTDBASE)tabp->GetTo_Tdb())->ResetDB(); ((PTDBASE)tabp->GetTo_Tdb())->ResetDB();
Tdbp = (PTDBASE)Tablist->GetTo_Tdb(); Tdbp = (Tablist) ? (PTDBASE)Tablist->GetTo_Tdb() : NULL;
Crp = 0; Crp = 0;
} // end of ResetDB } // end of ResetDB
...@@ -679,7 +679,7 @@ bool TDBTBM::OpenDB(PGLOBAL g) ...@@ -679,7 +679,7 @@ bool TDBTBM::OpenDB(PGLOBAL g)
/* Table already open, replace it at its beginning. */ /* Table already open, replace it at its beginning. */
/*******************************************************************/ /*******************************************************************/
ResetDB(); ResetDB();
return Tdbp->OpenDB(g); // Re-open fist table return (Tdbp) ? Tdbp->OpenDB(g) : false; // Re-open fist table
} // endif use } // endif use
#if 0 #if 0
......
...@@ -138,7 +138,8 @@ class DllExport TDBTBM : public TDBTBL { ...@@ -138,7 +138,8 @@ class DllExport TDBTBM : public TDBTBL {
virtual void ResetDB(void); virtual void ResetDB(void);
// Database routines // 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 int RowNumber(PGLOBAL g, bool b = FALSE);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
......
...@@ -1344,9 +1344,12 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype) ...@@ -1344,9 +1344,12 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
/***********************************************************************/ /***********************************************************************/
bool TYPVAL<PSZ>::SetValue_char(char *p, int n) bool TYPVAL<PSZ>::SetValue_char(char *p, int n)
{ {
bool rc; bool rc = false;
if (p && n > 0) { if (!p || n == 0) {
Reset();
Null = Nullable;
} else if (p != Strp) {
rc = n > Len; rc = n > Len;
if ((n = MY_MIN(n, Len))) { if ((n = MY_MIN(n, Len))) {
...@@ -1366,10 +1369,6 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n) ...@@ -1366,10 +1369,6 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n)
Reset(); Reset();
Null = false; Null = false;
} else {
rc = false;
Reset();
Null = Nullable;
} // endif p } // endif p
return rc; return rc;
...@@ -1380,12 +1379,12 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n) ...@@ -1380,12 +1379,12 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n)
/***********************************************************************/ /***********************************************************************/
void TYPVAL<PSZ>::SetValue_psz(PSZ s) void TYPVAL<PSZ>::SetValue_psz(PSZ s)
{ {
if (s) { if (!s) {
strncpy(Strp, s, Len);
Null = false;
} else {
Reset(); Reset();
Null = Nullable; Null = Nullable;
} else if (s != Strp) {
strncpy(Strp, s, Len);
Null = false;
} // endif s } // endif s
} // end of SetValue_psz } // end of SetValue_psz
...@@ -1627,12 +1626,6 @@ int TYPVAL<PSZ>::CompareValue(PVAL vp) ...@@ -1627,12 +1626,6 @@ int TYPVAL<PSZ>::CompareValue(PVAL vp)
return (n > 0) ? 1 : (n < 0) ? -1 : 0; return (n > 0) ? 1 : (n < 0) ? -1 : 0;
} // end of CompareValue } // end of CompareValue
static inline void v_strcpy(char *dest, const char *src)
{
if (dest != src)
strcpy(dest, src);
}
/***********************************************************************/ /***********************************************************************/
/* Compute a function on a string. */ /* Compute a function on a string. */
/***********************************************************************/ /***********************************************************************/
...@@ -1649,7 +1642,7 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) ...@@ -1649,7 +1642,7 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
assert(np == 1 || np == 2); assert(np == 1 || np == 2);
if (np == 2) if (np == 2)
strncpy(Strp, p[0], Len); SetValue_psz(p[0]);
if ((i = Len - (signed)strlen(Strp)) > 0) if ((i = Len - (signed)strlen(Strp)) > 0)
strncat(Strp, p[np - 1], i); strncat(Strp, p[np - 1], i);
...@@ -1657,11 +1650,11 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) ...@@ -1657,11 +1650,11 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
break; break;
case OP_MIN: case OP_MIN:
assert(np == 2); assert(np == 2);
v_strcpy(Strp, (strcmp(p[0], p[1]) < 0) ? p[0] : p[1]); SetValue_psz((strcmp(p[0], p[1]) < 0) ? p[0] : p[1]);
break; break;
case OP_MAX: case OP_MAX:
assert(np == 2); assert(np == 2);
v_strcpy(Strp, (strcmp(p[0], p[1]) > 0) ? p[0] : p[1]); SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]);
break; break;
default: default:
// sprintf(g->Message, MSG(BAD_EXP_OPER), op); // sprintf(g->Message, MSG(BAD_EXP_OPER), op);
......
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