Commit 5008a3e8 authored by Olivier Bertrand's avatar Olivier Bertrand

- Add in create a check for nullable columns not supported by some table types.

modified:
  storage/connect/ha_connect.cc
  storage/connect/mycat.cc
  storage/connect/mycat.h
parent d2b6d80b
......@@ -3255,7 +3255,7 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to)
ha_connect_exts= ha_connect_null_exts;
} // endif filename
// Done no more need for this
// Done no more need for this
err:
free_table_share(share);
fin:
......@@ -3821,6 +3821,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
bool dbf;
Field* *field;
Field *fp;
TABTYPE type;
TABLE *st= table; // Probably unuseful
PIXDEF xdp, pxd= NULL, toidx= NULL;
PGLOBAL g= GetPlug(table_arg->in_use);
......@@ -3830,25 +3831,25 @@ int ha_connect::create(const char *name, TABLE *table_arg,
// CONNECT engine specific table options:
DBUG_ASSERT(options);
type= GetTypeID(options->type);
if (options->data_charset)
{
if (options->data_charset) {
const CHARSET_INFO *data_charset;
if (!(data_charset= get_charset_by_csname(options->data_charset,
MY_CS_PRIMARY, MYF(0))))
{
MY_CS_PRIMARY, MYF(0)))) {
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), options->data_charset);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
if (GetTypeID(options->type) == TAB_XML &&
data_charset != &my_charset_utf8_general_ci)
{
} // endif charset
if (type == TAB_XML && data_charset != &my_charset_utf8_general_ci) {
my_printf_error(ER_UNKNOWN_ERROR,
"DATA_CHARSET='%s' is not supported for TABLE_TYPE=XML",
MYF(0), options->data_charset);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
}
} // endif utf8
} // endif charset
if (!g) {
rc= HA_ERR_INTERNAL_ERROR;
......@@ -3906,6 +3907,12 @@ int ha_connect::create(const char *name, TABLE *table_arg,
DBUG_RETURN(rc);
} // endswitch type
if ((fp)->real_maybe_null() && !IsTypeNullable(type)) {
my_printf_error(ER_UNKNOWN_ERROR,
"Table type %s does not support nullable columns",
MYF(0), options->type);
DBUG_RETURN(HA_ERR_UNSUPPORTED);
} // endif !nullable
if (dbf) {
bool b= false;
......@@ -3927,7 +3934,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} // endfor field
if (IsFileType(GetTypeID(options->type))) {
if (IsFileType(type)) {
table= table_arg; // Used by called functions
if (!options->filename) {
......
......@@ -149,6 +149,28 @@ bool IsFileType(TABTYPE type)
return isfile;
} // end of IsFileType
/***********************************************************************/
/* Return true for table types accepting null fields. */
/***********************************************************************/
bool IsTypeNullable(TABTYPE type)
{
bool nullable;
switch (type) {
case TAB_ODBC:
case TAB_MYSQL:
case TAB_INI:
case TAB_XML:
nullable= true;
break;
default:
nullable= false;
break;
} // endswitch type
return nullable;
} // end of IsTypeNullable
/***********************************************************************/
/* Get a unique enum catalog function ID. */
/***********************************************************************/
......
......@@ -36,6 +36,7 @@ typedef class ha_connect *PHC;
TABTYPE GetTypeID(const char *type);
bool IsFileType(TABTYPE type);
bool IsTypeNullable(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