Commit 0219ac1e authored by Olivier Bertrand's avatar Olivier Bertrand

This is a major update that fixes most of the issues and bugs that

have been created by the last addition of new CONNECT features.
The version previous to this one is a preliminary test version and
should not be distributed.

- Handle indexed UPDATE/DELETE. Previously this was just tested and
  an error message send when it could not be done. Now CONNECT can
  do it in all the cases. It is done by a MRR like tchnique by making
  a list of all update or delete to do, sort them, then execute them.
modified:
  storage/connect/array.cpp
  storage/connect/array.h
  storage/connect/filamap.cpp
  storage/connect/filamap.h
  storage/connect/filamdbf.cpp
  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/global.h
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h

- Differenciate Cardinality that returns a true or estimated table size
  and GetMaxSize that return a value equal or greater than the table
  row number. This fixes the errors of non matching opt files.
modified:
  storage/connect/connect.cc
  storage/connect/tabdos.cpp
  storage/connect/tabdos.h
  storage/connect/tabfix.cpp
  storage/connect/table.cpp
  storage/connect/tabmac.h
  storage/connect/tabmysql.cpp
  storage/connect/tabmysql.h
  storage/connect/tabodbc.cpp
  storage/connect/tabodbc.h
  storage/connect/tabpivot.h
  storage/connect/tabtbl.cpp
  storage/connect/tabtbl.h
  storage/connect/tabutil.cpp
  storage/connect/tabutil.h
  storage/connect/tabwmi.h
  storage/connect/xtable.h

- Fix some errors and issues when making index and opt files.
  Erase opt and index files for void tables.
  Fix wrong calculation of Block and Last in MakeBlockValues.
  Invalidate indexes before making opt file.
  Fully handle blocked variable tables. Make opt file for blocked
  variable tables even when they have no optimised colums.
modified:
  storage/connect/tabdos.cpp
  storage/connect/xindex.h

- Fix some errors making index
  Return an error when the allocation is too small (should not
  really occur now that GetMaxSize is sure)
  Don't use XXROW index for DBF tables because of soft deleted lines.
modified:
  storage/connect/xindex.cpp

- Typo
modified:
  storage/connect/macutil.cpp
  storage/connect/tabdos.h
  storage/connect/tabsys.cpp
  storage/connect/tabsys.h
parent 4d0587c3
...@@ -124,6 +124,9 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp) ...@@ -124,6 +124,9 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp)
case TYPE_DOUBLE: case TYPE_DOUBLE:
par->AddValue(g, *(double*)parmp->Value); par->AddValue(g, *(double*)parmp->Value);
break; break;
case TYPE_PCHAR:
par->AddValue(g, parmp->Value);
break;
} // endswitch valtyp } // endswitch valtyp
/*********************************************************************/ /*********************************************************************/
...@@ -156,6 +159,7 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec) ...@@ -156,6 +159,7 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec)
case TYPE_SHORT: case TYPE_SHORT:
case TYPE_INT: case TYPE_INT:
case TYPE_DOUBLE: case TYPE_DOUBLE:
case TYPE_PCHAR:
break; break;
#if 0 #if 0
case TYPE_TOKEN: case TYPE_TOKEN:
...@@ -172,12 +176,13 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec) ...@@ -172,12 +176,13 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec)
} // endswitch type } // endswitch type
Valblk = new(g) MBVALS; Valblk = new(g) MBVALS;
Vblp = Valblk->Allocate(g, Type, Len, prec, Size);
if (!Valblk->GetMemp() && Type != TYPE_LIST) if (!(Vblp = Valblk->Allocate(g, Type, Len, prec, Size)))
Type = TYPE_ERROR;
else if (!Valblk->GetMemp() && Type != TYPE_LIST)
// The error message was built by PlgDBalloc // The error message was built by PlgDBalloc
Type = TYPE_ERROR; Type = TYPE_ERROR;
else else if (type != TYPE_PCHAR)
Value = AllocateValue(g, type, Len, prec, NULL); Value = AllocateValue(g, type, Len, prec, NULL);
Constant = TRUE; Constant = TRUE;
...@@ -288,7 +293,24 @@ bool ARRAY::AddValue(PGLOBAL g, PSZ strp) ...@@ -288,7 +293,24 @@ bool ARRAY::AddValue(PGLOBAL g, PSZ strp)
} // end of AddValue } // end of AddValue
/***********************************************************************/ /***********************************************************************/
/* Add a SHORT integer element to an array. */ /* Add a char pointer element to an array. */
/***********************************************************************/
bool ARRAY::AddValue(PGLOBAL g, void *p)
{
if (Type != TYPE_PCHAR) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "PCHAR");
return TRUE;
} // endif Type
if (trace)
htrc(" adding pointer(%d): %p\n", Nval, p);
Vblp->SetValue((PSZ)p, Nval++);
return FALSE;
} // end of AddValue
/***********************************************************************/
/* Add a short integer element to an array. */
/***********************************************************************/ /***********************************************************************/
bool ARRAY::AddValue(PGLOBAL g, short n) bool ARRAY::AddValue(PGLOBAL g, short n)
{ {
...@@ -307,7 +329,7 @@ bool ARRAY::AddValue(PGLOBAL g, short n) ...@@ -307,7 +329,7 @@ bool ARRAY::AddValue(PGLOBAL g, short n)
} // end of AddValue } // end of AddValue
/***********************************************************************/ /***********************************************************************/
/* Add a int integer element to an array. */ /* Add an integer element to an array. */
/***********************************************************************/ /***********************************************************************/
bool ARRAY::AddValue(PGLOBAL g, int n) bool ARRAY::AddValue(PGLOBAL g, int n)
{ {
...@@ -404,15 +426,24 @@ bool ARRAY::GetSubValue(PGLOBAL g, PVAL valp, int *kp) ...@@ -404,15 +426,24 @@ bool ARRAY::GetSubValue(PGLOBAL g, PVAL valp, int *kp)
vblp = ((LSTBLK*)Vblp)->Mbvk[kp[0]]->Vblk; vblp = ((LSTBLK*)Vblp)->Mbvk[kp[0]]->Vblk;
valp->SetValue_pvblk(vblp, kp[1]); valp->SetValue_pvblk(vblp, kp[1]);
return FALSE; return FALSE;
} // end of GetNthValue } // end of GetSubValue
#endif // 0 #endif // 0
/***********************************************************************/
/* Return the nth value of an integer array. */
/***********************************************************************/
int ARRAY::GetIntValue(int n)
{
assert (Type == TYPE_INT);
return Vblp->GetIntValue(n);
} // end of GetIntValue
/***********************************************************************/ /***********************************************************************/
/* Return the nth value of a STRING array. */ /* Return the nth value of a STRING array. */
/***********************************************************************/ /***********************************************************************/
char *ARRAY::GetStringValue(int n) char *ARRAY::GetStringValue(int n)
{ {
assert (Type == TYPE_STRING); assert (Type == TYPE_STRING || Type == TYPE_PCHAR);
return Vblp->GetCharValue(n); return Vblp->GetCharValue(n);
} // end of GetStringValue } // end of GetStringValue
...@@ -765,6 +796,44 @@ bool ARRAY::Sort(PGLOBAL g) ...@@ -765,6 +796,44 @@ bool ARRAY::Sort(PGLOBAL g)
return TRUE; return TRUE;
} // end of Sort } // end of Sort
/***********************************************************************/
/* Sort and return the sort index. */
/* Note: This is meant if the array contains unique values. */
/* Returns Index.Memp if Ok or NULL in case of error. */
/***********************************************************************/
void *ARRAY::GetSortIndex(PGLOBAL g)
{
// Prepare non conservative sort with offet values
Index.Size = Nval * sizeof(int);
if (!PlgDBalloc(g, NULL, Index))
goto error;
Offset.Size = (Nval + 1) * sizeof(int);
if (!PlgDBalloc(g, NULL, Offset))
goto error;
// Call the sort program, it returns the number of distinct values
Ndif = Qsort(g, Nval);
if (Ndif < 0)
goto error;
if (Ndif < Nval)
goto error;
PlgDBfree(Offset);
return Index.Memp;
error:
Nval = Ndif = 0;
Valblk->Free();
PlgDBfree(Index);
PlgDBfree(Offset);
return NULL;
} // end of GetSortIndex
/***********************************************************************/ /***********************************************************************/
/* Block filter testing for IN operator on Column/Array operands. */ /* Block filter testing for IN operator on Column/Array operands. */
/* Here we call Find that returns TRUE if the value is in the array */ /* Here we call Find that returns TRUE if the value is in the array */
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
/* */ /* */
/* This file contains the ARRAY and VALBASE derived classes declares. */ /* This file contains the ARRAY and VALBASE derived classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __ARRAY_H
#define __ARRAY_H
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
...@@ -57,18 +60,21 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock ...@@ -57,18 +60,21 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
// void Empty(void); // void Empty(void);
void SetPrecision(PGLOBAL g, int p); void SetPrecision(PGLOBAL g, int p);
bool AddValue(PGLOBAL g, PSZ sp); bool AddValue(PGLOBAL g, PSZ sp);
bool AddValue(PGLOBAL g, void *p);
bool AddValue(PGLOBAL g, short n); bool AddValue(PGLOBAL g, short n);
bool AddValue(PGLOBAL g, int n); bool AddValue(PGLOBAL g, int n);
bool AddValue(PGLOBAL g, double f); bool AddValue(PGLOBAL g, double f);
bool AddValue(PGLOBAL g, PXOB xp); bool AddValue(PGLOBAL g, PXOB xp);
bool AddValue(PGLOBAL g, PVAL vp); bool AddValue(PGLOBAL g, PVAL vp);
void GetNthValue(PVAL valp, int n); void GetNthValue(PVAL valp, int n);
int GetIntValue(int n);
char *GetStringValue(int n); char *GetStringValue(int n);
BYTE Vcompare(PVAL vp, int n); BYTE Vcompare(PVAL vp, int n);
void Save(int); void Save(int);
void Restore(int); void Restore(int);
void Move(int, int); void Move(int, int);
bool Sort(PGLOBAL g); bool Sort(PGLOBAL g);
void *GetSortIndex(PGLOBAL g);
bool Find(PVAL valp); bool Find(PVAL valp);
bool FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm); bool FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm);
int Convert(PGLOBAL g, int k, PVAL vp = NULL); int Convert(PGLOBAL g, int k, PVAL vp = NULL);
...@@ -120,3 +126,5 @@ class MULAR : public CSORT, public BLOCK { // No need to be an XOBJECT ...@@ -120,3 +126,5 @@ class MULAR : public CSORT, public BLOCK { // No need to be an XOBJECT
int Narray; // The number of sub-arrays int Narray; // The number of sub-arrays
PARRAY *Pars; // To the block of real arrays PARRAY *Pars; // To the block of real arrays
}; // end of class ARRAY }; // end of class ARRAY
#endif // __ARRAY_H
...@@ -169,7 +169,8 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info) ...@@ -169,7 +169,8 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
info->data_file_length= (b) ? (ulonglong)tdbp->GetFileLength(g) : 0; info->data_file_length= (b) ? (ulonglong)tdbp->GetFileLength(g) : 0;
if (!b || info->data_file_length) if (!b || info->data_file_length)
info->records= (unsigned)tdbp->GetMaxSize(g); info->records= (unsigned)tdbp->Cardinality(g);
// info->records= (unsigned)tdbp->GetMaxSize(g);
else else
info->records= 0; info->records= 0;
...@@ -578,6 +579,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort) ...@@ -578,6 +579,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
} // endif } // endif
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) { if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
rc= RC_FX;
g->jump_level--; g->jump_level--;
goto err; goto err;
} // endif } // endif
......
This diff is collapsed.
/*************** FilAMap H Declares Source Code File (.H) **************/ /*************** FilAMap H Declares Source Code File (.H) **************/
/* Name: FILAMAP.H Version 1.2 */ /* Name: FILAMAP.H Version 1.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */ /* */
/* This file contains the MAP file access method classes declares. */ /* This file contains the MAP file access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMAP_H #ifndef __FILAMAP_H
#define __FILAMAP_H #define __FILAMAP_H
#include "block.h" #include "block.h"
#include "filamtxt.h" #include "filamtxt.h"
typedef class MAPFAM *PMAPFAM; typedef class MAPFAM *PMAPFAM;
/***********************************************************************/ /***********************************************************************/
/* This is the variable file access method using file mapping. */ /* This is the variable file access method using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport MAPFAM : public TXTFAM { class DllExport MAPFAM : public TXTFAM {
public: public:
// Constructor // Constructor
MAPFAM(PDOSDEF tdp); MAPFAM(PDOSDEF tdp);
MAPFAM(PMAPFAM tmfp); MAPFAM(PMAPFAM tmfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MAP;} virtual AMT GetAmType(void) {return TYPE_AM_MAP;}
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MAPFAM(this);} {return (PTXF)new(g) MAPFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;} virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual bool DeferReading(void) {return false;} virtual bool DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g, bool abort); virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members bool MakeDeletedFile(PGLOBAL g);
char *Memory; // Pointer on file mapping view.
char *Mempos; // Position of next data to read // Members
char *Fpos; // Position of last read record char *Memory; // Pointer on file mapping view.
char *Tpos; // Target Position for delete move char *Mempos; // Position of next data to read
char *Spos; // Start position for delete move char *Fpos; // Position of last read record
char *Top; // Mark end of file mapping view char *Tpos; // Target Position for delete move
}; // end of class MAPFAM char *Spos; // Start position for delete move
char *Top; // Mark end of file mapping view
/***********************************************************************/ }; // end of class MAPFAM
/* This is the blocked file access method using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport MBKFAM : public MAPFAM { /* This is the blocked file access method using file mapping. */
public: /***********************************************************************/
// Constructor class DllExport MBKFAM : public MAPFAM {
MBKFAM(PDOSDEF tdp); public:
MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {} // Constructor
MBKFAM(PDOSDEF tdp);
// Implementation MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MBKFAM(this);} // Implementation
virtual PTXF Duplicate(PGLOBAL g)
// Methods {return (PTXF)new(g) MBKFAM(this);}
virtual void Reset(void);
virtual int Cardinality(PGLOBAL g); // Methods
virtual int MaxBlkSize(PGLOBAL g, int s) virtual void Reset(void);
{return TXTFAM::MaxBlkSize(g, s);} virtual int Cardinality(PGLOBAL g);
virtual int GetRowID(void); virtual int MaxBlkSize(PGLOBAL g, int s)
virtual int SkipRecord(PGLOBAL g, bool header); {return TXTFAM::MaxBlkSize(g, s);}
virtual int ReadBuffer(PGLOBAL g); virtual int GetRowID(void);
virtual void Rewind(void); virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g);
protected: virtual void Rewind(void);
// No additional members
}; // end of class MBKFAM protected:
// No additional members
/***********************************************************************/ }; // end of class MBKFAM
/* This is the fixed file access method using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport MPXFAM : public MBKFAM { /* This is the fixed file access method using file mapping. */
public: /***********************************************************************/
// Constructor class DllExport MPXFAM : public MBKFAM {
MPXFAM(PDOSDEF tdp); public:
MPXFAM(PMAPFAM tmfp) : MBKFAM(tmfp) {} // Constructor
MPXFAM(PDOSDEF tdp);
// Implementation MPXFAM(PMAPFAM tmfp) : MBKFAM(tmfp) {}
virtual int GetPos(void);
virtual PTXF Duplicate(PGLOBAL g) // Implementation
{return (PTXF)new(g) MPXFAM(this);} virtual int GetPos(void);
virtual PTXF Duplicate(PGLOBAL g)
// Methods {return (PTXF)new(g) MPXFAM(this);}
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s) // Methods
{return TXTFAM::MaxBlkSize(g, s);} virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual bool SetPos(PGLOBAL g, int recpos); virtual int MaxBlkSize(PGLOBAL g, int s)
virtual bool DeferReading(void) {return false;} {return TXTFAM::MaxBlkSize(g, s);}
virtual int ReadBuffer(PGLOBAL g); virtual bool SetPos(PGLOBAL g, int recpos);
virtual int WriteBuffer(PGLOBAL g); virtual bool DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g);
protected: virtual int WriteBuffer(PGLOBAL g);
// No additional members
}; // end of class MPXFAM protected:
// No additional members
#endif // __FILAMAP_H }; // end of class MPXFAM
#endif // __FILAMAP_H
/*********** File AM Dbf C++ Program Source Code File (.CPP) ****************/ /*********** File AM Dbf C++ Program Source Code File (.CPP) ****************/
/* PROGRAM NAME: FILAMDBF */ /* PROGRAM NAME: FILAMDBF */
/* ------------- */ /* ------------- */
/* Version 1.6 */ /* Version 1.7 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -668,12 +668,9 @@ void DBFFAM::ResetBuffer(PGLOBAL g) ...@@ -668,12 +668,9 @@ void DBFFAM::ResetBuffer(PGLOBAL g)
/*********************************************************************/ /*********************************************************************/
/* If access is random, performances can be much better when the */ /* If access is random, performances can be much better when the */
/* reads are done on only one row, except for small tables that can */ /* reads are done on only one row, except for small tables that can */
/* be entirely read in one block. If the index is just used as a */ /* be entirely read in one block. */
/* bitmap filter, as for Update or delete, reading will be */
/* sequential and we better keep block reading. */
/*********************************************************************/ /*********************************************************************/
if (Tdbp->GetKindex() && Tdbp->GetMode() == MODE_READ && if (Tdbp->GetKindex() && ReadBlks != 1) {
ReadBlks != 1) {
Nrec = 1; // Better for random access Nrec = 1; // Better for random access
Rbuf = 0; Rbuf = 0;
Blksize = Lrecl; Blksize = Lrecl;
...@@ -763,12 +760,16 @@ int DBFFAM::DeleteRecords(PGLOBAL g, int irc) ...@@ -763,12 +760,16 @@ int DBFFAM::DeleteRecords(PGLOBAL g, int irc)
// T_Stream is the temporary stream or the table file stream itself // T_Stream is the temporary stream or the table file stream itself
if (!T_Stream) if (!T_Stream)
if (UseTemp) { if (UseTemp) {
if (OpenTempFile(g)) if ((Indxd = Tdbp->GetKindex() != NULL)) {
strcpy(g->Message, "DBF indexed udate using temp file NIY");
return RC_FX;
} else if (OpenTempFile(g))
return RC_FX; return RC_FX;
if (CopyHeader(g)) // For DBF tables if (CopyHeader(g)) // For DBF tables
return RC_FX; return RC_FX;
// Indxd = Tdbp->GetKindex() != NULL;
} else } else
T_Stream = Stream; T_Stream = Stream;
...@@ -796,6 +797,8 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort) ...@@ -796,6 +797,8 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort)
int rc = RC_OK, wrc = RC_OK; int rc = RC_OK, wrc = RC_OK;
MODE mode = Tdbp->GetMode(); MODE mode = Tdbp->GetMode();
Abort = abort;
// Closing is True if last Write was in error // Closing is True if last Write was in error
if (mode == MODE_INSERT && CurNum && !Closing) { if (mode == MODE_INSERT && CurNum && !Closing) {
// Some more inserted lines remain to be written // Some more inserted lines remain to be written
...@@ -810,16 +813,16 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort) ...@@ -810,16 +813,16 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort)
} // endif Modif } // endif Modif
if (UseTemp && T_Stream && wrc == RC_OK) { if (UseTemp && T_Stream && wrc == RC_OK) {
if (!abort) { if (!Abort) {
// Copy any remaining lines // Copy any remaining lines
bool b; bool b;
Fpos = Tdbp->Cardinality(g); Fpos = Tdbp->Cardinality(g);
abort = MoveIntermediateLines(g, &b) != RC_OK; Abort = MoveIntermediateLines(g, &b) != RC_OK;
} // endif abort } // endif Abort
// Delete the old file and rename the new temp file. // Delete the old file and rename the new temp file.
RenameTempFile(g, abort); RenameTempFile(g);
goto fin; goto fin;
} // endif UseTemp } // endif UseTemp
......
This diff is collapsed.
/************** FilAMFix H Declares Source Code File (.H) **************/ /************** FilAMFix H Declares Source Code File (.H) **************/
/* Name: FILAMFIX.H Version 1.3 */ /* Name: FILAMFIX.H Version 1.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005 - 2014 */ /* (C) Copyright to the author Olivier BERTRAND 2005 - 2014 */
/* */ /* */
/* This file contains the FIX file access method classes declares. */ /* This file contains the FIX file access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMFIX_H #ifndef __FILAMFIX_H
#define __FILAMFIX_H #define __FILAMFIX_H
#include "filamtxt.h" #include "filamtxt.h"
typedef class FIXFAM *PFIXFAM; typedef class FIXFAM *PFIXFAM;
typedef class BGXFAM *PBGXFAM; typedef class BGXFAM *PBGXFAM;
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */ /* This is the DOS/UNIX Access Method class declaration for standard */
/* files with fixed record format (FIX, BIN) */ /* files with fixed record format (FIX, BIN) */
/***********************************************************************/ /***********************************************************************/
class DllExport FIXFAM : public BLKFAM { class DllExport FIXFAM : public BLKFAM {
public: public:
// Constructor // Constructor
FIXFAM(PDOSDEF tdp); FIXFAM(PDOSDEF tdp);
FIXFAM(PFIXFAM txfp); FIXFAM(PFIXFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_FIX;} virtual AMT GetAmType(void) {return TYPE_AM_FIX;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) FIXFAM(this);} {return (PTXF)new(g) FIXFAM(this);}
// Methods // Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s) virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);} {return TXTFAM::MaxBlkSize(g, s);}
virtual bool AllocateBuffer(PGLOBAL g); virtual bool SetPos(PGLOBAL g, int recpos);
virtual void ResetBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual void ResetBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int WriteBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g, bool abort);
protected:
virtual bool CopyHeader(PGLOBAL g) {return false;} protected:
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b); virtual bool CopyHeader(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
// No additional members virtual bool MakeDeletedFile(PGLOBAL g);
}; // end of class FIXFAM
// No additional members
}; // end of class FIXFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/* that are standard files with columns starting at fixed offset */ /***********************************************************************/
/* This class is for fixed formatted files of more than 2 gigabytes. */ /* This is the DOS/UNIX Access Method class declaration for files */
/***********************************************************************/ /* that are standard files with columns starting at fixed offset */
class BGXFAM : public FIXFAM { /* This class is for fixed formatted files of more than 2 gigabytes. */
public: /***********************************************************************/
// Constructor class BGXFAM : public FIXFAM {
BGXFAM(PDOSDEF tdp); public:
BGXFAM(PBGXFAM txfp); // Constructor
BGXFAM(PDOSDEF tdp);
// Implementation BGXFAM(PBGXFAM txfp);
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BGXFAM(this);} // Implementation
virtual PTXF Duplicate(PGLOBAL g)
// Methods {return (PTXF)new(g) BGXFAM(this);}
virtual int Cardinality(PGLOBAL g);
virtual bool OpenTableFile(PGLOBAL g); // Methods
virtual int ReadBuffer(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int ReadBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort); virtual int WriteBuffer(PGLOBAL g);
virtual void Rewind(void); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g, bool abort);
protected: virtual void Rewind(void);
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos
, int org = FILE_BEGIN); protected:
int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); virtual bool OpenTempFile(PGLOBAL g);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool OpenTempFile(PGLOBAL g); virtual bool MakeDeletedFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
// Members bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos
HANDLE Hfile; // Handle(descriptor) to big file , int org = FILE_BEGIN);
HANDLE Tfile; // Handle(descriptor) to big temp file
}; // end of class BGXFAM // Members
HANDLE Hfile; // Handle(descriptor) to big file
#endif // __FILAMFIX_H HANDLE Tfile; // Handle(descriptor) to big temp file
}; // end of class BGXFAM
#endif // __FILAMFIX_H
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -1058,6 +1058,31 @@ int ZLBFAM::GetNextPos(void) ...@@ -1058,6 +1058,31 @@ int ZLBFAM::GetNextPos(void)
} // end of GetNextPos } // end of GetNextPos
/***********************************************************************/
/* SetPos: Replace the table at the specified position. */
/***********************************************************************/
bool ZLBFAM::SetPos(PGLOBAL g, int pos)
{
sprintf(g->Message, MSG(NO_SETPOS_YET), "ZIP");
return true;
#if 0 // All this must be checked
if (pos < 0) {
strcpy(g->Message, MSG(INV_REC_POS));
return true;
} // endif recpos
CurBlk = pos / Nrec;
CurNum = pos % Nrec;
#if defined(_DEBUG)
num_eq[(CurBlk == OldBlk) ? 1 : 0]++;
#endif
// Indicate the table position was externally set
Placed = true;
return false;
#endif // 0
} // end of SetPos
/***********************************************************************/ /***********************************************************************/
/* ReadBuffer: Read one line for a text file. */ /* ReadBuffer: Read one line for a text file. */
/***********************************************************************/ /***********************************************************************/
......
...@@ -149,6 +149,7 @@ class DllExport ZLBFAM : public BLKFAM { ...@@ -149,6 +149,7 @@ class DllExport ZLBFAM : public BLKFAM {
// Methods // Methods
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
......
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
#define TYPE_INT 7 #define TYPE_INT 7
#define TYPE_DECIM 9 #define TYPE_DECIM 9
#define TYPE_BIN 10 #define TYPE_BIN 10
#define TYPE_PCHAR 11
#if defined(OS32) #if defined(OS32)
#define SYS_STAMP "OS32" #define SYS_STAMP "OS32"
......
...@@ -558,7 +558,6 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg) ...@@ -558,7 +558,6 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
nox= false; nox= false;
abort= false; abort= false;
indexing= -1; indexing= -1;
only= -1;
locked= 0; locked= 0;
part_id= NULL; part_id= NULL;
data_file_name= NULL; data_file_name= NULL;
...@@ -1593,7 +1592,6 @@ int ha_connect::CloseTable(PGLOBAL g) ...@@ -1593,7 +1592,6 @@ int ha_connect::CloseTable(PGLOBAL g)
indexing= -1; indexing= -1;
nox= false; nox= false;
abort= false; abort= false;
only= -1;
return rc; return rc;
} // end of CloseTable } // end of CloseTable
...@@ -2513,7 +2511,7 @@ ha_rows ha_connect::records() ...@@ -2513,7 +2511,7 @@ ha_rows ha_connect::records()
if (!valid_info) if (!valid_info)
info(HA_STATUS_VARIABLE); info(HA_STATUS_VARIABLE);
if (tdbp && tdbp->Cardinality(NULL)) if (tdbp)
return stats.records; return stats.records;
else else
return HA_POS_ERROR; return HA_POS_ERROR;
...@@ -2877,13 +2875,13 @@ int ha_connect::index_init(uint idx, bool sorted) ...@@ -2877,13 +2875,13 @@ int ha_connect::index_init(uint idx, bool sorted)
xmod= MODE_READX; xmod= MODE_READX;
if (!(rc= rnd_init(0))) { if (!(rc= rnd_init(0))) {
if (xmod == MODE_READX) { // if (xmod == MODE_READX) {
active_index= idx; active_index= idx;
indexing= IsUnique(idx) ? 1 : 2; indexing= IsUnique(idx) ? 1 : 2;
} else { // } else {
active_index= MAX_KEY; // active_index= MAX_KEY;
indexing= 0; // indexing= 0;
} // endif xmod // } // endif xmod
} //endif rc } //endif rc
...@@ -2893,17 +2891,11 @@ int ha_connect::index_init(uint idx, bool sorted) ...@@ -2893,17 +2891,11 @@ int ha_connect::index_init(uint idx, bool sorted)
if ((rc= rnd_init(0))) if ((rc= rnd_init(0)))
DBUG_RETURN(rc); DBUG_RETURN(rc);
if ((xmod == MODE_UPDATE && ((TDBASE*)tdbp)->IsUsingTemp(g)) || if (locked == 2) {
xmod == MODE_DELETE || locked == 2) {
// Indexes are not updated in lock write mode // Indexes are not updated in lock write mode
// and cannot be used for DELETE or UPDATE using temp file. active_index= MAX_KEY;
if (locked == 2 || xmod == MODE_DELETE || !IsUnique(idx)) { indexing= 0;
active_index= MAX_KEY; DBUG_RETURN(0);
indexing= 0;
DBUG_RETURN(0);
} else
only= 1; // Indexing acceptable for only one value
} // endif locked } // endif locked
indexing= CntIndexInit(g, tdbp, (signed)idx); indexing= CntIndexInit(g, tdbp, (signed)idx);
...@@ -2922,6 +2914,7 @@ int ha_connect::index_init(uint idx, bool sorted) ...@@ -2922,6 +2914,7 @@ int ha_connect::index_init(uint idx, bool sorted)
} else // Void table } else // Void table
indexing= 0; indexing= 0;
rc= 0;
} // endif indexing } // endif indexing
if (xtrace) if (xtrace)
...@@ -3017,16 +3010,16 @@ int ha_connect::index_read(uchar * buf, const uchar * key, uint key_len, ...@@ -3017,16 +3010,16 @@ int ha_connect::index_read(uchar * buf, const uchar * key, uint key_len,
if (xtrace > 1) if (xtrace > 1)
htrc("%p index_read: op=%d\n", this, op); htrc("%p index_read: op=%d\n", this, op);
if ((indexing > 0 && (only < 0 || (only == 1 && op == OP_EQ))) if (indexing > 0) {
|| GetIndexType(GetRealType()) == 2) {
rc= ReadIndexed(buf, op, key, key_len); rc= ReadIndexed(buf, op, key, key_len);
only= (only == 1) ? 0 : -1;
} else { if (rc == HA_ERR_INTERNAL_ERROR) {
nox= true; // To block making indexes nox= true; // To block making indexes
abort= true; // Don't rename temp file abort= true; // Don't rename temp file
strcpy(xp->g->Message, "Cannot use indexing for this command"); } // endif rc
} else
rc= HA_ERR_INTERNAL_ERROR; // HA_ERR_KEY_NOT_FOUND ? rc= HA_ERR_INTERNAL_ERROR; // HA_ERR_KEY_NOT_FOUND ?
} // endelse
DBUG_RETURN(rc); DBUG_RETURN(rc);
} // end of index_read } // end of index_read
...@@ -4291,7 +4284,7 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key, ...@@ -4291,7 +4284,7 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
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);
if (indexing > 0 && only < 0) { if (indexing > 0) {
int nval; int nval;
uint len[2]; uint len[2];
const uchar *key[2]; const uchar *key[2];
...@@ -4312,10 +4305,9 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key, ...@@ -4312,10 +4305,9 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
else else
rows= (ha_rows)nval; rows= (ha_rows)nval;
} else if (indexing == 0) { } else if (indexing == 0)
rows= 100000000; // Don't use missing index rows= 100000000; // Don't use missing index
only= -1; else
} else
rows= HA_POS_ERROR; rows= HA_POS_ERROR;
DBUG_RETURN(rows); DBUG_RETURN(rows);
......
...@@ -535,7 +535,6 @@ int index_prev(uchar *buf); ...@@ -535,7 +535,6 @@ int index_prev(uchar *buf);
bool nox; // True when index should not be made bool nox; // True when index should not be made
bool abort; // True after error in UPDATE/DELETE bool abort; // True after error in UPDATE/DELETE
int indexing; // Type of indexing for CONNECT int indexing; // Type of indexing for CONNECT
int only; // If only one action is accepted
int locked; // Table lock int locked; // Table lock
MY_BITMAP *part_id; // Columns used for partition func MY_BITMAP *part_id; // Columns used for partition func
THR_LOCK_DATA lock_data; THR_LOCK_DATA lock_data;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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