diff options
Diffstat (limited to 'storage/connect')
| -rw-r--r-- | storage/connect/array.cpp | 2 | ||||
| -rw-r--r-- | storage/connect/connect.cc | 3 | ||||
| -rw-r--r-- | storage/connect/filter.cpp | 6 | ||||
| -rw-r--r-- | storage/connect/ha_connect.cc | 60 | ||||
| -rw-r--r-- | storage/connect/jdbconn.cpp | 62 | ||||
| -rw-r--r-- | storage/connect/json.h | 5 | ||||
| -rw-r--r-- | storage/connect/jsonudf.cpp | 6 | ||||
| -rw-r--r-- | storage/connect/plgdbutl.cpp | 2 | ||||
| -rw-r--r-- | storage/connect/tabdos.cpp | 10 | ||||
| -rw-r--r-- | storage/connect/tabodbc.cpp | 2 | ||||
| -rw-r--r-- | storage/connect/tabxml.cpp | 2 | ||||
| -rw-r--r-- | storage/connect/value.cpp | 51 |
12 files changed, 108 insertions, 103 deletions
diff --git a/storage/connect/array.cpp b/storage/connect/array.cpp index 639edf63a1a..59a53487a7e 100644 --- a/storage/connect/array.cpp +++ b/storage/connect/array.cpp @@ -520,7 +520,7 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm) } else if (opc != OP_EXIST) { sprintf(g->Message, MSG(MISSING_ARG), opc); - throw (int)TYPE_ARRAY; + throw (int)TYPE_ARRAY; } else // OP_EXIST return Nval > 0; diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 6b7236a2f83..5e80201fccf 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -1,4 +1,5 @@ -/* Copyright (C) MariaDB Corporation Ab +/* Copyright (C) Olivier Bertrand 2004 - 2017 + Copyright (C) MariaDB Corporation Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp index 1ca482ca269..bb3be629ea4 100644 --- a/storage/connect/filter.cpp +++ b/storage/connect/filter.cpp @@ -87,7 +87,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc) case OP_EXIST: bt = 0x00; break; default: sprintf(g->Message, MSG(BAD_FILTER_OP), opc); - throw (int)TYPE_ARRAY; + throw (int)TYPE_FILTER; } // endswitch opc return bt; @@ -1790,7 +1790,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having) break; // Remove eventual ending separator(s) // if (fp->Convert(g, having)) -// (int)throw TYPE_ARRAY; +// throw (int)TYPE_FILTER; filp = fp; fp = fp->Next; @@ -1799,8 +1799,6 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having) if (trace) htrc(" returning filp=%p\n", filp); -//if (filp) -// filp->Print(g, debug, 0); return filp; } // end of PrepareFilter diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index b73f41ff741..458369cd981 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -98,8 +98,8 @@ rnd_next signals that it has reached the end of its data. Calls to ha_connect::extra() are hints as to what will be occuring to the request. - Author Olivier Bertrand -*/ + Author Olivier Bertrand + */ #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation @@ -1070,55 +1070,55 @@ PCSZ GetListOption(PGLOBAL g, PCSZ opname, PCSZ oplist, PCSZ def) if (!oplist) return (char*)def; - char key[16], val[256]; - char *pv, *pn, *pk= (char*)oplist; - PCSZ opval= def; - int n; + char key[16], val[256]; + char *pv, *pn, *pk = (char*)oplist; + PCSZ opval = def; + int n; while (*pk == ' ') pk++; - for (; pk; pk= pn) { - pn= strchr(pk, ','); - pv= strchr(pk, '='); + for (; pk; pk = pn) { + pn = strchr(pk, ','); + pv = strchr(pk, '='); - if (pv && (!pn || pv < pn)) { + if (pv && (!pn || pv < pn)) { n = MY_MIN(static_cast<size_t>(pv - pk), sizeof(key) - 1); memcpy(key, pk, n); while (n && key[n - 1] == ' ') n--; - key[n]= 0; + key[n] = 0; - while(*(++pv) == ' ') ; + while (*(++pv) == ' '); - n= MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1); - memcpy(val, pv, n); + n = MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1); + memcpy(val, pv, n); while (n && val[n - 1] == ' ') n--; - val[n]= 0; - } else { - n= MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1); - memcpy(key, pk, n); + val[n] = 0; + } else { + n = MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1); + memcpy(key, pk, n); while (n && key[n - 1] == ' ') n--; - key[n]= 0; - val[0]= 0; - } // endif pv + key[n] = 0; + val[0] = 0; + } // endif pv - if (!stricmp(opname, key)) { - opval= PlugDup(g, val); - break; - } else if (!pn) - break; + if (!stricmp(opname, key)) { + opval = PlugDup(g, val); + break; + } else if (!pn) + break; - while (*(++pn) == ' ') ; - } // endfor pk + while (*(++pn) == ' '); + } // endfor pk return opval; } // end of GetListOption @@ -4321,8 +4321,8 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick) } else return false; - /* check FILE_ACL */ - /* fall through */ + // check FILE_ACL + // fall through case TAB_ODBC: case TAB_JDBC: case TAB_MYSQL: diff --git a/storage/connect/jdbconn.cpp b/storage/connect/jdbconn.cpp index cfe74cabacd..9746a66e6c8 100644 --- a/storage/connect/jdbconn.cpp +++ b/storage/connect/jdbconn.cpp @@ -154,38 +154,38 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v) case 91: // DATE, YEAR type = TYPE_DATE; - if (!tn || toupper(tn[0]) != 'Y') { - len = 10; - v = 'D'; - } else { - len = 4; - v = 'Y'; - } // endif len + if (!tn || toupper(tn[0]) != 'Y') { + len = 10; + v = 'D'; + } else { + len = 4; + v = 'Y'; + } // endif len - break; - case 92: // TIME - type = TYPE_DATE; - len = 8 + ((prec) ? (prec+1) : 0); - v = 'T'; - break; - case -5: // BIGINT - type = TYPE_BIGINT; - break; - case 0: // NULL - case -2: // BINARY - case -4: // LONGVARBINARY - case 70: // DATALINK - case 2000: // JAVA_OBJECT - case 2001: // DISTINCT - case 2002: // STRUCT - case 2003: // ARRAY - case 2004: // BLOB - case 2005: // CLOB - case 2006: // REF - case 2009: // SQLXML - case 2011: // NCLOB - default: - type = TYPE_ERROR; + break; + case 92: // TIME + type = TYPE_DATE; + len = 8 + ((prec) ? (prec + 1) : 0); + v = 'T'; + break; + case -5: // BIGINT + type = TYPE_BIGINT; + break; + case 0: // NULL + case -2: // BINARY + case -4: // LONGVARBINARY + case 70: // DATALINK + case 2000: // JAVA_OBJECT + case 2001: // DISTINCT + case 2002: // STRUCT + case 2003: // ARRAY + case 2004: // BLOB + case 2005: // CLOB + case 2006: // REF + case 2009: // SQLXML + case 2011: // NCLOB + default: + type = TYPE_ERROR; len = 0; } // endswitch type diff --git a/storage/connect/json.h b/storage/connect/json.h index cf7b2b18737..fd6c029df99 100644 --- a/storage/connect/json.h +++ b/storage/connect/json.h @@ -43,6 +43,10 @@ typedef struct { int len; } STRG, *PSG; +bool IsNum(PSZ s); +char *NextChr(PSZ s, char sep); +char *GetJsonNull(void); + PJSON ParseJson(PGLOBAL g, char *s, int n, int *prty = NULL, bool *b = NULL); PJAR ParseArray(PGLOBAL g, int& i, STRG& src, bool *pty); PJOB ParseObject(PGLOBAL g, int& i, STRG& src, bool *pty); @@ -294,4 +298,3 @@ class JVALUE : public JSON { PJVAL Next; // Next value in array bool Del; // True when deleted }; // end of class JVALUE - diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 12e511c51b2..00627669d60 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -31,13 +31,15 @@ bool IsNum(PSZ s); char *NextChr(PSZ s, char sep); char *GetJsonNull(void); uint GetJsonGrpSize(void); -static int IsJson(UDF_ARGS *args, uint i); -static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i); +static int IsJson(UDF_ARGS *args, uint i); +static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i); static char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *res_length, char *is_null, char *error); static char *bin_handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *res_length, char *is_null, char *error); +void json_array_deinit(UDF_INIT* initid); + static uint JsonGrpSize = 10; /* ----------------------------------- JSNX ------------------------------------ */ diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index 9b160df77b8..25da3162516 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -95,7 +95,7 @@ extern pthread_mutex_t parmut; //#endif // !__WIN__ // The debug trace used by the main thread - FILE *pfile = NULL; +FILE *pfile = NULL; MBLOCK Nmblk = {NULL, false, 0, false, NULL}; // Used to init MBLOCK's diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index b44705bc3cc..3b850cfd258 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -1311,7 +1311,7 @@ PBF TDBDOS::InitBlockFilter(PGLOBAL g, PFIL filp) } // endif !opm // if opm, pass thru - /* fall through */ + // fall through case OP_IN: if (filp->GetArgType(0) == TYPE_COLBLK && filp->GetArgType(1) == TYPE_ARRAY) { @@ -1647,8 +1647,8 @@ int TDBDOS::TestBlock(PGLOBAL g) /***********************************************************************/ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) { - int k, n, rc = RC_OK; - bool fixed, doit, sep, b = (pxdf != NULL); + int k, n, rc = RC_OK; + bool fixed, doit, sep, b = (pxdf != NULL); PCOL *keycols, colp; PIXDEF xdp, sxp = NULL; PKPDEF kdp; @@ -1694,8 +1694,8 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) try { // Allocate all columns that will be used by indexes. - // This must be done before opening the table so specific - // column initialization can be done (in particular by TDBVCT) + // This must be done before opening the table so specific + // column initialization can be done (in particular by TDBVCT) for (n = 0, xdp = pxdf; xdp; xdp = xdp->GetNext()) for (kdp = xdp->GetToKeyParts(); kdp; kdp = kdp->GetNext()) { if (!(colp = ColDB(g, kdp->GetName(), 0))) { diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index 56e5e72efd6..8ffa234ba5c 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -289,7 +289,7 @@ void TDBODBC::SetFile(PGLOBAL g, PCSZ fn) sprintf(Connect, MulConn, fn); } // endif MultConn - DBQ = (PSZ)fn; + DBQ = PlugDup(g, fn); } // end of SetFile /***********************************************************************/ diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index 6402f48e090..c09386451ff 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -1319,7 +1319,7 @@ void TDBXML::CloseDB(PGLOBAL g) Docp->CloseDoc(g, To_Xb); // This causes a crash in Diagnostics_area::set_error_status -// throw (int)TYPE_AM_XML; +// throw (int)TYPE_AM_XML; } // endif DumpDoc } // endif Changed diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index d709c20218a..60d1c2f459c 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -1656,35 +1656,36 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) int i; for (i = 0; i < np; i++) - if (vp[i]->IsNull()) - return false; - else - p[i] = vp[i]->GetCharString(val[i]); + p[i] = vp[i]->IsNull() ? NULL : vp[i]->GetCharString(val[i]); - switch (op) { - case OP_CNC: - assert(np == 1 || np == 2); + if (p[i-1]) { + switch (op) { + case OP_CNC: + assert(np == 1 || np == 2); - if (np == 2) - SetValue_psz(p[0]); + if (np == 2) + SetValue_psz(p[0]); - if ((i = Len - (signed)strlen(Strp)) > 0) - strncat(Strp, p[np - 1], i); + if ((i = Len - (signed)strlen(Strp)) > 0) + strncat(Strp, p[np - 1], i); - break; - case OP_MIN: - assert(np == 2); - SetValue_psz((strcmp(p[0], p[1]) < 0) ? p[0] : p[1]); - break; - case OP_MAX: - assert(np == 2); - SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]); - break; - default: - // sprintf(g->Message, MSG(BAD_EXP_OPER), op); - strcpy(g->Message, "Function not supported"); - return true; - } // endswitch op + break; + case OP_MIN: + assert(np == 2); + SetValue_psz((strcmp(p[0], p[1]) < 0) ? p[0] : p[1]); + break; + case OP_MAX: + assert(np == 2); + SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]); + break; + default: + // sprintf(g->Message, MSG(BAD_EXP_OPER), op); + strcpy(g->Message, "Function not supported"); + return true; + } // endswitch op + + Null = false; + } // endif p[i] Null = false; return false; |
