mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
- 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
This commit is contained in:
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -76,6 +76,7 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
|
||||
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);
|
||||
|
||||
|
@@ -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()) {
|
||||
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
/***********************************************************************/
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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++)
|
||||
if (trace)
|
||||
htrc("Compute: np=%d op=%d\n", np, op);
|
||||
|
||||
for (i = 0; i < np; i++) {
|
||||
p[i] = vp[i]->IsNull() ? NULL : vp[i]->GetCharString(val[i]);
|
||||
|
||||
if (p[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);
|
||||
|
Reference in New Issue
Block a user