mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fix some json discovery problems. Modified tabjson.cpp tabjson.h
This commit is contained in:
@@ -159,7 +159,7 @@ JSONDISC::JSONDISC(PGLOBAL g, uint *lg)
|
|||||||
jsp = NULL;
|
jsp = NULL;
|
||||||
row = NULL;
|
row = NULL;
|
||||||
sep = NULL;
|
sep = NULL;
|
||||||
i = n = bf = ncol = lvl = sz = 0;
|
i = n = bf = ncol = lvl = sz = limit = 0;
|
||||||
all = strfy = false;
|
all = strfy = false;
|
||||||
} // end of JSONDISC constructor
|
} // end of JSONDISC constructor
|
||||||
|
|
||||||
@@ -172,6 +172,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
|||||||
lvl = GetIntegerTableOption(g, topt, "Depth", lvl);
|
lvl = GetIntegerTableOption(g, topt, "Depth", lvl);
|
||||||
sep = GetStringTableOption(g, topt, "Separator", ".");
|
sep = GetStringTableOption(g, topt, "Separator", ".");
|
||||||
sz = GetIntegerTableOption(g, topt, "Jsize", 1024);
|
sz = GetIntegerTableOption(g, topt, "Jsize", 1024);
|
||||||
|
limit = GetIntegerTableOption(g, topt, "Limit", 10);
|
||||||
strfy = GetBooleanTableOption(g, topt, "Stringify", false);
|
strfy = GetBooleanTableOption(g, topt, "Stringify", false);
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@@ -458,7 +459,7 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
|
|||||||
jar = (PJAR)jsp;
|
jar = (PJAR)jsp;
|
||||||
|
|
||||||
if (all || (tdp->Xcol && !stricmp(tdp->Xcol, key)))
|
if (all || (tdp->Xcol && !stricmp(tdp->Xcol, key)))
|
||||||
ars = jar->GetSize(false);
|
ars = MY_MIN(jar->GetSize(false), limit);
|
||||||
else
|
else
|
||||||
ars = MY_MIN(jar->GetSize(false), 1);
|
ars = MY_MIN(jar->GetSize(false), 1);
|
||||||
|
|
||||||
@@ -527,10 +528,29 @@ void JSONDISC::AddColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (jcp) {
|
if (jcp) {
|
||||||
if (jcp->Type != jcol.Type) {
|
if (jcp->Type != jcol.Type) {
|
||||||
if (jcp->Type == TYPE_UNKNOWN)
|
if (jcp->Type == TYPE_UNKNOWN || jcol.Type == TYPE_VOID)
|
||||||
jcp->Type = jcol.Type;
|
jcp->Type = jcol.Type;
|
||||||
else if (jcol.Type != TYPE_UNKNOWN && jcol.Type != TYPE_VOID)
|
// else if (jcol.Type != TYPE_UNKNOWN && jcol.Type != TYPE_VOID)
|
||||||
jcp->Type = TYPE_STRING;
|
// jcp->Type = TYPE_STRING;
|
||||||
|
else if (jcp->Type != TYPE_STRING)
|
||||||
|
switch (jcol.Type) {
|
||||||
|
case TYPE_STRING:
|
||||||
|
case TYPE_DOUBLE:
|
||||||
|
jcp->Type = jcol.Type;
|
||||||
|
break;
|
||||||
|
case TYPE_BIGINT:
|
||||||
|
if (jcp->Type == TYPE_INT || jcp->Type == TYPE_TINY)
|
||||||
|
jcp->Type = jcol.Type;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case TYPE_INT:
|
||||||
|
if (jcp->Type == TYPE_TINY)
|
||||||
|
jcp->Type = jcol.Type;
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
} // endswith Type
|
||||||
|
|
||||||
} // endif Type
|
} // endif Type
|
||||||
|
|
||||||
|
@@ -68,7 +68,7 @@ public:
|
|||||||
PCSZ sep;
|
PCSZ sep;
|
||||||
char colname[65], fmt[129], buf[16];
|
char colname[65], fmt[129], buf[16];
|
||||||
uint *length;
|
uint *length;
|
||||||
int i, n, bf, ncol, lvl, sz;
|
int i, n, bf, ncol, lvl, sz, limit;
|
||||||
bool all, strfy;
|
bool all, strfy;
|
||||||
}; // end of JSONDISC
|
}; // end of JSONDISC
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user