Skip to content

Commit

Permalink
Merge branch 'ob-10.1' into 10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Buggynours committed Aug 8, 2018
2 parents 0153618 + 31dda7e commit cce151f
Show file tree
Hide file tree
Showing 22 changed files with 162 additions and 221 deletions.
4 changes: 2 additions & 2 deletions storage/connect/filamtxt.cpp
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions storage/connect/filamvct.cpp
Expand Up @@ -353,7 +353,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

/***********************************************************************/
Expand Down Expand Up @@ -2458,11 +2458,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;
Expand Down
24 changes: 8 additions & 16 deletions storage/connect/ha_connect.cc
Expand Up @@ -170,7 +170,7 @@
#define JSONMAX 10 // JSON Default max grp size

extern "C" {
char version[]= "Version 1.06.0007 March 11, 2018";
char version[]= "Version 1.06.0007 August 06, 2018";
#if defined(__WIN__)
char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__;
char slash= '\\';
Expand Down Expand Up @@ -3303,23 +3303,15 @@ 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(g->Message);
} else
buf->append("Cannot retrieve error message");

DBUG_RETURN(false);
} // end of get_error_message
Expand Down
41 changes: 13 additions & 28 deletions storage/connect/javaconn.cpp
Expand Up @@ -81,29 +81,6 @@ GETDEF JAVAConn::GetDefaultJavaVMInitArgs = NULL;
#define DEBUG_ONLY(f) ((void)0)
#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. */
/***********************************************************************/
Expand Down Expand Up @@ -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. */
Expand All @@ -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, (jboolean)false);
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, (jboolean)false);
Msg = GetUTFString(s);
} else
Msg = NULL;

Expand Down
1 change: 1 addition & 0 deletions storage/connect/javaconn.h
Expand Up @@ -90,6 +90,7 @@ class DllExport JAVAConn : public BLOCK {

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

Expand Down
38 changes: 13 additions & 25 deletions storage/connect/jdbconn.cpp
Expand Up @@ -322,10 +322,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;
Expand Down Expand Up @@ -707,21 +703,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;

Expand Down Expand Up @@ -836,11 +825,11 @@ bool JDBConn::Connect(PJPARM sop)
jstring s = (jstring)env->CallObjectMethod(job, qcid);

if (s != nullptr) {
char *qch = (char*)env->GetStringUTFChars(s, (jboolean)false);
char *qch = GetUTFString(s);
m_IDQuoteChar[0] = *qch;
} else {
s = (jstring)env->CallObjectMethod(job, errid);
Msg = (char*)env->GetStringUTFChars(s, (jboolean)false);
Msg = GetUTFString(s);
} // endif s

} // endif qcid
Expand Down Expand Up @@ -1018,7 +1007,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr;

if (cn) {
field = env->GetStringUTFChars(cn, (jboolean)false);
field = GetUTFString(cn);
val->SetValue_psz((PSZ)field);
} else
val->Reset();
Expand Down Expand Up @@ -1092,8 +1081,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr;

if (cn) {
const char *field = env->GetStringUTFChars(cn, (jboolean)false);
val->SetValue_psz((PSZ)field);
val->SetValue_psz((PSZ)GetUTFString(cn));
} else
val->Reset();

Expand Down Expand Up @@ -1372,19 +1360,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

Expand Down Expand Up @@ -1470,7 +1458,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
return NULL;
} // endif label

name = env->GetStringUTFChars(label, (jboolean)false);
name = GetUTFString(label);
crp = qrp->Colresp; // Column_Name
crp->Kdata->SetValue((char*)name, i);
n = env->GetIntArrayElements(val, 0);
Expand Down
6 changes: 3 additions & 3 deletions storage/connect/jmgoconn.cpp
Expand Up @@ -522,7 +522,7 @@ PSZ JMgoConn::GetDocument(void)
jdc = (jstring)env->CallObjectMethod(job, getdocid);

if (jdc)
doc = (PSZ)env->GetStringUTFChars(jdc, (jboolean)false);
doc = (PSZ)GetUTFString(jdc);

} // endif getdocid

Expand Down Expand Up @@ -690,7 +690,7 @@ jobject JMgoConn::MakeDoc(PGLOBAL g, PJNCOL jcp)

} // endif Jncolp

return parent;
return parent;
} // end of MakeDoc

/***********************************************************************/
Expand Down Expand Up @@ -807,7 +807,7 @@ PSZ JMgoConn::GetColumnValue(PSZ path)
fn = (jstring)env->CallObjectMethod(job, objfldid, jn);

if (fn)
fld = (PSZ)env->GetStringUTFChars(fn, (jboolean)false);
fld = (PSZ)GetUTFString(fn);

} // endif objfldid

Expand Down
2 changes: 1 addition & 1 deletion storage/connect/jsonudf.cpp
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions storage/connect/mysql-test/connect/r/jdbc.result
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion 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
Expand Down
1 change: 0 additions & 1 deletion 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
Expand Down
1 change: 0 additions & 1 deletion 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
Expand Down
1 change: 0 additions & 1 deletion 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
Expand Down
31 changes: 0 additions & 31 deletions storage/connect/mysql-test/connect/r/xml2.result
Expand Up @@ -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
#
Expand Down
2 changes: 2 additions & 0 deletions 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;
Expand Down
2 changes: 2 additions & 0 deletions 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;
Expand Down
2 changes: 2 additions & 0 deletions 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;
Expand Down
2 changes: 2 additions & 0 deletions 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;
Expand Down

0 comments on commit cce151f

Please sign in to comment.