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)
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;
......
......@@ -2453,11 +2453,11 @@ int VECFAM::RenameTempFile(PGLOBAL g)
remove(filetemp); // May still be there from previous error
if (rename(filename, filetemp)) { // Save file for security
sprintf(g->Message, MSG(RENAME_ERROR),
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
filename, filetemp, strerror(errno));
rc = RC_FX;
} else if (rename(tempname, filename)) {
sprintf(g->Message, MSG(RENAME_ERROR),
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file
rc = RC_FX;
......
......@@ -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= '\\';
......@@ -3304,22 +3304,14 @@ 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);
PGLOBAL g = xp->g;
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->copy(msg, (uint)strlen(msg), system_charset_info);
buf->append(g->Message);
} else
buf->copy("Cannot retrieve msg", 19, system_charset_info);
buf->append("Cannot retrieve error message");
DBUG_RETURN(false);
} // end of get_error_message
......
......@@ -138,6 +138,16 @@ JAVAConn::JAVAConn(PGLOBAL g, PCSZ wrapper)
// EndCom();
// } // end of ~JAVAConn
char *JAVAConn::GetUTFString(jstring s)
{
char *str;
const char *utf = env->GetStringUTFChars(s, nullptr);
str = PlugDup(m_G, utf);
env->ReleaseStringUTFChars(s, utf);
env->DeleteLocalRef(s);
return str;
} // end of GetUTFString
/***********************************************************************/
/* Screen for errors. */
......@@ -152,17 +162,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;
......
......@@ -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);
......
......@@ -707,21 +707,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;
......@@ -836,11 +829,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
......@@ -1018,7 +1011,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();
......@@ -1092,8 +1085,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();
......@@ -1372,19 +1364,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
......@@ -1470,7 +1462,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);
......
......@@ -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
......@@ -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
......
......@@ -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;
......
......@@ -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:24) 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
......
......@@ -72,7 +72,7 @@ bool JMGDISC::Find(PGLOBAL g)
bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
int ncol, int k)
{
const char *key;
const char *key, *utf;
char colname[65];
char fmt[129];
bool rc = true;
......@@ -101,7 +101,10 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
continue;
jkey = (jstring)Jcp->env->CallObjectMethod(Jcp->job, bvnameid);
key = Jcp->env->GetStringUTFChars(jkey, (jboolean)false);
utf = Jcp->env->GetStringUTFChars(jkey, nullptr);
key = PlugDup(g, utf);
Jcp->env->ReleaseStringUTFChars(jkey, utf);
Jcp->env->DeleteLocalRef(jkey);
if (pcn) {
strncpy(colname, pcn, 64);
......
......@@ -429,7 +429,7 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
char buf[MAX_STR];
strcpy(buf, g->Message);
sprintf(g->Message, "Error accessing %s.%s: %s", db, name, buf);
snprintf(g->Message, MAX_STR, "Error accessing %s.%s: %s", db, name, buf);
hc->tshp = NULL;
goto err;
} // endif Define
......
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