From 92d283c026b66ae772b4343f366f0da6321daa28 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 6 Mar 2017 17:23:56 +0100 Subject: Fix MDEV-12142 crash when creating CSV table Was an unprepared longjmp (now throw) Also fix a wrong calculation of To_Line sometimes causing a crash because of buffer overflow. modified: storage/connect/tabdos.cpp Fix a wrong setting of USER for JDBC tables in connect_assisted_discovery. Update jdbc_new.test after that fix, which changed errors. modified: storage/connect/ha_connect.cc modified: storage/connect/mysql-test/connect/r/jdbc_new.result modified: storage/connect/mysql-test/connect/t/jdbc_new.test Make using try/catch/throw the default option modified: storage/connect/CMakeLists.txt Typo modified: storage/connect/xindex.cpp Replace setjmp-longjmp's by try_catch-throw modified: storage/connect/CMakeLists.txt modified: storage/connect/array.cpp modified: storage/connect/blkfil.cpp modified: storage/connect/colblk.cpp modified: storage/connect/connect.cc modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/filter.cpp modified: storage/connect/global.h modified: storage/connect/ha_connect.cc modified: storage/connect/jdbconn.cpp modified: storage/connect/json.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/osutil.c modified: storage/connect/plgdbutl.cpp deleted: storage/connect/plugutil.c added: storage/connect/plugutil.cpp modified: storage/connect/tabdos.cpp modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabjdbc.h modified: storage/connect/tabjson.cpp modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h modified: storage/connect/tabmysql.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabodbc.h modified: storage/connect/tabpivot.cpp modified: storage/connect/tabsys.cpp modified: storage/connect/tabvct.cpp modified: storage/connect/tabvir.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/valblk.cpp modified: storage/connect/value.cpp modified: storage/connect/xindex.cpp modified: storage/connect/xobject.cpp --- storage/connect/tabjson.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'storage/connect/tabjson.cpp') diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 1e11d454cfc..4b2ab4fd240 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -1,6 +1,6 @@ /************* tabjson C++ Program Source Code File (.CPP) *************/ -/* PROGRAM NAME: tabjson Version 1.3 */ -/* (C) Copyright to the author Olivier BERTRAND 2014 - 2016 */ +/* PROGRAM NAME: tabjson Version 1.4 */ +/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */ /* This program are the JSON class DB execution routines. */ /***********************************************************************/ @@ -168,7 +168,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) G->Sarea_Size = tdp->Lrecl * 10; G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size); PlugSubSet(G, G->Sarea, G->Sarea_Size); - G->jump_level = -1; + G->jump_level = 0; tjnp->SetG(G); #else tjnp->SetG(g); @@ -478,7 +478,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m) G->Sarea_Size = Lrecl * 10; G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size); PlugSubSet(G, G->Sarea, G->Sarea_Size); - G->jump_level = -1; + G->jump_level = 0; ((TDBJSN*)tdbp)->G = G; #else ((TDBJSN*)tdbp)->G = g; @@ -1289,8 +1289,12 @@ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n) if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) { strcpy(g->Message, "Logical error expanding array"); - longjmp(g->jumper[g->jump_level], 666); - } // endif jvp +#if defined(USE_TRY) + throw 666; +#else // !USE_TRY + longjmp(g->jumper[g->jump_level], 666); +#endif // !USE_TRY + } // endif jvp if (n < Nod - 1 && jvp->GetJson()) { jval.SetValue(GetColumnValue(g, jvp->GetJson(), n + 1)); @@ -1475,8 +1479,12 @@ void JSONCOL::WriteColumn(PGLOBAL g) { if (Xpd && Tjp->Pretty < 2) { strcpy(g->Message, "Cannot write expanded column when Pretty is not 2"); +#if defined(USE_TRY) + throw 666; +#else // !USE_TRY longjmp(g->jumper[g->jump_level], 666); - } // endif Xpd +#endif // !USE_TRY + } // endif Xpd /*********************************************************************/ /* Check whether this node must be written. */ @@ -1510,8 +1518,12 @@ void JSONCOL::WriteColumn(PGLOBAL g) if (!(jsp = ParseJson(G, s, (int)strlen(s)))) { strcpy(g->Message, s); - longjmp(g->jumper[g->jump_level], 666); - } // endif jsp +#if defined(USE_TRY) + throw 666; +#else // !USE_TRY + longjmp(g->jumper[g->jump_level], 666); +#endif // !USE_TRY + } // endif jsp if (arp) { if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ) -- cgit v1.2.1 From a091314d2775e0d33f2476953a7c5ab9647b2f37 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 22 Apr 2017 14:14:11 +0200 Subject: Fix MDEV-12520: Decimal values can be truncated for JDBC tables modified: storage/connect/jdbconn.cpp Fix bug. Date value was null when retrieved from a json expanded array. modified: storage/connect/tabjson.cpp --- storage/connect/tabjson.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'storage/connect/tabjson.cpp') diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 4b2ab4fd240..f451c73b665 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -1171,6 +1171,7 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n) case TYPE_INTG: case TYPE_BINT: case TYPE_DBL: + case TYPE_DATE: vp->SetValue_pval(val->GetValue()); break; case TYPE_BOOL: -- cgit v1.2.1 From 1de6440a2e441e7aeffe85ee9c72e1e001fcf38d Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 3 May 2017 10:32:01 +0200 Subject: Fix MDEV-12587 MariaDB CONNECT DIR Type - Subfolder Option: SELECT Query Never Ends modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h Work on MDEV-12667 Crash when using JSON tables modified: storage/connect/connect.cc modified: storage/connect/ha_connect.cc modified: storage/connect/ha_connect.h modified: storage/connect/plgdbutl.cpp Change Base offset for DIR tables on Linux modified: storage/connect/reldef.cpp --- storage/connect/tabjson.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'storage/connect/tabjson.cpp') diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index f451c73b665..e074232600b 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -117,8 +117,10 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) return NULL; } // endif Fn - tdp->Database = SetPath(g, db); - tdp->Objname = GetStringTableOption(g, topt, "Object", NULL); + if (!(tdp->Database = SetPath(g, db))) + return NULL; + + tdp->Objname = GetStringTableOption(g, topt, "Object", NULL); tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0; tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2); -- cgit v1.2.1 From a2af3c0d44d919051c08b63cb10bed546d5f92a3 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Thu, 4 May 2017 18:51:19 +0200 Subject: 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 --- storage/connect/tabjson.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/connect/tabjson.cpp') diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index e074232600b..9450f8d76aa 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -443,7 +443,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m) if (Zipped) { #if defined(ZIP_SUPPORT) - if (m == MODE_READ || m == MODE_UPDATE) { + if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) { txfp = new(g) UNZFAM(this); } else if (m == MODE_INSERT) { txfp = new(g) ZIPFAM(this); -- cgit v1.2.1 From 531698e0da307943dff5ee6830a241d6829345cd Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 6 May 2017 00:08:20 +0200 Subject: 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 --- storage/connect/tabjson.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'storage/connect/tabjson.cpp') diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 9450f8d76aa..22f9b592952 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -1193,11 +1193,11 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n) // } // endif Type default: - vp->Reset(); - } // endswitch Type + vp->SetNull(true); + } // endswitch Type } else - vp->Reset(); + vp->SetNull(true); } // end of SetJsonValue @@ -1211,7 +1211,7 @@ void JSONCOL::ReadColumn(PGLOBAL g) // Set null when applicable if (Nullable) - Value->SetNull(Value->IsZero()); + Value->SetNull(Value->IsNull()); } // end of ReadColumn @@ -1548,6 +1548,7 @@ void JSONCOL::WriteColumn(PGLOBAL g) // Passthru case TYPE_DATE: case TYPE_INT: + case TYPE_TINY: case TYPE_SHORT: case TYPE_BIGINT: case TYPE_DOUBLE: -- cgit v1.2.1 From 1c88b9a8d3200bdf554ece09316cacf2146877ee Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Thu, 11 May 2017 21:57:21 +0200 Subject: 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 --- storage/connect/tabjson.cpp | 132 ++++++++++++++++++++++++++++++-------------- 1 file changed, 91 insertions(+), 41 deletions(-) (limited to 'storage/connect/tabjson.cpp') diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 22f9b592952..edfe710bc92 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -63,7 +63,7 @@ typedef struct _jncol { /* JSONColumns: construct the result blocks containing the description */ /* of all the columns of a table contained inside a JSON file. */ /***********************************************************************/ -PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) +PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info) { static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; @@ -112,7 +112,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) #endif // ZIP_SUPPORT tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL); - if (!tdp->Fn) { + if (!tdp->Fn && !dsn) { strcpy(g->Message, MSG(MISSING_FNAME)); return NULL; } // endif Fn @@ -120,7 +120,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) if (!(tdp->Database = SetPath(g, db))) return NULL; - tdp->Objname = GetStringTableOption(g, topt, "Object", NULL); + tdp->Objname = GetStringTableOption(g, topt, "Object", NULL); tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0; tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2); @@ -153,7 +153,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) if (tdp->Zipped) { #if defined(ZIP_SUPPORT) - tjnp = new(g)TDBJSN(tdp, new(g)UNZFAM(tdp)); + tjnp = new(g)TDBJSN(tdp, new(g) UNZFAM(tdp)); #else // !ZIP_SUPPORT sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); return NULL; @@ -264,8 +264,13 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) break; if (jcp) { - if (jcp->Type != jcol.Type) - jcp->Type = TYPE_STRING; + if (jcp->Type != jcol.Type) { + if (jcp->Type == TYPE_UNKNOWN) + jcp->Type = jcol.Type; + else if (jcol.Type != TYPE_UNKNOWN) + jcp->Type = TYPE_STRING; + + } // endif Type if (*fmt && (!jcp->Fmt || strlen(jcp->Fmt) < strlen(fmt))) { jcp->Fmt = PlugDup(g, fmt); @@ -338,7 +343,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) skipit: if (trace) - htrc("CSVColumns: n=%d len=%d\n", n, length[0]); + htrc("JSONColumns: n=%d len=%d\n", n, length[0]); /*********************************************************************/ /* Allocate the structures used to refer to the result set. */ @@ -419,7 +424,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff) Pretty = GetIntCatInfo("Pretty", 2); Limit = GetIntCatInfo("Limit", 10); Base = GetIntCatInfo("Base", 0) ? 1 : 0; - return DOSDEF::DefineAM(g, "DOS", poff); + return DOSDEF::DefineAM(g, (Uri ? "XMGO" : "DOS"), poff); } // end of DefineAM /***********************************************************************/ @@ -465,7 +470,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m) sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ"); return NULL; #endif // !GZ_SUPPORT - } else if (map) + } else if (map) txfp = new(g) MAPFAM(this); else txfp = new(g) DOSFAM(this); @@ -488,7 +493,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m) } else { if (Zipped) { #if defined(ZIP_SUPPORT) - if (m == MODE_READ || m == MODE_UPDATE) { + if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) { txfp = new(g) UNZFAM(this); } else if (m == MODE_INSERT) { strcpy(g->Message, "INSERT supported only for zipped JSON when pretty=0"); @@ -537,7 +542,7 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp) } else { Jmode = MODE_OBJECT; Objname = NULL; - Xcol = NULL; + Xcol = NULL; Limit = 1; Pretty = 0; B = 0; @@ -697,6 +702,9 @@ bool TDBJSN::OpenDB(PGLOBAL g) return true; } // endswitch Jmode + if (Xcol && Txfp->GetAmType() != TYPE_AM_MGO) + To_Filter = NULL; // Imcompatible + } // endif Use return TDBDOS::OpenDB(g); @@ -867,24 +875,21 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp) } // end of PrepareWriting - /***********************************************************************/ - /* WriteDB: Data Base write routine for DOS access method. */ - /***********************************************************************/ - int TDBJSN::WriteDB(PGLOBAL g) +/***********************************************************************/ +/* WriteDB: Data Base write routine for DOS access method. */ +/***********************************************************************/ +int TDBJSN::WriteDB(PGLOBAL g) { int rc = TDBDOS::WriteDB(g); #if USE_G - if (rc == RC_FX) - strcpy(g->Message, G->Message); - PlugSubSet(G, G->Sarea, G->Sarea_Size); #endif Row->Clear(); return rc; } // end of WriteDB - /* ---------------------------- JSONCOL ------------------------------ */ +/* ---------------------------- JSONCOL ------------------------------ */ /***********************************************************************/ /* JSONCOL public constructor. */ @@ -1148,12 +1153,62 @@ bool JSONCOL::ParseJpath(PGLOBAL g) return false; } // end of ParseJpath +/***********************************************************************/ +/* Get Jpath converted to Mongo path. */ +/***********************************************************************/ +char *JSONCOL::GetJpath(PGLOBAL g, bool proj) +{ + if (Jpath) { + char *p1, *p2, *mgopath; + int i = 0; + + if (strcmp(Jpath, "*")) + mgopath = PlugDup(g, Jpath); + else + return NULL; + + for (p1 = p2 = mgopath; *p1; p1++) + if (i) { // Inside [] + if (isdigit(*p1)) { + if (!proj) + *p2++ = *p1; + + i = 2; + } else if (*p1 == ']' && i == 2) { + if (proj && *(p1 + 1) == ':') + p1++; + + i = 0; + } else if (proj) + i = 2; + else + return NULL; + + } else switch (*p1) { + case ':': *p2++ = '.'; break; + case '[': i = 1; break; + case '*': + if (*(p2 - 1) == '.' && !*(p1 + 1)) { + p2--; // Suppress last :* + break; + } // endif p2 + + default: *p2++ = *p1; break; + } // endswitch p1; + + *p2 = 0; + return mgopath; + } else + return NULL; + +} // end of GetJpath + /***********************************************************************/ /* MakeJson: Serialize the json item and set value to it. */ /***********************************************************************/ PVAL JSONCOL::MakeJson(PGLOBAL g, PJSON jsp) - { - if (Value->IsTypeNum()) { +{ + if (Value->IsTypeNum()) { strcpy(g->Message, "Cannot make Json for a numeric column"); Value->Reset(); } else @@ -1174,7 +1229,7 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n) case TYPE_BINT: case TYPE_DBL: case TYPE_DATE: - vp->SetValue_pval(val->GetValue()); + vp->SetValue_pval(val->GetValue()); break; case TYPE_BOOL: if (vp->IsTypeNum()) @@ -1193,11 +1248,14 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n) // } // endif Type default: + vp->Reset(); vp->SetNull(true); } // endswitch Type - } else + } else { + vp->Reset(); vp->SetNull(true); + } // endif val } // end of SetJsonValue @@ -1210,8 +1268,8 @@ void JSONCOL::ReadColumn(PGLOBAL g) Value->SetValue_pval(GetColumnValue(g, Tjp->Row, 0)); // Set null when applicable - if (Nullable) - Value->SetNull(Value->IsNull()); + if (!Nullable) + Value->SetNull(false); } // end of ReadColumn @@ -1292,11 +1350,7 @@ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n) if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) { strcpy(g->Message, "Logical error expanding array"); -#if defined(USE_TRY) throw 666; -#else // !USE_TRY - longjmp(g->jumper[g->jump_level], 666); -#endif // !USE_TRY } // endif jvp if (n < Nod - 1 && jvp->GetJson()) { @@ -1482,11 +1536,7 @@ void JSONCOL::WriteColumn(PGLOBAL g) { if (Xpd && Tjp->Pretty < 2) { strcpy(g->Message, "Cannot write expanded column when Pretty is not 2"); -#if defined(USE_TRY) throw 666; -#else // !USE_TRY - longjmp(g->jumper[g->jump_level], 666); -#endif // !USE_TRY } // endif Xpd /*********************************************************************/ @@ -1521,11 +1571,7 @@ void JSONCOL::WriteColumn(PGLOBAL g) if (!(jsp = ParseJson(G, s, (int)strlen(s)))) { strcpy(g->Message, s); -#if defined(USE_TRY) throw 666; -#else // !USE_TRY - longjmp(g->jumper[g->jump_level], 666); -#endif // !USE_TRY } // endif jsp if (arp) { @@ -1876,8 +1922,11 @@ bool TDBJSON::OpenDB(PGLOBAL g) return true; } // endswitch Jmode - Use = USE_OPEN; - return false; + if (Xcol) + To_Filter = NULL; // Imcompatible + + Use = USE_OPEN; + return false; } // end of OpenDB /***********************************************************************/ @@ -1887,7 +1936,7 @@ int TDBJSON::ReadDB(PGLOBAL) { int rc; - N++; + N++; if (NextSame) { SameRow = NextSame; @@ -1999,6 +2048,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) { Topt = tdp->GetTopt(); Db = (char*)tdp->GetDB(); + Dsn = (char*)tdp->Uri; } // end of TDBJCL constructor /***********************************************************************/ @@ -2006,7 +2056,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) /***********************************************************************/ PQRYRES TDBJCL::GetResult(PGLOBAL g) { - return JSONColumns(g, Db, Topt, false); + return JSONColumns(g, Db, Dsn, Topt, false); } // end of GetResult /* --------------------------- End of json --------------------------- */ -- cgit v1.2.1 From 436070c6e106d22f2afce3a28fc15e33a2241ef9 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Fri, 12 May 2017 00:33:33 +0200 Subject: Fix failing test connect.json for MariaDB 10.0 Suppressing Uri and dsn from json tables (was MGO) modified: storage/connect/ha_connect.cc modified: storage/connect/tabdos.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h --- storage/connect/tabjson.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'storage/connect/tabjson.cpp') diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index edfe710bc92..5853425a4e5 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -63,7 +63,7 @@ typedef struct _jncol { /* JSONColumns: construct the result blocks containing the description */ /* of all the columns of a table contained inside a JSON file. */ /***********************************************************************/ -PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info) +PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info) { static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; @@ -112,7 +112,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info) #endif // ZIP_SUPPORT tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL); - if (!tdp->Fn && !dsn) { + if (!tdp->Fn) { strcpy(g->Message, MSG(MISSING_FNAME)); return NULL; } // endif Fn @@ -424,7 +424,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff) Pretty = GetIntCatInfo("Pretty", 2); Limit = GetIntCatInfo("Limit", 10); Base = GetIntCatInfo("Base", 0) ? 1 : 0; - return DOSDEF::DefineAM(g, (Uri ? "XMGO" : "DOS"), poff); + return DOSDEF::DefineAM(g, "DOS", poff); } // end of DefineAM /***********************************************************************/ @@ -2048,7 +2048,6 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) { Topt = tdp->GetTopt(); Db = (char*)tdp->GetDB(); - Dsn = (char*)tdp->Uri; } // end of TDBJCL constructor /***********************************************************************/ @@ -2056,7 +2055,7 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) /***********************************************************************/ PQRYRES TDBJCL::GetResult(PGLOBAL g) { - return JSONColumns(g, Db, Dsn, Topt, false); + return JSONColumns(g, Db, Topt, false); } // end of GetResult /* --------------------------- End of json --------------------------- */ -- cgit v1.2.1 From 7972da8aa1c52121f60fb8fdae534a46892b4e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 16 May 2017 20:08:47 +0300 Subject: Silence bogus GCC 7 warnings -Wimplicit-fallthrough Do not silence uncertain cases, or fix any bugs. The only functional change should be that ha_federated::extra() is not calling DBUG_PRINT to report an unhandled case for HA_EXTRA_PREPARE_FOR_DROP. --- storage/connect/tabjson.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/connect/tabjson.cpp') diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 1e11d454cfc..2addcc139fb 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -1530,7 +1530,7 @@ void JSONCOL::WriteColumn(PGLOBAL g) break; } // endif Op - // Passthru + // fall through case TYPE_DATE: case TYPE_INT: case TYPE_SHORT: -- cgit v1.2.1