summaryrefslogtreecommitdiff
path: root/storage/connect/filamvct.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2014-07-17 18:13:51 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2014-07-17 18:13:51 +0200
commit19042843613efeffb4880c4b145a7744b4810ab5 (patch)
treefd009e8f4663e6e7cd99eab8219353e4db276b0e /storage/connect/filamvct.cpp
parent78292e17ae2ceb3413644a29b25afe0c24d2bcc3 (diff)
downloadmariadb-git-19042843613efeffb4880c4b145a7744b4810ab5.tar.gz
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned by files, this is an enhanced MULTIPLE table. It can be also partitioned by sub-tables like TBL and this enables table sharding. 2) Handling a CONNECT bug that causes in some cases extraneous rows to remain in the table after an UPDATE or DELETE when the command uses indexing (for not fixed file tables). Until a real fix is done, CONNECT tries to ignore indexing and if it cannot do it abort the command with an error message. - Add tests on partitioning added: storage/connect/mysql-test/connect/r/part_file.result storage/connect/mysql-test/connect/r/part_table.result storage/connect/mysql-test/connect/t/part_file.test storage/connect/mysql-test/connect/t/part_table.test - Temporary fix modified: sql/sql_partition.cc - Add partition support modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabdos.cpp - Add functions ha_connect::IsUnique and ha_connect::CheckColumnList modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Prevent updating a partition table column that is part of the partition function (outward tables only) modified: storage/connect/ha_connect.cc - Support INSERT/UPDATE/DELETE for PROXY tables modified: storage/connect/tabutil.cpp - Handle the bug on updating rows via indexing. Waiting for a real fix, Don't use indexing when possible else raise an error and abort. modified: storage/connect/ha_connect.cc - dbuserp->UseTemp set to TMP_AUTO modified: storage/connect/connect.cc - Add members nox, abort and only modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Add arguments nox and abort to CntCloseTable modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/ha_connect.cc - Add arguments abort to CloseTableFile and RenameTempFile modified: storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabvct.cpp storage/connect/xtable.h - Fix info->records when file does not exists modified: storage/connect/connect.cc - Close XML table when opened for info modified: storage/connect/connect.cc - Add function VCTFAM::GetFileLength modified: storage/connect/filamvct.cpp storage/connect/filamvct.h - Column option DISTRIB -> ENUM modified: storage/connect/ha_connect.cc - Options connect, query_string and partname allways available modified: storage/connect/ha_connect.cc - Add function MYSQLC::GetTableSize modified: storage/connect/myconn.cpp storage/connect/myconn.h - Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK) modified: storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/plgdbsem.h storage/connect/table.cpp - Add function ExtractFromPath modified: storage/connect/colblk.cpp storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp - Enhance Cardinality for some table types modified: storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h - Add test on special column modified: storage/connect/tabfmt.cpp - Add new files (added for block indexing) modified: storage/connect/CMakeLists.txt
Diffstat (limited to 'storage/connect/filamvct.cpp')
-rwxr-xr-xstorage/connect/filamvct.cpp113
1 files changed, 74 insertions, 39 deletions
diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp
index b07ae8a2213..076222e9e7f 100755
--- a/storage/connect/filamvct.cpp
+++ b/storage/connect/filamvct.cpp
@@ -137,6 +137,39 @@ VCTFAM::VCTFAM(PVCTFAM txfp) : FIXFAM(txfp)
} // end of VCTFAM copy constructor
/***********************************************************************/
+/* VCT GetFileLength: returns file size in number of bytes. */
+/* This function is here to be accessible by VECFAM and VMPFAM. */
+/***********************************************************************/
+int VCTFAM::GetFileLength(PGLOBAL g)
+ {
+ if (Split) {
+ // Get the total file length
+ char filename[_MAX_PATH];
+ char *savfile = To_File;
+ int i, len = 0;
+
+ // Initialize the array of file structures
+ if (!Colfn) {
+ // Prepare the column file name pattern and set Ncol
+ Colfn = (char*)PlugSubAlloc(g, NULL, _MAX_PATH);
+ Ncol = ((PVCTDEF)Tdbp->GetDef())->MakeFnPattern(Colfn);
+ } // endif Colfn
+
+ To_File = filename;
+
+ for (i = 0; i < Ncol; i++) {
+ sprintf(filename, Colfn, i+1);
+ len += TXTFAM::GetFileLength(g);
+ } // endfor i
+
+ To_File = savfile;
+ return len;
+ } else
+ return TXTFAM::GetFileLength(g);
+
+ } // end of GetFileLength
+
+/***********************************************************************/
/* Reset read/write position values. */
/***********************************************************************/
void VCTFAM::Reset(void)
@@ -295,7 +328,7 @@ int VCTFAM::Cardinality(PGLOBAL g)
clen = cdp->GetClen();
sprintf(filename, Colfn, 1);
To_File = filename;
- len = GetFileLength(g);
+ len = TXTFAM::GetFileLength(g);
To_File = savfn;
if (len >= 0) {
@@ -1042,7 +1075,7 @@ bool VCTFAM::CleanUnusedSpace(PGLOBAL g)
/***********************************************************************/
/* Data Base close routine for VCT access method. */
/***********************************************************************/
-void VCTFAM::CloseTableFile(PGLOBAL g)
+void VCTFAM::CloseTableFile(PGLOBAL g, bool abort)
{
int rc = 0, wrc = RC_OK;
MODE mode = Tdbp->GetMode();
@@ -1078,7 +1111,7 @@ void VCTFAM::CloseTableFile(PGLOBAL g)
colp->WriteBlock(g);
if (UseTemp && T_Stream) {
- rc = RenameTempFile(g);
+ rc = RenameTempFile(g, abort);
if (Header) {
// Header must be set because it was not set in temp file
@@ -1092,7 +1125,7 @@ void VCTFAM::CloseTableFile(PGLOBAL g)
if (MaxBlk)
rc = CleanUnusedSpace(g);
- if ((rc = RenameTempFile(g)) != RC_FX) {
+ if ((rc = RenameTempFile(g, abort)) != RC_FX) {
Stream = T_Stream = NULL; // For SetBlockInfo
rc = ResetTableSize(g, Block, Last);
} // endif rc
@@ -1715,7 +1748,7 @@ int VCMFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/
/* Data Base close routine for VMP access method. */
/***********************************************************************/
-void VCMFAM::CloseTableFile(PGLOBAL g)
+void VCMFAM::CloseTableFile(PGLOBAL g, bool abort)
{
int wrc = RC_OK;
MODE mode = Tdbp->GetMode();
@@ -2252,7 +2285,7 @@ int VECFAM::DeleteRecords(PGLOBAL g, int irc)
} else // UseTemp
// Ok, now delete old files and rename new temp files
- if (RenameTempFile(g) == RC_FX)
+ if (RenameTempFile(g, false) == RC_FX)
return RC_FX;
// Reset these values for TDBVCT::MakeBlockValues
@@ -2382,7 +2415,7 @@ bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *bn)
/***********************************************************************/
/* Delete the old files and rename the new temporary files. */
/***********************************************************************/
-int VECFAM::RenameTempFile(PGLOBAL g)
+int VECFAM::RenameTempFile(PGLOBAL g, bool abort)
{
char *tempname, filetemp[_MAX_PATH], filename[_MAX_PATH];
int rc = RC_OK;
@@ -2398,25 +2431,30 @@ int VECFAM::RenameTempFile(PGLOBAL g)
continue;
tempname = (char*)T_Fbs[i]->Fname;
- sprintf(filename, Colfn, i+1);
- PlugSetPath(filename, filename, Tdbp->GetPath());
- strcat(PlugRemoveType(filetemp, filename), ".ttt");
- remove(filetemp); // May still be there from previous error
-
- if (rename(filename, filetemp)) { // Save file for security
- sprintf(g->Message, MSG(RENAME_ERROR),
- filename, filetemp, strerror(errno));
- rc = RC_FX;
- } else if (rename(tempname, filename)) {
- sprintf(g->Message, MSG(RENAME_ERROR),
- tempname, filename, strerror(errno));
- rc = rename(filetemp, filename); // Restore saved file
- rc = RC_FX;
- } else if (remove(filetemp)) {
- sprintf(g->Message, MSG(REMOVE_ERROR),
- filetemp, strerror(errno));
- rc = RC_INFO; // Acceptable
- } // endif's
+
+ if (!abort) {
+ sprintf(filename, Colfn, i+1);
+ PlugSetPath(filename, filename, Tdbp->GetPath());
+ strcat(PlugRemoveType(filetemp, filename), ".ttt");
+ remove(filetemp); // May still be there from previous error
+
+ if (rename(filename, filetemp)) { // Save file for security
+ sprintf(g->Message, MSG(RENAME_ERROR),
+ filename, filetemp, strerror(errno));
+ rc = RC_FX;
+ } else if (rename(tempname, filename)) {
+ sprintf(g->Message, MSG(RENAME_ERROR),
+ tempname, filename, strerror(errno));
+ rc = rename(filetemp, filename); // Restore saved file
+ rc = RC_FX;
+ } else if (remove(filetemp)) {
+ sprintf(g->Message, MSG(REMOVE_ERROR),
+ filetemp, strerror(errno));
+ rc = RC_INFO; // Acceptable
+ } // endif's
+
+ } else
+ remove(tempname);
} // endfor i
@@ -2426,7 +2464,7 @@ int VECFAM::RenameTempFile(PGLOBAL g)
/***********************************************************************/
/* Data Base close routine for VEC access method. */
/***********************************************************************/
-void VECFAM::CloseTableFile(PGLOBAL g)
+void VECFAM::CloseTableFile(PGLOBAL g, bool abort)
{
int rc = 0, wrc = RC_OK;
MODE mode = Tdbp->GetMode();
@@ -2453,10 +2491,10 @@ void VECFAM::CloseTableFile(PGLOBAL g)
longjmp(g->jumper[g->jump_level], 44);
} else if (mode == MODE_UPDATE) {
- if (UseTemp && !InitUpdate) {
+ if (UseTemp && !InitUpdate && !abort) {
// Write any intermediate lines to temp file
Fpos = OldBlk * Nrec;
- wrc = MoveIntermediateLines(g);
+ abort = MoveIntermediateLines(g) != RC_OK;
// Spos = Fpos + Nrec;
} // endif UseTemp
@@ -2466,20 +2504,17 @@ void VECFAM::CloseTableFile(PGLOBAL g)
colp; colp = (PVCTCOL)colp->Next)
colp->WriteBlock(g);
- if (wrc == RC_OK && UseTemp && !InitUpdate) {
+ if (wrc == RC_OK && UseTemp && !InitUpdate && !abort) {
// Write any intermediate lines to temp file
Fpos = (Block - 1) * Nrec + Last;
- wrc = MoveIntermediateLines(g);
+ abort = MoveIntermediateLines(g) != RC_OK;
} // endif UseTemp
} // endif's mode
if (UseTemp && !InitUpdate) {
// If they are errors, leave files unchanged
- if (wrc == RC_OK)
- rc = RenameTempFile(g);
- else
- longjmp(g->jumper[g->jump_level], 44);
+ rc = RenameTempFile(g, abort);
} else if (Streams)
for (int i = 0; i < Ncol; i++)
@@ -2950,7 +2985,7 @@ int VMPFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/
/* Data Base close routine for VMP access method. */
/***********************************************************************/
-void VMPFAM::CloseTableFile(PGLOBAL g)
+void VMPFAM::CloseTableFile(PGLOBAL g, bool abort)
{
if (Tdbp->GetMode() == MODE_DELETE) {
// Set Block and Nrec values for TDBVCT::MakeBlockValues
@@ -4072,7 +4107,7 @@ bool BGVFAM::CleanUnusedSpace(PGLOBAL g)
/***********************************************************************/
/* Data Base close routine for huge VEC access method. */
/***********************************************************************/
-void BGVFAM::CloseTableFile(PGLOBAL g)
+void BGVFAM::CloseTableFile(PGLOBAL g, bool abort)
{
int rc = 0, wrc = RC_OK;
MODE mode = Tdbp->GetMode();
@@ -4108,7 +4143,7 @@ void BGVFAM::CloseTableFile(PGLOBAL g)
colp->WriteBlock(g);
if (UseTemp && Tfile) {
- rc = RenameTempFile(g);
+ rc = RenameTempFile(g, abort);
Hfile = Tfile = INVALID_HANDLE_VALUE;
if (Header)
@@ -4121,7 +4156,7 @@ void BGVFAM::CloseTableFile(PGLOBAL g)
if (MaxBlk)
rc = CleanUnusedSpace(g);
- if ((rc = RenameTempFile(g)) != RC_FX) {
+ if ((rc = RenameTempFile(g, abort)) != RC_FX) {
Hfile = Tfile = INVALID_HANDLE_VALUE; // For SetBlockInfo
rc = ResetTableSize(g, Block, Last);
} // endif rc