1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

- 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
This commit is contained in:
Olivier Bertrand
2013-03-29 01:28:48 +01:00
parent 0de0a46f02
commit dd8c89b2f4
3 changed files with 47 additions and 26 deletions

View File

@@ -3288,10 +3288,10 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to)
if (IsFileType(GetTypeID(pos->type)) && !pos->filename) { if (IsFileType(GetTypeID(pos->type)) && !pos->filename) {
// This is a table whose files must be erased or renamed */ // This is a table whose files must be erased or renamed */
char ftype[8], *new_exts[2]; // char ftype[8], *new_exts[2];
#if 0 // This does not work with sepindex and causes a DBUG_ASSERT failure
char ftype[8], *xtype, *new_exts[3]; char ftype[8], *xtype, *new_exts[3];
if (share->keynames.count) {
switch (GetTypeID(pos->type)) { switch (GetTypeID(pos->type)) {
case TAB_CSV: case TAB_CSV:
case TAB_FMT: case TAB_FMT:
@@ -3302,14 +3302,15 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to)
case TAB_DBF: xtype= ".dbx"; break; case TAB_DBF: xtype= ".dbx"; break;
default: default:
xtype= NULL; xtype= NULL;
return true; // return true;
} // endswitch Ftype } // endswitch Ftype
if (xtype) if (xtype)
new_exts[i++]= xtype; new_exts[i++]= xtype;
#endif // 0
strcat(strcpy(ftype, "."), pos->type);
} // endif keynames
strcat(strcpy(ftype, "."), pos->type);
new_exts[i++]= ftype; new_exts[i++]= ftype;
new_exts[i]= NULL; new_exts[i]= NULL;
@@ -4039,7 +4040,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (IsFileType(type)) { if (IsFileType(type)) {
table= table_arg; // Used by called functions 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 file name is not specified, create a default file in
// the database directory named table_name.table_type. // the database directory named table_name.table_type.
// (temporarily not done for XML because a void file causes // (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()); strcpy(buf, GetTableName());
if (*buf != '#') { 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); strcat(strcat(buf, "."), options->type);
sprintf(g->Message, "No file name. Table will use %s", buf); sprintf(g->Message, "No file name. Table will use %s", buf);
push_warning(table->in_use, push_warning(table->in_use,

View File

@@ -452,7 +452,7 @@ int TDBDOS::ResetTableOpt(PGLOBAL g, bool dox)
int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
{ {
int k, n; int k, n;
bool fixed, doit, b = (pxdf != NULL); bool fixed, doit, sep, b = (pxdf != NULL);
PCOL *keycols, colp; PCOL *keycols, colp;
PIXDEF xdp, sxp = NULL; PIXDEF xdp, sxp = NULL;
PKPDEF kdp; PKPDEF kdp;
@@ -506,6 +506,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
} // endfor kdp } // endfor kdp
keycols = (PCOL*)PlugSubAlloc(g, NULL, n * sizeof(PCOL)); keycols = (PCOL*)PlugSubAlloc(g, NULL, n * sizeof(PCOL));
sep = cat->GetBoolCatInfo("SepIndex", false);
/*********************************************************************/ /*********************************************************************/
/* Construct and save the defined indexes. */ /* Construct and save the defined indexes. */
@@ -533,7 +534,8 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
} // endfor kdp } // endfor kdp
// If no indexed columns were updated, don't remake the index // If no indexed columns were updated, don't remake the index
if (!doit) // if indexes are in separate files.
if (!doit && sep)
continue; continue;
k = xdp->GetNparts(); k = xdp->GetNparts();

View File

@@ -391,8 +391,12 @@ int TDBXML::LoadTableFile(PGLOBAL g)
// Does the file exist? // Does the file exist?
int h= global_open(g, MSGID_NONE, filename, _O_RDONLY); int h= global_open(g, MSGID_NONE, filename, _O_RDONLY);
rc = (h == -1 && errno == ENOENT) ? RC_NF : RC_INFO; if (h != -1) {
if (h != -1) close(h); rc = (!_filelength(h)) ? RC_EF : RC_INFO;
close(h);
} else
rc = (errno == ENOENT) ? RC_NF : RC_INFO;
return rc; return rc;
} // endif Docp } // endif Docp
@@ -487,8 +491,8 @@ bool TDBXML::Initialize(PGLOBAL g)
} else } else
TabNode = Root; // Try this ? TabNode = Root; // Try this ?
} else if (rc == RC_NF) { } else if (rc == RC_NF || rc == RC_EF) {
// The XML file does not exist // The XML file does not exist or is void
if (Mode == MODE_INSERT) { if (Mode == MODE_INSERT) {
// New Document // New Document
char buf[64]; char buf[64];