Skip to content

Commit

Permalink
- Add a new CONNECT global variable allowing to tell whether or not
Browse files Browse the repository at this point in the history
  a temporary file should be used for UPDATE/DELETE of file tables.
  Also use the "sorted" argument of index_init to help decide if
  sorting of positions must be done.
modified:
  storage/connect/checklvl.h
  storage/connect/connect.cc
  storage/connect/connect.h
  storage/connect/filamdbf.cpp
  storage/connect/filamfix.cpp
  storage/connect/filamfix.h
  storage/connect/filamtxt.cpp
  storage/connect/ha_connect.cc
  storage/connect/mysql-test/connect/r/part_table.result
  storage/connect/plgdbsem.h
  storage/connect/plgdbutl.cpp
  storage/connect/reldef.cpp
  storage/connect/tabdos.cpp
  storage/connect/tabdos.h
  storage/connect/tabfix.cpp
  storage/connect/tabfmt.cpp
  storage/connect/tabvct.cpp
  storage/connect/tabvct.h
  storage/connect/xindex.cpp

- Fix a bug in TDBASE::ColDB that caused some special columns not to
  be found in the column list and reallocated without their Value
  causing a crash of some queries.
modified:
  storage/connect/table.cpp

- Fix a bug causing RestoreNrec to be called before closing a table
  causing a wrong value given to Spos
modified:
  storage/connect/tabdos.cpp
  storage/connect/xindex.cpp

- Add a new CONNECT global variable connect_exact_info. Set to ON, it
  tells CONNECT to return exact record numbers on info queries. If OFF
  it just gives an estimate. In version 10.0.13 this was unconditionally
  ON and caused info queries on remote tables to be extremely long and
  was the subject of MDEV-6612.
modified:
  storage/connect/ha_connect.cc
  storage/connect/tabdos.cpp
  storage/connect/tabmysql.cpp
  storage/connect/tabodbc.cpp
  • Loading branch information
Buggynours committed Aug 22, 2014
1 parent 8b9ed85 commit f930f4e
Show file tree
Hide file tree
Showing 25 changed files with 395 additions and 249 deletions.
7 changes: 4 additions & 3 deletions storage/connect/checklvl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ enum XMOD {XMOD_EXECUTE = 0, /* DOS execution mode */
/***********************************************************************/
/* Following definitions indicate the use of a temporay file. */
/***********************************************************************/
enum USETEMP {TMP_AUTO = 0, /* Best choice */
TMP_NO = 1, /* Never */
enum USETEMP {TMP_NO = 0, /* Never */
TMP_AUTO = 1, /* Best choice */
TMP_YES = 2, /* Always */
TMP_FORCE = 3}; /* Forced for MAP tables */
TMP_FORCE = 3, /* Forced for MAP tables */
TMP_TEST = 4}; /* Testing value */

#endif // _CHKLVL_DEFINED_
34 changes: 13 additions & 21 deletions storage/connect/connect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
return true;

((MYCAT *)dbuserp->Catalog)->SetDataPath(g, pathname);
dbuserp->UseTemp= TMP_AUTO;
//dbuserp->UseTemp= TMP_AUTO;

/*********************************************************************/
/* All is correct. */
Expand Down Expand Up @@ -503,8 +503,6 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
if (!colp->GetColUse(U_VIRTUAL))
colp->WriteColumn(g);

//if (tp->GetMode() == MODE_UPDATE && tp->IsUsingTemp(g) &&
// tp->GetKindex() && !tp->GetKindex()->IsSorted())
if (tp->IsIndexed())
// Index values must be sorted before updating
rc= (RCODE)((PTDBDOS)tp)->GetTxfp()->StoreValues(g, true);
Expand Down Expand Up @@ -580,21 +578,6 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
printf("CntCloseTable: tdbp=%p mode=%d nox=%d abort=%d\n",
tdbp, tdbp->GetMode(), nox, abort);

#if 0
if (tbxp->GetMode() == MODE_UPDATE &&
tbxp->GetKindex() && !tbxp->GetKindex()->IsSorted()) {
rc= tbxp->Txfp->UpdateSortedRows(g);
} else
if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN) {
if (tbxp->GetKindex() && !tbxp->GetKindex()->IsSorted())
rc= tbxp->Txfp->DeleteSortedRows(g);

if (!rc)
rc= tdbp->DeleteDB(g, RC_EF); // Specific A.M. delete routine

} // endif Mode
#endif // 0

if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN) {
if (tbxp->IsIndexed())
rc= ((PTDBDOS)tdbp)->GetTxfp()->DeleteSortedRows(g);
Expand All @@ -605,6 +588,15 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
} else if (tbxp->GetMode() == MODE_UPDATE && tbxp->IsIndexed())
rc= ((PTDBDOX)tdbp)->Txfp->UpdateSortedRows(g);

switch(rc) {
case RC_FX:
abort= true;
break;
case RC_INFO:
PushWarning(g, tbxp);
break;
} // endswitch rc

// Prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
Expand Down Expand Up @@ -655,7 +647,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
/* This is the condition(s) for doing indexing. */
/* Note: FIX table are not reset here to Nrec= 1. */
/***********************************************************************/
int CntIndexInit(PGLOBAL g, PTDB ptdb, int id)
int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted)
{
PIXDEF xdp;
PTDBDOX tdbp;
Expand Down Expand Up @@ -707,7 +699,7 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id)
#endif // 0

// Static indexes must be initialized now for records_in_range
if (tdbp->InitialyzeIndex(g, xdp))
if (tdbp->InitialyzeIndex(g, xdp, sorted))
return 0;

return (tdbp->To_Kindex->IsMul()) ? 2 : 1;
Expand Down Expand Up @@ -754,7 +746,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
#if 0
} // endif !To_Xdp
// Now it's time to make the dynamic index
if (tdbp->InitialyzeIndex(g, NULL)) {
if (tdbp->InitialyzeIndex(g, NULL, false)) {
sprintf(g->Message, "Fail to make dynamic index %s",
tdbp->To_Xdp->GetName());
return RC_FX;
Expand Down
8 changes: 4 additions & 4 deletions storage/connect/connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PTDB CntGetTDB(PGLOBAL g, const char *name, MODE xmod, PHC);
bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE, char *, char *, bool, PHC);
bool CntRewindTable(PGLOBAL g, PTDB tdbp);
int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort);
int CntIndexInit(PGLOBAL g, PTDB tdbp, int id);
int CntIndexInit(PGLOBAL g, PTDB tdbp, int id, bool sorted);
RCODE CntReadNext(PGLOBAL g, PTDB tdbp);
RCODE CntIndexRead(PGLOBAL g, PTDB, OPVAL op, const void *k, int n, bool mrr);
RCODE CntWriteRow(PGLOBAL g, PTDB tdbp);
Expand All @@ -50,7 +50,7 @@ PGLOBAL CntExit(PGLOBAL g);
/* These classes purpose is chiefly to access protected items! */
/***********************************************************************/
class DOXDEF: public DOSDEF {
friend int CntIndexInit(PGLOBAL, PTDB, int);
friend int CntIndexInit(PGLOBAL, PTDB, int, bool);
}; // end of class DOXDEF

/***********************************************************************/
Expand All @@ -59,7 +59,7 @@ class DOXDEF: public DOSDEF {
class TDBDOX: public TDBDOS {
friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntCloseTable(PGLOBAL, PTDB, bool, bool);
friend int CntIndexInit(PGLOBAL, PTDB, int);
friend int CntIndexInit(PGLOBAL, PTDB, int, bool);
friend RCODE CntIndexRead(PGLOBAL, PTDB, OPVAL, const void*, int, bool);
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool);
friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*,
Expand All @@ -70,7 +70,7 @@ class TDBDOX: public TDBDOS {
class XKPDEF: public KPARTDEF {
friend class TDBDOX;
friend class ha_connect;
friend int CntIndexInit(PGLOBAL, PTDB, int);
friend int CntIndexInit(PGLOBAL, PTDB, int, bool);
public:
XKPDEF(const char *name, int n) : KPARTDEF((PSZ)name, n) {}
}; // end of class XKPDEF
2 changes: 1 addition & 1 deletion storage/connect/filamdbf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort)
if (Modif && !Closing) {
// Last updated block remains to be written
Closing = true;
wrc = ReadBuffer(g);
wrc = WriteModifiedBlock(g);
} // endif Modif

if (UseTemp && T_Stream && wrc == RC_OK) {
Expand Down
Loading

0 comments on commit f930f4e

Please sign in to comment.