- Fix a bug concerning index mapping that caused mapped index files
not to be unmapped. This caused a crash instead of reporting an error. This was also fixed. modified: storage/connect/connect.cc storage/connect/ha_connect.cc storage/connect/maputil.cpp storage/connect/table.cpp storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h
This commit is contained in:
parent
f3af6da976
commit
9d41d856a7
@ -442,7 +442,7 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
|
|||||||
for (PCOL colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
|
for (PCOL colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
|
||||||
colp->SetKcol(NULL);
|
colp->SetKcol(NULL);
|
||||||
|
|
||||||
((PTDBASE)tdbp)->SetKindex(NULL);
|
((PTDBASE)tdbp)->ResetKindex(g, NULL);
|
||||||
} // endif index
|
} // endif index
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
// Save stack and allocation environment and prepare error return
|
||||||
@ -585,7 +585,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
|
|||||||
|
|
||||||
// Make all the eventual indexes
|
// Make all the eventual indexes
|
||||||
tbxp= (TDBDOX*)tdbp;
|
tbxp= (TDBDOX*)tdbp;
|
||||||
tbxp->SetKindex(NULL);
|
tbxp->ResetKindex(g, NULL);
|
||||||
tbxp->To_Key_Col= NULL;
|
tbxp->To_Key_Col= NULL;
|
||||||
rc= tbxp->ResetTableOpt(g, ((PTDBASE)tdbp)->GetDef()->Indexable() == 1);
|
rc= tbxp->ResetTableOpt(g, ((PTDBASE)tdbp)->GetDef()->Indexable() == 1);
|
||||||
|
|
||||||
|
@ -2449,7 +2449,7 @@ int ha_connect::index_init(uint idx, bool sorted)
|
|||||||
} // endif index type
|
} // endif index type
|
||||||
|
|
||||||
if ((rc= rnd_init(0)))
|
if ((rc= rnd_init(0)))
|
||||||
return rc;
|
DBUG_RETURN(rc);
|
||||||
|
|
||||||
if (locked == 2) {
|
if (locked == 2) {
|
||||||
// Indexes are not updated in lock write mode
|
// Indexes are not updated in lock write mode
|
||||||
@ -3816,7 +3816,8 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
|
|||||||
DBUG_ENTER("ha_connect::records_in_range");
|
DBUG_ENTER("ha_connect::records_in_range");
|
||||||
|
|
||||||
if (indexing < 0 || inx != active_index)
|
if (indexing < 0 || inx != active_index)
|
||||||
index_init(inx, false);
|
if (index_init(inx, false))
|
||||||
|
DBUG_RETURN(HA_POS_ERROR);
|
||||||
|
|
||||||
if (xtrace)
|
if (xtrace)
|
||||||
htrc("records_in_range: inx=%d indexing=%d\n", inx, indexing);
|
htrc("records_in_range: inx=%d indexing=%d\n", inx, indexing);
|
||||||
|
@ -80,7 +80,16 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR filename,
|
|||||||
} // endif hFileMap
|
} // endif hFileMap
|
||||||
|
|
||||||
access = (mode == MODE_READ) ? FILE_MAP_READ : FILE_MAP_WRITE;
|
access = (mode == MODE_READ) ? FILE_MAP_READ : FILE_MAP_WRITE;
|
||||||
mm->memory = MapViewOfFile(hFileMap, access, 0, 0, 0);
|
|
||||||
|
if (!(mm->memory = MapViewOfFile(hFileMap, access, 0, 0, 0))) {
|
||||||
|
DWORD ler = GetLastError();
|
||||||
|
|
||||||
|
sprintf(g->Message, "Error %ld in MapViewOfFile %s",
|
||||||
|
ler, filename);
|
||||||
|
CloseHandle(hFile);
|
||||||
|
return INVALID_HANDLE_VALUE;
|
||||||
|
} // endif memory
|
||||||
|
|
||||||
// lenH is the high-order word of the file size
|
// lenH is the high-order word of the file size
|
||||||
mm->lenL = GetFileSize(hFile, &mm->lenH);
|
mm->lenL = GetFileSize(hFile, &mm->lenH);
|
||||||
CloseHandle(hFileMap); // Not used anymore
|
CloseHandle(hFileMap); // Not used anymore
|
||||||
|
@ -304,15 +304,22 @@ int TDBASE::ResetTableOpt(PGLOBAL g, bool dox)
|
|||||||
} // end of ResetTableOpt
|
} // end of ResetTableOpt
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* SetKindex: set or reset the index pointer. */
|
/* ResetKindex: set or reset the index pointer. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void TDBASE::SetKindex(PKXBASE kxp)
|
void TDBASE::ResetKindex(PGLOBAL g, PKXBASE kxp)
|
||||||
{
|
{
|
||||||
if (To_Kindex)
|
if (To_Kindex) {
|
||||||
|
int pos = GetRecpos(); // To be reset in Txfp
|
||||||
|
|
||||||
|
for (PCOL colp= Columns; colp; colp= colp->GetNext())
|
||||||
|
colp->SetKcol(NULL);
|
||||||
|
|
||||||
To_Kindex->Close(); // Discard old index
|
To_Kindex->Close(); // Discard old index
|
||||||
|
SetRecpos(g, pos); // Ignore return value
|
||||||
|
} // endif To_Kindex
|
||||||
|
|
||||||
To_Kindex = kxp;
|
To_Kindex = kxp;
|
||||||
} // end of SetKindex
|
} // end of ResetKindex
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* SetRecpos: Replace the table at the specified position. */
|
/* SetRecpos: Replace the table at the specified position. */
|
||||||
|
@ -2131,9 +2131,6 @@ int XINDXS::FastFind(int nk)
|
|||||||
XLOAD::XLOAD(void)
|
XLOAD::XLOAD(void)
|
||||||
{
|
{
|
||||||
Hfile = INVALID_HANDLE_VALUE;
|
Hfile = INVALID_HANDLE_VALUE;
|
||||||
#if defined(WIN32) && defined(XMAP)
|
|
||||||
ViewBase = NULL;
|
|
||||||
#endif // WIN32 && XMAP
|
|
||||||
NewOff.Val = 0LL;
|
NewOff.Val = 0LL;
|
||||||
} // end of XLOAD constructor
|
} // end of XLOAD constructor
|
||||||
|
|
||||||
@ -2147,15 +2144,6 @@ void XLOAD::Close(void)
|
|||||||
Hfile = INVALID_HANDLE_VALUE;
|
Hfile = INVALID_HANDLE_VALUE;
|
||||||
} // endif Hfile
|
} // endif Hfile
|
||||||
|
|
||||||
#if defined(WIN32) && defined(XMAP)
|
|
||||||
if (ViewBase) {
|
|
||||||
if (!UnmapViewOfFile(ViewBase))
|
|
||||||
printf("Error %d closing Viewmap\n", GetLastError());
|
|
||||||
|
|
||||||
ViewBase = NULL;
|
|
||||||
} // endif ViewBase
|
|
||||||
#endif // WIN32 && XMAP
|
|
||||||
|
|
||||||
} // end of Close
|
} // end of Close
|
||||||
|
|
||||||
/* --------------------------- XFILE Class --------------------------- */
|
/* --------------------------- XFILE Class --------------------------- */
|
||||||
@ -2166,9 +2154,9 @@ void XLOAD::Close(void)
|
|||||||
XFILE::XFILE(void) : XLOAD()
|
XFILE::XFILE(void) : XLOAD()
|
||||||
{
|
{
|
||||||
Xfile = NULL;
|
Xfile = NULL;
|
||||||
#if defined(XMAP) && !defined(WIN32)
|
#if defined(XMAP)
|
||||||
Mmp = NULL;
|
Mmp = NULL;
|
||||||
#endif // XMAP && !WIN32
|
#endif // XMAP
|
||||||
} // end of XFILE constructor
|
} // end of XFILE constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@ -2193,9 +2181,9 @@ bool XFILE::Open(PGLOBAL g, char *filename, int id, MODE mode)
|
|||||||
} // endswitch mode
|
} // endswitch mode
|
||||||
|
|
||||||
if (!(Xfile= global_fopen(g, MSGID_OPEN_ERROR_AND_STRERROR, filename, pmod))) {
|
if (!(Xfile= global_fopen(g, MSGID_OPEN_ERROR_AND_STRERROR, filename, pmod))) {
|
||||||
#if defined(TRACE)
|
if (trace)
|
||||||
printf("Open: %s\n", g->Message);
|
htrc("Open: %s\n", g->Message);
|
||||||
#endif // TRACE
|
|
||||||
return true;
|
return true;
|
||||||
} // endif Xfile
|
} // endif Xfile
|
||||||
|
|
||||||
@ -2311,11 +2299,9 @@ void XFILE::Close(void)
|
|||||||
Xfile = NULL;
|
Xfile = NULL;
|
||||||
} // endif Xfile
|
} // endif Xfile
|
||||||
|
|
||||||
#if defined(XMAP) && !defined(WIN32)
|
#if defined(XMAP)
|
||||||
if (Mmp) {
|
if (Mmp && CloseMemMap(Mmp->memory, Mmp->lenL))
|
||||||
CloseMemMap(Mmp->memory, Mmp->lenL);
|
printf("Error %d closing mapped index\n");
|
||||||
Mmp = NULL;
|
|
||||||
} // endif Mmp
|
|
||||||
#endif // XMAP
|
#endif // XMAP
|
||||||
} // end of Close
|
} // end of Close
|
||||||
|
|
||||||
@ -2357,9 +2343,8 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
|
|||||||
return true;
|
return true;
|
||||||
} // endif
|
} // endif
|
||||||
|
|
||||||
#if defined(TRACE)
|
if (trace)
|
||||||
printf( "Xopen: filename=%s mode=%d\n", filename, mode);
|
htrc(" Xopen: filename=%s mode=%d\n", filename, mode);
|
||||||
#endif // TRACE
|
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
LONG high = 0;
|
LONG high = 0;
|
||||||
@ -2476,16 +2461,15 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
|
|||||||
|
|
||||||
if (Hfile == INVALID_HANDLE_VALUE) {
|
if (Hfile == INVALID_HANDLE_VALUE) {
|
||||||
/*rc = errno;*/
|
/*rc = errno;*/
|
||||||
#if defined(TRACE)
|
if (trace)
|
||||||
printf("Open: %s\n", g->Message);
|
htrc("Open: %s\n", g->Message);
|
||||||
#endif // TRACE
|
|
||||||
return true;
|
return true;
|
||||||
} // endif Hfile
|
} // endif Hfile
|
||||||
|
|
||||||
#if defined(TRACE)
|
if (trace)
|
||||||
printf(" rc=%d oflag=%p mode=%d handle=%d fn=%s\n",
|
htrc(" rc=%d oflag=%p mode=%d handle=%d fn=%s\n",
|
||||||
rc, oflag, mode, Hfile, filename);
|
rc, oflag, mode, Hfile, filename);
|
||||||
#endif // TRACE
|
|
||||||
|
|
||||||
if (mode == MODE_INSERT) {
|
if (mode == MODE_INSERT) {
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
@ -2588,15 +2572,15 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size)
|
|||||||
#else // UNIX
|
#else // UNIX
|
||||||
ssize_t count = (ssize_t)(n * size);
|
ssize_t count = (ssize_t)(n * size);
|
||||||
|
|
||||||
#if defined(TRACE)
|
if (trace)
|
||||||
printf("Hfile=%d n=%d size=%d count=%d\n", Hfile, n, size, count);
|
htrc("Hfile=%d n=%d size=%d count=%d\n", Hfile, n, size, count);
|
||||||
#endif // TRACE
|
|
||||||
|
|
||||||
if (read(Hfile, buf, count) != count) {
|
if (read(Hfile, buf, count) != count) {
|
||||||
sprintf(g->Message, MSG(READ_ERROR), "Index file", strerror(errno));
|
sprintf(g->Message, MSG(READ_ERROR), "Index file", strerror(errno));
|
||||||
#if defined(TRACE)
|
|
||||||
printf("read error %d\n", errno);
|
if (trace)
|
||||||
#endif // TRACE
|
htrc("read error %d\n", errno);
|
||||||
|
|
||||||
rc = true;
|
rc = true;
|
||||||
} // endif nbr
|
} // endif nbr
|
||||||
#endif // UNIX
|
#endif // UNIX
|
||||||
@ -2854,8 +2838,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
|
|||||||
// Allocate the Value object used when moving items
|
// Allocate the Value object used when moving items
|
||||||
Type = colp->GetResultType();
|
Type = colp->GetResultType();
|
||||||
|
|
||||||
if (!(Valp = AllocateValue(g, Type, len, colp->GetScale(),
|
if (!(Valp = AllocateValue(g, Type, len, prec, colp->IsUnsigned())))
|
||||||
colp->IsUnsigned())))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Klen = Valp->GetClen();
|
Klen = Valp->GetClen();
|
||||||
@ -2877,10 +2860,11 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
|
|||||||
|
|
||||||
// Store this information to avoid sorting when already done
|
// Store this information to avoid sorting when already done
|
||||||
if (Asc)
|
if (Asc)
|
||||||
// IsSorted = colp->GetOpt() < 0;
|
// IsSorted = colp->GetOpt() == 2;
|
||||||
IsSorted = false;
|
IsSorted = false;
|
||||||
|
|
||||||
//SetNulls(colp->IsNullable()); for when null columns will be indexable
|
//SetNulls(colp->IsNullable()); for when null columns will be indexable
|
||||||
|
Colp = colp;
|
||||||
return false;
|
return false;
|
||||||
} // end of Init
|
} // end of Init
|
||||||
|
|
||||||
@ -2891,7 +2875,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
|
BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
|
||||||
{
|
{
|
||||||
int len = colp->GetLength(), prec = colp->GetPrecision();
|
int len = colp->GetLength(), prec = colp->GetScale();
|
||||||
|
|
||||||
if (n[3] && colp->GetLength() > n[3]
|
if (n[3] && colp->GetLength() > n[3]
|
||||||
&& colp->GetResultType() == TYPE_STRING) {
|
&& colp->GetResultType() == TYPE_STRING) {
|
||||||
@ -2906,7 +2890,7 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
|
|||||||
this, colp, Type, n[0], len, m);
|
this, colp, Type, n[0], len, m);
|
||||||
|
|
||||||
// Allocate the Value object used when moving items
|
// Allocate the Value object used when moving items
|
||||||
Valp = AllocateValue(g, Type, len, prec, false, NULL);
|
Valp = AllocateValue(g, Type, len, prec, colp->IsUnsigned());
|
||||||
Klen = Valp->GetClen();
|
Klen = Valp->GetClen();
|
||||||
|
|
||||||
if (n[2]) {
|
if (n[2]) {
|
||||||
@ -2926,7 +2910,7 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
|
|||||||
// by blanks (if true) or keep the zero ending char (if false).
|
// by blanks (if true) or keep the zero ending char (if false).
|
||||||
// Currently we set it to true to be compatible with QRY blocks,
|
// Currently we set it to true to be compatible with QRY blocks,
|
||||||
// and last one to enable type checking (no conversion).
|
// and last one to enable type checking (no conversion).
|
||||||
Kblp = AllocValBlock(g, To_Keys, Type, n[0], len, prec, true, true);
|
Kblp = AllocValBlock(g, To_Keys, Type, n[0], len, prec, !Prefix, true);
|
||||||
|
|
||||||
if (n[1]) {
|
if (n[1]) {
|
||||||
Koff.Size = n[1] * sizeof(int);
|
Koff.Size = n[1] * sizeof(int);
|
||||||
@ -2937,6 +2921,7 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
|
|||||||
Ndf = n[0];
|
Ndf = n[0];
|
||||||
//IsSorted = colp->GetOpt() < 0;
|
//IsSorted = colp->GetOpt() < 0;
|
||||||
IsSorted = false;
|
IsSorted = false;
|
||||||
|
Colp = colp;
|
||||||
return m + Bkeys.Size + Keys.Size + Koff.Size;
|
return m + Bkeys.Size + Keys.Size + Koff.Size;
|
||||||
} // end of MapInit
|
} // end of MapInit
|
||||||
#endif // XMAP
|
#endif // XMAP
|
||||||
@ -3054,9 +3039,8 @@ int KXYCOL::Compare(int i1, int i2)
|
|||||||
// Do the actual comparison between values.
|
// Do the actual comparison between values.
|
||||||
register int k = Kblp->CompVal(i1, i2);
|
register int k = Kblp->CompVal(i1, i2);
|
||||||
|
|
||||||
#ifdef DEBUG2
|
if (trace > 2)
|
||||||
htrc("Compare done result=%d\n", k);
|
htrc("Compare done result=%d\n", k);
|
||||||
#endif
|
|
||||||
|
|
||||||
return (Asc) ? k : -k;
|
return (Asc) ? k : -k;
|
||||||
} // end of Compare
|
} // end of Compare
|
||||||
@ -3067,13 +3051,14 @@ int KXYCOL::Compare(int i1, int i2)
|
|||||||
int KXYCOL::CompVal(int i)
|
int KXYCOL::CompVal(int i)
|
||||||
{
|
{
|
||||||
// Do the actual comparison between numerical values.
|
// Do the actual comparison between numerical values.
|
||||||
#ifdef DEBUG2
|
if (trace > 2) {
|
||||||
register int k = (int)Kblp->CompVal(Valp, (int)i);
|
register int k = (int)Kblp->CompVal(Valp, (int)i);
|
||||||
|
|
||||||
htrc("Compare done result=%d\n", k);
|
htrc("Compare done result=%d\n", k);
|
||||||
return k;
|
return k;
|
||||||
#endif
|
} else
|
||||||
return Kblp->CompVal(Valp, i);
|
return Kblp->CompVal(Valp, i);
|
||||||
|
|
||||||
} // end of CompVal
|
} // end of CompVal
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
@ -339,9 +339,6 @@ class DllExport XLOAD : public BLOCK {
|
|||||||
// Members
|
// Members
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
HANDLE Hfile; // Handle to file or map
|
HANDLE Hfile; // Handle to file or map
|
||||||
#if defined(XMAP)
|
|
||||||
void *ViewBase; // Mapped view base address
|
|
||||||
#endif // XMAP
|
|
||||||
#else // UNIX
|
#else // UNIX
|
||||||
int Hfile; // Descriptor to file or map
|
int Hfile; // Descriptor to file or map
|
||||||
#endif // UNIX
|
#endif // UNIX
|
||||||
@ -371,7 +368,7 @@ class DllExport XFILE : public XLOAD {
|
|||||||
// Members
|
// Members
|
||||||
FILE *Xfile; // Index stream file
|
FILE *Xfile; // Index stream file
|
||||||
#if defined(XMAP)
|
#if defined(XMAP)
|
||||||
MMP Mmp; // To mapped index file
|
MMP Mmp; // Mapped view base address and length
|
||||||
#endif // XMAP
|
#endif // XMAP
|
||||||
}; // end of class XFILE
|
}; // end of class XFILE
|
||||||
|
|
||||||
|
@ -142,9 +142,10 @@ class DllExport TDBASE : public TDB {
|
|||||||
inline PKXBASE GetKindex(void) {return To_Kindex;}
|
inline PKXBASE GetKindex(void) {return To_Kindex;}
|
||||||
inline PCOL GetSetCols(void) {return To_SetCols;}
|
inline PCOL GetSetCols(void) {return To_SetCols;}
|
||||||
inline void SetSetCols(PCOL colp) {To_SetCols = colp;}
|
inline void SetSetCols(PCOL colp) {To_SetCols = colp;}
|
||||||
|
inline void SetKindex(PKXBASE kxp) {To_Kindex = kxp;}
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
void SetKindex(PKXBASE kxp);
|
void ResetKindex(PGLOBAL g, PKXBASE kxp);
|
||||||
PCOL Key(int i) {return (To_Key_Col) ? To_Key_Col[i] : NULL;}
|
PCOL Key(int i) {return (To_Key_Col) ? To_Key_Col[i] : NULL;}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
|
Loading…
x
Reference in New Issue
Block a user