Commit 6be6b4ab authored by Olivier Bertrand's avatar Olivier Bertrand

- All the processing of creating, dropping, modifying indexes was redesigned.

  The code was a legacy from the first versions of the XDB engine dating 2004
  and was not working anymore with recent versions of MySQL/MariaDB. A patch
  in create had been added but is was unsatisfying, recreating all indexes on
  any alter statement and sometimes doing nothing when it should have.
  This is a major update to be tested for stability. It was in most important
  cases et all current tests pass with this new version

modified:
  storage/connect/global.h
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h
  storage/connect/mycat.cc
  storage/connect/plugutil.c
  storage/connect/tabdos.cpp
  storage/connect/user_connect.cc
  storage/connect/user_connect.h
  storage/connect/xindex.h
parent b3b02104
......@@ -220,6 +220,7 @@ typedef struct _global { /* Global structure */
char Message[MAX_STR];
short Trace;
int Createas; /* To pass info to created table */
void *Xchk; /* indexes in create/alter */
int jump_level;
jmp_buf jumper[MAX_JUMP + 2];
} GLOBAL;
......
This diff is collapsed.
......@@ -48,6 +48,16 @@ typedef struct _xinfo {
char *data_file_name; /* Physical file name */
} XINFO, *PXF;
class XCHK : public BLOCK {
public:
XCHK(void) {oldsep= newsep= false; oldpix= newpix= NULL;}
bool oldsep; // Sepindex before create/alter
bool newsep; // Sepindex after create/alter
PIXDEF oldpix; // The indexes before create/alter
PIXDEF newpix; // The indexes after create/alter
}; // end of class XCHK
typedef class XCHK *PCHK;
typedef class user_connect *PCONNECT;
typedef struct ha_table_option_struct TOS, *PTOS;
typedef struct ha_field_option_struct FOS, *PFOS;
......@@ -87,11 +97,12 @@ class ha_connect: public handler
char *GetStringOption(char *opname, char *sdef= NULL);
PTOS GetTableOptionStruct(TABLE *table_arg);
bool GetBooleanOption(char *opname, bool bdef);
bool SetBooleanOption(char *opname, bool b);
int GetIntegerOption(char *opname);
bool SetIntegerOption(char *opname, int n);
PFOS GetFieldOptionStruct(Field *fp);
void *GetColumnOption(void *field, PCOLINFO pcf);
PIXDEF GetIndexInfo(int n);
PIXDEF GetIndexInfo(void);
const char *GetDBName(const char *name);
const char *GetTableName(void);
int GetColNameLen(Field *fp);
......
......@@ -556,26 +556,8 @@ int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp)
/***********************************************************************/
bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp)
{
PIXDEF xdp, pxd= NULL, toidx= NULL;
// Now take care of the index definitions
for (int n= 0; ; n++) {
if (xtrace)
printf("Getting index %d info\n", n + 1);
if (!(xdp= Hc->GetIndexInfo(n)))
break;
if (pxd)
pxd->SetNext(xdp);
else
toidx= xdp;
pxd= xdp;
} // endfor n
// All is correct, attach new index(es)
defp->SetIndx(toidx);
// Attach new index(es)
defp->SetIndx(Hc->GetIndexInfo());
return false;
} // end of GetIndexInfo
......
......@@ -152,6 +152,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
g->Trace = 0;
g->Createas = 0;
g->Activityp = g->ActivityStart = NULL;
g->Xchk = NULL;
strcpy(g->Message, "");
/*******************************************************************/
......
......@@ -157,13 +157,13 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
char filename[_MAX_PATH];
bool sep, rc = false;
if (!pxdf)
if (!To_Indx)
return false; // No index
// If true indexes are in separate files
sep = Cat->GetBoolCatInfo("SepIndex", false);
if (!sep && To_Indx) {
if (!sep && pxdf) {
strcpy(g->Message, MSG(NO_RECOV_SPACE));
return true;
} // endif sep
......@@ -204,7 +204,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
#endif // UNIX
} // endfor pxdf
} else { // !sep, no more indexes or name is NULL
} else { // !sep
// Drop all indexes, delete the common file
PlugSetPath(filename, Ofn, GetPath());
strcat(PlugRemoveType(filename, filename), ftype);
......
......@@ -70,7 +70,6 @@ user_connect::user_connect(THD *thd, const char *dbn)
next= NULL;
previous= NULL;
g= NULL;
tabp= NULL;
last_query_id= 0;
count= 0;
......@@ -141,6 +140,8 @@ bool user_connect::CheckCleanup(void)
if (thdp->query_id > last_query_id) {
PlugCleanup(g, true);
PlugSubSet(g, g->Sarea, g->Sarea_Size);
g->Xchk = NULL;
g->Createas = 0;
last_query_id= thdp->query_id;
if (xtrace)
......
......@@ -70,7 +70,6 @@ class user_connect
PCONNECT previous; // Previous user in chain
PGLOBAL g; // The common handle to CONNECT
//char dbname[32]; // The DBCONNECT database
PTDBDOS tabp; // The table used on create
query_id_t last_query_id; // the latest user query id
int count; // if used by several handlers
// Statistics
......
......@@ -76,6 +76,7 @@ typedef struct index_off {
class DllExport INDEXDEF : public BLOCK { /* Index description block */
friend class PLUGCAT;
friend class DOSDEF;
friend class ha_connect;
friend int PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add);
public:
// Constructor
......
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