Skip to content

Commit cce151f

Browse files
committed
Merge branch 'ob-10.1' into 10.1
2 parents 0153618 + 31dda7e commit cce151f

22 files changed

+162
-221
lines changed

storage/connect/filamtxt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,11 +1173,11 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
11731173
remove(filetemp); // May still be there from previous error
11741174

11751175
if (rename(filename, filetemp)) { // Save file for security
1176-
sprintf(g->Message, MSG(RENAME_ERROR),
1176+
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
11771177
filename, filetemp, strerror(errno));
11781178
throw 51;
11791179
} else if (rename(tempname, filename)) {
1180-
sprintf(g->Message, MSG(RENAME_ERROR),
1180+
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
11811181
tempname, filename, strerror(errno));
11821182
rc = rename(filetemp, filename); // Restore saved file
11831183
throw 52;

storage/connect/filamvct.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ int VCTFAM::Cardinality(PGLOBAL g)
353353

354354
} // endif split
355355

356-
return (Block) ? ((Block - 1) * Nrec + Last) : 0;
356+
return (Block) ? ((Block - 1) * Nrec + Last) : 0;
357357
} // end of Cardinality
358358

359359
/***********************************************************************/
@@ -2458,11 +2458,11 @@ int VECFAM::RenameTempFile(PGLOBAL g)
24582458
remove(filetemp); // May still be there from previous error
24592459

24602460
if (rename(filename, filetemp)) { // Save file for security
2461-
sprintf(g->Message, MSG(RENAME_ERROR),
2461+
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
24622462
filename, filetemp, strerror(errno));
24632463
rc = RC_FX;
24642464
} else if (rename(tempname, filename)) {
2465-
sprintf(g->Message, MSG(RENAME_ERROR),
2465+
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
24662466
tempname, filename, strerror(errno));
24672467
rc = rename(filetemp, filename); // Restore saved file
24682468
rc = RC_FX;

storage/connect/ha_connect.cc

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
#define JSONMAX 10 // JSON Default max grp size
171171

172172
extern "C" {
173-
char version[]= "Version 1.06.0007 March 11, 2018";
173+
char version[]= "Version 1.06.0007 August 06, 2018";
174174
#if defined(__WIN__)
175175
char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__;
176176
char slash= '\\';
@@ -3303,23 +3303,15 @@ bool ha_connect::get_error_message(int error, String* buf)
33033303
{
33043304
DBUG_ENTER("ha_connect::get_error_message");
33053305

3306-
if (xp && xp->g) {
3307-
PGLOBAL g= xp->g;
3308-
char msg[3072]; // MAX_STR * 3
3309-
uint dummy_errors;
3310-
uint32 len= copy_and_convert(msg, strlen(g->Message) * 3,
3311-
system_charset_info,
3312-
g->Message, strlen(g->Message),
3313-
&my_charset_latin1,
3314-
&dummy_errors);
3306+
if (xp && xp->g) {
3307+
PGLOBAL g = xp->g;
33153308

3316-
if (trace(1))
3317-
htrc("GEM(%d): len=%u %s\n", error, len, g->Message);
3309+
if (trace(1))
3310+
htrc("GEM(%d): %s\n", error, g->Message);
33183311

3319-
msg[len]= '\0';
3320-
buf->copy(msg, (uint)strlen(msg), system_charset_info);
3321-
} else
3322-
buf->copy("Cannot retrieve msg", 19, system_charset_info);
3312+
buf->append(g->Message);
3313+
} else
3314+
buf->append("Cannot retrieve error message");
33233315

33243316
DBUG_RETURN(false);
33253317
} // end of get_error_message

storage/connect/javaconn.cpp

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,6 @@ GETDEF JAVAConn::GetDefaultJavaVMInitArgs = NULL;
8181
#define DEBUG_ONLY(f) ((void)0)
8282
#endif // !_DEBUG
8383

84-
/***********************************************************************/
85-
/* Allocate the structure used to refer to the result set. */
86-
/***********************************************************************/
87-
static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, PCSZ db,
88-
PCSZ tab, PQRYRES qrp)
89-
{
90-
JCATPARM *cap;
91-
92-
#if defined(_DEBUG)
93-
assert(qrp);
94-
#endif
95-
96-
if ((cap = (JCATPARM *)PlgDBSubAlloc(g, NULL, sizeof(JCATPARM)))) {
97-
memset(cap, 0, sizeof(JCATPARM));
98-
cap->Id = fid;
99-
cap->Qrp = qrp;
100-
cap->DB = db;
101-
cap->Tab = tab;
102-
} // endif cap
103-
104-
return cap;
105-
} // end of AllocCatInfo
106-
10784
/***********************************************************************/
10885
/* JAVAConn construction/destruction. */
10986
/***********************************************************************/
@@ -138,6 +115,16 @@ JAVAConn::JAVAConn(PGLOBAL g, PCSZ wrapper)
138115
// EndCom();
139116

140117
// } // end of ~JAVAConn
118+
char *JAVAConn::GetUTFString(jstring s)
119+
{
120+
char *str;
121+
const char *utf = env->GetStringUTFChars(s, nullptr);
122+
123+
str = PlugDup(m_G, utf);
124+
env->ReleaseStringUTFChars(s, utf);
125+
env->DeleteLocalRef(s);
126+
return str;
127+
} // end of GetUTFString
141128

142129
/***********************************************************************/
143130
/* Screen for errors. */
@@ -152,17 +139,15 @@ bool JAVAConn::Check(jint rc)
152139
"toString", "()Ljava/lang/String;");
153140

154141
if (exc != nullptr && tid != nullptr) {
155-
jstring s = (jstring)env->CallObjectMethod(exc, tid);
156-
const char *utf = env->GetStringUTFChars(s, (jboolean)false);
157-
env->DeleteLocalRef(s);
158-
Msg = PlugDup(m_G, utf);
142+
s = (jstring)env->CallObjectMethod(exc, tid);
143+
Msg = GetUTFString(s);
159144
} else
160145
Msg = "Exception occured";
161146

162147
env->ExceptionClear();
163148
} else if (rc < 0) {
164149
s = (jstring)env->CallObjectMethod(job, errid);
165-
Msg = (char*)env->GetStringUTFChars(s, (jboolean)false);
150+
Msg = GetUTFString(s);
166151
} else
167152
Msg = NULL;
168153

storage/connect/javaconn.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class DllExport JAVAConn : public BLOCK {
9090

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

storage/connect/jdbconn.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,6 @@ static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, PCSZ db,
322322
{
323323
JCATPARM *cap;
324324

325-
#if defined(_DEBUG)
326-
assert(qrp);
327-
#endif
328-
329325
if ((cap = (JCATPARM *)PlgDBSubAlloc(g, NULL, sizeof(JCATPARM)))) {
330326
memset(cap, 0, sizeof(JCATPARM));
331327
cap->Id = fid;
@@ -707,21 +703,14 @@ bool JDBConn::SetUUID(PGLOBAL g, PTDBJDBC tjp)
707703
goto err;
708704
} // endif rc
709705

710-
// Returns 666 is case of error
711-
//jtyp = env->CallIntMethod(job, typid, 5, nullptr);
706+
// Should return 666 is case of error (not done yet)
707+
ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr);
712708

713-
//if (Check((jtyp == 666) ? -1 : 1)) {
714-
// sprintf(g->Message, "Getting jtyp: %s", Msg);
709+
//if (Check((ctyp == 666) ? -1 : 1)) {
710+
// sprintf(g->Message, "Getting ctyp: %s", Msg);
715711
// goto err;
716712
//} // endif ctyp
717713

718-
ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr);
719-
720-
if (Check(ctyp)) {
721-
sprintf(g->Message, "Getting ctyp: %s", Msg);
722-
goto err;
723-
} // endif ctyp
724-
725714
if (ctyp == 1111)
726715
((PJDBCCOL)colp)->uuid = true;
727716

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

838827
if (s != nullptr) {
839-
char *qch = (char*)env->GetStringUTFChars(s, (jboolean)false);
828+
char *qch = GetUTFString(s);
840829
m_IDQuoteChar[0] = *qch;
841830
} else {
842831
s = (jstring)env->CallObjectMethod(job, errid);
843-
Msg = (char*)env->GetStringUTFChars(s, (jboolean)false);
832+
Msg = GetUTFString(s);
844833
} // endif s
845834

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

10201009
if (cn) {
1021-
field = env->GetStringUTFChars(cn, (jboolean)false);
1010+
field = GetUTFString(cn);
10221011
val->SetValue_psz((PSZ)field);
10231012
} else
10241013
val->Reset();
@@ -1092,8 +1081,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
10921081
cn = nullptr;
10931082

10941083
if (cn) {
1095-
const char *field = env->GetStringUTFChars(cn, (jboolean)false);
1096-
val->SetValue_psz((PSZ)field);
1084+
val->SetValue_psz((PSZ)GetUTFString(cn));
10971085
} else
10981086
val->Reset();
10991087

@@ -1372,19 +1360,19 @@ bool JDBConn::SetParam(JDBCCOL *colp)
13721360
for (i = 0, n = 0; i < size; i++) {
13731361
crp = qrp->Colresp;
13741362
js = (jstring)env->GetObjectArrayElement(s, n++);
1375-
sval = (PSZ)env->GetStringUTFChars(js, 0);
1363+
sval = GetUTFString(js);
13761364
crp->Kdata->SetValue(sval, i);
13771365
crp = crp->Next;
13781366
js = (jstring)env->GetObjectArrayElement(s, n++);
1379-
sval = (PSZ)env->GetStringUTFChars(js, 0);
1367+
sval = GetUTFString(js);
13801368
crp->Kdata->SetValue(sval, i);
13811369
crp = crp->Next;
13821370
js = (jstring)env->GetObjectArrayElement(s, n++);
1383-
sval = (PSZ)env->GetStringUTFChars(js, 0);
1371+
sval = GetUTFString(js);
13841372
crp->Kdata->SetValue(sval, i);
13851373
crp = crp->Next;
13861374
js = (jstring)env->GetObjectArrayElement(s, n++);
1387-
sval = (PSZ)env->GetStringUTFChars(js, 0);
1375+
sval = GetUTFString(js);
13881376
crp->Kdata->SetValue(sval, i);
13891377
} // endfor i
13901378

@@ -1470,7 +1458,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
14701458
return NULL;
14711459
} // endif label
14721460

1473-
name = env->GetStringUTFChars(label, (jboolean)false);
1461+
name = GetUTFString(label);
14741462
crp = qrp->Colresp; // Column_Name
14751463
crp->Kdata->SetValue((char*)name, i);
14761464
n = env->GetIntArrayElements(val, 0);

storage/connect/jmgoconn.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ PSZ JMgoConn::GetDocument(void)
522522
jdc = (jstring)env->CallObjectMethod(job, getdocid);
523523

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

527527
} // endif getdocid
528528

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

691691
} // endif Jncolp
692692

693-
return parent;
693+
return parent;
694694
} // end of MakeDoc
695695

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

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

812812
} // endif objfldid
813813

storage/connect/jsonudf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4631,7 +4631,7 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
46314631
bsp = NULL;
46324632

46334633
if (!bsp && (bsp = JbinAlloc(g, args, initid->max_length, NULL)))
4634-
strncpy(bsp->Msg, g->Message, 139);
4634+
strncpy(bsp->Msg, g->Message, BMX);
46354635

46364636
// Keep result of constant function
46374637
g->Xchk = (initid->const_item) ? bsp : NULL;

storage/connect/mysql-test/connect/r/jdbc.result

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ DROP TABLE t1, connect.emp;
238238
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';
239239
SELECT * FROM t2 WHERE command='drop table tx1';
240240
command number message
241-
drop table tx1 0 Execute: java.sql.SQLSyntaxErrorException: Unknown table 'connect.tx1'
242-
Query is : drop table tx1
241+
drop table tx1 0 Execute: java.sql.SQLSyntaxErrorException: (conn:23) Unknown table 'connect.tx1'
243242
SELECT * FROM t2 WHERE command = 'create table tx1 (a int not null, b char(32), c double(8,2))';
244243
command number message
245244
create table tx1 (a int not null, b char(32), c double(8,2)) 0 Affected rows

storage/connect/mysql-test/connect/r/json_java_2.result

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/Mongo2.jar';
21
set connect_enable_mongo=1;
32
#
43
# Test the MONGO table type

0 commit comments

Comments
 (0)