mariadb/storage/connect/reldef.h

248 lines
11 KiB
C
Raw Normal View History

/*************** RelDef H Declares Source Code File (.H) ***************/
/* Name: RELDEF.H Version 1.6 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2004-2016 */
/* */
/* This file contains the DEF classes definitions. */
/***********************************************************************/
#ifndef __RELDEF_H
#define __RELDEF_H
#include "block.h"
#include "catalog.h"
2013-02-18 16:21:52 +01:00
#include "my_sys.h"
#include "mycat.h"
typedef class INDEXDEF *PIXDEF;
typedef class ha_connect *PHC;
/***********************************************************************/
/* Table or View (relation) definition block. */
/***********************************************************************/
class DllExport RELDEF : public BLOCK { // Relation definition block
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
public:
RELDEF(void); // Constructor
// Implementation
PRELDEF GetNext(void) {return Next;}
PSZ GetName(void) {return Name;}
PSZ GetDB(void) {return (PSZ)Database;}
PCOLDEF GetCols(void) {return To_Cols;}
PHC GetHandler(void) {return Hc;}
void SetCols(PCOLDEF pcd) {To_Cols = pcd;}
PCATLG GetCat(void) {return Cat;}
virtual const char *GetType(void) = 0;
virtual AMT GetDefType(void) = 0;
void SetName(const char *str) { Name=(char*)str; }
void SetCat(PCATLG cat) { Cat=cat; }
// Methods
PTOS GetTopt(void);
bool GetBoolCatInfo(PSZ what, bool bdef);
bool SetIntCatInfo(PSZ what, int ival);
This commit brings many changes, in particular two important ones: 1) Support of partitioning by connect. A table can be partitioned by files, this is an enhanced MULTIPLE table. It can be also partitioned by sub-tables like TBL and this enables table sharding. 2) Handling a CONNECT bug that causes in some cases extraneous rows to remain in the table after an UPDATE or DELETE when the command uses indexing (for not fixed file tables). Until a real fix is done, CONNECT tries to ignore indexing and if it cannot do it abort the command with an error message. - Add tests on partitioning added: storage/connect/mysql-test/connect/r/part_file.result storage/connect/mysql-test/connect/r/part_table.result storage/connect/mysql-test/connect/t/part_file.test storage/connect/mysql-test/connect/t/part_table.test - Temporary fix modified: sql/sql_partition.cc - Add partition support modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabdos.cpp - Add functions ha_connect::IsUnique and ha_connect::CheckColumnList modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Prevent updating a partition table column that is part of the partition function (outward tables only) modified: storage/connect/ha_connect.cc - Support INSERT/UPDATE/DELETE for PROXY tables modified: storage/connect/tabutil.cpp - Handle the bug on updating rows via indexing. Waiting for a real fix, Don't use indexing when possible else raise an error and abort. modified: storage/connect/ha_connect.cc - dbuserp->UseTemp set to TMP_AUTO modified: storage/connect/connect.cc - Add members nox, abort and only modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h - Add arguments nox and abort to CntCloseTable modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/ha_connect.cc - Add arguments abort to CloseTableFile and RenameTempFile modified: storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.cpp storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabvct.cpp storage/connect/xtable.h - Fix info->records when file does not exists modified: storage/connect/connect.cc - Close XML table when opened for info modified: storage/connect/connect.cc - Add function VCTFAM::GetFileLength modified: storage/connect/filamvct.cpp storage/connect/filamvct.h - Column option DISTRIB -> ENUM modified: storage/connect/ha_connect.cc - Options connect, query_string and partname allways available modified: storage/connect/ha_connect.cc - Add function MYSQLC::GetTableSize modified: storage/connect/myconn.cpp storage/connect/myconn.h - Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK) modified: storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/plgdbsem.h storage/connect/table.cpp - Add function ExtractFromPath modified: storage/connect/colblk.cpp storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp - Enhance Cardinality for some table types modified: storage/connect/tabdos.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/tabodbc.cpp storage/connect/tabodbc.h storage/connect/tabsys.cpp storage/connect/tabsys.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xtable.h - Add test on special column modified: storage/connect/tabfmt.cpp - Add new files (added for block indexing) modified: storage/connect/CMakeLists.txt
2014-07-17 18:13:51 +02:00
bool Partitioned(void);
int GetIntCatInfo(PSZ what, int idef);
int GetSizeCatInfo(PSZ what, PSZ sdef);
int GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size);
char *GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef);
virtual int Indexable(void) {return 0;}
virtual bool Define(PGLOBAL g, PCATLG cat,
LPCSTR name, LPCSTR schema, LPCSTR am) = 0;
virtual PTDB GetTable(PGLOBAL g, MODE mode) = 0;
protected:
PRELDEF Next; /* To next definition block */
PSZ Name; /* Name of the view */
LPCSTR Database; /* Table database */
PCOLDEF To_Cols; /* To a list of column desc */
PCATLG Cat; /* To DB catalog info */
PHC Hc; /* The Connect handler */
}; // end of RELDEF
/***********************************************************************/
2017-02-16 18:01:48 +01:00
/* This class corresponds to the data base description for tables */
/* of type DOS, FIX, CSV, DBF, BIN, VCT, JSON, XML... */
/***********************************************************************/
class DllExport TABDEF : public RELDEF { /* Logical table descriptor */
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
2017-02-16 18:01:48 +01:00
friend class TDB;
friend class TDBEXT;
public:
// Constructor
TABDEF(void); // Constructor
// Implementation
int GetDegree(void) {return Degree;}
void SetDegree(int d) {Degree = d;}
int GetElemt(void) {return Elemt;}
void SetNext(PTABDEF tdfp) {Next = tdfp;}
int GetMultiple(void) {return Multiple;}
int GetPseudo(void) {return Pseudo;}
PSZ GetPath(void);
//PSZ GetPath(void)
// {return (Database) ? (PSZ)Database : Cat->GetDataPath();}
bool SepIndex(void) {return GetBoolCatInfo("SepIndex", false);}
bool IsReadOnly(void) {return Read_Only;}
virtual AMT GetDefType(void) {return TYPE_AM_TAB;}
virtual PIXDEF GetIndx(void) {return NULL;}
Get rid of GCC warnings about unused parameters modified: storage/connect/array.cpp modified: storage/connect/blkfil.cpp modified: storage/connect/block.h modified: storage/connect/catalog.h modified: storage/connect/colblk.cpp modified: storage/connect/colblk.h modified: storage/connect/connect.cc modified: storage/connect/filamap.cpp modified: storage/connect/filamdbf.cpp modified: storage/connect/filamfix.cpp modified: storage/connect/filamtxt.cpp modified: storage/connect/filamtxt.h modified: storage/connect/filamvct.cpp modified: storage/connect/filamzip.cpp modified: storage/connect/filter.h modified: storage/connect/ha_connect.c modified: storage/connect/jsonudf.cpp modified: storage/connect/mycat.h modified: storage/connect/myconn.cpp modified: storage/connect/plgdbutl.cpp modified: storage/connect/reldef.cpp modified: storage/connect/reldef.h modified: storage/connect/tabcol.cpp modified: storage/connect/tabdos.cpp modified: storage/connect/tabdos.h modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabfmt.h modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h modified: storage/connect/table.cpp modified: storage/connect/tabmul.cpp modified: storage/connect/tabmysql.cpp modified: storage/connect/tabmysql.h modified: storage/connect/taboccur.cpp modified: storage/connect/tabpivot.cpp modified: storage/connect/tabsys.cpp modified: storage/connect/tabtbl.cpp modified: storage/connect/tabtbl.h modified: storage/connect/tabutil.cpp modified: storage/connect/tabutil.h modified: storage/connect/tabvct.cpp modified: storage/connect/tabvir.cpp modified: storage/connect/tabvir.h modified: storage/connect/tabxcl.cpp modified: storage/connect/tabxcl.h modified: storage/connect/tabxml.cpp modified: storage/connect/tabxml.h modified: storage/connect/valblk.cpp modified: storage/connect/valblk.h modified: storage/connect/value.cpp modified: storage/connect/value.h modified: storage/connect/xindex.cpp modified: storage/connect/xindex.h modified: storage/connect/xobject.h modified: storage/connect/xtable.h
2015-05-09 17:30:20 +02:00
virtual void SetIndx(PIXDEF) {}
virtual bool IsHuge(void) {return false;}
const CHARSET_INFO *data_charset() {return m_data_charset;}
// Methods
int GetColCatInfo(PGLOBAL g);
void SetIndexInfo(void);
bool DropTable(PGLOBAL g, PSZ name);
virtual bool Define(PGLOBAL g, PCATLG cat,
LPCSTR name, LPCSTR schema, LPCSTR am);
virtual bool DefineAM(PGLOBAL, LPCSTR, int) = 0;
protected:
// Members
PSZ Schema; /* Table schema (for ODBC) */
PSZ Desc; /* Table description */
uint Catfunc; /* Catalog function ID */
int Card; /* (max) number of rows in table */
int Elemt; /* Number of rows in blocks or rowset */
int Sort; /* Table already sorted ??? */
int Multiple; /* 0: No 1: DIR 2: Section 3: filelist */
int Degree; /* Number of columns in the table */
2017-02-16 18:01:48 +01:00
int Pseudo; /* Bit: 1 ROWID }Ok, 2 FILEID Ok */
bool Read_Only; /* true for read only tables */
2013-02-18 16:21:52 +01:00
const CHARSET_INFO *m_data_charset;
const char *csname; /* Table charset name */
2017-02-16 18:01:48 +01:00
}; // end of TABDEF
/***********************************************************************/
/* Externally defined OEM tables. */
/***********************************************************************/
class DllExport OEMDEF : public TABDEF { /* OEM table */
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
public:
// Constructor
OEMDEF(void) {Hdll = NULL; Pxdef = NULL; Module = Subtype = NULL;}
// Implementation
virtual const char *GetType(void) {return "OEM";}
virtual AMT GetDefType(void) {return TYPE_AM_OEM;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
protected:
PTABDEF GetXdef(PGLOBAL g);
// Members
Change all preprocessor compiler directives to use __WIN__ as the mean of specifying Windows or not Windows compile. This is what MariaDB does. modified: storage/connect/array.cpp modified: storage/connect/blkfil.cpp modified: storage/connect/block.h modified: storage/connect/colblk.cpp modified: storage/connect/domdoc.cpp modified: storage/connect/filamap.cpp modified: storage/connect/filamdbf.cpp modified: storage/connect/filamfix.cpp modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/filamzip.cpp modified: storage/connect/filter.cpp modified: storage/connect/filter.h modified: storage/connect/fmdlex.c modified: storage/connect/global.h modified: storage/connect/ha_connect.cc modified: storage/connect/json.cpp modified: storage/connect/macutil.cpp modified: storage/connect/macutil.h modified: storage/connect/maputil.cpp modified: storage/connect/mycat.cc modified: storage/connect/myconn.cpp modified: storage/connect/myconn.h modified: storage/connect/myutil.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/odbconn.h modified: storage/connect/os.h modified: storage/connect/osutil.c modified: storage/connect/plgdbsem.h modified: storage/connect/plgdbutl.cpp modified: storage/connect/plugutil.c modified: storage/connect/rcmsg.c modified: storage/connect/reldef.cpp modified: storage/connect/reldef.h modified: storage/connect/tabdos.cpp modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/tabmac.cpp modified: storage/connect/tabmac.h modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h modified: storage/connect/tabmysql.cpp modified: storage/connect/taboccur.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabpivot.cpp modified: storage/connect/tabsys.cpp modified: storage/connect/tabtbl.cpp modified: storage/connect/tabutil.cpp modified: storage/connect/tabvct.cpp modified: storage/connect/tabwmi.cpp modified: storage/connect/tabxcl.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/valblk.cpp modified: storage/connect/value.cpp modified: storage/connect/xindex.cpp modified: storage/connect/xindex.h
2015-05-27 16:23:38 +02:00
#if defined(__WIN__)
HANDLE Hdll; /* Handle to the external DLL */
Change all preprocessor compiler directives to use __WIN__ as the mean of specifying Windows or not Windows compile. This is what MariaDB does. modified: storage/connect/array.cpp modified: storage/connect/blkfil.cpp modified: storage/connect/block.h modified: storage/connect/colblk.cpp modified: storage/connect/domdoc.cpp modified: storage/connect/filamap.cpp modified: storage/connect/filamdbf.cpp modified: storage/connect/filamfix.cpp modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/filamzip.cpp modified: storage/connect/filter.cpp modified: storage/connect/filter.h modified: storage/connect/fmdlex.c modified: storage/connect/global.h modified: storage/connect/ha_connect.cc modified: storage/connect/json.cpp modified: storage/connect/macutil.cpp modified: storage/connect/macutil.h modified: storage/connect/maputil.cpp modified: storage/connect/mycat.cc modified: storage/connect/myconn.cpp modified: storage/connect/myconn.h modified: storage/connect/myutil.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/odbconn.h modified: storage/connect/os.h modified: storage/connect/osutil.c modified: storage/connect/plgdbsem.h modified: storage/connect/plgdbutl.cpp modified: storage/connect/plugutil.c modified: storage/connect/rcmsg.c modified: storage/connect/reldef.cpp modified: storage/connect/reldef.h modified: storage/connect/tabdos.cpp modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/tabmac.cpp modified: storage/connect/tabmac.h modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h modified: storage/connect/tabmysql.cpp modified: storage/connect/taboccur.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabpivot.cpp modified: storage/connect/tabsys.cpp modified: storage/connect/tabtbl.cpp modified: storage/connect/tabutil.cpp modified: storage/connect/tabvct.cpp modified: storage/connect/tabwmi.cpp modified: storage/connect/tabxcl.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/valblk.cpp modified: storage/connect/value.cpp modified: storage/connect/xindex.cpp modified: storage/connect/xindex.h
2015-05-27 16:23:38 +02:00
#else // !__WIN__
void *Hdll; /* Handle for the loaded shared library */
Change all preprocessor compiler directives to use __WIN__ as the mean of specifying Windows or not Windows compile. This is what MariaDB does. modified: storage/connect/array.cpp modified: storage/connect/blkfil.cpp modified: storage/connect/block.h modified: storage/connect/colblk.cpp modified: storage/connect/domdoc.cpp modified: storage/connect/filamap.cpp modified: storage/connect/filamdbf.cpp modified: storage/connect/filamfix.cpp modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/filamzip.cpp modified: storage/connect/filter.cpp modified: storage/connect/filter.h modified: storage/connect/fmdlex.c modified: storage/connect/global.h modified: storage/connect/ha_connect.cc modified: storage/connect/json.cpp modified: storage/connect/macutil.cpp modified: storage/connect/macutil.h modified: storage/connect/maputil.cpp modified: storage/connect/mycat.cc modified: storage/connect/myconn.cpp modified: storage/connect/myconn.h modified: storage/connect/myutil.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/odbconn.h modified: storage/connect/os.h modified: storage/connect/osutil.c modified: storage/connect/plgdbsem.h modified: storage/connect/plgdbutl.cpp modified: storage/connect/plugutil.c modified: storage/connect/rcmsg.c modified: storage/connect/reldef.cpp modified: storage/connect/reldef.h modified: storage/connect/tabdos.cpp modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/tabmac.cpp modified: storage/connect/tabmac.h modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h modified: storage/connect/tabmysql.cpp modified: storage/connect/taboccur.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabpivot.cpp modified: storage/connect/tabsys.cpp modified: storage/connect/tabtbl.cpp modified: storage/connect/tabutil.cpp modified: storage/connect/tabvct.cpp modified: storage/connect/tabwmi.cpp modified: storage/connect/tabxcl.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/valblk.cpp modified: storage/connect/value.cpp modified: storage/connect/xindex.cpp modified: storage/connect/xindex.h
2015-05-27 16:23:38 +02:00
#endif // !__WIN__
PTABDEF Pxdef; /* Pointer to the external TABDEF class */
char *Module; /* Path/Name of the DLL implenting it */
char *Subtype; /* The name of the OEM table sub type */
}; // end of OEMDEF
/***********************************************************************/
/* Column definition block used during creation. */
/***********************************************************************/
class DllExport COLCRT : public BLOCK { /* Column description block */
friend class TABDEF;
public:
COLCRT(PSZ name); // Constructor
COLCRT(void); // Constructor (for views)
// Implementation
PSZ GetName(void) {return Name;}
PSZ GetDecode(void) {return Decode;}
PSZ GetFmt(void) {return Fmt;}
int GetOpt(void) {return Opt;}
int GetFreq(void) {return Freq;}
int GetLong(void) {return Long;}
int GetPrecision(void) {return Precision;}
int GetOffset(void) {return Offset;}
void SetOffset(int offset) {Offset = offset;}
protected:
PCOLCRT Next; /* To next block */
PSZ Name; /* Column name */
PSZ Desc; /* Column description */
PSZ Decode; /* Date format */
PSZ Fmt; /* Input format for formatted files */
int Offset; /* Offset of field within record */
int Long; /* Length of field in file record (!BIN) */
int Key; /* Key (greater than 1 if multiple) */
int Precision; /* Logical column length */
int Scale; /* Decimals for float/decimal values */
int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */
int Freq; /* Estimated number of different values */
char DataType; /* Internal data type (C, N, F, T) */
}; // end of COLCRT
/***********************************************************************/
/* Column definition block. */
/***********************************************************************/
2017-02-16 18:01:48 +01:00
class DllExport COLDEF : public COLCRT { /* Column description block */
friend class TABDEF;
friend class COLBLK;
friend class DBFFAM;
2017-02-16 18:01:48 +01:00
friend class TDB;
friend class TDBASE;
friend class TDBDOS;
public:
COLDEF(void); // Constructor
// Implementation
PCOLDEF GetNext(void) {return (PCOLDEF)Next;}
void SetNext(PCOLDEF pcdf) {Next = pcdf;}
int GetLength(void) {return (int)F.Length;}
int GetClen(void) {return Clen;}
int GetType(void) {return Buf_Type;}
int GetPoff(void) {return Poff;}
void *GetMin(void) {return To_Min;}
void SetMin(void *minp) {To_Min = minp;}
void *GetMax(void) {return To_Max;}
void SetMax(void *maxp) {To_Max = maxp;}
bool GetXdb2(void) {return Xdb2;}
void SetXdb2(bool b) {Xdb2 = b;}
void *GetBmap(void) {return To_Bmap;}
void SetBmap(void *bmp) {To_Bmap = bmp;}
void *GetDval(void) {return To_Dval;}
void SetDval(void *dvp) {To_Dval = dvp;}
int GetNdv(void) {return Ndv;}
void SetNdv(int ndv) {Ndv = ndv;}
int GetNbm(void) {return Nbm;}
void SetNbm(int nbm) {Nbm = nbm;}
int Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff);
void Define(PGLOBAL g, PCOL colp);
bool IsSpecial(void) {return (Flags & U_SPECIAL) ? true : false;}
bool IsVirtual(void) {return (Flags & U_VIRTUAL) ? true : false;}
protected:
void *To_Min; /* Point to array of block min values */
void *To_Max; /* Point to array of block max values */
int *To_Pos; /* Point to array of block positions */
bool Xdb2; /* TRUE if to be optimized by XDB2 */
void *To_Bmap; /* To array of block bitmap values */
void *To_Dval; /* To array of column distinct values */
int Ndv; /* Number of distinct values */
int Nbm; /* Number of ULONG in bitmap (XDB2) */
int Buf_Type; /* Internal data type */
int Clen; /* Internal data size in chars (bytes) */
int Poff; /* Calculated offset for Packed tables */
FORMAT F; /* Output format (should be in COLCRT) */
ushort Flags; /* Used by MariaDB CONNECT handler */
}; // end of COLDEF
#endif // __RELDEF_H