Commit eab8fcfa authored by Olivier Bertrand's avatar Olivier Bertrand

- Set file name when unspecified as tablename.tabletype.

modified:
  storage/connect/ha_connect.cc
  storage/connect/mycat.cc
  storage/connect/mycat.h
parent bc9c8724
...@@ -1111,10 +1111,12 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) ...@@ -1111,10 +1111,12 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf)
// Field_length is only used for DATE columns // Field_length is only used for DATE columns
if (fop->fldlen) if (fop->fldlen)
pcf->Length= fop->fldlen; pcf->Length= fop->fldlen;
else if (pcf->Datefmt) { else {
int len;
if (pcf->Datefmt) {
// Find the (max) length produced by the date format // Find the (max) length produced by the date format
char buf[256]; char buf[256];
int len;
PGLOBAL g= GetPlug(table->in_use); PGLOBAL g= GetPlug(table->in_use);
#if defined(WIN32) #if defined(WIN32)
struct tm datm= {0,0,0,12,11,112,0,0,0}; struct tm datm= {0,0,0,12,11,112,0,0,0};
...@@ -1123,10 +1125,13 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf) ...@@ -1123,10 +1125,13 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf)
#endif // !WIN32 #endif // !WIN32
PDTP pdtp= MakeDateFormat(g, pcf->Datefmt, false, true, 0); PDTP pdtp= MakeDateFormat(g, pcf->Datefmt, false, true, 0);
if ((len= strftime(buf, 256, pdtp->OutFmt, &datm))) len= strftime(buf, 256, pdtp->OutFmt, &datm);
pcf->Length= len; } else
len= 0;
} // endif Datefmt // 11 is for signed numeric representation of the date
pcf->Length= (len) ? len : 11;
} // endelse
break; break;
case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_LONGLONG:
...@@ -3521,6 +3526,19 @@ bool ha_connect::pre_create(THD *thd, HA_CREATE_INFO *create_info, ...@@ -3521,6 +3526,19 @@ bool ha_connect::pre_create(THD *thd, HA_CREATE_INFO *create_info,
ok= false; ok= false;
} // endif supfnc } // endif supfnc
// If file name is not specified, set a default file name
// in the database directory from alias.type.
if (IsFileType(ttp) && !fn) {
char buf[256];
strcat(strcat(strcpy(buf, (char*)create_info->alias), "."), typn);
name= thd->make_lex_string(NULL, "file_name", 9, true);
val= thd->make_lex_string(NULL, buf, strlen(buf), true);
pov= new(mem) engine_option_value(*name, *val, false, &start, &end);
sprintf(g->Message, "Unspecified file name was set to %s", buf);
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
} // endif ttp && fn
// Test whether columns must be specified // Test whether columns must be specified
if (alter_info->create_list.elements) if (alter_info->create_list.elements)
return false; return false;
......
...@@ -123,6 +123,32 @@ TABTYPE GetTypeID(const char *type) ...@@ -123,6 +123,32 @@ TABTYPE GetTypeID(const char *type)
: (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY; : (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY;
} // end of GetTypeID } // end of GetTypeID
/***********************************************************************/
/* Return true for table types based on file. */
/***********************************************************************/
bool IsFileType(TABTYPE type)
{
bool isfile;
switch (type) {
case TAB_DOS:
case TAB_FIX:
case TAB_BIN:
case TAB_CSV:
case TAB_FMT:
case TAB_DBF:
case TAB_XML:
case TAB_VEC:
isfile= true;
break;
default:
isfile= false;
break;
} // endswitch type
return isfile;
} // end of IsFileType
/***********************************************************************/ /***********************************************************************/
/* Get a unique enum catalog function ID. */ /* Get a unique enum catalog function ID. */
/***********************************************************************/ /***********************************************************************/
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
typedef class ha_connect *PHC; typedef class ha_connect *PHC;
TABTYPE GetTypeID(const char *type); TABTYPE GetTypeID(const char *type);
bool IsFileType(TABTYPE type);
uint GetFuncID(const char *func); uint GetFuncID(const char *func);
/***********************************************************************/ /***********************************************************************/
......
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