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[]=
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)
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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;
......
......@@ -66,7 +66,8 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */
#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
......
......@@ -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);
......@@ -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) {
......
......@@ -85,7 +85,7 @@ class DllExport MGODEF : public EXTDEF { /* Table description */
// 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 */
......
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