Commit de1a9b17 authored by Olivier Bertrand's avatar Olivier Bertrand

Add table option FILTER used by Mongo and Json tables.

  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/mongofam.cpp
  modified:   storage/connect/mycat.h
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabjson.h
  modified:   storage/connect/tabmgo.cpp
  modified:   storage/connect/tabmgo.h

Fix a regression bug in MongoFam
(all = true only when no Options)
  modified:   storage/connect/mongofam.cpp

Fix a regression bug in JsonCol
(in JSONCOL::GetJpath)
  modified:   storage/connect/tabjson.cpp
parent cbdfdfc8
...@@ -508,7 +508,8 @@ ha_create_table_option connect_table_option_list[]= ...@@ -508,7 +508,8 @@ ha_create_table_option connect_table_option_list[]=
HA_TOPTION_STRING("CATFUNC", catfunc), HA_TOPTION_STRING("CATFUNC", catfunc),
HA_TOPTION_STRING("SRCDEF", srcdef), HA_TOPTION_STRING("SRCDEF", srcdef),
HA_TOPTION_STRING("COLIST", colist), 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_STRING("DATA_CHARSET", data_charset),
HA_TOPTION_NUMBER("LRECL", lrecl, 0, 0, INT_MAX32, 1), HA_TOPTION_NUMBER("LRECL", lrecl, 0, 0, INT_MAX32, 1),
HA_TOPTION_NUMBER("BLOCK_SIZE", elements, 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) ...@@ -1106,7 +1107,9 @@ PCSZ GetStringTableOption(PGLOBAL g, PTOS options, PCSZ opname, PCSZ sdef)
opval= options->srcdef; opval= options->srcdef;
else if (!stricmp(opname, "Colist")) else if (!stricmp(opname, "Colist"))
opval= options->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; opval= options->data_charset;
if (!opval && options->oplist) if (!opval && options->oplist)
......
...@@ -87,7 +87,7 @@ MGOFAM::MGOFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL) ...@@ -87,7 +87,7 @@ MGOFAM::MGOFAM(PJDEF tdp) : DOSFAM((PDOSDEF)NULL)
Db_name = tdp->Schema; Db_name = tdp->Schema;
Coll_name = tdp->Collname; Coll_name = tdp->Collname;
Options = tdp->Options; Options = tdp->Options;
Filter = NULL; Filter = tdp->Filter;
Done = false; Done = false;
Pipe = tdp->Pipe; Pipe = tdp->Pipe;
Lrecl = tdp->Lrecl + tdp->Ending; Lrecl = tdp->Lrecl + tdp->Ending;
...@@ -234,19 +234,6 @@ bool MGOFAM::Init(PGLOBAL g) ...@@ -234,19 +234,6 @@ bool MGOFAM::Init(PGLOBAL g)
if (Done) if (Done)
return false; 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); Uri = mongoc_uri_new(Uristr);
if (!Uri) { if (!Uri) {
...@@ -311,7 +298,7 @@ bool MGOFAM::MakeCursor(PGLOBAL g) ...@@ -311,7 +298,7 @@ bool MGOFAM::MakeCursor(PGLOBAL g)
for (cp = Tdbp->GetColumns(); cp; cp = cp->GetNext()) for (cp = Tdbp->GetColumns(); cp; cp = cp->GetNext())
if (!strcmp(cp->GetName(), "_id")) if (!strcmp(cp->GetName(), "_id"))
id = true; id = true;
else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*")) else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*") && !Options)
all = true; all = true;
if (Pipe) { if (Pipe) {
......
...@@ -47,6 +47,7 @@ struct ha_table_option_struct { ...@@ -47,6 +47,7 @@ struct ha_table_option_struct {
const char *catfunc; const char *catfunc;
const char *srcdef; const char *srcdef;
const char *colist; const char *colist;
const char *filter;
const char *oplist; const char *oplist;
const char *data_charset; const char *data_charset;
ulonglong lrecl; ulonglong lrecl;
......
...@@ -463,7 +463,7 @@ JSONDEF::JSONDEF(void) ...@@ -463,7 +463,7 @@ JSONDEF::JSONDEF(void)
Sep = '.'; Sep = '.';
#if defined(MONGO_SUPPORT) #if defined(MONGO_SUPPORT)
Uri = NULL; Uri = NULL;
Collname = Schema = Options = NULL; Collname = Schema = Options = Filter = NULL;
Pipe = false; Pipe = false;
#endif // MONGO_SUPPORT #endif // MONGO_SUPPORT
} // end of JSONDEF constructor } // end of JSONDEF constructor
...@@ -488,6 +488,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff) ...@@ -488,6 +488,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
Collname = GetStringCatInfo(g, "Tabname", Collname); Collname = GetStringCatInfo(g, "Tabname", Collname);
Schema = GetStringCatInfo(g, "Dbname", "test"); Schema = GetStringCatInfo(g, "Dbname", "test");
Options = GetStringCatInfo(g, "Colist", NULL); Options = GetStringCatInfo(g, "Colist", NULL);
Filter = GetStringCatInfo(g, "Filter", NULL);
Pipe = GetBoolCatInfo("Pipeline", false); Pipe = GetBoolCatInfo("Pipeline", false);
Pretty = 0; Pretty = 0;
#else // !MONGO_SUPPORT #else // !MONGO_SUPPORT
...@@ -1323,7 +1324,7 @@ char *JSONCOL::GetJpath(PGLOBAL g, bool proj) ...@@ -1323,7 +1324,7 @@ char *JSONCOL::GetJpath(PGLOBAL g, bool proj)
*p2++ = '.'; *p2++ = '.';
break; break;
case '[': case '[':
if (*p2 != '.') if (*(p2 - 1) != '.')
*p2++ = '.'; *p2++ = '.';
i = 1; i = 1;
......
...@@ -66,7 +66,8 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */ ...@@ -66,7 +66,8 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */
#if defined(MONGO_SUPPORT) #if defined(MONGO_SUPPORT)
PCSZ Collname; /* External collection name */ PCSZ Collname; /* External collection name */
PCSZ Schema; /* External schema (DB) 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 */ bool Pipe; /* True if Colist is a pipeline */
#endif // MONGO_SUPPORT #endif // MONGO_SUPPORT
}; // end of JSONDEF }; // end of JSONDEF
......
...@@ -170,18 +170,9 @@ int MGODISC::GetColumns(PGLOBAL g, char *db, PTOS topt) ...@@ -170,18 +170,9 @@ int MGODISC::GetColumns(PGLOBAL g, char *db, PTOS topt)
tdp->Tabschema = GetStringTableOption(g, topt, "Dbname", db); tdp->Tabschema = GetStringTableOption(g, topt, "Dbname", db);
tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0; tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
tdp->Colist = GetStringTableOption(g, topt, "Colist", "all"); tdp->Colist = GetStringTableOption(g, topt, "Colist", "all");
tdp->Filter = GetStringTableOption(g, topt, "Filter", NULL);
tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false); 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) if (trace)
htrc("Uri %s coll=%s db=%s colist=%s filter=%s lvl=%d\n", 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); tdp->Uri, tdp->Tabname, tdp->Tabschema, tdp->Colist, tdp->Filter, lvl);
...@@ -650,19 +641,6 @@ bool TDBMGO::Init(PGLOBAL g) ...@@ -650,19 +641,6 @@ bool TDBMGO::Init(PGLOBAL g)
G = 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); Uri = mongoc_uri_new(Uristr);
if (!Uri) { if (!Uri) {
...@@ -746,7 +724,7 @@ mongoc_cursor_t *TDBMGO::MakeCursor(PGLOBAL g) ...@@ -746,7 +724,7 @@ mongoc_cursor_t *TDBMGO::MakeCursor(PGLOBAL g)
for (cp = Columns; cp; cp = cp->GetNext()) for (cp = Columns; cp; cp = cp->GetNext())
if (!strcmp(cp->GetName(), "_id")) if (!strcmp(cp->GetName(), "_id"))
id = true; id = true;
else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*")) else if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*") && !Options)
all = true; all = true;
if (Pipe) { if (Pipe) {
......
...@@ -85,7 +85,7 @@ class DllExport MGODEF : public EXTDEF { /* Table description */ ...@@ -85,7 +85,7 @@ class DllExport MGODEF : public EXTDEF { /* Table description */
// Members // Members
PCSZ Uri; /* MongoDB connection URI */ PCSZ Uri; /* MongoDB connection URI */
PCSZ Colist; /* Options list */ PCSZ Colist; /* Options list */
char *Filter; /* Filtering query */ PCSZ Filter; /* Filtering query */
int Level; /* Used for catalog table */ int Level; /* Used for catalog table */
int Base; /* The array index base */ int Base; /* The array index base */
bool Pipe; /* True is Colist is a pipeline */ bool Pipe; /* True is Colist is a pipeline */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment