diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 80b5d062039..6fb79f5f58a 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -508,7 +508,8 @@ ha_create_table_option connect_table_option_list[]= HA_TOPTION_STRING("CATFUNC", catfunc), HA_TOPTION_STRING("SRCDEF", srcdef), HA_TOPTION_STRING("COLIST", colist), - HA_TOPTION_STRING("OPTION_LIST", oplist), + HA_TOPTION_STRING("FILTER", filter), + HA_TOPTION_STRING("OPTION_LIST", oplist), HA_TOPTION_STRING("DATA_CHARSET", data_charset), HA_TOPTION_NUMBER("LRECL", lrecl, 0, 0, INT_MAX32, 1), HA_TOPTION_NUMBER("BLOCK_SIZE", elements, 0, 0, INT_MAX32, 1), @@ -1106,7 +1107,9 @@ PCSZ GetStringTableOption(PGLOBAL g, PTOS options, PCSZ opname, PCSZ sdef) opval= options->srcdef; else if (!stricmp(opname, "Colist")) opval= options->colist; - else if (!stricmp(opname, "Data_charset")) + else if (!stricmp(opname, "Filter")) + opval = options->filter; + else if (!stricmp(opname, "Data_charset")) opval= options->data_charset; if (!opval && options->oplist) @@ -4447,7 +4450,7 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, case SQLCOM_CHECK: // TODO implement it case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT... - newmode= MODE_READ; + newmode= MODE_READ; break; default: htrc("Unsupported sql_command=%d\n", thd_sql_command(thd)); @@ -5584,6 +5587,9 @@ static int connect_assisted_discovery(handlerton *, THD* thd, break; #if defined(MONGO_SUPPORT) case TAB_MONGO: + if (!topt->tabname) + topt->tabname = tab; + ok = true; break; #endif // MONGO_SUPPORT @@ -6204,7 +6210,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, // Note that if no support is specified, the default is MS-DOM // on Windows and libxml2 otherwise - switch (*xsup) { + switch (toupper(*xsup)) { case '*': #if defined(__WIN__) dom= true; diff --git a/storage/connect/mongofam.cpp b/storage/connect/mongofam.cpp index 0b9bd429d85..2452d10e114 100644 --- a/storage/connect/mongofam.cpp +++ b/storage/connect/mongofam.cpp @@ -87,7 +87,7 @@ MGOFAM::MGOFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL) Db_name = tdp->Schema; Coll_name = tdp->Collname; Options = tdp->Options; - Filter = NULL; + Filter = tdp->Filter; Done = false; Pipe = tdp->Pipe; Lrecl = tdp->Lrecl + tdp->Ending; @@ -234,19 +234,6 @@ bool MGOFAM::Init(PGLOBAL g) if (Done) return false; - if (Options && !Pipe) { - char *p = (char*)strchr(Options, ';'); - - if (p) { - *p++ = 0; - - if (p) - Filter = p; - - } // endif p - - } // endif Options - Uri = mongoc_uri_new(Uristr); if (!Uri) { @@ -311,7 +298,7 @@ bool MGOFAM::MakeCursor(PGLOBAL g) for (cp = Tdbp->GetColumns(); cp; cp = cp->GetNext()) if (!strcmp(cp->GetName(), "_id")) id = true; - else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*")) + else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*") && !Options) all = true; if (Pipe) { diff --git a/storage/connect/mycat.h b/storage/connect/mycat.h index b6bdd5e5e11..75dd0e5d150 100644 --- a/storage/connect/mycat.h +++ b/storage/connect/mycat.h @@ -47,6 +47,7 @@ struct ha_table_option_struct { const char *catfunc; const char *srcdef; const char *colist; + const char *filter; const char *oplist; const char *data_charset; ulonglong lrecl; diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 98c9f080b48..e4246b7cf29 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -463,7 +463,7 @@ JSONDEF::JSONDEF(void) Sep = '.'; #if defined(MONGO_SUPPORT) Uri = NULL; - Collname = Schema = Options = NULL; + Collname = Schema = Options = Filter = NULL; Pipe = false; #endif // MONGO_SUPPORT } // end of JSONDEF constructor @@ -488,6 +488,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff) Collname = GetStringCatInfo(g, "Tabname", Collname); Schema = GetStringCatInfo(g, "Dbname", "test"); Options = GetStringCatInfo(g, "Colist", NULL); + Filter = GetStringCatInfo(g, "Filter", NULL); Pipe = GetBoolCatInfo("Pipeline", false); Pretty = 0; #else // !MONGO_SUPPORT @@ -1323,7 +1324,7 @@ char *JSONCOL::GetJpath(PGLOBAL g, bool proj) *p2++ = '.'; break; case '[': - if (*p2 != '.') + if (*(p2 - 1) != '.') *p2++ = '.'; i = 1; diff --git a/storage/connect/tabjson.h b/storage/connect/tabjson.h index 9ca03ddbc83..c87bf7ff903 100644 --- a/storage/connect/tabjson.h +++ b/storage/connect/tabjson.h @@ -66,7 +66,8 @@ public: #if defined(MONGO_SUPPORT) PCSZ Collname; /* External collection name */ PCSZ Schema; /* External schema (DB) name */ - PSZ Options; /* Colist ; filter */ + PSZ Options; /* Colist ; Pipe */ + PSZ Filter; /* Filter */ bool Pipe; /* True if Colist is a pipeline */ #endif // MONGO_SUPPORT }; // end of JSONDEF diff --git a/storage/connect/tabmgo.cpp b/storage/connect/tabmgo.cpp index 37a0e44debc..5a804a749e8 100644 --- a/storage/connect/tabmgo.cpp +++ b/storage/connect/tabmgo.cpp @@ -170,18 +170,9 @@ int MGODISC::GetColumns(PGLOBAL g, char *db, PTOS topt) tdp->Tabschema = GetStringTableOption(g, topt, "Dbname", db); tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0; tdp->Colist = GetStringTableOption(g, topt, "Colist", "all"); + tdp->Filter = GetStringTableOption(g, topt, "Filter", NULL); tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false); - if (tdp->Colist) { - char *p = (char*)strchr(tdp->Colist, ';'); - - if (p) { - *p++ = 0; - tdp->Filter = *p ? p : NULL; - } // endif p - - } // endif Colist - if (trace) htrc("Uri %s coll=%s db=%s colist=%s filter=%s lvl=%d\n", tdp->Uri, tdp->Tabname, tdp->Tabschema, tdp->Colist, tdp->Filter, lvl); @@ -412,8 +403,8 @@ bool MGODEF::DefineAM(PGLOBAL g, LPCSTR, int poff) /***********************************************************************/ PTDB MGODEF::GetTable(PGLOBAL g, MODE m) { - //if (Catfunc == FNC_COL) - // return new(g)TDBGOL(this); + if (Catfunc == FNC_COL) + return new(g)TDBGOL(this); return new(g) TDBMGO(this); } // end of GetTable @@ -650,19 +641,6 @@ bool TDBMGO::Init(PGLOBAL g) G = g; - if (Options && !Pipe) { - char *p = (char*)strchr(Options, ';'); - - if (p) { - *p++ = 0; - - if (p) - Filter = p; - - } // endif p - - } // endif Options - Uri = mongoc_uri_new(Uristr); if (!Uri) { @@ -746,7 +724,7 @@ mongoc_cursor_t *TDBMGO::MakeCursor(PGLOBAL g) for (cp = Columns; cp; cp = cp->GetNext()) if (!strcmp(cp->GetName(), "_id")) id = true; - else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*")) + else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*") && !Options) all = true; if (Pipe) { @@ -1455,17 +1433,15 @@ bool MGOCOL::AddValue(PGLOBAL g, bson_t *doc, char *key, bool upd) } // end of AddValue -#if 0 /* ---------------------------TDBGOL class --------------------------- */ /***********************************************************************/ /* TDBGOL class constructor. */ /***********************************************************************/ -TDBJCL::TDBJCL(PMGODEF tdp) : TDBCAT(tdp) +TDBGOL::TDBGOL(PMGODEF tdp) : TDBCAT(tdp) { Topt = tdp->GetTopt(); - Db = (char*)tdp->GetDB(); - Dsn = (char*)tdp->Uri; + Db = (char*)tdp->GetTabschema(); } // end of TDBJCL constructor /***********************************************************************/ @@ -1473,8 +1449,7 @@ TDBJCL::TDBJCL(PMGODEF tdp) : TDBCAT(tdp) /***********************************************************************/ PQRYRES TDBGOL::GetResult(PGLOBAL g) { - return JSONColumns(g, Db, Dsn, Topt, false); + return MGOColumns(g, Db, Topt, false); } // end of GetResult -#endif // 0 /* -------------------------- End of mongo --------------------------- */ diff --git a/storage/connect/tabmgo.h b/storage/connect/tabmgo.h index 610de367268..66676794e47 100644 --- a/storage/connect/tabmgo.h +++ b/storage/connect/tabmgo.h @@ -85,7 +85,7 @@ protected: // Members PCSZ Uri; /* MongoDB connection URI */ PCSZ Colist; /* Options list */ - char *Filter; /* Filtering query */ + PCSZ Filter; /* Filtering query */ int Level; /* Used for catalog table */ int Base; /* The array index base */ bool Pipe; /* True is Colist is a pipeline */ @@ -110,7 +110,7 @@ public: }; // end of INCOL; /***********************************************************************/ -/* This is the MongoDB Access Method class declaration. */ +/* This is the MongoDB Table Type class declaration. */ /* The table is a collection, each record being a document. */ /***********************************************************************/ class DllExport TDBMGO : public TDBEXT { @@ -213,7 +213,6 @@ protected: char *Mbuf; // The Mini buffer }; // end of class MGOCOL -#if 0 /***********************************************************************/ /* This is the class declaration for the MONGO catalog table. */ /***********************************************************************/ @@ -229,6 +228,4 @@ protected: // Members PTOS Topt; char *Db; - char *Dsn; }; // end of class TDBGOL -#endif // 0