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++) {
|
for (i = 0; i < ars; i++) {
|
||||||
jvrp = arp->GetValue(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() || (op == OP_CNC && GetJsonNull())) {
|
||||||
if (jvrp->IsNull()) {
|
if (jvrp->IsNull()) {
|
||||||
jvrp->Value = AllocateValue(g, GetJsonNull(), TYPE_STRING);
|
jvrp->Value = AllocateValue(g, GetJsonNull(), TYPE_STRING);
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#define MAXCOL 200 /* Default max column nb in result */
|
#define MAXCOL 200 /* Default max column nb in result */
|
||||||
#define TYPE_UNKNOWN 12 /* Must be greater than other types */
|
#define TYPE_UNKNOWN 12 /* Must be greater than other types */
|
||||||
|
|
||||||
|
bool MakeSelector(PGLOBAL g, PFIL fp, PSTRG s);
|
||||||
bool IsNum(PSZ 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;
|
int i, n = 0;
|
||||||
PCSZ drv;
|
PCSZ drv;
|
||||||
PBCOL bcp;
|
PBCOL bcp;
|
||||||
MGODISC *cmgd;
|
MGODISC *cmgd = NULL;
|
||||||
PQRYRES qrp;
|
PQRYRES qrp;
|
||||||
PCOLRES crp;
|
PCOLRES crp;
|
||||||
|
|
||||||
@@ -223,7 +224,7 @@ skipit:
|
|||||||
return qrp;
|
return qrp;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (cmgd->tmgp)
|
if (cmgd && cmgd->tmgp)
|
||||||
cmgd->tmgp->CloseDB(g);
|
cmgd->tmgp->CloseDB(g);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@@ -73,9 +73,10 @@ 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;
|
||||||
char colname[65];
|
char colname[65];
|
||||||
char fmt[129];
|
char fmt[129];
|
||||||
bool rc = true;
|
bool rc = true;
|
||||||
|
size_t z;
|
||||||
jint *n = nullptr;
|
jint *n = nullptr;
|
||||||
jstring jkey;
|
jstring jkey;
|
||||||
jobject jres;
|
jobject jres;
|
||||||
@@ -105,14 +106,16 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
|
|||||||
if (pcn) {
|
if (pcn) {
|
||||||
strncpy(colname, pcn, 64);
|
strncpy(colname, pcn, 64);
|
||||||
colname[64] = 0;
|
colname[64] = 0;
|
||||||
strncat(strncat(colname, "_", 65), key, 65);
|
z = 65 - strlen(colname);
|
||||||
|
strncat(strncat(colname, "_", z), key, z - 1);
|
||||||
} else
|
} else
|
||||||
strcpy(colname, key);
|
strcpy(colname, key);
|
||||||
|
|
||||||
if (pfmt) {
|
if (pfmt) {
|
||||||
strncpy(fmt, pfmt, 128);
|
strncpy(fmt, pfmt, 128);
|
||||||
fmt[128] = 0;
|
fmt[128] = 0;
|
||||||
strncat(strncat(fmt, ".", 129), key, 129);
|
z = 129 - strlen(fmt);
|
||||||
|
strncat(strncat(fmt, ".", z), key, z - 1);
|
||||||
} else
|
} else
|
||||||
strcpy(fmt, key);
|
strcpy(fmt, key);
|
||||||
|
|
||||||
|
@@ -1592,16 +1592,14 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
|
|||||||
ars = MY_MIN(Tjp->Limit, arp->size());
|
ars = MY_MIN(Tjp->Limit, arp->size());
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
htrc("CalculateArray size=%d op=%d nextsame=%d\n", ars, op, nextsame);
|
htrc("CalculateArray: size=%d op=%d nextsame=%d\n",
|
||||||
else // This seems to prevent a bug in zip.test
|
ars, op, nextsame);
|
||||||
htrc("");
|
|
||||||
|
|
||||||
for (i = 0; i < ars; i++) {
|
for (i = 0; i < ars; i++) {
|
||||||
jvrp = arp->GetValue(i);
|
jvrp = arp->GetValue(i);
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
htrc("i=%d Value %s null=%d nv=%d\n",
|
htrc("i=%d nv=%d\n", i, nv);
|
||||||
i, jvrp->GetString(g), jvrp->IsNull() ? 1 : 0, nv);
|
|
||||||
|
|
||||||
if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) do {
|
if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) do {
|
||||||
if (jvrp->IsNull()) {
|
if (jvrp->IsNull()) {
|
||||||
@@ -1655,6 +1653,7 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
|
|||||||
|
|
||||||
htrc("vp='%s' err=%d\n",
|
htrc("vp='%s' err=%d\n",
|
||||||
vp->GetCharString(&buf), err ? 1 : 0);
|
vp->GetCharString(&buf), err ? 1 : 0);
|
||||||
|
|
||||||
} // endif trace
|
} // endif trace
|
||||||
|
|
||||||
} // endif Null
|
} // endif Null
|
||||||
|
@@ -650,7 +650,7 @@ bool TDBTBM::IsLocal(PTABLE tbp)
|
|||||||
|
|
||||||
return ((!stricmp(tdbp->Host, "localhost") ||
|
return ((!stricmp(tdbp->Host, "localhost") ||
|
||||||
!strcmp(tdbp->Host, "127.0.0.1")) &&
|
!strcmp(tdbp->Host, "127.0.0.1")) &&
|
||||||
tdbp->Port == GetDefaultPort());
|
tdbp->Port == (int)GetDefaultPort());
|
||||||
} // end of IsLocal
|
} // end of IsLocal
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
@@ -120,7 +120,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
|
|||||||
FLD_REM, FLD_NO, FLD_CHARSET};
|
FLD_REM, FLD_NO, FLD_CHARSET};
|
||||||
unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 32, 32};
|
unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 32, 32};
|
||||||
PCSZ fmt;
|
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 i, n, ncol = sizeof(buftyp) / sizeof(int);
|
||||||
int prec, len, type, scale;
|
int prec, len, type, scale;
|
||||||
int zconv = GetConvSize();
|
int zconv = GetConvSize();
|
||||||
@@ -185,7 +185,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
|
|||||||
colname = (char *)fp->field_name;
|
colname = (char *)fp->field_name;
|
||||||
crp->Kdata->SetValue(colname, i);
|
crp->Kdata->SetValue(colname, i);
|
||||||
|
|
||||||
chset = (char *)fp->charset()->name;
|
// chset = (char *)fp->charset()->name;
|
||||||
// v = (!strcmp(chset, "binary")) ? 'B' : 0;
|
// v = (!strcmp(chset, "binary")) ? 'B' : 0;
|
||||||
v = 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];
|
char *p[2], val[2][32];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < np; i++)
|
if (trace)
|
||||||
p[i] = vp[i]->IsNull() ? NULL : vp[i]->GetCharString(val[i]);
|
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) {
|
switch (op) {
|
||||||
case OP_CNC:
|
case OP_CNC:
|
||||||
assert(np == 1 || np == 2);
|
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)
|
if ((i = Len - (signed)strlen(Strp)) > 0)
|
||||||
strncat(Strp, p[np - 1], i);
|
strncat(Strp, p[np - 1], i);
|
||||||
|
|
||||||
|
if (trace)
|
||||||
|
htrc("Strp=%s\n", Strp);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case OP_MIN:
|
case OP_MIN:
|
||||||
assert(np == 2);
|
assert(np == 2);
|
||||||
|
Reference in New Issue
Block a user