diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index f9a9fac11cc..1e9e7bab075 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -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,26 +4677,43 @@ int ha_connect::create(const char *name, TABLE *table_arg, // Get the index definitions if (xdp= GetIndexInfo()) { - PDBUSER dup= PlgGetUser(g); - PCATLG cat= (dup) ? dup->Catalog : NULL; - - if (cat) { - cat->SetDataPath(g, table_arg->s->db.str); - - if ((rc= optimize(table->in_use, NULL))) { - printf("Create rc=%d %s\n", rc, g->Message); - my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); - rc= HA_ERR_INTERNAL_ERROR; - } else - CloseTable(g); - - } // endif cat + if (IsTypeIndexable(type)) { + PDBUSER dup= PlgGetUser(g); + PCATLG cat= (dup) ? dup->Catalog : NULL; + + if (cat) { + cat->SetDataPath(g, table_arg->s->db.str); + + if ((rc= optimize(table->in_use, NULL))) { + printf("Create rc=%d %s\n", rc, g->Message); + my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); + rc= HA_ERR_INTERNAL_ERROR; + } else + CloseTable(g); + + } // 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 { - ((PCHK)g->Xchk)->newsep= GetBooleanOption("Sepindex", false); - ((PCHK)g->Xchk)->newpix= GetIndexInfo(); + 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); + } // endif Indexable + } // endif Xchk table= st; diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc index a9326b38bb5..092d38a142a 100644 --- a/storage/connect/mycat.cc +++ b/storage/connect/mycat.cc @@ -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. */ /***********************************************************************/ diff --git a/storage/connect/mycat.h b/storage/connect/mycat.h index c878d5be1a8..05fa96e6295 100644 --- a/storage/connect/mycat.h +++ b/storage/connect/mycat.h @@ -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); /***********************************************************************/