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)
case TYPE_DOUBLE:
par->AddValue(g, *(double*)parmp->Value);
break;
case TYPE_PCHAR:
par->AddValue(g, parmp->Value);
break;
} // endswitch valtyp
/*********************************************************************/
......@@ -156,6 +159,7 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec)
case TYPE_SHORT:
case TYPE_INT:
case TYPE_DOUBLE:
case TYPE_PCHAR:
break;
#if 0
case TYPE_TOKEN:
......@@ -172,12 +176,13 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec)
} // endswitch type
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
Type = TYPE_ERROR;
else
else if (type != TYPE_PCHAR)
Value = AllocateValue(g, type, Len, prec, NULL);
Constant = TRUE;
......@@ -288,7 +293,24 @@ bool ARRAY::AddValue(PGLOBAL g, PSZ strp)
} // 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)
{
......@@ -307,7 +329,7 @@ bool ARRAY::AddValue(PGLOBAL g, short n)
} // 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)
{
......@@ -404,15 +426,24 @@ bool ARRAY::GetSubValue(PGLOBAL g, PVAL valp, int *kp)
vblp = ((LSTBLK*)Vblp)->Mbvk[kp[0]]->Vblk;
valp->SetValue_pvblk(vblp, kp[1]);
return FALSE;
} // end of GetNthValue
} // end of GetSubValue
#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. */
/***********************************************************************/
char *ARRAY::GetStringValue(int n)
{
assert (Type == TYPE_STRING);
assert (Type == TYPE_STRING || Type == TYPE_PCHAR);
return Vblp->GetCharValue(n);
} // end of GetStringValue
......@@ -765,6 +796,44 @@ bool ARRAY::Sort(PGLOBAL g)
return TRUE;
} // 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. */
/* Here we call Find that returns TRUE if the value is in the array */
......
......@@ -5,6 +5,9 @@
/* */
/* This file contains the ARRAY and VALBASE derived classes declares. */
/***********************************************************************/
#ifndef __ARRAY_H
#define __ARRAY_H
/***********************************************************************/
/* Include required application header files */
......@@ -57,18 +60,21 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
// void Empty(void);
void SetPrecision(PGLOBAL g, int p);
bool AddValue(PGLOBAL g, PSZ sp);
bool AddValue(PGLOBAL g, void *p);
bool AddValue(PGLOBAL g, short n);
bool AddValue(PGLOBAL g, int n);
bool AddValue(PGLOBAL g, double f);
bool AddValue(PGLOBAL g, PXOB xp);
bool AddValue(PGLOBAL g, PVAL vp);
void GetNthValue(PVAL valp, int n);
int GetIntValue(int n);
char *GetStringValue(int n);
BYTE Vcompare(PVAL vp, int n);
void Save(int);
void Restore(int);
void Move(int, int);
bool Sort(PGLOBAL g);
void *GetSortIndex(PGLOBAL g);
bool Find(PVAL valp);
bool FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm);
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
int Narray; // The number of sub-arrays
PARRAY *Pars; // To the block of real arrays
}; // end of class ARRAY
#endif // __ARRAY_H
......@@ -169,7 +169,8 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
info->data_file_length= (b) ? (ulonglong)tdbp->GetFileLength(g) : 0;
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
info->records= 0;
......@@ -578,6 +579,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
} // endif
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
rc= RC_FX;
g->jump_level--;
goto err;
} // endif
......
/*********** File AM Map C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: FILAMAP */
/* ------------- */
/* Version 1.5 */
/* Version 1.6 */
/* */
/* COPYRIGHT: */
/* ---------- */
......@@ -48,6 +48,11 @@
extern "C" int trace;
/***********************************************************************/
/* Routine called externally by MAPFAM MakeDeletedFile function. */
/***********************************************************************/
PARRAY MakeValueArray(PGLOBAL g, PPARM pp);
/* --------------------------- Class MAPFAM -------------------------- */
/***********************************************************************/
......@@ -398,16 +403,23 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
} // endif irc
if (Tpos == Spos)
if (Tpos == Spos) {
/*******************************************************************/
/* First line to delete. Move of eventual preceeding lines is */
/* not required here, just setting of future Spos and Tpos. */
/*******************************************************************/
Tpos = Fpos; // Spos is set below
else if ((n = Fpos - Spos) > 0) {
/*******************************************************************/
Tpos = Spos = Fpos;
Indxd = Tdbp->GetKindex() != NULL;
} // endif Tpos
if (Indxd) {
// Moving will be done later, must be done in sequential order
(void)AddListValue(g, TYPE_PCHAR, Fpos, &To_Pos);
(void)AddListValue(g, TYPE_PCHAR, Mempos, &To_Sos);
} else if ((n = Fpos - Spos) > 0) {
/*****************************************************************/
/* Non consecutive line to delete. Move intermediate lines. */
/*******************************************************************/
/*****************************************************************/
memmove(Tpos, Spos, n);
Tpos += n;
......@@ -425,6 +437,10 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
} else if (To_Fb) { // Can be NULL for deleted files
/*******************************************************************/
/* Last call after EOF has been reached. */
/*******************************************************************/
Abort = (Indxd && MakeDeletedFile(g));
/*******************************************************************/
/* We must firstly Unmap the view and use the saved file handle */
/* to put an EOF at the end of the copied part of the file. */
/*******************************************************************/
......@@ -433,9 +449,10 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
CloseMemMap(fp->Memory, (size_t)fp->Length);
fp->Count = 0; // Avoid doing it twice
/*******************************************************************/
if (!Abort) {
/*****************************************************************/
/* Remove extra records. */
/*******************************************************************/
/*****************************************************************/
n = Tpos - Memory;
#if defined(WIN32)
......@@ -458,7 +475,6 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
return RC_FX;
} // endif
CloseHandle(fp->Handle);
#else // UNIX
if (ftruncate(fp->Handle, (off_t)n)) {
sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
......@@ -466,6 +482,12 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
return RC_FX;
} // endif
#endif // UNIX
} // endif Abort
#if defined(WIN32)
CloseHandle(fp->Handle);
#else // UNIX
close(fp->Handle);
#endif // UNIX
} // endif irc
......@@ -473,6 +495,55 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
return RC_OK; // All is correct
} // end of DeleteRecords
/***********************************************************************/
/* MakeDeletedFile. When deleting using indexing, the issue is that */
/* record are not necessarily deleted in sequential order. Moving */
/* intermediate lines cannot be done while deleting them. */
/* What we do here is to reorder the deleted records and move the */
/* intermediate files from the ordered deleted record positions. */
/***********************************************************************/
bool MAPFAM::MakeDeletedFile(PGLOBAL g)
{
int *ix, i, n;
/*********************************************************************/
/* Make and order the arrays from the saved values. */
/*********************************************************************/
if (!(Posar = MakeValueArray(g, To_Pos))) {
strcpy(g->Message, "Position array is null");
goto err;
} else if (!(Sosar = MakeValueArray(g, To_Sos))) {
strcpy(g->Message, "Start position array is null");
goto err;
} else if (!(ix = (int*)Posar->GetSortIndex(g))) {
strcpy(g->Message, "Error getting array sort index");
goto err;
} // endif's
for (i = 0; i < Posar->GetNval(); i++) {
Fpos = Posar->GetStringValue(ix[i]);
if (!i) {
Tpos = Fpos;
} else if ((n = Fpos - Spos) >= 0) {
// Move all not deleted lines preceding this one
memmove(Tpos, Spos, n);
Tpos += n;
} // endif n
// New start position
Spos = Sosar->GetStringValue(ix[i]);
} // endfor i
return false;
err:
if (trace)
htrc("%s\n", g->Message);
return true;
} // end of MakeDeletedFile
/***********************************************************************/
/* Table file close routine for MAP access method. */
/***********************************************************************/
......
/*************** 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. */
/***********************************************************************/
......@@ -47,6 +47,8 @@ class DllExport MAPFAM : public TXTFAM {
virtual void Rewind(void);
protected:
bool MakeDeletedFile(PGLOBAL g);
// Members
char *Memory; // Pointer on file mapping view.
char *Mempos; // Position of next data to read
......
/*********** File AM Dbf C++ Program Source Code File (.CPP) ****************/
/* PROGRAM NAME: FILAMDBF */
/* ------------- */
/* Version 1.6 */
/* Version 1.7 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -668,12 +668,9 @@ void DBFFAM::ResetBuffer(PGLOBAL g)
/*********************************************************************/
/* If access is random, performances can be much better when the */
/* 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 */
/* bitmap filter, as for Update or delete, reading will be */
/* sequential and we better keep block reading. */
/* be entirely read in one block. */
/*********************************************************************/
if (Tdbp->GetKindex() && Tdbp->GetMode() == MODE_READ &&
ReadBlks != 1) {
if (Tdbp->GetKindex() && ReadBlks != 1) {
Nrec = 1; // Better for random access
Rbuf = 0;
Blksize = Lrecl;
......@@ -763,12 +760,16 @@ int DBFFAM::DeleteRecords(PGLOBAL g, int irc)
// T_Stream is the temporary stream or the table file stream itself
if (!T_Stream)
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;
if (CopyHeader(g)) // For DBF tables
return RC_FX;
// Indxd = Tdbp->GetKindex() != NULL;
} else
T_Stream = Stream;
......@@ -796,6 +797,8 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort)
int rc = RC_OK, wrc = RC_OK;
MODE mode = Tdbp->GetMode();
Abort = abort;
// Closing is True if last Write was in error
if (mode == MODE_INSERT && CurNum && !Closing) {
// Some more inserted lines remain to be written
......@@ -810,16 +813,16 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort)
} // endif Modif
if (UseTemp && T_Stream && wrc == RC_OK) {
if (!abort) {
if (!Abort) {
// Copy any remaining lines
bool b;
Fpos = Tdbp->Cardinality(g);
abort = MoveIntermediateLines(g, &b) != RC_OK;
} // endif abort
Abort = MoveIntermediateLines(g, &b) != RC_OK;
} // endif Abort
// Delete the old file and rename the new temp file.
RenameTempFile(g, abort);
RenameTempFile(g);
goto fin;
} // endif UseTemp
......
This diff is collapsed.
......@@ -33,6 +33,7 @@ class DllExport FIXFAM : public BLKFAM {
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);}
virtual bool SetPos(PGLOBAL g, int recpos);
virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
......@@ -43,6 +44,7 @@ class DllExport FIXFAM : public BLKFAM {
protected:
virtual bool CopyHeader(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
virtual bool MakeDeletedFile(PGLOBAL g);
// No additional members
}; // end of class FIXFAM
......@@ -73,12 +75,13 @@ class BGXFAM : public FIXFAM {
virtual void Rewind(void);
protected:
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos
, int org = FILE_BEGIN);
int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool MakeDeletedFile(PGLOBAL g);
int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos
, int org = FILE_BEGIN);
// Members
HANDLE Hfile; // Handle(descriptor) to big file
......
This diff is collapsed.
/************** FilAMTxt H Declares Source Code File (.H) **************/
/* Name: FILAMTXT.H Version 1.2 */
/* Name: FILAMTXT.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 file access method classes declares. */
/***********************************************************************/
......@@ -10,6 +10,7 @@
#define __FILAMTXT_H
#include "block.h"
#include "array.h"
typedef class TXTFAM *PTXF;
typedef class DOSFAM *PDOSFAM;
......@@ -70,10 +71,18 @@ class DllExport TXTFAM : public BLOCK {
virtual void Rewind(void) = 0;
protected:
bool AddListValue(PGLOBAL g, int type, void *val, PPARM *top);
// Members
PTDBDOS Tdbp; // To table class
PSZ To_File; // Points to table file name
PFBLOCK To_Fb; // Pointer to file block
PPARM To_Pos; // Pointer to position list
PPARM To_Sos; // Pointer to start position list
PPARM To_Upd; // Pointer to udated line list
PARRAY Posar; // Pointer to position array
PARRAY Sosar; // Pointer to start position array
PARRAY Updar; // Pointer to udated lines array
bool Placed; // true if Recpos was externally set
bool IsRead; // false for deferred reading
bool Blocked; // true if using blocked I/O
......@@ -100,6 +109,8 @@ class DllExport TXTFAM : public BLOCK {
int Ending; // Length of line end
bool Padded; // true if fixed size blocks are padded
bool Eof; // true if an EOF (0xA) character exists
bool Indxd; // True for indexed UPDATE/DELETE
bool Abort; // To abort on error
char *CrLf; // End of line character(s)
}; // end of class TXTFAM
......@@ -112,6 +123,7 @@ class DllExport DOSFAM : public TXTFAM {
// Constructor
DOSFAM(PDOSDEF tdp);
DOSFAM(PDOSFAM txfp);
DOSFAM(PBLKFAM tdfp, PDOSDEF tdp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DOS;}
......@@ -141,7 +153,9 @@ class DllExport DOSFAM : public TXTFAM {
protected:
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
virtual int RenameTempFile(PGLOBAL g, bool abort);
virtual int RenameTempFile(PGLOBAL g);
virtual bool MakeUpdatedFile(PGLOBAL g);
virtual bool MakeDeletedFile(PGLOBAL g);
// Members
FILE *Stream; // Points to Dos file structure
......@@ -149,8 +163,8 @@ class DllExport DOSFAM : public TXTFAM {
PFBLOCK To_Fbt; // Pointer to temp file block
int Fpos; // Position of last read record
int Tpos; // Target Position for delete move
int Spos; // Start position for delete move
bool UseTemp; // True to use a temporary file in Delete
int Spos; // Start position for update/delete move
bool UseTemp; // True to use a temporary file in Upd/Del
bool Bin; // True to force binary mode
}; // end of class DOSFAM
......
This diff is collapsed.
......@@ -66,6 +66,7 @@ class DllExport VCTFAM : public FIXFAM {
virtual bool MoveLines(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g);
virtual bool MakeDeletedFile(PGLOBAL g);
virtual int GetBlockInfo(PGLOBAL g);
virtual bool SetBlockInfo(PGLOBAL g);
bool ResetTableSize(PGLOBAL g, int block, int last);
......@@ -112,7 +113,10 @@ class DllExport VCMFAM : public VCTFAM {
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g, bool abort);
protected:
// Specific functions
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool MakeDeletedFile(PGLOBAL g);
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
......@@ -157,7 +161,8 @@ class DllExport VECFAM : public VCTFAM {
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveLines(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual int RenameTempFile(PGLOBAL g, bool abort);
virtual int RenameTempFile(PGLOBAL g);
virtual bool MakeDeletedFile(PGLOBAL g);
bool OpenColumnFile(PGLOBAL g, char *opmode, int i);
// Members
......@@ -194,6 +199,7 @@ class DllExport VMPFAM : public VCMFAM {
virtual void CloseTableFile(PGLOBAL g, bool abort);
protected:
virtual bool MakeDeletedFile(PGLOBAL g);
bool MapColumnFile(PGLOBAL g, MODE mode, int i);
// Members
......
......@@ -1058,6 +1058,31 @@ int ZLBFAM::GetNextPos(void)
} // 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. */
/***********************************************************************/
......
......@@ -149,6 +149,7 @@ class DllExport ZLBFAM : public BLKFAM {
// Methods
virtual int GetFileLength(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
......
......@@ -85,6 +85,7 @@
#define TYPE_INT 7
#define TYPE_DECIM 9
#define TYPE_BIN 10
#define TYPE_PCHAR 11
#if defined(OS32)
#define SYS_STAMP "OS32"
......
......@@ -558,7 +558,6 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
nox= false;
abort= false;
indexing= -1;
only= -1;
locked= 0;
part_id= NULL;
data_file_name= NULL;
......@@ -1593,7 +1592,6 @@ int ha_connect::CloseTable(PGLOBAL g)
indexing= -1;
nox= false;
abort= false;
only= -1;
return rc;
} // end of CloseTable
......@@ -2513,7 +2511,7 @@ ha_rows ha_connect::records()
if (!valid_info)
info(HA_STATUS_VARIABLE);
if (tdbp && tdbp->Cardinality(NULL))
if (tdbp)
return stats.records;
else
return HA_POS_ERROR;
......@@ -2877,13 +2875,13 @@ int ha_connect::index_init(uint idx, bool sorted)
xmod= MODE_READX;
if (!(rc= rnd_init(0))) {
if (xmod == MODE_READX) {
// if (xmod == MODE_READX) {
active_index= idx;
indexing= IsUnique(idx) ? 1 : 2;
} else {
active_index= MAX_KEY;
indexing= 0;
} // endif xmod
// } else {
// active_index= MAX_KEY;
// indexing= 0;
// } // endif xmod
} //endif rc
......@@ -2893,17 +2891,11 @@ int ha_connect::index_init(uint idx, bool sorted)
if ((rc= rnd_init(0)))
DBUG_RETURN(rc);
if ((xmod == MODE_UPDATE && ((TDBASE*)tdbp)->IsUsingTemp(g)) ||
xmod == MODE_DELETE || locked == 2) {
if (locked == 2) {
// Indexes are not updated in lock write mode
// and cannot be used for DELETE or UPDATE using temp file.
if (locked == 2 || xmod == MODE_DELETE || !IsUnique(idx)) {
active_index= MAX_KEY;
indexing= 0;
DBUG_RETURN(0);
} else
only= 1; // Indexing acceptable for only one value
} // endif locked
indexing= CntIndexInit(g, tdbp, (signed)idx);
......@@ -2922,6 +2914,7 @@ int ha_connect::index_init(uint idx, bool sorted)
} else // Void table
indexing= 0;
rc= 0;
} // endif indexing
if (xtrace)
......@@ -3017,16 +3010,16 @@ int ha_connect::index_read(uchar * buf, const uchar * key, uint key_len,
if (xtrace > 1)
htrc("%p index_read: op=%d\n", this, op);
if ((indexing > 0 && (only < 0 || (only == 1 && op == OP_EQ)))
|| GetIndexType(GetRealType()) == 2) {
if (indexing > 0) {
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
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 ?
} // endelse
DBUG_RETURN(rc);
} // end of index_read
......@@ -4291,7 +4284,7 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
if (xtrace)
htrc("records_in_range: inx=%d indexing=%d\n", inx, indexing);
if (indexing > 0 && only < 0) {
if (indexing > 0) {
int nval;
uint len[2];
const uchar *key[2];
......@@ -4312,10 +4305,9 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
else
rows= (ha_rows)nval;
} else if (indexing == 0) {
} else if (indexing == 0)
rows= 100000000; // Don't use missing index
only= -1;
} else
else
rows= HA_POS_ERROR;
DBUG_RETURN(rows);
......
......@@ -535,7 +535,6 @@ int index_prev(uchar *buf);
bool nox; // True when index should not be made
bool abort; // True after error in UPDATE/DELETE
int indexing; // Type of indexing for CONNECT
int only; // If only one action is accepted
int locked; // Table lock
MY_BITMAP *part_id; // Columns used for partition func
THR_LOCK_DATA lock_data;
......
......@@ -103,7 +103,7 @@ int MACINFO::GetNadap(PGLOBAL g)
} // endif MaxSize
return N;
} // end of GetMaxSize
} // end of GetNadap
/***********************************************************************/
/* GetMacInfo: Get info for all found adapters. */
......
......@@ -144,14 +144,16 @@ SELECT * FROM t1 WHERE id = 35;
id msg
35 thirty five
UPDATE t1 SET msg = 'number' WHERE id in (60,72);
ERROR HY000: Got error 122 'Remote: Got error 122 'Cannot use indexing for this command' from CONNECT' from CONNECT
Warnings:
Note 1105 xt3: 2 affected rows
Note 1105 xt3: 0 affected rows
UPDATE t1 SET msg = 'soixante' WHERE id = 60;
Warnings:
Note 1105 xt3: 1 affected rows
SELECT * FROM t1 WHERE id > 50;
id msg
60 soixante
72 seventy two
72 number
81 eighty one
UPDATE t1 SET msg = 'big' WHERE id > 50;
Warnings:
......@@ -173,7 +175,20 @@ id msg
60 big
81 big
DELETE FROM t1 WHERE id in (60,72);
ERROR HY000: Got error 122 'Remote: Got error 122 'Cannot use indexing for this command' from CONNECT' from CONNECT
Warnings:
Note 1105 xt3: 2 affected rows
Note 1105 xt3: 0 affected rows
SELECT * FROM t1;
id msg
4 four
7 sept
1 one
8 eight
40 forty
10 ten
11 eleven
35 thirty five
81 big
DROP TABLE t1;
DROP TABLE xt1;
DROP TABLE xt2;
......
......@@ -71,15 +71,14 @@ SELECT * FROM t1;
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE id = 81;
SELECT * FROM t1 WHERE id = 7;
SELECT * FROM t1 WHERE id = 35;
--error ER_GET_ERRMSG
UPDATE t1 SET msg = 'number' WHERE id in (60,72);
UPDATE t1 SET msg = 'soixante' WHERE id = 60;
SELECT * FROM t1 WHERE id > 50;
UPDATE t1 SET msg = 'big' WHERE id > 50;
UPDATE t1 SET msg = 'sept' WHERE id = 7;
SELECT * FROM t1;
--error ER_GET_ERRMSG
DELETE FROM t1 WHERE id in (60,72);
SELECT * FROM t1;
DROP TABLE t1;
DROP TABLE xt1;
DROP TABLE xt2;
......
......@@ -567,6 +567,7 @@ DllExport PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
/* Exported utility routines. */
/***********************************************************************/
DllExport FILE *PlugOpenFile(PGLOBAL, LPCSTR, LPCSTR);
DllExport FILE *PlugReopenFile(PGLOBAL, PFBLOCK, LPCSTR);
DllExport int PlugCloseFile(PGLOBAL, PFBLOCK, bool all = false);
DllExport void PlugCleanup(PGLOBAL, bool);
DllExport bool GetPromptAnswer(PGLOBAL, char *);
......
......@@ -832,6 +832,23 @@ FILE *PlugOpenFile(PGLOBAL g, LPCSTR fname, LPCSTR ftype)
return (fop);
} // end of PlugOpenFile
/***********************************************************************/
/* Close file routine: the purpose of this routine is to avoid */
/* double closing that freeze the system on some Unix platforms. */
/***********************************************************************/
FILE *PlugReopenFile(PGLOBAL g, PFBLOCK fp, LPCSTR md)
{
FILE *fop;
if ((fop = global_fopen(g, MSGID_OPEN_MODE_STRERROR, fp->Fname, md))) {
fp->Count = 1;
fp->Type = TYPE_FB_FILE;
fp->File = fop;
} /* endif fop */
return (fop);
} // end of PlugOpenFile
/***********************************************************************/
/* Close file routine: the purpose of this routine is to avoid */
/* double closing that freeze the system on some Unix platforms. */
......
This diff is collapsed.
......@@ -152,7 +152,7 @@ class DllExport TDBDOS : public TDBASE {
virtual int GetFileLength(PGLOBAL g) {return Txfp->GetFileLength(g);}
virtual int GetProgMax(PGLOBAL g);
virtual int GetProgCur(void);
virtual int GetAffectedRows(void) {return Txfp->GetDelRows();}
//virtual int GetAffectedRows(void) {return Txfp->GetDelRows();}
virtual int GetRecpos(void) {return Txfp->GetPos();}
virtual bool SetRecpos(PGLOBAL g, int recpos)
{return Txfp->SetPos(g, recpos);}
......@@ -184,7 +184,6 @@ class DllExport TDBDOS : public TDBASE {
PBF To_BlkFil; // To evaluation block filter
PFIL SavFil; // Saved hidden filter
char *To_Line; // Points to current processed line
RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT)
bool Abort; // TRUE when aborting UPDATE/DELETE
int Lrecl; // Logical Record Length
int AvgLen; // Logical Record Average Length
......
......@@ -176,9 +176,11 @@ void TDBFIX::RestoreNrec(void)
Txfp->Nrec = (To_Def && To_Def->GetElemt()) ? To_Def->GetElemt()
: DOS_BUFF_LEN;
Txfp->Blksize = Txfp->Nrec * Txfp->Lrecl;
assert(Cardinal >= 0);
if (Cardinal >= 0)
Txfp->Block = (Cardinal > 0)
? (Cardinal + Txfp->Nrec - 1) / Txfp->Nrec : 0;
} // endif Padded
} // end of RestoreNrec
......
......@@ -143,6 +143,7 @@ TDBASE::TDBASE(PTABDEF tdp) : TDB(tdp)
To_Kindex = NULL;
To_Xdp = NULL;
To_SetCols = NULL;
Ftype = RECFM_NAF;
MaxSize = -1;
Knum = 0;
Read_Only = (tdp) ? tdp->IsReadOnly() : false;
......@@ -157,6 +158,7 @@ TDBASE::TDBASE(PTDBASE tdbp) : TDB(tdbp)
To_Kindex = tdbp->To_Kindex;
To_Xdp = tdbp->To_Xdp;
To_SetCols = tdbp->To_SetCols; // ???
Ftype = tdbp->Ftype;
MaxSize = tdbp->MaxSize;
Knum = tdbp->Knum;
Read_Only = tdbp->Read_Only;
......
......@@ -58,6 +58,7 @@ class TDBMAC : public TDBASE {
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int Cardinality(PGLOBAL g) {return GetMaxSize(g);}
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
......
......@@ -771,7 +771,8 @@ int TDBMYSQL::Cardinality(PGLOBAL g)
Cardinal = myc.GetTableSize(g, query);
myc.Close();
} // endif Cardinal
} else
Cardinal = 10; // To make MySQL happy
return Cardinal;
} // end of Cardinality
......
......@@ -81,7 +81,7 @@ class TDBMYSQL : public TDBASE {
// Methods
virtual PTDB CopyOne(PTABS t);
virtual int GetAffectedRows(void) {return AftRows;}
//virtual int GetAffectedRows(void) {return AftRows;}
virtual int GetRecpos(void) {return N;}
virtual int GetProgMax(PGLOBAL g);
virtual void ResetDB(void) {N = 0;}
......
......@@ -696,7 +696,8 @@ int TDBODBC::Cardinality(PGLOBAL g)
return -3;
ocp->Close();
} // endif Cardinal
} else
Cardinal = 10; // To make MySQL happy
return Cardinal;
} // end of Cardinality
......
......@@ -88,7 +88,7 @@ class TDBODBC : public TDBASE {
virtual PSZ GetFile(PGLOBAL g);
virtual void SetFile(PGLOBAL g, PSZ fn);
virtual void ResetSize(void);
virtual int GetAffectedRows(void) {return AftRows;}
//virtual int GetAffectedRows(void) {return AftRows;}
virtual PSZ GetServer(void) {return "ODBC";}
virtual int Indexable(void) {return 2;}
......
......@@ -105,6 +105,7 @@ class TDBPIVOT : public TDBPRX {
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int Cardinality(PGLOBAL g) {return (g) ? 10 : 0;}
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
......
......@@ -60,7 +60,7 @@ class TDBINI : public TDBASE {
virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void) {return N;}
virtual int GetProgCur(void) {return N;}
virtual int GetAffectedRows(void) {return 0;}
//virtual int GetAffectedRows(void) {return 0;}
virtual PSZ GetFile(PGLOBAL g) {return Ifile;}
virtual void SetFile(PGLOBAL g, PSZ fn) {Ifile = fn;}
virtual void ResetDB(void) {Seclist = Section = NULL; N = 0;}
......
......@@ -350,7 +350,34 @@ bool TDBTBL::TestFil(PGLOBAL g, PCFIL filp, PTABLE tabp)
} // end of TestFil
/***********************************************************************/
/* Sum up the sizes of all sub-tables. */
/* Sum up the cardinality of all sub-tables. */
/***********************************************************************/
int TDBTBL::Cardinality(PGLOBAL g)
{
if (Cardinal < 0) {
int tsz;
if (!Tablist && InitTableList(g))
return 0; // Cannot be calculated at this stage
Cardinal = 0;
for (PTABLE tabp = Tablist; tabp; tabp = tabp->GetNext()) {
if ((tsz = tabp->GetTo_Tdb()->Cardinality(g)) < 0) {
Cardinal = -1;
return tsz;
} // endif mxsz
Cardinal += tsz;
} // endfor i
} // endif Cardinal
return Cardinal;
} // end of Cardinality
/***********************************************************************/
/* Sum up the maximum sizes of all sub-tables. */
/***********************************************************************/
int TDBTBL::GetMaxSize(PGLOBAL g)
{
......
......@@ -78,6 +78,7 @@ class DllExport TDBTBL : public TDBPRX {
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual int RowNumber(PGLOBAL g, bool b = FALSE);
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp);
......
......@@ -497,6 +497,21 @@ PCOL TDBPRX::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
return new(g) PRXCOL(cdp, this, cprec, n);
} // end of MakeCol
/***********************************************************************/
/* PRX Cardinality: returns the number of rows in the table. */
/***********************************************************************/
int TDBPRX::Cardinality(PGLOBAL g)
{
if (Cardinal < 0) {
if (InitTable(g))
return 0;
Cardinal = Tdbp->Cardinality(g);
} // endif MaxSize
return Cardinal;
} // end of GetMaxSize
/***********************************************************************/
/* PRX GetMaxSize: returns the maximum number of rows in the table. */
/***********************************************************************/
......
......@@ -76,6 +76,7 @@ class DllExport TDBPRX : public TDBASE {
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual bool InitTable(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
......
......@@ -95,7 +95,10 @@ bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
DOSDEF::DefineAM(g, "BIN", poff);
Estimate = GetIntCatInfo("Estimate", 0);
if ((Estimate = GetIntCatInfo("Estimate", 0)))
Elemt = MY_MIN(Elemt, Estimate);
// Split treated as INT to get default value
Split = GetIntCatInfo("Split", (Estimate) ? 0 : 1);
Header = GetIntCatInfo("Header", 0);
......@@ -103,7 +106,7 @@ bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
if (Estimate && !Split && !Header) {
char *fn = GetStringCatInfo(g, "Filename", "?");
// No separate header file fo urbi tables
// No separate header file for urbi tables
Header = (*fn == '?') ? 3 : 2;
} // endif Estimate
......@@ -309,8 +312,12 @@ bool TDBVCT::OpenDB(PGLOBAL g)
/*********************************************************************/
/* Delete all is not handled using file mapping. */
/*********************************************************************/
if (Mode == MODE_DELETE && !Next && Txfp->GetAmType() == TYPE_AM_MAP) {
if (Mode == MODE_DELETE && !Next && Txfp->GetAmType() == TYPE_AM_VMP) {
if (IsSplit())
Txfp = new(g) VECFAM((PVCTDEF)To_Def);
else
Txfp = new(g) VCTFAM((PVCTDEF)To_Def);
Txfp->SetTdbp(this);
} // endif Mode
......
......@@ -26,7 +26,7 @@ class DllExport VCTDEF : public DOSDEF { /* Logical table description */
friend class VMPFAM;
public:
// Constructor
VCTDEF(void) {Split = Estimate = Header = 0;}
VCTDEF(void) {Split = false; Estimate = Header = 0;}
// Implementation
virtual const char *GetType(void) {return "VCT";}
......@@ -40,7 +40,7 @@ class DllExport VCTDEF : public DOSDEF { /* Logical table description */
int MakeFnPattern(char *fpat);
// Members
int Split; /* Columns in separate files */
bool Split; /* Columns in separate files */
int Estimate; /* Estimated maximum size of table */
int Header; /* 0: no, 1: separate, 2: in data file */
}; // end of VCTDEF
......
......@@ -75,6 +75,7 @@ class TDBWMI : public TDBASE {
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int Cardinality(PGLOBAL g) {return GetMaxSize(g);}
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
......
......@@ -100,6 +100,9 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
else
blkp = new(g) TYPBLK<char>(mp, nval, type);
break;
case TYPE_PCHAR:
blkp = new(g) PTRBLK(g, mp, nval);
break;
default:
sprintf(g->Message, MSG(BAD_VALBLK_TYPE), type);
......@@ -1353,6 +1356,18 @@ void DATBLK::SetValue(PSZ p, int n)
} // end of SetValue
/* -------------------------- Class PTRBLK --------------------------- */
/***********************************************************************/
/* Compare two values of the block. */
/***********************************************************************/
int PTRBLK::CompVal(int i1, int i2)
{
return (Strp[i1] > Strp[i2]) ? 1 : (Strp[i1] < Strp[i2]) ? (-1) : 0;
} // end of CompVal
/* -------------------------- Class MBVALS --------------------------- */
/***********************************************************************/
......
......@@ -329,5 +329,28 @@ class DATBLK : public TYPBLK<int> {
PVAL Dvalp; // Date value used to convert string
}; // end of class DATBLK
/***********************************************************************/
/* Class PTRBLK: represent a block of char pointers. */
/* Currently this class is used only by the ARRAY class to make and */
/* sort a list of char pointers. */
/***********************************************************************/
class PTRBLK : public STRBLK {
friend class ARRAY;
friend PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int,
bool, bool, bool);
protected:
// Constructors
PTRBLK(PGLOBAL g, void *mp, int size) : STRBLK(g, mp, size) {}
// Implementation
// Methods
virtual void SetValue(PSZ p, int n) {Strp[n] = p;}
virtual int CompVal(int i1, int i2);
protected:
// Members
}; // end of class PTRBLK
#endif // __VALBLK__H__
......@@ -184,6 +184,7 @@ PSZ GetTypeName(int type)
case TYPE_TINY: name = "TINY"; break;
case TYPE_DECIM: name = "DECIMAL"; break;
case TYPE_BIN: name = "BINARY"; break;
case TYPE_PCHAR: name = "PCHAR"; break;
default: name = "UNKNOWN"; break;
} // endswitch type
......@@ -205,6 +206,7 @@ int GetTypeSize(int type, int len)
case TYPE_DATE: len = sizeof(int); break;
case TYPE_DOUBLE: len = sizeof(double); break;
case TYPE_TINY: len = sizeof(char); break;
case TYPE_PCHAR: len = sizeof(char*); break;
default: len = 0;
} // endswitch type
......@@ -228,6 +230,7 @@ char *GetFormatType(int type)
case TYPE_TINY: c = "T"; break;
case TYPE_DECIM: c = "M"; break;
case TYPE_BIN: c = "B"; break;
case TYPE_PCHAR: c = "P"; break;
} // endswitch type
return c;
......@@ -250,6 +253,7 @@ int GetFormatType(char c)
case 'T': type = TYPE_TINY; break;
case 'M': type = TYPE_DECIM; break;
case 'B': type = TYPE_BIN; break;
case 'P': type = TYPE_PCHAR; break;
} // endswitch type
return type;
......
......@@ -439,7 +439,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
/* Standard init: read the file and construct the index table. */
/* Note: reading will be sequential as To_Kindex is not set. */
/*********************************************************************/
for (i = nkey = 0; i < n && rc != RC_EF; i++) {
for (i = nkey = 0; rc != RC_EF; i++) {
#if 0
if (!dup->Step) {
strcpy(g->Message, MSG(QUERY_CANCELLED));
......@@ -555,6 +555,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
if (!Mul)
if (Ndif < Num_K) {
strcpy(g->Message, MSG(INDEX_NOT_UNIQ));
brc = true;
goto err;
} else
PlgDBfree(Offset); // Not used anymore
......@@ -649,9 +650,11 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
/*********************************************************************/
/* For sorted columns and fixed record size, file position can be */
/* calculated, so the Record array can be discarted. */
/* Not true for DBF tables because of eventual soft deleted lines. */
/* Note: for Num_K = 1 any non null value is Ok. */
/*********************************************************************/
if (Srtd && !filp && Tdbp->Ftype != RECFM_VAR) {
if (Srtd && !filp && Tdbp->Ftype != RECFM_VAR
&& Tdbp->Txfp->GetAmType() != TYPE_AM_DBF) {
Incr = (Num_K > 1) ? To_Rec[1] : Num_K;
PlgDBfree(Record);
} // endif Srtd
......
......@@ -89,6 +89,7 @@ class DllExport INDEXDEF : public BLOCK { /* Index description block */
bool IsUnique(void) {return Unique;}
bool IsDynamic(void) {return Dynamic;}
bool IsAuto(void) {return AutoInc;}
bool IsValid(void) {return !Invalid;}
void SetAuto(bool b) {AutoInc = b;}
void SetInvalid(bool b) {Invalid = b;}
int GetNparts(void) {return Nparts;}
......
......@@ -84,7 +84,7 @@ class DllExport TDB: public BLOCK { // Table Descriptor Block.
// Methods
virtual bool IsSame(PTDB tp) {return tp == this;}
virtual bool GetBlockValues(PGLOBAL g) {return false;}
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int Cardinality(PGLOBAL g) {return 0;}
virtual int GetMaxSize(PGLOBAL) = 0;
virtual int GetProgMax(PGLOBAL) = 0;
virtual int GetProgCur(void) = 0;
......@@ -160,7 +160,7 @@ class DllExport TDBASE : public TDB {
virtual PSZ GetPath(void);
virtual void PrintAM(FILE *f, char *m);
virtual RECFM GetFtype(void) {return RECFM_NAF;}
virtual int GetAffectedRows(void) {return -1;}
//virtual int GetAffectedRows(void) {return -1;}
virtual int GetRecpos(void) = 0;
virtual bool SetRecpos(PGLOBAL g, int recpos);
virtual bool IsReadOnly(void) {return Read_Only;}
......@@ -197,6 +197,7 @@ class DllExport TDBASE : public TDB {
PKXBASE To_Kindex; // Points to table key index
PIXDEF To_Xdp; // To the index definition block
PCOL To_SetCols; // Points to updated columns
RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT)
int MaxSize; // Max size in number of lines
int Knum; // Size of key arrays
bool Read_Only; // True for read only tables
......
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