Commit 26e2dd39 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'connect/10.2' into 10.2

parents 4ddcb4eb 9644415f
...@@ -1173,11 +1173,11 @@ int DOSFAM::RenameTempFile(PGLOBAL g) ...@@ -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;
......
...@@ -2453,11 +2453,11 @@ int VECFAM::RenameTempFile(PGLOBAL g) ...@@ -2453,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;
......
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
#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.0007 August 06, 2018";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__; char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
...@@ -3304,22 +3304,14 @@ bool ha_connect::get_error_message(int error, String* buf) ...@@ -3304,22 +3304,14 @@ 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(g->Message);
buf->copy(msg, (uint)strlen(msg), system_charset_info);
} 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
......
...@@ -138,6 +138,16 @@ JAVAConn::JAVAConn(PGLOBAL g, PCSZ wrapper) ...@@ -138,6 +138,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 +162,15 @@ bool JAVAConn::Check(jint rc) ...@@ -152,17 +162,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, (jboolean)false); 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, (jboolean)false); Msg = GetUTFString(s);
} else } else
Msg = NULL; Msg = NULL;
......
...@@ -90,6 +90,7 @@ class DllExport JAVAConn : public BLOCK { ...@@ -90,6 +90,7 @@ class DllExport JAVAConn : public BLOCK {
// 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);
......
...@@ -707,21 +707,14 @@ bool JDBConn::SetUUID(PGLOBAL g, PTDBJDBC tjp) ...@@ -707,21 +707,14 @@ 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); ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr);
//if (Check((jtyp == 666) ? -1 : 1)) { //if (Check((ctyp == 666) ? -1 : 1)) {
// sprintf(g->Message, "Getting jtyp: %s", Msg); // sprintf(g->Message, "Getting ctyp: %s", Msg);
// goto err; // goto err;
//} // endif ctyp //} // 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) if (ctyp == 1111)
((PJDBCCOL)colp)->uuid = true; ((PJDBCCOL)colp)->uuid = true;
...@@ -836,11 +829,11 @@ bool JDBConn::Connect(PJPARM sop) ...@@ -836,11 +829,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, (jboolean)false); 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, (jboolean)false); Msg = GetUTFString(s);
} // endif s } // endif s
} // endif qcid } // endif qcid
...@@ -1018,7 +1011,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1018,7 +1011,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr; cn = nullptr;
if (cn) { if (cn) {
field = env->GetStringUTFChars(cn, (jboolean)false); field = GetUTFString(cn);
val->SetValue_psz((PSZ)field); val->SetValue_psz((PSZ)field);
} else } else
val->Reset(); val->Reset();
...@@ -1092,8 +1085,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1092,8 +1085,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr; cn = nullptr;
if (cn) { if (cn) {
const char *field = env->GetStringUTFChars(cn, (jboolean)false); val->SetValue_psz((PSZ)GetUTFString(cn));
val->SetValue_psz((PSZ)field);
} else } else
val->Reset(); val->Reset();
...@@ -1372,19 +1364,19 @@ bool JDBConn::SetParam(JDBCCOL *colp) ...@@ -1372,19 +1364,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
...@@ -1470,7 +1462,7 @@ bool JDBConn::SetParam(JDBCCOL *colp) ...@@ -1470,7 +1462,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
return NULL; return NULL;
} // endif label } // endif label
name = env->GetStringUTFChars(label, (jboolean)false); 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);
......
...@@ -522,7 +522,7 @@ PSZ JMgoConn::GetDocument(void) ...@@ -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, (jboolean)false); doc = (PSZ)GetUTFString(jdc);
} // endif getdocid } // endif getdocid
...@@ -807,7 +807,7 @@ PSZ JMgoConn::GetColumnValue(PSZ path) ...@@ -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, (jboolean)false); fld = (PSZ)GetUTFString(fn);
} // endif objfldid } // endif objfldid
......
...@@ -4631,7 +4631,7 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -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;
......
...@@ -238,8 +238,7 @@ DROP TABLE t1, connect.emp; ...@@ -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:24) 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
......
...@@ -72,7 +72,7 @@ bool JMGDISC::Find(PGLOBAL g) ...@@ -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, ...@@ -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, (jboolean)false); 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);
......
...@@ -429,7 +429,7 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) ...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment