mirror of
https://github.com/MariaDB/server.git
synced 2025-11-27 05:41:41 +03:00
This is a major update concerning many source files.
Fix MDEV-12035. modified: storage/connect/jsonudf.cpp Working on MDEV-11832: Srcdef performance enhancement This require to mark place holders into srcdef to indicate where to insert the where/having clauses that are retrieved in push_cond. However this also make necessary to handle aliases in the srcdef. This was the opportunity to base all external tables on common classes called EXTDEF, TABEXT and EXTCOL. modified: storage/connect/array.cpp modified: storage/connect/array.h modified: storage/connect/colblk.cpp modified: storage/connect/connect.cc modified: storage/connect/filamdbf.cpp modified: storage/connect/ha_connect.cc modified: storage/connect/jdbconn.cpp modified: storage/connect/mycat.cc modified: storage/connect/myconn.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/plgdbsem.h modified: storage/connect/reldef.cpp modified: storage/connect/reldef.h modified: storage/connect/tabdos.cpp modified: storage/connect/tabdos.h modified: storage/connect/tabfix.cpp modified: storage/connect/tabfix.h modified: storage/connect/tabfmt.cpp modified: storage/connect/tabfmt.h modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabjdbc.h modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h modified: storage/connect/table.cpp modified: storage/connect/tabmac.cpp modified: storage/connect/tabmac.h modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h modified: storage/connect/tabmysql.cpp modified: storage/connect/tabmysql.h modified: storage/connect/taboccur.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabodbc.h modified: storage/connect/tabpivot.cpp modified: storage/connect/tabpivot.h modified: storage/connect/tabsys.cpp modified: storage/connect/tabsys.h modified: storage/connect/tabtbl.cpp modified: storage/connect/tabutil.cpp modified: storage/connect/tabutil.h modified: storage/connect/tabvct.cpp modified: storage/connect/tabvct.h modified: storage/connect/tabvir.cpp modified: storage/connect/tabwmi.cpp modified: storage/connect/tabxcl.cpp modified: storage/connect/tabxcl.h modified: storage/connect/tabxml.cpp modified: storage/connect/tabxml.h modified: storage/connect/xindex.cpp modified: storage/connect/xindex.h modified: storage/connect/xobject.h modified: storage/connect/xtable.h added: storage/connect/tabext.cpp added: storage/connect/tabext.h
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/****************** jsonudf C++ Program Source Code File (.CPP) ******************/
|
||||
/* PROGRAM NAME: jsonudf Version 1.4 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2015-2016 */
|
||||
/* PROGRAM NAME: jsonudf Version 1.5 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2015-2017 */
|
||||
/* This program are the JSON User Defined Functions . */
|
||||
/*********************************************************************************/
|
||||
|
||||
@@ -242,13 +242,16 @@ my_bool JSNX::ParseJpath(PGLOBAL g)
|
||||
// Jpath = Name;
|
||||
return true;
|
||||
|
||||
pbuf = PlugDup(g, Jpath);
|
||||
if (!(pbuf = PlgDBDup(g, Jpath)))
|
||||
return true;
|
||||
|
||||
// The Jpath must be analyzed
|
||||
for (i = 0, p = pbuf; (p = strchr(p, ':')); i++, p++)
|
||||
Nod++; // One path node found
|
||||
|
||||
Nodes = (PJNODE)PlugSubAlloc(g, NULL, (++Nod) * sizeof(JNODE));
|
||||
if (!(Nodes = (PJNODE)PlgDBSubAlloc(g, NULL, (++Nod) * sizeof(JNODE))))
|
||||
return true;
|
||||
|
||||
memset(Nodes, 0, (Nod)* sizeof(JNODE));
|
||||
|
||||
// Analyze the Jpath for this column
|
||||
@@ -1086,9 +1089,10 @@ inline void JsonFreeMem(PGLOBAL g)
|
||||
/*********************************************************************************/
|
||||
static my_bool JsonInit(UDF_INIT *initid, UDF_ARGS *args,
|
||||
char *message, my_bool mbn,
|
||||
unsigned long reslen, unsigned long memlen)
|
||||
unsigned long reslen, unsigned long memlen,
|
||||
unsigned long more = 0)
|
||||
{
|
||||
PGLOBAL g = PlugInit(NULL, memlen);
|
||||
PGLOBAL g = PlugInit(NULL, memlen + more);
|
||||
|
||||
if (!g) {
|
||||
strcpy(message, "Allocation error");
|
||||
@@ -1100,6 +1104,7 @@ static my_bool JsonInit(UDF_INIT *initid, UDF_ARGS *args,
|
||||
} // endif g
|
||||
|
||||
g->Mrr = (args->arg_count && args->args[0]) ? 1 : 0;
|
||||
g->ActivityStart = (PACTIVITY)more;
|
||||
initid->maybe_null = mbn;
|
||||
initid->max_length = reslen;
|
||||
initid->ptr = (char*)g;
|
||||
@@ -1444,6 +1449,8 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
|
||||
|
||||
} // endif b
|
||||
|
||||
ml += (unsigned long)g->ActivityStart; // more
|
||||
|
||||
if (ml > g->Sarea_Size) {
|
||||
free(g->Sarea);
|
||||
|
||||
@@ -2758,7 +2765,7 @@ void json_item_merge_deinit(UDF_INIT* initid)
|
||||
/*********************************************************************************/
|
||||
my_bool json_get_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
unsigned long reslen, memlen;
|
||||
unsigned long reslen, memlen, more;
|
||||
int n = IsJson(args, 0);
|
||||
|
||||
if (args->arg_count < 2) {
|
||||
@@ -2767,7 +2774,7 @@ my_bool json_get_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
} else if (!n && args->arg_type[0] != STRING_RESULT) {
|
||||
strcpy(message, "First argument must be a json item");
|
||||
return true;
|
||||
} else if (args->arg_type[1] != STRING_RESULT) {
|
||||
} else if (args->arg_type[1] != STRING_RESULT) {
|
||||
strcpy(message, "Second argument is not a string (jpath)");
|
||||
return true;
|
||||
} else
|
||||
@@ -2780,11 +2787,13 @@ my_bool json_get_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
memcpy(fn, args->args[0], args->lengths[0]);
|
||||
fn[args->lengths[0]] = 0;
|
||||
fl = GetFileLength(fn);
|
||||
memlen += fl * 3;
|
||||
} else if (n != 3)
|
||||
memlen += args->lengths[0] * 3;
|
||||
more = fl * 3;
|
||||
} else if (n != 3) {
|
||||
more = args->lengths[0] * 3;
|
||||
} else
|
||||
more = 0;
|
||||
|
||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||
return JsonInit(initid, args, message, true, reslen, memlen, more);
|
||||
} // end of json_get_item_init
|
||||
|
||||
char *json_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
@@ -2885,7 +2894,7 @@ my_bool jsonget_string_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
} // endif's
|
||||
|
||||
CalcLen(args, false, reslen, memlen);
|
||||
memlen += more;
|
||||
//memlen += more;
|
||||
|
||||
if (n == 2 && args->args[0]) {
|
||||
char fn[_MAX_PATH];
|
||||
@@ -2894,11 +2903,11 @@ my_bool jsonget_string_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
memcpy(fn, args->args[0], args->lengths[0]);
|
||||
fn[args->lengths[0]] = 0;
|
||||
fl = GetFileLength(fn);
|
||||
memlen += fl * 3;
|
||||
more += fl * 3;
|
||||
} else if (n != 3)
|
||||
memlen += args->lengths[0] * 3;
|
||||
more += args->lengths[0] * 3;
|
||||
|
||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||
return JsonInit(initid, args, message, true, reslen, memlen, more);
|
||||
} // end of jsonget_string_init
|
||||
|
||||
char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
@@ -2994,7 +3003,7 @@ void jsonget_string_deinit(UDF_INIT* initid)
|
||||
/*********************************************************************************/
|
||||
my_bool jsonget_int_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
unsigned long reslen, memlen;
|
||||
unsigned long reslen, memlen, more;
|
||||
|
||||
if (args->arg_count != 2) {
|
||||
strcpy(message, "This function must have 2 arguments");
|
||||
@@ -3008,10 +3017,10 @@ my_bool jsonget_int_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
} else
|
||||
CalcLen(args, false, reslen, memlen);
|
||||
|
||||
if (IsJson(args, 0) != 3)
|
||||
memlen += 1000; // TODO: calculate this
|
||||
// TODO: calculate this
|
||||
more = (IsJson(args, 0) != 3) ? 1000 : 0;
|
||||
|
||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||
return JsonInit(initid, args, message, true, reslen, memlen, more);
|
||||
} // end of jsonget_int_init
|
||||
|
||||
long long jsonget_int(UDF_INIT *initid, UDF_ARGS *args,
|
||||
@@ -3100,7 +3109,7 @@ void jsonget_int_deinit(UDF_INIT* initid)
|
||||
/*********************************************************************************/
|
||||
my_bool jsonget_real_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
unsigned long reslen, memlen;
|
||||
unsigned long reslen, memlen, more;
|
||||
|
||||
if (args->arg_count < 2) {
|
||||
strcpy(message, "At least 2 arguments required");
|
||||
@@ -3123,10 +3132,10 @@ my_bool jsonget_real_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
|
||||
CalcLen(args, false, reslen, memlen);
|
||||
|
||||
if (IsJson(args, 0) != 3)
|
||||
memlen += 1000; // TODO: calculate this
|
||||
// TODO: calculate this
|
||||
more = (IsJson(args, 0) != 3) ? 1000 : 0;
|
||||
|
||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||
return JsonInit(initid, args, message, true, reslen, memlen, more);
|
||||
} // end of jsonget_real_init
|
||||
|
||||
double jsonget_real(UDF_INIT *initid, UDF_ARGS *args,
|
||||
@@ -3234,10 +3243,11 @@ my_bool jsonlocate_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
|
||||
CalcLen(args, false, reslen, memlen);
|
||||
|
||||
if (IsJson(args, 0) != 3)
|
||||
memlen += more; // TODO: calculate this
|
||||
// TODO: calculate this
|
||||
if (IsJson(args, 0) == 3)
|
||||
more = 0;
|
||||
|
||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||
return JsonInit(initid, args, message, true, reslen, memlen, more);
|
||||
} // end of jsonlocate_init
|
||||
|
||||
char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
@@ -3358,10 +3368,11 @@ my_bool json_locate_all_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
|
||||
CalcLen(args, false, reslen, memlen);
|
||||
|
||||
if (IsJson(args, 0) != 3)
|
||||
memlen += more; // TODO: calculate this
|
||||
// TODO: calculate this
|
||||
if (IsJson(args, 0) == 3)
|
||||
more = 0;
|
||||
|
||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||
return JsonInit(initid, args, message, true, reslen, memlen, more);
|
||||
} // end of json_locate_all_init
|
||||
|
||||
char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
@@ -3485,12 +3496,12 @@ my_bool jsoncontains_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
} // endif's
|
||||
|
||||
CalcLen(args, false, reslen, memlen);
|
||||
memlen += more;
|
||||
//memlen += more;
|
||||
|
||||
if (IsJson(args, 0) != 3)
|
||||
memlen += 1000; // TODO: calculate this
|
||||
// TODO: calculate this
|
||||
more += (IsJson(args, 0) != 3 ? 1000 : 0);
|
||||
|
||||
return JsonInit(initid, args, message, false, reslen, memlen);
|
||||
return JsonInit(initid, args, message, false, reslen, memlen, more);
|
||||
} // end of jsoncontains_init
|
||||
|
||||
long long jsoncontains(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
@@ -3537,12 +3548,12 @@ my_bool jsoncontains_path_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
} // endif's
|
||||
|
||||
CalcLen(args, false, reslen, memlen);
|
||||
memlen += more;
|
||||
//memlen += more;
|
||||
|
||||
if (IsJson(args, 0) != 3)
|
||||
memlen += 1000; // TODO: calculate this
|
||||
// TODO: calculate this
|
||||
more += (IsJson(args, 0) != 3 ? 1000 : 0);
|
||||
|
||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||
return JsonInit(initid, args, message, true, reslen, memlen, more);
|
||||
} // end of jsoncontains_path_init
|
||||
|
||||
long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
@@ -3736,7 +3747,7 @@ fin:
|
||||
/*********************************************************************************/
|
||||
my_bool json_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
unsigned long reslen, memlen;
|
||||
unsigned long reslen, memlen, more = 0;
|
||||
int n = IsJson(args, 0);
|
||||
|
||||
if (!(args->arg_count % 2)) {
|
||||
@@ -3755,11 +3766,11 @@ my_bool json_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
memcpy(fn, args->args[0], args->lengths[0]);
|
||||
fn[args->lengths[0]] = 0;
|
||||
fl = GetFileLength(fn);
|
||||
memlen += fl * 3;
|
||||
more += fl * 3;
|
||||
} else if (n != 3)
|
||||
memlen += args->lengths[0] * 3;
|
||||
more += args->lengths[0] * 3;
|
||||
|
||||
if (!JsonInit(initid, args, message, true, reslen, memlen)) {
|
||||
if (!JsonInit(initid, args, message, true, reslen, memlen, more)) {
|
||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||
|
||||
// This is a constant function
|
||||
@@ -3954,7 +3965,7 @@ void json_file_deinit(UDF_INIT* initid)
|
||||
/*********************************************************************************/
|
||||
my_bool jfile_make_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
unsigned long reslen, memlen, more = 1024;
|
||||
unsigned long reslen, memlen;
|
||||
|
||||
if (args->arg_count < 1 || args->arg_count > 3) {
|
||||
strcpy(message, "Wrong number of arguments");
|
||||
@@ -4993,7 +5004,7 @@ fin:
|
||||
/*********************************************************************************/
|
||||
my_bool jbin_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
unsigned long reslen, memlen;
|
||||
unsigned long reslen, memlen, more = 0;
|
||||
int n = IsJson(args, 0);
|
||||
|
||||
if (!(args->arg_count % 2)) {
|
||||
@@ -5012,11 +5023,11 @@ my_bool jbin_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
memcpy(fn, args->args[0], args->lengths[0]);
|
||||
fn[args->lengths[0]] = 0;
|
||||
fl = GetFileLength(fn);
|
||||
memlen += fl * 3;
|
||||
more = fl * 3;
|
||||
} else if (n != 3)
|
||||
memlen += args->lengths[0] * 3;
|
||||
more = args->lengths[0] * 3;
|
||||
|
||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||
return JsonInit(initid, args, message, true, reslen, memlen, more);
|
||||
} // end of jbin_set_item_init
|
||||
|
||||
char *jbin_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
@@ -5104,8 +5115,8 @@ my_bool jbin_file_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
fl = GetFileLength(args->args[0]);
|
||||
reslen += fl;
|
||||
more += fl * M;
|
||||
memlen += more;
|
||||
return JsonInit(initid, args, message, true, reslen, memlen);
|
||||
//memlen += more;
|
||||
return JsonInit(initid, args, message, true, reslen, memlen, more);
|
||||
} // end of jbin_file_init
|
||||
|
||||
char *jbin_file(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
|
||||
Reference in New Issue
Block a user