summaryrefslogtreecommitdiff
path: root/storage/connect
diff options
context:
space:
mode:
Diffstat (limited to 'storage/connect')
-rw-r--r--storage/connect/CMakeLists.txt9
-rw-r--r--storage/connect/connect.cc2
-rw-r--r--storage/connect/domdoc.cpp4
-rw-r--r--storage/connect/filamtxt.cpp6
-rw-r--r--storage/connect/filamvct.cpp28
-rw-r--r--storage/connect/global.h4
-rw-r--r--storage/connect/ha_connect.cc134
-rw-r--r--storage/connect/ha_connect.h6
-rw-r--r--storage/connect/javaconn.cpp41
-rw-r--r--storage/connect/javaconn.h1
-rw-r--r--storage/connect/jdbconn.cpp38
-rw-r--r--storage/connect/jmgoconn.cpp6
-rw-r--r--storage/connect/json.h3
-rw-r--r--storage/connect/jsonudf.cpp6
-rw-r--r--storage/connect/mycat.cc15
-rw-r--r--storage/connect/mysql-test/connect/disabled.def23
-rw-r--r--storage/connect/mysql-test/connect/r/jdbc.result3
-rw-r--r--storage/connect/mysql-test/connect/r/json_java_2.result1
-rw-r--r--storage/connect/mysql-test/connect/r/json_java_3.result1
-rw-r--r--storage/connect/mysql-test/connect/r/mongo_java_2.result1
-rw-r--r--storage/connect/mysql-test/connect/r/mongo_java_3.result1
-rw-r--r--storage/connect/mysql-test/connect/r/mysql_exec.result6
-rw-r--r--storage/connect/mysql-test/connect/r/odbc_postgresql.result18
-rw-r--r--storage/connect/mysql-test/connect/r/xml2.result31
-rw-r--r--storage/connect/mysql-test/connect/t/json_java_2.test2
-rw-r--r--storage/connect/mysql-test/connect/t/json_java_3.test2
-rw-r--r--storage/connect/mysql-test/connect/t/mongo_java_2.test2
-rw-r--r--storage/connect/mysql-test/connect/t/mongo_java_3.test2
-rw-r--r--storage/connect/mysql-test/connect/t/xml2.test36
-rw-r--r--storage/connect/odbconn.cpp10
-rw-r--r--storage/connect/tabext.cpp8
-rw-r--r--storage/connect/tabjdbc.cpp9
-rw-r--r--storage/connect/tabjmg.cpp11
-rw-r--r--storage/connect/tabjson.h1
-rw-r--r--storage/connect/tabmysql.cpp11
-rw-r--r--storage/connect/tabodbc.cpp13
-rw-r--r--storage/connect/tabpivot.cpp166
-rw-r--r--storage/connect/tabutil.cpp2
-rw-r--r--storage/connect/tabvct.cpp6
-rw-r--r--storage/connect/user_connect.cc1
40 files changed, 349 insertions, 321 deletions
diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt
index 6e8c8baf90e..0ca794df230 100644
--- a/storage/connect/CMakeLists.txt
+++ b/storage/connect/CMakeLists.txt
@@ -109,6 +109,7 @@ IF(CONNECT_WITH_LIBXML2)
FIND_PACKAGE(LibXml2)
IF (LIBXML2_FOUND)
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
+ SET(ZLIB_LIBRARY "z") # see ZLIB_INCLUDE_DIR below
SET(XML_LIBRARY ${LIBXML2_LIBRARIES})
SET(CONNECT_SOURCES ${CONNECT_SOURCES} libdoc.cpp libdoc.h)
add_definitions(-DLIBXML2_SUPPORT)
@@ -326,6 +327,14 @@ IF(NOT TARGET connect)
RETURN()
ENDIF()
+# Don't link with bundled zlib and systel libxml2 at the same time.
+# System libxml2 uses system zlib, might conflict with the bundled one.
+IF (XML_LIBRARY AND BUILD_BUNDLED_ZLIB)
+ GET_PROPERTY(INCS TARGET connect PROPERTY INCLUDE_DIRECTORIES)
+ LIST(REMOVE_ITEM INCS ${ZLIB_INCLUDE_DIR})
+ SET_PROPERTY(TARGET connect PROPERTY INCLUDE_DIRECTORIES ${INCS})
+ENDIF()
+
IF(WIN32)
IF (libmongoc-1.0_FOUND)
SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS
diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc
index 39123b18c59..21bca637eab 100644
--- a/storage/connect/connect.cc
+++ b/storage/connect/connect.cc
@@ -254,7 +254,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
try {
if (!c1) {
- if (mode == MODE_INSERT)
+// if (mode == MODE_INSERT) or CHECK TABLE
// Allocate all column blocks for that table
tdbp->ColDB(g, NULL, 0);
diff --git a/storage/connect/domdoc.cpp b/storage/connect/domdoc.cpp
index ba8eb829abd..9ae34a3b9ef 100644
--- a/storage/connect/domdoc.cpp
+++ b/storage/connect/domdoc.cpp
@@ -84,8 +84,8 @@ DOMDOC::DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
: XMLDOCUMENT(nsl, nsdf, enc)
{
assert (!fp || fp->Type == TYPE_FB_XML);
- Docp = (fp) ? ((PXBLOCK)fp)->Docp : NULL;
- Nlist = NULL;
+ Docp = (fp) ? ((PXBLOCK)fp)->Docp : (MSXML2::IXMLDOMDocumentPtr)NULL;
+ Nlist = NULL;
Hr = 0;
} // end of DOMDOC constructor
diff --git a/storage/connect/filamtxt.cpp b/storage/connect/filamtxt.cpp
index 7c222eb3c80..ca48fc765a1 100644
--- a/storage/connect/filamtxt.cpp
+++ b/storage/connect/filamtxt.cpp
@@ -427,7 +427,7 @@ int TXTFAM::DeleteSortedRows(PGLOBAL g)
for (i = 0; i < Posar->GetNval(); i++) {
if ((irc = InitDelete(g, Posar->GetIntValue(ix[i]),
- Sosar->GetIntValue(ix[i])) == RC_FX))
+ Sosar->GetIntValue(ix[i]))) == RC_FX)
goto err;
// Now delete the sorted rows
@@ -1173,11 +1173,11 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
remove(filetemp); // May still be there from previous error
if (rename(filename, filetemp)) { // Save file for security
- sprintf(g->Message, MSG(RENAME_ERROR),
+ snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
filename, filetemp, strerror(errno));
throw 51;
} else if (rename(tempname, filename)) {
- sprintf(g->Message, MSG(RENAME_ERROR),
+ snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file
throw 52;
diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp
index dd827d084fa..6d0779b150a 100644
--- a/storage/connect/filamvct.cpp
+++ b/storage/connect/filamvct.cpp
@@ -348,7 +348,7 @@ int VCTFAM::Cardinality(PGLOBAL g)
} // endif split
- return (Block) ? ((Block - 1) * Nrec + Last) : 0;
+ return (Block) ? ((Block - 1) * Nrec + Last) : 0;
} // end of Cardinality
/***********************************************************************/
@@ -510,7 +510,8 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g)
for (; cp; cp = (PVCTCOL)cp->Next)
cp->Blk = AllocValBlock(g, NewBlock + Nrec * cp->Deplac,
cp->Buf_Type, Nrec, cp->Format.Length,
- cp->Format.Prec, chk);
+ cp->Format.Prec, chk, true,
+ cp->IsUnsigned());
return InitInsert(g); // Initialize inserting
} else {
@@ -544,7 +545,8 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g)
for (; cp; cp = (PVCTCOL)cp->Next)
if (!cp->IsSpecial()) // Not a pseudo column
cp->Blk = AllocValBlock(g, NULL, cp->Buf_Type, Nrec,
- cp->Format.Length, cp->Format.Prec);
+ cp->Format.Length, cp->Format.Prec,
+ true, true, cp->IsUnsigned());
} //endif mode
@@ -1511,7 +1513,8 @@ bool VCMFAM::AllocateBuffer(PGLOBAL g)
for (cp = (PVCTCOL)Tdbp->GetColumns(); cp; cp = (PVCTCOL)cp->Next)
if (!cp->IsSpecial()) { // Not a pseudo column
cp->Blk = AllocValBlock(g, (void*)1, cp->Buf_Type, Nrec,
- cp->Format.Length, cp->Format.Prec);
+ cp->Format.Length, cp->Format.Prec,
+ true, true, cp->IsUnsigned());
cp->AddStatus(BUF_MAPPED);
} // endif IsSpecial
@@ -2062,7 +2065,7 @@ bool VECFAM::AllocateBuffer(PGLOBAL g)
for (cp = (PVCTCOL)tdbp->Columns; cp; cp = (PVCTCOL)cp->Next)
cp->Blk = AllocValBlock(g, To_Bufs[cp->Index - 1],
cp->Buf_Type, Nrec, cp->Format.Length,
- cp->Format.Prec, chk);
+ cp->Format.Prec, chk, true, cp->IsUnsigned());
return InitInsert(g);
} else {
@@ -2111,7 +2114,8 @@ bool VECFAM::AllocateBuffer(PGLOBAL g)
for (cp = (PVCTCOL)tdbp->Columns; cp; cp = (PVCTCOL)cp->Next)
if (!cp->IsSpecial()) // Not a pseudo column
cp->Blk = AllocValBlock(g, NULL, cp->Buf_Type, Nrec,
- cp->Format.Length, cp->Format.Prec);
+ cp->Format.Length, cp->Format.Prec,
+ true, true, cp->IsUnsigned());
} // endif mode
@@ -2449,11 +2453,11 @@ int VECFAM::RenameTempFile(PGLOBAL g)
remove(filetemp); // May still be there from previous error
if (rename(filename, filetemp)) { // Save file for security
- sprintf(g->Message, MSG(RENAME_ERROR),
+ snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
filename, filetemp, strerror(errno));
rc = RC_FX;
} else if (rename(tempname, filename)) {
- sprintf(g->Message, MSG(RENAME_ERROR),
+ snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file
rc = RC_FX;
@@ -2882,7 +2886,8 @@ bool VMPFAM::AllocateBuffer(PGLOBAL g)
for (cp = (PVCTCOL)Tdbp->GetColumns(); cp; cp = (PVCTCOL)cp->Next)
if (!cp->IsSpecial()) { // Not a pseudo column
cp->Blk = AllocValBlock(g, (void*)1, cp->Buf_Type, Nrec,
- cp->Format.Length, cp->Format.Prec);
+ cp->Format.Length, cp->Format.Prec,
+ true, true, cp->IsUnsigned());
cp->AddStatus(BUF_MAPPED);
} // endif IsSpecial
@@ -3664,7 +3669,7 @@ bool BGVFAM::AllocateBuffer(PGLOBAL g)
for (; cp; cp = (PVCTCOL)cp->Next)
cp->Blk = AllocValBlock(g, NewBlock + Nrec * cp->Deplac,
cp->Buf_Type, Nrec, cp->Format.Length,
- cp->Format.Prec, chk);
+ cp->Format.Prec, chk, true, cp->IsUnsigned());
InitInsert(g); // Initialize inserting
@@ -3712,7 +3717,8 @@ bool BGVFAM::AllocateBuffer(PGLOBAL g)
for (; cp; cp = (PVCTCOL)cp->Next)
if (!cp->IsSpecial()) // Not a pseudo column
cp->Blk = AllocValBlock(g, NULL, cp->Buf_Type, Nrec,
- cp->Format.Length, cp->Format.Prec);
+ cp->Format.Length, cp->Format.Prec,
+ true, true, cp->IsUnsigned());
} //endif mode
diff --git a/storage/connect/global.h b/storage/connect/global.h
index 472d09408c3..36e8a311124 100644
--- a/storage/connect/global.h
+++ b/storage/connect/global.h
@@ -1,7 +1,7 @@
/***********************************************************************/
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright MariaDB Corporation Ab */
-/* Author Olivier Bertrand 1993-2017 */
+/* Author Olivier Bertrand 1993-2018 */
/***********************************************************************/
/***********************************************************************/
@@ -192,7 +192,7 @@ typedef struct _global { /* Global structure */
PACTIVITY Activityp;
char Message[MAX_STR];
ulong More; /* Used by jsonudf */
- int Createas; /* To pass info to created table */
+ int Createas; /* To pass multi to ext tables */
void *Xchk; /* indexes in create/alter */
short Alchecked; /* Checked for ALTER */
short Mrr; /* True when doing mrr */
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index af329c0c8df..58b112b1f26 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -107,13 +107,9 @@
#define MYSQL_SERVER 1
#define DONT_DEFINE_VOID
-#include "sql_class.h"
-#include "create_options.h"
-#include "mysql_com.h"
-#include "field.h"
+#include <my_global.h>
#include "sql_parse.h"
#include "sql_base.h"
-#include <sys/stat.h>
#include "sql_partition.h"
#undef OFFSET
@@ -174,9 +170,9 @@
#define JSONMAX 10 // JSON Default max grp size
extern "C" {
- char version[]= "Version 1.06.0007 March 11, 2018";
+ char version[]= "Version 1.06.0008 October 06, 2018";
#if defined(__WIN__)
- char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__;
+ char compver[]= "Version 1.06.0008 " __DATE__ " " __TIME__;
char slash= '\\';
#else // !__WIN__
char slash= '/';
@@ -1782,13 +1778,13 @@ bool ha_connect::CheckVirtualIndex(TABLE_SHARE *s)
bool ha_connect::IsPartitioned(void)
{
#ifdef WITH_PARTITION_STORAGE_ENGINE
- if (tshp)
+ if (tshp)
return tshp->partition_info_str_len > 0;
else if (table && table->part_info)
return true;
else
#endif
- return false;
+ return false;
} // end of IsPartitioned
@@ -2813,7 +2809,7 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
htrc("Cond type=%d\n", cond->type());
if (cond->type() == COND::COND_ITEM) {
- char *pb0, *pb1, *pb2, *ph0, *ph1, *ph2;
+ char *pb0, *pb1, *pb2, *ph0= 0, *ph1= 0, *ph2= 0;
bool bb = false, bh = false;
Item_cond *cond_item= (Item_cond *)cond;
@@ -3294,6 +3290,58 @@ ha_rows ha_connect::records()
} // end of records
+int ha_connect::check(THD* thd, HA_CHECK_OPT* check_opt)
+{
+ int rc = HA_ADMIN_OK;
+ PGLOBAL g = ((table && table->in_use) ? GetPlug(table->in_use, xp) :
+ (xp) ? xp->g : NULL);
+ DBUG_ENTER("ha_connect::check");
+
+ if (!g || !table || xmod != MODE_READ)
+ DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
+
+ // Do not close the table if it was opened yet (possible?)
+ if (IsOpened()) {
+ if (IsPartitioned() && CheckColumnList(g)) // map can have been changed
+ rc = HA_ADMIN_CORRUPT;
+ else if (tdbp->OpenDB(g)) // Rewind table
+ rc = HA_ADMIN_CORRUPT;
+
+ } else if (xp->CheckQuery(valid_query_id)) {
+ tdbp = NULL; // Not valid anymore
+
+ if (OpenTable(g, false))
+ rc = HA_ADMIN_CORRUPT;
+
+ } else // possible?
+ DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
+
+ if (rc == HA_ADMIN_OK) {
+ TABTYPE type = GetTypeID(GetStringOption("Type", "*"));
+
+ if (IsFileType(type)) {
+ if (check_opt->flags & T_MEDIUM) {
+ // TO DO
+ do {
+ if ((rc = CntReadNext(g, tdbp)) == RC_FX)
+ break;
+
+ } while (rc != RC_EF);
+
+ rc = (rc == RC_EF) ? HA_ADMIN_OK : HA_ADMIN_CORRUPT;
+ } else if (check_opt->flags & T_EXTEND) {
+ // TO DO
+ } // endif's flags
+
+ } // endif file type
+
+ } else
+ PushWarning(g, thd, 1);
+
+ DBUG_RETURN(rc);
+} // end of check
+
+
/**
Return an error message specific to this handler.
@@ -3307,23 +3355,16 @@ bool ha_connect::get_error_message(int error, String* buf)
{
DBUG_ENTER("ha_connect::get_error_message");
- if (xp && xp->g) {
- PGLOBAL g= xp->g;
- char msg[3072]; // MAX_STR * 3
- uint dummy_errors;
- uint32 len= copy_and_convert(msg, strlen(g->Message) * 3,
- system_charset_info,
- g->Message, strlen(g->Message),
- &my_charset_latin1,
- &dummy_errors);
+ if (xp && xp->g) {
+ PGLOBAL g = xp->g;
- if (trace(1))
- htrc("GEM(%d): len=%u %s\n", error, len, g->Message);
+ if (trace(1))
+ htrc("GEM(%d): %s\n", error, g->Message);
- msg[len]= '\0';
- buf->copy(msg, (uint)strlen(msg), system_charset_info);
- } else
- buf->copy("Cannot retrieve msg", 19, system_charset_info);
+ buf->append(ErrConvString(g->Message, strlen(g->Message),
+ &my_charset_latin1).ptr());
+ } else
+ buf->append("Cannot retrieve error message");
DBUG_RETURN(false);
} // end of get_error_message
@@ -3436,7 +3477,7 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
rc = 0;
} else
- rc = HA_ERR_INTERNAL_ERROR;
+ rc = HA_ERR_CRASHED_ON_USAGE; // Table must be repaired
} // endif rc
@@ -3452,6 +3493,9 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
rc = HA_ERR_INTERNAL_ERROR;
} // end catch
+ if (rc)
+ my_message(ER_WARN_DATA_OUT_OF_RANGE, g->Message, MYF(0));
+
return rc;
} // end of optimize
@@ -4513,14 +4557,16 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
// case SQLCOM_REPLACE_SELECT:
// newmode= MODE_UPDATE; // To be checked
// break;
- case SQLCOM_DELETE:
- case SQLCOM_DELETE_MULTI:
+ case SQLCOM_DELETE_MULTI:
+ *cras = true;
+ case SQLCOM_DELETE:
case SQLCOM_TRUNCATE:
newmode= MODE_DELETE;
break;
- case SQLCOM_UPDATE:
case SQLCOM_UPDATE_MULTI:
- newmode= MODE_UPDATE;
+ *cras = true;
+ case SQLCOM_UPDATE:
+ newmode= MODE_UPDATE;
break;
case SQLCOM_SELECT:
case SQLCOM_OPTIMIZE:
@@ -4545,8 +4591,10 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
newmode= MODE_ANY;
break;
// } // endif partitioned
-
- default:
+ case SQLCOM_REPAIR: // TODO implement it
+ newmode = MODE_UPDATE;
+ break;
+ default:
htrc("Unsupported sql_command=%d\n", thd_sql_command(thd));
strcpy(g->Message, "CONNECT Unsupported command");
my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0));
@@ -4558,17 +4606,18 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
switch (thd_sql_command(thd)) {
case SQLCOM_CREATE_TABLE:
*chk= true;
- *cras= true;
+ break;
+ case SQLCOM_UPDATE_MULTI:
+ case SQLCOM_DELETE_MULTI:
+ *cras= true;
case SQLCOM_INSERT:
case SQLCOM_LOAD:
case SQLCOM_INSERT_SELECT:
// case SQLCOM_REPLACE:
// case SQLCOM_REPLACE_SELECT:
case SQLCOM_DELETE:
- case SQLCOM_DELETE_MULTI:
case SQLCOM_TRUNCATE:
case SQLCOM_UPDATE:
- case SQLCOM_UPDATE_MULTI:
case SQLCOM_SELECT:
case SQLCOM_OPTIMIZE:
case SQLCOM_SET_OPTION:
@@ -4596,8 +4645,9 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
break;
// } // endif partitioned
- case SQLCOM_CHECK: // TODO implement it
- case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT...
+ case SQLCOM_CHECK: // TODO implement it
+ case SQLCOM_ANALYZE: // TODO implement it
+ case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT...
newmode= MODE_READ;
break;
default:
@@ -4879,7 +4929,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
#endif // 0
if (cras)
- g->Createas= 1; // To tell created table to ignore FLAG
+ g->Createas= 1; // To tell external tables of a multi-table command
if (trace(1)) {
#if 0
@@ -5570,7 +5620,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
} // endif p
} else if (ttp != TAB_ODBC || !(fnc & (FNC_TABLE | FNC_COL)))
- tab = table_s->table_name.str; // Default value
+ tab = (char*)table_s->table_name.str; // Default value
} // endif tab
@@ -6202,9 +6252,9 @@ int ha_connect::create(const char *name, TABLE *table_arg,
LEX_STRING cnc = table_arg->s->connect_string;
#ifdef WITH_PARTITION_STORAGE_ENGINE
partition_info *part_info= table_arg->part_info;
-#else
+#else // !WITH_PARTITION_STORAGE_ENGINE
#define part_info 0
-#endif // WITH_PARTITION_STORAGE_ENGINE
+#endif // !WITH_PARTITION_STORAGE_ENGINE
xp= GetUser(thd, xp);
PGLOBAL g= xp->g;
@@ -7260,7 +7310,7 @@ maria_declare_plugin(connect)
0x0107, /* version number (1.05) */
NULL, /* status variables */
connect_system_variables, /* system variables */
- "1.06.0007", /* string version */
+ "1.06.0008", /* string version */
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
}
maria_declare_plugin_end;
diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h
index 4c5bf5856cc..07b1c2d2e7d 100644
--- a/storage/connect/ha_connect.h
+++ b/storage/connect/ha_connect.h
@@ -347,11 +347,7 @@ PFIL CondFilter(PGLOBAL g, Item *cond);
//PFIL CheckFilter(PGLOBAL g);
/** admin commands - called from mysql_admin_table */
-virtual int check(THD* thd, HA_CHECK_OPT* check_opt)
-{
- // TODO: implement it
- return HA_ADMIN_OK; // Just to avoid error message with checktables
-} // end of check
+virtual int check(THD* thd, HA_CHECK_OPT* check_opt);
/**
Number of rows in table. It will only be called if
diff --git a/storage/connect/javaconn.cpp b/storage/connect/javaconn.cpp
index ec10b125737..f919344f20b 100644
--- a/storage/connect/javaconn.cpp
+++ b/storage/connect/javaconn.cpp
@@ -82,29 +82,6 @@ GETDEF JAVAConn::GetDefaultJavaVMInitArgs = NULL;
#endif // !_DEBUG
/***********************************************************************/
-/* Allocate the structure used to refer to the result set. */
-/***********************************************************************/
-static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, PCSZ db,
- PCSZ tab, PQRYRES qrp)
-{
- JCATPARM *cap;
-
-#if defined(_DEBUG)
- assert(qrp);
-#endif
-
- if ((cap = (JCATPARM *)PlgDBSubAlloc(g, NULL, sizeof(JCATPARM)))) {
- memset(cap, 0, sizeof(JCATPARM));
- cap->Id = fid;
- cap->Qrp = qrp;
- cap->DB = db;
- cap->Tab = tab;
- } // endif cap
-
- return cap;
-} // end of AllocCatInfo
-
-/***********************************************************************/
/* JAVAConn construction/destruction. */
/***********************************************************************/
JAVAConn::JAVAConn(PGLOBAL g, PCSZ wrapper)
@@ -138,6 +115,16 @@ JAVAConn::JAVAConn(PGLOBAL g, PCSZ wrapper)
// EndCom();
// } // end of ~JAVAConn
+char *JAVAConn::GetUTFString(jstring s)
+{
+ char *str;
+ const char *utf = env->GetStringUTFChars(s, nullptr);
+
+ str = PlugDup(m_G, utf);
+ env->ReleaseStringUTFChars(s, utf);
+ env->DeleteLocalRef(s);
+ return str;
+} // end of GetUTFString
/***********************************************************************/
/* Screen for errors. */
@@ -152,17 +139,15 @@ bool JAVAConn::Check(jint rc)
"toString", "()Ljava/lang/String;");
if (exc != nullptr && tid != nullptr) {
- jstring s = (jstring)env->CallObjectMethod(exc, tid);
- const char *utf = env->GetStringUTFChars(s, NULL);
- env->DeleteLocalRef(s);
- Msg = PlugDup(m_G, utf);
+ s = (jstring)env->CallObjectMethod(exc, tid);
+ Msg = GetUTFString(s);
} else
Msg = "Exception occured";
env->ExceptionClear();
} else if (rc < 0) {
s = (jstring)env->CallObjectMethod(job, errid);
- Msg = (char*)env->GetStringUTFChars(s, NULL);
+ Msg = GetUTFString(s);
} else
Msg = NULL;
diff --git a/storage/connect/javaconn.h b/storage/connect/javaconn.h
index 54b7c4e92b7..73812f6ab3b 100644
--- a/storage/connect/javaconn.h
+++ b/storage/connect/javaconn.h
@@ -90,6 +90,7 @@ public:
// Java operations
protected:
+ char *GetUTFString(jstring s);
bool gmID(PGLOBAL g, jmethodID& mid, const char *name, const char *sig);
bool Check(jint rc = 0);
diff --git a/storage/connect/jdbconn.cpp b/storage/connect/jdbconn.cpp
index 7e42ca126d0..e54eeb0fcdd 100644
--- a/storage/connect/jdbconn.cpp
+++ b/storage/connect/jdbconn.cpp
@@ -314,10 +314,6 @@ static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, PCSZ db,
{
JCATPARM *cap;
-#if defined(_DEBUG)
- assert(qrp);
-#endif
-
if ((cap = (JCATPARM *)PlgDBSubAlloc(g, NULL, sizeof(JCATPARM)))) {
memset(cap, 0, sizeof(JCATPARM));
cap->Id = fid;
@@ -699,21 +695,14 @@ bool JDBConn::SetUUID(PGLOBAL g, PTDBJDBC tjp)
goto err;
} // endif rc
- // Returns 666 is case of error
- //jtyp = env->CallIntMethod(job, typid, 5, nullptr);
+ // Should return 666 is case of error (not done yet)
+ ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr);
- //if (Check((jtyp == 666) ? -1 : 1)) {
- // sprintf(g->Message, "Getting jtyp: %s", Msg);
+ //if (Check((ctyp == 666) ? -1 : 1)) {
+ // sprintf(g->Message, "Getting ctyp: %s", Msg);
// goto err;
//} // endif ctyp
- ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr);
-
- if (Check(ctyp)) {
- sprintf(g->Message, "Getting ctyp: %s", Msg);
- goto err;
- } // endif ctyp
-
if (ctyp == 1111)
((PJDBCCOL)colp)->uuid = true;
@@ -828,11 +817,11 @@ bool JDBConn::Connect(PJPARM sop)
jstring s = (jstring)env->CallObjectMethod(job, qcid);
if (s != nullptr) {
- char *qch = (char*)env->GetStringUTFChars(s, NULL);
+ char *qch = GetUTFString(s);
m_IDQuoteChar[0] = *qch;
} else {
s = (jstring)env->CallObjectMethod(job, errid);
- Msg = (char*)env->GetStringUTFChars(s, NULL);
+ Msg = GetUTFString(s);
} // endif s
} // endif qcid
@@ -1010,7 +999,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr;
if (cn) {
- field = env->GetStringUTFChars(cn, NULL);
+ field = GetUTFString(cn);
val->SetValue_psz((PSZ)field);
} else
val->Reset();
@@ -1084,8 +1073,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr;
if (cn) {
- const char *field = env->GetStringUTFChars(cn, NULL);
- val->SetValue_psz((PSZ)field);
+ val->SetValue_psz((PSZ)GetUTFString(cn));
} else
val->Reset();
@@ -1364,19 +1352,19 @@ bool JDBConn::SetParam(JDBCCOL *colp)
for (i = 0, n = 0; i < size; i++) {
crp = qrp->Colresp;
js = (jstring)env->GetObjectArrayElement(s, n++);
- sval = (PSZ)env->GetStringUTFChars(js, 0);
+ sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i);
crp = crp->Next;
js = (jstring)env->GetObjectArrayElement(s, n++);
- sval = (PSZ)env->GetStringUTFChars(js, 0);
+ sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i);
crp = crp->Next;
js = (jstring)env->GetObjectArrayElement(s, n++);
- sval = (PSZ)env->GetStringUTFChars(js, 0);
+ sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i);
crp = crp->Next;
js = (jstring)env->GetObjectArrayElement(s, n++);
- sval = (PSZ)env->GetStringUTFChars(js, 0);
+ sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i);
} // endfor i
@@ -1462,7 +1450,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
return NULL;
} // endif label
- name = env->GetStringUTFChars(label, NULL);
+ name = GetUTFString(label);
crp = qrp->Colresp; // Column_Name
crp->Kdata->SetValue((char*)name, i);
n = env->GetIntArrayElements(val, 0);
diff --git a/storage/connect/jmgoconn.cpp b/storage/connect/jmgoconn.cpp
index 33668e69988..bd1ddadd80d 100644
--- a/storage/connect/jmgoconn.cpp
+++ b/storage/connect/jmgoconn.cpp
@@ -522,7 +522,7 @@ PSZ JMgoConn::GetDocument(void)
jdc = (jstring)env->CallObjectMethod(job, getdocid);
if (jdc)
- doc = (PSZ)env->GetStringUTFChars(jdc, NULL);
+ doc = (PSZ)GetUTFString(jdc);
} // endif getdocid
@@ -690,7 +690,7 @@ jobject JMgoConn::MakeDoc(PGLOBAL g, PJNCOL jcp)
} // endif Jncolp
- return parent;
+ return parent;
} // end of MakeDoc
/***********************************************************************/
@@ -807,7 +807,7 @@ PSZ JMgoConn::GetColumnValue(PSZ path)
fn = (jstring)env->CallObjectMethod(job, objfldid, jn);
if (fn)
- fld = (PSZ)env->GetStringUTFChars(fn, NULL);
+ fld = (PSZ)GetUTFString(fn);
} // endif objfldid
diff --git a/storage/connect/json.h b/storage/connect/json.h
index dcc97287420..cc394401cc3 100644
--- a/storage/connect/json.h
+++ b/storage/connect/json.h
@@ -44,6 +44,9 @@ typedef struct {
int len;
} STRG, *PSG;
+char *NextChr(PSZ s, char sep);
+char *GetJsonNull(void);
+
PJSON ParseJson(PGLOBAL g, char *s, int n, int *prty = NULL, bool *b = NULL);
PJAR ParseArray(PGLOBAL g, int& i, STRG& src, bool *pty);
PJOB ParseObject(PGLOBAL g, int& i, STRG& src, bool *pty);
diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp
index 794a84f22c4..26455d572b6 100644
--- a/storage/connect/jsonudf.cpp
+++ b/storage/connect/jsonudf.cpp
@@ -1620,7 +1620,7 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
if (AllocSarea(g, ml)) {
char errmsg[MAX_STR];
- snprintf(errmsg, sizeof(errmsg)-1, MSG(WORK_AREA), g->Message);
+ snprintf(errmsg, sizeof(errmsg) - 1, MSG(WORK_AREA), g->Message);
strcpy(g->Message, errmsg);
return true;
} // endif SareaAlloc
@@ -1673,7 +1673,7 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
n = strlen(s);
if (IsJson(args, i))
- j = strchr(s, '_') - s + 1;
+ j = (int)(strchr(s, '_') - s + 1);
if (j && n > j) {
s += j;
@@ -4631,7 +4631,7 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
bsp = NULL;
if (!bsp && (bsp = JbinAlloc(g, args, initid->max_length, NULL)))
- strncpy(bsp->Msg, g->Message, 139);
+ strncpy(bsp->Msg, g->Message, BMX);
// Keep result of constant function
g->Xchk = (initid->const_item) ? bsp : NULL;
diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc
index cc8f75b2976..cc5675db5c8 100644
--- a/storage/connect/mycat.cc
+++ b/storage/connect/mycat.cc
@@ -18,7 +18,7 @@
/* ------------- */
/* Version 1.6 */
/* */
-/* Author: Olivier Bertrand 2012 - 2017 */
+/* Author: Olivier Bertrand 2012 - 2018 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -28,20 +28,13 @@
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
-#include <my_config.h>
+#define DONT_DEFINE_VOID
+#include <my_global.h>
-#if defined(__WIN__)
-//#include <windows.h>
-//#include <sqlext.h>
-#elif defined(UNIX)
-#include <sys/types.h>
+#if defined(UNIX)
#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
#include <string.h>
#endif
-#define DONT_DEFINE_VOID
-//#include <mysql/plugin.h>
#include "handler.h"
#undef OFFSET
diff --git a/storage/connect/mysql-test/connect/disabled.def b/storage/connect/mysql-test/connect/disabled.def
index 0dcf030613d..827ed58b835 100644
--- a/storage/connect/mysql-test/connect/disabled.def
+++ b/storage/connect/mysql-test/connect/disabled.def
@@ -9,14 +9,15 @@
# Do not use any TAB characters for whitespace.
#
##############################################################################
-jdbc : Variable settings depend on machine configuration
-jdbc_new : Variable settings depend on machine configuration
-jdbc_oracle : Variable settings depend on machine configuration
-jdbc_postgresql : Variable settings depend on machine configuration
-json_mongo_c : Need MongoDB running and its C Driver installed
-json_java_2 : Need MongoDB running and its Java Driver installed
-json_java_3 : Need MongoDB running and its Java Driver installed
-mongo_c : Need MongoDB running and its C Driver installed
-mongo_java_2 : Need MongoDB running and its Java Driver installed
-mongo_java_3 : Need MongoDB running and its Java Driver installed
-tbl_thread : Bug MDEV-9844,10179,14214 03/01/2018 OB Option THREAD removed
+infoschema-9739 : Crashes with MariaDB 10.0
+jdbc : Variable settings depend on machine configuration
+jdbc_new : Variable settings depend on machine configuration
+jdbc_oracle : Variable settings depend on machine configuration
+jdbc_postgresql : Variable settings depend on machine configuration
+json_mongo_c : Need MongoDB running and its C Driver installed
+json_java_2 : Need MongoDB running and its Java Driver installed
+json_java_3 : Need MongoDB running and its Java Driver installed
+mongo_c : Need MongoDB running and its C Driver installed
+mongo_java_2 : Need MongoDB running and its Java Driver installed
+mongo_java_3 : Need MongoDB running and its Java Driver installed
+tbl_thread : Bug MDEV-9844,10179,14214 03/01/2018 OB Option THREAD removed
diff --git a/storage/connect/mysql-test/connect/r/jdbc.result b/storage/connect/mysql-test/connect/r/jdbc.result
index 895b4070d70..1bcd7b736bb 100644
--- a/storage/connect/mysql-test/connect/r/jdbc.result
+++ b/storage/connect/mysql-test/connect/r/jdbc.result
@@ -238,8 +238,7 @@ DROP TABLE t1, connect.emp;
CREATE TABLE t2 (command varchar(128) not null,number int(5) not null flag=1,message varchar(255) flag=2) ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:mariadb://localhost:PORT/connect' OPTION_LIST='User=root,Execsrc=1';
SELECT * FROM t2 WHERE command='drop table tx1';
command number message
-drop table tx1 0 Execute: java.sql.SQLSyntaxErrorException: Unknown table 'connect.tx1'
-Query is : drop table tx1
+drop table tx1 0 Execute: java.sql.SQLSyntaxErrorException: (conn:23) Unknown table 'connect.tx1'
SELECT * FROM t2 WHERE command = 'create table tx1 (a int not null, b char(32), c double(8,2))';
command number message
create table tx1 (a int not null, b char(32), c double(8,2)) 0 Affected rows
diff --git a/storage/connect/mysql-test/connect/r/json_java_2.result b/storage/connect/mysql-test/connect/r/json_java_2.result
index 1a90132dede..ff87d8e2ad7 100644
--- a/storage/connect/mysql-test/connect/r/json_java_2.result
+++ b/storage/connect/mysql-test/connect/r/json_java_2.result
@@ -1,4 +1,3 @@
-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
diff --git a/storage/connect/mysql-test/connect/r/json_java_3.result b/storage/connect/mysql-test/connect/r/json_java_3.result
index 4c5fc94fca6..eb8bfc022d6 100644
--- a/storage/connect/mysql-test/connect/r/json_java_3.result
+++ b/storage/connect/mysql-test/connect/r/json_java_3.result
@@ -1,4 +1,3 @@
-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
diff --git a/storage/connect/mysql-test/connect/r/mongo_java_2.result b/storage/connect/mysql-test/connect/r/mongo_java_2.result
index 67c67653e88..bc186d7137e 100644
--- a/storage/connect/mysql-test/connect/r/mongo_java_2.result
+++ b/storage/connect/mysql-test/connect/r/mongo_java_2.result
@@ -1,4 +1,3 @@
-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
diff --git a/storage/connect/mysql-test/connect/r/mongo_java_3.result b/storage/connect/mysql-test/connect/r/mongo_java_3.result
index 665178bd3ea..30c696fc9eb 100644
--- a/storage/connect/mysql-test/connect/r/mongo_java_3.result
+++ b/storage/connect/mysql-test/connect/r/mongo_java_3.result
@@ -1,4 +1,3 @@
-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
diff --git a/storage/connect/mysql-test/connect/r/mysql_exec.result b/storage/connect/mysql-test/connect/r/mysql_exec.result
index 483fbd9e6a6..add98a6235d 100644
--- a/storage/connect/mysql-test/connect/r/mysql_exec.result
+++ b/storage/connect/mysql-test/connect/r/mysql_exec.result
@@ -30,6 +30,8 @@ insert ignore into t1(id) values(NULL) 1 1 Affected rows
Warning 0 1364 Field 'msg' doesn't have a default value
update t1 set msg = 'Four' where id = 4 0 1 Affected rows
select * from t1 0 2 Result set columns
+Warnings:
+Warning 1105 Result set columns
#
# Checking Using Procedure
#
@@ -43,9 +45,13 @@ CALL p1('insert ignore into t1(id) values(NULL)');
command warnings number message
insert ignore into t1(id) values(NULL) 1 1 Affected rows
Warning 0 1364 Field 'msg' doesn't have a default value
+Warnings:
+Warning 1105 Affected rows
CALL p1('update t1 set msg = "Five" where id = 5');
command warnings number message
update t1 set msg = "Five" where id = 5 0 1 Affected rows
+Warnings:
+Warning 1105 Affected rows
DROP PROCEDURE p1;
DROP TABLE t1;
SELECT * FROM t1;
diff --git a/storage/connect/mysql-test/connect/r/odbc_postgresql.result b/storage/connect/mysql-test/connect/r/odbc_postgresql.result
index 3426d23e29c..dc23dbdb990 100644
--- a/storage/connect/mysql-test/connect/r/odbc_postgresql.result
+++ b/storage/connect/mysql-test/connect/r/odbc_postgresql.result
@@ -99,9 +99,9 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu
mtr public t1 a 4 int4 10 4 0 10 0
mtr public t2 a 4 int4 10 4 0 10 0
mtr public v1 a 4 int4 10 4 0 10 1
-mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0
-mtr schema1 t2 a 1 bpchar 10 60 NULL NULL 0
-mtr schema1 v1 a 1 bpchar 10 60 NULL NULL 1
+mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
+mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0
+mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1
DROP TABLE t1;
# All columns in the schemas "public" and "schema1"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%.%';
@@ -110,16 +110,16 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu
mtr public t1 a 4 int4 10 4 0 10 0
mtr public t2 a 4 int4 10 4 0 10 0
mtr public v1 a 4 int4 10 4 0 10 1
-mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0
-mtr schema1 t2 a 1 bpchar 10 60 NULL NULL 0
-mtr schema1 v1 a 1 bpchar 10 60 NULL NULL 1
+mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
+mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0
+mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1
DROP TABLE t1;
# All tables "t1" in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%.t1';
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
mtr public t1 a 4 int4 10 4 0 10 0
-mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0
+mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
DROP TABLE t1;
# Table "t1" in the schema "public"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.public.t1';
@@ -131,14 +131,14 @@ DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.schema1.t1';
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
-mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0
+mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
DROP TABLE t1;
# All tables "t1" in all schemas (Catalog name is ignored by PostgreSQL)
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='xxx.%.t1';
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
mtr public t1 a 4 int4 10 4 0 10 0
-mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0
+mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
DROP TABLE t1;
#
# Checking tables
diff --git a/storage/connect/mysql-test/connect/r/xml2.result b/storage/connect/mysql-test/connect/r/xml2.result
index eea53bf55c7..b8075fa1928 100644
--- a/storage/connect/mysql-test/connect/r/xml2.result
+++ b/storage/connect/mysql-test/connect/r/xml2.result
@@ -333,37 +333,6 @@ DROP TABLE t1;
#
# Testing Cyrillic
#
-CREATE TABLE t1
-(
-c CHAR(16) CHARACTER SET utf8
-) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='cp1251.xml'
- OPTION_LIST='xmlsup=libxml2,rownode=b';
-SELECT * FROM t1;
-c БВГДЕЖЗ
-INSERT INTO t1 VALUES ('ИКЛМН');
-SELECT c, HEX(c) FROM t1;
-c БВГДЕЖЗ
-HEX(c) D091D092D093D094D095D096D097
-c ИКЛМН
-HEX(c) D098D09AD09BD09CD09D
-DROP TABLE t1;
-CREATE TABLE t1
-(
-c CHAR(16) CHARACTER SET cp1251
-) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='cp1251.xml'
- OPTION_LIST='xmlsup=libxml2,rownode=b';
-SELECT * FROM t1;
-c БВГДЕЖЗ
-c ИКЛМН
-INSERT INTO t1 VALUES ('ОПРСТ');
-SELECT c, HEX(c) FROM t1;
-c БВГДЕЖЗ
-HEX(c) C1C2C3C4C5C6C7
-c ИКЛМН
-HEX(c) C8CACBCCCD
-c ОПРСТ
-HEX(c) CECFD0D1D2
-DROP TABLE t1;
#
# Testing that the underlying file is created with a proper Encoding
#
diff --git a/storage/connect/mysql-test/connect/t/json_java_2.test b/storage/connect/mysql-test/connect/t/json_java_2.test
index bb32eff4e94..2f64d8e2eed 100644
--- a/storage/connect/mysql-test/connect/t/json_java_2.test
+++ b/storage/connect/mysql-test/connect/t/json_java_2.test
@@ -1,7 +1,9 @@
-- source jdbconn.inc
-- source mongo.inc
+--disable_query_log
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo2.jar';
+--enable_query_log
let $DRV= Java;
let $VERS= 2;
let $TYPE= JSON;
diff --git a/storage/connect/mysql-test/connect/t/json_java_3.test b/storage/connect/mysql-test/connect/t/json_java_3.test
index 29e66cd5a1c..cee8343772a 100644
--- a/storage/connect/mysql-test/connect/t/json_java_3.test
+++ b/storage/connect/mysql-test/connect/t/json_java_3.test
@@ -1,7 +1,9 @@
-- source jdbconn.inc
-- source mongo.inc
+--disable_query_log
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo3.jar';
+--enable_query_log
let $DRV= Java;
let $VERS= 3;
let $TYPE= JSON;
diff --git a/storage/connect/mysql-test/connect/t/mongo_java_2.test b/storage/connect/mysql-test/connect/t/mongo_java_2.test
index 21da5dce68f..7dcd028185e 100644
--- a/storage/connect/mysql-test/connect/t/mongo_java_2.test
+++ b/storage/connect/mysql-test/connect/t/mongo_java_2.test
@@ -1,7 +1,9 @@
-- source jdbconn.inc
-- source mongo.inc
+--disable_query_log
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo2.jar';
+--enable_query_log
let $DRV= Java;
let $VERS= 2;
let $TYPE= MONGO;
diff --git a/storage/connect/mysql-test/connect/t/mongo_java_3.test b/storage/connect/mysql-test/connect/t/mongo_java_3.test
index b7584adcc7e..aab16d5e003 100644
--- a/storage/connect/mysql-test/connect/t/mongo_java_3.test
+++ b/storage/connect/mysql-test/connect/t/mongo_java_3.test
@@ -1,7 +1,9 @@
-- source jdbconn.inc
-- source mongo.inc
+--disable_query_log
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo3.jar';
+--enable_query_log
let $DRV= Java;
let $VERS= 3;
let $TYPE= MONGO;
diff --git a/storage/connect/mysql-test/connect/t/xml2.test b/storage/connect/mysql-test/connect/t/xml2.test
index 0f26b8ab5c0..7bbc3dbd87c 100644
--- a/storage/connect/mysql-test/connect/t/xml2.test
+++ b/storage/connect/mysql-test/connect/t/xml2.test
@@ -240,24 +240,24 @@ DROP TABLE t1;
--echo #
--echo # Testing Cyrillic
--echo #
-CREATE TABLE t1
-(
- c CHAR(16) CHARACTER SET utf8
-) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='cp1251.xml'
- OPTION_LIST='xmlsup=libxml2,rownode=b';
-SELECT * FROM t1;
-INSERT INTO t1 VALUES ('ИКЛМН');
-SELECT c, HEX(c) FROM t1;
-DROP TABLE t1;
-CREATE TABLE t1
-(
- c CHAR(16) CHARACTER SET cp1251
-) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='cp1251.xml'
- OPTION_LIST='xmlsup=libxml2,rownode=b';
-SELECT * FROM t1;
-INSERT INTO t1 VALUES ('ОПРСТ');
-SELECT c, HEX(c) FROM t1;
-DROP TABLE t1;
+#CREATE TABLE t1
+#(
+# c CHAR(16) CHARACTER SET utf8
+#) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='cp1251.xml'
+# OPTION_LIST='xmlsup=libxml2,rownode=b';
+#SELECT * FROM t1;
+#INSERT INTO t1 VALUES ('ИКЛМН');
+#SELECT c, HEX(c) FROM t1;
+#DROP TABLE t1;
+#CREATE TABLE t1
+#(
+# c CHAR(16) CHARACTER SET cp1251
+#) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='cp1251.xml'
+# OPTION_LIST='xmlsup=libxml2,rownode=b';
+#SELECT * FROM t1;
+#INSERT INTO t1 VALUES ('ОПРСТ');
+#SELECT c, HEX(c) FROM t1;
+#DROP TABLE t1;
--echo #
diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp
index f7b1a43a95d..6687513fa6c 100644
--- a/storage/connect/odbconn.cpp
+++ b/storage/connect/odbconn.cpp
@@ -2354,11 +2354,11 @@ int ODBConn::GetCatInfo(CATPARM *cap)
if (!Check(rc))
ThrowDBX(rc, fnc, hstmt);
- rc = SQLNumResultCols(hstmt, &ncol);
-
- // n because we no more ignore the first column
- if ((n = (UWORD)qrp->Nbcol) > (UWORD)ncol)
- ThrowDBX(MSG(COL_NUM_MISM));
+ // Some data source do not implement SQLNumResultCols
+ if (Check(SQLNumResultCols(hstmt, &ncol)))
+ // n because we no more ignore the first column
+ if ((n = (UWORD)qrp->Nbcol) > (UWORD)ncol)
+ ThrowDBX(MSG(COL_NUM_MISM));
// Unconditional to handle STRBLK's
pval = (PVAL *)PlugSubAlloc(g, NULL, n * sizeof(PVAL));
diff --git a/storage/connect/tabext.cpp b/storage/connect/tabext.cpp
index 64d401bef15..f2d5eb0e69d 100644
--- a/storage/connect/tabext.cpp
+++ b/storage/connect/tabext.cpp
@@ -125,6 +125,12 @@ EXTDEF::EXTDEF(void)
/***********************************************************************/
bool EXTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
+ if (g->Createas) {
+ strcpy(g->Message,
+ "Multiple-table UPDATE/DELETE commands are not supported");
+ return true;
+ } // endif multi
+
Desc = NULL;
Tabname = GetStringCatInfo(g, "Name",
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
@@ -286,7 +292,7 @@ bool TDBEXT::MakeSrcdef(PGLOBAL g)
char *catp = strstr(Srcdef, "%s");
if (catp) {
- char *fil1, *fil2;
+ char *fil1 = 0, *fil2;
PCSZ ph = ((EXTDEF*)To_Def)->Phpos;
if (!ph)
diff --git a/storage/connect/tabjdbc.cpp b/storage/connect/tabjdbc.cpp
index 275b5edaeae..adb3fc4fb51 100644
--- a/storage/connect/tabjdbc.cpp
+++ b/storage/connect/tabjdbc.cpp
@@ -1157,8 +1157,9 @@ bool TDBXJDC::OpenDB(PGLOBAL g)
/* Get the command to execute. */
/*********************************************************************/
if (!(Cmdlist = MakeCMD(g))) {
- Jcp->Close();
- return true;
+ // Next lines commented out because of CHECK TABLE
+ //Jcp->Close();
+ //return true;
} // endif Query
Rows = 1;
@@ -1189,8 +1190,10 @@ int TDBXJDC::ReadDB(PGLOBAL g)
Fpos++; // Used for progress info
Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next;
return RC_OK;
- } else
+ } else {
+ PushWarning(g, this, 1);
return RC_EF;
+ } // endif Cmdlist
} // end of ReadDB
diff --git a/storage/connect/tabjmg.cpp b/storage/connect/tabjmg.cpp
index 4653973a4db..850d9e5fa9b 100644
--- a/storage/connect/tabjmg.cpp
+++ b/storage/connect/tabjmg.cpp
@@ -72,7 +72,7 @@ bool JMGDISC::Find(PGLOBAL g)
bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
int ncol, int k)
{
- const char *key;
+ const char *key, *utf;
char colname[65];
char fmt[129];
bool rc = true;
@@ -101,7 +101,10 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
continue;
jkey = (jstring)Jcp->env->CallObjectMethod(Jcp->job, bvnameid);
- key = Jcp->env->GetStringUTFChars(jkey, NULL);
+ utf = Jcp->env->GetStringUTFChars(jkey, nullptr);
+ key = PlugDup(g, utf);
+ Jcp->env->ReleaseStringUTFChars(jkey, utf);
+ Jcp->env->DeleteLocalRef(jkey);
if (pcn) {
strncpy(colname, pcn, 64);
@@ -457,8 +460,8 @@ PSZ JMGCOL::GetJpath(PGLOBAL g, bool proj)
} else
*p2++ = *p1;
- *p2 = 0;
- return projpath;
+ *p2 = 0;
+ return projpath;
} else
return Jpath;
diff --git a/storage/connect/tabjson.h b/storage/connect/tabjson.h
index 0341c0f8aa0..2ff72905e86 100644
--- a/storage/connect/tabjson.h
+++ b/storage/connect/tabjson.h
@@ -16,6 +16,7 @@ typedef class JSONDEF *PJDEF;
typedef class TDBJSON *PJTDB;
typedef class JSONCOL *PJCOL;
class TDBJSN;
+PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info);
/***********************************************************************/
/* The JSON tree node. Can be an Object or an Array. */
diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp
index 605b3822430..ceffafac02c 100644
--- a/storage/connect/tabmysql.cpp
+++ b/storage/connect/tabmysql.cpp
@@ -1587,8 +1587,9 @@ bool TDBMYEXC::OpenDB(PGLOBAL g)
/* Get the command to execute. */
/*********************************************************************/
if (!(Cmdlist = MakeCMD(g))) {
- Myc.Close();
- return true;
+ // Next lines commented out because of CHECK TABLE
+ //Myc.Close();
+ //return true;
} // endif Cmdlist
return false;
@@ -1647,8 +1648,10 @@ int TDBMYEXC::ReadDB(PGLOBAL g)
++N;
return RC_OK;
- } else
- return RC_EF;
+ } else {
+ PushWarning(g, this, 1);
+ return RC_EF;
+ } // endif Cmdlist
} // end of ReadDB
diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp
index f7bc3934fbd..fddfb0c0420 100644
--- a/storage/connect/tabodbc.cpp
+++ b/storage/connect/tabodbc.cpp
@@ -1249,9 +1249,10 @@ bool TDBXDBC::OpenDB(PGLOBAL g)
/* Get the command to execute. */
/*********************************************************************/
if (!(Cmdlist = MakeCMD(g))) {
- Ocp->Close();
- return true;
- } // endif Query
+ // Next lines commented out because of CHECK TABLE
+ //Ocp->Close();
+ //return true;
+ } // endif Cmdlist
Rows = 1;
return false;
@@ -1274,8 +1275,10 @@ int TDBXDBC::ReadDB(PGLOBAL g)
Fpos++; // Used for progress info
Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next;
return RC_OK;
- } else
- return RC_EF;
+ } else {
+ PushWarning(g, this, 1);
+ return RC_EF;
+ } // endif Cmdlist
} // end of ReadDB
diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp
index da5d134f347..9121a0453e5 100644
--- a/storage/connect/tabpivot.cpp
+++ b/storage/connect/tabpivot.cpp
@@ -107,12 +107,12 @@ bool PIVAID::SkipColumn(PCOLRES crp, char *skc)
/***********************************************************************/
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
{
- char *p, *query, *colname, *skc, buf[64];
- int ndif, nblin, w = 0;
- bool b = false;
- PVAL valp;
- PQRYRES qrp;
- PCOLRES *pcrp, crp, fncrp = NULL;
+ char *p, *query, *colname, *skc, buf[64];
+ int ndif, nblin, w = 0;
+ bool b = false;
+ PVAL valp;
+ PQRYRES qrp;
+ PCOLRES *pcrp, crp, fncrp = NULL;
try {
// Are there columns to skip?
@@ -186,7 +186,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} // endif picol
- // Prepare the column list
+ // Prepare the column list
for (pcrp = &Qryp->Colresp; crp = *pcrp; )
if (SkipColumn(crp, skc)) {
// Ignore this column
@@ -205,95 +205,95 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} else
pcrp = &crp->Next;
- if (!Rblkp) {
- strcpy(g->Message, MSG(NO_DEF_PIVOTCOL));
- goto err;
- } else if (!fncrp) {
- strcpy(g->Message, MSG(NO_DEF_FNCCOL));
- goto err;
- } // endif
+ if (!Rblkp) {
+ strcpy(g->Message, MSG(NO_DEF_PIVOTCOL));
+ goto err;
+ } else if (!fncrp) {
+ strcpy(g->Message, MSG(NO_DEF_FNCCOL));
+ goto err;
+ } // endif
- if (Tabsrc) {
- Myc.Close();
- b = false;
+ if (Tabsrc) {
+ Myc.Close();
+ b = false;
- // Before calling sort, initialize all
- nblin = Qryp->Nblin;
+ // Before calling sort, initialize all
+ nblin = Qryp->Nblin;
- Index.Size = nblin * sizeof(int);
- Index.Sub = TRUE; // Should be small enough
+ Index.Size = nblin * sizeof(int);
+ Index.Sub = TRUE; // Should be small enough
- if (!PlgDBalloc(g, NULL, Index))
- goto err;
+ if (!PlgDBalloc(g, NULL, Index))
+ goto err;
- Offset.Size = (nblin + 1) * sizeof(int);
- Offset.Sub = TRUE; // Should be small enough
+ Offset.Size = (nblin + 1) * sizeof(int);
+ Offset.Sub = TRUE; // Should be small enough
- if (!PlgDBalloc(g, NULL, Offset))
- goto err;
+ if (!PlgDBalloc(g, NULL, Offset))
+ goto err;
- ndif = Qsort(g, nblin);
+ ndif = Qsort(g, nblin);
- if (ndif < 0) // error
- goto err;
+ if (ndif < 0) // error
+ goto err;
- } else {
- // The query was limited, we must get pivot column values
- // Returned values must be in their original character set
- // if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX)
- // goto err;
+ } else {
+ // The query was limited, we must get pivot column values
+ // Returned values must be in their original character set
+ // if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX)
+ // goto err;
- query = (char*)PlugSubAlloc(g, NULL, 0);
- sprintf(query, "SELECT DISTINCT `%s` FROM `%s`", Picol, Tabname);
- PlugSubAlloc(g, NULL, strlen(query) + 1);
- Myc.FreeResult();
+ query = (char*)PlugSubAlloc(g, NULL, 0);
+ sprintf(query, "SELECT DISTINCT `%s` FROM `%s`", Picol, Tabname);
+ PlugSubAlloc(g, NULL, strlen(query) + 1);
+ Myc.FreeResult();
- // Send the source command to MySQL
- if (Myc.ExecSQL(g, query, &w) == RC_FX)
- goto err;
+ // Send the source command to MySQL
+ if (Myc.ExecSQL(g, query, &w) == RC_FX)
+ goto err;
- // We must have a storage query to get pivot column values
- if (!(qrp = Myc.GetResult(g, true)))
- goto err;
+ // We must have a storage query to get pivot column values
+ if (!(qrp = Myc.GetResult(g, true)))
+ goto err;
- Myc.Close();
- b = false;
+ Myc.Close();
+ b = false;
- // Get the column list
- crp = qrp->Colresp;
- Rblkp = crp->Kdata;
- ndif = qrp->Nblin;
- } // endif Tabsrc
+ // Get the column list
+ crp = qrp->Colresp;
+ Rblkp = crp->Kdata;
+ ndif = qrp->Nblin;
+ } // endif Tabsrc
- // Allocate the Value used to retieve column names
- if (!(valp = AllocateValue(g, Rblkp->GetType(),
- Rblkp->GetVlen(),
- Rblkp->GetPrec())))
- goto err;
+ // Allocate the Value used to retieve column names
+ if (!(valp = AllocateValue(g, Rblkp->GetType(),
+ Rblkp->GetVlen(),
+ Rblkp->GetPrec())))
+ goto err;
- // Now make the functional columns
- for (int i = 0; i < ndif; i++) {
- if (i) {
- crp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES));
- memcpy(crp, fncrp, sizeof(COLRES));
- } else
- crp = fncrp;
-
- // Get the value that will be the generated column name
- if (Tabsrc)
- valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]);
- else
- valp->SetValue_pvblk(Rblkp, i);
-
- colname = valp->GetCharString(buf);
- crp->Name = PlugDup(g, colname);
- crp->Flag = 1;
-
- // Add this column
- *pcrp = crp;
- crp->Next = NULL;
- pcrp = &crp->Next;
- } // endfor i
+ // Now make the functional columns
+ for (int i = 0; i < ndif; i++) {
+ if (i) {
+ crp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES));
+ memcpy(crp, fncrp, sizeof(COLRES));
+ } else
+ crp = fncrp;
+
+ // Get the value that will be the generated column name
+ if (Tabsrc)
+ valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]);
+ else
+ valp->SetValue_pvblk(Rblkp, i);
+
+ colname = valp->GetCharString(buf);
+ crp->Name = PlugDup(g, colname);
+ crp->Flag = 1;
+
+ // Add this column
+ *pcrp = crp;
+ crp->Next = NULL;
+ pcrp = &crp->Next;
+ } // endfor i
// We added ndif columns and removed 2 (picol and fncol)
Qryp->Nbcol += (ndif - 2);
@@ -306,10 +306,10 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} // end catch
err:
- if (b)
- Myc.Close();
+ if (b)
+ Myc.Close();
- return NULL;
+ return NULL;
} // end of MakePivotColumns
/***********************************************************************/
diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp
index 68b66aec31f..462a6fcd839 100644
--- a/storage/connect/tabutil.cpp
+++ b/storage/connect/tabutil.cpp
@@ -429,7 +429,7 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
char buf[MAX_STR];
strcpy(buf, g->Message);
- sprintf(g->Message, "Error accessing %s.%s: %s", db, name, buf);
+ snprintf(g->Message, MAX_STR, "Error accessing %s.%s: %s", db, name, buf);
hc->tshp = NULL;
goto err;
} // endif Define
diff --git a/storage/connect/tabvct.cpp b/storage/connect/tabvct.cpp
index 11b344ef652..40d020202ea 100644
--- a/storage/connect/tabvct.cpp
+++ b/storage/connect/tabvct.cpp
@@ -456,13 +456,11 @@ bool VCTCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
if (tdbp->Txfp->GetAmType() == TYPE_AM_VMP && ok) {
Blk = AllocValBlock(g, (void*)1, Buf_Type, tdbp->Txfp->Nrec,
- Format.Length,
- Format.Prec, check);
+ Format.Length, Format.Prec, check, true, Unsigned);
Status |= BUF_MAPPED; // Will point into mapped file
} else
Blk = AllocValBlock(g, NULL, Buf_Type, tdbp->Txfp->Nrec,
- Format.Length,
- Format.Prec, check);
+ Format.Length, Format.Prec, check, true, Unsigned);
} // endif Mode
return false;
diff --git a/storage/connect/user_connect.cc b/storage/connect/user_connect.cc
index 9532d7c2a8d..e2d3b664aeb 100644
--- a/storage/connect/user_connect.cc
+++ b/storage/connect/user_connect.cc
@@ -36,6 +36,7 @@
#define DONT_DEFINE_VOID
#define MYSQL_SERVER
+#include <my_global.h>
#include "sql_class.h"
#undef OFFSET