Commit 99d95c8a authored by Olivier Bertrand's avatar Olivier Bertrand

- Added table type PIVOT

modified:
  storage/connect/filamdbf.cpp
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h
  storage/connect/mycat.cc
  storage/connect/myconn.cpp
  storage/connect/odbconn.cpp
  storage/connect/plgcnx.h
  storage/connect/plgdbsem.h
  storage/connect/plgdbutl.cpp
  storage/connect/tabfmt.cpp
  storage/connect/tabpivot.cpp
  storage/connect/tabpivot.h
  storage/connect/tabutil.cpp
  storage/connect/tabwmi.cpp
  storage/connect/tabxcl.cpp
  storage/connect/value.cpp
  storage/connect/value.h
parent be268bed
......@@ -178,15 +178,13 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
/****************************************************************************/
PQRYRES DBFColumns(PGLOBAL g, const char *fn, BOOL info)
{
static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR,
DB_INT, DB_INT, DB_SHORT};
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
TYPE_INT, TYPE_INT, TYPE_SHORT};
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME,
FLD_PREC, FLD_LENGTH, FLD_SCALE};
static unsigned int length[] = {11, 6, 8, 10, 10, 6};
char buf[2], filename[_MAX_PATH];
int ncol = sizeof(dbtype) / sizeof(int);
int ncol = sizeof(buftyp) / sizeof(int);
int rc, type, len, field, fields;
BOOL bad;
DBFHEADER mainhead;
......@@ -228,8 +226,7 @@ PQRYRES DBFColumns(PGLOBAL g, const char *fn, BOOL info)
fields = 0;
qrp = PlgAllocResult(g, ncol, fields, IDS_COLUMNS + 3,
dbtype, buftyp, fldtyp, length, true, false);
//qrp->Info = info || (rc == RC_INFO);
buftyp, fldtyp, length, true, false);
if (info)
return qrp;
......
......@@ -207,6 +207,8 @@ ha_create_table_option connect_table_option_list[]=
HA_TOPTION_STRING("MODULE", module),
HA_TOPTION_STRING("SUBTYPE", subtype),
HA_TOPTION_STRING("CATFUNC", catfunc),
HA_TOPTION_STRING("SRCDEF", srcdef),
HA_TOPTION_STRING("COLIST", colist),
HA_TOPTION_STRING("OPTION_LIST", oplist),
HA_TOPTION_STRING("DATA_CHARSET", data_charset),
HA_TOPTION_NUMBER("LRECL", lrecl, 0, 0, INT_MAX32, 1),
......@@ -590,7 +592,7 @@ static char *GetListOption(PGLOBAL g, const char *opname,
} else {
if (pn) {
n= pn - pk;
n= min(pn - pk, 15);
memcpy(key, pk, n);
key[n]= 0;
} else
......@@ -655,6 +657,10 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
opval= (char*)options->subtype;
else if (!stricmp(opname, "Catfunc"))
opval= (char*)options->catfunc;
else if (!stricmp(opname, "Srcdef"))
opval= (char*)options->srcdef;
else if (!stricmp(opname, "Colist"))
opval= (char*)options->colist;
else if (!stricmp(opname, "Data_charset"))
opval= (char*)options->data_charset;
......@@ -2667,7 +2673,6 @@ bool ha_connect::check_privileges(THD *thd, PTOS options)
case TAB_JCT:
case TAB_DMY:
case TAB_NIY:
case TAB_PIVOT:
my_printf_error(ER_UNKNOWN_ERROR,
"Unsupported table type %s", MYF(0), options->type);
return true;
......@@ -2706,6 +2711,7 @@ bool ha_connect::check_privileges(THD *thd, PTOS options)
case TAB_XCL:
case TAB_PRX:
case TAB_OCCUR:
case TAB_PIVOT:
return false;
}
......
......@@ -83,6 +83,8 @@ struct ha_table_option_struct {
const char *module;
const char *subtype;
const char *catfunc;
const char *srcdef;
const char *colist;
const char *oplist;
const char *data_charset;
ulonglong lrecl;
......
......@@ -132,6 +132,9 @@ TABTYPE GetTypeID(const char *type)
: (!stricmp(type, "OCCUR")) ? TAB_OCCUR
: (!stricmp(type, "CATLG")) ? TAB_PRX // Legacy
: (!stricmp(type, "PROXY")) ? TAB_PRX
#ifdef PIVOT_SUPPORT
: (!stricmp(type, "PIVOT")) ? TAB_PIVOT
#endif
: (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY;
} // end of GetTypeID
......@@ -650,9 +653,9 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am)
#if defined(MYSQL_SUPPORT)
case TAB_MYSQL: tdp= new(g) MYSQLDEF; break;
#endif // MYSQL_SUPPORT
//#if defined(PIVOT_SUPPORT)
// case TAB_PIVOT: tdp= new(g) PIVOTDEF; break;
//#endif // PIVOT_SUPPORT
#if defined(PIVOT_SUPPORT)
case TAB_PIVOT: tdp= new(g) PIVOTDEF; break;
#endif // PIVOT_SUPPORT
default:
sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name);
} // endswitch
......
......@@ -74,10 +74,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
const char *table, const char *colpat,
int port, bool key, bool info)
{
static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR, DB_INT,
DB_CHAR, DB_SHORT, DB_SHORT, DB_SHORT,
DB_CHAR, DB_CHAR, DB_CHAR};
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
TYPE_STRING, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT,
TYPE_STRING, TYPE_STRING, TYPE_STRING};
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
......@@ -85,7 +82,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
FLD_REM, FLD_NO, FLD_CHARSET};
static unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 256, 32, 32};
char *fld, *fmt, cmd[128];
int i, n, nf, ncol = sizeof(dbtype) / sizeof(int);
int i, n, nf, ncol = sizeof(buftyp) / sizeof(int);
int len, type, prec, rc, k = 0;
PQRYRES qrp;
PCOLRES crp;
......@@ -134,7 +131,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
/* Allocate the structures used to refer to the result set. */
/**********************************************************************/
qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3,
dbtype, buftyp, fldtyp, length, true, true);
buftyp, fldtyp, length, true, true);
// Some columns must be renamed
for (i = 0, crp = qrp->Colresp; crp; crp = crp->Next)
......@@ -665,7 +662,6 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
crp->Prec = fld->decimals;
crp->Length = fld->max_length;
crp->Clen = GetTypeSize(crp->Type, crp->Length);
crp->DBtype = GetDBType((int)crp->Type);
if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows,
crp->Clen, 0, FALSE, TRUE))) {
......
......@@ -230,11 +230,7 @@ void ResetNullValues(CATPARM *cap)
PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table,
char *colpat, bool info)
{
static int dbtype[] = {DB_CHAR, DB_CHAR, DB_CHAR,
DB_CHAR, DB_SHORT, DB_CHAR,
DB_INT, DB_INT, DB_SHORT,
DB_SHORT, DB_SHORT, DB_CHAR};
static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
TYPE_STRING, TYPE_SHORT, TYPE_STRING,
TYPE_INT, TYPE_INT, TYPE_SHORT,
TYPE_SHORT, TYPE_SHORT, TYPE_STRING};
......@@ -285,7 +281,7 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table,
/* Allocate the structures used to refer to the result set. */
/************************************************************************/
qrp = PlgAllocResult(g, ncol, maxres, IDS_COLUMNS,
dbtype, buftyp, fldtyp, length, true, true);
buftyp, fldtyp, length, true, true);
if (info) // Info table
return qrp;
......@@ -396,7 +392,6 @@ PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info)
/*************************************************************************/
PQRYRES ODBCDataSources(PGLOBAL g, bool info)
{
static int dbtype[] = {DB_CHAR, DB_CHAR};
static int buftyp[] = {TYPE_STRING, TYPE_STRING};
static XFLD fldtyp[] = {FLD_NAME, FLD_REM};
static unsigned int length[] = {0, 256};
......@@ -425,7 +420,7 @@ PQRYRES ODBCDataSources(PGLOBAL g, bool info)
/* Allocate the structures used to refer to the result set. */
/************************************************************************/
qrp = PlgAllocResult(g, ncol, maxres, IDS_DSRC,
dbtype, buftyp, fldtyp, length, true, true);
buftyp, fldtyp, length, true, true);
/************************************************************************/
/* Now get the results into blocks. */
......@@ -446,7 +441,6 @@ PQRYRES ODBCDataSources(PGLOBAL g, bool info)
/*************************************************************************/
PQRYRES ODBCDrivers(PGLOBAL g, bool info)
{
static int dbtype[] = {DB_CHAR, DB_CHAR};
static int buftyp[] = {TYPE_STRING, TYPE_STRING};
static XFLD fldtyp[] = {FLD_NAME, FLD_REM};
static unsigned int length[] = {128, 256};
......@@ -471,7 +465,7 @@ PQRYRES ODBCDrivers(PGLOBAL g, bool info)
/* Allocate the structures used to refer to the result set. */
/************************************************************************/
qrp = PlgAllocResult(g, ncol, maxres, IDS_DRIVER,
dbtype, buftyp, fldtyp, length, true, true);
buftyp, fldtyp, length, true, true);
/************************************************************************/
/* Now get the results into blocks. */
......@@ -492,8 +486,7 @@ PQRYRES ODBCDrivers(PGLOBAL g, bool info)
/***********************************************************************/
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info)
{
static int dbtype[] = {DB_CHAR, DB_CHAR, DB_CHAR, DB_CHAR, DB_CHAR};
static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
TYPE_STRING, TYPE_STRING};
static XFLD fldtyp[] = {FLD_QUALIF, FLD_OWNER, FLD_NAME,
FLD_TYPE, FLD_REM};
......@@ -536,7 +529,7 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info)
/************************************************************************/
/* Allocate the structures used to refer to the result set. */
/************************************************************************/
qrp = PlgAllocResult(g, ncol, maxres, IDS_TABLES, dbtype, buftyp,
qrp = PlgAllocResult(g, ncol, maxres, IDS_TABLES, buftyp,
fldtyp, length, true, true);
if (info)
......@@ -579,8 +572,6 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info)
/**************************************************************************/
PQRYRES ODBCPrimaryKeys(PGLOBAL g, ODBConn *op, char *dsn, char *table)
{
static int dbtype[] = {DB_CHAR, DB_CHAR, DB_CHAR,
DB_CHAR, DB_SHORT, DB_CHAR};
static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
TYPE_STRING, TYPE_SHORT, TYPE_STRING};
static unsigned int length[] = {0, 0, 0, 0, 6, 128};
......@@ -623,7 +614,7 @@ PQRYRES ODBCPrimaryKeys(PGLOBAL g, ODBConn *op, char *dsn, char *table)
/* Allocate the structure used to refer to the result set. */
/************************************************************************/
qrp = PlgAllocResult(g, ncol, maxres, IDS_PKEY,
dbtype, buftyp, NULL, length, true, true);
buftyp, NULL, length, true, true);
if (trace)
htrc("Getting pkey results ncol=%d\n", qrp->Nbcol);
......@@ -662,9 +653,6 @@ PQRYRES ODBCPrimaryKeys(PGLOBAL g, ODBConn *op, char *dsn, char *table)
PQRYRES ODBCStatistics(PGLOBAL g, ODBConn *op, char *dsn, char *pat,
int un, int acc)
{
static int dbtype[] = {DB_CHAR, DB_CHAR, DB_CHAR, DB_SHORT, DB_CHAR,
DB_CHAR, DB_SHORT, DB_SHORT, DB_CHAR, DB_CHAR,
DB_INT, DB_INT, DB_CHAR};
static int buftyp[] = {TYPE_STRING,
TYPE_STRING, TYPE_STRING, TYPE_SHORT, TYPE_STRING,
TYPE_STRING, TYPE_SHORT, TYPE_SHORT, TYPE_STRING,
......@@ -708,7 +696,7 @@ PQRYRES ODBCStatistics(PGLOBAL g, ODBConn *op, char *dsn, char *pat,
/* Allocate the structure used to refer to the result set. */
/************************************************************************/
qrp = PlgAllocResult(g, ncol, maxres, IDS_STAT,
dbtype, buftyp, NULL, length, true, true);
buftyp, NULL, length, true, true);
if (trace)
htrc("Getting stat results ncol=%d\n", qrp->Nbcol);
......
......@@ -49,17 +49,6 @@ enum RCODE {RC_OK = 0, /* No error return code */
RC_INFO = 4}; /* Success with info */
#endif // !RC_OK_DEFINED
/**************************************************************************/
/* Data types. */
/**************************************************************************/
enum XDBTYPE {DB_ERROR = 0, /* Unknown or wrong type */
DB_STRING = 1, /* Null terminated string */
DB_CHAR = 2, /* Character array */
DB_SHORT = 3, /* Used by some catalog functions */
DB_INT = 4, /* Long integer array */
DB_DOUBLE = 5, /* Double float array */
DB_DATE = 6}; /* Datetime value array */
/**************************************************************************/
/* Index of info values within the info int integer array. */
/**************************************************************************/
......
......@@ -513,7 +513,6 @@ typedef struct _colres {
PVBLK Kdata; /* Column block of values */
char *Nulls; /* Column null value array */
int Type; /* Internal type */
int DBtype; /* Data type */
int Datasize; /* Overall data size */
int Ncol; /* Column number */
int Clen; /* Data individual internal size */
......@@ -545,7 +544,7 @@ int ExtractDate(char *, PDTP, int, int val[6]);
/* Allocate the result structure that will contain result data. */
/**************************************************************************/
PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
int *dbtype, int *buftyp, XFLD *fldtyp,
int *buftyp, XFLD *fldtyp,
unsigned int *length, bool blank, bool nonull);
/***********************************************************************/
......
......@@ -270,7 +270,7 @@ void ptrc(char const *fmt, ...)
/* Allocate the result structure that will contain result data. */
/**************************************************************************/
PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
int *dbtype, int *buftyp, XFLD *fldtyp,
int *buftyp, XFLD *fldtyp,
unsigned int *length, bool blank, bool nonull)
{
char cname[NAM_LEN+1];
......@@ -304,7 +304,6 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
crp->Length = length[i];
crp->Clen = GetTypeSize(crp->Type, length[i]);
crp->Prec = 0;
crp->DBtype = dbtype[i];
if (ids > 0) {
#if defined(XMSG)
......
......@@ -78,8 +78,6 @@ extern "C" int trace;
PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q,
int hdr, int mxr, bool info)
{
static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR,
DB_INT, DB_INT, DB_SHORT};
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
TYPE_INT, TYPE_INT, TYPE_SHORT};
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME,
......@@ -87,7 +85,7 @@ PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q,
static unsigned int length[] = {6, 6, 8, 10, 10, 6};
char *p, *colname[MAXCOL], dechar, filename[_MAX_PATH], buf[4096];
int i, imax, hmax, n, nerr, phase, blank, digit, dec, type;
int ncol = sizeof(dbtype) / sizeof(int);
int ncol = sizeof(buftyp) / sizeof(int);
int num_read = 0, num_max = 10000000; // Statistics
int len[MAXCOL], typ[MAXCOL], prc[MAXCOL];
FILE *infile;
......@@ -341,7 +339,7 @@ PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q,
/* Allocate the structures used to refer to the result set. */
/*********************************************************************/
qrp = PlgAllocResult(g, ncol, imax, IDS_COLUMNS + 3,
dbtype, buftyp, fldtyp, length, true, false);
buftyp, fldtyp, length, true, false);
qrp->Nblin = imax;
if (info)
......
This diff is collapsed.
......@@ -22,13 +22,12 @@ typedef class QRSCOL *PQRSCOL;
/***********************************************************************/
/* PIVOT table. */
/***********************************************************************/
//ass DllExport PIVOTDEF : public TABDEF {/* Logical table description */
class PIVOTDEF : public TABDEF { /* Logical table description */
//ass DllExport PIVOTDEF : public PRXDEF {/* Logical table description */
class PIVOTDEF : public PRXDEF { /* Logical table description */
friend class TDBPIVOT;
public:
// Constructor
PIVOTDEF(void) {Pseudo = 3;
Tabname = Tabsrc = Picol = Fncol = Function = NULL;}
PIVOTDEF(void);
// Implementation
virtual const char *GetType(void) {return "PIVOT";}
......@@ -39,26 +38,27 @@ class PIVOTDEF : public TABDEF { /* Logical table description */
protected:
// Members
char *Host; /* Host machine to use */
char *User; /* User logon info */
char *Pwd; /* Password logon info */
char *DB; /* Database to be used by server */
char *Tabname; /* Name of source table */
char *Host; /* Host machine to use */
char *User; /* User logon info */
char *Pwd; /* Password logon info */
char *DB; /* Database to be used by server */
char *Tabname; /* Name of source table */
char *Tabsrc; /* The source table SQL description */
char *Picol; /* The pivot column */
char *Picol; /* The pivot column */
char *Fncol; /* The function column */
char *Function; /* The function applying to group by */
bool GBdone; /* True if tabname as group by format */
int Port; /* MySQL port number */
bool Accept; /* TRUE if no match is accepted */
int Port; /* MySQL port number */
}; // end of PIVOTDEF
/***********************************************************************/
/* This is the class declaration for the PIVOT table. */
/***********************************************************************/
//ass DllExport TDBPIVOT : public TDBASE, public CSORT {
class TDBPIVOT : public TDBASE, public CSORT {
class TDBPIVOT : public TDBPRX {
friend class FNCCOL;
friend class SRCCOL;
//friend class SRCCOL;
public:
// Constructor
TDBPIVOT(PPIVOTDEF tdp);
......@@ -85,39 +85,41 @@ class TDBPIVOT : public TDBASE, public CSORT {
virtual void CloseDB(PGLOBAL g);
// The sorting function
virtual int Qcompare(int *, int *);
//virtual int Qcompare(int *, int *);
protected:
PQRYRES GetSourceTable(PGLOBAL g);
int MakePivotColumns(PGLOBAL g);
bool UpdateTableFields(PGLOBAL g, int n);
bool GetSourceTable(PGLOBAL g);
//int MakePivotColumns(PGLOBAL g);
//bool UpdateTableFields(PGLOBAL g, int n);
// Members
MYSQLC Myc; // MySQL connection class
PTDBQRS Tqrp; // To the source table result
char *Host; // Host machine to use
char *User; // User logon info
char *Pwd; // Password logon info
char *Database; // Database to be used by server
PQRYRES Qryp; // Points to Query result block
char *Tabname; // Name of source table
char *Tabsrc; // SQL of source table
char *Picol; // Pivot column name
char *Fncol; // Function column name
char *Function; // The function applying to group by
PQRSCOL Fcolp; // To the function column in source
PQRSCOL Xcolp; // To the pivot column in source
PCOLRES Xresp; // To the pivot result column
//PCOLRES To_Sort; // Saved Qryp To_Sort pointer
PVBLK Rblkp; // The value block of the pivot column
bool GBdone; // True when subtable is "Group by"
int Mult; // Multiplication factor
int Ncol; // The number of generated columns
int N; // The current table index
int M; // The occurence rank
int Port; // MySQL port number
BYTE FileStatus; // 0: First 1: Rows 2: End-of-File
BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip
//MYSQLC Myc; // MySQL connection class
//PTDBQRS Tqrp; // To the source table result
char *Host; // Host machine to use
char *User; // User logon info
char *Pwd; // Password logon info
char *Database; // Database to be used by server
//PQRYRES Qryp; // Points to Query result block
char *Tabname; // Name of source table
char *Tabsrc; // SQL of source table
char *Picol; // Pivot column name
char *Fncol; // Function column name
char *Function; // The function applying to group by
PCOL Fcolp; // To the function column in source
PCOL Xcolp; // To the pivot column in source
PCOL Dcolp; // To the dump column
//PCOLRES Xresp; // To the pivot result column
//PCOLRES To_Sort; // Saved Qryp To_Sort pointer
//PVBLK Rblkp; // The value block of the pivot column
bool GBdone; // True when subtable is "Group by"
bool Accept; // TRUE if no match is accepted
int Mult; // Multiplication factor
int Ncol; // The number of generated columns
int N; // The current table index
int M; // The occurence rank
int Port; // MySQL port number
BYTE FileStatus; // 0: First 1: Rows 2: End-of-File
BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip
}; // end of class TDBPIVOT
/***********************************************************************/
......@@ -127,30 +129,30 @@ class FNCCOL : public COLBLK {
friend class TDBPIVOT;
public:
// Constructor
FNCCOL(PCOL colp, PTDBPIVOT tdbp);
FNCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_FNC;}
// Methods
virtual void Reset(void) {}
bool InitColumn(PGLOBAL g, PVAL valp);
bool InitColumn(PGLOBAL g);
bool CompareColumn(void);
protected:
// Member
PVAL Hval; // The original value used to generate the header
PVAL Hval; // The value containing the header
PCOL Xcolp;
}; // end of class FNCCOL
/***********************************************************************/
/* Class SRCCOL: for other source columns. */
/***********************************************************************/
class SRCCOL : public COLBLK {
class SRCCOL : public PRXCOL {
friend class TDBPIVOT;
public:
// Constructors
//SRCCOL(PCOLDEF cdp, PTDBPIVOT tdbp, int n);
SRCCOL(PCOL cp, PTDBPIVOT tdbp, int n);
//SRCCOL(SRCCOL *colp, PTDB tdbp); // Constructor used in copy process
SRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int n);
// Implementation
virtual int GetAmType(void) {return TYPE_AM_SRC;}
......@@ -158,16 +160,15 @@ class SRCCOL : public COLBLK {
// Methods
virtual void Reset(void) {}
void SetColumn(void);
bool Init(PGLOBAL g, PTDBPIVOT tdbp);
bool CompareColumn(void);
bool Init(PGLOBAL g);
bool CompareLast(void);
protected:
// Default constructor not to be used
SRCCOL(void) {}
// Members
PQRSCOL Colp;
PVAL Cnval;
//PVAL Cnval;
}; // end of class SRCCOL
/***********************************************************************/
......
......@@ -121,10 +121,7 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db,
PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
const char *name, bool info)
{
static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR, DB_INT,
DB_INT, DB_SHORT, DB_SHORT, DB_SHORT,
DB_CHAR, DB_CHAR, DB_CHAR};
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT,
TYPE_STRING, TYPE_STRING, TYPE_STRING};
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
......@@ -132,7 +129,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
FLD_REM, FLD_NO, FLD_CHARSET};
static unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 256, 32, 32};
char *fld, *fmt;
int i, n, ncol = sizeof(dbtype) / sizeof(int);
int i, n, ncol = sizeof(buftyp) / sizeof(int);
int len, type, prec;
bool mysql;
TABLE_SHARE *s;
......@@ -156,7 +153,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
/* Allocate the structures used to refer to the result set. */
/**********************************************************************/
qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3,
dbtype, buftyp, fldtyp, length, true, true);
buftyp, fldtyp, length, true, true);
// Some columns must be renamed
for (i = 0, crp = qrp->Colresp; crp; crp = crp->Next)
......
......@@ -135,14 +135,12 @@ PWMIUT InitWMI(PGLOBAL g, char *nsp, char *classname)
/***********************************************************************/
PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info)
{
static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR,
DB_INT, DB_INT, DB_SHORT};
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
TYPE_INT, TYPE_INT, TYPE_SHORT};
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME,
FLD_PREC, FLD_LENGTH, FLD_SCALE};
static unsigned int len, length[] = {0, 6, 8, 10, 10, 6};
int i = 0, n = 0, ncol = sizeof(dbtype) / sizeof(int);
int i = 0, n = 0, ncol = sizeof(buftyp) / sizeof(int);
int lng, typ, prec;
LONG low, upp;
BSTR propname;
......@@ -213,7 +211,7 @@ PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info)
/* Allocate the structures used to refer to the result set. */
/*********************************************************************/
qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3,
dbtype, buftyp, fldtyp, length, true, true);
buftyp, fldtyp, length, true, true);
if (info)
return qrp;
......
......@@ -66,7 +66,6 @@ extern "C" int trace;
/***********************************************************************/
XCLDEF::XCLDEF(void)
{
Pseudo = 3;
Xcol = NULL;
Sep = ',';
Mult = 10;
......
......@@ -154,46 +154,6 @@ int GetTypeSize(int type, int len)
return len;
} // end of GetTypeSize
/***********************************************************************/
/* GetPLGType: returns the PlugDB type corresponding to a DB type. */
/***********************************************************************/
int GetPLGType(int type)
{
int tp;
switch (type) {
case DB_CHAR:
case DB_STRING: tp = TYPE_STRING; break;
case DB_SHORT: tp = TYPE_SHORT; break;
case DB_INT: tp = TYPE_INT; break;
case DB_DOUBLE: tp = TYPE_FLOAT; break;
case DB_DATE: tp = TYPE_DATE; break;
default: tp = TYPE_ERROR;
} // endswitch type
return tp;
} // end of GetPLGType
/***********************************************************************/
/* GetDBType: returns the DB type corresponding to a PlugDB type. */
/***********************************************************************/
int GetDBType(int type)
{
int tp;
switch (type) {
case TYPE_STRING: tp = DB_CHAR; break;
case TYPE_SHORT: tp = DB_SHORT; break;
case TYPE_INT: tp = DB_INT; break;
case TYPE_BIGINT:
case TYPE_FLOAT: tp = DB_DOUBLE; break;
case TYPE_DATE: tp = DB_DATE; break;
default: tp = DB_ERROR;
} // endswitch type
return tp;
} // end of GetPLGType
/***********************************************************************/
/* GetFormatType: returns the FORMAT character(s) according to type. */
/***********************************************************************/
......@@ -1143,10 +1103,13 @@ bool TYPVAL<PSZ>::IsEqual(PVAL vp, bool chktype)
return false;
else if (Null || vp->IsNull())
return false;
else if (Ci || vp->IsCi())
return !stricmp(Strp, vp->GetCharValue());
char buf[32];
if (Ci || vp->IsCi())
return !stricmp(Strp, vp->GetCharString(buf));
else // (!Ci)
return !strcmp(Strp, vp->GetCharValue());
return !strcmp(Strp, vp->GetCharString(buf));
} // end of IsEqual
......
......@@ -38,7 +38,6 @@ typedef struct _datpar *PDTP; // For DTVAL
/***********************************************************************/
/* Utilities used to test types and to allocated values. */
/***********************************************************************/
int GetPLGType(int);
PVAL AllocateValue(PGLOBAL, void *, short);
// Exported functions
......@@ -50,7 +49,6 @@ DllExport int TranslateSQLType(int stp, int prec, int& len);
#endif
DllExport char *GetFormatType(int);
DllExport int GetFormatType(char);
DllExport int GetDBType(int);
DllExport bool IsTypeChar(int type);
DllExport bool IsTypeNum(int type);
DllExport int ConvertType(int, int, CONV, bool match = false);
......@@ -82,12 +80,12 @@ class DllExport VALUE : public BLOCK {
virtual longlong GetBigintValue(void) = 0;
virtual double GetFloatValue(void) = 0;
virtual void *GetTo_Val(void) = 0;
virtual void SetPrec(int prec) {Prec = prec;}
bool IsNull(void) {return Null;}
void SetNull(bool b) {Null = b;}
void SetNullable(bool b) {Nullable = b;}
int GetType(void) {return Type;}
int GetClen(void) {return Clen;}
void SetPrec(int prec) {Prec = prec;}
void SetGlobal(PGLOBAL g) {Global = g;}
// Methods
......@@ -217,6 +215,7 @@ class DllExport TYPVAL<PSZ>: public VALUE {
virtual longlong GetBigintValue(void) {return atoll(Strp);}
virtual double GetFloatValue(void) {return atof(Strp);}
virtual void *GetTo_Val(void) {return Strp;}
virtual void SetPrec(int prec) {Ci = prec != 0;}
// Methods
virtual bool SetValue_pval(PVAL valp, bool chktype);
......
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