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) ...@@ -439,10 +439,10 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
// Reading sequencially an indexed table. This happens after the // Reading sequencially an indexed table. This happens after the
// handler function records_in_range was called and MySQL decides // handler function records_in_range was called and MySQL decides
// to quit using the index (!!!) Drop the index. // to quit using the index (!!!) Drop the index.
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(g, 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
...@@ -456,7 +456,12 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp) ...@@ -456,7 +456,12 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
goto err; goto err;
} // endif rc } // 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: err:
g->jump_level--; g->jump_level--;
...@@ -585,7 +590,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp) ...@@ -585,7 +590,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(g, NULL); tbxp->ResetKindex(g, NULL);
tbxp->To_Key_Col= NULL; tbxp->To_Key_Col= NULL;
rc= tbxp->ResetTableOpt(g, true, rc= tbxp->ResetTableOpt(g, true,
((PTDBASE)tdbp)->GetDef()->Indexable() == 1); ((PTDBASE)tdbp)->GetDef()->Indexable() == 1);
......
...@@ -1725,7 +1725,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp) ...@@ -1725,7 +1725,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
if (filp->Eval(g)) if (filp->Eval(g))
longjmp(g->jumper[g->jump_level], TYPE_FILTER); longjmp(g->jumper[g->jump_level], TYPE_FILTER);
if (trace) if (trace > 1)
htrc("PlugFilter filp=%p result=%d\n", htrc("PlugFilter filp=%p result=%d\n",
filp, filp->GetResult()); filp, filp->GetResult());
......
...@@ -170,7 +170,8 @@ ...@@ -170,7 +170,8 @@
#define SZWMIN 4194304 // Minimum work area size 4M #define SZWMIN 4194304 // Minimum work area size 4M
extern "C" { 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) #if defined(XMSG)
char msglang[]; // Default message language char msglang[]; // Default message language
...@@ -420,7 +421,7 @@ static int connect_init_func(void *p) ...@@ -420,7 +421,7 @@ static int connect_init_func(void *p)
{ {
DBUG_ENTER("connect_init_func"); DBUG_ENTER("connect_init_func");
sql_print_information("CONNECT: %s", version); sql_print_information("CONNECT: %s", compver);
// xtrace is now a system variable // xtrace is now a system variable
trace= xtrace; trace= xtrace;
...@@ -432,9 +433,10 @@ static int connect_init_func(void *p) ...@@ -432,9 +433,10 @@ static int connect_init_func(void *p)
init_connect_psi_keys(); init_connect_psi_keys();
connect_hton= (handlerton *)p; connect_hton= (handlerton *)p;
connect_hton->state= SHOW_OPTION_YES; connect_hton->state= SHOW_OPTION_YES;
connect_hton->create= connect_create_handler; connect_hton->create= connect_create_handler;
connect_hton->flags= HTON_TEMPORARY_NOT_SUPPORTED | HTON_NO_PARTITION; //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->table_options= connect_table_option_list;
connect_hton->field_options= connect_field_option_list; connect_hton->field_options= connect_field_option_list;
connect_hton->index_options= connect_index_option_list; connect_hton->index_options= connect_index_option_list;
...@@ -446,7 +448,7 @@ static int connect_init_func(void *p) ...@@ -446,7 +448,7 @@ static int connect_init_func(void *p)
DTVAL::SetTimeShift(); // Initialize time zone shift once for all DTVAL::SetTimeShift(); // Initialize time zone shift once for all
DBUG_RETURN(0); DBUG_RETURN(0);
} } // end of connect_init_func
/** /**
...@@ -476,13 +478,13 @@ static int connect_done_func(void *p) ...@@ -476,13 +478,13 @@ static int connect_done_func(void *p)
} // endfor pc } // endfor pc
DBUG_RETURN(error); DBUG_RETURN(error);
} } // end of connect_done_func
/** /**
@brief @brief
Example of simple lock controls. The "share" it creates is a 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 one of these? Well, you have pieces that are used for locking, and
they are needed to function. they are needed to function.
*/ */
...@@ -490,20 +492,22 @@ static int connect_done_func(void *p) ...@@ -490,20 +492,22 @@ static int connect_done_func(void *p)
CONNECT_SHARE *ha_connect::get_share() CONNECT_SHARE *ha_connect::get_share()
{ {
CONNECT_SHARE *tmp_share; CONNECT_SHARE *tmp_share;
lock_shared_ha_data(); 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; tmp_share= new CONNECT_SHARE;
if (!tmp_share) if (!tmp_share)
goto err; goto err;
mysql_mutex_init(con_key_mutex_CONNECT_SHARE_mutex, mysql_mutex_init(con_key_mutex_CONNECT_SHARE_mutex,
&tmp_share->mutex, MY_MUTEX_INIT_FAST); &tmp_share->mutex, MY_MUTEX_INIT_FAST);
set_ha_share_ptr(static_cast<Handler_share*>(tmp_share)); set_ha_share_ptr(static_cast<Handler_share*>(tmp_share));
} } // endif tmp_share
err:
err:
unlock_shared_ha_data(); unlock_shared_ha_data();
return tmp_share; return tmp_share;
} } // end of get_share
static handler* connect_create_handler(handlerton *hton, static handler* connect_create_handler(handlerton *hton,
...@@ -740,7 +744,7 @@ ulonglong ha_connect::table_flags() const ...@@ -740,7 +744,7 @@ ulonglong ha_connect::table_flags() const
} // end of table_flags } // 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, char *GetListOption(PGLOBAL g, const char *opname,
const char *oplist, const char *def) const char *oplist, const char *def)
...@@ -2717,7 +2721,7 @@ int ha_connect::index_init(uint idx, bool sorted) ...@@ -2717,7 +2721,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
...@@ -3133,6 +3137,10 @@ void ha_connect::position(const uchar *record) ...@@ -3133,6 +3137,10 @@ void ha_connect::position(const uchar *record)
DBUG_ENTER("ha_connect::position"); DBUG_ENTER("ha_connect::position");
//if (((PTDBASE)tdbp)->GetDef()->Indexable()) //if (((PTDBASE)tdbp)->GetDef()->Indexable())
my_store_ptr(ref, ref_length, (my_off_t)((PTDBASE)tdbp)->GetRecpos()); 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; DBUG_VOID_RETURN;
} // end of position } // end of position
...@@ -3159,9 +3167,13 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos) ...@@ -3159,9 +3167,13 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos)
PTDBASE tp= (PTDBASE)tdbp; PTDBASE tp= (PTDBASE)tdbp;
DBUG_ENTER("ha_connect::rnd_pos"); 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); rc= rnd_next(buf);
else } else
rc= HA_ERR_KEY_NOT_FOUND; rc= HA_ERR_KEY_NOT_FOUND;
DBUG_RETURN(rc); DBUG_RETURN(rc);
...@@ -4085,7 +4097,8 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key, ...@@ -4085,7 +4097,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, ...@@ -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
......
...@@ -35,7 +35,7 @@ Warning 1105 No table_type. Will be set to DOS ...@@ -35,7 +35,7 @@ Warning 1105 No table_type. Will be set to DOS
SELECT * FROM t2; SELECT * FROM t2;
line line
<?xml version="1.0" encoding="UTF-8"?> <?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> <t1>
<row> <row>
<TH>c</TH> <TH>c</TH>
...@@ -71,7 +71,7 @@ t1 CREATE TABLE `t1` ( ...@@ -71,7 +71,7 @@ t1 CREATE TABLE `t1` (
SELECT * FROM t2; SELECT * FROM t2;
line line
<?xml version="1.0" encoding="UTF-8"?> <?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> <t1>
<row d="One"> <row d="One">
<c>1</c> <c>1</c>
......
...@@ -416,7 +416,7 @@ DROP TABLE t1; ...@@ -416,7 +416,7 @@ DROP TABLE t1;
SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml'); SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml');
SELECT CAST(@a AS CHAR CHARACTER SET latin1); SELECT CAST(@a AS CHAR CHARACTER SET latin1);
CAST(@a AS CHAR CHARACTER SET latin1) <?xml version="1.0" encoding="iso-8859-1"?> 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> <t1>
<line> <line>
<node>ÀÁÂÃ</node> <node>ÀÁÂÃ</node>
......
/************** Table C++ Functions Source Code File (.CPP) ************/ /************** Table C++ Functions Source Code File (.CPP) ************/
/* Name: TABLE.CPP Version 2.7 */ /* Name: TABLE.CPP Version 2.7 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ /* (C) Copyright to the author Olivier BERTRAND 1999-2014 */
/* */ /* */
/* This file contains the TBX, TDB and OPJOIN classes functions. */ /* This file contains the TBX, TDB and OPJOIN classes functions. */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
/* Include relevant MariaDB header file. */ /* Include relevant MariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
/* global.h is header containing all global Plug declarations. */ /* global.h is header containing all global Plug declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */ /* plgdbsem.h is header containing the DB applic. declarations. */
/* xobject.h is header containing XOBJECT derived classes declares. */ /* xobject.h is header containing XOBJECT derived classes declares. */
/***********************************************************************/ /***********************************************************************/
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"
#include "xtable.h" #include "xtable.h"
#include "tabcol.h" #include "tabcol.h"
#include "filamtxt.h" #include "filamtxt.h"
#include "tabdos.h" #include "tabdos.h"
//#include "catalog.h" //#include "catalog.h"
#include "reldef.h" #include "reldef.h"
int TDB::Tnum = 0; int TDB::Tnum = 0;
extern "C" int trace; // The general trace value extern "C" int trace; // The general trace value
/***********************************************************************/ /***********************************************************************/
/* Utility routines. */ /* Utility routines. */
/***********************************************************************/ /***********************************************************************/
void NewPointer(PTABS, void *, void *); void NewPointer(PTABS, void *, void *);
void AddPointer(PTABS, void *); void AddPointer(PTABS, void *);
/* ---------------------------- class TDB ---------------------------- */ /* ---------------------------- class TDB ---------------------------- */
/***********************************************************************/ /***********************************************************************/
/* TDB public constructors. */ /* TDB public constructors. */
/***********************************************************************/ /***********************************************************************/
TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum) TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum)
{ {
Use = USE_NO; Use = USE_NO;
To_Orig = NULL; To_Orig = NULL;
To_Filter = NULL; To_Filter = NULL;
To_CondFil = NULL; To_CondFil = NULL;
Next = NULL; Next = NULL;
Name = (tdp) ? tdp->GetName() : NULL; Name = (tdp) ? tdp->GetName() : NULL;
To_Table = NULL; To_Table = NULL;
Columns = NULL; Columns = NULL;
Degree = (tdp) ? tdp->GetDegree() : 0; Degree = (tdp) ? tdp->GetDegree() : 0;
Mode = MODE_READ; Mode = MODE_READ;
} // end of TDB standard constructor } // end of TDB standard constructor
TDB::TDB(PTDB tdbp) : Tdb_No(++Tnum) TDB::TDB(PTDB tdbp) : Tdb_No(++Tnum)
{ {
Use = tdbp->Use; Use = tdbp->Use;
To_Orig = tdbp; To_Orig = tdbp;
To_Filter = NULL; To_Filter = NULL;
To_CondFil = NULL; To_CondFil = NULL;
Next = NULL; Next = NULL;
Name = tdbp->Name; Name = tdbp->Name;
To_Table = tdbp->To_Table; To_Table = tdbp->To_Table;
Columns = NULL; Columns = NULL;
Degree = tdbp->Degree; Degree = tdbp->Degree;
Mode = tdbp->Mode; Mode = tdbp->Mode;
} // end of TDB copy constructor } // end of TDB copy constructor
// Methods // Methods
/***********************************************************************/ /***********************************************************************/
/* RowNumber: returns the current row ordinal number. */ /* RowNumber: returns the current row ordinal number. */
/***********************************************************************/ /***********************************************************************/
int TDB::RowNumber(PGLOBAL g, bool b) int TDB::RowNumber(PGLOBAL g, bool b)
{ {
sprintf(g->Message, MSG(ROWID_NOT_IMPL), GetAmName(g, GetAmType())); sprintf(g->Message, MSG(ROWID_NOT_IMPL), GetAmName(g, GetAmType()));
return 0; return 0;
} // end of RowNumber } // end of RowNumber
PTDB TDB::Copy(PTABS t) PTDB TDB::Copy(PTABS t)
{ {
PTDB tp, tdb1, tdb2 = NULL, outp = NULL; PTDB tp, tdb1, tdb2 = NULL, outp = NULL;
//PGLOBAL g = t->G; // Is this really useful ??? //PGLOBAL g = t->G; // Is this really useful ???
for (tdb1 = this; tdb1; tdb1 = tdb1->Next) { for (tdb1 = this; tdb1; tdb1 = tdb1->Next) {
tp = tdb1->CopyOne(t); tp = tdb1->CopyOne(t);
if (!outp) if (!outp)
outp = tp; outp = tp;
else else
tdb2->Next = tp; tdb2->Next = tp;
tdb2 = tp; tdb2 = tp;
NewPointer(t, tdb1, tdb2); NewPointer(t, tdb1, tdb2);
} // endfor tdb1 } // endfor tdb1
return outp; return outp;
} // end of Copy } // end of Copy
void TDB::Print(PGLOBAL g, FILE *f, uint n) void TDB::Print(PGLOBAL g, FILE *f, uint n)
{ {
PCOL cp; PCOL cp;
char m[64]; char m[64];
memset(m, ' ', n); // Make margin string memset(m, ' ', n); // Make margin string
m[n] = '\0'; m[n] = '\0';
for (PTDB tp = this; tp; tp = tp->Next) { for (PTDB tp = this; tp; tp = tp->Next) {
fprintf(f, "%sTDB (%p) %s no=%d use=%d type=%d\n", m, fprintf(f, "%sTDB (%p) %s no=%d use=%d type=%d\n", m,
tp, tp->Name, tp->Tdb_No, tp->Use, tp->GetAmType()); tp, tp->Name, tp->Tdb_No, tp->Use, tp->GetAmType());
tp->PrintAM(f, m); tp->PrintAM(f, m);
fprintf(f, "%s Columns (deg=%d):\n", m, tp->Degree); fprintf(f, "%s Columns (deg=%d):\n", m, tp->Degree);
for (cp = tp->Columns; cp; cp = cp->GetNext()) for (cp = tp->Columns; cp; cp = cp->GetNext())
cp->Print(g, f, n); cp->Print(g, f, n);
} /* endfor tp */ } /* endfor tp */
} // end of Print } // end of Print
void TDB::Print(PGLOBAL g, char *ps, uint z) void TDB::Print(PGLOBAL g, char *ps, uint z)
{ {
sprintf(ps, "R%d.%s", Tdb_No, Name); sprintf(ps, "R%d.%s", Tdb_No, Name);
} // end of Print } // end of Print
/* -------------------------- class TDBASE --------------------------- */ /* -------------------------- class TDBASE --------------------------- */
/***********************************************************************/ /***********************************************************************/
/* Implementation of the TDBASE class. This is the base class to all */ /* Implementation of the TDBASE class. This is the base class to all */
/* classes for tables that can be joined together. */ /* classes for tables that can be joined together. */
/***********************************************************************/ /***********************************************************************/
TDBASE::TDBASE(PTABDEF tdp) : TDB(tdp) TDBASE::TDBASE(PTABDEF tdp) : TDB(tdp)
{ {
To_Def = tdp; To_Def = tdp;
To_Link = NULL; To_Link = NULL;
To_Key_Col = NULL; To_Key_Col = NULL;
To_Kindex = NULL; To_Kindex = NULL;
To_Xdp = NULL; To_Xdp = NULL;
To_SetCols = NULL; To_SetCols = NULL;
MaxSize = -1; MaxSize = -1;
Knum = 0; Knum = 0;
Read_Only = (tdp) ? tdp->IsReadOnly() : false; Read_Only = (tdp) ? tdp->IsReadOnly() : false;
m_data_charset= (tdp) ? tdp->data_charset() : NULL; m_data_charset= (tdp) ? tdp->data_charset() : NULL;
} // end of TDBASE constructor } // end of TDBASE constructor
TDBASE::TDBASE(PTDBASE tdbp) : TDB(tdbp) TDBASE::TDBASE(PTDBASE tdbp) : TDB(tdbp)
{ {
To_Def = tdbp->To_Def; To_Def = tdbp->To_Def;
To_Link = tdbp->To_Link; To_Link = tdbp->To_Link;
To_Key_Col = tdbp->To_Key_Col; To_Key_Col = tdbp->To_Key_Col;
To_Kindex = tdbp->To_Kindex; To_Kindex = tdbp->To_Kindex;
To_Xdp = tdbp->To_Xdp; To_Xdp = tdbp->To_Xdp;
To_SetCols = tdbp->To_SetCols; // ??? To_SetCols = tdbp->To_SetCols; // ???
MaxSize = tdbp->MaxSize; MaxSize = tdbp->MaxSize;
Knum = tdbp->Knum; Knum = tdbp->Knum;
Read_Only = tdbp->Read_Only; Read_Only = tdbp->Read_Only;
m_data_charset= tdbp->m_data_charset; m_data_charset= tdbp->m_data_charset;
} // end of TDBASE copy constructor } // end of TDBASE copy constructor
/***********************************************************************/ /***********************************************************************/
/* Return the pointer on the DB catalog this table belongs to. */ /* Return the pointer on the DB catalog this table belongs to. */
/***********************************************************************/ /***********************************************************************/
PCATLG TDBASE::GetCat(void) PCATLG TDBASE::GetCat(void)
{ {
return (To_Def) ? To_Def->GetCat() : NULL; return (To_Def) ? To_Def->GetCat() : NULL;
} // end of GetCat } // end of GetCat
/***********************************************************************/ /***********************************************************************/
/* Return the pointer on the charset of this table. */ /* Return the pointer on the charset of this table. */
/***********************************************************************/ /***********************************************************************/
CHARSET_INFO *TDBASE::data_charset(void) CHARSET_INFO *TDBASE::data_charset(void)
{ {
// If no DATA_CHARSET is specified, we assume that character // If no DATA_CHARSET is specified, we assume that character
// set of the remote data is the same with CHARACTER SET // set of the remote data is the same with CHARACTER SET
// definition of the SQL column. // definition of the SQL column.
return m_data_charset ? m_data_charset : &my_charset_bin; return m_data_charset ? m_data_charset : &my_charset_bin;
} // end of data_charset } // end of data_charset
/***********************************************************************/ /***********************************************************************/
/* Return the datapath of the DB this table belongs to. */ /* Return the datapath of the DB this table belongs to. */
/***********************************************************************/ /***********************************************************************/
PSZ TDBASE::GetPath(void) PSZ TDBASE::GetPath(void)
{ {
return To_Def->GetPath(); return To_Def->GetPath();
} // end of GetPath } // end of GetPath
/***********************************************************************/ /***********************************************************************/
/* Initialize TDBASE based column description block construction. */ /* Initialize TDBASE based column description block construction. */
/* name is used to call columns by name. */ /* name is used to call columns by name. */
/* num is used by TBL to construct columns by index number. */ /* num is used by TBL to construct columns by index number. */
/* Note: name=Null and num=0 for constructing all columns (select *) */ /* Note: name=Null and num=0 for constructing all columns (select *) */
/***********************************************************************/ /***********************************************************************/
PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num) PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num)
{ {
int i; int i;
PCOLDEF cdp; PCOLDEF cdp;
PCOL cp, colp = NULL, cprec = NULL; PCOL cp, colp = NULL, cprec = NULL;
if (trace) if (trace)
htrc("ColDB: am=%d colname=%s tabname=%s num=%d\n", htrc("ColDB: am=%d colname=%s tabname=%s num=%d\n",
GetAmType(), SVP(name), Name, num); GetAmType(), SVP(name), Name, num);
for (cdp = To_Def->GetCols(), i = 1; cdp; cdp = cdp->GetNext(), i++) for (cdp = To_Def->GetCols(), i = 1; cdp; cdp = cdp->GetNext(), i++)
if ((!name && !num) || if ((!name && !num) ||
(name && !stricmp(cdp->GetName(), name)) || num == i) { (name && !stricmp(cdp->GetName(), name)) || num == i) {
/*****************************************************************/ /*****************************************************************/
/* Check for existence of desired column. */ /* Check for existence of desired column. */
/* Also find where to insert the new block. */ /* Also find where to insert the new block. */
/*****************************************************************/ /*****************************************************************/
for (cp = Columns; cp; cp = cp->GetNext()) for (cp = Columns; cp; cp = cp->GetNext())
if (cp->GetIndex() < i) if (cp->GetIndex() < i)
cprec = cp; cprec = cp;
else if (cp->GetIndex() == i) else if (cp->GetIndex() == i)
break; break;
if (trace) if (trace)
htrc("cdp(%d).Name=%s cp=%p\n", i, cdp->GetName(), cp); htrc("cdp(%d).Name=%s cp=%p\n", i, cdp->GetName(), cp);
/*****************************************************************/ /*****************************************************************/
/* Now take care of Column Description Block. */ /* Now take care of Column Description Block. */
/*****************************************************************/ /*****************************************************************/
if (cp) if (cp)
colp = cp; colp = cp;
else if (!(cdp->Flags & U_SPECIAL)) else if (!(cdp->Flags & U_SPECIAL))
colp = MakeCol(g, cdp, cprec, i); colp = MakeCol(g, cdp, cprec, i);
else if (Mode == MODE_READ) else if (Mode == MODE_READ)
colp = InsertSpcBlk(g, cdp); colp = InsertSpcBlk(g, cdp);
if (trace) if (trace)
htrc("colp=%p\n", colp); htrc("colp=%p\n", colp);
if (name || num) if (name || num)
break; break;
else if (colp && !colp->IsSpecial()) else if (colp && !colp->IsSpecial())
cprec = colp; cprec = colp;
} // endif Name } // endif Name
return (colp); return (colp);
} // end of ColDB } // end of ColDB
/***********************************************************************/ /***********************************************************************/
/* InsertSpecialColumn: Put a special column ahead of the column list.*/ /* InsertSpecialColumn: Put a special column ahead of the column list.*/
/***********************************************************************/ /***********************************************************************/
PCOL TDBASE::InsertSpecialColumn(PGLOBAL g, PCOL colp) PCOL TDBASE::InsertSpecialColumn(PGLOBAL g, PCOL colp)
{ {
if (!colp->IsSpecial()) if (!colp->IsSpecial())
return NULL; return NULL;
colp->SetNext(Columns); colp->SetNext(Columns);
Columns = colp; Columns = colp;
return colp; return colp;
} // end of InsertSpecialColumn } // end of InsertSpecialColumn
/***********************************************************************/ /***********************************************************************/
/* Make a special COLBLK to insert in a table. */ /* Make a special COLBLK to insert in a table. */
/***********************************************************************/ /***********************************************************************/
PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp) PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp)
{ {
//char *name = cdp->GetName(); //char *name = cdp->GetName();
char *name = cdp->GetFmt(); char *name = cdp->GetFmt();
PCOLUMN cp; PCOLUMN cp;
PCOL colp; PCOL colp;
cp= new(g) COLUMN(cdp->GetName()); cp= new(g) COLUMN(cdp->GetName());
cp->SetTo_Table(To_Table); cp->SetTo_Table(To_Table);
if (!stricmp(name, "FILEID") || if (!stricmp(name, "FILEID") ||
!stricmp(name, "SERVID")) { !stricmp(name, "SERVID")) {
if (!To_Def || !(To_Def->GetPseudo() & 2)) { if (!To_Def || !(To_Def->GetPseudo() & 2)) {
sprintf(g->Message, MSG(BAD_SPEC_COLUMN)); sprintf(g->Message, MSG(BAD_SPEC_COLUMN));
return NULL; return NULL;
} // endif Pseudo } // endif Pseudo
if (!stricmp(name, "FILEID")) if (!stricmp(name, "FILEID"))
colp = new(g) FIDBLK(cp); colp = new(g) FIDBLK(cp);
else else
colp = new(g) SIDBLK(cp); colp = new(g) SIDBLK(cp);
} else if (!stricmp(name, "TABID")) { } else if (!stricmp(name, "TABID")) {
colp = new(g) TIDBLK(cp); colp = new(g) TIDBLK(cp);
//} else if (!stricmp(name, "CONID")) { //} else if (!stricmp(name, "CONID")) {
// colp = new(g) CIDBLK(cp); // colp = new(g) CIDBLK(cp);
} else if (!stricmp(name, "ROWID")) { } else if (!stricmp(name, "ROWID")) {
colp = new(g) RIDBLK(cp, false); colp = new(g) RIDBLK(cp, false);
} else if (!stricmp(name, "ROWNUM")) { } else if (!stricmp(name, "ROWNUM")) {
colp = new(g) RIDBLK(cp, true); colp = new(g) RIDBLK(cp, true);
} else { } else {
sprintf(g->Message, MSG(BAD_SPECIAL_COL), name); sprintf(g->Message, MSG(BAD_SPECIAL_COL), name);
return NULL; return NULL;
} // endif's name } // endif's name
if (!(colp = InsertSpecialColumn(g, colp))) { if (!(colp = InsertSpecialColumn(g, colp))) {
sprintf(g->Message, MSG(BAD_SPECIAL_COL), name); sprintf(g->Message, MSG(BAD_SPECIAL_COL), name);
return NULL; return NULL;
} // endif Insert } // endif Insert
return (colp); return (colp);
} // end of InsertSpcBlk } // end of InsertSpcBlk
/***********************************************************************/ /***********************************************************************/
/* ResetTableOpt: Wrong for this table type. */ /* ResetTableOpt: Wrong for this table type. */
/***********************************************************************/ /***********************************************************************/
int TDBASE::ResetTableOpt(PGLOBAL g, bool dop, bool dox) int TDBASE::ResetTableOpt(PGLOBAL g, bool dop, bool dox)
{ {
strcpy(g->Message, "This table is not indexable"); strcpy(g->Message, "This table is not indexable");
return RC_INFO; return RC_INFO;
} // end of ResetTableOpt } // end of ResetTableOpt
/***********************************************************************/ /***********************************************************************/
/* SetKindex: set or reset the index pointer. */ /* ResetKindex: set or reset the index pointer. */
/***********************************************************************/ /***********************************************************************/
void TDBASE::SetKindex(PGLOBAL g, PKXBASE kxp) void TDBASE::ResetKindex(PGLOBAL g, PKXBASE kxp)
{ {
if (To_Kindex) { if (To_Kindex) {
int pos = GetRecpos(); // To be reset in Txfp int pos = GetRecpos(); // To be reset in Txfp
To_Kindex->Close(); // Discard old index for (PCOL colp= Columns; colp; colp= colp->GetNext())
SetRecpos(g, pos); // Ignore return value colp->SetKcol(NULL);
} // endif To_Kindex
To_Kindex->Close(); // Discard old index
To_Kindex = kxp; SetRecpos(g, pos); // Ignore return value
} // end of SetKindex } // endif To_Kindex
/***********************************************************************/ To_Kindex = kxp;
/* SetRecpos: Replace the table at the specified position. */ } // end of ResetKindex
/***********************************************************************/
bool TDBASE::SetRecpos(PGLOBAL g, int recpos) /***********************************************************************/
{ /* SetRecpos: Replace the table at the specified position. */
strcpy(g->Message, MSG(SETRECPOS_NIY)); /***********************************************************************/
return true; bool TDBASE::SetRecpos(PGLOBAL g, int recpos)
} // end of SetRecpos {
strcpy(g->Message, MSG(SETRECPOS_NIY));
/***********************************************************************/ return true;
/* Methods */ } // end of SetRecpos
/***********************************************************************/
void TDBASE::PrintAM(FILE *f, char *m) /***********************************************************************/
{ /* Methods */
fprintf(f, "%s AM(%d): mode=%d\n", m, GetAmType(), Mode); /***********************************************************************/
} // end of PrintAM void TDBASE::PrintAM(FILE *f, char *m)
{
/***********************************************************************/ fprintf(f, "%s AM(%d): mode=%d\n", m, GetAmType(), Mode);
/* Marks DOS/MAP table columns used in internal joins. */ } // end of PrintAM
/* tdb2 is the top of tree or first tdb in chained tdb's and tdbp */
/* points to the currently marked tdb. */ /***********************************************************************/
/* Two questions here: exact meaning of U_J_INT ? */ /* Marks DOS/MAP table columns used in internal joins. */
/* Why is the eventual reference to To_Key_Col not marked U_J_EXT ? */ /* tdb2 is the top of tree or first tdb in chained tdb's and tdbp */
/***********************************************************************/ /* points to the currently marked tdb. */
void TDBASE::MarkDB(PGLOBAL g, PTDB tdb2) /* Two questions here: exact meaning of U_J_INT ? */
{ /* Why is the eventual reference to To_Key_Col not marked U_J_EXT ? */
if (trace) /***********************************************************************/
htrc("DOS MarkDB: tdbp=%p tdb2=%p\n", this, tdb2); void TDBASE::MarkDB(PGLOBAL g, PTDB tdb2)
{
} // end of MarkDB if (trace)
htrc("DOS MarkDB: tdbp=%p tdb2=%p\n", this, tdb2);
/* ---------------------------TDBCAT class --------------------------- */
} // end of MarkDB
/***********************************************************************/
/* Implementation of the TDBCAT class. */ /* ---------------------------TDBCAT class --------------------------- */
/***********************************************************************/
TDBCAT::TDBCAT(PTABDEF tdp) : TDBASE(tdp) /***********************************************************************/
{ /* Implementation of the TDBCAT class. */
Qrp = NULL; /***********************************************************************/
Init = false; TDBCAT::TDBCAT(PTABDEF tdp) : TDBASE(tdp)
N = -1; {
} // end of TDBCAT constructor Qrp = NULL;
Init = false;
/***********************************************************************/ N = -1;
/* Allocate CAT column description block. */ } // end of TDBCAT constructor
/***********************************************************************/
PCOL TDBCAT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /***********************************************************************/
{ /* Allocate CAT column description block. */
PCATCOL colp; /***********************************************************************/
PCOL TDBCAT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
colp = (PCATCOL)new(g) CATCOL(cdp, this, n); {
PCATCOL colp;
if (cprec) {
colp->SetNext(cprec->GetNext()); colp = (PCATCOL)new(g) CATCOL(cdp, this, n);
cprec->SetNext(colp);
} else { if (cprec) {
colp->SetNext(Columns); colp->SetNext(cprec->GetNext());
Columns = colp; cprec->SetNext(colp);
} // endif cprec } else {
colp->SetNext(Columns);
return colp; Columns = colp;
} // end of MakeCol } // endif cprec
/***********************************************************************/ return colp;
/* Initialize: Get the result query block. */ } // end of MakeCol
/***********************************************************************/
bool TDBCAT::Initialize(PGLOBAL g) /***********************************************************************/
{ /* Initialize: Get the result query block. */
if (Init) /***********************************************************************/
return false; bool TDBCAT::Initialize(PGLOBAL g)
{
if (!(Qrp = GetResult(g))) if (Init)
return true; return false;
if (Qrp->Truncated) { if (!(Qrp = GetResult(g)))
sprintf(g->Message, "Result limited to %d lines", Qrp->Maxres); return true;
PushWarning(g, this);
} // endif Truncated if (Qrp->Truncated) {
sprintf(g->Message, "Result limited to %d lines", Qrp->Maxres);
if (Qrp->BadLines) { PushWarning(g, this);
sprintf(g->Message, "%d bad lines in result", Qrp->BadLines); } // endif Truncated
PushWarning(g, this);
} // endif Badlines if (Qrp->BadLines) {
sprintf(g->Message, "%d bad lines in result", Qrp->BadLines);
Init = true; PushWarning(g, this);
return false; } // endif Badlines
} // end of Initialize
Init = true;
/***********************************************************************/ return false;
/* CAT: Get the number of properties. */ } // end of Initialize
/***********************************************************************/
int TDBCAT::GetMaxSize(PGLOBAL g) /***********************************************************************/
{ /* CAT: Get the number of properties. */
if (MaxSize < 0) { /***********************************************************************/
// if (Initialize(g)) int TDBCAT::GetMaxSize(PGLOBAL g)
// return -1; {
if (MaxSize < 0) {
// MaxSize = Qrp->Nblin; // if (Initialize(g))
MaxSize = 10; // To make MariaDB happy // return -1;
} // endif MaxSize
// MaxSize = Qrp->Nblin;
return MaxSize; MaxSize = 10; // To make MariaDB happy
} // end of GetMaxSize } // endif MaxSize
/***********************************************************************/ return MaxSize;
/* CAT Access Method opening routine. */ } // end of GetMaxSize
/***********************************************************************/
bool TDBCAT::OpenDB(PGLOBAL g) /***********************************************************************/
{ /* CAT Access Method opening routine. */
if (Use == USE_OPEN) { /***********************************************************************/
/*******************************************************************/ bool TDBCAT::OpenDB(PGLOBAL g)
/* Table already open. */ {
/*******************************************************************/ if (Use == USE_OPEN) {
N = -1; /*******************************************************************/
return false; /* Table already open. */
} // endif use /*******************************************************************/
N = -1;
if (Mode != MODE_READ) { return false;
/*******************************************************************/ } // endif use
/* ODBC Info tables cannot be modified. */
/*******************************************************************/ if (Mode != MODE_READ) {
strcpy(g->Message, "CAT tables are read only"); /*******************************************************************/
return true; /* ODBC Info tables cannot be modified. */
} // endif Mode /*******************************************************************/
strcpy(g->Message, "CAT tables are read only");
/*********************************************************************/ return true;
/* Initialize the ODBC processing. */ } // endif Mode
/*********************************************************************/
if (Initialize(g)) /*********************************************************************/
return true; /* Initialize the ODBC processing. */
/*********************************************************************/
Use = USE_OPEN; if (Initialize(g))
return InitCol(g); return true;
} // end of OpenDB
Use = USE_OPEN;
/***********************************************************************/ return InitCol(g);
/* Initialize columns. */ } // end of OpenDB
/***********************************************************************/
bool TDBCAT::InitCol(PGLOBAL g) /***********************************************************************/
{ /* Initialize columns. */
PCATCOL colp; /***********************************************************************/
PCOLRES crp; bool TDBCAT::InitCol(PGLOBAL g)
{
for (colp = (PCATCOL)Columns; colp; colp = (PCATCOL)colp->GetNext()) { PCATCOL colp;
for (crp = Qrp->Colresp; crp; crp = crp->Next) PCOLRES crp;
if ((colp->Flag && colp->Flag == crp->Fld) ||
(!colp->Flag && !stricmp(colp->Name, crp->Name))) { for (colp = (PCATCOL)Columns; colp; colp = (PCATCOL)colp->GetNext()) {
colp->Crp = crp; for (crp = Qrp->Colresp; crp; crp = crp->Next)
break; if ((colp->Flag && colp->Flag == crp->Fld) ||
} // endif Flag (!colp->Flag && !stricmp(colp->Name, crp->Name))) {
colp->Crp = crp;
break;
if (!colp->Crp /*&& !colp->GetValue()->IsConstant()*/) { } // endif Flag
sprintf(g->Message, "Invalid flag %d for column %s",
colp->Flag, colp->Name);
return true; if (!colp->Crp /*&& !colp->GetValue()->IsConstant()*/) {
} // endif Crp sprintf(g->Message, "Invalid flag %d for column %s",
colp->Flag, colp->Name);
} // endfor colp return true;
} // endif Crp
return false;
} // end of InitCol } // endfor colp
/***********************************************************************/ return false;
/* SetRecpos: Replace the table at the specified position. */ } // end of InitCol
/***********************************************************************/
bool TDBCAT::SetRecpos(PGLOBAL g, int recpos) /***********************************************************************/
{ /* SetRecpos: Replace the table at the specified position. */
N = recpos - 1; /***********************************************************************/
return false; bool TDBCAT::SetRecpos(PGLOBAL g, int recpos)
} // end of SetRecpos {
N = recpos - 1;
/***********************************************************************/ return false;
/* Data Base read routine for CAT access method. */ } // end of SetRecpos
/***********************************************************************/
int TDBCAT::ReadDB(PGLOBAL g) /***********************************************************************/
{ /* Data Base read routine for CAT access method. */
return (++N < Qrp->Nblin) ? RC_OK : RC_EF; /***********************************************************************/
} // end of ReadDB int TDBCAT::ReadDB(PGLOBAL g)
{
/***********************************************************************/ return (++N < Qrp->Nblin) ? RC_OK : RC_EF;
/* WriteDB: Data Base write routine for CAT access methods. */ } // end of ReadDB
/***********************************************************************/
int TDBCAT::WriteDB(PGLOBAL g) /***********************************************************************/
{ /* WriteDB: Data Base write routine for CAT access methods. */
strcpy(g->Message, "CAT tables are read only"); /***********************************************************************/
return RC_FX; int TDBCAT::WriteDB(PGLOBAL g)
} // end of WriteDB {
strcpy(g->Message, "CAT tables are read only");
/***********************************************************************/ return RC_FX;
/* Data Base delete line routine for CAT access methods. */ } // end of WriteDB
/***********************************************************************/
int TDBCAT::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/
{ /* Data Base delete line routine for CAT access methods. */
strcpy(g->Message, "Delete not enabled for CAT tables"); /***********************************************************************/
return RC_FX; int TDBCAT::DeleteDB(PGLOBAL g, int irc)
} // end of DeleteDB {
strcpy(g->Message, "Delete not enabled for CAT tables");
/***********************************************************************/ return RC_FX;
/* Data Base close routine for WMI access method. */ } // end of DeleteDB
/***********************************************************************/
void TDBCAT::CloseDB(PGLOBAL g) /***********************************************************************/
{ /* Data Base close routine for WMI access method. */
// Nothing to do /***********************************************************************/
} // end of CloseDB void TDBCAT::CloseDB(PGLOBAL g)
{
// ------------------------ CATCOL functions ---------------------------- // Nothing to do
} // end of CloseDB
/***********************************************************************/
/* CATCOL public constructor. */ // ------------------------ CATCOL functions ----------------------------
/***********************************************************************/
CATCOL::CATCOL(PCOLDEF cdp, PTDB tdbp, int n) /***********************************************************************/
: COLBLK(cdp, tdbp, n) /* CATCOL public constructor. */
{ /***********************************************************************/
Tdbp = (PTDBCAT)tdbp; CATCOL::CATCOL(PCOLDEF cdp, PTDB tdbp, int n)
Crp = NULL; : COLBLK(cdp, tdbp, n)
Flag = cdp->GetOffset(); {
} // end of WMICOL constructor Tdbp = (PTDBCAT)tdbp;
Crp = NULL;
/***********************************************************************/ Flag = cdp->GetOffset();
/* Read the next Data Source elements. */ } // end of WMICOL constructor
/***********************************************************************/
void CATCOL::ReadColumn(PGLOBAL g) /***********************************************************************/
{ /* Read the next Data Source elements. */
// Get the value of the Name or Description property /***********************************************************************/
Value->SetValue_pvblk(Crp->Kdata, Tdbp->N); void CATCOL::ReadColumn(PGLOBAL g)
} // end of ReadColumn {
// Get the value of the Name or Description property
Value->SetValue_pvblk(Crp->Kdata, Tdbp->N);
} // end of ReadColumn
...@@ -522,8 +522,8 @@ bool TDBXML::Initialize(PGLOBAL g) ...@@ -522,8 +522,8 @@ bool TDBXML::Initialize(PGLOBAL g)
To_Xb = Docp->LinkXblock(g, Mode, rc, filename); To_Xb = Docp->LinkXblock(g, Mode, rc, filename);
// Add a CONNECT comment node // 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); Docp->AddComment(g, buf);
if (XmlDB) { if (XmlDB) {
......
...@@ -684,11 +684,14 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) ...@@ -684,11 +684,14 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
if (SaveIndex(g, sxp)) if (SaveIndex(g, sxp))
brc = true; brc = true;
} else // Dynamic index } else { // Dynamic index
// Indicate that key column values can be found from KEYCOL's // Indicate that key column values can be found from KEYCOL's
for (kcp = To_KeyCol; kcp; kcp = kcp->Next) for (kcp = To_KeyCol; kcp; kcp = kcp->Next)
kcp->Colp->SetKcol(kcp); kcp->Colp->SetKcol(kcp);
Tdbp->SetFilter(NULL); // Not used anymore
} // endif X
err: err:
// We don't need the index anymore // We don't need the index anymore
if (X || brc) if (X || brc)
...@@ -2234,9 +2237,6 @@ int XINDXS::FastFind(int nk) ...@@ -2234,9 +2237,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
...@@ -2250,15 +2250,6 @@ void XLOAD::Close(void) ...@@ -2250,15 +2250,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 --------------------------- */
...@@ -2269,9 +2260,9 @@ void XLOAD::Close(void) ...@@ -2269,9 +2260,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
/***********************************************************************/ /***********************************************************************/
...@@ -2414,11 +2405,9 @@ void XFILE::Close(void) ...@@ -2414,11 +2405,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
...@@ -2955,8 +2944,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln) ...@@ -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 // 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();
...@@ -2992,7 +2980,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln) ...@@ -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) 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) {
...@@ -3002,12 +2990,12 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m) ...@@ -3002,12 +2990,12 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
Type = colp->GetResultType(); Type = colp->GetResultType();
if (trace) if (trace)
htrc("MapInit(%p): colp=%p type=%d n=%d len=%d m=%p\n", htrc("MapInit(%p): colp=%p type=%d n=%d len=%d m=%p\n",
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]) {
...@@ -3027,7 +3015,7 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m) ...@@ -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). // 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);
...@@ -3038,6 +3026,7 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m) ...@@ -3038,6 +3026,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
......
...@@ -347,9 +347,6 @@ class DllExport XLOAD : public BLOCK { ...@@ -347,9 +347,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
...@@ -377,9 +374,9 @@ class DllExport XFILE : public XLOAD { ...@@ -377,9 +374,9 @@ class DllExport XFILE : public XLOAD {
protected: protected:
// 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
......
...@@ -146,9 +146,10 @@ class DllExport TDBASE : public TDB { ...@@ -146,9 +146,10 @@ class DllExport TDBASE : public TDB {
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 SetXdp(PIXDEF xdp) {To_Xdp = xdp;} inline void SetXdp(PIXDEF xdp) {To_Xdp = xdp;}
inline void SetKindex(PKXBASE kxp) {To_Kindex = kxp;}
// Properties // 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;} PCOL Key(int i) {return (To_Key_Col) ? To_Key_Col[i] : NULL;}
// Methods // 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