Commit 879be566 authored by Olivier Bertrand's avatar Olivier Bertrand

- Add some warnings to Create Table process

modified:
  storage/connect/filamvct.cpp
  storage/connect/ha_connect.cc
parent 98e551d0
...@@ -153,9 +153,8 @@ void VCTFAM::Reset(void) ...@@ -153,9 +153,8 @@ void VCTFAM::Reset(void)
int VCTFAM::GetBlockInfo(PGLOBAL g) int VCTFAM::GetBlockInfo(PGLOBAL g)
{ {
char filename[_MAX_PATH]; char filename[_MAX_PATH];
int k, n; int h, k, n;
VECHEADER vh; VECHEADER vh;
FILE *s;
if (Header < 1 || Header > 3 || !MaxBlk) { if (Header < 1 || Header > 3 || !MaxBlk) {
sprintf(g->Message, "Invalid header value %d", Header); sprintf(g->Message, "Invalid header value %d", Header);
...@@ -168,15 +167,20 @@ int VCTFAM::GetBlockInfo(PGLOBAL g) ...@@ -168,15 +167,20 @@ int VCTFAM::GetBlockInfo(PGLOBAL g)
if (Header == 2) if (Header == 2)
strcat(PlugRemoveType(filename, filename), ".blk"); strcat(PlugRemoveType(filename, filename), ".blk");
if (!(s= global_fopen(g, MSGID_CANNOT_OPEN, filename, "rb"))) { if ((h = global_open(g, MSGID_CANNOT_OPEN, filename, O_RDONLY)) == -1
|| !_filelength(h)) {
// Consider this is a void table // Consider this is a void table
Last = Nrec; Last = Nrec;
Block = 0; Block = 0;
if (h != -1)
close(h);
return n; return n;
} else if (Header == 3) } else if (Header == 3)
k = fseek(s, -(int)sizeof(VECHEADER), SEEK_END); k = lseek(h, -(int)sizeof(VECHEADER), SEEK_END);
if (fread(&vh, sizeof(vh), 1, s) != 1) { if ((k = read(h, &vh, sizeof(vh))) != sizeof(vh)) {
sprintf(g->Message, "Error reading header file %s", filename); sprintf(g->Message, "Error reading header file %s", filename);
n = -1; n = -1;
} else if (MaxBlk * Nrec != vh.MaxRec) { } else if (MaxBlk * Nrec != vh.MaxRec) {
...@@ -188,7 +192,7 @@ int VCTFAM::GetBlockInfo(PGLOBAL g) ...@@ -188,7 +192,7 @@ int VCTFAM::GetBlockInfo(PGLOBAL g)
Last = (vh.NumRec + Nrec - 1) % Nrec + 1; Last = (vh.NumRec + Nrec - 1) % Nrec + 1;
} // endif s } // endif s
fclose(s); close(h);
return n; return n;
} // end of GetBlockInfo } // end of GetBlockInfo
......
...@@ -650,10 +650,10 @@ char *ha_connect::GetListOption(const char *opname, ...@@ -650,10 +650,10 @@ char *ha_connect::GetListOption(const char *opname,
const char *oplist, const char *oplist,
const char *def) const char *def)
{ {
char key[16], val[256]; char key[16], val[256];
char *pk, *pv, *pn; char *pk, *pv, *pn;
char *opval= (char *) def; char *opval= (char*) def;
int n; int n;
for (pk= (char*)oplist; pk; pk= ++pn) { for (pk= (char*)oplist; pk; pk= ++pn) {
pn= strchr(pk, ','); pn= strchr(pk, ',');
...@@ -3960,6 +3960,48 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3960,6 +3960,48 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} else } else
dbf= (GetTypeID(options->type) == TAB_DBF); dbf= (GetTypeID(options->type) == TAB_DBF);
if (type == TAB_XML) {
bool dom; // True: MS-DOM, False libxml2
char *xsup= GetListOption("Xmlsup", options->oplist, "*");
// Note that if no support is specified, the default is MS-DOM
// on Windows and libxml2 otherwise
switch (*xsup) {
case '*':
#if defined(WIN32)
dom= true;
#else // !WIN32
dom= false;
#endif // !WIN32
break;
case 'M':
case 'D':
dom= true;
break;
default:
dom= false;
} // endswitch xsup
#if !defined(DOMDOC_SUPPORT)
if (dom) {
strcpy(g->Message, "MS-DOM not supported by this version");
xsup= NULL;
} // endif DomDoc
#endif // !DOMDOC_SUPPORT
#if !defined(LIBXML2_SUPPORT)
if (!dom) {
strcpy(g->Message, "libxml2 not supported by this version");
xsup= NULL;
} // endif Libxml2
#endif // !LIBXML2_SUPPORT
if (!xsup)
push_warning(table->in_use,
MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
} // endif type
// Check column types // Check column types
for (field= table_arg->field; *field; field++) { for (field= table_arg->field; *field; field++) {
fp= *field; fp= *field;
...@@ -4052,18 +4094,23 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -4052,18 +4094,23 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (*buf != '#') { if (*buf != '#') {
// Check for incompatible options // Check for incompatible options
if (GetTypeID(options->type) == TAB_VEC && if (options->sepindex) {
(!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, my_printf_error(ER_UNKNOWN_ERROR,
"SEPINDEX is incompatible with unspecified file name", "SEPINDEX is incompatible with unspecified file name",
MYF(0), options->type); MYF(0), options->type);
DBUG_RETURN(HA_ERR_UNSUPPORTED); DBUG_RETURN(HA_ERR_UNSUPPORTED);
} // endif's } else if (GetTypeID(options->type) == TAB_VEC)
if (!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->header == 2) {
my_printf_error(ER_UNKNOWN_ERROR,
"header=2 is not allowed for %s tables whose file name is unspecified",
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);
...@@ -4072,13 +4119,21 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -4072,13 +4119,21 @@ int ha_connect::create(const char *name, TABLE *table_arg,
strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/"); strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/");
PlugSetPath(fn, buf, dbpath); PlugSetPath(fn, buf, dbpath);
if ((h= ::open(fn, O_CREAT, 0666)) == -1) { if ((h= ::open(fn, O_CREAT | O_EXCL, 0666)) == -1) {
sprintf(g->Message, "Cannot create file %s", fn); if (errno == EEXIST)
sprintf(g->Message, "Default file %s already exists", fn);
else
sprintf(g->Message, "Error %d creating file %s", errno, fn);
push_warning(table->in_use, push_warning(table->in_use,
MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
} else } else
::close(h); ::close(h);
if (type == TAB_FMT || options->readonly)
push_warning(table->in_use, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
"Congratulation, you just created a read-only void table!");
} // endif buf } // endif buf
} else { } else {
...@@ -4110,6 +4165,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -4110,6 +4165,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if ((rc= optimize(NULL, NULL))) { if ((rc= optimize(NULL, NULL))) {
printf("Create rc=%d %s\n", rc, g->Message); printf("Create rc=%d %s\n", rc, g->Message);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
} else } else
CloseTable(g); CloseTable(g);
......
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