From dd8c89b2f44408e9e7c74ee990d88e8d9cd375de Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Fri, 29 Mar 2013 01:28:48 +0100 Subject: [PATCH] - Fix problems related to table file names when not specified: Split unspecified VEC tables are no more allowed. Empty XML files are now accepted. Separate index files are now depending upon the SEPINDEX option and not allowed when file name is not specified. DROP now can erase table and index file. modified: storage/connect/ha_connect.cc storage/connect/tabdos.cpp storage/connect/tabxml.cpp --- storage/connect/ha_connect.cc | 53 ++++++++++++++++++++++------------- storage/connect/tabdos.cpp | 6 ++-- storage/connect/tabxml.cpp | 14 +++++---- 3 files changed, 47 insertions(+), 26 deletions(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 6b9f87ffe87..ef3bd5761b6 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3288,28 +3288,29 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to) if (IsFileType(GetTypeID(pos->type)) && !pos->filename) { // This is a table whose files must be erased or renamed */ - char ftype[8], *new_exts[2]; -#if 0 // This does not work with sepindex and causes a DBUG_ASSERT failure +// char ftype[8], *new_exts[2]; char ftype[8], *xtype, *new_exts[3]; - switch (GetTypeID(pos->type)) { - case TAB_CSV: - case TAB_FMT: - case TAB_DOS: xtype= ".dnx"; break; - case TAB_FIX: xtype= ".fnx"; break; - case TAB_BIN: xtype= ".bnx"; break; - case TAB_VEC: xtype= ".vnx"; break; - case TAB_DBF: xtype= ".dbx"; break; - default: - xtype= NULL; - return true; - } // endswitch Ftype + if (share->keynames.count) { + switch (GetTypeID(pos->type)) { + case TAB_CSV: + case TAB_FMT: + case TAB_DOS: xtype= ".dnx"; break; + case TAB_FIX: xtype= ".fnx"; break; + case TAB_BIN: xtype= ".bnx"; break; + case TAB_VEC: xtype= ".vnx"; break; + case TAB_DBF: xtype= ".dbx"; break; + default: + xtype= NULL; +// return true; + } // endswitch Ftype + + if (xtype) + new_exts[i++]= xtype; + + } // endif keynames - if (xtype) - new_exts[i++]= xtype; -#endif // 0 strcat(strcpy(ftype, "."), pos->type); - new_exts[i++]= ftype; new_exts[i]= NULL; @@ -4039,7 +4040,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, if (IsFileType(type)) { table= table_arg; // Used by called functions - if (!options->filename && type != TAB_XML) { + if (!options->filename) { // The file name is not specified, create a default file in // the database directory named table_name.table_type. // (temporarily not done for XML because a void file causes @@ -4050,6 +4051,20 @@ int ha_connect::create(const char *name, TABLE *table_arg, strcpy(buf, GetTableName()); if (*buf != '#') { + // Check for incompatible options + if (GetTypeID(options->type) == TAB_VEC && + (!table->s->max_rows || options->split)) { + my_printf_error(ER_UNKNOWN_ERROR, + "%s tables whose file name is unspecified cannot be split", + MYF(0), options->type); + DBUG_RETURN(HA_ERR_UNSUPPORTED); + } else if (options->sepindex) { + my_printf_error(ER_UNKNOWN_ERROR, + "SEPINDEX is incompatible with unspecified file name", + MYF(0), options->type); + DBUG_RETURN(HA_ERR_UNSUPPORTED); + } // endif's + strcat(strcat(buf, "."), options->type); sprintf(g->Message, "No file name. Table will use %s", buf); push_warning(table->in_use, diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index a566aceeae7..dee4a9025c2 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -452,7 +452,7 @@ int TDBDOS::ResetTableOpt(PGLOBAL g, bool dox) int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) { int k, n; - bool fixed, doit, b = (pxdf != NULL); + bool fixed, doit, sep, b = (pxdf != NULL); PCOL *keycols, colp; PIXDEF xdp, sxp = NULL; PKPDEF kdp; @@ -506,6 +506,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) } // endfor kdp keycols = (PCOL*)PlugSubAlloc(g, NULL, n * sizeof(PCOL)); + sep = cat->GetBoolCatInfo("SepIndex", false); /*********************************************************************/ /* Construct and save the defined indexes. */ @@ -533,7 +534,8 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) } // endfor kdp // If no indexed columns were updated, don't remake the index - if (!doit) + // if indexes are in separate files. + if (!doit && sep) continue; k = xdp->GetNparts(); diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index cb593d39857..9b8db7abbab 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -383,7 +383,7 @@ int TDBXML::LoadTableFile(PGLOBAL g) return RC_FX; } // endif init - if (trace) + if (trace) htrc("TDBXML: parsing %s rc=%d\n", filename, rc); // Parse the XML file @@ -391,8 +391,12 @@ int TDBXML::LoadTableFile(PGLOBAL g) // Does the file exist? int h= global_open(g, MSGID_NONE, filename, _O_RDONLY); - rc = (h == -1 && errno == ENOENT) ? RC_NF : RC_INFO; - if (h != -1) close(h); + if (h != -1) { + rc = (!_filelength(h)) ? RC_EF : RC_INFO; + close(h); + } else + rc = (errno == ENOENT) ? RC_NF : RC_INFO; + return rc; } // endif Docp @@ -487,8 +491,8 @@ bool TDBXML::Initialize(PGLOBAL g) } else TabNode = Root; // Try this ? - } else if (rc == RC_NF) { - // The XML file does not exist + } else if (rc == RC_NF || rc == RC_EF) { + // The XML file does not exist or is void if (Mode == MODE_INSERT) { // New Document char buf[64];