Commit 9cb4b6c0 authored by Olivier Bertrand's avatar Olivier Bertrand

- FIX some MAP and XMAP errors (such as mapped indexes not closed)

  Do not put version in XML files header
  Remove HTON_NO_PARTITION for testing
  Fix a wrong return (instead of DBUG_RETURN) in index_init
  Plus a few typos
modified:
  storage/connect/connect.cc
  storage/connect/filter.cpp
  storage/connect/ha_connect.cc
  storage/connect/maputil.cpp
  storage/connect/mysql-test/connect/r/alter_xml.result
  storage/connect/mysql-test/connect/r/xml.result
  storage/connect/table.cpp
  storage/connect/tabxml.cpp
  storage/connect/xindex.cpp
  storage/connect/xindex.h
  storage/connect/xtable.h
parent cdbb7958
......@@ -439,10 +439,10 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
// Reading sequencially an indexed table. This happens after the
// handler function records_in_range was called and MySQL decides
// to quit using the index (!!!) Drop the index.
for (PCOL colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
colp->SetKcol(NULL);
// for (PCOL colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
// colp->SetKcol(NULL);
((PTDBASE)tdbp)->SetKindex(g, NULL);
((PTDBASE)tdbp)->ResetKindex(g, NULL);
} // endif index
// Save stack and allocation environment and prepare error return
......@@ -456,7 +456,12 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
goto err;
} // endif rc
while ((rc= (RCODE)tdbp->ReadDB(g)) == RC_NF) ;
do {
if ((rc= (RCODE)tdbp->ReadDB(g)) == RC_OK)
if (!ApplyFilter(g, tdbp->GetFilter()))
rc= RC_NF;
} while (rc == RC_NF);
err:
g->jump_level--;
......@@ -585,7 +590,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
// Make all the eventual indexes
tbxp= (TDBDOX*)tdbp;
tbxp->SetKindex(g, NULL);
tbxp->ResetKindex(g, NULL);
tbxp->To_Key_Col= NULL;
rc= tbxp->ResetTableOpt(g, true,
((PTDBASE)tdbp)->GetDef()->Indexable() == 1);
......
......@@ -1725,7 +1725,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
if (filp->Eval(g))
longjmp(g->jumper[g->jump_level], TYPE_FILTER);
if (trace)
if (trace > 1)
htrc("PlugFilter filp=%p result=%d\n",
filp, filp->GetResult());
......
......@@ -170,7 +170,8 @@
#define SZWMIN 4194304 // Minimum work area size 4M
extern "C" {
char version[]= "Version 1.03.0002 April 23, 2014";
char version[]= "Version 1.03.0002 May 03, 2014";
char compver[]= "Version 1.03.0002 " __DATE__ " " __TIME__;
#if defined(XMSG)
char msglang[]; // Default message language
......@@ -420,7 +421,7 @@ static int connect_init_func(void *p)
{
DBUG_ENTER("connect_init_func");
sql_print_information("CONNECT: %s", version);
sql_print_information("CONNECT: %s", compver);
// xtrace is now a system variable
trace= xtrace;
......@@ -432,9 +433,10 @@ static int connect_init_func(void *p)
init_connect_psi_keys();
connect_hton= (handlerton *)p;
connect_hton->state= SHOW_OPTION_YES;
connect_hton->create= connect_create_handler;
connect_hton->flags= HTON_TEMPORARY_NOT_SUPPORTED | HTON_NO_PARTITION;
connect_hton->state= SHOW_OPTION_YES;
connect_hton->create= connect_create_handler;
//connect_hton->flags= HTON_TEMPORARY_NOT_SUPPORTED | HTON_NO_PARTITION;
connect_hton->flags= HTON_TEMPORARY_NOT_SUPPORTED;
connect_hton->table_options= connect_table_option_list;
connect_hton->field_options= connect_field_option_list;
connect_hton->index_options= connect_index_option_list;
......@@ -446,7 +448,7 @@ static int connect_init_func(void *p)
DTVAL::SetTimeShift(); // Initialize time zone shift once for all
DBUG_RETURN(0);
}
} // end of connect_init_func
/**
......@@ -476,13 +478,13 @@ static int connect_done_func(void *p)
} // endfor pc
DBUG_RETURN(error);
}
} // end of connect_done_func
/**
@brief
Example of simple lock controls. The "share" it creates is a
structure we will pass to each example handler. Do you have to have
structure we will pass to each CONNECT handler. Do you have to have
one of these? Well, you have pieces that are used for locking, and
they are needed to function.
*/
......@@ -490,20 +492,22 @@ static int connect_done_func(void *p)
CONNECT_SHARE *ha_connect::get_share()
{
CONNECT_SHARE *tmp_share;
lock_shared_ha_data();
if (!(tmp_share= static_cast<CONNECT_SHARE*>(get_ha_share_ptr())))
{
if (!(tmp_share= static_cast<CONNECT_SHARE*>(get_ha_share_ptr()))) {
tmp_share= new CONNECT_SHARE;
if (!tmp_share)
goto err;
mysql_mutex_init(con_key_mutex_CONNECT_SHARE_mutex,
&tmp_share->mutex, MY_MUTEX_INIT_FAST);
set_ha_share_ptr(static_cast<Handler_share*>(tmp_share));
}
err:
} // endif tmp_share
err:
unlock_shared_ha_data();
return tmp_share;
}
} // end of get_share
static handler* connect_create_handler(handlerton *hton,
......@@ -740,7 +744,7 @@ ulonglong ha_connect::table_flags() const
} // end of table_flags
/****************************************************************************/
/* Return the value of an option specified in the option list. */
/* Return the value of an option specified in an option list. */
/****************************************************************************/
char *GetListOption(PGLOBAL g, const char *opname,
const char *oplist, const char *def)
......@@ -2717,7 +2721,7 @@ int ha_connect::index_init(uint idx, bool sorted)
} // endif index type
if ((rc= rnd_init(0)))
return rc;
DBUG_RETURN(rc);
if (locked == 2) {
// Indexes are not updated in lock write mode
......@@ -3133,6 +3137,10 @@ void ha_connect::position(const uchar *record)
DBUG_ENTER("ha_connect::position");
//if (((PTDBASE)tdbp)->GetDef()->Indexable())
my_store_ptr(ref, ref_length, (my_off_t)((PTDBASE)tdbp)->GetRecpos());
if (trace)
htrc("position: pos=%d\n", ((PTDBASE)tdbp)->GetRecpos());
DBUG_VOID_RETURN;
} // end of position
......@@ -3159,9 +3167,13 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos)
PTDBASE tp= (PTDBASE)tdbp;
DBUG_ENTER("ha_connect::rnd_pos");
if (!tp->SetRecpos(xp->g, (int)my_get_ptr(pos, ref_length)))
if (!tp->SetRecpos(xp->g, (int)my_get_ptr(pos, ref_length))) {
if (trace)
htrc("rnd_pos: %d\n", tp->GetRecpos());
tp->SetFilter(NULL);
rc= rnd_next(buf);
else
} else
rc= HA_ERR_KEY_NOT_FOUND;
DBUG_RETURN(rc);
......@@ -4085,7 +4097,8 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
DBUG_ENTER("ha_connect::records_in_range");
if (indexing < 0 || inx != active_index)
index_init(inx, false);
if (index_init(inx, false))
DBUG_RETURN(HA_POS_ERROR);
if (xtrace)
htrc("records_in_range: inx=%d indexing=%d\n", inx, indexing);
......
......@@ -80,7 +80,16 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR filename,
} // endif hFileMap
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
mm->lenL = GetFileSize(hFile, &mm->lenH);
CloseHandle(hFileMap); // Not used anymore
......
......@@ -35,7 +35,7 @@ Warning 1105 No table_type. Will be set to DOS
SELECT * FROM t2;
line
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<!-- Created by the MariaDB CONNECT Storage Engine-->
<t1>
<row>
<TH>c</TH>
......@@ -71,7 +71,7 @@ t1 CREATE TABLE `t1` (
SELECT * FROM t2;
line
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<!-- Created by the MariaDB CONNECT Storage Engine-->
<t1>
<row d="One">
<c>1</c>
......
......@@ -416,7 +416,7 @@ DROP TABLE t1;
SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml');
SELECT CAST(@a AS CHAR CHARACTER SET latin1);
CAST(@a AS CHAR CHARACTER SET latin1) <?xml version="1.0" encoding="iso-8859-1"?>
<!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<!-- Created by the MariaDB CONNECT Storage Engine-->
<t1>
<line>
<node>ÀÁÂÃ</node>
......
This diff is collapsed.
......@@ -522,8 +522,8 @@ bool TDBXML::Initialize(PGLOBAL g)
To_Xb = Docp->LinkXblock(g, Mode, rc, filename);
// Add a CONNECT comment node
// sprintf(buf, MSG(CREATED_PLUGDB), version);
sprintf(buf, " Created by CONNECT %s ", version);
// sprintf(buf, " Created by CONNECT %s ", version);
strcpy(buf, " Created by the MariaDB CONNECT Storage Engine");
Docp->AddComment(g, buf);
if (XmlDB) {
......
......@@ -684,11 +684,14 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
if (SaveIndex(g, sxp))
brc = true;
} else // Dynamic index
} else { // Dynamic index
// Indicate that key column values can be found from KEYCOL's
for (kcp = To_KeyCol; kcp; kcp = kcp->Next)
kcp->Colp->SetKcol(kcp);
Tdbp->SetFilter(NULL); // Not used anymore
} // endif X
err:
// We don't need the index anymore
if (X || brc)
......@@ -2234,9 +2237,6 @@ int XINDXS::FastFind(int nk)
XLOAD::XLOAD(void)
{
Hfile = INVALID_HANDLE_VALUE;
#if defined(WIN32) && defined(XMAP)
ViewBase = NULL;
#endif // WIN32 && XMAP
NewOff.Val = 0LL;
} // end of XLOAD constructor
......@@ -2250,15 +2250,6 @@ void XLOAD::Close(void)
Hfile = INVALID_HANDLE_VALUE;
} // 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
/* --------------------------- XFILE Class --------------------------- */
......@@ -2269,9 +2260,9 @@ void XLOAD::Close(void)
XFILE::XFILE(void) : XLOAD()
{
Xfile = NULL;
#if defined(XMAP) && !defined(WIN32)
#if defined(XMAP)
Mmp = NULL;
#endif // XMAP && !WIN32
#endif // XMAP
} // end of XFILE constructor
/***********************************************************************/
......@@ -2414,11 +2405,9 @@ void XFILE::Close(void)
Xfile = NULL;
} // endif Xfile
#if defined(XMAP) && !defined(WIN32)
if (Mmp) {
CloseMemMap(Mmp->memory, Mmp->lenL);
Mmp = NULL;
} // endif Mmp
#if defined(XMAP)
if (Mmp && CloseMemMap(Mmp->memory, Mmp->lenL))
printf("Error %d closing mapped index\n");
#endif // XMAP
} // end of Close
......@@ -2955,8 +2944,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
// Allocate the Value object used when moving items
Type = colp->GetResultType();
if (!(Valp = AllocateValue(g, Type, len, colp->GetScale(),
colp->IsUnsigned())))
if (!(Valp = AllocateValue(g, Type, len, prec, colp->IsUnsigned())))
return true;
Klen = Valp->GetClen();
......@@ -2992,7 +2980,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)
{
int len = colp->GetLength(), prec = colp->GetPrecision();
int len = colp->GetLength(), prec = colp->GetScale();
if (n[3] && colp->GetLength() > n[3]
&& colp->GetResultType() == TYPE_STRING) {
......@@ -3002,12 +2990,12 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
Type = colp->GetResultType();
if (trace)
htrc("MapInit(%p): colp=%p type=%d n=%d len=%d m=%p\n",
this, colp, Type, n[0], len, m);
if (trace)
htrc("MapInit(%p): colp=%p type=%d n=%d len=%d m=%p\n",
this, colp, Type, n[0], len, m);
// 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();
if (n[2]) {
......@@ -3027,7 +3015,7 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
// by blanks (if true) or keep the zero ending char (if false).
// Currently we set it to true to be compatible with QRY blocks,
// 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]) {
Koff.Size = n[1] * sizeof(int);
......@@ -3038,6 +3026,7 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
Ndf = n[0];
//IsSorted = colp->GetOpt() < 0;
IsSorted = false;
Colp = colp;
return m + Bkeys.Size + Keys.Size + Koff.Size;
} // end of MapInit
#endif // XMAP
......
......@@ -347,9 +347,6 @@ class DllExport XLOAD : public BLOCK {
// Members
#if defined(WIN32)
HANDLE Hfile; // Handle to file or map
#if defined(XMAP)
void *ViewBase; // Mapped view base address
#endif // XMAP
#else // UNIX
int Hfile; // Descriptor to file or map
#endif // UNIX
......@@ -377,9 +374,9 @@ class DllExport XFILE : public XLOAD {
protected:
// Members
FILE *Xfile; // Index stream file
FILE *Xfile; // Index stream file
#if defined(XMAP)
MMP Mmp; // To mapped index file
MMP Mmp; // Mapped view base address and length
#endif // XMAP
}; // end of class XFILE
......
......@@ -146,9 +146,10 @@ class DllExport TDBASE : public TDB {
inline PCOL GetSetCols(void) {return To_SetCols;}
inline void SetSetCols(PCOL colp) {To_SetCols = colp;}
inline void SetXdp(PIXDEF xdp) {To_Xdp = xdp;}
inline void SetKindex(PKXBASE kxp) {To_Kindex = kxp;}
// Properties
void SetKindex(PGLOBAL g, PKXBASE kxp);
void ResetKindex(PGLOBAL g, PKXBASE kxp);
PCOL Key(int i) {return (To_Key_Col) ? To_Key_Col[i] : NULL;}
// Methods
......
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