Commit be7e41db authored by Olivier Bertrand's avatar Olivier Bertrand

- Mongo defined columns

    modified:   storage/connect/cmgoconn.cpp
    modified:   storage/connect/cmgoconn.h

- Change default array LIMIT from 10 to 50
    modified:   storage/connect/ha_connect.cc
    modified:   storage/connect/tabbson.cpp
    modified:   storage/connect/tabjson.cpp
    modified:   storage/connect/tabxml.cpp
parent e0edfc27
...@@ -300,6 +300,7 @@ void CMgoConn::Project(PGLOBAL g, PSTRG s) ...@@ -300,6 +300,7 @@ void CMgoConn::Project(PGLOBAL g, PSTRG s)
for (cp = tp->GetColumns(); cp; cp = cp->GetNext()) { for (cp = tp->GetColumns(); cp; cp = cp->GetNext()) {
path = cp->GetJpath(g, true); path = cp->GetJpath(g, true);
// Resolve path collision
for (hp = php; hp; hp = hp->Next) { for (hp = php; hp; hp = hp->Next) {
if (strlen(path) < strlen(hp->Path)) { if (strlen(path) < strlen(hp->Path)) {
n = strlen(path); n = strlen(path);
...@@ -318,6 +319,7 @@ void CMgoConn::Project(PGLOBAL g, PSTRG s) ...@@ -318,6 +319,7 @@ void CMgoConn::Project(PGLOBAL g, PSTRG s)
// New path // New path
hp = (PTHP)PlugSubAlloc(g, NULL, sizeof(PTH)); hp = (PTHP)PlugSubAlloc(g, NULL, sizeof(PTH));
hp->Path = path; hp->Path = path;
hp->Name = cp->GetName();
hp->Next = NULL; hp->Next = NULL;
*nphp = hp; *nphp = hp;
nphp = &hp->Next; nphp = &hp->Next;
...@@ -332,8 +334,16 @@ void CMgoConn::Project(PGLOBAL g, PSTRG s) ...@@ -332,8 +334,16 @@ void CMgoConn::Project(PGLOBAL g, PSTRG s)
else else
b = true; b = true;
s->Append(hp->Path); if (*hp->Path == '{') {
s->Append("\":1"); // This is a Mongo defined column
s->Append(hp->Name);
s->Append("\":");
s->Append(hp->Path);
} else {
s->Append(hp->Path);
s->Append("\":1");
} // endif Path
} // endfor hp } // endfor hp
} // end of Project } // end of Project
...@@ -885,9 +895,12 @@ void CMgoConn::GetColumnValue(PGLOBAL g, PCOL colp) ...@@ -885,9 +895,12 @@ void CMgoConn::GetColumnValue(PGLOBAL g, PCOL colp)
char *jpath = colp->GetJpath(g, false); char *jpath = colp->GetJpath(g, false);
bool b = false; bool b = false;
PVAL value = colp->GetValue(); PVAL value = colp->GetValue();
bson_iter_t Iter; // Used to retrieve column value bson_iter_t Iter; // Used to retrieve column value
bson_iter_t Desc; // Descendant iter bson_iter_t Desc; // Descendant iter
if (*jpath == '{')
jpath = colp->GetName(); // This is a Mongo defined column
if (!*jpath || !strcmp(jpath, "*")) { if (!*jpath || !strcmp(jpath, "*")) {
value->SetValue_psz(Mini(g, colp, Document, false)); value->SetValue_psz(Mini(g, colp, Document, false));
} else if (bson_iter_init(&Iter, Document) && } else if (bson_iter_init(&Iter, Document) &&
......
...@@ -44,6 +44,7 @@ typedef struct _path_list *PTHP; ...@@ -44,6 +44,7 @@ typedef struct _path_list *PTHP;
typedef struct _path_list { typedef struct _path_list {
PSZ Path; PSZ Path;
PSZ Name;
PTHP Next; PTHP Next;
} PTH; } PTH;
......
...@@ -167,10 +167,10 @@ ...@@ -167,10 +167,10 @@
#define SZCONV 1024 // Default converted text size #define SZCONV 1024 // Default converted text size
#define SZWORK 67108864 // Default work area size 64M #define SZWORK 67108864 // Default work area size 64M
#define SZWMIN 4194304 // Minimum work area size 4M #define SZWMIN 4194304 // Minimum work area size 4M
#define JSONMAX 10 // JSON Default max grp size #define JSONMAX 50 // JSON Default max grp size
extern "C" { extern "C" {
char version[]= "Version 1.07.0003 May 02, 2021"; char version[]= "Version 1.07.0003 May 22, 2021";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.07.0003 " __DATE__ " " __TIME__; char compver[]= "Version 1.07.0003 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
...@@ -508,7 +508,7 @@ char *GetJsonNull(void) ...@@ -508,7 +508,7 @@ char *GetJsonNull(void)
int GetDefaultDepth(void) {return THDVAR(current_thd, default_depth);} int GetDefaultDepth(void) {return THDVAR(current_thd, default_depth);}
int GetDefaultPrec(void) {return THDVAR(current_thd, default_prec);} int GetDefaultPrec(void) {return THDVAR(current_thd, default_prec);}
uint GetJsonGrpSize(void) uint GetJsonGrpSize(void)
{return connect_hton ? THDVAR(current_thd, json_grp_size) : 10;} {return connect_hton ? THDVAR(current_thd, json_grp_size) : 50;}
size_t GetWorkSize(void) {return (size_t)THDVAR(current_thd, work_size);} size_t GetWorkSize(void) {return (size_t)THDVAR(current_thd, work_size);}
void SetWorkSize(size_t) void SetWorkSize(size_t)
{ {
......
...@@ -173,7 +173,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt) ...@@ -173,7 +173,7 @@ int BSONDISC::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); limit = GetIntegerTableOption(g, topt, "Limit", 50);
strfy = GetStringTableOption(g, topt, "Stringify", NULL); strfy = GetStringTableOption(g, topt, "Stringify", NULL);
/*********************************************************************/ /*********************************************************************/
...@@ -1159,7 +1159,7 @@ bool BSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -1159,7 +1159,7 @@ bool BSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Objname = GetStringCatInfo(g, "Object", NULL); Objname = GetStringCatInfo(g, "Object", NULL);
Xcol = GetStringCatInfo(g, "Expand", NULL); Xcol = GetStringCatInfo(g, "Expand", NULL);
Pretty = GetIntCatInfo("Pretty", 2); Pretty = GetIntCatInfo("Pretty", 2);
Limit = GetIntCatInfo("Limit", 10); Limit = GetIntCatInfo("Limit", 50);
Base = GetIntCatInfo("Base", 0) ? 1 : 0; Base = GetIntCatInfo("Base", 0) ? 1 : 0;
Sep = *GetStringCatInfo(g, "Separator", "."); Sep = *GetStringCatInfo(g, "Separator", ".");
Accept = GetBoolCatInfo("Accept", false); Accept = GetBoolCatInfo("Accept", false);
......
...@@ -179,7 +179,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt) ...@@ -179,7 +179,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
sep = GetStringTableOption(g, topt, "Separator", "."); sep = GetStringTableOption(g, topt, "Separator", ".");
strfy = GetStringTableOption(g, topt, "Stringify", NULL); strfy = GetStringTableOption(g, topt, "Stringify", NULL);
sz = GetIntegerTableOption(g, topt, "Jsize", 1024); sz = GetIntegerTableOption(g, topt, "Jsize", 1024);
limit = GetIntegerTableOption(g, topt, "Limit", 10); limit = GetIntegerTableOption(g, topt, "Limit", 50);
/*********************************************************************/ /*********************************************************************/
/* Open the input file. */ /* Open the input file. */
...@@ -635,7 +635,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -635,7 +635,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Objname = GetStringCatInfo(g, "Object", NULL); Objname = GetStringCatInfo(g, "Object", NULL);
Xcol = GetStringCatInfo(g, "Expand", NULL); Xcol = GetStringCatInfo(g, "Expand", NULL);
Pretty = GetIntCatInfo("Pretty", 2); Pretty = GetIntCatInfo("Pretty", 2);
Limit = GetIntCatInfo("Limit", 10); Limit = GetIntCatInfo("Limit", 50);
Base = GetIntCatInfo("Base", 0) ? 1 : 0; Base = GetIntCatInfo("Base", 0) ? 1 : 0;
Sep = *GetStringCatInfo(g, "Separator", "."); Sep = *GetStringCatInfo(g, "Separator", ".");
Accept = GetBoolCatInfo("Accept", false); Accept = GetBoolCatInfo("Accept", false);
......
...@@ -525,7 +525,7 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -525,7 +525,7 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
XmlDB = GetStringCatInfo(g, "XmlDB", NULL); XmlDB = GetStringCatInfo(g, "XmlDB", NULL);
Nslist = GetStringCatInfo(g, "Nslist", NULL); Nslist = GetStringCatInfo(g, "Nslist", NULL);
DefNs = GetStringCatInfo(g, "DefNs", NULL); DefNs = GetStringCatInfo(g, "DefNs", NULL);
Limit = GetIntCatInfo("Limit", 10); Limit = GetIntCatInfo("Limit", 50);
Xpand = GetBoolCatInfo("Expand", false); Xpand = GetBoolCatInfo("Expand", false);
Header = GetIntCatInfo("Header", 0); Header = GetIntCatInfo("Header", 0);
GetCharCatInfo("Xmlsup", "*", buf, sizeof(buf)); GetCharCatInfo("Xmlsup", "*", buf, sizeof(buf));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment