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,22 +1111,27 @@ void *ha_connect::GetColumnOption(void *field, PCOLINFO pcf)
// Field_length is only used for DATE columns
if (fop->fldlen)
pcf->Length= fop->fldlen;
else if (pcf->Datefmt) {
// Find the (max) length produced by the date format
char buf[256];
int len;
PGLOBAL g= GetPlug(table->in_use);
else {
int len;
if (pcf->Datefmt) {
// Find the (max) length produced by the date format
char buf[256];
PGLOBAL g= GetPlug(table->in_use);
#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};
#else // !WIN32
struct tm datm= {0,0,0,12,11,112,0,0,0,0,0};
struct tm datm= {0,0,0,12,11,112,0,0,0,0,0};
#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)))
pcf->Length= len;
len= strftime(buf, 256, pdtp->OutFmt, &datm);
} else
len= 0;
} // endif Datefmt
// 11 is for signed numeric representation of the date
pcf->Length= (len) ? len : 11;
} // endelse
break;
case MYSQL_TYPE_LONGLONG:
......@@ -3521,6 +3526,19 @@ bool ha_connect::pre_create(THD *thd, HA_CREATE_INFO *create_info,
ok= false;
} // 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
if (alter_info->create_list.elements)
return false;
......
......@@ -123,6 +123,32 @@ TABTYPE GetTypeID(const char *type)
: (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY;
} // 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. */
/***********************************************************************/
......
......@@ -35,6 +35,7 @@
typedef class ha_connect *PHC;
TABTYPE GetTypeID(const char *type);
bool IsFileType(TABTYPE type);
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