1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Fix wrong value of JSON column

When null and the column is NOT NULL the value was not reset.
  modified:   storage/connect/tabjson.cpp

Fix converting bstr_t string to set error message
  modified:   storage/connect/domdoc.cpp

Fix MDEV-12768: -Wformat-overflow compile warnings
  modified:   storage/connect/global.h
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/plugutil.cpp
  modified:   storage/connect/tabvct.cpp

Typo (in external_lock)
  modified:   storage/connect/ha_connect.cc

Remove some warnings
  modified:   storage/connect/odbconn.cpp
  modified:   storage/connect/tabmysql.cpp

Add MEM_RESERVE flag to virtualAlloc
  modified:   storage/connect/plgdbutl.cpp

Fix MDEV-12573:
Accept=1 may show incorrect value for NULL column in CONNECT TBL
  modified:   storage/connect/tabutil.cpp

Fix wrong setting of key size when greater than 2G
 modified:   storage/connect/xindex.cpp

Fixing MDEV-12149: compile errors on Windows with /Zc:strictStrings
Introduce typedef PCSZ and replace PSZ by it where it matters
All done on CONNECT but compile still fails because of an included system file
  modified:   storage/connect/array.cpp
  modified:   storage/connect/catalog.h
  modified:   storage/connect/colblk.cpp
  modified:   storage/connect/colblk.h
  modified:   storage/connect/connect.cc
  modified:   storage/connect/domdoc.cpp
  modified:   storage/connect/domdoc.h
  modified:   storage/connect/filamdbf.cpp
  modified:   storage/connect/filamdbf.h
  modified:   storage/connect/filamfix.cpp
  modified:   storage/connect/filamgz.cpp
  modified:   storage/connect/filamtxt.h
  modified:   storage/connect/filamvct.cpp
  modified:   storage/connect/filamvct.h
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/filamzip.h
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/ha_connect.h
  modified:   storage/connect/jdbccat.h
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/jdbconn.h
  modified:   storage/connect/json.cpp
  modified:   storage/connect/json.h
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/jsonudf.h
  modified:   storage/connect/libdoc.cpp
  modified:   storage/connect/macutil.cpp
  modified:   storage/connect/myconn.cpp
  modified:   storage/connect/myutil.cpp
  modified:   storage/connect/myutil.h
  modified:   storage/connect/odbccat.h
  modified:   storage/connect/odbconn.cpp
  modified:   storage/connect/odbconn.h
  modified:   storage/connect/os.h
  modified:   storage/connect/plgdbsem.h
  modified:   storage/connect/plgdbutl.cpp
  modified:   storage/connect/plgxml.cpp
  modified:   storage/connect/plgxml.h
  modified:   storage/connect/plugutil.cpp
  modified:   storage/connect/preparse.h
  modified:   storage/connect/reldef.cpp
  modified:   storage/connect/reldef.h
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabdos.h
  modified:   storage/connect/tabext.cpp
  modified:   storage/connect/tabext.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/tabmul.cpp
  modified:   storage/connect/tabmul.h
  modified:   storage/connect/tabmysql.cpp
  modified:   storage/connect/tabmysql.h
  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/tabutil.cpp
  modified:   storage/connect/tabutil.h
  modified:   storage/connect/tabvir.cpp
  modified:   storage/connect/tabvir.h
  modified:   storage/connect/tabwmi.cpp
  modified:   storage/connect/tabwmi.h
  modified:   storage/connect/tabxml.cpp
  modified:   storage/connect/tabxml.h
  modified:   storage/connect/tabzip.cpp
  modified:   storage/connect/tabzip.h
  modified:   storage/connect/valblk.cpp
  modified:   storage/connect/valblk.h
  modified:   storage/connect/value.cpp
  modified:   storage/connect/value.h
  modified:   storage/connect/xindex.cpp
  modified:   storage/connect/xobject.cpp
  modified:   storage/connect/xobject.h
  modified:   storage/connect/xtable.h

Fix MDEV-12603 Insert replaces values in ZIP file
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/filamzip.h

Fix MDEV-12686 Handle null in json
Fix MDEV-12688 Insert does not handle type TINYINT
  modified:   storage/connect/json.cpp
  modified:   storage/connect/tabjson.cpp

Fix MDEV-12653 Cannot add index for ZIP CONNECT table
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabfmt.cpp
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/xindex.cpp
This commit is contained in:
Olivier Bertrand
2017-05-11 21:57:21 +02:00
parent 531698e0da
commit 1c88b9a8d3
99 changed files with 2384 additions and 3391 deletions

View File

@@ -1455,7 +1455,7 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
free(g->Sarea);
if (!(g->Sarea = PlugAllocMem(g, ml))) {
char errmsg[256];
char errmsg[MAX_STR];
sprintf(errmsg, MSG(WORK_AREA), g->Message);
strcpy(g->Message, errmsg);
@@ -1496,7 +1496,7 @@ static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i)
/*********************************************************************************/
/* Make a valid key from the passed argument. */
/*********************************************************************************/
static PSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
{
if (args->arg_count > (unsigned)i) {
int j = 0, n = args->attribute_lengths[i];
@@ -2253,7 +2253,8 @@ my_bool json_object_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
char *json_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error)
{
char *key, *str = NULL;
PCSZ key;
char *str = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr;
if (g->Xchk) {
@@ -2358,7 +2359,7 @@ char *json_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // endif Xchk
if (!CheckMemory(g, initid, args, 1, false, true, true)) {
char *key;
PCSZ key;
PJOB jobp;
PJSON jsp, top;
PJVAL jvp = MakeValue(g, args, 0, &top);
@@ -2921,70 +2922,53 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (g->N) {
str = (char*)g->Activityp;
goto fin;
goto err;
} else if (initid->const_item)
g->N = 1;
#if defined(USE_TRY)
try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
*is_null = 1;
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
str = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true)) {
PUSH_WARNING("CheckMemory error");
goto err;
} else
jvp = MakeValue(g, args, 0);
if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) {
PUSH_WARNING(g->Message);
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true)) {
PUSH_WARNING("CheckMemory error");
goto err;
} // endif jsp
} else
jvp = MakeValue(g, args, 0);
if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) {
PUSH_WARNING(g->Message);
goto err;
} // endif jsp
} else
jsp = jvp->GetJson();
if (g->Mrr) { // First argument is a constant
g->Xchk = jsp;
JsonMemSave(g);
} // endif Mrr
} else
jsp = jvp->GetJson();
jsp = (PJSON)g->Xchk;
if (g->Mrr) { // First argument is a constant
g->Xchk = jsp;
JsonMemSave(g);
} // endif Mrr
path = MakePSZ(g, args, 1);
jsx = new(g) JSNX(g, jsp, TYPE_STRING, initid->max_length);
} else
jsp = (PJSON)g->Xchk;
if (jsx->SetJpath(g, path)) {
PUSH_WARNING(g->Message);
goto err;
} // endif SetJpath
path = MakePSZ(g, args, 1);
jsx = new(g) JSNX(g, jsp, TYPE_STRING, initid->max_length);
jsx->ReadValue(g);
if (jsx->SetJpath(g, path)) {
PUSH_WARNING(g->Message);
goto err;
} // endif SetJpath
if (!jsx->GetValue()->IsNull())
str = jsx->GetValue()->GetCharValue();
jsx->ReadValue(g);
if (initid->const_item)
// Keep result of constant function
g->Activityp = (PACTIVITY)str;
if (!jsx->GetValue()->IsNull())
str = jsx->GetValue()->GetCharValue();
if (initid->const_item)
// Keep result of constant function
g->Activityp = (PACTIVITY)str;
#if defined(USE_TRY)
} catch (int n) {
} catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
PUSH_WARNING(g->Message);
@@ -2996,12 +2980,6 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // end catch
err:
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
fin:
if (!str) {
*is_null = 1;
*res_length = 0;
@@ -3292,64 +3270,45 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else if (initid->const_item)
g->N = 1;
#if defined(USE_TRY)
try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
*error = 1;
*is_null = 1;
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
*error = 1;
path = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, !g->Xchk)) {
PUSH_WARNING("CheckMemory error");
*error = 1;
goto err;
} else
jvp = MakeValue(g, args, 0);
if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) {
PUSH_WARNING(g->Message);
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, !g->Xchk)) {
PUSH_WARNING("CheckMemory error");
*error = 1;
goto err;
} // endif jsp
} else
jvp = MakeValue(g, args, 0);
if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) {
PUSH_WARNING(g->Message);
goto err;
} // endif jsp
} else
jsp = jvp->GetJson();
if (g->Mrr) { // First argument is a constant
g->Xchk = jsp;
JsonMemSave(g);
} // endif Mrr
} else
jsp = jvp->GetJson();
jsp = (PJSON)g->Xchk;
if (g->Mrr) { // First argument is a constant
g->Xchk = jsp;
JsonMemSave(g);
} // endif Mrr
// The item to locate
jvp2 = MakeValue(g, args, 1);
} else
jsp = (PJSON)g->Xchk;
k = (args->arg_count > 2) ? (int)*(long long*)args->args[2] : 1;
// The item to locate
jvp2 = MakeValue(g, args, 1);
jsx = new(g) JSNX(g, jsp, TYPE_STRING);
path = jsx->Locate(g, jsp, jvp2, k);
k = (args->arg_count > 2) ? (int)*(long long*)args->args[2] : 1;
if (initid->const_item)
// Keep result of constant function
g->Activityp = (PACTIVITY)path;
jsx = new(g) JSNX(g, jsp, TYPE_STRING);
path = jsx->Locate(g, jsp, jvp2, k);
if (initid->const_item)
// Keep result of constant function
g->Activityp = (PACTIVITY)path;
#if defined(USE_TRY)
} catch (int n) {
} catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
PUSH_WARNING(g->Message);
@@ -3363,11 +3322,6 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // end catch
err:
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
if (!path) {
*res_length = 0;
*is_null = 1;
@@ -3439,65 +3393,46 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else if (initid->const_item)
g->N = 1;
#if defined(USE_TRY)
try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
*error = 1;
*is_null = 1;
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
*error = 1;
path = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true)) {
PUSH_WARNING("CheckMemory error");
*error = 1;
goto err;
} else
jvp = MakeValue(g, args, 0);
if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) {
PUSH_WARNING(g->Message);
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true)) {
PUSH_WARNING("CheckMemory error");
*error = 1;
goto err;
} // endif jsp
} else
jvp = MakeValue(g, args, 0);
if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) {
PUSH_WARNING(g->Message);
goto err;
} // endif jsp
} else
jsp = jvp->GetJson();
if (g->Mrr) { // First argument is a constant
g->Xchk = jsp;
JsonMemSave(g);
} // endif Mrr
} else
jsp = jvp->GetJson();
jsp = (PJSON)g->Xchk;
if (g->Mrr) { // First argument is a constant
g->Xchk = jsp;
JsonMemSave(g);
} // endif Mrr
// The item to locate
jvp2 = MakeValue(g, args, 1);
} else
jsp = (PJSON)g->Xchk;
if (args->arg_count > 2)
mx = (int)*(long long*)args->args[2];
// The item to locate
jvp2 = MakeValue(g, args, 1);
jsx = new(g) JSNX(g, jsp, TYPE_STRING);
path = jsx->LocateAll(g, jsp, jvp2, mx);
if (args->arg_count > 2)
mx = (int)*(long long*)args->args[2];
if (initid->const_item)
// Keep result of constant function
g->Activityp = (PACTIVITY)path;
jsx = new(g) JSNX(g, jsp, TYPE_STRING);
path = jsx->LocateAll(g, jsp, jvp2, mx);
if (initid->const_item)
// Keep result of constant function
g->Activityp = (PACTIVITY)path;
#if defined(USE_TRY)
} catch (int n) {
} catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
PUSH_WARNING(g->Message);
@@ -3511,11 +3446,6 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // end catch
err:
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
if (!path) {
*res_length = 0;
*is_null = 1;
@@ -3722,87 +3652,61 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
goto fin;
} // endelse
#if defined(USE_TRY)
try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
*error = 1;
goto fin;
} // endif jump_level
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true, false, true)) {
PUSH_WARNING("CheckMemory error");
throw 1;
} else
jvp = MakeValue(g, args, 0);
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
str = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) {
throw 2;
} // endif jsp
} else
jsp = jvp->GetJson();
if (g->Mrr) { // First argument is a constant
g->Xchk = jsp;
JsonMemSave(g);
} // endif Mrr
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true, false, true)) {
PUSH_WARNING("CheckMemory error");
#if defined(USE_TRY)
throw 1;
#else // !USE_TRY
goto err;
#endif // !USE_TRY
} else
jvp = MakeValue(g, args, 0);
jsp = (PJSON)g->Xchk;
if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) {
#if defined(USE_TRY)
throw 2;
#else // !USE_TRY
jsx = new(g)JSNX(g, jsp, TYPE_STRING, initid->max_length, 0, true);
for (uint i = 1; i + 1 < args->arg_count; i += 2) {
jvp = MakeValue(gb, args, i);
path = MakePSZ(g, args, i + 1);
if (jsx->SetJpath(g, path, false)) {
PUSH_WARNING(g->Message);
goto err;
#endif // !USE_TRY
} // endif jsp
continue;
} // endif SetJpath
} else
jsp = jvp->GetJson();
if (w) {
jsx->ReadValue(g);
b = jsx->GetValue()->IsNull();
b = (w == 1) ? b : !b;
} // endif w
if (g->Mrr) { // First argument is a constant
g->Xchk = jsp;
JsonMemSave(g);
} // endif Mrr
if (b && jsx->WriteValue(gb, jvp))
PUSH_WARNING(g->Message);
} else
jsp = (PJSON)g->Xchk;
} // endfor i
jsx = new(g)JSNX(g, jsp, TYPE_STRING, initid->max_length, 0, true);
// In case of error or file, return unchanged argument
if (!(str = MakeResult(g, args, jsp, INT_MAX32)))
str = MakePSZ(g, args, 0);
for (uint i = 1; i+1 < args->arg_count; i += 2) {
jvp = MakeValue(gb, args, i);
path = MakePSZ(g, args, i+1);
if (g->N)
// Keep result of constant function
g->Activityp = (PACTIVITY)str;
if (jsx->SetJpath(g, path, false)) {
PUSH_WARNING(g->Message);
continue;
} // endif SetJpath
if (w) {
jsx->ReadValue(g);
b = jsx->GetValue()->IsNull();
b = (w == 1) ? b : !b;
} // endif w
if (b && jsx->WriteValue(gb, jvp))
PUSH_WARNING(g->Message);
} // endfor i
// In case of error or file, return unchanged argument
if (!(str = MakeResult(g, args, jsp, INT_MAX32)))
str = MakePSZ(g, args, 0);
if (g->N)
// Keep result of constant function
g->Activityp = (PACTIVITY)str;
#if defined(USE_TRY)
} catch (int n) {
} catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
PUSH_WARNING(g->Message);
@@ -3812,10 +3716,6 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
PUSH_WARNING(g->Message);
str = NULL;
} // end catch
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
fin:
if (!str) {
@@ -4642,7 +4542,7 @@ char *jbin_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // endif bsp
if (!CheckMemory(g, initid, args, 2, false, true, true)) {
char *key;
PCSZ key;
PJOB jobp;
PJVAL jvp = MakeValue(g, args, 0, &top);
PJSON jsp = jvp->GetJson();
@@ -4722,7 +4622,7 @@ char *jbin_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // endif bsp
if (!CheckMemory(g, initid, args, 1, false, true, true)) {
char *key;
PCSZ key;
PJOB jobp;
PJVAL jvp = MakeValue(g, args, 0, &top);
PJSON jsp = jvp->GetJson();