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
...@@ -3821,6 +3821,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3821,6 +3821,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
bool dbf; bool dbf;
Field* *field; Field* *field;
Field *fp; Field *fp;
TABTYPE type;
TABLE *st= table; // Probably unuseful TABLE *st= table; // Probably unuseful
PIXDEF xdp, pxd= NULL, toidx= NULL; PIXDEF xdp, pxd= NULL, toidx= NULL;
PGLOBAL g= GetPlug(table_arg->in_use); PGLOBAL g= GetPlug(table_arg->in_use);
...@@ -3830,25 +3831,25 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3830,25 +3831,25 @@ int ha_connect::create(const char *name, TABLE *table_arg,
// CONNECT engine specific table options: // CONNECT engine specific table options:
DBUG_ASSERT(options); DBUG_ASSERT(options);
type= GetTypeID(options->type);
if (options->data_charset) if (options->data_charset) {
{
const CHARSET_INFO *data_charset; const CHARSET_INFO *data_charset;
if (!(data_charset= get_charset_by_csname(options->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); my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), options->data_charset);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
} } // endif charset
if (GetTypeID(options->type) == TAB_XML &&
data_charset != &my_charset_utf8_general_ci) if (type == TAB_XML && data_charset != &my_charset_utf8_general_ci) {
{
my_printf_error(ER_UNKNOWN_ERROR, my_printf_error(ER_UNKNOWN_ERROR,
"DATA_CHARSET='%s' is not supported for TABLE_TYPE=XML", "DATA_CHARSET='%s' is not supported for TABLE_TYPE=XML",
MYF(0), options->data_charset); MYF(0), options->data_charset);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
} } // endif utf8
}
} // endif charset
if (!g) { if (!g) {
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
...@@ -3906,6 +3907,12 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3906,6 +3907,12 @@ int ha_connect::create(const char *name, TABLE *table_arg,
DBUG_RETURN(rc); DBUG_RETURN(rc);
} // endswitch type } // 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) { if (dbf) {
bool b= false; bool b= false;
...@@ -3927,7 +3934,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3927,7 +3934,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} // endfor field } // endfor field
if (IsFileType(GetTypeID(options->type))) { if (IsFileType(type)) {
table= table_arg; // Used by called functions table= table_arg; // Used by called functions
if (!options->filename) { if (!options->filename) {
......
...@@ -149,6 +149,28 @@ bool IsFileType(TABTYPE type) ...@@ -149,6 +149,28 @@ bool IsFileType(TABTYPE type)
return isfile; return isfile;
} // end of IsFileType } // 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. */ /* Get a unique enum catalog function ID. */
/***********************************************************************/ /***********************************************************************/
......
...@@ -36,6 +36,7 @@ typedef class ha_connect *PHC; ...@@ -36,6 +36,7 @@ typedef class ha_connect *PHC;
TABTYPE GetTypeID(const char *type); TABTYPE GetTypeID(const char *type);
bool IsFileType(TABTYPE type); bool IsFileType(TABTYPE type);
bool IsTypeNullable(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