mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
- Inline MakePtr and MakeOff with OFFSET as size_t
Also add a new member Saved_Size in the Global structure. modified: storage/connect/global.h modified: storage/connect/plugutil.cpp modified: storage/connect/user_connect.cc modified: storage/connect/jsonudf.cpp - Add session variables json_all_path and default_depth modified: storage/connect/ha_connect.cc modified: storage/connect/mongo.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/tabxml.cpp - ADD column options JPATH and XPATH Work as FIELD_FORMAT but are more readable modified: storage/connect/ha_connect.cc modified: storage/connect/ha_connect.h modified: storage/connect/mysql-test/connect/r/json_java_2.result modified: storage/connect/mysql-test/connect/r/json_java_3.result modified: storage/connect/mysql-test/connect/r/json_mongo_c.result - Handle negative numbes in the option list modified: storage/connect/ha_connect.cc - Fix Json parse that could crash the server. Was because it could use THROW out of the TRY block. Also handle all error by THROW. It is now done by a new class JSON. modified: storage/connect/json.cpp modified: storage/connect/json.h - Add a new UDF function jfile_translate. It translate a Json file to pretty = 0. Fast because it does not a real parse of the file. modified: storage/connect/jsonudf.cpp modified: storage/connect/jsonudf.h - Add a now options JSIZE and STRINGIFY to Json tables. STRINGIFY makes Objects or Arrays to be returned by their json representation instead of by their concatenated values. JSIZE allows to specify the LRECL (was 256) defaults to 1024. Also fix a bug about locating the sub-table by its path. modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h
This commit is contained in:
@@ -52,19 +52,10 @@
|
||||
/* External functions. */
|
||||
/***********************************************************************/
|
||||
USETEMP UseTemp(void);
|
||||
bool JsonAllPath(void);
|
||||
int GetDefaultDepth(void);
|
||||
char *GetJsonNull(void);
|
||||
|
||||
//typedef struct _jncol {
|
||||
// struct _jncol *Next;
|
||||
// char *Name;
|
||||
// char *Fmt;
|
||||
// int Type;
|
||||
// int Len;
|
||||
// int Scale;
|
||||
// bool Cbn;
|
||||
// bool Found;
|
||||
//} JCOL, *PJCL;
|
||||
|
||||
/***********************************************************************/
|
||||
/* JSONColumns: construct the result blocks containing the description */
|
||||
/* of all the columns of a table contained inside a JSON file. */
|
||||
@@ -167,23 +158,20 @@ JSONDISC::JSONDISC(PGLOBAL g, uint *lg)
|
||||
jsp = NULL;
|
||||
row = NULL;
|
||||
sep = NULL;
|
||||
i = n = bf = ncol = lvl = 0;
|
||||
all = false;
|
||||
i = n = bf = ncol = lvl = sz = 0;
|
||||
all = strfy = false;
|
||||
} // end of JSONDISC constructor
|
||||
|
||||
int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
||||
{
|
||||
char filename[_MAX_PATH];
|
||||
bool mgo = (GetTypeID(topt->type) == TAB_MONGO);
|
||||
PCSZ level = GetStringTableOption(g, topt, "Level", NULL);
|
||||
|
||||
if ((level = GetStringTableOption(g, topt, "Depth", level))) {
|
||||
lvl = atoi(level);
|
||||
lvl = (lvl > 16) ? 16 : lvl;
|
||||
} else
|
||||
lvl = 0;
|
||||
|
||||
sep = GetStringTableOption(g, topt, "Separator", ".");
|
||||
lvl = GetIntegerTableOption(g, topt, "Level", GetDefaultDepth());
|
||||
lvl = GetIntegerTableOption(g, topt, "Depth", lvl);
|
||||
sep = GetStringTableOption(g, topt, "Separator", ".");
|
||||
sz = GetIntegerTableOption(g, topt, "Jsize", 1024);
|
||||
strfy = GetBooleanTableOption(g, topt, "Stringify", false);
|
||||
|
||||
/*********************************************************************/
|
||||
/* Open the input file. */
|
||||
@@ -306,7 +294,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
||||
// Allocate the parse work memory
|
||||
PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL));
|
||||
memset(G, 0, sizeof(GLOBAL));
|
||||
G->Sarea_Size = tdp->Lrecl * 10;
|
||||
G->Sarea_Size = (size_t)tdp->Lrecl * 10;
|
||||
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
||||
PlugSubSet(G->Sarea, G->Sarea_Size);
|
||||
G->jump_level = 0;
|
||||
@@ -403,7 +391,10 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
|
||||
PJAR jar;
|
||||
|
||||
if ((valp = jvp ? jvp->GetValue() : NULL)) {
|
||||
jcol.Type = valp->GetType();
|
||||
if (JsonAllPath() && !fmt[bf])
|
||||
strcat(fmt, colname);
|
||||
|
||||
jcol.Type = valp->GetType();
|
||||
jcol.Len = valp->GetValLen();
|
||||
jcol.Scale = valp->GetValPrec();
|
||||
jcol.Cbn = valp->IsNull();
|
||||
@@ -482,8 +473,16 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
|
||||
} // endswitch Type
|
||||
|
||||
} else if (lvl >= 0) {
|
||||
jcol.Type = TYPE_STRING;
|
||||
jcol.Len = 256;
|
||||
if (strfy) {
|
||||
if (!fmt[bf])
|
||||
strcat(fmt, colname);
|
||||
|
||||
strcat(fmt, ".*");
|
||||
} else if (JsonAllPath() && !fmt[bf])
|
||||
strcat(fmt, colname);
|
||||
|
||||
jcol.Type = TYPE_STRING;
|
||||
jcol.Len = sz;
|
||||
jcol.Scale = 0;
|
||||
jcol.Cbn = true;
|
||||
} else
|
||||
@@ -2040,7 +2039,7 @@ int TDBJSON::MakeDocument(PGLOBAL g)
|
||||
if ((objpath = PlugDup(g, Objname))) {
|
||||
if (*objpath == '$') objpath++;
|
||||
if (*objpath == '.') objpath++;
|
||||
p1 = p2 = NULL;
|
||||
p1 = (*objpath == '[') ? objpath++ : NULL;
|
||||
|
||||
/*********************************************************************/
|
||||
/* Find the table in the tree structure. */
|
||||
|
||||
Reference in New Issue
Block a user