1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Squashed commit of connect/10.0:

commit 02d8c21380f
Author: Olivier Bertrand <bertrandop@gmail.com>
Date:   Sat Oct 6 16:27:13 2018 +0200

    - Fix truncating error messages on first unrecognized latin1 character
      modified:   storage/connect/ha_connect.cc

    - Fix MDEV-17343
      Reject multi-table UPDATE/DELETE commands that crash on some systems
      modified:   storage/connect/ha_connect.cc
      modified:   storage/connect/tabext.cpp

    - Try to fix failing tests (MariaDB version 10.0 only)
      modified:   storage/connect/mysql-test/connect/disabled.def

    - Typo
      modified:   storage/connect/global.h

commit f83caed8569
Author: Olivier Bertrand <bertrandop@gmail.com>
Date:   Tue Sep 25 15:49:26 2018 +0200

    - Try to fix failing tests (MariaDB version 10.0 only)
      modified:   storage/connect/mysql-test/connect/disabled.def
      modified:   storage/connect/mysql-test/connect/r/grant2.result
      modified:   storage/connect/mysql-test/connect/r/infoschema2-9739.result
      modified:   storage/connect/mysql-test/connect/r/mysql_exec.result

commit 9fd6f178846
Author: Olivier Bertrand <bertrandop@gmail.com>
Date:   Sun Sep 23 19:45:59 2018 +0200

    - Implement the CHECK TABLE statement and accept REPAIR and ANALYZE
      modified:   storage/connect/connect.cc
      modified:   storage/connect/ha_connect.cc
      modified:   storage/connect/ha_connect.h
      modified:   storage/connect/tabjdbc.cpp
      modified:   storage/connect/tabmysql.cpp
      modified:   storage/connect/tabodbc.cpp

    - MDEV-17212: Test if NumResultCols is implemented by the data source
      modified:   storage/connect/odbconn.cpp

    - Change error type in Optimize
      modified:   storage/connect/ha_connect.cc

    - Update version date
      modified:   storage/connect/ha_connect.cc

    - Record new result from odbc_postgresql.test
      modified:   storage/connect/mysql-test/connect/r/odbc_postgresql.result

commit d8cf51319e1
Author: Olivier Bertrand <bertrandop@gmail.com>
Date:   Wed Aug 8 12:18:52 2018 +0200

    - Comment out failing Cyrillic test in xml2.test
      modified:   storage/connect/mysql-test/connect/r/xml2.result
      modified:   storage/connect/mysql-test/connect/t/xml2.test

commit 9df49e21f9e
Author: Olivier Bertrand <bertrandop@gmail.com>
Date:   Tue Aug 7 15:01:06 2018 +0200

    - Fix MDEV-16672 Connect: Warnings with 10.0
      filamtxt.cpp: DOSFAM::RenameTempFile: Change sprintf to snprintf.
      filamvct.cpp: VECFAM::RenameTempFile: Change sprintf to snprintf.
      javaconn.cpp:
        Add JAVAConn::GetUTFString function.
        Use it instead of env->GetStringUTFChars.
        Fix wrong identation.
      javaconn.h: Add GetUTFString declaration.
      jdbconn.cpp:
        Use GetUTFString function instead of env->GetStringUTFChars.
      jmgoconn.cpp:
        Use GetUTFString function instead of env->GetStringUTFChars.
        Fix wrong identation.
      jsonudf.cpp: change 139 to BMX line 4631.
      tabjmg.cpp:
        Add ReleaseStringUTF.
        Fix wrong identation.
      tabpivot.cpp: Fix wrong identation.
      tabutil.cpp: TDBPRX::GetSubTable: Change sprintf to snprintf.
      modified:   storage/connect/filamtxt.cpp
      modified:   storage/connect/filamvct.cpp
      modified:   storage/connect/javaconn.cpp
      modified:   storage/connect/javaconn.h
      modified:   storage/connect/jdbconn.cpp
      modified:   storage/connect/jmgoconn.cpp
      modified:   storage/connect/jsonudf.cpp
      modified:   storage/connect/tabjmg.cpp
      modified:   storage/connect/tabpivot.cpp
      modified:   storage/connect/tabutil.cpp

    - Fix MDEV-16895 CONNECT engine's get_error_message can cause buffer
                     overflow and server crash with long queries
      ha_connect_cc: Update version.
        get_error_message: Remove charset conversion.
      modified:   storage/connect/ha_connect.cc

    - Fix a server crash on inserting bigint to a JDBC table
      JDBConn::SetUUID:
        Suppress check on ctyp that causes a server crash because ctyp
        can be negative and this triggers an DEBUG_ASSERT on return.
      modified:   storage/connect/jdbconn.cpp

    - Delete an assert(qrp) from JCATPARM *AllocCatInfo that is called with
      qrp=NULL from JDBConn::SetUUID. Also delete a clone of this function
      that was duplicated in javaconn.cpp.
      modified:   storage/connect/javaconn.cpp
      modified:   storage/connect/jdbconn.cpp

    - Update some disabled tests and results to avoid failure
      modified:   storage/connect/mysql-test/connect/r/jdbc.result
      modified:   storage/connect/mysql-test/connect/r/json_java_2.result
      modified:   storage/connect/mysql-test/connect/r/json_java_3.result
      modified:   storage/connect/mysql-test/connect/r/mongo_java_2.result
      modified:   storage/connect/mysql-test/connect/r/mongo_java_3.result
      modified:   storage/connect/mysql-test/connect/t/json_java_2.test
      modified:   storage/connect/mysql-test/connect/t/json_java_3.test
      modified:   storage/connect/mysql-test/connect/t/mongo_java_2.test
      modified:   storage/connect/mysql-test/connect/t/mongo_java_3.test

commit 415273eb193
Author: Olivier Bertrand <bertrandop@gmail.com>
Date:   Thu Jun 28 19:37:49 2018 +0200

    - Fix MDEV-16167 Cannot insert unsigned values into a VEC table
      modified:   storage/connect/filamvct.cpp
      modified:   storage/connect/tabvct.cpp

commit 9ffcb68a9f2
Author: Olivier Bertrand <bertrandop@gmail.com>
Date:   Mon May 7 22:43:43 2018 +0200

    - Fix MDEV-15735 CONNECT [filamtxt.cpp:429]: Suspicious condition
      modified:   storage/connect/filamtxt.cpp

    - Fix compiler warnings
      modified:   storage/connect/domdoc.cpp
      modified:   storage/connect/ha_connect.cc
      modified:   storage/connect/json.h
      modified:   storage/connect/jsonudf.cpp
      modified:   storage/connect/tabext.cpp
      modified:   storage/connect/tabjson.cpp
      modified:   storage/connect/tabjson.h

    - Miscelleanous from 10.3
      modified:   storage/connect/ha_connect.cc
      modified:   storage/connect/mycat.cc
      modified:   storage/connect/user_connect.cc
This commit is contained in:
Olivier Bertrand
2018-05-07 22:43:43 +02:00
committed by Sergei Golubchik
parent 411a2540ee
commit 70e567f576
41 changed files with 356 additions and 341 deletions

View File

@@ -254,7 +254,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
try { try {
if (!c1) { if (!c1) {
if (mode == MODE_INSERT) // if (mode == MODE_INSERT) or CHECK TABLE
// Allocate all column blocks for that table // Allocate all column blocks for that table
tdbp->ColDB(g, NULL, 0); tdbp->ColDB(g, NULL, 0);

View File

@@ -84,8 +84,8 @@ DOMDOC::DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
: XMLDOCUMENT(nsl, nsdf, enc) : XMLDOCUMENT(nsl, nsdf, enc)
{ {
assert (!fp || fp->Type == TYPE_FB_XML); assert (!fp || fp->Type == TYPE_FB_XML);
Docp = (fp) ? ((PXBLOCK)fp)->Docp : NULL; Docp = (fp) ? ((PXBLOCK)fp)->Docp : (MSXML2::IXMLDOMDocumentPtr)NULL;
Nlist = NULL; Nlist = NULL;
Hr = 0; Hr = 0;
} // end of DOMDOC constructor } // end of DOMDOC constructor

View File

@@ -427,7 +427,7 @@ int TXTFAM::DeleteSortedRows(PGLOBAL g)
for (i = 0; i < Posar->GetNval(); i++) { for (i = 0; i < Posar->GetNval(); i++) {
if ((irc = InitDelete(g, Posar->GetIntValue(ix[i]), if ((irc = InitDelete(g, Posar->GetIntValue(ix[i]),
Sosar->GetIntValue(ix[i])) == RC_FX)) Sosar->GetIntValue(ix[i]))) == RC_FX)
goto err; goto err;
// Now delete the sorted rows // Now delete the sorted rows
@@ -1173,11 +1173,11 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
remove(filetemp); // May still be there from previous error remove(filetemp); // May still be there from previous error
if (rename(filename, filetemp)) { // Save file for security 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)); filename, filetemp, strerror(errno));
throw 51; throw 51;
} else if (rename(tempname, filename)) { } else if (rename(tempname, filename)) {
sprintf(g->Message, MSG(RENAME_ERROR), snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
tempname, filename, strerror(errno)); tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file rc = rename(filetemp, filename); // Restore saved file
throw 52; throw 52;

View File

@@ -348,7 +348,7 @@ int VCTFAM::Cardinality(PGLOBAL g)
} // endif split } // endif split
return (Block) ? ((Block - 1) * Nrec + Last) : 0; return (Block) ? ((Block - 1) * Nrec + Last) : 0;
} // end of Cardinality } // end of Cardinality
/***********************************************************************/ /***********************************************************************/
@@ -510,7 +510,8 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g)
for (; cp; cp = (PVCTCOL)cp->Next) for (; cp; cp = (PVCTCOL)cp->Next)
cp->Blk = AllocValBlock(g, NewBlock + Nrec * cp->Deplac, cp->Blk = AllocValBlock(g, NewBlock + Nrec * cp->Deplac,
cp->Buf_Type, Nrec, cp->Format.Length, cp->Buf_Type, Nrec, cp->Format.Length,
cp->Format.Prec, chk); cp->Format.Prec, chk, true,
cp->IsUnsigned());
return InitInsert(g); // Initialize inserting return InitInsert(g); // Initialize inserting
} else { } else {
@@ -544,7 +545,8 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g)
for (; cp; cp = (PVCTCOL)cp->Next) for (; cp; cp = (PVCTCOL)cp->Next)
if (!cp->IsSpecial()) // Not a pseudo column if (!cp->IsSpecial()) // Not a pseudo column
cp->Blk = AllocValBlock(g, NULL, cp->Buf_Type, Nrec, 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 } //endif mode
@@ -1511,7 +1513,8 @@ bool VCMFAM::AllocateBuffer(PGLOBAL g)
for (cp = (PVCTCOL)Tdbp->GetColumns(); cp; cp = (PVCTCOL)cp->Next) for (cp = (PVCTCOL)Tdbp->GetColumns(); cp; cp = (PVCTCOL)cp->Next)
if (!cp->IsSpecial()) { // Not a pseudo column if (!cp->IsSpecial()) { // Not a pseudo column
cp->Blk = AllocValBlock(g, (void*)1, cp->Buf_Type, Nrec, 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); cp->AddStatus(BUF_MAPPED);
} // endif IsSpecial } // endif IsSpecial
@@ -2062,7 +2065,7 @@ bool VECFAM::AllocateBuffer(PGLOBAL g)
for (cp = (PVCTCOL)tdbp->Columns; cp; cp = (PVCTCOL)cp->Next) for (cp = (PVCTCOL)tdbp->Columns; cp; cp = (PVCTCOL)cp->Next)
cp->Blk = AllocValBlock(g, To_Bufs[cp->Index - 1], cp->Blk = AllocValBlock(g, To_Bufs[cp->Index - 1],
cp->Buf_Type, Nrec, cp->Format.Length, cp->Buf_Type, Nrec, cp->Format.Length,
cp->Format.Prec, chk); cp->Format.Prec, chk, true, cp->IsUnsigned());
return InitInsert(g); return InitInsert(g);
} else { } else {
@@ -2111,7 +2114,8 @@ bool VECFAM::AllocateBuffer(PGLOBAL g)
for (cp = (PVCTCOL)tdbp->Columns; cp; cp = (PVCTCOL)cp->Next) for (cp = (PVCTCOL)tdbp->Columns; cp; cp = (PVCTCOL)cp->Next)
if (!cp->IsSpecial()) // Not a pseudo column if (!cp->IsSpecial()) // Not a pseudo column
cp->Blk = AllocValBlock(g, NULL, cp->Buf_Type, Nrec, 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 } // endif mode
@@ -2449,11 +2453,11 @@ int VECFAM::RenameTempFile(PGLOBAL g)
remove(filetemp); // May still be there from previous error remove(filetemp); // May still be there from previous error
if (rename(filename, filetemp)) { // Save file for security 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)); filename, filetemp, strerror(errno));
rc = RC_FX; rc = RC_FX;
} else if (rename(tempname, filename)) { } else if (rename(tempname, filename)) {
sprintf(g->Message, MSG(RENAME_ERROR), snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
tempname, filename, strerror(errno)); tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file rc = rename(filetemp, filename); // Restore saved file
rc = RC_FX; rc = RC_FX;
@@ -2882,7 +2886,8 @@ bool VMPFAM::AllocateBuffer(PGLOBAL g)
for (cp = (PVCTCOL)Tdbp->GetColumns(); cp; cp = (PVCTCOL)cp->Next) for (cp = (PVCTCOL)Tdbp->GetColumns(); cp; cp = (PVCTCOL)cp->Next)
if (!cp->IsSpecial()) { // Not a pseudo column if (!cp->IsSpecial()) { // Not a pseudo column
cp->Blk = AllocValBlock(g, (void*)1, cp->Buf_Type, Nrec, 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); cp->AddStatus(BUF_MAPPED);
} // endif IsSpecial } // endif IsSpecial
@@ -3664,7 +3669,7 @@ bool BGVFAM::AllocateBuffer(PGLOBAL g)
for (; cp; cp = (PVCTCOL)cp->Next) for (; cp; cp = (PVCTCOL)cp->Next)
cp->Blk = AllocValBlock(g, NewBlock + Nrec * cp->Deplac, cp->Blk = AllocValBlock(g, NewBlock + Nrec * cp->Deplac,
cp->Buf_Type, Nrec, cp->Format.Length, cp->Buf_Type, Nrec, cp->Format.Length,
cp->Format.Prec, chk); cp->Format.Prec, chk, true, cp->IsUnsigned());
InitInsert(g); // Initialize inserting InitInsert(g); // Initialize inserting
@@ -3712,7 +3717,8 @@ bool BGVFAM::AllocateBuffer(PGLOBAL g)
for (; cp; cp = (PVCTCOL)cp->Next) for (; cp; cp = (PVCTCOL)cp->Next)
if (!cp->IsSpecial()) // Not a pseudo column if (!cp->IsSpecial()) // Not a pseudo column
cp->Blk = AllocValBlock(g, NULL, cp->Buf_Type, Nrec, 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 } //endif mode

View File

@@ -1,7 +1,7 @@
/***********************************************************************/ /***********************************************************************/
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */ /* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright MariaDB Corporation Ab */ /* (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; PACTIVITY Activityp;
char Message[MAX_STR]; char Message[MAX_STR];
ulong More; /* Used by jsonudf */ 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 */ void *Xchk; /* indexes in create/alter */
short Alchecked; /* Checked for ALTER */ short Alchecked; /* Checked for ALTER */
short Mrr; /* True when doing mrr */ short Mrr; /* True when doing mrr */

View File

@@ -107,13 +107,9 @@
#define MYSQL_SERVER 1 #define MYSQL_SERVER 1
#define DONT_DEFINE_VOID #define DONT_DEFINE_VOID
#include "sql_class.h" #include <my_global.h>
#include "create_options.h"
#include "mysql_com.h"
#include "field.h"
#include "sql_parse.h" #include "sql_parse.h"
#include "sql_base.h" #include "sql_base.h"
#include <sys/stat.h>
#include "sql_partition.h" #include "sql_partition.h"
#undef OFFSET #undef OFFSET
@@ -174,9 +170,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.06.0007 March 11, 2018"; char version[]= "Version 1.06.0008 October 06, 2018";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__; char compver[]= "Version 1.06.0008 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
#else // !__WIN__ #else // !__WIN__
char slash= '/'; char slash= '/';
@@ -432,7 +428,7 @@ handlerton *connect_hton= NULL;
uint GetTraceValue(void) uint GetTraceValue(void)
{return (uint)(connect_hton ? THDVAR(current_thd, xtrace) : 0);} {return (uint)(connect_hton ? THDVAR(current_thd, xtrace) : 0);}
bool ExactInfo(void) {return THDVAR(current_thd, exact_info);} bool ExactInfo(void) {return THDVAR(current_thd, exact_info);}
bool CondPushEnabled(void) {return THDVAR(current_thd, cond_push);} static bool CondPushEnabled(void) {return THDVAR(current_thd, cond_push);}
USETEMP UseTemp(void) {return (USETEMP)THDVAR(current_thd, use_tempfile);} USETEMP UseTemp(void) {return (USETEMP)THDVAR(current_thd, use_tempfile);}
int GetConvSize(void) {return THDVAR(current_thd, conv_size);} int GetConvSize(void) {return THDVAR(current_thd, conv_size);}
TYPCONV GetTypeConv(void) {return (TYPCONV)THDVAR(current_thd, type_conv);} TYPCONV GetTypeConv(void) {return (TYPCONV)THDVAR(current_thd, type_conv);}
@@ -1781,12 +1777,14 @@ bool ha_connect::CheckVirtualIndex(TABLE_SHARE *s)
bool ha_connect::IsPartitioned(void) bool ha_connect::IsPartitioned(void)
{ {
if (tshp) #ifdef WITH_PARTITION_STORAGE_ENGINE
if (tshp)
return tshp->partition_info_str_len > 0; return tshp->partition_info_str_len > 0;
else if (table && table->part_info) else if (table && table->part_info)
return true; return true;
else else
return false; #endif
return false;
} // end of IsPartitioned } // end of IsPartitioned
@@ -2811,7 +2809,7 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
htrc("Cond type=%d\n", cond->type()); htrc("Cond type=%d\n", cond->type());
if (cond->type() == COND::COND_ITEM) { 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; bool bb = false, bh = false;
Item_cond *cond_item= (Item_cond *)cond; Item_cond *cond_item= (Item_cond *)cond;
@@ -3292,6 +3290,58 @@ ha_rows ha_connect::records()
} // end of 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. Return an error message specific to this handler.
@@ -3305,23 +3355,16 @@ bool ha_connect::get_error_message(int error, String* buf)
{ {
DBUG_ENTER("ha_connect::get_error_message"); DBUG_ENTER("ha_connect::get_error_message");
if (xp && xp->g) { if (xp && xp->g) {
PGLOBAL g= 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 (trace(1)) if (trace(1))
htrc("GEM(%d): len=%u %s\n", error, len, g->Message); htrc("GEM(%d): %s\n", error, g->Message);
msg[len]= '\0'; buf->append(ErrConvString(g->Message, strlen(g->Message),
buf->copy(msg, (uint)strlen(msg), system_charset_info); &my_charset_latin1).ptr());
} else } else
buf->copy("Cannot retrieve msg", 19, system_charset_info); buf->append("Cannot retrieve error message");
DBUG_RETURN(false); DBUG_RETURN(false);
} // end of get_error_message } // end of get_error_message
@@ -3434,7 +3477,7 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
rc = 0; rc = 0;
} else } else
rc = HA_ERR_INTERNAL_ERROR; rc = HA_ERR_CRASHED_ON_USAGE; // Table must be repaired
} // endif rc } // endif rc
@@ -3450,6 +3493,9 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
rc = HA_ERR_INTERNAL_ERROR; rc = HA_ERR_INTERNAL_ERROR;
} // end catch } // end catch
if (rc)
my_message(ER_WARN_DATA_OUT_OF_RANGE, g->Message, MYF(0));
return rc; return rc;
} // end of optimize } // end of optimize
@@ -4511,14 +4557,16 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
// case SQLCOM_REPLACE_SELECT: // case SQLCOM_REPLACE_SELECT:
// newmode= MODE_UPDATE; // To be checked // newmode= MODE_UPDATE; // To be checked
// break; // break;
case SQLCOM_DELETE: case SQLCOM_DELETE_MULTI:
case SQLCOM_DELETE_MULTI: *cras = true;
case SQLCOM_DELETE:
case SQLCOM_TRUNCATE: case SQLCOM_TRUNCATE:
newmode= MODE_DELETE; newmode= MODE_DELETE;
break; break;
case SQLCOM_UPDATE:
case SQLCOM_UPDATE_MULTI: case SQLCOM_UPDATE_MULTI:
newmode= MODE_UPDATE; *cras = true;
case SQLCOM_UPDATE:
newmode= MODE_UPDATE;
break; break;
case SQLCOM_SELECT: case SQLCOM_SELECT:
case SQLCOM_OPTIMIZE: case SQLCOM_OPTIMIZE:
@@ -4543,8 +4591,10 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
newmode= MODE_ANY; newmode= MODE_ANY;
break; break;
// } // endif partitioned // } // endif partitioned
case SQLCOM_REPAIR: // TODO implement it
default: newmode = MODE_UPDATE;
break;
default:
htrc("Unsupported sql_command=%d\n", thd_sql_command(thd)); htrc("Unsupported sql_command=%d\n", thd_sql_command(thd));
strcpy(g->Message, "CONNECT Unsupported command"); strcpy(g->Message, "CONNECT Unsupported command");
my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0)); my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0));
@@ -4556,17 +4606,18 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
switch (thd_sql_command(thd)) { switch (thd_sql_command(thd)) {
case SQLCOM_CREATE_TABLE: case SQLCOM_CREATE_TABLE:
*chk= true; *chk= true;
*cras= true; break;
case SQLCOM_UPDATE_MULTI:
case SQLCOM_DELETE_MULTI:
*cras= true;
case SQLCOM_INSERT: case SQLCOM_INSERT:
case SQLCOM_LOAD: case SQLCOM_LOAD:
case SQLCOM_INSERT_SELECT: case SQLCOM_INSERT_SELECT:
// case SQLCOM_REPLACE: // case SQLCOM_REPLACE:
// case SQLCOM_REPLACE_SELECT: // case SQLCOM_REPLACE_SELECT:
case SQLCOM_DELETE: case SQLCOM_DELETE:
case SQLCOM_DELETE_MULTI:
case SQLCOM_TRUNCATE: case SQLCOM_TRUNCATE:
case SQLCOM_UPDATE: case SQLCOM_UPDATE:
case SQLCOM_UPDATE_MULTI:
case SQLCOM_SELECT: case SQLCOM_SELECT:
case SQLCOM_OPTIMIZE: case SQLCOM_OPTIMIZE:
case SQLCOM_SET_OPTION: case SQLCOM_SET_OPTION:
@@ -4594,8 +4645,9 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
break; break;
// } // endif partitioned // } // endif partitioned
case SQLCOM_CHECK: // TODO implement it case SQLCOM_CHECK: // TODO implement it
case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT... case SQLCOM_ANALYZE: // TODO implement it
case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT...
newmode= MODE_READ; newmode= MODE_READ;
break; break;
default: default:
@@ -4877,7 +4929,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
#endif // 0 #endif // 0
if (cras) 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 (trace(1)) {
#if 0 #if 0
@@ -5568,7 +5620,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
} // endif p } // endif p
} else if (ttp != TAB_ODBC || !(fnc & (FNC_TABLE | FNC_COL))) } 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 } // endif tab
@@ -6200,7 +6252,9 @@ int ha_connect::create(const char *name, TABLE *table_arg,
LEX_STRING cnc = table_arg->s->connect_string; LEX_STRING cnc = table_arg->s->connect_string;
#if defined(WITH_PARTITION_STORAGE_ENGINE) #if defined(WITH_PARTITION_STORAGE_ENGINE)
partition_info *part_info= table_arg->part_info; partition_info *part_info= table_arg->part_info;
#endif // WITH_PARTITION_STORAGE_ENGINE #else // !WITH_PARTITION_STORAGE_ENGINE
#define part_info 0
#endif // !WITH_PARTITION_STORAGE_ENGINE
xp= GetUser(thd, xp); xp= GetUser(thd, xp);
PGLOBAL g= xp->g; PGLOBAL g= xp->g;
@@ -6301,9 +6355,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
// fall through // fall through
case TAB_MYSQL: case TAB_MYSQL:
#if defined(WITH_PARTITION_STORAGE_ENGINE)
if (!part_info) if (!part_info)
#endif // WITH_PARTITION_STORAGE_ENGINE
{const char *src= options->srcdef; {const char *src= options->srcdef;
PCSZ host, db, tab= options->tabname; PCSZ host, db, tab= options->tabname;
int port; int port;
@@ -6567,7 +6619,6 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} else } else
lwt[i]= tolower(options->type[i]); lwt[i]= tolower(options->type[i]);
#if defined(WITH_PARTITION_STORAGE_ENGINE)
if (part_info) { if (part_info) {
char *p; char *p;
@@ -6577,7 +6628,6 @@ int ha_connect::create(const char *name, TABLE *table_arg,
strcat(strcat(strcpy(buf, p), "."), lwt); strcat(strcat(strcpy(buf, p), "."), lwt);
*p= 0; *p= 0;
} else { } else {
#endif // WITH_PARTITION_STORAGE_ENGINE
strcat(strcat(strcpy(buf, GetTableName()), "."), lwt); strcat(strcat(strcpy(buf, GetTableName()), "."), lwt);
sprintf(g->Message, "No file name. Table will use %s", buf); sprintf(g->Message, "No file name. Table will use %s", buf);
@@ -6585,9 +6635,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/"); strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/");
#if defined(WITH_PARTITION_STORAGE_ENGINE)
} // endif part_info } // endif part_info
#endif // WITH_PARTITION_STORAGE_ENGINE
PlugSetPath(fn, buf, dbpath); PlugSetPath(fn, buf, dbpath);
@@ -6652,11 +6700,9 @@ int ha_connect::create(const char *name, TABLE *table_arg,
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0,
"Unexpected command in create, please contact CONNECT team"); "Unexpected command in create, please contact CONNECT team");
#if defined(WITH_PARTITION_STORAGE_ENGINE)
if (part_info && !inward) if (part_info && !inward)
strncpy(partname, decode(g, strrchr(name, '#') + 1), sizeof(partname) - 1); strncpy(partname, decode(g, strrchr(name, '#') + 1), sizeof(partname) - 1);
// strcpy(partname, part_info->curr_part_elem->partition_name); // strcpy(partname, part_info->curr_part_elem->partition_name);
#endif // WITH_PARTITION_STORAGE_ENGINE
if (g->Alchecked == 0 && if (g->Alchecked == 0 &&
(!IsFileType(type) || FileExists(options->filename, false))) { (!IsFileType(type) || FileExists(options->filename, false))) {
@@ -6692,12 +6738,10 @@ int ha_connect::create(const char *name, TABLE *table_arg,
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc = HA_ERR_INTERNAL_ERROR; rc = HA_ERR_INTERNAL_ERROR;
} else if (cat) { } else if (cat) {
#if defined(WITH_PARTITION_STORAGE_ENGINE)
if (part_info) if (part_info)
strncpy(partname, strncpy(partname,
decode(g, strrchr(name, (inward ? slash : '#')) + 1), decode(g, strrchr(name, (inward ? slash : '#')) + 1),
sizeof(partname) - 1); sizeof(partname) - 1);
#endif // WITH_PARTITION_STORAGE_ENGINE
if ((rc= optimize(table->in_use, NULL))) { if ((rc= optimize(table->in_use, NULL))) {
htrc("Create rc=%d %s\n", rc, g->Message); htrc("Create rc=%d %s\n", rc, g->Message);
@@ -7266,7 +7310,7 @@ maria_declare_plugin(connect)
0x0107, /* version number (1.05) */ 0x0107, /* version number (1.05) */
NULL, /* status variables */ NULL, /* status variables */
connect_system_variables, /* system variables */ connect_system_variables, /* system variables */
"1.06.0007", /* string version */ "1.06.0008", /* string version */
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
} }
maria_declare_plugin_end; maria_declare_plugin_end;

View File

@@ -347,11 +347,7 @@ PFIL CondFilter(PGLOBAL g, Item *cond);
//PFIL CheckFilter(PGLOBAL g); //PFIL CheckFilter(PGLOBAL g);
/** admin commands - called from mysql_admin_table */ /** admin commands - called from mysql_admin_table */
virtual int check(THD* thd, HA_CHECK_OPT* check_opt) 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
/** /**
Number of rows in table. It will only be called if Number of rows in table. It will only be called if

View File

@@ -81,29 +81,6 @@ GETDEF JAVAConn::GetDefaultJavaVMInitArgs = NULL;
#define DEBUG_ONLY(f) ((void)0) #define DEBUG_ONLY(f) ((void)0)
#endif // !_DEBUG #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 construction/destruction. */
/***********************************************************************/ /***********************************************************************/
@@ -138,6 +115,16 @@ JAVAConn::JAVAConn(PGLOBAL g, PCSZ wrapper)
// EndCom(); // EndCom();
// } // end of ~JAVAConn // } // 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. */ /* Screen for errors. */
@@ -152,17 +139,15 @@ bool JAVAConn::Check(jint rc)
"toString", "()Ljava/lang/String;"); "toString", "()Ljava/lang/String;");
if (exc != nullptr && tid != nullptr) { if (exc != nullptr && tid != nullptr) {
jstring s = (jstring)env->CallObjectMethod(exc, tid); s = (jstring)env->CallObjectMethod(exc, tid);
const char *utf = env->GetStringUTFChars(s, NULL); Msg = GetUTFString(s);
env->DeleteLocalRef(s);
Msg = PlugDup(m_G, utf);
} else } else
Msg = "Exception occured"; Msg = "Exception occured";
env->ExceptionClear(); env->ExceptionClear();
} else if (rc < 0) { } else if (rc < 0) {
s = (jstring)env->CallObjectMethod(job, errid); s = (jstring)env->CallObjectMethod(job, errid);
Msg = (char*)env->GetStringUTFChars(s, NULL); Msg = GetUTFString(s);
} else } else
Msg = NULL; Msg = NULL;

View File

@@ -90,6 +90,7 @@ public:
// Java operations // Java operations
protected: protected:
char *GetUTFString(jstring s);
bool gmID(PGLOBAL g, jmethodID& mid, const char *name, const char *sig); bool gmID(PGLOBAL g, jmethodID& mid, const char *name, const char *sig);
bool Check(jint rc = 0); bool Check(jint rc = 0);

View File

@@ -314,10 +314,6 @@ static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, PCSZ db,
{ {
JCATPARM *cap; JCATPARM *cap;
#if defined(_DEBUG)
assert(qrp);
#endif
if ((cap = (JCATPARM *)PlgDBSubAlloc(g, NULL, sizeof(JCATPARM)))) { if ((cap = (JCATPARM *)PlgDBSubAlloc(g, NULL, sizeof(JCATPARM)))) {
memset(cap, 0, sizeof(JCATPARM)); memset(cap, 0, sizeof(JCATPARM));
cap->Id = fid; cap->Id = fid;
@@ -699,20 +695,13 @@ bool JDBConn::SetUUID(PGLOBAL g, PTDBJDBC tjp)
goto err; goto err;
} // endif rc } // endif rc
// Returns 666 is case of error // Should return 666 is case of error (not done yet)
//jtyp = env->CallIntMethod(job, typid, 5, nullptr);
//if (Check((jtyp == 666) ? -1 : 1)) {
// sprintf(g->Message, "Getting jtyp: %s", Msg);
// goto err;
//} // endif ctyp
ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr); ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr);
if (Check(ctyp)) { //if (Check((ctyp == 666) ? -1 : 1)) {
sprintf(g->Message, "Getting ctyp: %s", Msg); // sprintf(g->Message, "Getting ctyp: %s", Msg);
goto err; // goto err;
} // endif ctyp //} // endif ctyp
if (ctyp == 1111) if (ctyp == 1111)
((PJDBCCOL)colp)->uuid = true; ((PJDBCCOL)colp)->uuid = true;
@@ -828,11 +817,11 @@ bool JDBConn::Connect(PJPARM sop)
jstring s = (jstring)env->CallObjectMethod(job, qcid); jstring s = (jstring)env->CallObjectMethod(job, qcid);
if (s != nullptr) { if (s != nullptr) {
char *qch = (char*)env->GetStringUTFChars(s, NULL); char *qch = GetUTFString(s);
m_IDQuoteChar[0] = *qch; m_IDQuoteChar[0] = *qch;
} else { } else {
s = (jstring)env->CallObjectMethod(job, errid); s = (jstring)env->CallObjectMethod(job, errid);
Msg = (char*)env->GetStringUTFChars(s, NULL); Msg = GetUTFString(s);
} // endif s } // endif s
} // endif qcid } // endif qcid
@@ -1010,7 +999,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr; cn = nullptr;
if (cn) { if (cn) {
field = env->GetStringUTFChars(cn, NULL); field = GetUTFString(cn);
val->SetValue_psz((PSZ)field); val->SetValue_psz((PSZ)field);
} else } else
val->Reset(); val->Reset();
@@ -1084,8 +1073,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr; cn = nullptr;
if (cn) { if (cn) {
const char *field = env->GetStringUTFChars(cn, NULL); val->SetValue_psz((PSZ)GetUTFString(cn));
val->SetValue_psz((PSZ)field);
} else } else
val->Reset(); val->Reset();
@@ -1364,19 +1352,19 @@ bool JDBConn::SetParam(JDBCCOL *colp)
for (i = 0, n = 0; i < size; i++) { for (i = 0, n = 0; i < size; i++) {
crp = qrp->Colresp; crp = qrp->Colresp;
js = (jstring)env->GetObjectArrayElement(s, n++); js = (jstring)env->GetObjectArrayElement(s, n++);
sval = (PSZ)env->GetStringUTFChars(js, 0); sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i); crp->Kdata->SetValue(sval, i);
crp = crp->Next; crp = crp->Next;
js = (jstring)env->GetObjectArrayElement(s, n++); js = (jstring)env->GetObjectArrayElement(s, n++);
sval = (PSZ)env->GetStringUTFChars(js, 0); sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i); crp->Kdata->SetValue(sval, i);
crp = crp->Next; crp = crp->Next;
js = (jstring)env->GetObjectArrayElement(s, n++); js = (jstring)env->GetObjectArrayElement(s, n++);
sval = (PSZ)env->GetStringUTFChars(js, 0); sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i); crp->Kdata->SetValue(sval, i);
crp = crp->Next; crp = crp->Next;
js = (jstring)env->GetObjectArrayElement(s, n++); js = (jstring)env->GetObjectArrayElement(s, n++);
sval = (PSZ)env->GetStringUTFChars(js, 0); sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i); crp->Kdata->SetValue(sval, i);
} // endfor i } // endfor i
@@ -1462,7 +1450,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
return NULL; return NULL;
} // endif label } // endif label
name = env->GetStringUTFChars(label, NULL); name = GetUTFString(label);
crp = qrp->Colresp; // Column_Name crp = qrp->Colresp; // Column_Name
crp->Kdata->SetValue((char*)name, i); crp->Kdata->SetValue((char*)name, i);
n = env->GetIntArrayElements(val, 0); n = env->GetIntArrayElements(val, 0);

View File

@@ -522,7 +522,7 @@ PSZ JMgoConn::GetDocument(void)
jdc = (jstring)env->CallObjectMethod(job, getdocid); jdc = (jstring)env->CallObjectMethod(job, getdocid);
if (jdc) if (jdc)
doc = (PSZ)env->GetStringUTFChars(jdc, NULL); doc = (PSZ)GetUTFString(jdc);
} // endif getdocid } // endif getdocid
@@ -690,7 +690,7 @@ jobject JMgoConn::MakeDoc(PGLOBAL g, PJNCOL jcp)
} // endif Jncolp } // endif Jncolp
return parent; return parent;
} // end of MakeDoc } // end of MakeDoc
/***********************************************************************/ /***********************************************************************/
@@ -807,7 +807,7 @@ PSZ JMgoConn::GetColumnValue(PSZ path)
fn = (jstring)env->CallObjectMethod(job, objfldid, jn); fn = (jstring)env->CallObjectMethod(job, objfldid, jn);
if (fn) if (fn)
fld = (PSZ)env->GetStringUTFChars(fn, NULL); fld = (PSZ)GetUTFString(fn);
} // endif objfldid } // endif objfldid

View File

@@ -44,6 +44,9 @@ typedef struct {
int len; int len;
} STRG, *PSG; } 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); PJSON ParseJson(PGLOBAL g, char *s, int n, int *prty = NULL, bool *b = NULL);
PJAR ParseArray(PGLOBAL g, int& i, STRG& src, bool *pty); PJAR ParseArray(PGLOBAL g, int& i, STRG& src, bool *pty);
PJOB ParseObject(PGLOBAL g, int& i, STRG& src, bool *pty); PJOB ParseObject(PGLOBAL g, int& i, STRG& src, bool *pty);

View File

@@ -1620,7 +1620,7 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
if (AllocSarea(g, ml)) { if (AllocSarea(g, ml)) {
char errmsg[MAX_STR]; char errmsg[MAX_STR];
sprintf(errmsg, MSG(WORK_AREA), g->Message); snprintf(errmsg, sizeof(errmsg) - 1, MSG(WORK_AREA), g->Message);
strcpy(g->Message, errmsg); strcpy(g->Message, errmsg);
return true; return true;
} // endif SareaAlloc } // endif SareaAlloc
@@ -1673,7 +1673,7 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
n = strlen(s); n = strlen(s);
if (IsJson(args, i)) if (IsJson(args, i))
j = strchr(s, '_') - s + 1; j = (int)(strchr(s, '_') - s + 1);
if (j && n > j) { if (j && n > j) {
s += j; s += j;
@@ -4631,7 +4631,7 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
bsp = NULL; bsp = NULL;
if (!bsp && (bsp = JbinAlloc(g, args, initid->max_length, 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 // Keep result of constant function
g->Xchk = (initid->const_item) ? bsp : NULL; g->Xchk = (initid->const_item) ? bsp : NULL;

View File

@@ -18,7 +18,7 @@
/* ------------- */ /* ------------- */
/* Version 1.6 */ /* Version 1.6 */
/* */ /* */
/* Author: Olivier Bertrand 2012 - 2017 */ /* Author: Olivier Bertrand 2012 - 2018 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
@@ -28,20 +28,13 @@
/***********************************************************************/ /***********************************************************************/
/* Include relevant MariaDB header file. */ /* Include relevant MariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include <my_config.h> #define DONT_DEFINE_VOID
#include <my_global.h>
#if defined(__WIN__) #if defined(UNIX)
//#include <windows.h>
//#include <sqlext.h>
#elif defined(UNIX)
#include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#endif #endif
#define DONT_DEFINE_VOID
//#include <mysql/plugin.h>
#include "handler.h" #include "handler.h"
#undef OFFSET #undef OFFSET

View File

@@ -9,14 +9,17 @@
# Do not use any TAB characters for whitespace. # Do not use any TAB characters for whitespace.
# #
############################################################################## ##############################################################################
jdbc : Variable settings depend on machine configuration infoschema-9739 : Crashes with MariaDB 10.0
jdbc_new : Variable settings depend on machine configuration infoschema2-9739 : Temporary until recording result with MariaDB 10.0
jdbc_oracle : Variable settings depend on machine configuration jdbc : Variable settings depend on machine configuration
jdbc_postgresql : Variable settings depend on machine configuration jdbc_new : Variable settings depend on machine configuration
json_mongo_c : Need MongoDB running and its C Driver installed jdbc_oracle : Variable settings depend on machine configuration
json_java_2 : Need MongoDB running and its Java Driver installed jdbc_postgresql : Variable settings depend on machine configuration
json_java_3 : Need MongoDB running and its Java Driver installed json_mongo_c : Need MongoDB running and its C Driver installed
mongo_c : Need MongoDB running and its C Driver installed json_java_2 : Need MongoDB running and its Java Driver installed
mongo_java_2 : Need MongoDB running and its Java Driver installed json_java_3 : Need MongoDB running and its Java Driver installed
mongo_java_3 : Need MongoDB running and its Java Driver installed mongo_c : Need MongoDB running and its C Driver installed
tbl_thread : Bug MDEV-9844,10179,14214 03/01/2018 OB Option THREAD removed 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
vcol : Different error code on different versions

View File

@@ -622,7 +622,7 @@ test.t1 optimize status OK
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize Error Access denied for user 'user'@'localhost' (using password: NO) test.t1 optimize Error Access denied for user 'user'@'localhost' (using password: NO)
test.t1 optimize Error Got error 122 'This operation requires the FILE privilege' from CONNECT test.t1 optimize Error Can't lock file (errno: 122 "Internal (unspecified) error in handler")
test.t1 optimize error Corrupt test.t1 optimize error Corrupt
DROP TABLE t1; DROP TABLE t1;
# Testing SQLCOM_ALTER_TABLE (adding columns) # Testing SQLCOM_ALTER_TABLE (adding columns)

View File

@@ -8,5 +8,5 @@ TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE
Warnings: Warnings:
Warning 1286 Unknown storage engine 'InnoDB' Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB' Warning 1286 Unknown storage engine 'InnoDB'
Warning 1296 Got error 174 'File t1.xml not found' from CONNECT Warning 1105
drop table t1; drop table t1;

View File

@@ -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'; 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'; SELECT * FROM t2 WHERE command='drop table tx1';
command number message command number message
drop table tx1 0 Execute: java.sql.SQLSyntaxErrorException: Unknown table 'connect.tx1' drop table tx1 0 Execute: java.sql.SQLSyntaxErrorException: (conn:23) Unknown table 'connect.tx1'
Query is : drop table tx1
SELECT * FROM t2 WHERE command = 'create table tx1 (a int not null, b char(32), c double(8,2))'; SELECT * FROM t2 WHERE command = 'create table tx1 (a int not null, b char(32), c double(8,2))';
command number message command number message
create table tx1 (a int not null, b char(32), c double(8,2)) 0 Affected rows create table tx1 (a int not null, b char(32), c double(8,2)) 0 Affected rows

View File

@@ -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; set connect_enable_mongo=1;
# #
# Test the MONGO table type # Test the MONGO table type

View File

@@ -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; set connect_enable_mongo=1;
# #
# Test the MONGO table type # Test the MONGO table type

View File

@@ -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; set connect_enable_mongo=1;
# #
# Test the MONGO table type # Test the MONGO table type

View File

@@ -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; set connect_enable_mongo=1;
# #
# Test the MONGO table type # Test the MONGO table type

View File

@@ -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 Warning 0 1364 Field 'msg' doesn't have a default value
update t1 set msg = 'Four' where id = 4 0 1 Affected rows update t1 set msg = 'Four' where id = 4 0 1 Affected rows
select * from t1 0 2 Result set columns select * from t1 0 2 Result set columns
Warnings:
Warning 1105 Result set columns
# #
# Checking Using Procedure # Checking Using Procedure
# #
@@ -43,9 +45,13 @@ CALL p1('insert ignore into t1(id) values(NULL)');
command warnings number message command warnings number message
insert ignore into t1(id) values(NULL) 1 1 Affected rows insert ignore into t1(id) values(NULL) 1 1 Affected rows
Warning 0 1364 Field 'msg' doesn't have a default value 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'); CALL p1('update t1 set msg = "Five" where id = 5');
command warnings number message command warnings number message
update t1 set msg = "Five" where id = 5 0 1 Affected rows update t1 set msg = "Five" where id = 5 0 1 Affected rows
Warnings:
Warning 1105 Affected rows
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP TABLE t1; DROP TABLE t1;
SELECT * FROM t1; SELECT * FROM t1;

View File

@@ -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 t1 a 4 int4 10 4 0 10 0
mtr public t2 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 public v1 a 4 int4 10 4 0 10 1
mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
mtr schema1 t2 a 1 bpchar 10 60 NULL NULL 0 mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0
mtr schema1 v1 a 1 bpchar 10 60 NULL NULL 1 mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1
DROP TABLE t1; DROP TABLE t1;
# All columns in the schemas "public" and "schema1" # 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='%.%.%'; 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 t1 a 4 int4 10 4 0 10 0
mtr public t2 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 public v1 a 4 int4 10 4 0 10 1
mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
mtr schema1 t2 a 1 bpchar 10 60 NULL NULL 0 mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0
mtr schema1 v1 a 1 bpchar 10 60 NULL NULL 1 mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1
DROP TABLE t1; DROP TABLE t1;
# All tables "t1" in all schemas # 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'; 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; 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 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 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; DROP TABLE t1;
# Table "t1" in the schema "public" # 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'; 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'; 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; 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 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; DROP TABLE t1;
# All tables "t1" in all schemas (Catalog name is ignored by PostgreSQL) # 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'; 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; 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 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 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; DROP TABLE t1;
# #
# Checking tables # Checking tables

View File

@@ -333,37 +333,6 @@ DROP TABLE t1;
# #
# Testing Cyrillic # 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 # Testing that the underlying file is created with a proper Encoding
# #

View File

@@ -1,7 +1,9 @@
-- source jdbconn.inc -- source jdbconn.inc
-- source mongo.inc -- source mongo.inc
--disable_query_log
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo2.jar'; eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo2.jar';
--enable_query_log
let $DRV= Java; let $DRV= Java;
let $VERS= 2; let $VERS= 2;
let $TYPE= JSON; let $TYPE= JSON;

View File

@@ -1,7 +1,9 @@
-- source jdbconn.inc -- source jdbconn.inc
-- source mongo.inc -- source mongo.inc
--disable_query_log
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo3.jar'; eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo3.jar';
--enable_query_log
let $DRV= Java; let $DRV= Java;
let $VERS= 3; let $VERS= 3;
let $TYPE= JSON; let $TYPE= JSON;

View File

@@ -1,7 +1,9 @@
-- source jdbconn.inc -- source jdbconn.inc
-- source mongo.inc -- source mongo.inc
--disable_query_log
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo2.jar'; eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo2.jar';
--enable_query_log
let $DRV= Java; let $DRV= Java;
let $VERS= 2; let $VERS= 2;
let $TYPE= MONGO; let $TYPE= MONGO;

View File

@@ -1,7 +1,9 @@
-- source jdbconn.inc -- source jdbconn.inc
-- source mongo.inc -- source mongo.inc
--disable_query_log
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo3.jar'; eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo3.jar';
--enable_query_log
let $DRV= Java; let $DRV= Java;
let $VERS= 3; let $VERS= 3;
let $TYPE= MONGO; let $TYPE= MONGO;

View File

@@ -240,24 +240,24 @@ DROP TABLE t1;
--echo # --echo #
--echo # Testing Cyrillic --echo # Testing Cyrillic
--echo # --echo #
CREATE TABLE t1 #CREATE TABLE t1
( #(
c CHAR(16) CHARACTER SET utf8 # c CHAR(16) CHARACTER SET utf8
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='cp1251.xml' #) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='cp1251.xml'
OPTION_LIST='xmlsup=libxml2,rownode=b'; # OPTION_LIST='xmlsup=libxml2,rownode=b';
SELECT * FROM t1; #SELECT * FROM t1;
INSERT INTO t1 VALUES ('ИКЛМН'); #INSERT INTO t1 VALUES ('ИКЛМН');
SELECT c, HEX(c) FROM t1; #SELECT c, HEX(c) FROM t1;
DROP TABLE t1; #DROP TABLE t1;
CREATE TABLE t1 #CREATE TABLE t1
( #(
c CHAR(16) CHARACTER SET cp1251 # c CHAR(16) CHARACTER SET cp1251
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='cp1251.xml' #) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='cp1251.xml'
OPTION_LIST='xmlsup=libxml2,rownode=b'; # OPTION_LIST='xmlsup=libxml2,rownode=b';
SELECT * FROM t1; #SELECT * FROM t1;
INSERT INTO t1 VALUES ('ОПРСТ'); #INSERT INTO t1 VALUES ('ОПРСТ');
SELECT c, HEX(c) FROM t1; #SELECT c, HEX(c) FROM t1;
DROP TABLE t1; #DROP TABLE t1;
--echo # --echo #

View File

@@ -2354,11 +2354,11 @@ int ODBConn::GetCatInfo(CATPARM *cap)
if (!Check(rc)) if (!Check(rc))
ThrowDBX(rc, fnc, hstmt); ThrowDBX(rc, fnc, hstmt);
rc = SQLNumResultCols(hstmt, &ncol); // Some data source do not implement SQLNumResultCols
if (Check(SQLNumResultCols(hstmt, &ncol)))
// n because we no more ignore the first column // n because we no more ignore the first column
if ((n = (UWORD)qrp->Nbcol) > (UWORD)ncol) if ((n = (UWORD)qrp->Nbcol) > (UWORD)ncol)
ThrowDBX(MSG(COL_NUM_MISM)); ThrowDBX(MSG(COL_NUM_MISM));
// Unconditional to handle STRBLK's // Unconditional to handle STRBLK's
pval = (PVAL *)PlugSubAlloc(g, NULL, n * sizeof(PVAL)); pval = (PVAL *)PlugSubAlloc(g, NULL, n * sizeof(PVAL));

View File

@@ -125,6 +125,12 @@ EXTDEF::EXTDEF(void)
/***********************************************************************/ /***********************************************************************/
bool EXTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) 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; Desc = NULL;
Tabname = GetStringCatInfo(g, "Name", Tabname = GetStringCatInfo(g, "Name",
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name); (Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
@@ -286,7 +292,7 @@ bool TDBEXT::MakeSrcdef(PGLOBAL g)
char *catp = strstr(Srcdef, "%s"); char *catp = strstr(Srcdef, "%s");
if (catp) { if (catp) {
char *fil1, *fil2; char *fil1 = 0, *fil2;
PCSZ ph = ((EXTDEF*)To_Def)->Phpos; PCSZ ph = ((EXTDEF*)To_Def)->Phpos;
if (!ph) if (!ph)

View File

@@ -1157,8 +1157,9 @@ bool TDBXJDC::OpenDB(PGLOBAL g)
/* Get the command to execute. */ /* Get the command to execute. */
/*********************************************************************/ /*********************************************************************/
if (!(Cmdlist = MakeCMD(g))) { if (!(Cmdlist = MakeCMD(g))) {
Jcp->Close(); // Next lines commented out because of CHECK TABLE
return true; //Jcp->Close();
//return true;
} // endif Query } // endif Query
Rows = 1; Rows = 1;
@@ -1189,8 +1190,10 @@ int TDBXJDC::ReadDB(PGLOBAL g)
Fpos++; // Used for progress info Fpos++; // Used for progress info
Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next; Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next;
return RC_OK; return RC_OK;
} else } else {
PushWarning(g, this, 1);
return RC_EF; return RC_EF;
} // endif Cmdlist
} // end of ReadDB } // end of ReadDB

View File

@@ -72,7 +72,7 @@ bool JMGDISC::Find(PGLOBAL g)
bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt, bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
int ncol, int k) int ncol, int k)
{ {
const char *key; const char *key, *utf;
char colname[65]; char colname[65];
char fmt[129]; char fmt[129];
bool rc = true; bool rc = true;
@@ -101,7 +101,10 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
continue; continue;
jkey = (jstring)Jcp->env->CallObjectMethod(Jcp->job, bvnameid); 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) { if (pcn) {
strncpy(colname, pcn, 64); strncpy(colname, pcn, 64);
@@ -457,8 +460,8 @@ PSZ JMGCOL::GetJpath(PGLOBAL g, bool proj)
} else } else
*p2++ = *p1; *p2++ = *p1;
*p2 = 0; *p2 = 0;
return projpath; return projpath;
} else } else
return Jpath; return Jpath;

View File

@@ -16,6 +16,7 @@ typedef class JSONDEF *PJDEF;
typedef class TDBJSON *PJTDB; typedef class TDBJSON *PJTDB;
typedef class JSONCOL *PJCOL; typedef class JSONCOL *PJCOL;
class TDBJSN; 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. */ /* The JSON tree node. Can be an Object or an Array. */

View File

@@ -1587,8 +1587,9 @@ bool TDBMYEXC::OpenDB(PGLOBAL g)
/* Get the command to execute. */ /* Get the command to execute. */
/*********************************************************************/ /*********************************************************************/
if (!(Cmdlist = MakeCMD(g))) { if (!(Cmdlist = MakeCMD(g))) {
Myc.Close(); // Next lines commented out because of CHECK TABLE
return true; //Myc.Close();
//return true;
} // endif Cmdlist } // endif Cmdlist
return false; return false;
@@ -1647,8 +1648,10 @@ int TDBMYEXC::ReadDB(PGLOBAL g)
++N; ++N;
return RC_OK; return RC_OK;
} else } else {
return RC_EF; PushWarning(g, this, 1);
return RC_EF;
} // endif Cmdlist
} // end of ReadDB } // end of ReadDB

View File

@@ -1249,9 +1249,10 @@ bool TDBXDBC::OpenDB(PGLOBAL g)
/* Get the command to execute. */ /* Get the command to execute. */
/*********************************************************************/ /*********************************************************************/
if (!(Cmdlist = MakeCMD(g))) { if (!(Cmdlist = MakeCMD(g))) {
Ocp->Close(); // Next lines commented out because of CHECK TABLE
return true; //Ocp->Close();
} // endif Query //return true;
} // endif Cmdlist
Rows = 1; Rows = 1;
return false; return false;
@@ -1274,8 +1275,10 @@ int TDBXDBC::ReadDB(PGLOBAL g)
Fpos++; // Used for progress info Fpos++; // Used for progress info
Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next; Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next;
return RC_OK; return RC_OK;
} else } else {
return RC_EF; PushWarning(g, this, 1);
return RC_EF;
} // endif Cmdlist
} // end of ReadDB } // end of ReadDB

View File

@@ -107,12 +107,12 @@ bool PIVAID::SkipColumn(PCOLRES crp, char *skc)
/***********************************************************************/ /***********************************************************************/
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
{ {
char *p, *query, *colname, *skc, buf[64]; char *p, *query, *colname, *skc, buf[64];
int ndif, nblin, w = 0; int ndif, nblin, w = 0;
bool b = false; bool b = false;
PVAL valp; PVAL valp;
PQRYRES qrp; PQRYRES qrp;
PCOLRES *pcrp, crp, fncrp = NULL; PCOLRES *pcrp, crp, fncrp = NULL;
try { try {
// Are there columns to skip? // Are there columns to skip?
@@ -186,7 +186,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} // endif picol } // endif picol
// Prepare the column list // Prepare the column list
for (pcrp = &Qryp->Colresp; crp = *pcrp; ) for (pcrp = &Qryp->Colresp; crp = *pcrp; )
if (SkipColumn(crp, skc)) { if (SkipColumn(crp, skc)) {
// Ignore this column // Ignore this column
@@ -205,95 +205,95 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} else } else
pcrp = &crp->Next; pcrp = &crp->Next;
if (!Rblkp) { if (!Rblkp) {
strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); strcpy(g->Message, MSG(NO_DEF_PIVOTCOL));
goto err; goto err;
} else if (!fncrp) { } else if (!fncrp) {
strcpy(g->Message, MSG(NO_DEF_FNCCOL)); strcpy(g->Message, MSG(NO_DEF_FNCCOL));
goto err; goto err;
} // endif } // endif
if (Tabsrc) { if (Tabsrc) {
Myc.Close(); Myc.Close();
b = false; b = false;
// Before calling sort, initialize all // Before calling sort, initialize all
nblin = Qryp->Nblin; nblin = Qryp->Nblin;
Index.Size = nblin * sizeof(int); Index.Size = nblin * sizeof(int);
Index.Sub = TRUE; // Should be small enough Index.Sub = TRUE; // Should be small enough
if (!PlgDBalloc(g, NULL, Index)) if (!PlgDBalloc(g, NULL, Index))
goto err;
Offset.Size = (nblin + 1) * sizeof(int);
Offset.Sub = TRUE; // Should be small enough
if (!PlgDBalloc(g, NULL, Offset))
goto err;
ndif = Qsort(g, nblin);
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;
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;
// We must have a storage query to get pivot column values
if (!(qrp = Myc.GetResult(g, true)))
goto err;
Myc.Close();
b = false;
// 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; goto err;
// Now make the functional columns Offset.Size = (nblin + 1) * sizeof(int);
for (int i = 0; i < ndif; i++) { Offset.Sub = TRUE; // Should be small enough
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 (!PlgDBalloc(g, NULL, Offset))
if (Tabsrc) goto err;
valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]);
else
valp->SetValue_pvblk(Rblkp, i);
colname = valp->GetCharString(buf); ndif = Qsort(g, nblin);
crp->Name = PlugDup(g, colname);
crp->Flag = 1;
// Add this column if (ndif < 0) // error
*pcrp = crp; goto err;
crp->Next = NULL;
pcrp = &crp->Next; } else {
} // endfor i // 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();
// 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;
Myc.Close();
b = false;
// 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;
// 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) // We added ndif columns and removed 2 (picol and fncol)
Qryp->Nbcol += (ndif - 2); Qryp->Nbcol += (ndif - 2);
@@ -306,10 +306,10 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} // end catch } // end catch
err: err:
if (b) if (b)
Myc.Close(); Myc.Close();
return NULL; return NULL;
} // end of MakePivotColumns } // end of MakePivotColumns
/***********************************************************************/ /***********************************************************************/

View File

@@ -429,7 +429,7 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
char buf[MAX_STR]; char buf[MAX_STR];
strcpy(buf, g->Message); 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; hc->tshp = NULL;
goto err; goto err;
} // endif Define } // endif Define

View File

@@ -456,13 +456,11 @@ bool VCTCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
if (tdbp->Txfp->GetAmType() == TYPE_AM_VMP && ok) { if (tdbp->Txfp->GetAmType() == TYPE_AM_VMP && ok) {
Blk = AllocValBlock(g, (void*)1, Buf_Type, tdbp->Txfp->Nrec, Blk = AllocValBlock(g, (void*)1, Buf_Type, tdbp->Txfp->Nrec,
Format.Length, Format.Length, Format.Prec, check, true, Unsigned);
Format.Prec, check);
Status |= BUF_MAPPED; // Will point into mapped file Status |= BUF_MAPPED; // Will point into mapped file
} else } else
Blk = AllocValBlock(g, NULL, Buf_Type, tdbp->Txfp->Nrec, Blk = AllocValBlock(g, NULL, Buf_Type, tdbp->Txfp->Nrec,
Format.Length, Format.Length, Format.Prec, check, true, Unsigned);
Format.Prec, check);
} // endif Mode } // endif Mode
return false; return false;

View File

@@ -36,6 +36,7 @@
#define DONT_DEFINE_VOID #define DONT_DEFINE_VOID
#define MYSQL_SERVER #define MYSQL_SERVER
#include <my_global.h>
#include "sql_class.h" #include "sql_class.h"
#undef OFFSET #undef OFFSET