summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2017-10-16 15:08:17 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2017-10-16 15:08:17 +0200
commitc83e2a63452946cf58241380f03a23ab4884c42b (patch)
treed0bbb84f9a6110ca1346c4ba14003276dca0a728
parent6691d12e2d5d0aa26353ddca143067edf4cf56d5 (diff)
downloadmariadb-git-c83e2a63452946cf58241380f03a23ab4884c42b.tar.gz
- Fix a bug in TYPVAL<PSZ> compute causing it sometime not to be executed
This was the cause of the bug in CalculateArray modified: storage/connect/jsonudf.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/value.cpp - Avoid some compiler warnings modified: storage/connect/mongo.cpp modified: storage/connect/tabjmg.cpp modified: storage/connect/tabtbl.cpp modified: storage/connect/tabutil.cpp
-rw-r--r--storage/connect/jsonudf.cpp3
-rw-r--r--storage/connect/mongo.cpp5
-rw-r--r--storage/connect/tabjmg.cpp13
-rw-r--r--storage/connect/tabjson.cpp11
-rw-r--r--storage/connect/tabtbl.cpp2
-rw-r--r--storage/connect/tabutil.cpp4
-rw-r--r--storage/connect/value.cpp17
7 files changed, 36 insertions, 19 deletions
diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp
index 078aff29bfe..afb5ae811c7 100644
--- a/storage/connect/jsonudf.cpp
+++ b/storage/connect/jsonudf.cpp
@@ -512,6 +512,9 @@ PVAL JSNX::CalculateArray(PGLOBAL g, PJAR arp, int n)
for (i = 0; i < ars; i++) {
jvrp = arp->GetValue(i);
+ if (trace)
+ htrc("i=%d nv=%d\n", i, nv);
+
if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) {
if (jvrp->IsNull()) {
jvrp->Value = AllocateValue(g, GetJsonNull(), TYPE_STRING);
diff --git a/storage/connect/mongo.cpp b/storage/connect/mongo.cpp
index 6b5c9ec8e8f..088dc2d29d1 100644
--- a/storage/connect/mongo.cpp
+++ b/storage/connect/mongo.cpp
@@ -33,6 +33,7 @@
#define MAXCOL 200 /* Default max column nb in result */
#define TYPE_UNKNOWN 12 /* Must be greater than other types */
+bool MakeSelector(PGLOBAL g, PFIL fp, PSTRG s);
bool IsNum(PSZ s);
/***********************************************************************/
@@ -130,7 +131,7 @@ PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info)
int i, n = 0;
PCSZ drv;
PBCOL bcp;
- MGODISC *cmgd;
+ MGODISC *cmgd = NULL;
PQRYRES qrp;
PCOLRES crp;
@@ -223,7 +224,7 @@ skipit:
return qrp;
err:
- if (cmgd->tmgp)
+ if (cmgd && cmgd->tmgp)
cmgd->tmgp->CloseDB(g);
return NULL;
diff --git a/storage/connect/tabjmg.cpp b/storage/connect/tabjmg.cpp
index 566b1f91611..ba3e1c3e7c0 100644
--- a/storage/connect/tabjmg.cpp
+++ b/storage/connect/tabjmg.cpp
@@ -73,9 +73,10 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
int ncol, int k)
{
const char *key;
- char colname[65];
- char fmt[129];
- bool rc = true;
+ char colname[65];
+ char fmt[129];
+ bool rc = true;
+ size_t z;
jint *n = nullptr;
jstring jkey;
jobject jres;
@@ -105,14 +106,16 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
if (pcn) {
strncpy(colname, pcn, 64);
colname[64] = 0;
- strncat(strncat(colname, "_", 65), key, 65);
+ z = 65 - strlen(colname);
+ strncat(strncat(colname, "_", z), key, z - 1);
} else
strcpy(colname, key);
if (pfmt) {
strncpy(fmt, pfmt, 128);
fmt[128] = 0;
- strncat(strncat(fmt, ".", 129), key, 129);
+ z = 129 - strlen(fmt);
+ strncat(strncat(fmt, ".", z), key, z - 1);
} else
strcpy(fmt, key);
diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp
index 24881aae415..8778b7d4b47 100644
--- a/storage/connect/tabjson.cpp
+++ b/storage/connect/tabjson.cpp
@@ -1592,16 +1592,14 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
ars = MY_MIN(Tjp->Limit, arp->size());
if (trace)
- htrc("CalculateArray size=%d op=%d nextsame=%d\n", ars, op, nextsame);
- else // This seems to prevent a bug in zip.test
- htrc("");
+ htrc("CalculateArray: size=%d op=%d nextsame=%d\n",
+ ars, op, nextsame);
for (i = 0; i < ars; i++) {
jvrp = arp->GetValue(i);
if (trace)
- htrc("i=%d Value %s null=%d nv=%d\n",
- i, jvrp->GetString(g), jvrp->IsNull() ? 1 : 0, nv);
+ htrc("i=%d nv=%d\n", i, nv);
if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) do {
if (jvrp->IsNull()) {
@@ -1623,7 +1621,7 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
continue;
} else
SetJsonValue(g, MulVal, jvp, n);
-
+
if (!MulVal->IsNull()) {
switch (op) {
case OP_CNC:
@@ -1655,6 +1653,7 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
htrc("vp='%s' err=%d\n",
vp->GetCharString(&buf), err ? 1 : 0);
+
} // endif trace
} // endif Null
diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp
index bb7eae9c256..d3fb31fb57a 100644
--- a/storage/connect/tabtbl.cpp
+++ b/storage/connect/tabtbl.cpp
@@ -650,7 +650,7 @@ bool TDBTBM::IsLocal(PTABLE tbp)
return ((!stricmp(tdbp->Host, "localhost") ||
!strcmp(tdbp->Host, "127.0.0.1")) &&
- tdbp->Port == GetDefaultPort());
+ tdbp->Port == (int)GetDefaultPort());
} // end of IsLocal
/***********************************************************************/
diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp
index a2c04e2cf62..5d8d7c1b9f8 100644
--- a/storage/connect/tabutil.cpp
+++ b/storage/connect/tabutil.cpp
@@ -120,7 +120,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
FLD_REM, FLD_NO, FLD_CHARSET};
unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 32, 32};
PCSZ fmt;
- char *pn, *tn, *fld, *colname, *chset, v;
+ char *pn, *tn, *fld, *colname, v; // *chset
int i, n, ncol = sizeof(buftyp) / sizeof(int);
int prec, len, type, scale;
int zconv = GetConvSize();
@@ -185,7 +185,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
colname = (char *)fp->field_name;
crp->Kdata->SetValue(colname, i);
- chset = (char *)fp->charset()->name;
+// chset = (char *)fp->charset()->name;
// v = (!strcmp(chset, "binary")) ? 'B' : 0;
v = 0;
diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp
index f08d18b5421..c7a6c8dd06a 100644
--- a/storage/connect/value.cpp
+++ b/storage/connect/value.cpp
@@ -1656,10 +1656,18 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
char *p[2], val[2][32];
int i;
- for (i = 0; i < np; i++)
- p[i] = vp[i]->IsNull() ? NULL : vp[i]->GetCharString(val[i]);
+ if (trace)
+ htrc("Compute: np=%d op=%d\n", np, op);
- if (p[i]) {
+ for (i = 0; i < np; i++) {
+ p[i] = vp[i]->IsNull() ? NULL : vp[i]->GetCharString(val[i]);
+
+ if (trace)
+ htrc("p[%d]=%s\n", i, p[i]);
+
+ } // endfor i
+
+ if (p[0] && p[np - 1]) {
switch (op) {
case OP_CNC:
assert(np == 1 || np == 2);
@@ -1670,6 +1678,9 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
if ((i = Len - (signed)strlen(Strp)) > 0)
strncat(Strp, p[np - 1], i);
+ if (trace)
+ htrc("Strp=%s\n", Strp);
+
break;
case OP_MIN:
assert(np == 2);