summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--storage/connect/connect.cc3
-rw-r--r--storage/connect/ha_connect.cc27
-rw-r--r--storage/connect/ha_connect.h2
-rw-r--r--storage/connect/plgdbutl.cpp5
-rw-r--r--storage/connect/reldef.cpp11
-rw-r--r--storage/connect/tabjson.cpp6
-rw-r--r--storage/connect/tabmul.cpp65
-rw-r--r--storage/connect/tabmul.h6
-rw-r--r--storage/connect/tabxml.cpp7
9 files changed, 82 insertions, 50 deletions
diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc
index 9ec93bfe1ba..5d5eca80275 100644
--- a/storage/connect/connect.cc
+++ b/storage/connect/connect.cc
@@ -117,7 +117,8 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
handler);
// Set the database path for this table
- handler->SetDataPath(g, pathname);
+ if (handler->SetDataPath(g, pathname))
+ return true;
if (dbuserp->Catalog) {
// ((MYCAT *)dbuserp->Catalog)->SetHandler(handler); done later
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 2cd581c5c64..9f0b62c73b3 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -1739,9 +1739,9 @@ void ha_connect::AddColName(char *cp, Field *fp)
/***********************************************************************/
/* This function sets the current database path. */
/***********************************************************************/
-void ha_connect::SetDataPath(PGLOBAL g, const char *path)
+bool ha_connect::SetDataPath(PGLOBAL g, const char *path)
{
- datapath= SetPath(g, path);
+ return (!(datapath = SetPath(g, path)));
} // end of SetDataPath
/****************************************************************************/
@@ -2721,6 +2721,8 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
if (x)
return NULL;
+ else
+ pb0 = pb1 = pb2 = ph0 = ph1 = ph2 = NULL;
if (trace)
htrc("Cond: Ftype=%d name=%s\n", cond_item->functype(),
@@ -4110,10 +4112,14 @@ int ha_connect::info(uint flag)
} // endif xmod
// This is necessary for getting file length
- if (table)
- SetDataPath(g, table->s->db.str);
- else
- DBUG_RETURN(HA_ERR_INTERNAL_ERROR); // Should never happen
+ if (table) {
+ if (SetDataPath(g, table->s->db.str)) {
+ my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
+ DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
+ } // endif SetDataPath
+
+ } else
+ DBUG_RETURN(HA_ERR_INTERNAL_ERROR); // Should never happen
if (!(tdbp= GetTDB(g)))
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); // Should never happen
@@ -6563,9 +6569,10 @@ int ha_connect::create(const char *name, TABLE *table_arg,
PDBUSER dup= PlgGetUser(g);
PCATLG cat= (dup) ? dup->Catalog : NULL;
- SetDataPath(g, table_arg->s->db.str);
-
- if (cat) {
+ if (SetDataPath(g, table_arg->s->db.str)) {
+ my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
+ rc = HA_ERR_INTERNAL_ERROR;
+ } else if (cat) {
// cat->SetDataPath(g, table_arg->s->db.str);
#if defined(WITH_PARTITION_STORAGE_ENGINE)
@@ -7137,6 +7144,6 @@ maria_declare_plugin(connect)
NULL, /* status variables */
connect_system_variables, /* system variables */
"1.05.0003", /* string version */
- MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */
+ MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
}
maria_declare_plugin_end;
diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h
index 3d9ff967618..155bec3c966 100644
--- a/storage/connect/ha_connect.h
+++ b/storage/connect/ha_connect.h
@@ -199,7 +199,7 @@ public:
bool IsUnique(uint n);
char *GetDataPath(void) {return (char*)datapath;}
- void SetDataPath(PGLOBAL g, const char *path);
+ bool SetDataPath(PGLOBAL g, const char *path);
PTDB GetTDB(PGLOBAL g);
int OpenTable(PGLOBAL g, bool del= false);
bool CheckColumnList(PGLOBAL g);
diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp
index 299332f51b4..eef9fba44f5 100644
--- a/storage/connect/plgdbutl.cpp
+++ b/storage/connect/plgdbutl.cpp
@@ -412,8 +412,9 @@ char *SetPath(PGLOBAL g, const char *path)
if (path) {
size_t len= strlen(path) + (*path != '.' ? 4 : 1);
- buf= (char*)PlugSubAlloc(g, NULL, len);
-
+ if (!(buf = (char*)PlgDBSubAlloc(g, NULL, len)))
+ return NULL;
+
if (PlugIsAbsolutePath(path)) {
strcpy(buf, path);
return buf;
diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp
index 5bb7848ab1c..c0f3074769a 100644
--- a/storage/connect/reldef.cpp
+++ b/storage/connect/reldef.cpp
@@ -1,11 +1,11 @@
/************* RelDef CPP Program Source Code File (.CPP) **************/
/* PROGRAM NAME: RELDEF */
/* ------------- */
-/* Version 1.6 */
+/* Version 1.7 */
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2004-2016 */
+/* (C) Copyright to the author Olivier BERTRAND 2004-2017 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -277,8 +277,13 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
// Take care of the column definitions
i= poff= nof= nlg= 0;
+#if defined(__WIN__)
// Offsets of HTML and DIR tables start from 0, DBF at 1
- loff= (tc == TAB_DBF) ? 1 : (tc == TAB_XML || tc == TAB_DIR) ? -1 : 0;
+ loff = (tc == TAB_DBF) ? 1 : (tc == TAB_XML || tc == TAB_DIR) ? -1 : 0;
+#else // !__WIN__
+ // Offsets of HTML tables start from 0, DIR and DBF at 1
+ loff = (tc == TAB_DBF || tc == TAB_DIR) ? 1 : (tc == TAB_XML) ? -1 : 0;
+#endif // !__WIN__
while (true) {
// Default Offset depends on table type
diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp
index f451c73b665..e074232600b 100644
--- a/storage/connect/tabjson.cpp
+++ b/storage/connect/tabjson.cpp
@@ -117,8 +117,10 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
return NULL;
} // endif Fn
- tdp->Database = SetPath(g, db);
- tdp->Objname = GetStringTableOption(g, topt, "Object", NULL);
+ if (!(tdp->Database = SetPath(g, db)))
+ return NULL;
+
+ tdp->Objname = GetStringTableOption(g, topt, "Object", NULL);
tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2);
diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp
index 4128fea6afc..b5f07db8413 100644
--- a/storage/connect/tabmul.cpp
+++ b/storage/connect/tabmul.cpp
@@ -603,9 +603,10 @@ bool TDBMSD::InitFileNames(PGLOBAL g)
bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR, int)
{
Desc = Fn = GetStringCatInfo(g, "Filename", NULL);
- Incl = (GetIntCatInfo("Subdir", 0) != 0);
- Huge = (GetIntCatInfo("Huge", 0) != 0);
- return false;
+ Incl = GetBoolCatInfo("Subdir", false);
+ Huge = GetBoolCatInfo("Huge", false);
+ Nodir = GetBoolCatInfo("Nodir", true);
+ return false;
} // end of DefineAM
/***********************************************************************/
@@ -654,12 +655,14 @@ void TDBDIR::Init(void)
TDBDIR::TDBDIR(PDIRDEF tdp) : TDBASE(tdp)
{
To_File = tdp->Fn;
+ Nodir = tdp->Nodir;
Init();
} // end of TDBDIR standard constructor
TDBDIR::TDBDIR(PSZ fpat) : TDBASE((PTABDEF)NULL)
{
To_File = fpat;
+ Nodir = true;
Init();
} // end of TDBDIR constructor
@@ -812,27 +815,32 @@ int TDBDIR::ReadDB(PGLOBAL g)
int rc = RC_OK;
#if defined(__WIN__)
- if (hSearch == INVALID_HANDLE_VALUE) {
- /*******************************************************************/
- /* Start searching files in the target directory. The use of the */
- /* Path function is required when called from TDBSDR. */
- /*******************************************************************/
- hSearch = FindFirstFile(Path(g), &FileData);
+ do {
+ if (hSearch == INVALID_HANDLE_VALUE) {
+ /*****************************************************************/
+ /* Start searching files in the target directory. The use of */
+ /* the Path function is required when called from TDBSDR. */
+ /*****************************************************************/
+ hSearch = FindFirstFile(Path(g), &FileData);
+
+ if (hSearch == INVALID_HANDLE_VALUE) {
+ rc = RC_EF;
+ break;
+ } else
+ iFile++;
- if (hSearch == INVALID_HANDLE_VALUE)
- rc = RC_EF;
- else
- iFile++;
+ } else {
+ if (!FindNextFile(hSearch, &FileData)) {
+ // Restore file name and type pattern
+ _splitpath(To_File, NULL, NULL, Fname, Ftype);
+ rc = RC_EF;
+ break;
+ } else
+ iFile++;
- } else {
- if (!FindNextFile(hSearch, &FileData)) {
- // Restore file name and type pattern
- _splitpath(To_File, NULL, NULL, Fname, Ftype);
- rc = RC_EF;
- } else
- iFile++;
+ } // endif hSearch
- } // endif hSearch
+ } while (Nodir && FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
if (rc == RC_OK)
_splitpath(FileData.cFileName, NULL, NULL, Fname, Ftype);
@@ -1229,8 +1237,9 @@ int TDBSDR::ReadDB(PGLOBAL g)
retry:
do {
if (Sub->H == INVALID_HANDLE_VALUE) {
- _makepath(Fpath, Drive, Direc, "*", ".");
- Sub->H = FindFirstFile(Fpath, &FileData);
+// _makepath(Fpath, Drive, Direc, "*", "."); why was this made?
+ _makepath(Fpath, Drive, Direc, "*", NULL);
+ Sub->H = FindFirstFile(Fpath, &FileData);
} else if (!FindNextFile(Sub->H, &FileData)) {
FindClose(Sub->H);
Sub->H = INVALID_HANDLE_VALUE;
@@ -1238,8 +1247,9 @@ int TDBSDR::ReadDB(PGLOBAL g)
break;
} // endif findnext
- } while(!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- || *FileData.cFileName== '.');
+ } while (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
+ (*FileData.cFileName == '.' &&
+ (!FileData.cFileName[1] || FileData.cFileName[1] == '.')));
if (Sub->H == INVALID_HANDLE_VALUE) {
// No more sub-directories. Are we in a sub-directory?
@@ -1293,8 +1303,9 @@ int TDBSDR::ReadDB(PGLOBAL g)
if (lstat(Fpath, &Fileinfo) < 0) {
sprintf(g->Message, "%s: %s", Fpath, strerror(errno));
rc = RC_FX;
- } else if (S_ISDIR(Fileinfo.st_mode) && *Entry->d_name != '.') {
- // Look in the name sub-directory
+ } else if (S_ISDIR(Fileinfo.st_mode) && strcmp(Entry->d_name, ".")
+ && strcmp(Entry->d_name, "..")) {
+ // Look in the name sub-directory
if (!Sub->Next) {
PSUBDIR sup;
diff --git a/storage/connect/tabmul.h b/storage/connect/tabmul.h
index 3c0ab1a4aa5..f26d982d49b 100644
--- a/storage/connect/tabmul.h
+++ b/storage/connect/tabmul.h
@@ -119,7 +119,8 @@ class DllExport DIRDEF : public TABDEF { /* Directory listing table */
PSZ Fn; /* Path/Name of file search */
bool Incl; /* true to include sub-directories */
bool Huge; /* true if files can be larger than 2GB */
- }; // end of DIRDEF
+ bool Nodir; /* true to exclude directories */
+}; // end of DIRDEF
/***********************************************************************/
/* This is the DIR Access Method class declaration for tables that */
@@ -175,7 +176,8 @@ public:
char Direc[_MAX_DIR]; // Search path
char Fname[_MAX_FNAME]; // File name
char Ftype[_MAX_EXT]; // File extention
- }; // end of class TDBDIR
+ bool Nodir; // Exclude directories from file list
+}; // end of class TDBDIR
/***********************************************************************/
/* This is the DIR Access Method class declaration for tables that */
diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp
index a895ffbd839..386d016d082 100644
--- a/storage/connect/tabxml.cpp
+++ b/storage/connect/tabxml.cpp
@@ -157,8 +157,11 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
tdp = new(g) XMLDEF;
tdp->Fn = fn;
- tdp->Database = SetPath(g, db);
- tdp->Tabname = tab;
+
+ if (!(tdp->Database = SetPath(g, db)))
+ return NULL;
+
+ tdp->Tabname = tab;
tdp->Zipped = GetBooleanTableOption(g, topt, "Zipped", false);
tdp->Entry = GetStringTableOption(g, topt, "Entry", NULL);