Commit a8b09c14 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix bug MDEV-5261

modified:
  storage/connect/ha_connect.cc
  storage/connect/mycat.cc
  storage/connect/mycat.h
parent 41dbe1c9
......@@ -3044,12 +3044,18 @@ int ha_connect::external_lock(THD *thd, int lock_type)
rc= 2; // Logical error ???
else if (g->Xchk) {
if (!tdbp || *tdbp->GetName() == '#') {
if (!tdbp && !(tdbp= GetTDB(g)))
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
else if (!((PTDBASE)tdbp)->GetDef()->Indexable()) {
sprintf(g->Message, "Table %s is not indexable", tdbp->GetName());
// DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
DBUG_RETURN(0);
} // endif Indexable
bool oldsep= ((PCHK)g->Xchk)->oldsep;
bool newsep= ((PCHK)g->Xchk)->newsep;
PTDBDOS tdp= (PTDBDOS)(tdbp ? tdbp : GetTDB(g));
if (!tdp)
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
PTDBDOS tdp= (PTDBDOS)tdbp;
PDOSDEF ddp= (PDOSDEF)tdp->GetDef();
PIXDEF xp, xp1, xp2, drp=NULL, adp= NULL;
......@@ -4671,6 +4677,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
// Get the index definitions
if (xdp= GetIndexInfo()) {
if (IsTypeIndexable(type)) {
PDBUSER dup= PlgGetUser(g);
PCATLG cat= (dup) ? dup->Catalog : NULL;
......@@ -4686,11 +4693,27 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} // endif cat
} else {
sprintf(g->Message, "Table type %s is not indexable", options->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR;
} // endif Indexable
} // endif xdp
} else {
PIXDEF xdp= GetIndexInfo();
if (xdp && !IsTypeIndexable(type)) {
g->Xchk= NULL;
sprintf(g->Message, "Table type %s is not indexable", options->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR;
} else {
((PCHK)g->Xchk)->newpix= xdp;
((PCHK)g->Xchk)->newsep= GetBooleanOption("Sepindex", false);
((PCHK)g->Xchk)->newpix= GetIndexInfo();
} // endif Indexable
} // endif Xchk
table= st;
......
......@@ -172,21 +172,6 @@ bool IsTypeNullable(TABTYPE type)
{
bool nullable;
#if 0
switch (type) {
case TAB_ODBC:
case TAB_MYSQL:
case TAB_TBL:
case TAB_INI:
case TAB_XML:
nullable= true;
break;
default:
nullable= false;
break;
} // endswitch type
#endif // 0
switch (type) {
case TAB_MAC:
case TAB_DIR:
......@@ -222,6 +207,31 @@ bool IsTypeFixed(TABTYPE type)
return fix;
} // end of IsTypeFixed
/***********************************************************************/
/* Return true for table types with fix length records. */
/***********************************************************************/
bool IsTypeIndexable(TABTYPE type)
{
bool idx;
switch (type) {
case TAB_DOS:
case TAB_CSV:
case TAB_FMT:
case TAB_FIX:
case TAB_BIN:
case TAB_VEC:
case TAB_DBF:
idx= true;
break;
default:
idx= false;
break;
} // endswitch type
return idx;
} // end of IsTypeIndexable
/***********************************************************************/
/* Get a unique enum catalog function ID. */
/***********************************************************************/
......
......@@ -38,6 +38,7 @@ TABTYPE GetTypeID(const char *type);
bool IsFileType(TABTYPE type);
bool IsTypeNullable(TABTYPE type);
bool IsTypeFixed(TABTYPE type);
bool IsTypeIndexable(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