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) ...@@ -3044,12 +3044,18 @@ int ha_connect::external_lock(THD *thd, int lock_type)
rc= 2; // Logical error ??? rc= 2; // Logical error ???
else if (g->Xchk) { else if (g->Xchk) {
if (!tdbp || *tdbp->GetName() == '#') { 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 oldsep= ((PCHK)g->Xchk)->oldsep;
bool newsep= ((PCHK)g->Xchk)->newsep; bool newsep= ((PCHK)g->Xchk)->newsep;
PTDBDOS tdp= (PTDBDOS)(tdbp ? tdbp : GetTDB(g)); PTDBDOS tdp= (PTDBDOS)tdbp;
if (!tdp)
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
PDOSDEF ddp= (PDOSDEF)tdp->GetDef(); PDOSDEF ddp= (PDOSDEF)tdp->GetDef();
PIXDEF xp, xp1, xp2, drp=NULL, adp= NULL; PIXDEF xp, xp1, xp2, drp=NULL, adp= NULL;
...@@ -4671,6 +4677,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -4671,6 +4677,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
// Get the index definitions // Get the index definitions
if (xdp= GetIndexInfo()) { if (xdp= GetIndexInfo()) {
if (IsTypeIndexable(type)) {
PDBUSER dup= PlgGetUser(g); PDBUSER dup= PlgGetUser(g);
PCATLG cat= (dup) ? dup->Catalog : NULL; PCATLG cat= (dup) ? dup->Catalog : NULL;
...@@ -4686,11 +4693,27 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -4686,11 +4693,27 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} // endif cat } // 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 } // endif xdp
} else { } 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)->newsep= GetBooleanOption("Sepindex", false);
((PCHK)g->Xchk)->newpix= GetIndexInfo(); } // endif Indexable
} // endif Xchk } // endif Xchk
table= st; table= st;
......
...@@ -172,21 +172,6 @@ bool IsTypeNullable(TABTYPE type) ...@@ -172,21 +172,6 @@ bool IsTypeNullable(TABTYPE type)
{ {
bool nullable; 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) { switch (type) {
case TAB_MAC: case TAB_MAC:
case TAB_DIR: case TAB_DIR:
...@@ -222,6 +207,31 @@ bool IsTypeFixed(TABTYPE type) ...@@ -222,6 +207,31 @@ bool IsTypeFixed(TABTYPE type)
return fix; return fix;
} // end of IsTypeFixed } // 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. */ /* Get a unique enum catalog function ID. */
/***********************************************************************/ /***********************************************************************/
......
...@@ -38,6 +38,7 @@ TABTYPE GetTypeID(const char *type); ...@@ -38,6 +38,7 @@ TABTYPE GetTypeID(const char *type);
bool IsFileType(TABTYPE type); bool IsFileType(TABTYPE type);
bool IsTypeNullable(TABTYPE type); bool IsTypeNullable(TABTYPE type);
bool IsTypeFixed(TABTYPE type); bool IsTypeFixed(TABTYPE type);
bool IsTypeIndexable(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