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)
int VCTFAM::GetBlockInfo(PGLOBAL g)
{
char filename[_MAX_PATH];
int k, n;
int h, k, n;
VECHEADER vh;
FILE *s;
if (Header < 1 || Header > 3 || !MaxBlk) {
sprintf(g->Message, "Invalid header value %d", Header);
......@@ -168,15 +167,20 @@ int VCTFAM::GetBlockInfo(PGLOBAL g)
if (Header == 2)
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
Last = Nrec;
Block = 0;
if (h != -1)
close(h);
return n;
} 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);
n = -1;
} else if (MaxBlk * Nrec != vh.MaxRec) {
......@@ -188,7 +192,7 @@ int VCTFAM::GetBlockInfo(PGLOBAL g)
Last = (vh.NumRec + Nrec - 1) % Nrec + 1;
} // endif s
fclose(s);
close(h);
return n;
} // end of GetBlockInfo
......
......@@ -652,7 +652,7 @@ char *ha_connect::GetListOption(const char *opname,
{
char key[16], val[256];
char *pk, *pv, *pn;
char *opval= (char *) def;
char *opval= (char*) def;
int n;
for (pk= (char*)oplist; pk; pk= ++pn) {
......@@ -3960,6 +3960,48 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} else
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
for (field= table_arg->field; *field; field++) {
fp= *field;
......@@ -4052,15 +4094,20 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (*buf != '#') {
// Check for incompatible options
if (GetTypeID(options->type) == TAB_VEC &&
(!table->s->max_rows || options->split)) {
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);
} 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->sepindex) {
} else if (options->header == 2) {
my_printf_error(ER_UNKNOWN_ERROR,
"SEPINDEX is incompatible with unspecified file name",
"header=2 is not allowed for %s tables whose file name is unspecified",
MYF(0), options->type);
DBUG_RETURN(HA_ERR_UNSUPPORTED);
} // endif's
......@@ -4072,13 +4119,21 @@ int ha_connect::create(const char *name, TABLE *table_arg,
strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/");
PlugSetPath(fn, buf, dbpath);
if ((h= ::open(fn, O_CREAT, 0666)) == -1) {
sprintf(g->Message, "Cannot create file %s", fn);
if ((h= ::open(fn, O_CREAT | O_EXCL, 0666)) == -1) {
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,
MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
} else
::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
} else {
......@@ -4110,6 +4165,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if ((rc= optimize(NULL, NULL))) {
printf("Create rc=%d %s\n", rc, g->Message);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR;
} else
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