summaryrefslogtreecommitdiff
path: root/storage/connect
diff options
context:
space:
mode:
Diffstat (limited to 'storage/connect')
-rw-r--r--storage/connect/connect.cc15
-rw-r--r--storage/connect/filter.cpp2
-rw-r--r--storage/connect/ha_connect.cc49
-rw-r--r--storage/connect/maputil.cpp11
-rw-r--r--storage/connect/mysql-test/connect/r/alter_xml.result4
-rw-r--r--storage/connect/mysql-test/connect/r/xml.result2
-rw-r--r--storage/connect/table.cpp1115
-rw-r--r--storage/connect/tabxml.cpp4
-rwxr-xr-xstorage/connect/xindex.cpp45
-rw-r--r--storage/connect/xindex.h7
-rw-r--r--storage/connect/xtable.h3
11 files changed, 637 insertions, 620 deletions
diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc
index 9e551f2ccc7..70f05b242d5 100644
--- a/storage/connect/connect.cc
+++ b/storage/connect/connect.cc
@@ -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);
diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp
index 9b646ca58b9..229b6f7b0ec 100644
--- a/storage/connect/filter.cpp
+++ b/storage/connect/filter.cpp
@@ -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());
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index ae9de333054..37141e5c290 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -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);
diff --git a/storage/connect/maputil.cpp b/storage/connect/maputil.cpp
index b7032f10d2b..7104259ebad 100644
--- a/storage/connect/maputil.cpp
+++ b/storage/connect/maputil.cpp
@@ -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
diff --git a/storage/connect/mysql-test/connect/r/alter_xml.result b/storage/connect/mysql-test/connect/r/alter_xml.result
index bd3b281b05b..f2250b78d2d 100644
--- a/storage/connect/mysql-test/connect/r/alter_xml.result
+++ b/storage/connect/mysql-test/connect/r/alter_xml.result
@@ -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>
diff --git a/storage/connect/mysql-test/connect/r/xml.result b/storage/connect/mysql-test/connect/r/xml.result
index 5018eec47fc..eea53bf55c7 100644
--- a/storage/connect/mysql-test/connect/r/xml.result
+++ b/storage/connect/mysql-test/connect/r/xml.result
@@ -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>
diff --git a/storage/connect/table.cpp b/storage/connect/table.cpp
index 6cd043ec9a9..42cca1d2691 100644
--- a/storage/connect/table.cpp
+++ b/storage/connect/table.cpp
@@ -1,556 +1,559 @@
-/************** Table C++ Functions Source Code File (.CPP) ************/
-/* Name: TABLE.CPP Version 2.7 */
-/* */
-/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */
-/* */
-/* This file contains the TBX, TDB and OPJOIN classes functions. */
-/***********************************************************************/
-
-/***********************************************************************/
-/* Include relevant MariaDB header file. */
-/***********************************************************************/
-#include "my_global.h"
-
-/***********************************************************************/
-/* Include required application header files */
-/* global.h is header containing all global Plug declarations. */
-/* plgdbsem.h is header containing the DB applic. declarations. */
-/* xobject.h is header containing XOBJECT derived classes declares. */
-/***********************************************************************/
-#include "global.h"
-#include "plgdbsem.h"
-#include "xtable.h"
-#include "tabcol.h"
-#include "filamtxt.h"
-#include "tabdos.h"
-//#include "catalog.h"
-#include "reldef.h"
-
-int TDB::Tnum = 0;
-
-extern "C" int trace; // The general trace value
-
-/***********************************************************************/
-/* Utility routines. */
-/***********************************************************************/
-void NewPointer(PTABS, void *, void *);
-void AddPointer(PTABS, void *);
-
-/* ---------------------------- class TDB ---------------------------- */
-
-/***********************************************************************/
-/* TDB public constructors. */
-/***********************************************************************/
-TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum)
- {
- Use = USE_NO;
- To_Orig = NULL;
- To_Filter = NULL;
- To_CondFil = NULL;
- Next = NULL;
- Name = (tdp) ? tdp->GetName() : NULL;
- To_Table = NULL;
- Columns = NULL;
- Degree = (tdp) ? tdp->GetDegree() : 0;
- Mode = MODE_READ;
- } // end of TDB standard constructor
-
-TDB::TDB(PTDB tdbp) : Tdb_No(++Tnum)
- {
- Use = tdbp->Use;
- To_Orig = tdbp;
- To_Filter = NULL;
- To_CondFil = NULL;
- Next = NULL;
- Name = tdbp->Name;
- To_Table = tdbp->To_Table;
- Columns = NULL;
- Degree = tdbp->Degree;
- Mode = tdbp->Mode;
- } // end of TDB copy constructor
-
-// Methods
-
-/***********************************************************************/
-/* RowNumber: returns the current row ordinal number. */
-/***********************************************************************/
-int TDB::RowNumber(PGLOBAL g, bool b)
- {
- sprintf(g->Message, MSG(ROWID_NOT_IMPL), GetAmName(g, GetAmType()));
- return 0;
- } // end of RowNumber
-
-PTDB TDB::Copy(PTABS t)
- {
- PTDB tp, tdb1, tdb2 = NULL, outp = NULL;
-//PGLOBAL g = t->G; // Is this really useful ???
-
- for (tdb1 = this; tdb1; tdb1 = tdb1->Next) {
- tp = tdb1->CopyOne(t);
-
- if (!outp)
- outp = tp;
- else
- tdb2->Next = tp;
-
- tdb2 = tp;
- NewPointer(t, tdb1, tdb2);
- } // endfor tdb1
-
- return outp;
- } // end of Copy
-
-void TDB::Print(PGLOBAL g, FILE *f, uint n)
- {
- PCOL cp;
- char m[64];
-
- memset(m, ' ', n); // Make margin string
- m[n] = '\0';
-
- for (PTDB tp = this; tp; tp = tp->Next) {
- fprintf(f, "%sTDB (%p) %s no=%d use=%d type=%d\n", m,
- tp, tp->Name, tp->Tdb_No, tp->Use, tp->GetAmType());
-
- tp->PrintAM(f, m);
- fprintf(f, "%s Columns (deg=%d):\n", m, tp->Degree);
-
- for (cp = tp->Columns; cp; cp = cp->GetNext())
- cp->Print(g, f, n);
-
- } /* endfor tp */
-
- } // end of Print
-
-void TDB::Print(PGLOBAL g, char *ps, uint z)
- {
- sprintf(ps, "R%d.%s", Tdb_No, Name);
- } // end of Print
-
-/* -------------------------- class TDBASE --------------------------- */
-
-/***********************************************************************/
-/* Implementation of the TDBASE class. This is the base class to all */
-/* classes for tables that can be joined together. */
-/***********************************************************************/
-TDBASE::TDBASE(PTABDEF tdp) : TDB(tdp)
- {
- To_Def = tdp;
- To_Link = NULL;
- To_Key_Col = NULL;
- To_Kindex = NULL;
- To_Xdp = NULL;
- To_SetCols = NULL;
- MaxSize = -1;
- Knum = 0;
- Read_Only = (tdp) ? tdp->IsReadOnly() : false;
- m_data_charset= (tdp) ? tdp->data_charset() : NULL;
- } // end of TDBASE constructor
-
-TDBASE::TDBASE(PTDBASE tdbp) : TDB(tdbp)
- {
- To_Def = tdbp->To_Def;
- To_Link = tdbp->To_Link;
- To_Key_Col = tdbp->To_Key_Col;
- To_Kindex = tdbp->To_Kindex;
- To_Xdp = tdbp->To_Xdp;
- To_SetCols = tdbp->To_SetCols; // ???
- MaxSize = tdbp->MaxSize;
- Knum = tdbp->Knum;
- Read_Only = tdbp->Read_Only;
- m_data_charset= tdbp->m_data_charset;
- } // end of TDBASE copy constructor
-
-/***********************************************************************/
-/* Return the pointer on the DB catalog this table belongs to. */
-/***********************************************************************/
-PCATLG TDBASE::GetCat(void)
- {
- return (To_Def) ? To_Def->GetCat() : NULL;
- } // end of GetCat
-
-/***********************************************************************/
-/* Return the pointer on the charset of this table. */
-/***********************************************************************/
-CHARSET_INFO *TDBASE::data_charset(void)
- {
- // If no DATA_CHARSET is specified, we assume that character
- // set of the remote data is the same with CHARACTER SET
- // definition of the SQL column.
- return m_data_charset ? m_data_charset : &my_charset_bin;
- } // end of data_charset
-
-/***********************************************************************/
-/* Return the datapath of the DB this table belongs to. */
-/***********************************************************************/
-PSZ TDBASE::GetPath(void)
- {
- return To_Def->GetPath();
- } // end of GetPath
-
-/***********************************************************************/
-/* Initialize TDBASE based column description block construction. */
-/* name is used to call columns by name. */
-/* num is used by TBL to construct columns by index number. */
-/* Note: name=Null and num=0 for constructing all columns (select *) */
-/***********************************************************************/
-PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num)
- {
- int i;
- PCOLDEF cdp;
- PCOL cp, colp = NULL, cprec = NULL;
-
- if (trace)
- htrc("ColDB: am=%d colname=%s tabname=%s num=%d\n",
- GetAmType(), SVP(name), Name, num);
-
- for (cdp = To_Def->GetCols(), i = 1; cdp; cdp = cdp->GetNext(), i++)
- if ((!name && !num) ||
- (name && !stricmp(cdp->GetName(), name)) || num == i) {
- /*****************************************************************/
- /* Check for existence of desired column. */
- /* Also find where to insert the new block. */
- /*****************************************************************/
- for (cp = Columns; cp; cp = cp->GetNext())
- if (cp->GetIndex() < i)
- cprec = cp;
- else if (cp->GetIndex() == i)
- break;
-
- if (trace)
- htrc("cdp(%d).Name=%s cp=%p\n", i, cdp->GetName(), cp);
-
- /*****************************************************************/
- /* Now take care of Column Description Block. */
- /*****************************************************************/
- if (cp)
- colp = cp;
- else if (!(cdp->Flags & U_SPECIAL))
- colp = MakeCol(g, cdp, cprec, i);
- else if (Mode == MODE_READ)
- colp = InsertSpcBlk(g, cdp);
-
- if (trace)
- htrc("colp=%p\n", colp);
-
- if (name || num)
- break;
- else if (colp && !colp->IsSpecial())
- cprec = colp;
-
- } // endif Name
-
- return (colp);
- } // end of ColDB
-
-/***********************************************************************/
-/* InsertSpecialColumn: Put a special column ahead of the column list.*/
-/***********************************************************************/
-PCOL TDBASE::InsertSpecialColumn(PGLOBAL g, PCOL colp)
- {
- if (!colp->IsSpecial())
- return NULL;
-
- colp->SetNext(Columns);
- Columns = colp;
- return colp;
- } // end of InsertSpecialColumn
-
-/***********************************************************************/
-/* Make a special COLBLK to insert in a table. */
-/***********************************************************************/
-PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp)
- {
-//char *name = cdp->GetName();
- char *name = cdp->GetFmt();
- PCOLUMN cp;
- PCOL colp;
-
- cp= new(g) COLUMN(cdp->GetName());
- cp->SetTo_Table(To_Table);
-
- if (!stricmp(name, "FILEID") ||
- !stricmp(name, "SERVID")) {
- if (!To_Def || !(To_Def->GetPseudo() & 2)) {
- sprintf(g->Message, MSG(BAD_SPEC_COLUMN));
- return NULL;
- } // endif Pseudo
-
- if (!stricmp(name, "FILEID"))
- colp = new(g) FIDBLK(cp);
- else
- colp = new(g) SIDBLK(cp);
-
- } else if (!stricmp(name, "TABID")) {
- colp = new(g) TIDBLK(cp);
-//} else if (!stricmp(name, "CONID")) {
-// colp = new(g) CIDBLK(cp);
- } else if (!stricmp(name, "ROWID")) {
- colp = new(g) RIDBLK(cp, false);
- } else if (!stricmp(name, "ROWNUM")) {
- colp = new(g) RIDBLK(cp, true);
- } else {
- sprintf(g->Message, MSG(BAD_SPECIAL_COL), name);
- return NULL;
- } // endif's name
-
- if (!(colp = InsertSpecialColumn(g, colp))) {
- sprintf(g->Message, MSG(BAD_SPECIAL_COL), name);
- return NULL;
- } // endif Insert
-
- return (colp);
- } // end of InsertSpcBlk
-
-/***********************************************************************/
-/* ResetTableOpt: Wrong for this table type. */
-/***********************************************************************/
-int TDBASE::ResetTableOpt(PGLOBAL g, bool dop, bool dox)
-{
- strcpy(g->Message, "This table is not indexable");
- return RC_INFO;
-} // end of ResetTableOpt
-
-/***********************************************************************/
-/* SetKindex: set or reset the index pointer. */
-/***********************************************************************/
-void TDBASE::SetKindex(PGLOBAL g, PKXBASE kxp)
- {
- if (To_Kindex) {
- int pos = GetRecpos(); // To be reset in Txfp
-
- To_Kindex->Close(); // Discard old index
- SetRecpos(g, pos); // Ignore return value
- } // endif To_Kindex
-
- To_Kindex = kxp;
- } // end of SetKindex
-
-/***********************************************************************/
-/* SetRecpos: Replace the table at the specified position. */
-/***********************************************************************/
-bool TDBASE::SetRecpos(PGLOBAL g, int recpos)
- {
- strcpy(g->Message, MSG(SETRECPOS_NIY));
- return true;
- } // end of SetRecpos
-
-/***********************************************************************/
-/* Methods */
-/***********************************************************************/
-void TDBASE::PrintAM(FILE *f, char *m)
- {
- fprintf(f, "%s AM(%d): mode=%d\n", m, GetAmType(), Mode);
- } // end of PrintAM
-
-/***********************************************************************/
-/* Marks DOS/MAP table columns used in internal joins. */
-/* 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 ? */
-/* Why is the eventual reference to To_Key_Col not marked U_J_EXT ? */
-/***********************************************************************/
-void TDBASE::MarkDB(PGLOBAL g, PTDB tdb2)
- {
- if (trace)
- htrc("DOS MarkDB: tdbp=%p tdb2=%p\n", this, tdb2);
-
- } // end of MarkDB
-
-/* ---------------------------TDBCAT class --------------------------- */
-
-/***********************************************************************/
-/* Implementation of the TDBCAT class. */
-/***********************************************************************/
-TDBCAT::TDBCAT(PTABDEF tdp) : TDBASE(tdp)
- {
- Qrp = NULL;
- Init = false;
- N = -1;
- } // end of TDBCAT constructor
-
-/***********************************************************************/
-/* Allocate CAT column description block. */
-/***********************************************************************/
-PCOL TDBCAT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
- {
- PCATCOL colp;
-
- colp = (PCATCOL)new(g) CATCOL(cdp, this, n);
-
- if (cprec) {
- colp->SetNext(cprec->GetNext());
- cprec->SetNext(colp);
- } else {
- colp->SetNext(Columns);
- Columns = colp;
- } // endif cprec
-
- return colp;
- } // end of MakeCol
-
-/***********************************************************************/
-/* Initialize: Get the result query block. */
-/***********************************************************************/
-bool TDBCAT::Initialize(PGLOBAL g)
- {
- if (Init)
- return false;
-
- if (!(Qrp = GetResult(g)))
- return true;
-
- if (Qrp->Truncated) {
- sprintf(g->Message, "Result limited to %d lines", Qrp->Maxres);
- PushWarning(g, this);
- } // endif Truncated
-
- if (Qrp->BadLines) {
- sprintf(g->Message, "%d bad lines in result", Qrp->BadLines);
- PushWarning(g, this);
- } // endif Badlines
-
- Init = true;
- return false;
- } // end of Initialize
-
-/***********************************************************************/
-/* CAT: Get the number of properties. */
-/***********************************************************************/
-int TDBCAT::GetMaxSize(PGLOBAL g)
- {
- if (MaxSize < 0) {
-// if (Initialize(g))
-// return -1;
-
-// MaxSize = Qrp->Nblin;
- MaxSize = 10; // To make MariaDB happy
- } // endif MaxSize
-
- return MaxSize;
- } // end of GetMaxSize
-
-/***********************************************************************/
-/* CAT Access Method opening routine. */
-/***********************************************************************/
-bool TDBCAT::OpenDB(PGLOBAL g)
- {
- if (Use == USE_OPEN) {
- /*******************************************************************/
- /* Table already open. */
- /*******************************************************************/
- N = -1;
- return false;
- } // endif use
-
- if (Mode != MODE_READ) {
- /*******************************************************************/
- /* ODBC Info tables cannot be modified. */
- /*******************************************************************/
- strcpy(g->Message, "CAT tables are read only");
- return true;
- } // endif Mode
-
- /*********************************************************************/
- /* Initialize the ODBC processing. */
- /*********************************************************************/
- if (Initialize(g))
- return true;
-
- Use = USE_OPEN;
- return InitCol(g);
- } // end of OpenDB
-
-/***********************************************************************/
-/* Initialize columns. */
-/***********************************************************************/
-bool TDBCAT::InitCol(PGLOBAL g)
- {
- PCATCOL colp;
- PCOLRES crp;
-
- for (colp = (PCATCOL)Columns; colp; colp = (PCATCOL)colp->GetNext()) {
- for (crp = Qrp->Colresp; crp; crp = crp->Next)
- if ((colp->Flag && colp->Flag == crp->Fld) ||
- (!colp->Flag && !stricmp(colp->Name, crp->Name))) {
- colp->Crp = crp;
- break;
- } // endif Flag
-
-
- if (!colp->Crp /*&& !colp->GetValue()->IsConstant()*/) {
- sprintf(g->Message, "Invalid flag %d for column %s",
- colp->Flag, colp->Name);
- return true;
- } // endif Crp
-
- } // endfor colp
-
- return false;
- } // end of InitCol
-
-/***********************************************************************/
-/* SetRecpos: Replace the table at the specified position. */
-/***********************************************************************/
-bool TDBCAT::SetRecpos(PGLOBAL g, int recpos)
- {
- N = recpos - 1;
- return false;
- } // end of SetRecpos
-
-/***********************************************************************/
-/* Data Base read routine for CAT access method. */
-/***********************************************************************/
-int TDBCAT::ReadDB(PGLOBAL g)
- {
- return (++N < Qrp->Nblin) ? RC_OK : RC_EF;
- } // end of ReadDB
-
-/***********************************************************************/
-/* WriteDB: Data Base write routine for CAT access methods. */
-/***********************************************************************/
-int TDBCAT::WriteDB(PGLOBAL g)
- {
- strcpy(g->Message, "CAT tables are read only");
- return RC_FX;
- } // end of WriteDB
-
-/***********************************************************************/
-/* Data Base delete line routine for CAT access methods. */
-/***********************************************************************/
-int TDBCAT::DeleteDB(PGLOBAL g, int irc)
- {
- strcpy(g->Message, "Delete not enabled for CAT tables");
- return RC_FX;
- } // end of DeleteDB
-
-/***********************************************************************/
-/* Data Base close routine for WMI access method. */
-/***********************************************************************/
-void TDBCAT::CloseDB(PGLOBAL g)
- {
- // Nothing to do
- } // end of CloseDB
-
-// ------------------------ CATCOL functions ----------------------------
-
-/***********************************************************************/
-/* CATCOL public constructor. */
-/***********************************************************************/
-CATCOL::CATCOL(PCOLDEF cdp, PTDB tdbp, int n)
- : COLBLK(cdp, tdbp, n)
- {
- Tdbp = (PTDBCAT)tdbp;
- Crp = NULL;
- Flag = cdp->GetOffset();
- } // end of WMICOL constructor
-
-/***********************************************************************/
-/* Read the next Data Source elements. */
-/***********************************************************************/
-void CATCOL::ReadColumn(PGLOBAL g)
- {
- // Get the value of the Name or Description property
- Value->SetValue_pvblk(Crp->Kdata, Tdbp->N);
- } // end of ReadColumn
-
+/************** Table C++ Functions Source Code File (.CPP) ************/
+/* Name: TABLE.CPP Version 2.7 */
+/* */
+/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */
+/* */
+/* This file contains the TBX, TDB and OPJOIN classes functions. */
+/***********************************************************************/
+
+/***********************************************************************/
+/* Include relevant MariaDB header file. */
+/***********************************************************************/
+#include "my_global.h"
+
+/***********************************************************************/
+/* Include required application header files */
+/* global.h is header containing all global Plug declarations. */
+/* plgdbsem.h is header containing the DB applic. declarations. */
+/* xobject.h is header containing XOBJECT derived classes declares. */
+/***********************************************************************/
+#include "global.h"
+#include "plgdbsem.h"
+#include "xtable.h"
+#include "tabcol.h"
+#include "filamtxt.h"
+#include "tabdos.h"
+//#include "catalog.h"
+#include "reldef.h"
+
+int TDB::Tnum = 0;
+
+extern "C" int trace; // The general trace value
+
+/***********************************************************************/
+/* Utility routines. */
+/***********************************************************************/
+void NewPointer(PTABS, void *, void *);
+void AddPointer(PTABS, void *);
+
+/* ---------------------------- class TDB ---------------------------- */
+
+/***********************************************************************/
+/* TDB public constructors. */
+/***********************************************************************/
+TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum)
+ {
+ Use = USE_NO;
+ To_Orig = NULL;
+ To_Filter = NULL;
+ To_CondFil = NULL;
+ Next = NULL;
+ Name = (tdp) ? tdp->GetName() : NULL;
+ To_Table = NULL;
+ Columns = NULL;
+ Degree = (tdp) ? tdp->GetDegree() : 0;
+ Mode = MODE_READ;
+ } // end of TDB standard constructor
+
+TDB::TDB(PTDB tdbp) : Tdb_No(++Tnum)
+ {
+ Use = tdbp->Use;
+ To_Orig = tdbp;
+ To_Filter = NULL;
+ To_CondFil = NULL;
+ Next = NULL;
+ Name = tdbp->Name;
+ To_Table = tdbp->To_Table;
+ Columns = NULL;
+ Degree = tdbp->Degree;
+ Mode = tdbp->Mode;
+ } // end of TDB copy constructor
+
+// Methods
+
+/***********************************************************************/
+/* RowNumber: returns the current row ordinal number. */
+/***********************************************************************/
+int TDB::RowNumber(PGLOBAL g, bool b)
+ {
+ sprintf(g->Message, MSG(ROWID_NOT_IMPL), GetAmName(g, GetAmType()));
+ return 0;
+ } // end of RowNumber
+
+PTDB TDB::Copy(PTABS t)
+ {
+ PTDB tp, tdb1, tdb2 = NULL, outp = NULL;
+//PGLOBAL g = t->G; // Is this really useful ???
+
+ for (tdb1 = this; tdb1; tdb1 = tdb1->Next) {
+ tp = tdb1->CopyOne(t);
+
+ if (!outp)
+ outp = tp;
+ else
+ tdb2->Next = tp;
+
+ tdb2 = tp;
+ NewPointer(t, tdb1, tdb2);
+ } // endfor tdb1
+
+ return outp;
+ } // end of Copy
+
+void TDB::Print(PGLOBAL g, FILE *f, uint n)
+ {
+ PCOL cp;
+ char m[64];
+
+ memset(m, ' ', n); // Make margin string
+ m[n] = '\0';
+
+ for (PTDB tp = this; tp; tp = tp->Next) {
+ fprintf(f, "%sTDB (%p) %s no=%d use=%d type=%d\n", m,
+ tp, tp->Name, tp->Tdb_No, tp->Use, tp->GetAmType());
+
+ tp->PrintAM(f, m);
+ fprintf(f, "%s Columns (deg=%d):\n", m, tp->Degree);
+
+ for (cp = tp->Columns; cp; cp = cp->GetNext())
+ cp->Print(g, f, n);
+
+ } /* endfor tp */
+
+ } // end of Print
+
+void TDB::Print(PGLOBAL g, char *ps, uint z)
+ {
+ sprintf(ps, "R%d.%s", Tdb_No, Name);
+ } // end of Print
+
+/* -------------------------- class TDBASE --------------------------- */
+
+/***********************************************************************/
+/* Implementation of the TDBASE class. This is the base class to all */
+/* classes for tables that can be joined together. */
+/***********************************************************************/
+TDBASE::TDBASE(PTABDEF tdp) : TDB(tdp)
+ {
+ To_Def = tdp;
+ To_Link = NULL;
+ To_Key_Col = NULL;
+ To_Kindex = NULL;
+ To_Xdp = NULL;
+ To_SetCols = NULL;
+ MaxSize = -1;
+ Knum = 0;
+ Read_Only = (tdp) ? tdp->IsReadOnly() : false;
+ m_data_charset= (tdp) ? tdp->data_charset() : NULL;
+ } // end of TDBASE constructor
+
+TDBASE::TDBASE(PTDBASE tdbp) : TDB(tdbp)
+ {
+ To_Def = tdbp->To_Def;
+ To_Link = tdbp->To_Link;
+ To_Key_Col = tdbp->To_Key_Col;
+ To_Kindex = tdbp->To_Kindex;
+ To_Xdp = tdbp->To_Xdp;
+ To_SetCols = tdbp->To_SetCols; // ???
+ MaxSize = tdbp->MaxSize;
+ Knum = tdbp->Knum;
+ Read_Only = tdbp->Read_Only;
+ m_data_charset= tdbp->m_data_charset;
+ } // end of TDBASE copy constructor
+
+/***********************************************************************/
+/* Return the pointer on the DB catalog this table belongs to. */
+/***********************************************************************/
+PCATLG TDBASE::GetCat(void)
+ {
+ return (To_Def) ? To_Def->GetCat() : NULL;
+ } // end of GetCat
+
+/***********************************************************************/
+/* Return the pointer on the charset of this table. */
+/***********************************************************************/
+CHARSET_INFO *TDBASE::data_charset(void)
+ {
+ // If no DATA_CHARSET is specified, we assume that character
+ // set of the remote data is the same with CHARACTER SET
+ // definition of the SQL column.
+ return m_data_charset ? m_data_charset : &my_charset_bin;
+ } // end of data_charset
+
+/***********************************************************************/
+/* Return the datapath of the DB this table belongs to. */
+/***********************************************************************/
+PSZ TDBASE::GetPath(void)
+ {
+ return To_Def->GetPath();
+ } // end of GetPath
+
+/***********************************************************************/
+/* Initialize TDBASE based column description block construction. */
+/* name is used to call columns by name. */
+/* num is used by TBL to construct columns by index number. */
+/* Note: name=Null and num=0 for constructing all columns (select *) */
+/***********************************************************************/
+PCOL TDBASE::ColDB(PGLOBAL g, PSZ name, int num)
+ {
+ int i;
+ PCOLDEF cdp;
+ PCOL cp, colp = NULL, cprec = NULL;
+
+ if (trace)
+ htrc("ColDB: am=%d colname=%s tabname=%s num=%d\n",
+ GetAmType(), SVP(name), Name, num);
+
+ for (cdp = To_Def->GetCols(), i = 1; cdp; cdp = cdp->GetNext(), i++)
+ if ((!name && !num) ||
+ (name && !stricmp(cdp->GetName(), name)) || num == i) {
+ /*****************************************************************/
+ /* Check for existence of desired column. */
+ /* Also find where to insert the new block. */
+ /*****************************************************************/
+ for (cp = Columns; cp; cp = cp->GetNext())
+ if (cp->GetIndex() < i)
+ cprec = cp;
+ else if (cp->GetIndex() == i)
+ break;
+
+ if (trace)
+ htrc("cdp(%d).Name=%s cp=%p\n", i, cdp->GetName(), cp);
+
+ /*****************************************************************/
+ /* Now take care of Column Description Block. */
+ /*****************************************************************/
+ if (cp)
+ colp = cp;
+ else if (!(cdp->Flags & U_SPECIAL))
+ colp = MakeCol(g, cdp, cprec, i);
+ else if (Mode == MODE_READ)
+ colp = InsertSpcBlk(g, cdp);
+
+ if (trace)
+ htrc("colp=%p\n", colp);
+
+ if (name || num)
+ break;
+ else if (colp && !colp->IsSpecial())
+ cprec = colp;
+
+ } // endif Name
+
+ return (colp);
+ } // end of ColDB
+
+/***********************************************************************/
+/* InsertSpecialColumn: Put a special column ahead of the column list.*/
+/***********************************************************************/
+PCOL TDBASE::InsertSpecialColumn(PGLOBAL g, PCOL colp)
+ {
+ if (!colp->IsSpecial())
+ return NULL;
+
+ colp->SetNext(Columns);
+ Columns = colp;
+ return colp;
+ } // end of InsertSpecialColumn
+
+/***********************************************************************/
+/* Make a special COLBLK to insert in a table. */
+/***********************************************************************/
+PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp)
+ {
+//char *name = cdp->GetName();
+ char *name = cdp->GetFmt();
+ PCOLUMN cp;
+ PCOL colp;
+
+ cp= new(g) COLUMN(cdp->GetName());
+ cp->SetTo_Table(To_Table);
+
+ if (!stricmp(name, "FILEID") ||
+ !stricmp(name, "SERVID")) {
+ if (!To_Def || !(To_Def->GetPseudo() & 2)) {
+ sprintf(g->Message, MSG(BAD_SPEC_COLUMN));
+ return NULL;
+ } // endif Pseudo
+
+ if (!stricmp(name, "FILEID"))
+ colp = new(g) FIDBLK(cp);
+ else
+ colp = new(g) SIDBLK(cp);
+
+ } else if (!stricmp(name, "TABID")) {
+ colp = new(g) TIDBLK(cp);
+//} else if (!stricmp(name, "CONID")) {
+// colp = new(g) CIDBLK(cp);
+ } else if (!stricmp(name, "ROWID")) {
+ colp = new(g) RIDBLK(cp, false);
+ } else if (!stricmp(name, "ROWNUM")) {
+ colp = new(g) RIDBLK(cp, true);
+ } else {
+ sprintf(g->Message, MSG(BAD_SPECIAL_COL), name);
+ return NULL;
+ } // endif's name
+
+ if (!(colp = InsertSpecialColumn(g, colp))) {
+ sprintf(g->Message, MSG(BAD_SPECIAL_COL), name);
+ return NULL;
+ } // endif Insert
+
+ return (colp);
+ } // end of InsertSpcBlk
+
+/***********************************************************************/
+/* ResetTableOpt: Wrong for this table type. */
+/***********************************************************************/
+int TDBASE::ResetTableOpt(PGLOBAL g, bool dop, bool dox)
+{
+ strcpy(g->Message, "This table is not indexable");
+ return RC_INFO;
+} // end of ResetTableOpt
+
+/***********************************************************************/
+/* ResetKindex: set or reset the index pointer. */
+/***********************************************************************/
+void TDBASE::ResetKindex(PGLOBAL g, PKXBASE kxp)
+ {
+ 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
+ SetRecpos(g, pos); // Ignore return value
+ } // endif To_Kindex
+
+ To_Kindex = kxp;
+ } // end of ResetKindex
+
+/***********************************************************************/
+/* SetRecpos: Replace the table at the specified position. */
+/***********************************************************************/
+bool TDBASE::SetRecpos(PGLOBAL g, int recpos)
+ {
+ strcpy(g->Message, MSG(SETRECPOS_NIY));
+ return true;
+ } // end of SetRecpos
+
+/***********************************************************************/
+/* Methods */
+/***********************************************************************/
+void TDBASE::PrintAM(FILE *f, char *m)
+ {
+ fprintf(f, "%s AM(%d): mode=%d\n", m, GetAmType(), Mode);
+ } // end of PrintAM
+
+/***********************************************************************/
+/* Marks DOS/MAP table columns used in internal joins. */
+/* 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 ? */
+/* Why is the eventual reference to To_Key_Col not marked U_J_EXT ? */
+/***********************************************************************/
+void TDBASE::MarkDB(PGLOBAL g, PTDB tdb2)
+ {
+ if (trace)
+ htrc("DOS MarkDB: tdbp=%p tdb2=%p\n", this, tdb2);
+
+ } // end of MarkDB
+
+/* ---------------------------TDBCAT class --------------------------- */
+
+/***********************************************************************/
+/* Implementation of the TDBCAT class. */
+/***********************************************************************/
+TDBCAT::TDBCAT(PTABDEF tdp) : TDBASE(tdp)
+ {
+ Qrp = NULL;
+ Init = false;
+ N = -1;
+ } // end of TDBCAT constructor
+
+/***********************************************************************/
+/* Allocate CAT column description block. */
+/***********************************************************************/
+PCOL TDBCAT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
+ {
+ PCATCOL colp;
+
+ colp = (PCATCOL)new(g) CATCOL(cdp, this, n);
+
+ if (cprec) {
+ colp->SetNext(cprec->GetNext());
+ cprec->SetNext(colp);
+ } else {
+ colp->SetNext(Columns);
+ Columns = colp;
+ } // endif cprec
+
+ return colp;
+ } // end of MakeCol
+
+/***********************************************************************/
+/* Initialize: Get the result query block. */
+/***********************************************************************/
+bool TDBCAT::Initialize(PGLOBAL g)
+ {
+ if (Init)
+ return false;
+
+ if (!(Qrp = GetResult(g)))
+ return true;
+
+ if (Qrp->Truncated) {
+ sprintf(g->Message, "Result limited to %d lines", Qrp->Maxres);
+ PushWarning(g, this);
+ } // endif Truncated
+
+ if (Qrp->BadLines) {
+ sprintf(g->Message, "%d bad lines in result", Qrp->BadLines);
+ PushWarning(g, this);
+ } // endif Badlines
+
+ Init = true;
+ return false;
+ } // end of Initialize
+
+/***********************************************************************/
+/* CAT: Get the number of properties. */
+/***********************************************************************/
+int TDBCAT::GetMaxSize(PGLOBAL g)
+ {
+ if (MaxSize < 0) {
+// if (Initialize(g))
+// return -1;
+
+// MaxSize = Qrp->Nblin;
+ MaxSize = 10; // To make MariaDB happy
+ } // endif MaxSize
+
+ return MaxSize;
+ } // end of GetMaxSize
+
+/***********************************************************************/
+/* CAT Access Method opening routine. */
+/***********************************************************************/
+bool TDBCAT::OpenDB(PGLOBAL g)
+ {
+ if (Use == USE_OPEN) {
+ /*******************************************************************/
+ /* Table already open. */
+ /*******************************************************************/
+ N = -1;
+ return false;
+ } // endif use
+
+ if (Mode != MODE_READ) {
+ /*******************************************************************/
+ /* ODBC Info tables cannot be modified. */
+ /*******************************************************************/
+ strcpy(g->Message, "CAT tables are read only");
+ return true;
+ } // endif Mode
+
+ /*********************************************************************/
+ /* Initialize the ODBC processing. */
+ /*********************************************************************/
+ if (Initialize(g))
+ return true;
+
+ Use = USE_OPEN;
+ return InitCol(g);
+ } // end of OpenDB
+
+/***********************************************************************/
+/* Initialize columns. */
+/***********************************************************************/
+bool TDBCAT::InitCol(PGLOBAL g)
+ {
+ PCATCOL colp;
+ PCOLRES crp;
+
+ for (colp = (PCATCOL)Columns; colp; colp = (PCATCOL)colp->GetNext()) {
+ for (crp = Qrp->Colresp; crp; crp = crp->Next)
+ if ((colp->Flag && colp->Flag == crp->Fld) ||
+ (!colp->Flag && !stricmp(colp->Name, crp->Name))) {
+ colp->Crp = crp;
+ break;
+ } // endif Flag
+
+
+ if (!colp->Crp /*&& !colp->GetValue()->IsConstant()*/) {
+ sprintf(g->Message, "Invalid flag %d for column %s",
+ colp->Flag, colp->Name);
+ return true;
+ } // endif Crp
+
+ } // endfor colp
+
+ return false;
+ } // end of InitCol
+
+/***********************************************************************/
+/* SetRecpos: Replace the table at the specified position. */
+/***********************************************************************/
+bool TDBCAT::SetRecpos(PGLOBAL g, int recpos)
+ {
+ N = recpos - 1;
+ return false;
+ } // end of SetRecpos
+
+/***********************************************************************/
+/* Data Base read routine for CAT access method. */
+/***********************************************************************/
+int TDBCAT::ReadDB(PGLOBAL g)
+ {
+ return (++N < Qrp->Nblin) ? RC_OK : RC_EF;
+ } // end of ReadDB
+
+/***********************************************************************/
+/* WriteDB: Data Base write routine for CAT access methods. */
+/***********************************************************************/
+int TDBCAT::WriteDB(PGLOBAL g)
+ {
+ strcpy(g->Message, "CAT tables are read only");
+ return RC_FX;
+ } // end of WriteDB
+
+/***********************************************************************/
+/* Data Base delete line routine for CAT access methods. */
+/***********************************************************************/
+int TDBCAT::DeleteDB(PGLOBAL g, int irc)
+ {
+ strcpy(g->Message, "Delete not enabled for CAT tables");
+ return RC_FX;
+ } // end of DeleteDB
+
+/***********************************************************************/
+/* Data Base close routine for WMI access method. */
+/***********************************************************************/
+void TDBCAT::CloseDB(PGLOBAL g)
+ {
+ // Nothing to do
+ } // end of CloseDB
+
+// ------------------------ CATCOL functions ----------------------------
+
+/***********************************************************************/
+/* CATCOL public constructor. */
+/***********************************************************************/
+CATCOL::CATCOL(PCOLDEF cdp, PTDB tdbp, int n)
+ : COLBLK(cdp, tdbp, n)
+ {
+ Tdbp = (PTDBCAT)tdbp;
+ Crp = NULL;
+ Flag = cdp->GetOffset();
+ } // end of WMICOL constructor
+
+/***********************************************************************/
+/* Read the next Data Source elements. */
+/***********************************************************************/
+void CATCOL::ReadColumn(PGLOBAL g)
+ {
+ // Get the value of the Name or Description property
+ Value->SetValue_pvblk(Crp->Kdata, Tdbp->N);
+ } // end of ReadColumn
+
diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp
index 1e9c172cdb3..ee5749d8ab7 100644
--- a/storage/connect/tabxml.cpp
+++ b/storage/connect/tabxml.cpp
@@ -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) {
diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp
index 52febd99687..5f7d982c701 100755
--- a/storage/connect/xindex.cpp
+++ b/storage/connect/xindex.cpp
@@ -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
diff --git a/storage/connect/xindex.h b/storage/connect/xindex.h
index c8b7f27de22..6800c18944d 100644
--- a/storage/connect/xindex.h
+++ b/storage/connect/xindex.h
@@ -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
diff --git a/storage/connect/xtable.h b/storage/connect/xtable.h
index 10d89307be5..c4537ac0417 100644
--- a/storage/connect/xtable.h
+++ b/storage/connect/xtable.h
@@ -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