Commit 46f3e320 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix a bug causing CONNECT to loop when expanding a JSON column

  when the expanded column value is null or void array.
- Adding the FullArray option to JSON tables.
- Skipping expanded JSON lines when the expanded column value is null.
  modified:   storage/connect/connect.cc
  modified:   storage/connect/tabdos.h
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabjson.h
parent d8436c9f
......@@ -404,6 +404,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
rc = RC_FX;
} catch (const char *msg) {
strcpy(g->Message, msg);
rc = RC_NF;
} // end catch
return rc;
......
SET GLOBAL connect_class_path='C:/MariaDB-10.1/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo2.jar';
SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo2.jar';
set connect_enable_mongo=1;
#
# Test the MONGO table type
#
......@@ -381,3 +382,4 @@ planner 167 41.75
postcard 23 5.75
DROP TABLE t1;
true
set connect_enable_mongo=0;
SET GLOBAL connect_class_path='C:/MariaDB-10.1/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo3.jar';
SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo3.jar';
set connect_enable_mongo=1;
#
# Test the MONGO table type
#
......@@ -381,3 +382,4 @@ planner 167 41.75
postcard 23 5.75
DROP TABLE t1;
true
set connect_enable_mongo=0;
set connect_enable_mongo=1;
#
# Test the MONGO table type
#
......@@ -380,3 +381,4 @@ planner 167 41.75
postcard 23 5.75
DROP TABLE t1;
true
set connect_enable_mongo=0;
set connect_enable_mongo=1;
#
# Test the MONGO table type
#
......@@ -376,3 +377,4 @@ planner 167 41.750000
postcard 23 5.750000
DROP TABLE t1;
true
set connect_enable_mongo=0;
SET GLOBAL connect_class_path='C:/MariaDB-10.1/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo2.jar';
SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo2.jar';
set connect_enable_mongo=1;
#
# Test the MONGO table type
#
......@@ -377,3 +378,4 @@ planner 167 41.75
postcard 23 5.75
DROP TABLE t1;
true
set connect_enable_mongo=0;
SET GLOBAL connect_class_path='C:/MariaDB-10.1/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo3.jar';
SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo3.jar';
set connect_enable_mongo=1;
#
# Test the MONGO table type
#
......@@ -377,3 +378,4 @@ planner 167 41.75
postcard 23 5.75
DROP TABLE t1;
true
set connect_enable_mongo=0;
connect master,127.0.0.1,root,,test,$MASTER_MYPORT,;
connect slave,127.0.0.1,root,,test,$SLAVE_MYPORT,;
connection master;
CREATE DATABASE connect;
connection slave;
CREATE DATABASE connect;
connection default;
#
# Checking thread TBL tables
#
......@@ -11,6 +16,7 @@ a b
1 test01
2 test02
3 test03
connection master;
CREATE TABLE rt2 (a int, b char(10));
INSERT INTO rt2 VALUES (4,'test04'),(5,'test05'),(6,'test06'),(7,'test07');
SELECT * FROM rt2;
......@@ -19,6 +25,7 @@ a b
5 test05
6 test06
7 test07
connection slave;
USE test;
CREATE TABLE rt3 (a int, b char(10));
INSERT INTO rt3 VALUES (8,'test08'),(9,'test09'),(10,'test10'),(11,'test11');
......@@ -44,6 +51,7 @@ a b
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';
SELECT * FROM t2;
......@@ -79,7 +87,7 @@ a b
CREATE TABLE total (a int, b char(10))
ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3,t4,t5'
OPTION_LIST='thread=yes,port=PORT';
set connect_xtrace=1;
set connect_xtrace=96;
SELECT * FROM total order by a desc;
a b
19 test19
......@@ -103,8 +111,11 @@ a b
1 test01
0 test00
set connect_xtrace=0;
connection master;
DROP TABLE rt2;
connection slave;
DROP TABLE rt3,rt4,rt5;
connection default;
DROP TABLE t1,t2,t3,t4,t5,total;
#
# Old thread TBL tables test modified
......@@ -118,7 +129,7 @@ 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;
set connect_xtrace=96;
SELECT * FROM total order by v desc;
v
22
......@@ -137,7 +148,7 @@ 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;
set connect_xtrace=96;
SELECT * FROM total order by v desc;
v
22
......@@ -146,7 +157,9 @@ set connect_xtrace=0;
DROP TABLE total;
DROP TABLE t1;
DROP TABLE t2;
connection master;
DROP TABLE IF EXISTS connect.t1;
DROP DATABASE IF EXISTS connect;
connection slave;
DROP TABLE IF EXISTS connect.t1;
DROP DATABASE IF EXISTS connect;
let $MONGO= C:/PROGRA~1/MongoDB/Server/3.4/bin/mongo;
let $MONGOIMPORT= C:/PROGRA~1/MongoDB/Server/3.4/bin/mongoimport;
let $MONGO= C:/Applic/MongoDB/Server/3.6/bin/mongo;
let $MONGOIMPORT= C:/Applic/MongoDB/Server/3.6/bin/mongoimport;
#set connect_enable_mongo=1;
set connect_enable_mongo=1;
--echo #
--echo # Test the MONGO table type
......@@ -130,7 +130,9 @@ DROP TABLE t1;
--echo #
--echo # try CRUD operations
--echo #
--disable_query_log
--exec $MONGO --eval "db.testcoll.drop()" --quiet
--enable_query_log
eval CREATE TABLE t1 (_id INT(4) NOT NULL, msg CHAR(64))
ENGINE=CONNECT TABLE_TYPE=$TYPE TABNAME='testcoll'
OPTION_LIST='Driver=$DRV,Version=$VERS' $CONN;
......@@ -147,7 +149,9 @@ DROP TABLE t1;
--echo #
--echo # List states whose population is equal or more than 10 millions
--echo #
--disable_query_log
--exec $MONGO --eval "db.cities.drop()" --quiet
--enable_query_log
--exec $MONGOIMPORT --quiet $MTR_SUITE_DIR/std_data/cities.json
eval CREATE TABLE t1 (
_id char(5) NOT NULL,
......@@ -204,4 +208,4 @@ SELECT * FROM t1;
DROP TABLE t1;
--exec $MONGO --eval "db.testcoll.drop()" --quiet
#set connect_enable_mongo=0;
set connect_enable_mongo=0;
......@@ -56,7 +56,7 @@ SELECT * FROM t5;
eval CREATE TABLE total (a int, b char(10))
ENGINE=CONNECT TABLE_TYPE=TBL TABLE_LIST='t1,t2,t3,t4,t5'
OPTION_LIST='thread=yes,port=$PORT';
set connect_xtrace=1;
set connect_xtrace=96;
SELECT * FROM total order by a desc;
set connect_xtrace=0;
......@@ -85,7 +85,7 @@ 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';
set connect_xtrace=1;
set connect_xtrace=96;
SELECT * FROM total order by v desc;
set connect_xtrace=0;
DROP TABLE t1,t2,total;
......@@ -101,7 +101,7 @@ 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';
set connect_xtrace=1;
set connect_xtrace=96;
SELECT * FROM total order by v desc;
set connect_xtrace=0;
......
......@@ -29,6 +29,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
friend class TXTFAM;
friend class DBFBASE;
friend class UNZIPUTL;
friend class JSONCOL;
public:
// Constructor
DOSDEF(void);
......
This diff is collapsed.
......@@ -15,6 +15,7 @@ enum JMODE {MODE_OBJECT, MODE_ARRAY, MODE_VALUE};
typedef class JSONDEF *PJDEF;
typedef class TDBJSON *PJTDB;
typedef class JSONCOL *PJCOL;
class TDBJSN;
/***********************************************************************/
/* The JSON tree node. Can be an Object or an Array. */
......@@ -29,6 +30,47 @@ typedef struct _jnode {
int Nx; // Next to read row number
} JNODE, *PJNODE;
typedef struct _jncol {
struct _jncol *Next;
char *Name;
char *Fmt;
int Type;
int Len;
int Scale;
bool Cbn;
bool Found;
} JCOL, *PJCL;
/***********************************************************************/
/* Class used to get the columns of a mongo collection. */
/***********************************************************************/
class JSONDISC : public BLOCK {
public:
// Constructor
JSONDISC(PGLOBAL g, int *lg);
// Functions
int GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt);
bool Find(PGLOBAL g, PJVAL jvp, int j);
void AddColumn(PGLOBAL g);
// Members
JCOL jcol;
PJCL jcp, fjcp, pjcp;
PVAL valp;
PJDEF tdp;
TDBJSN *tjnp;
PJTDB tjsp;
PJPR jpp;
PJSON jsp;
PJOB row;
PCSZ sep;
char colname[65], fmt[129], buf[16];
int *length;
int i, n, bf, ncol, lvl;
bool all;
}; // end of JSONDISC
/***********************************************************************/
/* JSON table. */
/***********************************************************************/
......@@ -36,13 +78,13 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */
friend class TDBJSON;
friend class TDBJSN;
friend class TDBJCL;
friend class JSONDISC;
#if defined(CMGO_SUPPORT)
friend class CMGFAM;
#endif // CMGO_SUPPORT
#if defined(JAVA_SUPPORT)
friend class JMGFAM;
#endif // JAVA_SUPPORT
friend PQRYRES JSONColumns(PGLOBAL, PCSZ, PCSZ, PTOS, bool);
public:
// Constructor
JSONDEF(void);
......
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