diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2018-02-16 15:43:33 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2018-02-16 15:43:33 +0100 |
commit | 34e141180b1c615f66b07b6e7b71e0c9b1491bd7 (patch) | |
tree | 852ff00aa07613af0cff9f7ac9d01155353013c2 /storage/connect | |
parent | 18e6a81bab2ea148b008b9d0106bbcc0d42ac026 (diff) | |
parent | a351f40cba21244b8b6c2d8b86631407abd62dd9 (diff) | |
download | mariadb-git-34e141180b1c615f66b07b6e7b71e0c9b1491bd7.tar.gz |
Commit merge of new MariaDB version
Diffstat (limited to 'storage/connect')
-rw-r--r-- | storage/connect/filter.cpp | 83 | ||||
-rw-r--r-- | storage/connect/fmdlex.c | 18 | ||||
-rw-r--r-- | storage/connect/myconn.cpp | 5 | ||||
-rw-r--r-- | storage/connect/rcmsg.c | 7 | ||||
-rw-r--r-- | storage/connect/rcmsg.h | 2 | ||||
-rw-r--r-- | storage/connect/reldef.cpp | 14 | ||||
-rw-r--r-- | storage/connect/tabmul.cpp | 4 | ||||
-rw-r--r-- | storage/connect/tabmysql.h | 2 |
8 files changed, 109 insertions, 26 deletions
diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp index 47fead660fd..4a1a3aca7a2 100644 --- a/storage/connect/filter.cpp +++ b/storage/connect/filter.cpp @@ -35,6 +35,9 @@ #include "array.h" #include "filter.h" #include "xindex.h" +#if defined(MONGO_SUPPORT) || defined(JDBC_SUPPORT) +#include "tabext.h" +#endif // MONGO_SUPPORT || JDBC_SUPPORT /***********************************************************************/ /* Utility routines. */ @@ -1403,6 +1406,86 @@ PFIL FILTER::Copy(PTABS t) } // end of Copy #endif // 0 +#if defined(MONGO_SUPPORT) +/***********************************************************************/ +/* Make selector json representation for Mongo tables. */ +/***********************************************************************/ +bool FILTER::MakeSelector(PGLOBAL g, PSTRG s) +{ + s->Append('{'); + + if (Opc == OP_AND || Opc == OP_OR) { + if (GetArgType(0) != TYPE_FILTER || GetArgType(1) != TYPE_FILTER) + return true; + + s->Append("\"$"); + s->Append(Opc == OP_AND ? "and" : "or"); + s->Append("\":["); + + if (((PFIL)Arg(0))->MakeSelector(g, s)) + return true; + + s->Append(','); + + if (((PFIL)Arg(1))->MakeSelector(g, s)) + return true; + + s->Append(']'); + } else { + if (GetArgType(0) != TYPE_COLBLK) + return true; + + s->Append('"'); + s->Append(((PCOL)Arg(0))->GetJpath(g, false)); + s->Append("\":{\"$"); + + switch (Opc) { + case OP_EQ: + s->Append("eq"); + break; + case OP_NE: + s->Append("ne"); + break; + case OP_GT: + s->Append("gt"); + break; + case OP_GE: + s->Append("gte"); + break; + case OP_LT: + s->Append("lt"); + break; + case OP_LE: + s->Append("lte"); + break; + case OP_NULL: + case OP_LIKE: + case OP_EXIST: + default: + return true; + } // endswitch Opc + + s->Append("\":"); + + if (GetArgType(1) == TYPE_COLBLK) { + s->Append("\"$"); + s->Append(((PEXTCOL)Arg(1))->GetJpath(g, false)); + s->Append('"'); + } else { + char buf[501]; + + Arg(1)->Prints(g, buf, 500); + s->Append(buf); + } // endif Type + + s->Append('}'); + } // endif Opc + + s->Append('}'); + return false; +} // end of MakeSelector +#endif // MONGO_SUPPORT + /*********************************************************************/ /* Make file output of FILTER contents. */ /*********************************************************************/ diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index 548a7ae5b7e..a8d48a5d3b1 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -417,10 +417,10 @@ static PDTP pp; static void MakeParm(int n); static void MakeMMDD(int n); static void MakeAMPM(int n); -static void MakeIn(char *); -static void MakeOut(char *); -static void Quotin(char *); -static void Quotout(char *); +static void MakeIn(const char *); +static void MakeOut(const char *); +static void Quotin(const char *); +static void Quotout(const char *); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -529,7 +529,7 @@ YY_DECL pp->Num = 0; if (pp->InFmt) {*pp->InFmt = '\0'; pp->InFmt[pp->Outsize -1] = '\0'; } if (pp->OutFmt) {*pp->OutFmt = '\0'; pp->OutFmt[pp->Outsize -1] = '\0'; } - pp->Curp = pp->Format; + pp->Curp = (char*) pp->Format; yy_init = 1; /* This is a new input */ @@ -1492,7 +1492,7 @@ void MakeAMPM(int n) } /* end of MakeAMPM */ -void MakeIn(char *text) +void MakeIn(const char *text) { if (!pp->InFmt) return; @@ -1500,14 +1500,14 @@ void MakeIn(char *text) strncat(pp->InFmt, text, (pp->Outsize - 1) - strlen(pp->InFmt)); } /* end of MakeIn */ -void MakeOut(char *text) +void MakeOut(const char *text) { if (!pp->OutFmt) return; strncat(pp->OutFmt, text, (pp->Outsize - 1) - strlen(pp->OutFmt)); } /* end of MakeOut */ -void Quotin(char *text) +void Quotin(const char *text) { if (!pp->InFmt) return; @@ -1516,7 +1516,7 @@ void Quotin(char *text) pp->InFmt[strlen(pp->InFmt)-1] = '\0'; } /* end of Quotin */ -void Quotout(char *text) +void Quotout(const char *text) { if (!pp->OutFmt) return; diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 9da9c268c3d..41c6c1b90b4 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -933,8 +933,9 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) crp->Prec = (crp->Type == TYPE_DOUBLE || crp->Type == TYPE_DECIM) ? fld->decimals : 0; - crp->Length = MY_MAX(fld->length, fld->max_length); - crp->Clen = GetTypeSize(crp->Type, crp->Length); + CHARSET_INFO *cs= get_charset(fld->charsetnr, MYF(0)); + crp->Clen = GetTypeSize(crp->Type, fld->length); + crp->Length = fld->length / (cs ? cs->mbmaxlen : 1); uns = (fld->flags & (UNSIGNED_FLAG | ZEROFILL_FLAG)) ? true : false; if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows, diff --git a/storage/connect/rcmsg.c b/storage/connect/rcmsg.c index 75759e03314..895f8f5862b 100644 --- a/storage/connect/rcmsg.c +++ b/storage/connect/rcmsg.c @@ -27,9 +27,9 @@ char *msglang(void); -char *GetMsgid(int id) +const char *GetMsgid(int id) { - char *p = NULL; + const char *p = NULL; // This conditional until a real fix is found for MDEV-7304 #if defined(FRENCH) @@ -55,7 +55,8 @@ char *GetMsgid(int id) int GetRcString(int id, char *buf, int bufsize) { - char *p = NULL, msg[32]; + const char *p = NULL; + char msg[32]; if (!(p = GetMsgid(id))) { sprintf(msg, "ID=%d unknown", id); diff --git a/storage/connect/rcmsg.h b/storage/connect/rcmsg.h index b22e77f5175..499ca3b2dd4 100644 --- a/storage/connect/rcmsg.h +++ b/storage/connect/rcmsg.h @@ -5,7 +5,7 @@ extern "C" { #endif -char *GetMsgid(int id); +const char *GetMsgid(int id); int GetRcString(int id, char *buf, int bufsize); #ifdef __cplusplus diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index 072bd25c5a7..e4f169575f8 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -547,14 +547,12 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) } // endif dladdr #endif // 0 - // Is the library already loaded? - if (!Hdll && !(Hdll = dlopen(soname, RTLD_NOLOAD))) - // Load the desired shared library - if (!(Hdll = dlopen(soname, RTLD_LAZY))) { - error = dlerror(); - sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error)); - return NULL; - } // endif Hdll + // Load the desired shared library + if (!Hdll && !(Hdll = dlopen(soname, RTLD_LAZY))) { + error = dlerror(); + sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error)); + return NULL; + } // endif Hdll // The exported name is always in uppercase for (int i = 0; ; i++) { diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index 1afd21db452..649fc6706c6 100644 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -203,12 +203,12 @@ bool TDBMUL::InitFileNames(PGLOBAL g) // Data files can be imported from Windows (having CRLF) if (*p == '\n' || *p == '\r') { // is this enough for Unix ??? - *p--; // Eliminate ending CR or LF character + p--; // Eliminate ending CR or LF character if (p >= filename) // is this enough for Unix ??? if (*p == '\n' || *p == '\r') - *p--; // Eliminate ending CR or LF character + p--; // Eliminate ending CR or LF character } // endif p diff --git a/storage/connect/tabmysql.h b/storage/connect/tabmysql.h index 39fba87bcc9..4b61c7eb762 100644 --- a/storage/connect/tabmysql.h +++ b/storage/connect/tabmysql.h @@ -135,7 +135,7 @@ class TDBMYSQL : public TDBEXT { int m_Rc; // Return code from command //int AftRows; // The number of affected rows int N; // The current table index - int Port; // MySQL port number (0 = default) + unsigned Port; // MySQL port number (0 = default) //int Nparm; // The number of statement parameters //int Quoted; // The identifier quoting level }; // end of class TDBMYSQL |