Commit 089938cd authored by Alexander Barkov's avatar Alexander Barkov

Merge 10.0->10.0-connect

parents 82ce2a25 4d0587c3
......@@ -7,123 +7,120 @@
#ifdef __cplusplus
extern "C" {
#define MYSQL_DTRACE_DISABLED false
#else
#define MYSQL_DTRACE_DISABLED 0
#endif
#define MYSQL_CONNECTION_START(arg0, arg1, arg2)
#define MYSQL_CONNECTION_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_CONNECTION_START_ENABLED() (0)
#define MYSQL_CONNECTION_DONE(arg0, arg1)
#define MYSQL_CONNECTION_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_CONNECTION_DONE_ENABLED() (0)
#define MYSQL_COMMAND_START(arg0, arg1, arg2, arg3)
#define MYSQL_COMMAND_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_COMMAND_START_ENABLED() (0)
#define MYSQL_COMMAND_DONE(arg0)
#define MYSQL_COMMAND_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_COMMAND_DONE_ENABLED() (0)
#define MYSQL_QUERY_START(arg0, arg1, arg2, arg3, arg4)
#define MYSQL_QUERY_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_START_ENABLED() (0)
#define MYSQL_QUERY_DONE(arg0)
#define MYSQL_QUERY_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_DONE_ENABLED() (0)
#define MYSQL_QUERY_PARSE_START(arg0)
#define MYSQL_QUERY_PARSE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_PARSE_START_ENABLED() (0)
#define MYSQL_QUERY_PARSE_DONE(arg0)
#define MYSQL_QUERY_PARSE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_PARSE_DONE_ENABLED() (0)
#define MYSQL_QUERY_CACHE_HIT(arg0, arg1)
#define MYSQL_QUERY_CACHE_HIT_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_CACHE_HIT_ENABLED() (0)
#define MYSQL_QUERY_CACHE_MISS(arg0)
#define MYSQL_QUERY_CACHE_MISS_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_CACHE_MISS_ENABLED() (0)
#define MYSQL_QUERY_EXEC_START(arg0, arg1, arg2, arg3, arg4, arg5)
#define MYSQL_QUERY_EXEC_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_EXEC_START_ENABLED() (0)
#define MYSQL_QUERY_EXEC_DONE(arg0)
#define MYSQL_QUERY_EXEC_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_QUERY_EXEC_DONE_ENABLED() (0)
#define MYSQL_INSERT_ROW_START(arg0, arg1)
#define MYSQL_INSERT_ROW_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_ROW_START_ENABLED() (0)
#define MYSQL_INSERT_ROW_DONE(arg0)
#define MYSQL_INSERT_ROW_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_ROW_DONE_ENABLED() (0)
#define MYSQL_UPDATE_ROW_START(arg0, arg1)
#define MYSQL_UPDATE_ROW_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_UPDATE_ROW_START_ENABLED() (0)
#define MYSQL_UPDATE_ROW_DONE(arg0)
#define MYSQL_UPDATE_ROW_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_UPDATE_ROW_DONE_ENABLED() (0)
#define MYSQL_DELETE_ROW_START(arg0, arg1)
#define MYSQL_DELETE_ROW_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_DELETE_ROW_START_ENABLED() (0)
#define MYSQL_DELETE_ROW_DONE(arg0)
#define MYSQL_DELETE_ROW_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_DELETE_ROW_DONE_ENABLED() (0)
#define MYSQL_READ_ROW_START(arg0, arg1, arg2)
#define MYSQL_READ_ROW_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_READ_ROW_START_ENABLED() (0)
#define MYSQL_READ_ROW_DONE(arg0)
#define MYSQL_READ_ROW_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_READ_ROW_DONE_ENABLED() (0)
#define MYSQL_INDEX_READ_ROW_START(arg0, arg1)
#define MYSQL_INDEX_READ_ROW_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INDEX_READ_ROW_START_ENABLED() (0)
#define MYSQL_INDEX_READ_ROW_DONE(arg0)
#define MYSQL_INDEX_READ_ROW_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INDEX_READ_ROW_DONE_ENABLED() (0)
#define MYSQL_HANDLER_RDLOCK_START(arg0, arg1)
#define MYSQL_HANDLER_RDLOCK_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_RDLOCK_START_ENABLED() (0)
#define MYSQL_HANDLER_WRLOCK_START(arg0, arg1)
#define MYSQL_HANDLER_WRLOCK_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_WRLOCK_START_ENABLED() (0)
#define MYSQL_HANDLER_UNLOCK_START(arg0, arg1)
#define MYSQL_HANDLER_UNLOCK_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_UNLOCK_START_ENABLED() (0)
#define MYSQL_HANDLER_RDLOCK_DONE(arg0)
#define MYSQL_HANDLER_RDLOCK_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_RDLOCK_DONE_ENABLED() (0)
#define MYSQL_HANDLER_WRLOCK_DONE(arg0)
#define MYSQL_HANDLER_WRLOCK_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_WRLOCK_DONE_ENABLED() (0)
#define MYSQL_HANDLER_UNLOCK_DONE(arg0)
#define MYSQL_HANDLER_UNLOCK_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_HANDLER_UNLOCK_DONE_ENABLED() (0)
#define MYSQL_FILESORT_START(arg0, arg1)
#define MYSQL_FILESORT_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_FILESORT_START_ENABLED() (0)
#define MYSQL_FILESORT_DONE(arg0, arg1)
#define MYSQL_FILESORT_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_FILESORT_DONE_ENABLED() (0)
#define MYSQL_SELECT_START(arg0)
#define MYSQL_SELECT_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_SELECT_START_ENABLED() (0)
#define MYSQL_SELECT_DONE(arg0, arg1)
#define MYSQL_SELECT_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_SELECT_DONE_ENABLED() (0)
#define MYSQL_INSERT_START(arg0)
#define MYSQL_INSERT_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_START_ENABLED() (0)
#define MYSQL_INSERT_DONE(arg0, arg1)
#define MYSQL_INSERT_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_DONE_ENABLED() (0)
#define MYSQL_INSERT_SELECT_START(arg0)
#define MYSQL_INSERT_SELECT_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_SELECT_START_ENABLED() (0)
#define MYSQL_INSERT_SELECT_DONE(arg0, arg1)
#define MYSQL_INSERT_SELECT_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_INSERT_SELECT_DONE_ENABLED() (0)
#define MYSQL_UPDATE_START(arg0)
#define MYSQL_UPDATE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_UPDATE_START_ENABLED() (0)
#define MYSQL_UPDATE_DONE(arg0, arg1, arg2)
#define MYSQL_UPDATE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_UPDATE_DONE_ENABLED() (0)
#define MYSQL_MULTI_UPDATE_START(arg0)
#define MYSQL_MULTI_UPDATE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_MULTI_UPDATE_START_ENABLED() (0)
#define MYSQL_MULTI_UPDATE_DONE(arg0, arg1, arg2)
#define MYSQL_MULTI_UPDATE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_MULTI_UPDATE_DONE_ENABLED() (0)
#define MYSQL_DELETE_START(arg0)
#define MYSQL_DELETE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_DELETE_START_ENABLED() (0)
#define MYSQL_DELETE_DONE(arg0, arg1)
#define MYSQL_DELETE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_DELETE_DONE_ENABLED() (0)
#define MYSQL_MULTI_DELETE_START(arg0)
#define MYSQL_MULTI_DELETE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_MULTI_DELETE_START_ENABLED() (0)
#define MYSQL_MULTI_DELETE_DONE(arg0, arg1)
#define MYSQL_MULTI_DELETE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_MULTI_DELETE_DONE_ENABLED() (0)
#define MYSQL_NET_READ_START()
#define MYSQL_NET_READ_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_NET_READ_START_ENABLED() (0)
#define MYSQL_NET_READ_DONE(arg0, arg1)
#define MYSQL_NET_READ_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_NET_READ_DONE_ENABLED() (0)
#define MYSQL_NET_WRITE_START(arg0)
#define MYSQL_NET_WRITE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_NET_WRITE_START_ENABLED() (0)
#define MYSQL_NET_WRITE_DONE(arg0)
#define MYSQL_NET_WRITE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_NET_WRITE_DONE_ENABLED() (0)
#define MYSQL_KEYCACHE_READ_START(arg0, arg1, arg2, arg3)
#define MYSQL_KEYCACHE_READ_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_READ_START_ENABLED() (0)
#define MYSQL_KEYCACHE_READ_BLOCK(arg0)
#define MYSQL_KEYCACHE_READ_BLOCK_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_READ_BLOCK_ENABLED() (0)
#define MYSQL_KEYCACHE_READ_HIT()
#define MYSQL_KEYCACHE_READ_HIT_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_READ_HIT_ENABLED() (0)
#define MYSQL_KEYCACHE_READ_MISS()
#define MYSQL_KEYCACHE_READ_MISS_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_READ_MISS_ENABLED() (0)
#define MYSQL_KEYCACHE_READ_DONE(arg0, arg1)
#define MYSQL_KEYCACHE_READ_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_READ_DONE_ENABLED() (0)
#define MYSQL_KEYCACHE_WRITE_START(arg0, arg1, arg2, arg3)
#define MYSQL_KEYCACHE_WRITE_START_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_WRITE_START_ENABLED() (0)
#define MYSQL_KEYCACHE_WRITE_BLOCK(arg0)
#define MYSQL_KEYCACHE_WRITE_BLOCK_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_WRITE_BLOCK_ENABLED() (0)
#define MYSQL_KEYCACHE_WRITE_DONE(arg0, arg1)
#define MYSQL_KEYCACHE_WRITE_DONE_ENABLED() MYSQL_DTRACE_DISABLED
#define MYSQL_KEYCACHE_WRITE_DONE_ENABLED() (0)
#ifdef __cplusplus
}
......
......@@ -3195,13 +3195,26 @@ uint32 get_partition_id_cols_list_for_endpoint(partition_info *part_info,
(list_index - 1)*num_columns,
nparts, left_endpoint,
include_endpoint)));
#if 0
if (!left_endpoint)
{
/* Set the end after this list tuple if not already after the last. */
if (list_index < part_info->num_parts)
list_index++;
}
#else
if (!left_endpoint && list_index < part_info->num_list_values)
{
/*
Set the end after this list tuple if it is not already after the last
and it matches.
*/
int cmp = cmp_rec_and_tuple_prune(list_col_array + list_index*num_columns,
nparts, left_endpoint, include_endpoint);
if (cmp >= 0)
list_index++;
}
#endif
DBUG_RETURN(list_index);
}
......
......@@ -19,20 +19,20 @@ SET(CONNECT_PLUGIN_DYNAMIC "connect")
SET(CONNECT_SOURCES
ha_connect.cc connect.cc user_connect.cc mycat.cc
fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h
csort.cpp maputil.cpp plgdbutl.cpp
colblk.cpp reldef.cpp tabcol.cpp table.cpp
filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamvct.cpp
tabdos.cpp tabfix.cpp tabfmt.cpp tabmul.cpp tabsys.cpp tabvct.cpp
array.cpp blkfil.cpp colblk.cpp csort.cpp
filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamvct.cpp filamzip.cpp
filter.cpp maputil.cpp myutil.cpp plgdbutl.cpp reldef.cpp tabcol.cpp
tabdos.cpp tabfix.cpp tabfmt.cpp table.cpp tabmul.cpp taboccur.cpp
tabpivot.cpp tabsys.cpp tabtbl.cpp tabutil.cpp tabvct.cpp tabxcl.cpp
valblk.cpp value.cpp xindex.cpp xobject.cpp
filamzip.cpp tabtbl.cpp myutil.cpp
tabutil.cpp tabxcl.cpp taboccur.cpp tabpivot.cpp
block.h catalog.h checklvl.h colblk.h connect.h csort.h engmsg.h
filamap.h filamdbf.h filamfix.h filamtxt.h filamvct.h filamzip.h
global.h ha_connect.h inihandl.h maputil.h msgid.h mycat.h myutil.h os.h
osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h resource.h tabcol.h
tabdos.h tabfix.h tabfmt.h tabmul.h tabsys.h tabtbl.h tabvct.h
user_connect.h valblk.h value.h xindex.h xobject.h xtable.h
tabutil.h tabxcl.h taboccur.h tabpivot.h)
array.h blkfil.h block.h catalog.h checklvl.h colblk.h connect.h csort.h
engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamvct.h filamzip.h
filter.h global.h ha_connect.h inihandl.h maputil.h msgid.h mycat.h myutil.h
os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h resource.h tabcol.h
tabdos.h tabfix.h tabfmt.h tabmul.h taboccur.h tabpivot.h tabsys.h
tabtbl.h tabutil.h tabvct.h tabxcl.h user_connect.h valblk.h value.h
xindex.h xobject.h xtable.h)
#
# Definitions that are shared for all OSes
......
This diff is collapsed.
/**************** Array H Declares Source Code File (.H) ***************/
/* Name: ARRAY.H Version 3.1 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */
/* This file contains the ARRAY and VALBASE derived classes declares. */
/***********************************************************************/
/***********************************************************************/
/* Include required application header files */
/***********************************************************************/
#include "xobject.h"
#include "valblk.h"
#include "csort.h"
typedef class ARRAY *PARRAY;
/***********************************************************************/
/* Definition of class ARRAY with all its method functions. */
/* Note: This is not a general array class that could be defined as */
/* a template class, but rather a specific object containing a list */
/* of values to be processed by the filter IN operator. */
/* In addition it must act as a metaclass by being able to give back */
/* the type of values it contains. */
/* It must also be able to convert itself from some type to another. */
/***********************************************************************/
class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
friend class MULAR;
//friend class VALLST;
//friend class SFROW;
public:
// Constructors
ARRAY(PGLOBAL g, int type, int size, int len = 1, int prec = 0);
//ARRAY(PGLOBAL g, PQUERY qryp);
//ARRAY(PGLOBAL g, PARRAY par, int k);
// Implementation
virtual int GetType(void) {return TYPE_ARRAY;}
virtual int GetResultType(void) {return Type;}
virtual int GetLength(void) {return Len;}
virtual int GetLengthEx(void) {return Len;}
virtual int GetScale() {return 0;}
int GetNval(void) {return Nval;}
int GetSize(void) {return Size;}
// PVAL GetValp(void) {return Valp;}
void SetType(int atype) {Type = atype;}
// void SetCorrel(bool b) {Correlated = b;}
// Methods
virtual void Reset(void) {Bot = -1;}
virtual int Qcompare(int *, int *);
virtual bool Compare(PXOB) {assert(FALSE); return FALSE;}
virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(FALSE); return FALSE;}
//virtual int CheckSpcCol(PTDB, int) {return 0;}
virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z);
// void Empty(void);
void SetPrecision(PGLOBAL g, int p);
bool AddValue(PGLOBAL g, PSZ sp);
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);
char *GetStringValue(int n);
BYTE Vcompare(PVAL vp, int n);
void Save(int);
void Restore(int);
void Move(int, int);
bool Sort(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);
int BlockTest(PGLOBAL g, int opc, int opm,
void *minp, void *maxp, bool s);
PSZ MakeArrayList(PGLOBAL g);
bool CanBeShort(void);
bool GetSubValue(PGLOBAL g, PVAL valp, int *kp);
protected:
// Members
PMBV Valblk; // To the MBVALS class
PVBLK Vblp; // To Valblock of the data array
//PVAL Valp; // The value used for Save and Restore is Value
int Size; // Size of value array
int Nval; // Total number of items in array
int Ndif; // Total number of distinct items in array
int Xsize; // Size of Index (used for correlated arrays)
int Type; // Type of individual values in the array
int Len; // Length of character string
int Bot; // Bottom of research index
int Top; // Top of research index
int X, Inf, Sup; // Used for block optimization
//bool Correlated; // -----------> Temporary
}; // end of class ARRAY
/***********************************************************************/
/* Definition of class MULAR with all its method functions. */
/* This class is used when constructing the arrays of constants used */
/* for indexing. Its only purpose is to provide a way to sort, reduce */
/* and reorder the arrays of multicolumn indexes as one block. Indeed */
/* sorting the arrays independantly would break the correspondance of */
/* column values. */
/***********************************************************************/
class MULAR : public CSORT, public BLOCK { // No need to be an XOBJECT
public:
// Constructor
MULAR(PGLOBAL g, int n);
// Implementation
void SetPars(PARRAY par, int i) {Pars[i] = par;}
// Methods
virtual int Qcompare(int *i1, int *i2); // Sort compare routine
bool Sort(PGLOBAL g);
protected:
// Members
int Narray; // The number of sub-arrays
PARRAY *Pars; // To the block of real arrays
}; // end of class ARRAY
This diff is collapsed.
This diff is collapsed.
......@@ -43,6 +43,8 @@ typedef struct _colinfo {
int Key;
int Precision;
int Scale;
int Opt;
int Freq;
char *Remark;
char *Datefmt;
char *Fieldfmt;
......
/************* Colblk C++ Functions Source Code File (.CPP) ************/
/* Name: COLBLK.CPP Version 2.0 */
/* Name: COLBLK.CPP Version 2.1 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2013 */
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
/* */
/* This file contains the COLBLK class functions. */
/***********************************************************************/
......@@ -38,8 +38,10 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
if ((Cdp = cdp)) {
Name = cdp->Name;
Format = cdp->F;
Opt = cdp->Opt;
Long = cdp->Long;
Precision = cdp->Precision;
Freq = cdp->Freq;
Buf_Type = cdp->Buf_Type;
ColUse |= cdp->Flags; // Used by CONNECT
Nullable = !!(cdp->Flags & U_NULLS);
......@@ -47,8 +49,10 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
} else {
Name = NULL;
memset(&Format, 0, sizeof(FORMAT));
Opt = 0;
Long = 0;
Precision = 0;
Freq = 0;
Buf_Type = TYPE_ERROR;
Nullable = false;
Unsigned = false;
......@@ -288,7 +292,7 @@ void RIDBLK::ReadColumn(PGLOBAL g)
/***********************************************************************/
/* FIDBLK constructor for the FILEID special column. */
/***********************************************************************/
FIDBLK::FIDBLK(PCOLUMN cp) : SPCBLK(cp)
FIDBLK::FIDBLK(PCOLUMN cp, OPVAL op) : SPCBLK(cp), Op(op)
{
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
Precision = Long = _MAX_PATH;
......@@ -315,7 +319,14 @@ void FIDBLK::ReadColumn(PGLOBAL g)
Fn = ((PTDBASE)To_Tdb)->GetFile(g);
PlugSetPath(filename, Fn, ((PTDBASE)To_Tdb)->GetPath());
if (Op != OP_XX) {
char buff[_MAX_PATH];
Value->SetValue_psz(ExtractFromPath(g, buff, filename, Op));
} else
Value->SetValue_psz(filename);
} // endif Fn
} // end of ReadColumn
......@@ -347,6 +358,38 @@ void TIDBLK::ReadColumn(PGLOBAL g)
} // end of ReadColumn
/***********************************************************************/
/* PRTBLK constructor for the PARTID special column. */
/***********************************************************************/
PRTBLK::PRTBLK(PCOLUMN cp) : SPCBLK(cp)
{
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
Precision = Long = 64;
Buf_Type = TYPE_STRING;
*Format.Type = 'C';
Format.Length = Long;
Format.Prec = 1; // Case insensitive
Constant = true; // TODO: check whether this is true indeed
Pname = NULL;
} // end of PRTBLK constructor
/***********************************************************************/
/* ReadColumn: what this routine does is to return the partition ID. */
/***********************************************************************/
void PRTBLK::ReadColumn(PGLOBAL g)
{
if (Pname == NULL) {
char *p;
PTDBASE tdbp = (PTDBASE)To_Tdb;
Pname = tdbp->GetDef()->GetStringCatInfo(g, "partname", "?");
p = strrchr(Pname, '#');
Value->SetValue_psz((p) ? p + 1 : Pname);
} // endif Pname
} // end of ReadColumn
/***********************************************************************/
/* SIDBLK constructor for the SERVID special column. */
/***********************************************************************/
......
......@@ -36,10 +36,13 @@ class DllExport COLBLK : public XOBJECT {
virtual int GetAmType() {return TYPE_AM_ERROR;}
virtual void SetOk(void) {Status |= BUF_EMPTY;}
virtual PTDB GetTo_Tdb(void) {return To_Tdb;}
virtual int GetClustered(void) {return 0;}
virtual int IsClustered(void) {return FALSE;}
PCOL GetNext(void) {return Next;}
PSZ GetName(void) {return Name;}
int GetIndex(void) {return Index;}
ushort GetColUse(void) {return ColUse;}
int GetOpt(void) {return Opt;}
ushort GetColUse(ushort u) {return (ColUse & u);}
ushort GetStatus(void) {return Status;}
ushort GetStatus(ushort u) {return (Status & u);}
......@@ -48,14 +51,15 @@ class DllExport COLBLK : public XOBJECT {
void AddColUse(ushort u) {ColUse |= u;}
void AddStatus(ushort u) {Status |= u;}
void SetNext(PCOL cp) {Next = cp;}
PXCOL GetKcol(void) {return To_Kcol;}
void SetKcol(PXCOL kcp) {To_Kcol = kcp;}
PCOLDEF GetCdp(void) {return Cdp;}
PSZ GetDomain(void) {return (Cdp) ? Cdp->Decode : NULL;}
PSZ GetDesc(void) {return (Cdp) ? Cdp->Desc : NULL;}
PSZ GetFmt(void) {return (Cdp) ? Cdp->Fmt : NULL;}
bool IsUnsigned(void) {return Unsigned;}
bool IsNullable(void) {return Nullable;}
bool IsVirtual(void) {return Cdp->IsVirtual();}
bool IsNullable(void) {return Nullable;}
void SetNullable(bool b) {Nullable = b;}
// Methods
......@@ -70,6 +74,7 @@ class DllExport COLBLK : public XOBJECT {
virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
virtual bool VarSize(void) {return false;}
bool InitValue(PGLOBAL g);
protected:
......@@ -82,9 +87,11 @@ class DllExport COLBLK : public XOBJECT {
bool Nullable; // True if nullable
bool Unsigned; // True if unsigned
int Index; // Column number in table
int Opt; // Cluster/sort information
int Buf_Type; // Data type
int Long; // Internal length in table
int Precision; // Column length (as for ODBC)
int Freq; // Evaluated ceiling of distinct values
FORMAT Format; // Output format
ushort ColUse; // Column usage
ushort Status; // Column read status
......@@ -137,7 +144,7 @@ class DllExport RIDBLK : public SPCBLK {
class DllExport FIDBLK : public SPCBLK {
public:
// Constructor
FIDBLK(PCOLUMN cp);
FIDBLK(PCOLUMN cp, OPVAL op);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_FILID;}
......@@ -148,6 +155,7 @@ class DllExport FIDBLK : public SPCBLK {
protected:
PSZ Fn; // The current To_File of the table
OPVAL Op; // The file part operator
}; // end of class FIDBLK
/***********************************************************************/
......@@ -173,6 +181,29 @@ class DllExport TIDBLK : public SPCBLK {
PSZ Tname; // The current table name
}; // end of class TIDBLK
/***********************************************************************/
/* Class PRTBLK: PARTID special column descriptor. */
/***********************************************************************/
class DllExport PRTBLK : public SPCBLK {
public:
// Constructor
PRTBLK(PCOLUMN cp);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_PRTID;}
// Methods
virtual void Reset(void) {} // This is a pseudo constant column
virtual void ReadColumn(PGLOBAL g);
protected:
// Default constructor not to be used
PRTBLK(void) {}
// Members
PSZ Pname; // The current partition name
}; // end of class PRTBLK
/***********************************************************************/
/* Class SIDBLK: SERVID special column descriptor. */
/***********************************************************************/
......
......@@ -57,7 +57,7 @@ extern "C" int trace;
/* Routines called internally by semantic routines. */
/***********************************************************************/
void CntEndDB(PGLOBAL);
RCODE EvalColumns(PGLOBAL g, PTDB tdbp);
RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool mrr= false);
/***********************************************************************/
/* MySQL routines called externally by semantic routines. */
......@@ -142,7 +142,7 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
return true;
((MYCAT *)dbuserp->Catalog)->SetDataPath(g, pathname);
dbuserp->UseTemp= TMP_YES; // Must use temporary file
dbuserp->UseTemp= TMP_AUTO;
/*********************************************************************/
/* All is correct. */
......@@ -167,7 +167,12 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
if (tdbp) {
b= tdbp->GetFtype() != RECFM_NAF;
info->data_file_length= (b) ? (ulonglong)tdbp->GetFileLength(g) : 0;
if (!b || info->data_file_length)
info->records= (unsigned)tdbp->GetMaxSize(g);
else
info->records= 0;
// info->mean_rec_length= tdbp->GetLrecl();
info->mean_rec_length= 0;
info->data_file_name= (b) ? tdbp->GetFile(g) : NULL;
......@@ -343,12 +348,12 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
//tdbp->SetMode(mode);
if (del && ((PTDBASE)tdbp)->GetFtype() != RECFM_NAF) {
if (del/* && ((PTDBASE)tdbp)->GetFtype() != RECFM_NAF*/) {
// To avoid erasing the table when doing a partial delete
// make a fake Next
PDOSDEF ddp= new(g) DOSDEF;
PTDB tp= new(g) TDBDOS(ddp, NULL);
tdbp->SetNext(tp);
// PDOSDEF ddp= new(g) DOSDEF;
// PTDB tp= new(g) TDBDOS(ddp, NULL);
tdbp->SetNext((PTDB)1);
dup->Check &= ~CHK_DELETE;
} // endif del
......@@ -387,7 +392,7 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp)
/***********************************************************************/
/* Evaluate all columns after a record is read. */
/***********************************************************************/
RCODE EvalColumns(PGLOBAL g, PTDB tdbp)
RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool mrr)
{
RCODE rc= RC_OK;
PCOL colp;
......@@ -415,7 +420,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp)
colp->Reset();
// Virtual columns are computed by MariaDB
if (!colp->GetColUse(U_VIRTUAL))
if (!colp->GetColUse(U_VIRTUAL) && (!mrr || colp->GetKcol()))
if (colp->Eval(g))
rc= RC_FX;
......@@ -439,8 +444,8 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
// Reading sequencially an indexed table. This happens after the
// handler function records_in_range was called and MySQL decides
// to quit using the index (!!!) Drop the index.
for (PCOL colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
colp->SetKcol(NULL);
// for (PCOL colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
// colp->SetKcol(NULL);
((PTDBASE)tdbp)->ResetKindex(g, NULL);
} // endif index
......@@ -456,7 +461,12 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
goto err;
} // endif rc
while ((rc= (RCODE)tdbp->ReadDB(g)) == RC_NF) ;
do {
if ((rc= (RCODE)tdbp->ReadDB(g)) == RC_OK)
if (!ApplyFilter(g, tdbp->GetFilter()))
rc= RC_NF;
} while (rc == RC_NF);
err:
g->jump_level--;
......@@ -539,16 +549,23 @@ RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all)
/***********************************************************************/
/* CLOSETAB: Close a table. */
/***********************************************************************/
int CntCloseTable(PGLOBAL g, PTDB tdbp)
int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
{
int rc= RC_OK;
TDBDOX *tbxp= NULL;
if (!tdbp || tdbp->GetUse() != USE_OPEN)
if (!tdbp)
return rc; // Nothing to do
else if (tdbp->GetUse() != USE_OPEN) {
if (tdbp->GetAmType() == TYPE_AM_XML)
tdbp->CloseDB(g); // Opened by GetMaxSize
return rc;
} // endif !USE_OPEN
if (trace)
printf("CntCloseTable: tdbp=%p mode=%d\n", tdbp, tdbp->GetMode());
printf("CntCloseTable: tdbp=%p mode=%d nox=%d abort=%d\n",
tdbp, tdbp->GetMode(), nox, abort);
if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN)
rc= tdbp->DeleteDB(g, RC_EF); // Specific A.M. delete routine
......@@ -567,8 +584,9 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
// This will close the table file(s) and also finalize write
// operations such as Insert, Update, or Delete.
tdbp->SetAbort(abort);
tdbp->CloseDB(g);
tdbp->SetAbort(false);
g->jump_level--;
if (trace > 1)
......@@ -577,17 +595,18 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
//if (!((PTDBDOX)tdbp)->GetModified())
// return 0;
if (tdbp->GetMode() == MODE_READ || tdbp->GetMode() == MODE_ANY)
if (nox || tdbp->GetMode() == MODE_READ || tdbp->GetMode() == MODE_ANY)
return 0;
if (trace > 1)
printf("About to reset indexes\n");
printf("About to reset opt\n");
// Make all the eventual indexes
tbxp= (TDBDOX*)tdbp;
tbxp->ResetKindex(g, NULL);
tbxp->To_Key_Col= NULL;
rc= tbxp->ResetTableOpt(g, ((PTDBASE)tdbp)->GetDef()->Indexable() == 1);
rc= tbxp->ResetTableOpt(g, true,
((PTDBASE)tdbp)->GetDef()->Indexable() == 1);
err:
if (trace > 1)
......@@ -603,15 +622,8 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
/***********************************************************************/
int CntIndexInit(PGLOBAL g, PTDB ptdb, int id)
{
int k;
PCOL colp;
PVAL valp;
PKXBASE xp;
PXLOAD pxp;
PIXDEF xdp;
XKPDEF *kdp;
PTDBDOX tdbp;
PCOLDEF cdp;
DOXDEF *dfp;
if (!ptdb)
......@@ -650,63 +662,27 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id)
return 0;
} // endif xdp
// Allocate the key columns definition block
tdbp->Knum= xdp->GetNparts();
tdbp->To_Key_Col= (PCOL*)PlugSubAlloc(g, NULL, tdbp->Knum * sizeof(PCOL));
// Get the key column description list
for (k= 0, kdp= (XKPDEF*)xdp->GetToKeyParts(); kdp; kdp= (XKPDEF*)kdp->Next)
if (!(colp= tdbp->ColDB(g, kdp->Name, 0)) || colp->InitValue(g)) {
sprintf(g->Message, "Wrong column %s", kdp->Name);
#if 0
if (xdp->IsDynamic()) {
// This is a dynamically created index (KINDEX)
// It should not be created now, if called by index range
tdbp->SetXdp(xdp);
return (xdp->IsUnique()) ? 1 : 2;
} // endif dynamic
#endif // 0
// Static indexes must be initialized now for records_in_range
if (tdbp->InitialyzeIndex(g, xdp))
return 0;
} else
tdbp->To_Key_Col[k++]= colp;
#if defined(_DEBUG)
if (k != tdbp->Knum) {
sprintf(g->Message, "Key part number mismatch for %s",
xdp->GetName());
return 0;
} // endif k
#endif // _DEBUG
// Allocate the pseudo constants that will contain the key values
tdbp->To_Link= (PXOB*)PlugSubAlloc(g, NULL, tdbp->Knum * sizeof(PXOB));
for (k= 0, kdp= (XKPDEF*)xdp->GetToKeyParts();
kdp; k++, kdp= (XKPDEF*)kdp->Next) {
cdp= tdbp->Key(k)->GetCdp();
valp= AllocateValue(g, cdp->GetType(), cdp->GetLength());
tdbp->To_Link[k]= new(g) CONSTANT(valp);
} // endfor k
// Make the index on xdp
if (!xdp->IsAuto()) {
if (dfp->Huge)
pxp= new(g) XHUGE;
else
pxp= new(g) XFILE;
if (tdbp->Knum == 1) // Single index
xp= new(g) XINDXS(tdbp, xdp, pxp, tdbp->To_Key_Col, tdbp->To_Link);
else // Multi-Column index
xp= new(g) XINDEX(tdbp, xdp, pxp, tdbp->To_Key_Col, tdbp->To_Link);
} else // Column contains same values as ROWID
xp= new(g) XXROW(tdbp);
if (xp->Init(g))
return 0;
tdbp->To_Kindex= xp;
return (xp->IsMul()) ? 2 : 1;
return (tdbp->To_Kindex->IsMul()) ? 2 : 1;
} // end of CntIndexInit
/***********************************************************************/
/* IndexRead: fetch a record having the index value. */
/***********************************************************************/
RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
const void *key, int len)
const void *key, int len, bool mrr)
{
char *kp= (char*)key;
int n, x;
......@@ -737,9 +713,20 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
// Set reference values and index operator
if (!tdbp->To_Link || !tdbp->To_Kindex) {
// if (!tdbp->To_Xdp) {
sprintf(g->Message, "Index not initialized for table %s", tdbp->Name);
return RC_FX;
} else
#if 0
} // endif !To_Xdp
// Now it's time to make the dynamic index
if (tdbp->InitialyzeIndex(g, NULL)) {
sprintf(g->Message, "Fail to make dynamic index %s",
tdbp->To_Xdp->GetName());
return RC_FX;
} // endif MakeDynamicIndex
#endif // 0
} // endif !To_Kindex
xbp= (XXBASE*)tdbp->To_Kindex;
if (key) {
......@@ -793,7 +780,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
rnd:
if ((rc= (RCODE)ptdb->ReadDB(g)) == RC_OK)
rc= EvalColumns(g, ptdb);
rc= EvalColumns(g, ptdb, mrr);
return rc;
} // end of CntIndexRead
......@@ -828,10 +815,14 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
} else
tdbp= (PTDBDOX)ptdb;
if (!tdbp->To_Link || !tdbp->To_Kindex) {
if (!tdbp->To_Kindex || !tdbp->To_Link) {
if (!tdbp->To_Xdp) {
sprintf(g->Message, "Index not initialized for table %s", tdbp->Name);
DBUG_PRINT("Range", ("%s", g->Message));
return -1;
} else // Dynamic index
return tdbp->To_Xdp->GetMaxSame(); // TODO a better estimate
} else
xbp= (XXBASE*)tdbp->To_Kindex;
......
......@@ -33,10 +33,10 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname);
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);
int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort);
int CntIndexInit(PGLOBAL g, PTDB tdbp, int id);
RCODE CntReadNext(PGLOBAL g, PTDB tdbp);
RCODE CntIndexRead(PGLOBAL g, PTDB, OPVAL op, const void *k, int n);
RCODE CntIndexRead(PGLOBAL g, PTDB, OPVAL op, const void *k, int n, bool mrr);
RCODE CntWriteRow(PGLOBAL g, PTDB tdbp);
RCODE CntUpdateRow(PGLOBAL g, PTDB tdbp);
RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all);
......@@ -58,9 +58,9 @@ class DOXDEF: public DOSDEF {
/***********************************************************************/
class TDBDOX: public TDBDOS {
friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntCloseTable(PGLOBAL, PTDB);
friend int CntCloseTable(PGLOBAL, PTDB, bool, bool);
friend int CntIndexInit(PGLOBAL, PTDB, int);
friend RCODE CntIndexRead(PGLOBAL, PTDB, OPVAL, const void*, int);
friend RCODE CntIndexRead(PGLOBAL, PTDB, OPVAL, const void*, int, bool);
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool);
friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*,
bool*, key_part_map*);
......
/*********** File AM Map C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: FILAMAP */
/* ------------- */
/* Version 1.4 */
/* Version 1.5 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -129,9 +129,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
&& fp->Count && fp->Mode == mode)
break;
if (trace)
#ifdef DEBTRACE
htrc("Mapping file, fp=%p\n", fp);
#endif
} else
fp = NULL;
......@@ -322,8 +322,26 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
/*******************************************************************/
/* Record file position in case of UPDATE or DELETE. */
/*******************************************************************/
int rc;
next:
Fpos = Mempos;
CurBlk = (int)Rows++;
/*******************************************************************/
/* Check whether optimization on ROWID */
/* can be done, as well as for join as for local filtering. */
/*******************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
// Skip this record
if ((rc = SkipRecord(g, FALSE)) != RC_OK)
return rc;
goto next;
} // endswitch rc
} else
Placed = false;
......@@ -382,7 +400,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
if (Tpos == Spos)
/*******************************************************************/
/* First line to delete. Move of eventual preceding lines is */
/* 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
......@@ -458,7 +476,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
/***********************************************************************/
/* Table file close routine for MAP access method. */
/***********************************************************************/
void MAPFAM::CloseTableFile(PGLOBAL g)
void MAPFAM::CloseTableFile(PGLOBAL g, bool abort)
{
PlugCloseFile(g, To_Fb);
To_Fb = NULL; // To get correct file size in Cardinality
......@@ -488,7 +506,7 @@ MBKFAM::MBKFAM(PDOSDEF tdp) : MAPFAM(tdp)
Block = tdp->GetBlock();
Last = tdp->GetLast();
Nrec = tdp->GetElemt();
BlkPos = NULL;
BlkPos = tdp->GetTo_Pos();
CurNum = Nrec;
} // end of MBKFAM standard constructor
......@@ -508,9 +526,7 @@ void MBKFAM::Reset(void)
/***********************************************************************/
int MBKFAM::Cardinality(PGLOBAL g)
{
// Should not be called in this version
return (g) ? -1 : 0;
//return (g) ? (int)((Block - 1) * Nrec + Last) : 1;
return (g) ? (int)((Block - 1) * Nrec + Last) : 1;
} // end of Cardinality
/***********************************************************************/
......@@ -534,8 +550,49 @@ int MBKFAM::GetRowID(void)
/***********************************************************************/
int MBKFAM::ReadBuffer(PGLOBAL g)
{
strcpy(g->Message, "This AM cannot be used in this version");
return RC_FX;
int len;
/*********************************************************************/
/* Sequential block reading when Placed is not true. */
/*********************************************************************/
if (Placed) {
Placed = false;
} else if (Mempos >= Top) { // Are we at the end of the memory
return RC_EF;
} else if (++CurNum < Nrec) {
Fpos = Mempos;
} else {
/*******************************************************************/
/* New block. */
/*******************************************************************/
CurNum = 0;
next:
if (++CurBlk >= Block)
return RC_EF;
/*******************************************************************/
/* Before reading a new block, check whether block optimization */
/* can be done, as well as for join as for local filtering. */
/*******************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
goto next;
} // endswitch rc
Fpos = Mempos = Memory + BlkPos[CurBlk];
} // endif's
// Immediately calculate next position (Used by DeleteDB)
while (*Mempos++ != '\n') ; // What about Unix ???
// Set caller line buffer
len = (Mempos - Fpos) - Ending;
memcpy(Tdbp->GetLine(), Fpos, len);
Tdbp->GetLine()[len] = '\0';
return RC_OK;
} // end of ReadBuffer
/***********************************************************************/
......@@ -626,9 +683,21 @@ int MPXFAM::ReadBuffer(PGLOBAL g)
/*******************************************************************/
CurNum = 0;
next:
if (++CurBlk >= Block)
return RC_EF;
/*******************************************************************/
/* Before reading a new block, check whether block optimization */
/* can be done, as well as for join as for local filtering. */
/*******************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
goto next;
} // endswitch rc
Fpos = Mempos = Headlen + Memory + CurBlk * Blksize;
} // endif's
......
......@@ -33,6 +33,7 @@ class DllExport MAPFAM : public TXTFAM {
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
......@@ -42,7 +43,7 @@ class DllExport MAPFAM : public TXTFAM {
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void);
protected:
......@@ -71,6 +72,8 @@ class DllExport MBKFAM : public MAPFAM {
// Methods
virtual void Reset(void);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);}
virtual int GetRowID(void);
virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g);
......@@ -96,6 +99,8 @@ class DllExport MPXFAM : public MBKFAM {
// Methods
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 DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g);
......
......@@ -791,7 +791,7 @@ void DBFFAM::Rewind(void)
/***********************************************************************/
/* Table file close routine for DBF access method. */
/***********************************************************************/
void DBFFAM::CloseTableFile(PGLOBAL g)
void DBFFAM::CloseTableFile(PGLOBAL g, bool abort)
{
int rc = RC_OK, wrc = RC_OK;
MODE mode = Tdbp->GetMode();
......@@ -810,17 +810,17 @@ void DBFFAM::CloseTableFile(PGLOBAL g)
} // endif Modif
if (UseTemp && T_Stream && wrc == RC_OK) {
if (!abort) {
// Copy any remaining lines
bool b;
Fpos = Tdbp->Cardinality(g);
abort = MoveIntermediateLines(g, &b) != RC_OK;
} // endif abort
if ((rc = MoveIntermediateLines(g, &b)) == RC_OK) {
// Delete the old file and rename the new temp file.
RenameTempFile(g);
RenameTempFile(g, abort);
goto fin;
} // endif rc
} // endif UseTemp
} // endif's mode
......
......@@ -67,7 +67,7 @@ class DllExport DBFFAM : public FIXFAM, public DBFBASE {
virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void);
protected:
......
......@@ -169,9 +169,20 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
CurNum = 0;
Tdbp->SetLine(To_Buf);
next:
if (++CurBlk >= Block)
return RC_EF;
/*****************************************************************/
/* Before reading a new block, check whether block indexing */
/* can be done, as well as for join as for local filtering. */
/*****************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
goto next;
} // endswitch rc
} // endif's
if (OldBlk == CurBlk) {
......@@ -304,8 +315,7 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
} else { // Mode == MODE_UPDATE
// T_Stream is the temporary stream or the table file stream itself
if (!T_Stream)
{
if (!T_Stream) {
if (UseTemp /*&& Tdbp->GetMode() == MODE_UPDATE*/) {
if (OpenTempFile(g))
return RC_FX;
......@@ -315,7 +325,9 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
} else
T_Stream = Stream;
}
} // endif T_Stream
Modif++; // Modified line in Update mode
} // endif Mode
......@@ -409,7 +421,7 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/
/* Ok, now delete old file and rename new temp file. */
/*****************************************************************/
if (RenameTempFile(g))
if (RenameTempFile(g, false))
return RC_FX;
} else {
......@@ -516,7 +528,7 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
/***********************************************************************/
/* Table file close routine for FIX access method. */
/***********************************************************************/
void FIXFAM::CloseTableFile(PGLOBAL g)
void FIXFAM::CloseTableFile(PGLOBAL g, bool abort)
{
int rc = RC_OK, wrc = RC_OK;
MODE mode = Tdbp->GetMode();
......@@ -535,17 +547,17 @@ void FIXFAM::CloseTableFile(PGLOBAL g)
} // endif Modif
if (UseTemp && T_Stream && wrc == RC_OK) {
if (!abort) {
// Copy any remaining lines
bool b;
Fpos = Tdbp->Cardinality(g);
abort = MoveIntermediateLines(g, &b) != RC_OK;
} // endif // abort
if ((rc = MoveIntermediateLines(g, &b)) == RC_OK) {
// Delete the old file and rename the new temp file.
RenameTempFile(g);
RenameTempFile(g, abort);
goto fin;
} // endif rc
} // endif UseTemp
} // endif's mode
......@@ -1013,9 +1025,21 @@ int BGXFAM::ReadBuffer(PGLOBAL g)
CurNum = 0;
Tdbp->SetLine(To_Buf);
next:
if (++CurBlk >= Block)
return RC_EF;
/*****************************************************************/
/* Before reading a new block, check whether block optimization */
/* can be done, as well as for join as for local filtering. */
/*****************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
goto next;
} // endswitch rc
} // endif's
if (OldBlk == CurBlk) {
......@@ -1222,7 +1246,7 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/
/* Ok, now delete old file and rename new temp file. */
/*****************************************************************/
if (RenameTempFile(g))
if (RenameTempFile(g, false))
return RC_FX;
} else {
......@@ -1352,7 +1376,7 @@ bool BGXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
/***********************************************************************/
/* Data Base close routine for BIGFIX access method. */
/***********************************************************************/
void BGXFAM::CloseTableFile(PGLOBAL g)
void BGXFAM::CloseTableFile(PGLOBAL g, bool abort)
{
int rc = RC_OK, wrc = RC_OK;
MODE mode = Tdbp->GetMode();
......@@ -1370,17 +1394,17 @@ void BGXFAM::CloseTableFile(PGLOBAL g)
} // endif Modif
if (UseTemp && Tfile && wrc == RC_OK) {
if (!abort) {
// Copy any remaining lines
bool b;
Fpos = Tdbp->Cardinality(g);
abort = MoveIntermediateLines(g, &b) != RC_OK;
} // endif abort
if ((rc = MoveIntermediateLines(g, &b)) == RC_OK) {
// Delete the old file and rename the new temp file.
RenameTempFile(g);
RenameTempFile(g, abort);
goto fin;
} // endif rc
} // endif UseTemp
} // endif's mode
......
/************** FilAMFix H Declares Source Code File (.H) **************/
/* Name: FILAMFIX.H Version 1.2 */
/* Name: FILAMFIX.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 FIX file access method classes declares. */
/***********************************************************************/
......@@ -31,12 +31,14 @@ class DllExport FIXFAM : public BLKFAM {
// Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);}
virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
protected:
virtual bool CopyHeader(PGLOBAL g) {return false;}
......@@ -67,7 +69,7 @@ class BGXFAM : public FIXFAM {
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void);
protected:
......
This diff is collapsed.
......@@ -53,6 +53,7 @@ class DllExport TXTFAM : public BLOCK {
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g) {return false;}
virtual void ResetBuffer(PGLOBAL g) {}
virtual int GetNerr(void) {return 0;}
......@@ -65,7 +66,7 @@ class DllExport TXTFAM : public BLOCK {
virtual int ReadBuffer(PGLOBAL g) = 0;
virtual int WriteBuffer(PGLOBAL g) = 0;
virtual int DeleteRecords(PGLOBAL g, int irc) = 0;
virtual void CloseTableFile(PGLOBAL g) = 0;
virtual void CloseTableFile(PGLOBAL g, bool abort) = 0;
virtual void Rewind(void) = 0;
protected:
......@@ -124,6 +125,7 @@ class DllExport DOSFAM : public TXTFAM {
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
......@@ -133,13 +135,13 @@ class DllExport DOSFAM : public TXTFAM {
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void);
protected:
virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
virtual int RenameTempFile(PGLOBAL g);
virtual int RenameTempFile(PGLOBAL g, bool abort);
// Members
FILE *Stream; // Points to Dos file structure
......@@ -172,6 +174,7 @@ class DllExport BLKFAM : public DOSFAM {
// Methods
virtual void Reset(void);
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
......@@ -179,7 +182,7 @@ class DllExport BLKFAM : public DOSFAM {
virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void);
protected:
......
This diff is collapsed.
......@@ -37,9 +37,11 @@ class DllExport VCTFAM : public FIXFAM {
virtual AMT GetAmType(void) {return TYPE_AM_VCT;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VCTFAM(this);}
virtual int GetFileLength(PGLOBAL g);
// Methods
virtual void Reset(void);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g) {}
......@@ -51,7 +53,7 @@ class DllExport VCTFAM : public FIXFAM {
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void);
// Specific functions
......@@ -70,8 +72,8 @@ class DllExport VCTFAM : public FIXFAM {
// Members
char *NewBlock; // To block written on Insert
char *Colfn; // Pattern for column file names (VER)
char *Tempat; // Pattern for temp file names (VER)
char *Colfn; // Pattern for column file names (VEC)
char *Tempat; // Pattern for temp file names (VEC)
int *Clens; // Pointer to col size array
int *Deplac; // Pointer to col start position array
bool *Isnum; // Pointer to buffer type isnum result
......@@ -108,7 +110,7 @@ class DllExport VCMFAM : public VCTFAM {
virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
// Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
......@@ -145,7 +147,7 @@ class DllExport VECFAM : public VCTFAM {
virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
// Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
......@@ -155,7 +157,7 @@ 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);
virtual int RenameTempFile(PGLOBAL g, bool abort);
bool OpenColumnFile(PGLOBAL g, char *opmode, int i);
// Members
......@@ -189,7 +191,7 @@ class DllExport VMPFAM : public VCMFAM {
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
protected:
bool MapColumnFile(PGLOBAL g, MODE mode, int i);
......@@ -220,7 +222,7 @@ class BGVFAM : public VCTFAM {
virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void);
// Specific functions
......
This diff is collapsed.
/************** FilAmZip H Declares Source Code File (.H) **************/
/* Name: FILAMZIP.H Version 1.1 */
/* Name: FILAMZIP.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */
/* This file contains the GZIP access method classes declares. */
/***********************************************************************/
......@@ -38,6 +38,7 @@ class DllExport ZIPFAM : public TXTFAM {
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
......@@ -47,7 +48,7 @@ class DllExport ZIPFAM : public TXTFAM {
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void);
protected:
......@@ -77,6 +78,7 @@ class DllExport ZBKFAM : public ZIPFAM {
// Methods
virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
......@@ -84,7 +86,7 @@ class DllExport ZBKFAM : public ZIPFAM {
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void);
protected:
......@@ -120,7 +122,6 @@ class DllExport ZIXFAM : public ZBKFAM {
// No additional Members
}; // end of class ZIXFAM
#if 0
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for PlugDB */
/* fixed/variable files compressed using the zlib library functions. */
......@@ -151,7 +152,7 @@ class DllExport ZLBFAM : public BLKFAM {
virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
virtual void Rewind(void);
protected:
......@@ -164,6 +165,5 @@ class DllExport ZLBFAM : public BLKFAM {
int *Zlenp; // Pointer to block length
bool Optimized; // true when opt file is available
}; // end of class ZLBFAM
#endif // 0
#endif // __FILAMZIP_H
This diff is collapsed.
/*************** Filter H Declares Source Code File (.H) ***************/
/* Name: FILTER.H Version 1.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2010-2012 */
/* */
/* This file contains the FILTER and derived classes declares. */
/***********************************************************************/
#ifndef __FILTER__
#define __FILTER__
/***********************************************************************/
/* Include required application header files */
/***********************************************************************/
#include "xobject.h"
/***********************************************************************/
/* Utilities for WHERE condition building. */
/***********************************************************************/
PFIL MakeFilter(PGLOBAL g, PFIL filp, OPVAL vop, PFIL fp);
PFIL MakeFilter(PGLOBAL g, PCOL *colp, POPER pop, PPARM pfirst, bool neg);
/***********************************************************************/
/* Definition of class FILTER with all its method functions. */
/* Note: Most virtual implementation functions are not in use yet */
/* but could be in future system evolution. */
/***********************************************************************/
class DllExport FILTER : public XOBJECT { /* Filter description block */
//friend PFIL PrepareFilter(PGLOBAL, PFIL, bool);
friend DllExport bool ApplyFilter(PGLOBAL, PFIL);
public:
// Constructors
FILTER(PGLOBAL g, POPER pop, PPARM *tp = NULL);
FILTER(PGLOBAL g, OPVAL opc, PPARM *tp = NULL);
FILTER(PFIL fil1);
// Implementation
virtual int GetType(void) {return TYPE_FILTER;}
virtual int GetResultType(void) {return TYPE_INT;}
virtual int GetLength(void) {return 1;}
virtual int GetLengthEx(void) {assert(FALSE); return 0;}
virtual int GetScale() {return 0;};
PFIL GetNext(void) {return Next;}
OPVAL GetOpc(void) {return Opc;}
int GetOpm(void) {return Opm;}
int GetArgType(int i) {return Arg(i)->GetType();}
bool GetResult(void) {return Value->GetIntValue() != 0;}
PXOB &Arg(int i) {return Test[i].Arg;}
PVAL &Val(int i) {return Test[i].Value;}
bool &Conv(int i) {return Test[i].Conv;}
void SetNext(PFIL filp) {Next = filp;}
// Methods
virtual void Reset(void);
virtual bool Compare(PXOB) {return FALSE;} // Not used yet
virtual bool Init(PGLOBAL);
virtual bool Eval(PGLOBAL);
virtual bool SetFormat(PGLOBAL, FORMAT&) {return TRUE;} // NUY
//virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag);
//virtual int RefNum(PSQL);
//virtual PXOB SetSelect(PGLOBAL, PSQL, bool) {return NULL;} // NUY
//virtual PXOB CheckSubQuery(PGLOBAL, PSQL);
//virtual bool CheckLocal(PTDB);
//virtual int CheckSpcCol(PTDB tdbp, int n);
virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z);
// PFIL Linearize(bool nosep);
// PFIL Link(PGLOBAL g, PFIL fil2);
// PFIL RemoveLastSep(void);
// PFIL SortJoin(PGLOBAL g);
// bool FindJoinFilter(POPJOIN opj, PFIL fprec, bool teq,
// bool tek, bool tk2, bool tc2, bool tix, bool thx);
// bool CheckHaving(PGLOBAL g, PSQL sqlp);
bool Convert(PGLOBAL g, bool having);
// int SplitFilter(PFIL *fp);
// int SplitFilter(PFIL *fp, PTDB tp, int n);
// PFIL LinkFilter(PGLOBAL g, PFIL fp2);
// PFIL Copy(PTABS t);
protected:
FILTER(void) {} // Standard constructor not to be used
void Constr(PGLOBAL g, OPVAL opc, int opm, PPARM *tp);
// Members
PFIL Next; // Used for linearization
OPVAL Opc; // Comparison operator
int Opm; // Modificator
BYTE Bt; // Operator bitmap
struct {
int B_T; // Buffer type
PXOB Arg; // Points to argument
PVAL Value; // Points to argument value
bool Conv; // TRUE if argument must be converted
} Test[2];
}; // end of class FILTER
/***********************************************************************/
/* Derived class FILTERX: used to replace a filter by a derived class */
/* using an Eval method optimizing the filtering evaluation. */
/* Note: this works only if the members of the derived class are the */
/* same than the ones of the original class (NO added members). */
/***********************************************************************/
class FILTERX : public FILTER {
public:
// Methods
virtual bool Eval(PGLOBAL) = 0; // just to prevent direct FILTERX use
// Fake operator new used to change a filter into a derived filter
void * operator new(size_t size, PFIL filp) {return filp;}
#if defined(WIN32)
// Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, PFIL) {}
#else
void operator delete(void *) {}
#endif
}; // end of class FILTERX
/***********************************************************************/
/* Derived class FILTEREQ: OP_EQ, no conversion and Xobject args. */
/***********************************************************************/
class FILTERCMP : public FILTERX {
public:
// Constructor
FILTERCMP(PGLOBAL g);
// Methods
virtual bool Eval(PGLOBAL);
}; // end of class FILTEREQ
/***********************************************************************/
/* Derived class FILTERAND: OP_AND, no conversion and Xobject args. */
/***********************************************************************/
class FILTERAND : public FILTERX {
public:
// Methods
virtual bool Eval(PGLOBAL);
}; // end of class FILTERAND
/***********************************************************************/
/* Derived class FILTEROR: OP_OR, no conversion and Xobject args. */
/***********************************************************************/
class FILTEROR : public FILTERX {
public:
// Methods
virtual bool Eval(PGLOBAL);
}; // end of class FILTEROR
/***********************************************************************/
/* Derived class FILTERNOT: OP_NOT, no conversion and Xobject args. */
/***********************************************************************/
class FILTERNOT : public FILTERX {
public:
// Methods
virtual bool Eval(PGLOBAL);
}; // end of class FILTERNOT
/***********************************************************************/
/* Derived class FILTERIN: OP_IN, no conversion and Array 2nd arg. */
/***********************************************************************/
class FILTERIN : public FILTERX {
public:
// Methods
virtual bool Eval(PGLOBAL);
}; // end of class FILTERIN
/***********************************************************************/
/* Derived class FILTERTRUE: Always returns TRUE. */
/***********************************************************************/
class FILTERTRUE : public FILTERX {
public:
// Constructor
FILTERTRUE(PVAL valp) {Value = valp; Value->SetValue_bool(TRUE);}
// Methods
virtual void Reset(void);
virtual bool Eval(PGLOBAL);
}; // end of class FILTERTRUE
#endif // __FILTER__
/***********************************************************************/
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright Olivier Bertrand 1993-2012 */
/* (C) Copyright Olivier Bertrand 1993-2014 */
/***********************************************************************/
/***********************************************************************/
......@@ -223,6 +223,7 @@ typedef struct _global { /* Global structure */
int Createas; /* To pass info to created table */
void *Xchk; /* indexes in create/alter */
short Alchecked; /* Checked for ALTER */
short Mrr; /* True when doing mrr */
short Trace;
int jump_level;
jmp_buf jumper[MAX_JUMP + 2];
......
This diff is collapsed.
/* Copyright (C) Olivier Bertrand 2004 - 2013
/* Copyright (C) Olivier Bertrand 2004 - 2014
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -72,6 +72,7 @@ typedef class XCHK *PCHK;
typedef class user_connect *PCONNECT;
typedef struct ha_table_option_struct TOS, *PTOS;
typedef struct ha_field_option_struct FOS, *PFOS;
typedef struct ha_index_option_struct XOS, *PXOS;
extern handlerton *connect_hton;
......@@ -122,12 +123,27 @@ struct ha_table_option_struct {
struct ha_field_option_struct
{
ulonglong offset;
ulonglong freq;
ulonglong fldlen;
uint opt;
const char *dateformat;
const char *fieldformat;
char *special;
};
/*
index options can be declared similarly
using the ha_index_option_struct structure.
Their values can be specified in the CREATE TABLE per index:
CREATE TABLE ( field ..., .., INDEX .... *here*, ... )
*/
struct ha_index_option_struct
{
bool dynamic;
bool mapped;
};
/** @brief
CONNECT_SHARE is a structure that will be shared among all open handlers.
This example implements the minimum of what you will probably need.
......@@ -166,31 +182,38 @@ class ha_connect: public handler
static bool connect_init(void);
static bool connect_end(void);
TABTYPE GetRealType(PTOS pos= NULL);
char *GetRealString(const char *s);
char *GetStringOption(char *opname, char *sdef= NULL);
PTOS GetTableOptionStruct(TABLE_SHARE *s= NULL);
bool GetBooleanOption(char *opname, bool bdef);
bool SetBooleanOption(char *opname, bool b);
int GetIntegerOption(char *opname);
bool GetIndexOption(KEY *kp, char *opname);
bool CheckString(const char *str1, const char *str2);
bool SameString(TABLE *tab, char *opn);
bool SetIntegerOption(char *opname, int n);
bool SameInt(TABLE *tab, char *opn);
bool SameBool(TABLE *tab, char *opn);
bool FileExists(const char *fn);
bool FileExists(const char *fn, bool bf);
bool NoFieldOptionChange(TABLE *tab);
PFOS GetFieldOptionStruct(Field *fp);
void *GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf);
PXOS GetIndexOptionStruct(KEY *kp);
PIXDEF GetIndexInfo(TABLE_SHARE *s= NULL);
const char *GetDBName(const char *name);
const char *GetTableName(void);
char *GetPartName(void);
//int GetColNameLen(Field *fp);
//char *GetColName(Field *fp);
//void AddColName(char *cp, Field *fp);
TABLE *GetTable(void) {return table;}
bool IsSameIndex(PIXDEF xp1, PIXDEF xp2);
bool IsPartitioned(void);
bool IsUnique(uint n);
PTDB GetTDB(PGLOBAL g);
int OpenTable(PGLOBAL g, bool del= false);
bool CheckColumnList(PGLOBAL g);
bool IsOpened(void);
int CloseTable(PGLOBAL g);
int MakeRecord(char *buf);
......@@ -329,6 +352,8 @@ class ha_connect: public handler
virtual const COND *cond_push(const COND *cond);
PCFIL CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond);
const char *GetValStr(OPVAL vop, bool neg);
PFIL CondFilter(PGLOBAL g, Item *cond);
//PFIL CheckFilter(PGLOBAL g);
/**
Number of rows in table. It will only be called if
......@@ -463,6 +488,28 @@ int index_prev(uchar *buf);
enum thr_lock_type lock_type); ///< required
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
/**
* Multi Range Read interface
*/
int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
uint n_ranges, uint mode, HANDLER_BUFFER *buf);
int multi_range_read_next(range_id_t *range_info);
ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
uint *flags, Cost_estimate *cost);
ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
uint key_parts, uint *bufsz,
uint *flags, Cost_estimate *cost);
int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size);
int reset(void) {ds_mrr.dsmrr_close(); return 0;}
/* Index condition pushdown implementation */
// Item *idx_cond_push(uint keyno, Item* idx_cond);
private:
DsMrr_impl ds_mrr;
protected:
bool check_privileges(THD *thd, PTOS options, char *dbn);
MODE CheckMode(PGLOBAL g, THD *thd, MODE newmode, bool *chk, bool *cras);
......@@ -478,14 +525,19 @@ int index_prev(uchar *buf);
PVAL sdvalin; // Used to convert date values
PVAL sdvalout; // Used to convert date values
bool istable; // True for table handler
//char tname[64]; // The table name
char partname[64]; // The partition name
MODE xmod; // Table mode
XINFO xinfo; // The table info structure
bool valid_info; // True if xinfo is valid
bool stop; // Used when creating index
bool alter; // True when converting to other engine
bool mrr; // True when getting index positions
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;
public:
......
......@@ -571,6 +571,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
tdbp->GetAmType());
tablep->SetTo_Tdb(tdbp);
tdbp->SetTable(tablep);
tdbp->SetMode(mode);
} // endif tdbp
return (tdbp);
......
......@@ -686,19 +686,48 @@ int MYSQLC::ExecSQL(PGLOBAL g, const char *query, int *w)
rc = RC_NF;
} // endif field count
if (w)
//*w = mysql_warning_count(m_DB);
if (w)
// *w = mysql_warning_count(m_DB);
*w = m_DB->warning_count;
return rc;
} // end of ExecSQL
/***********************************************************************/
/* Get table size by executing "select count(*) from table_name". */
/***********************************************************************/
int MYSQLC::GetTableSize(PGLOBAL g, PSZ query)
{
if (mysql_real_query(m_DB, query, strlen(query))) {
#if defined(_DEBUG)
char *msg = (char*)PlugSubAlloc(g, NULL, 512 + strlen(query));
sprintf(msg, "(%d) %s [%s]", mysql_errno(m_DB),
mysql_error(m_DB), query);
strncpy(g->Message, msg, sizeof(g->Message) - 1);
g->Message[sizeof(g->Message) - 1] = 0;
#endif // _DEBUG
return -2;
} // endif mysql_real_query
if (!(m_Res = mysql_store_result(m_DB)))
return -3;
// Get the resulting count value
m_Rows = (int)mysql_num_rows(m_Res); // Should be 1
if (m_Rows && (m_Row = mysql_fetch_row(m_Res)))
return atoi(*m_Row);
return -4;
} // end of GetTableSize
/***********************************************************************/
/* Move to a specific row and column */
/***********************************************************************/
void MYSQLC::DataSeek(my_ulonglong row)
{
MYSQL_ROWS *tmp=0;
MYSQL_ROWS *tmp = 0;
//DBUG_PRINT("info",("mysql_data_seek(%ld)",(long) row));
if (m_Res->data)
......
......@@ -64,6 +64,7 @@ class DllItem MYSQLC {
// Methods
int GetResultSize(PGLOBAL g, PSZ sql);
int GetTableSize(PGLOBAL g, PSZ query);
int Open(PGLOBAL g, const char *host, const char *db,
const char *user= "root", const char *pwd= "*",
int pt= 0);
......
......@@ -21,8 +21,8 @@ DROP INDEX xd ON t1;
ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d);
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 xc 1 c A NULL NULL NULL XPLUG
t1 1 xd 1 d A NULL NULL NULL XPLUG
t1 1 xc 1 c A NULL NULL NULL XINDEX
t1 1 xd 1 d A NULL NULL NULL XINDEX
ALTER TABLE t1 DROP INDEX xc, DROP INDEX xd;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
......@@ -111,8 +111,8 @@ t1 CREATE TABLE `t1` (
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=DBF
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 xc 1 c A NULL NULL NULL XPLUG
t1 1 xd 1 d A NULL NULL NULL XPLUG
t1 1 xc 1 c A NULL NULL NULL XINDEX
t1 1 xd 1 d A NULL NULL NULL XINDEX
SELECT * FROM t1;
c d
1 One
......@@ -143,8 +143,8 @@ line
ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d);
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 xc 1 c A NULL NULL NULL XPLUG
t1 1 xd 1 d A NULL NULL NULL XPLUG
t1 1 xc 1 c A NULL NULL NULL XINDEX
t1 1 xd 1 d A NULL NULL NULL XINDEX
SELECT d FROM t1 WHERE c = 2;
d
Two
......@@ -249,7 +249,7 @@ line
# Sure enough, the data file was not deleted.
#
ALTER TABLE t1 ENGINE=CONNECT;
ERROR HY000: Operation denied. Table data would be lost.
ERROR HY000: Operation denied. Table data would be modified.
#
# But changing back to CONNECT succeed
# if the data file does not exist.
......
......@@ -35,7 +35,7 @@ Warning 1105 No table_type. Will be set to DOS
SELECT * FROM t2;
line
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<!-- Created by the MariaDB CONNECT Storage Engine-->
<t1>
<row>
<TH>c</TH>
......@@ -71,7 +71,7 @@ t1 CREATE TABLE `t1` (
SELECT * FROM t2;
line
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<!-- Created by the MariaDB CONNECT Storage Engine-->
<t1>
<row d="One">
<c>1</c>
......
......@@ -193,8 +193,6 @@ Kevin 8
Lisbeth 2
Mary 2
ALTER TABLE xpet MODIFY number INT NOT NULL;
Warnings:
Warning 1105 This is an outward table, table data were not modified.
SELECT * FROM xpet;
name race number
John dog 2
......
This diff is collapsed.
This diff is collapsed.
......@@ -59,8 +59,6 @@ Joe 5 14.00 0.00 12.00
# Restricting the columns in a Pivot Table
#
ALTER TABLE pivex DROP COLUMN week;
Warnings:
Warning 1105 This is an outward table, table data were not modified.
SELECT * FROM pivex;
Who Beer Car Food
Beth 51.00 0.00 29.00
......
......@@ -416,7 +416,7 @@ DROP TABLE t1;
SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml');
SELECT CAST(@a AS CHAR CHARACTER SET latin1);
CAST(@a AS CHAR CHARACTER SET latin1) <?xml version="1.0" encoding="iso-8859-1"?>
<!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<!-- Created by the MariaDB CONNECT Storage Engine-->
<t1>
<line>
<node>ÀÁÂÃ</node>
......
This diff is collapsed.
This diff is collapsed.
......@@ -28,6 +28,8 @@ enum BLKTYP {TYPE_TABLE = 50, /* Table Name/Srcdef/... Block */
TYPE_COLUMN = 51, /* Column Name/Qualifier Block */
TYPE_TDB = 53, /* Table Description Block */
TYPE_COLBLK = 54, /* Column Description Block */
TYPE_FILTER = 55, /* Filter Description Block */
TYPE_ARRAY = 63, /* General array type */
TYPE_PSZ = 64, /* Pointer to String ended by 0 */
TYPE_SQL = 65, /* Pointer to SQL block */
TYPE_XOBJECT = 69, /* Extended DB object */
......@@ -83,6 +85,7 @@ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
TYPE_AM_SRVID = 5, /* SERVID type (special column) */
TYPE_AM_TABID = 6, /* TABID type (special column) */
TYPE_AM_CNSID = 7, /* CONSTID type (special column) */
TYPE_AM_PRTID = 8, /* PARTID type (special column) */
TYPE_AM_COUNT = 10, /* CPT AM type no (count table) */
TYPE_AM_DCD = 20, /* Decode access method type no */
TYPE_AM_CMS = 30, /* CMS access method type no */
......@@ -371,6 +374,7 @@ typedef class COLDEF *PCOLDEF;
typedef class CONSTANT *PCONST;
typedef class VALUE *PVAL;
typedef class VALBLK *PVBLK;
typedef class FILTER *PFIL;
typedef struct _fblock *PFBLOCK;
typedef struct _mblock *PMBLOCK;
......@@ -416,6 +420,7 @@ typedef struct { /* User application block */
PFBLOCK Openlist; /* To file/map open list */
PMBLOCK Memlist; /* To memory block list */
PXUSED Xlist; /* To used index list */
int Maxbmp; /* Maximum XDB2 bitmap size */
int Check; /* General level of checking */
int Numlines; /* Number of lines involved */
USETEMP UseTemp; /* Use temporary file */
......@@ -460,6 +465,21 @@ typedef struct _tabs {
PTABADR P3;
} TABS;
/***********************************************************************/
/* Argument of expression, function, filter etc. (Xobject) */
/***********************************************************************/
typedef struct _arg { /* Argument */
PXOB To_Obj; /* To the argument object */
PVAL Value; /* Argument value */
bool Conv; /* TRUE if conversion is required */
} ARGBLK, *PARG;
typedef struct _oper { /* Operator */
PSZ Name; /* The input/output operator name */
OPVAL Val; /* Operator numeric value */
int Mod; /* The modificator */
} OPER, *POPER;
/***********************************************************************/
/* Following definitions are used to define table fields (columns). */
/***********************************************************************/
......@@ -530,6 +550,7 @@ PPARM Vcolist(PGLOBAL, PTDB, PSZ, bool);
void PlugPutOut(PGLOBAL, FILE *, short, void *, uint);
void PlugLineDB(PGLOBAL, PSZ, short, void *, uint);
char *PlgGetDataPath(PGLOBAL g);
char *ExtractFromPath(PGLOBAL, char *, char *, OPVAL);
void AddPointer(PTABS, void *);
PDTP MakeDateFormat(PGLOBAL, PSZ, bool, bool, int);
int ExtractDate(char *, PDTP, int, int val[6]);
......
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.
/*************** Tabxml H Declares Source Code File (.H) ***************/
/* Name: TABXML.H Version 1.6 */
/* */
......
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