1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

- Commit merge files

modified:
  storage/connect/catalog.h
  storage/connect/filamvct.cpp
  storage/connect/filamzip.cpp
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h
  storage/connect/mycat.cc
  storage/connect/mycat.h
  storage/connect/myconn.cpp
  storage/connect/mysql-test/connect/r/xml.result
  storage/connect/plgdbutl.cpp
  storage/connect/reldef.cpp
  storage/connect/reldef.h
  storage/connect/tabdos.cpp
  storage/connect/tabfmt.cpp
  storage/connect/tabmul.cpp
  storage/connect/tabmysql.cpp
  storage/connect/taboccur.cpp
  storage/connect/tabodbc.cpp
  storage/connect/tabpivot.cpp
  storage/connect/tabpivot.h
  storage/connect/tabsys.cpp
  storage/connect/tabtbl.cpp
  storage/connect/tabutil.cpp
  storage/connect/tabvct.cpp
  storage/connect/tabwmi.cpp
  storage/connect/tabxcl.cpp
  storage/connect/tabxml.cpp
  storage/connect/xindex.cpp
This commit is contained in:
Olivier Bertrand
2014-04-19 16:41:25 +02:00
28 changed files with 7802 additions and 7691 deletions

View File

@@ -1,122 +1,112 @@
/*************** Catalog H Declares Source Code File (.H) **************/ /*************** Catalog H Declares Source Code File (.H) **************/
/* Name: CATALOG.H Version 3.2 */ /* Name: CATALOG.H Version 3.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2000-2012 */
/* */ /* */
/* This file contains the CATALOG PlugDB classes definitions. */ /* This file contains the CATALOG PlugDB classes definitions. */
/***********************************************************************/ /***********************************************************************/
#ifndef __CATALOG__H #ifndef __CATALOG__H
#define __CATALOG__H #define __CATALOG__H
#include "block.h" #include "block.h"
/***********************************************************************/ /***********************************************************************/
/* Defines the length of a buffer to contain entire table section. */ /* Defines the length of a buffer to contain entire table section. */
/***********************************************************************/ /***********************************************************************/
#define PLG_MAX_PATH 144 /* Must be the same across systems */ #define PLG_MAX_PATH 144 /* Must be the same across systems */
#define PLG_BUFF_LEN 100 /* Number of lines in binary file buffer */ #define PLG_BUFF_LEN 100 /* Number of lines in binary file buffer */
//typedef class INDEXDEF *PIXDEF; //typedef class INDEXDEF *PIXDEF;
/***********************************************************************/ /***********************************************************************/
/* Defines the structure used to enumerate tables or views. */ /* Defines the structure used to enumerate tables or views. */
/***********************************************************************/ /***********************************************************************/
typedef struct _curtab { typedef struct _curtab {
PRELDEF CurTdb; PRELDEF CurTdb;
char *Curp; char *Curp;
char *Tabpat; char *Tabpat;
bool Ispat; bool Ispat;
bool NoView; bool NoView;
int Nt; int Nt;
char *Type[16]; char *Type[16];
} CURTAB, *PCURTAB; } CURTAB, *PCURTAB;
/***********************************************************************/ /***********************************************************************/
/* Defines the structure used to get column catalog info. */ /* Defines the structure used to get column catalog info. */
/***********************************************************************/ /***********************************************************************/
typedef struct _colinfo { typedef struct _colinfo {
char *Name; char *Name;
int Type; int Type;
int Offset; int Offset;
int Length; int Length;
int Key; int Key;
int Precision; int Precision;
int Scale; int Scale;
int Opt; int Opt;
int Freq; int Freq;
char *Remark; char *Remark;
char *Datefmt; char *Datefmt;
char *Fieldfmt; char *Fieldfmt;
ushort Flags; // Used by MariaDB CONNECT handlers ushort Flags; // Used by MariaDB CONNECT handlers
} COLINFO, *PCOLINFO; } COLINFO, *PCOLINFO;
/***********************************************************************/ /***********************************************************************/
/* CATALOG: base class for catalog classes. */ /* CATALOG: base class for catalog classes. */
/***********************************************************************/ /***********************************************************************/
class DllExport CATALOG { class DllExport CATALOG {
friend class RELDEF; friend class RELDEF;
friend class TABDEF; friend class TABDEF;
friend class DIRDEF; friend class DIRDEF;
friend class OEMDEF; friend class OEMDEF;
public: public:
CATALOG(void); // Constructor CATALOG(void); // Constructor
virtual ~CATALOG() { } // Make -Wdelete-non-virtual-dtor happy virtual ~CATALOG() { } // Make -Wdelete-non-virtual-dtor happy
// Implementation // Implementation
int GetCblen(void) {return Cblen;} int GetCblen(void) {return Cblen;}
bool GetDefHuge(void) {return DefHuge;} bool GetDefHuge(void) {return DefHuge;}
void SetDefHuge(bool b) {DefHuge = b;} void SetDefHuge(bool b) {DefHuge = b;}
char *GetCbuf(void) {return Cbuf;} char *GetCbuf(void) {return Cbuf;}
char *GetDataPath(void) {return (char*)DataPath;} char *GetDataPath(void) {return (char*)DataPath;}
// Methods // Methods
virtual void Reset(void) {} virtual void Reset(void) {}
virtual void SetDataPath(PGLOBAL g, const char *path) {} virtual void SetDataPath(PGLOBAL g, const char *path) {}
virtual bool GetBoolCatInfo(PSZ what, bool bdef) {return bdef;} virtual bool CheckName(PGLOBAL g, char *name) {return true;}
virtual bool SetIntCatInfo(PSZ what, int ival) {return false;} virtual bool ClearName(PGLOBAL g, PSZ name) {return true;}
virtual int GetIntCatInfo(PSZ what, int idef) {return idef;} virtual PRELDEF MakeOneTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
virtual int GetSizeCatInfo(PSZ what, PSZ sdef) {return 0;} virtual PRELDEF GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;}
virtual int GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size) virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type,
{strncpy(buf, sdef, size); return size;} PRELDEF *prp = NULL) {return NULL;}
virtual char *GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;}
{return sdef;} virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;}
virtual int GetColCatInfo(PGLOBAL g, PTABDEF defp) {return -1;} virtual bool TestCond(PGLOBAL g, const char *name, const char *type)
virtual bool GetIndexInfo(PGLOBAL g, PTABDEF defp) {return true;} {return true;}
virtual bool CheckName(PGLOBAL g, char *name) {return true;} virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;}
virtual bool ClearName(PGLOBAL g, PSZ name) {return true;} virtual PTDB GetTable(PGLOBAL g, PTABLE tablep,
virtual PRELDEF MakeOneTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} MODE mode = MODE_READ, LPCSTR type = NULL)
virtual PRELDEF GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;} {return NULL;}
virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type, virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {}
PRELDEF *prp = NULL) {return NULL;} virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer,
virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;} int maxbuf, int info[]) {}
virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;} virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer,
virtual bool TestCond(PGLOBAL g, const char *name, const char *type) int maxbuf, int info[]) {}
{return true;} virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname,
virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;} char *buffer, int maxbuf, int info[]) {return NULL;}
virtual PTDB GetTable(PGLOBAL g, PTABLE tablep, virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;}
MODE mode = MODE_READ, LPCSTR type = NULL) virtual void ClearDB(PGLOBAL g) {}
{return NULL;}
virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {} protected:
virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer, virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;}
int maxbuf, int info[]) {} virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer,
int maxbuf, int info[]) {} // Members
virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname, char *Cbuf; /* Buffer used for col section */
char *buffer, int maxbuf, int info[]) {return NULL;} int Cblen; /* Length of suballoc. buffer */
virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;} CURTAB Ctb; /* Used to enumerate tables */
virtual void ClearDB(PGLOBAL g) {} bool DefHuge; /* true: tables default to huge */
LPCSTR DataPath; /* Is the Path of DB data dir */
protected: }; // end of class CATALOG
virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;}
virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} #endif // __CATALOG__H
// Members
char *Cbuf; /* Buffer used for col section */
int Cblen; /* Length of suballoc. buffer */
CURTAB Ctb; /* Used to enumerate tables */
bool DefHuge; /* true: tables default to huge */
LPCSTR DataPath; /* Is the Path of DB data dir */
}; // end of class CATALOG
#endif // __CATALOG__H

File diff suppressed because it is too large Load Diff

View File

@@ -652,13 +652,12 @@ int ZBKFAM::DeleteRecords(PGLOBAL g, int irc)
if (irc == RC_EF) { if (irc == RC_EF) {
LPCSTR name = Tdbp->GetName(); LPCSTR name = Tdbp->GetName();
PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
PCATLG cat = PlgGetCatalog(g);
defp->SetBlock(0); defp->SetBlock(0);
defp->SetLast(Nrec); defp->SetLast(Nrec);
if (!cat->SetIntCatInfo("Blocks", 0) || if (!defp->SetIntCatInfo("Blocks", 0) ||
!cat->SetIntCatInfo("Last", 0)) { !defp->SetIntCatInfo("Last", 0)) {
sprintf(g->Message, MSG(UPDATE_ERROR), "Header"); sprintf(g->Message, MSG(UPDATE_ERROR), "Header");
return RC_FX; return RC_FX;
} else } else
@@ -677,7 +676,6 @@ void ZBKFAM::CloseTableFile(PGLOBAL g)
int rc = RC_OK; int rc = RC_OK;
if (Tdbp->GetMode() == MODE_INSERT) { if (Tdbp->GetMode() == MODE_INSERT) {
PCATLG cat = PlgGetCatalog(g);
LPCSTR name = Tdbp->GetName(); LPCSTR name = Tdbp->GetName();
PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
@@ -696,8 +694,8 @@ void ZBKFAM::CloseTableFile(PGLOBAL g)
if (rc != RC_FX) { if (rc != RC_FX) {
defp->SetBlock(Block); defp->SetBlock(Block);
defp->SetLast(Last); defp->SetLast(Last);
cat->SetIntCatInfo("Blocks", Block); defp->SetIntCatInfo("Blocks", Block);
cat->SetIntCatInfo("Last", Last); defp->SetIntCatInfo("Last", Last);
} // endif } // endif
gzclose(Zfile); gzclose(Zfile);
@@ -1335,7 +1333,6 @@ void ZLBFAM::CloseTableFile(PGLOBAL g)
int rc = RC_OK; int rc = RC_OK;
if (Tdbp->GetMode() == MODE_INSERT) { if (Tdbp->GetMode() == MODE_INSERT) {
PCATLG cat = PlgGetCatalog(g);
LPCSTR name = Tdbp->GetName(); LPCSTR name = Tdbp->GetName();
PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
@@ -1355,8 +1352,8 @@ void ZLBFAM::CloseTableFile(PGLOBAL g)
if (rc != RC_FX) { if (rc != RC_FX) {
defp->SetBlock(Block); defp->SetBlock(Block);
defp->SetLast(Last); defp->SetLast(Last);
cat->SetIntCatInfo("Blocks", Block); defp->SetIntCatInfo("Blocks", Block);
cat->SetIntCatInfo("Last", Last); defp->SetIntCatInfo("Last", Last);
} // endif } // endif
fclose(Stream); fclose(Stream);

View File

@@ -637,10 +637,16 @@ static PGLOBAL GetPlug(THD *thd, PCONNECT& lxp)
/****************************************************************************/ /****************************************************************************/
TABTYPE ha_connect::GetRealType(PTOS pos) TABTYPE ha_connect::GetRealType(PTOS pos)
{ {
TABTYPE type= GetTypeID(pos->type); TABTYPE type;
if (pos || (pos= GetTableOptionStruct(table))) {
type= GetTypeID(pos->type);
if (type == TAB_UNDEF) if (type == TAB_UNDEF)
type= pos->srcdef ? TAB_MYSQL : pos->tabname ? TAB_PRX : TAB_DOS; type= pos->srcdef ? TAB_MYSQL : pos->tabname ? TAB_PRX : TAB_DOS;
} else
type= TAB_UNDEF;
return type; return type;
} // end of GetRealType } // end of GetRealType
@@ -653,8 +659,8 @@ ulonglong ha_connect::table_flags() const
{ {
ulonglong flags= HA_CAN_VIRTUAL_COLUMNS | HA_REC_NOT_IN_SEQ | ulonglong flags= HA_CAN_VIRTUAL_COLUMNS | HA_REC_NOT_IN_SEQ |
HA_NO_AUTO_INCREMENT | HA_NO_PREFIX_CHAR_KEYS | HA_NO_AUTO_INCREMENT | HA_NO_PREFIX_CHAR_KEYS |
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE | // HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
HA_PARTIAL_COLUMN_READ | HA_PARTIAL_COLUMN_READ | HA_FILE_BASED |
// HA_NULL_IN_KEY | not implemented yet // HA_NULL_IN_KEY | not implemented yet
// HA_FAST_KEY_READ | causes error when sorting (???) // HA_FAST_KEY_READ | causes error when sorting (???)
HA_NO_TRANSACTIONS | HA_DUPLICATE_KEY_NOT_IN_ORDER | HA_NO_TRANSACTIONS | HA_DUPLICATE_KEY_NOT_IN_ORDER |
@@ -1433,8 +1439,9 @@ int ha_connect::MakeRecord(char *buf)
} // endif colp } // endif colp
value= colp->GetValue(); value= colp->GetValue();
p= NULL;
// All this could be better optimized // All this was better optimized
if (!value->IsNull()) { if (!value->IsNull()) {
switch (value->GetType()) { switch (value->GetType()) {
case TYPE_DATE: case TYPE_DATE:
@@ -1459,39 +1466,37 @@ int ha_connect::MakeRecord(char *buf)
// Get date in the format required by MySQL fields // Get date in the format required by MySQL fields
value->FormatValue(sdvalout, fmt); value->FormatValue(sdvalout, fmt);
p= sdvalout->GetCharValue(); p= sdvalout->GetCharValue();
break; rc= fp->store(p, strlen(p), charset, CHECK_FIELD_WARN);
case TYPE_DOUBLE:
p= NULL;
break; break;
case TYPE_STRING: case TYPE_STRING:
// Passthru case TYPE_DECIM:
default:
p= value->GetCharString(val); p= value->GetCharString(val);
charset= tdbp->data_charset();
rc= fp->store(p, strlen(p), charset, CHECK_FIELD_WARN);
break;
case TYPE_DOUBLE:
rc= fp->store(value->GetFloatValue());
break;
default:
rc= fp->store(value->GetBigintValue(), value->IsUnsigned());
break; break;
} // endswitch Type } // endswitch Type
if (p) { // Store functions returns 1 on overflow and -1 on fatal error
if (fp->store(p, strlen(p), charset, CHECK_FIELD_WARN)) { if (rc > 0) {
// Avoid "error" on null fields char buf[128];
if (value->GetIntValue()) THD *thd= ha_thd();
rc= HA_ERR_WRONG_IN_RECORD;
DBUG_PRINT("MakeRecord", ("%s", p)); sprintf(buf, "Out of range value %s for column '%s' at row %ld",
} // endif store value->GetCharString(val),
fp->field_name,
thd->get_stmt_da()->current_row_for_warning());
} else push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, buf);
if (fp->store(value->GetFloatValue())) { DBUG_PRINT("MakeRecord", ("%s", buf));
// rc= HA_ERR_WRONG_IN_RECORD; a Warning was ignored rc= 0;
char buf[128]; } else if (rc < 0)
THD *thd= ha_thd(); rc= HA_ERR_WRONG_IN_RECORD;
sprintf(buf, "Out of range value for column '%s' at row %ld",
fp->field_name,
thd->get_stmt_da()->current_row_for_warning());
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, buf);
DBUG_PRINT("MakeRecord", ("%s", value->GetCharString(val)));
} // endif store
fp->set_notnull(); fp->set_notnull();
} else } else
@@ -2670,7 +2675,6 @@ int ha_connect::index_next(uchar *buf)
} // end of index_next } // end of index_next
#ifdef NOT_USED
/** /**
@brief @brief
Used to read backwards through the index. Used to read backwards through the index.
@@ -2678,9 +2682,15 @@ int ha_connect::index_next(uchar *buf)
int ha_connect::index_prev(uchar *buf) int ha_connect::index_prev(uchar *buf)
{ {
DBUG_ENTER("ha_connect::index_prev"); DBUG_ENTER("ha_connect::index_prev");
DBUG_RETURN(HA_ERR_WRONG_COMMAND); int rc;
}
#endif // NOT_USED if (indexing > 0) {
rc= ReadIndexed(buf, OP_PREV);
} else
rc= HA_ERR_WRONG_COMMAND;
DBUG_RETURN(rc);
} // end of index_prev
/** /**
@@ -3017,12 +3027,21 @@ int ha_connect::info(uint flag)
if (!valid_info) { if (!valid_info) {
// tdbp must be available to get updated info // tdbp must be available to get updated info
if (xp->CheckQuery(valid_query_id) || !tdbp) { if (xp->CheckQuery(valid_query_id) || !tdbp) {
PDBUSER dup= PlgGetUser(g);
PCATLG cat= (dup) ? dup->Catalog : NULL;
if (xmod == MODE_ANY || xmod == MODE_ALTER) { if (xmod == MODE_ANY || xmod == MODE_ALTER) {
// Pure info, not a query // Pure info, not a query
pure= true; pure= true;
xp->CheckCleanup(); xp->CheckCleanup();
} // endif xmod } // endif xmod
// This is necessary for getting file length
if (cat && table)
cat->SetDataPath(g, table->s->db.str);
else
return HA_ERR_INTERNAL_ERROR; // Should never happen
tdbp= GetTDB(g); tdbp= GetTDB(g);
} // endif tdbp } // endif tdbp
@@ -4330,8 +4349,8 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
char v, spc= ',', qch= 0; char v, spc= ',', qch= 0;
const char *fncn= "?"; const char *fncn= "?";
const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src; const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src;
const char *col, *ocl, *rnk, *pic, *fcl; const char *col, *ocl, *rnk, *pic, *fcl, *skc;
char *tab, *dsn, *shm; char *tab, *dsn, *shm;
#if defined(WIN32) #if defined(WIN32)
char *nsp= NULL, *cls= NULL; char *nsp= NULL, *cls= NULL;
#endif // WIN32 #endif // WIN32
@@ -4360,7 +4379,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
if (!g) if (!g)
return HA_ERR_INTERNAL_ERROR; return HA_ERR_INTERNAL_ERROR;
user= host= pwd= tbl= src= col= ocl= pic= fcl= rnk= dsn= NULL; user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= dsn= NULL;
// Get the useful create options // Get the useful create options
ttp= GetTypeID(topt->type); ttp= GetTypeID(topt->type);
@@ -4386,6 +4405,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
ocl= GetListOption(g, "occurcol", topt->oplist, NULL); ocl= GetListOption(g, "occurcol", topt->oplist, NULL);
pic= GetListOption(g, "pivotcol", topt->oplist, NULL); pic= GetListOption(g, "pivotcol", topt->oplist, NULL);
fcl= GetListOption(g, "fnccol", topt->oplist, NULL); fcl= GetListOption(g, "fnccol", topt->oplist, NULL);
skc= GetListOption(g, "skipcol", topt->oplist, NULL);
rnk= GetListOption(g, "rankcol", topt->oplist, NULL); rnk= GetListOption(g, "rankcol", topt->oplist, NULL);
pwd= GetListOption(g, "password", topt->oplist); pwd= GetListOption(g, "password", topt->oplist);
#if defined(WIN32) #if defined(WIN32)
@@ -4652,7 +4672,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
break; break;
case TAB_PIVOT: case TAB_PIVOT:
qrp= PivotColumns(g, tab, src, pic, fcl, host, db, user, pwd, port); qrp= PivotColumns(g, tab, src, pic, fcl, skc, host, db, user, pwd, port);
break; break;
case TAB_OEM: case TAB_OEM:
qrp= OEMColumns(g, topt, tab, (char*)db, fnc == FNC_COL); qrp= OEMColumns(g, topt, tab, (char*)db, fnc == FNC_COL);
@@ -5236,7 +5256,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
// Get the index definitions // Get the index definitions
if (xdp= GetIndexInfo()) { if (xdp= GetIndexInfo()) {
if (IsTypeIndexable(type)) { if (GetIndexType(type) == 1) {
PDBUSER dup= PlgGetUser(g); PDBUSER dup= PlgGetUser(g);
PCATLG cat= (dup) ? dup->Catalog : NULL; PCATLG cat= (dup) ? dup->Catalog : NULL;
@@ -5251,8 +5271,8 @@ int ha_connect::create(const char *name, TABLE *table_arg,
CloseTable(g); CloseTable(g);
} // endif cat } // endif cat
} else { } else if (!GetIndexType(type)) {
sprintf(g->Message, "Table type %s is not indexable", options->type); sprintf(g->Message, "Table type %s is not indexable", options->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_UNSUPPORTED; rc= HA_ERR_UNSUPPORTED;
@@ -5546,35 +5566,36 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
if (ha_alter_info->handler_flags & index_operations || if (ha_alter_info->handler_flags & index_operations ||
!SameString(altered_table, "optname") || !SameString(altered_table, "optname") ||
!SameBool(altered_table, "sepindex")) { !SameBool(altered_table, "sepindex")) {
if (!IsTypeIndexable(type)) { if (GetIndexType(type) == 1) {
g->Xchk= new(g) XCHK;
PCHK xcp= (PCHK)g->Xchk;
xcp->oldpix= GetIndexInfo(table->s);
xcp->newpix= GetIndexInfo(altered_table->s);
xcp->oldsep= GetBooleanOption("sepindex", false);
xcp->oldsep= xcp->SetName(g, GetStringOption("optname"));
tshp= altered_table->s;
xcp->newsep= GetBooleanOption("sepindex", false);
xcp->newsep= xcp->SetName(g, GetStringOption("optname"));
tshp= NULL;
if (xtrace && g->Xchk)
htrc(
"oldsep=%d newsep=%d oldopn=%s newopn=%s oldpix=%p newpix=%p\n",
xcp->oldsep, xcp->newsep,
SVP(xcp->oldopn), SVP(xcp->newopn),
xcp->oldpix, xcp->newpix);
if (sqlcom == SQLCOM_ALTER_TABLE)
idx= true;
else
DBUG_RETURN(HA_ALTER_INPLACE_EXCLUSIVE_LOCK);
} else if (!GetIndexType(type)) {
sprintf(g->Message, "Table type %s is not indexable", oldopt->type); sprintf(g->Message, "Table type %s is not indexable", oldopt->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
DBUG_RETURN(HA_ALTER_ERROR); DBUG_RETURN(HA_ALTER_ERROR);
} // endif Indexable } // endif index type
g->Xchk= new(g) XCHK;
PCHK xcp= (PCHK)g->Xchk;
xcp->oldpix= GetIndexInfo(table->s);
xcp->newpix= GetIndexInfo(altered_table->s);
xcp->oldsep= GetBooleanOption("sepindex", false);
xcp->oldsep= xcp->SetName(g, GetStringOption("optname"));
tshp= altered_table->s;
xcp->newsep= GetBooleanOption("sepindex", false);
xcp->newsep= xcp->SetName(g, GetStringOption("optname"));
tshp= NULL;
if (xtrace && g->Xchk)
htrc(
"oldsep=%d newsep=%d oldopn=%s newopn=%s oldpix=%p newpix=%p\n",
xcp->oldsep, xcp->newsep,
SVP(xcp->oldopn), SVP(xcp->newopn),
xcp->oldpix, xcp->newpix);
if (sqlcom == SQLCOM_ALTER_TABLE)
idx= true;
else
DBUG_RETURN(HA_ALTER_INPLACE_EXCLUSIVE_LOCK);
} // endif index operation } // endif index operation

View File

@@ -180,7 +180,7 @@ public:
// CONNECT Implementation // CONNECT Implementation
static bool connect_init(void); static bool connect_init(void);
static bool connect_end(void); static bool connect_end(void);
TABTYPE GetRealType(PTOS pos); TABTYPE GetRealType(PTOS pos= NULL);
char *GetStringOption(char *opname, char *sdef= NULL); char *GetStringOption(char *opname, char *sdef= NULL);
PTOS GetTableOptionStruct(TABLE *table_arg); PTOS GetTableOptionStruct(TABLE *table_arg);
bool GetBooleanOption(char *opname, bool bdef); bool GetBooleanOption(char *opname, bool bdef);
@@ -256,8 +256,8 @@ public:
*/ */
ulong index_flags(uint inx, uint part, bool all_parts) const ulong index_flags(uint inx, uint part, bool all_parts) const
{ {
return HA_READ_NEXT | HA_READ_RANGE | HA_READ_ORDER return HA_READ_NEXT | HA_READ_RANGE | HA_READ_ORDER |
| HA_KEYREAD_ONLY | HA_KEY_SCAN_NOT_ROR; HA_READ_PREV | HA_KEYREAD_ONLY | HA_KEY_SCAN_NOT_ROR;
} // end of index_flags } // end of index_flags
/** @brief /** @brief
@@ -421,7 +421,7 @@ PFIL CondFilter(PGLOBAL g, Item *cond);
We implement this in ha_connect.cc. It's not an obligatory method; We implement this in ha_connect.cc. It's not an obligatory method;
skip it and and MySQL will treat it as not implemented. skip it and and MySQL will treat it as not implemented.
*/ */
//int index_prev(uchar *buf); int index_prev(uchar *buf);
/** @brief /** @brief
We implement this in ha_connect.cc. It's not an obligatory method; We implement this in ha_connect.cc. It's not an obligatory method;

View File

@@ -211,7 +211,7 @@ bool IsTypeNullable(TABTYPE type)
} // end of IsTypeNullable } // end of IsTypeNullable
/***********************************************************************/ /***********************************************************************/
/* Return true for table types with fix length records. */ /* Return true for indexable table by XINDEX. */
/***********************************************************************/ /***********************************************************************/
bool IsTypeFixed(TABTYPE type) bool IsTypeFixed(TABTYPE type)
{ {
@@ -233,7 +233,7 @@ bool IsTypeFixed(TABTYPE type)
} // end of IsTypeFixed } // end of IsTypeFixed
/***********************************************************************/ /***********************************************************************/
/* Return true for table types with fix length records. */ /* Return true for table indexable by XINDEX. */
/***********************************************************************/ /***********************************************************************/
bool IsTypeIndexable(TABTYPE type) bool IsTypeIndexable(TABTYPE type)
{ {
@@ -257,6 +257,35 @@ bool IsTypeIndexable(TABTYPE type)
return idx; return idx;
} // end of IsTypeIndexable } // end of IsTypeIndexable
/***********************************************************************/
/* Return index type: 0 NO, 1 XINDEX, 2 REMOTE. */
/***********************************************************************/
int GetIndexType(TABTYPE type)
{
int xtyp;
switch (type) {
case TAB_DOS:
case TAB_CSV:
case TAB_FMT:
case TAB_FIX:
case TAB_BIN:
case TAB_VEC:
case TAB_DBF:
xtyp= 1;
break;
case TAB_MYSQL:
case TAB_ODBC:
// xtyp= 2; Remote indexes not implemented yet
// break;
default:
xtyp= 0;
break;
} // endswitch type
return xtyp;
} // end of GetIndexType
/***********************************************************************/ /***********************************************************************/
/* Get a unique enum catalog function ID. */ /* Get a unique enum catalog function ID. */
/***********************************************************************/ /***********************************************************************/
@@ -434,281 +463,6 @@ void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path)
} // end of SetDataPath } // end of SetDataPath
/***********************************************************************/
/* This function sets an integer MYCAT information. */
/***********************************************************************/
bool MYCAT::SetIntCatInfo(PSZ what, int n)
{
return Hc->SetIntegerOption(what, n);
} // end of SetIntCatInfo
/***********************************************************************/
/* This function returns integer MYCAT information. */
/***********************************************************************/
int MYCAT::GetIntCatInfo(PSZ what, int idef)
{
int n= Hc->GetIntegerOption(what);
return (n == NO_IVAL) ? idef : n;
} // end of GetIntCatInfo
/***********************************************************************/
/* This function returns Boolean MYCAT information. */
/***********************************************************************/
bool MYCAT::GetBoolCatInfo(PSZ what, bool bdef)
{
bool b= Hc->GetBooleanOption(what, bdef);
return b;
} // end of GetBoolCatInfo
/***********************************************************************/
/* This function returns size catalog information. */
/***********************************************************************/
int MYCAT::GetSizeCatInfo(PSZ what, PSZ sdef)
{
char * s, c;
int i, n= 0;
if (!(s= Hc->GetStringOption(what)))
s= sdef;
if ((i= sscanf(s, " %d %c ", &n, &c)) == 2)
switch (toupper(c)) {
case 'M':
n *= 1024;
case 'K':
n *= 1024;
} // endswitch c
return n;
} // end of GetSizeCatInfo
/***********************************************************************/
/* This function sets char MYCAT information in buf. */
/***********************************************************************/
int MYCAT::GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size)
{
char *s= Hc->GetStringOption(what);
strncpy(buf, ((s) ? s : sdef), size);
return size;
} // end of GetCharCatInfo
/***********************************************************************/
/* This function returns string MYCAT information. */
/* Default parameter is "*" to get the handler default. */
/***********************************************************************/
char *MYCAT::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
{
char *sval= NULL, *s= Hc->GetStringOption(what, sdef);
if (s) {
sval= (char*)PlugSubAlloc(g, NULL, strlen(s) + 1);
strcpy(sval, s);
} else if (!stricmp(what, "filename")) {
// Return default file name
char *ftype= Hc->GetStringOption("Type", "*");
int i, n;
if (IsFileType(GetTypeID(ftype))) {
sval= (char*)PlugSubAlloc(g, NULL, strlen(Hc->GetTableName()) + 12);
strcat(strcpy(sval, Hc->GetTableName()), ".");
n= strlen(sval);
// Fold ftype to lower case
for (i= 0; i < 12; i++)
if (!ftype[i]) {
sval[n+i]= 0;
break;
} else
sval[n+i]= tolower(ftype[i]);
} // endif FileType
} // endif s
return sval;
} // end of GetStringCatInfo
/***********************************************************************/
/* This function returns column MYCAT information. */
/***********************************************************************/
int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp)
{
char *type= GetStringCatInfo(g, "Type", "*");
int i, loff, poff, nof, nlg;
void *field= NULL;
TABTYPE tc;
PCOLDEF cdp, lcdp= NULL, tocols= NULL;
PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO));
memset(pcf, 0, sizeof(COLINFO));
// Get a unique char identifier for type
tc= (defp->Catfunc == FNC_NO) ? GetTypeID(type) : TAB_PRX;
// Take care of the column definitions
i= poff= nof= nlg= 0;
// Offsets of HTML and DIR tables start from 0, DBF at 1
loff= (tc == TAB_DBF) ? 1 : (tc == TAB_XML || tc == TAB_DIR) ? -1 : 0;
while (true) {
// Default Offset depends on table type
switch (tc) {
case TAB_DOS:
case TAB_FIX:
case TAB_BIN:
case TAB_VEC:
case TAB_DBF:
poff= loff + nof; // Default next offset
nlg= max(nlg, poff); // Default lrecl
break;
case TAB_CSV:
case TAB_FMT:
nlg+= nof;
case TAB_DIR:
case TAB_XML:
poff= loff + 1;
break;
case TAB_INI:
case TAB_MAC:
case TAB_TBL:
case TAB_XCL:
case TAB_OCCUR:
case TAB_PRX:
case TAB_OEM:
poff = 0; // Offset represents an independant flag
break;
default: // VCT PLG ODBC MYSQL WMI...
poff = 0; // NA
break;
} // endswitch tc
// do {
field= Hc->GetColumnOption(g, field, pcf);
// } while (field && (*pcf->Name =='*' /*|| pcf->Flags & U_VIRTUAL*/));
if (tc == TAB_DBF && pcf->Type == TYPE_DATE && !pcf->Datefmt) {
// DBF date format defaults to 'YYYMMDD'
pcf->Datefmt= "YYYYMMDD";
pcf->Length= 8;
} // endif tc
if (!field)
break;
// Allocate the column description block
cdp= new(g) COLDEF;
if ((nof= cdp->Define(g, NULL, pcf, poff)) < 0)
return -1; // Error, probably unhandled type
else if (nof)
loff= cdp->GetOffset();
switch (tc) {
case TAB_VEC:
cdp->SetOffset(0); // Not to have shift
case TAB_BIN:
// BIN/VEC are packed by default
if (nof)
// Field width is the internal representation width
// that can also depend on the column format
switch (cdp->Fmt ? *cdp->Fmt : 'X') {
case 'C': break;
case 'R':
case 'F':
case 'L':
case 'I': nof= 4; break;
case 'D': nof= 8; break;
case 'S': nof= 2; break;
case 'T': nof= 1; break;
default: nof= cdp->Clen;
} // endswitch Fmt
default:
break;
} // endswitch tc
if (lcdp)
lcdp->SetNext(cdp);
else
tocols= cdp;
lcdp= cdp;
i++;
} // endwhile
// Degree is the the number of defined columns (informational)
if (i != defp->GetDegree())
defp->SetDegree(i);
if (defp->GetDefType() == TYPE_AM_DOS) {
int ending, recln= 0;
PDOSDEF ddp= (PDOSDEF)defp;
// Was commented because sometimes ending is 0 even when
// not specified (for instance if quoted is specified)
// if ((ending= Hc->GetIntegerOption("Ending")) < 0) {
if ((ending= Hc->GetIntegerOption("Ending")) <= 0) {
#if defined(WIN32)
ending= 2;
#else
ending= 1;
#endif
Hc->SetIntegerOption("Ending", ending);
} // endif ending
// Calculate the default record size
switch (tc) {
case TAB_FIX:
recln= nlg + ending; // + length of line ending
break;
case TAB_BIN:
case TAB_VEC:
recln= nlg;
// if ((k= (pak < 0) ? 8 : pak) > 1)
// See above for detailed comment
// Round up lrecl to multiple of 8 or pak
// recln= ((recln + k - 1) / k) * k;
break;
case TAB_DOS:
case TAB_DBF:
recln= nlg;
break;
case TAB_CSV:
case TAB_FMT:
// The number of separators (assuming an extra one can exist)
// recln= poff * ((qotd) ? 3 : 1); to be investigated
recln= nlg + poff * 3; // To be safe
default:
break;
} // endswitch tc
// lrecl must be at least recln to avoid buffer overflow
recln= max(recln, Hc->GetIntegerOption("Lrecl"));
Hc->SetIntegerOption("Lrecl", recln);
ddp->SetLrecl(recln);
} // endif Lrecl
// Attach the column definition to the tabdef
defp->SetCols(tocols);
return poff;
} // end of GetColCatInfo
/***********************************************************************/
/* GetIndexInfo: retrieve index description from the table structure. */
/***********************************************************************/
bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp)
{
// Attach new index(es)
defp->SetIndx(Hc->GetIndexInfo());
return false;
} // end of GetIndexInfo
/***********************************************************************/ /***********************************************************************/
/* GetTableDesc: retrieve a table descriptor. */ /* GetTableDesc: retrieve a table descriptor. */
/* Look for a table descriptor matching the name and type. */ /* Look for a table descriptor matching the name and type. */

View File

@@ -40,6 +40,7 @@ bool IsExactType(TABTYPE type);
bool IsTypeNullable(TABTYPE type); bool IsTypeNullable(TABTYPE type);
bool IsTypeFixed(TABTYPE type); bool IsTypeFixed(TABTYPE type);
bool IsTypeIndexable(TABTYPE type); bool IsTypeIndexable(TABTYPE type);
int GetIndexType(TABTYPE type);
uint GetFuncID(const char *func); uint GetFuncID(const char *func);
/***********************************************************************/ /***********************************************************************/
@@ -57,14 +58,6 @@ class MYCAT : public CATALOG {
void Reset(void); void Reset(void);
void SetDataPath(PGLOBAL g, const char *path) void SetDataPath(PGLOBAL g, const char *path)
{SetPath(g, &DataPath, path);} {SetPath(g, &DataPath, path);}
bool GetBoolCatInfo(PSZ what, bool bdef);
bool SetIntCatInfo(PSZ what, int ival);
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);
int GetColCatInfo(PGLOBAL g, PTABDEF defp);
bool GetIndexInfo(PGLOBAL g, PTABDEF defp);
bool StoreIndex(PGLOBAL g, PTABDEF defp) {return false;} // Temporary bool StoreIndex(PGLOBAL g, PTABDEF defp) {return false;} // Temporary
PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
LPCSTR type, PRELDEF *prp = NULL); LPCSTR type, PRELDEF *prp = NULL);

View File

@@ -365,7 +365,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
int pt) int pt)
{ {
const char *pipe = NULL; const char *pipe = NULL;
uint cto = 60, nrt = 120; uint cto = 6000, nrt = 12000;
m_DB = mysql_init(NULL); m_DB = mysql_init(NULL);

View File

@@ -326,6 +326,9 @@ Warnings:
Level Warning Level Warning
Code 1366 Code 1366
Message Incorrect string value: '\xC3\x81\xC3\x82\xC3\x83...' for column 'c' at row 1 Message Incorrect string value: '\xC3\x81\xC3\x82\xC3\x83...' for column 'c' at row 1
Level Warning
Code 1105
Message Out of range value ÁÂÃÄÅÆÇ for column 'c' at row 1
DROP TABLE t1; DROP TABLE t1;
# #
# Testing Cyrillic # Testing Cyrillic

View File

@@ -374,7 +374,7 @@ PCATLG PlgGetCatalog(PGLOBAL g, bool jump)
} // end of PlgGetCatalog } // end of PlgGetCatalog
/***********************************************************************/ /***********************************************************************/
/* PlgGetCatalog: returns CATALOG class pointer. */ /* PlgGetDataPath: returns the default data path. */
/***********************************************************************/ /***********************************************************************/
char *PlgGetDataPath(PGLOBAL g) char *PlgGetDataPath(PGLOBAL g)
{ {

View File

@@ -24,6 +24,7 @@
#include "osutil.h" #include "osutil.h"
//#include "sqlext.h" //#include "sqlext.h"
#endif #endif
#include "handler.h"
/***********************************************************************/ /***********************************************************************/
/* Include application header files */ /* Include application header files */
@@ -46,6 +47,7 @@
#include "tabdos.h" #include "tabdos.h"
#include "valblk.h" #include "valblk.h"
#include "tabmul.h" #include "tabmul.h"
#include "ha_connect.h"
/* --------------------------- Class RELDEF -------------------------- */ /* --------------------------- Class RELDEF -------------------------- */
@@ -60,8 +62,106 @@ RELDEF::RELDEF(void)
Name = NULL; Name = NULL;
Database = NULL; Database = NULL;
Cat = NULL; Cat = NULL;
Hc = NULL;
} // end of RELDEF constructor } // end of RELDEF constructor
/***********************************************************************/
/* This function sets an integer table information. */
/***********************************************************************/
bool RELDEF::SetIntCatInfo(PSZ what, int n)
{
return Hc->SetIntegerOption(what, n);
} // end of SetIntCatInfo
/***********************************************************************/
/* This function returns integer table information. */
/***********************************************************************/
int RELDEF::GetIntCatInfo(PSZ what, int idef)
{
int n= Hc->GetIntegerOption(what);
return (n == NO_IVAL) ? idef : n;
} // end of GetIntCatInfo
/***********************************************************************/
/* This function returns Boolean table information. */
/***********************************************************************/
bool RELDEF::GetBoolCatInfo(PSZ what, bool bdef)
{
bool b= Hc->GetBooleanOption(what, bdef);
return b;
} // end of GetBoolCatInfo
/***********************************************************************/
/* This function returns size catalog information. */
/***********************************************************************/
int RELDEF::GetSizeCatInfo(PSZ what, PSZ sdef)
{
char * s, c;
int i, n= 0;
if (!(s= Hc->GetStringOption(what)))
s= sdef;
if ((i= sscanf(s, " %d %c ", &n, &c)) == 2)
switch (toupper(c)) {
case 'M':
n *= 1024;
case 'K':
n *= 1024;
} // endswitch c
return n;
} // end of GetSizeCatInfo
/***********************************************************************/
/* This function sets char table information in buf. */
/***********************************************************************/
int RELDEF::GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size)
{
char *s= Hc->GetStringOption(what);
strncpy(buf, ((s) ? s : sdef), size);
return size;
} // end of GetCharCatInfo
/***********************************************************************/
/* This function returns string table information. */
/* Default parameter is "*" to get the handler default. */
/***********************************************************************/
char *RELDEF::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
{
char *sval= NULL, *s= Hc->GetStringOption(what, sdef);
if (s) {
sval= (char*)PlugSubAlloc(g, NULL, strlen(s) + 1);
strcpy(sval, s);
} else if (!stricmp(what, "filename")) {
// Return default file name
char *ftype= Hc->GetStringOption("Type", "*");
int i, n;
if (IsFileType(GetTypeID(ftype))) {
sval= (char*)PlugSubAlloc(g, NULL, strlen(Hc->GetTableName()) + 12);
strcat(strcpy(sval, Hc->GetTableName()), ".");
n= strlen(sval);
// Fold ftype to lower case
for (i= 0; i < 12; i++)
if (!ftype[i]) {
sval[n+i]= 0;
break;
} else
sval[n+i]= tolower(ftype[i]);
} // endif FileType
} // endif s
return sval;
} // end of GetStringCatInfo
/* --------------------------- Class TABDEF -------------------------- */ /* --------------------------- Class TABDEF -------------------------- */
/***********************************************************************/ /***********************************************************************/
@@ -91,24 +191,201 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1); Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1);
strcpy(Name, name); strcpy(Name, name);
Cat = cat; Cat = cat;
Catfunc = GetFuncID(Cat->GetStringCatInfo(g, "Catfunc", NULL)); Hc = ((MYCAT*)cat)->GetHandler();
Elemt = cat->GetIntCatInfo("Elements", 0); Catfunc = GetFuncID(GetStringCatInfo(g, "Catfunc", NULL));
Multiple = cat->GetIntCatInfo("Multiple", 0); Elemt = GetIntCatInfo("Elements", 0);
Degree = cat->GetIntCatInfo("Degree", 0); Multiple = GetIntCatInfo("Multiple", 0);
Read_Only = cat->GetBoolCatInfo("ReadOnly", false); Degree = GetIntCatInfo("Degree", 0);
const char *data_charset_name= cat->GetStringCatInfo(g, "Data_charset", NULL); Read_Only = GetBoolCatInfo("ReadOnly", false);
const char *data_charset_name= GetStringCatInfo(g, "Data_charset", NULL);
m_data_charset= data_charset_name ? m_data_charset= data_charset_name ?
get_charset_by_csname(data_charset_name, MY_CS_PRIMARY, 0): get_charset_by_csname(data_charset_name, MY_CS_PRIMARY, 0):
NULL; NULL;
// Get The column definitions // Get The column definitions
if ((poff = cat->GetColCatInfo(g, this)) < 0) if ((poff = GetColCatInfo(g)) < 0)
return true; return true;
// Do the definition of AM specific fields // Do the definition of AM specific fields
return DefineAM(g, am, poff); return DefineAM(g, am, poff);
} // end of Define } // end of Define
/***********************************************************************/
/* This function returns column table information. */
/***********************************************************************/
int TABDEF::GetColCatInfo(PGLOBAL g)
{
char *type= GetStringCatInfo(g, "Type", "*");
int i, loff, poff, nof, nlg;
void *field= NULL;
TABTYPE tc;
PCOLDEF cdp, lcdp= NULL, tocols= NULL;
PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO));
memset(pcf, 0, sizeof(COLINFO));
// Get a unique char identifier for type
tc= (Catfunc == FNC_NO) ? GetTypeID(type) : TAB_PRX;
// Take care of the column definitions
i= poff= nof= nlg= 0;
// Offsets of HTML and DIR tables start from 0, DBF at 1
loff= (tc == TAB_DBF) ? 1 : (tc == TAB_XML || tc == TAB_DIR) ? -1 : 0;
while (true) {
// Default Offset depends on table type
switch (tc) {
case TAB_DOS:
case TAB_FIX:
case TAB_BIN:
case TAB_VEC:
case TAB_DBF:
poff= loff + nof; // Default next offset
nlg= max(nlg, poff); // Default lrecl
break;
case TAB_CSV:
case TAB_FMT:
nlg+= nof;
case TAB_DIR:
case TAB_XML:
poff= loff + 1;
break;
case TAB_INI:
case TAB_MAC:
case TAB_TBL:
case TAB_XCL:
case TAB_OCCUR:
case TAB_PRX:
case TAB_OEM:
poff = 0; // Offset represents an independant flag
break;
default: // VCT PLG ODBC MYSQL WMI...
poff = 0; // NA
break;
} // endswitch tc
// do {
field= Hc->GetColumnOption(g, field, pcf);
// } while (field && (*pcf->Name =='*' /*|| pcf->Flags & U_VIRTUAL*/));
if (tc == TAB_DBF && pcf->Type == TYPE_DATE && !pcf->Datefmt) {
// DBF date format defaults to 'YYYMMDD'
pcf->Datefmt= "YYYYMMDD";
pcf->Length= 8;
} // endif tc
if (!field)
break;
// Allocate the column description block
cdp= new(g) COLDEF;
if ((nof= cdp->Define(g, NULL, pcf, poff)) < 0)
return -1; // Error, probably unhandled type
else if (nof)
loff= cdp->GetOffset();
switch (tc) {
case TAB_VEC:
cdp->SetOffset(0); // Not to have shift
case TAB_BIN:
// BIN/VEC are packed by default
if (nof)
// Field width is the internal representation width
// that can also depend on the column format
switch (cdp->Fmt ? *cdp->Fmt : 'X') {
case 'C': break;
case 'R':
case 'F':
case 'L':
case 'I': nof= 4; break;
case 'D': nof= 8; break;
case 'S': nof= 2; break;
case 'T': nof= 1; break;
default: nof= cdp->Clen;
} // endswitch Fmt
default:
break;
} // endswitch tc
if (lcdp)
lcdp->SetNext(cdp);
else
tocols= cdp;
lcdp= cdp;
i++;
} // endwhile
// Degree is the the number of defined columns (informational)
if (i != GetDegree())
SetDegree(i);
if (GetDefType() == TYPE_AM_DOS) {
int ending, recln= 0;
// Was commented because sometimes ending is 0 even when
// not specified (for instance if quoted is specified)
// if ((ending= Hc->GetIntegerOption("Ending")) < 0) {
if ((ending= Hc->GetIntegerOption("Ending")) <= 0) {
#if defined(WIN32)
ending= 2;
#else
ending= 1;
#endif
Hc->SetIntegerOption("Ending", ending);
} // endif ending
// Calculate the default record size
switch (tc) {
case TAB_FIX:
recln= nlg + ending; // + length of line ending
break;
case TAB_BIN:
case TAB_VEC:
recln= nlg;
// if ((k= (pak < 0) ? 8 : pak) > 1)
// See above for detailed comment
// Round up lrecl to multiple of 8 or pak
// recln= ((recln + k - 1) / k) * k;
break;
case TAB_DOS:
case TAB_DBF:
recln= nlg;
break;
case TAB_CSV:
case TAB_FMT:
// The number of separators (assuming an extra one can exist)
// recln= poff * ((qotd) ? 3 : 1); to be investigated
recln= nlg + poff * 3; // To be safe
default:
break;
} // endswitch tc
// lrecl must be at least recln to avoid buffer overflow
recln= max(recln, Hc->GetIntegerOption("Lrecl"));
Hc->SetIntegerOption("Lrecl", recln);
((PDOSDEF)this)->SetLrecl(recln);
} // endif Lrecl
// Attach the column definition to the tabdef
SetCols(tocols);
return poff;
} // end of GetColCatInfo
/***********************************************************************/
/* SetIndexInfo: retrieve index description from the table structure. */
/***********************************************************************/
void TABDEF::SetIndexInfo(void)
{
// Attach new index(es)
SetIndx(Hc->GetIndexInfo());
} // end of SetIndexInfo
/* --------------------------- Class OEMDEF -------------------------- */ /* --------------------------- Class OEMDEF -------------------------- */
/***********************************************************************/ /***********************************************************************/
@@ -188,7 +465,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
// Have the external class do its complete definition // Have the external class do its complete definition
if (!cat->Cbuf) { if (!cat->Cbuf) {
// Suballocate a temporary buffer for the entire column section // Suballocate a temporary buffer for the entire column section
cat->Cblen = cat->GetSizeCatInfo("Colsize", "8K"); cat->Cblen = GetSizeCatInfo("Colsize", "8K");
cat->Cbuf = (char*)PlugSubAlloc(g, NULL, cat->Cblen); cat->Cbuf = (char*)PlugSubAlloc(g, NULL, cat->Cblen);
} // endif Cbuf } // endif Cbuf
@@ -218,8 +495,8 @@ bool OEMDEF::DeleteTableFile(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
Module = Cat->GetStringCatInfo(g, "Module", ""); Module = GetStringCatInfo(g, "Module", "");
Subtype = Cat->GetStringCatInfo(g, "Subtype", Module); Subtype = GetStringCatInfo(g, "Subtype", Module);
if (!*Module) if (!*Module)
Module = Subtype; Module = Subtype;

View File

@@ -1,225 +1,233 @@
/*************** RelDef H Declares Source Code File (.H) ***************/ /*************** RelDef H Declares Source Code File (.H) ***************/
/* Name: RELDEF.H Version 1.4 */ /* Name: RELDEF.H Version 1.4 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2004-2014 */
/* */ /* */
/* This file contains the DEF classes definitions. */ /* This file contains the DEF classes definitions. */
/***********************************************************************/ /***********************************************************************/
#ifndef __RELDEF_H #ifndef __RELDEF_H
#define __RELDEF_H #define __RELDEF_H
#include "block.h" #include "block.h"
#include "catalog.h" #include "catalog.h"
#include "my_sys.h" #include "my_sys.h"
typedef class INDEXDEF *PIXDEF; typedef class INDEXDEF *PIXDEF;
typedef class ha_connect *PHC;
/***********************************************************************/
/* Table or View (relation) definition block. */ /***********************************************************************/
/***********************************************************************/ /* Table or View (relation) definition block. */
class DllExport RELDEF : public BLOCK { // Relation definition block /***********************************************************************/
friend class CATALOG; class DllExport RELDEF : public BLOCK { // Relation definition block
friend class PLUGCAT; friend class CATALOG;
friend class MYCAT; friend class PLUGCAT;
public: friend class MYCAT;
RELDEF(void); // Constructor public:
RELDEF(void); // Constructor
// Implementation
PRELDEF GetNext(void) {return Next;} // Implementation
PSZ GetName(void) {return Name;} PRELDEF GetNext(void) {return Next;}
PSZ GetDB(void) {return (PSZ)Database;} PSZ GetName(void) {return Name;}
PCOLDEF GetCols(void) {return To_Cols;} PSZ GetDB(void) {return (PSZ)Database;}
void SetCols(PCOLDEF pcd) {To_Cols = pcd;} PCOLDEF GetCols(void) {return To_Cols;}
PCATLG GetCat(void) {return Cat;} void SetCols(PCOLDEF pcd) {To_Cols = pcd;}
virtual const char *GetType(void) = 0; PCATLG GetCat(void) {return Cat;}
virtual AMT GetDefType(void) = 0; virtual const char *GetType(void) = 0;
void SetName(const char *str) { Name=(char*)str; } virtual AMT GetDefType(void) = 0;
void SetCat(PCATLG cat) { Cat=cat; } void SetName(const char *str) { Name=(char*)str; }
void SetCat(PCATLG cat) { Cat=cat; }
// Methods
virtual bool Indexable(void) {return false;} // Methods
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) = 0; bool GetBoolCatInfo(PSZ what, bool bdef);
virtual PTDB GetTable(PGLOBAL g, MODE mode) = 0; bool SetIntCatInfo(PSZ what, int ival);
int GetIntCatInfo(PSZ what, int idef);
protected: int GetSizeCatInfo(PSZ what, PSZ sdef);
PRELDEF Next; /* To next definition block */ int GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size);
PSZ Name; /* Name of the view */ char *GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef);
LPCSTR Database; /* Table database */ virtual bool Indexable(void) {return false;}
PCOLDEF To_Cols; /* To a list of column desc */ virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) = 0;
PCATLG Cat; /* To DB catalog info */ virtual PTDB GetTable(PGLOBAL g, MODE mode) = 0;
}; // end of RELDEF
protected:
/***********************************************************************/ PRELDEF Next; /* To next definition block */
/* These classes correspond to the data base description contained in */ PSZ Name; /* Name of the view */
/* a .XDB file the A.M. DOS, FIX, CSV, MAP, BIN, VCT, PLG, ODBC, DOM. */ LPCSTR Database; /* Table database */
/***********************************************************************/ PCOLDEF To_Cols; /* To a list of column desc */
class DllExport TABDEF : public RELDEF { /* Logical table descriptor */ PCATLG Cat; /* To DB catalog info */
friend class CATALOG; PHC Hc; /* The Connect handler */
friend class PLUGCAT; }; // end of RELDEF
friend class MYCAT;
public: /***********************************************************************/
// Constructor /* These classes correspond to the data base description contained in */
TABDEF(void); // Constructor /* a .XDB file the A.M. DOS, FIX, CSV, MAP, BIN, VCT, PLG, ODBC, DOM. */
/***********************************************************************/
// Implementation class DllExport TABDEF : public RELDEF { /* Logical table descriptor */
int GetDegree(void) {return Degree;} friend class CATALOG;
void SetDegree(int d) {Degree = d;} friend class PLUGCAT;
int GetElemt(void) {return Elemt;} friend class MYCAT;
void SetNext(PTABDEF tdfp) {Next = tdfp;} public:
int GetMultiple(void) {return Multiple;} // Constructor
int GetPseudo(void) {return Pseudo;} TABDEF(void); // Constructor
PSZ GetPath(void)
{return (Database) ? (PSZ)Database : Cat->GetDataPath();} // Implementation
bool SepIndex(void) {return Cat->GetBoolCatInfo("SepIndex", false);} int GetDegree(void) {return Degree;}
bool IsReadOnly(void) {return Read_Only;} void SetDegree(int d) {Degree = d;}
virtual AMT GetDefType(void) {return TYPE_AM_TAB;} int GetElemt(void) {return Elemt;}
virtual PIXDEF GetIndx(void) {return NULL;} void SetNext(PTABDEF tdfp) {Next = tdfp;}
virtual void SetIndx(PIXDEF xp) {} int GetMultiple(void) {return Multiple;}
virtual bool IsHuge(void) {return false;} int GetPseudo(void) {return Pseudo;}
const CHARSET_INFO *data_charset() {return m_data_charset;} PSZ GetPath(void)
{return (Database) ? (PSZ)Database : Cat->GetDataPath();}
// Methods bool SepIndex(void) {return GetBoolCatInfo("SepIndex", false);}
bool DropTable(PGLOBAL g, PSZ name); bool IsReadOnly(void) {return Read_Only;}
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am); virtual AMT GetDefType(void) {return TYPE_AM_TAB;}
virtual bool DefineAM(PGLOBAL, LPCSTR, int) = 0; virtual PIXDEF GetIndx(void) {return NULL;}
virtual void SetIndx(PIXDEF xp) {}
protected: virtual bool IsHuge(void) {return false;}
// Members const CHARSET_INFO *data_charset() {return m_data_charset;}
PSZ Schema; /* Table schema (for ODBC) */
PSZ Desc; /* Table description */ // Methods
uint Catfunc; /* Catalog function ID */ int GetColCatInfo(PGLOBAL g);
int Card; /* (max) number of rows in table */ void SetIndexInfo(void);
int Elemt; /* Number of rows in blocks or rowset */ bool DropTable(PGLOBAL g, PSZ name);
int Sort; /* Table already sorted ??? */ virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am);
int Multiple; /* 0: No 1: DIR 2: Section 3: filelist */ virtual bool DefineAM(PGLOBAL, LPCSTR, int) = 0;
int Degree; /* Number of columns in the table */
int Pseudo; /* Bit: 1 ROWID Ok, 2 FILEID Ok */ protected:
bool Read_Only; /* true for read only tables */ // Members
const CHARSET_INFO *m_data_charset; PSZ Schema; /* Table schema (for ODBC) */
}; // end of TABDEF PSZ Desc; /* Table description */
uint Catfunc; /* Catalog function ID */
/***********************************************************************/ int Card; /* (max) number of rows in table */
/* Externally defined OEM tables. */ int Elemt; /* Number of rows in blocks or rowset */
/***********************************************************************/ int Sort; /* Table already sorted ??? */
class DllExport OEMDEF : public TABDEF { /* OEM table */ int Multiple; /* 0: No 1: DIR 2: Section 3: filelist */
friend class CATALOG; int Degree; /* Number of columns in the table */
friend class PLUGCAT; int Pseudo; /* Bit: 1 ROWID Ok, 2 FILEID Ok */
friend class MYCAT; bool Read_Only; /* true for read only tables */
public: const CHARSET_INFO *m_data_charset;
// Constructor }; // end of TABDEF
OEMDEF(void) {Hdll = NULL; Pxdef = NULL; Module = Subtype = NULL;}
/***********************************************************************/
// Implementation /* Externally defined OEM tables. */
virtual const char *GetType(void) {return "OEM";} /***********************************************************************/
virtual AMT GetDefType(void) {return TYPE_AM_OEM;} class DllExport OEMDEF : public TABDEF { /* OEM table */
friend class CATALOG;
// Methods friend class PLUGCAT;
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); friend class MYCAT;
virtual PTDB GetTable(PGLOBAL g, MODE mode); public:
// Constructor
protected: OEMDEF(void) {Hdll = NULL; Pxdef = NULL; Module = Subtype = NULL;}
PTABDEF GetXdef(PGLOBAL g);
// Implementation
// Members virtual const char *GetType(void) {return "OEM";}
#if defined(WIN32) virtual AMT GetDefType(void) {return TYPE_AM_OEM;}
HANDLE Hdll; /* Handle to the external DLL */
#else // !WIN32 // Methods
void *Hdll; /* Handle for the loaded shared library */ virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
#endif // !WIN32 virtual PTDB GetTable(PGLOBAL g, MODE mode);
PTABDEF Pxdef; /* Pointer to the external TABDEF class */
char *Module; /* Path/Name of the DLL implenting it */ protected:
char *Subtype; /* The name of the OEM table sub type */ PTABDEF GetXdef(PGLOBAL g);
}; // end of OEMDEF
// Members
/***********************************************************************/ #if defined(WIN32)
/* Column definition block used during creation. */ HANDLE Hdll; /* Handle to the external DLL */
/***********************************************************************/ #else // !WIN32
class DllExport COLCRT : public BLOCK { /* Column description block */ void *Hdll; /* Handle for the loaded shared library */
friend class TABDEF; #endif // !WIN32
public: PTABDEF Pxdef; /* Pointer to the external TABDEF class */
COLCRT(PSZ name); // Constructor char *Module; /* Path/Name of the DLL implenting it */
COLCRT(void); // Constructor (for views) char *Subtype; /* The name of the OEM table sub type */
}; // end of OEMDEF
// Implementation
PSZ GetName(void) {return Name;} /***********************************************************************/
PSZ GetDecode(void) {return Decode;} /* Column definition block used during creation. */
PSZ GetFmt(void) {return Fmt;} /***********************************************************************/
int GetOpt(void) {return Opt;} class DllExport COLCRT : public BLOCK { /* Column description block */
int GetFreq(void) {return Freq;} friend class TABDEF;
int GetLong(void) {return Long;} public:
int GetPrecision(void) {return Precision;} COLCRT(PSZ name); // Constructor
int GetOffset(void) {return Offset;} COLCRT(void); // Constructor (for views)
void SetOffset(int offset) {Offset = offset;}
// Implementation
protected: PSZ GetName(void) {return Name;}
PCOLCRT Next; /* To next block */ PSZ GetDecode(void) {return Decode;}
PSZ Name; /* Column name */ PSZ GetFmt(void) {return Fmt;}
PSZ Desc; /* Column description */ int GetOpt(void) {return Opt;}
PSZ Decode; /* Date format */ int GetFreq(void) {return Freq;}
PSZ Fmt; /* Input format for formatted files */ int GetLong(void) {return Long;}
int Offset; /* Offset of field within record */ int GetPrecision(void) {return Precision;}
int Long; /* Length of field in file record (!BIN) */ int GetOffset(void) {return Offset;}
int Key; /* Key (greater than 1 if multiple) */ void SetOffset(int offset) {Offset = offset;}
int Precision; /* Logical column length */
int Scale; /* Decimals for float/decimal values */ protected:
int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */ PCOLCRT Next; /* To next block */
int Freq; /* Estimated number of different values */ PSZ Name; /* Column name */
char DataType; /* Internal data type (C, N, F, T) */ PSZ Desc; /* Column description */
}; // end of COLCRT PSZ Decode; /* Date format */
PSZ Fmt; /* Input format for formatted files */
/***********************************************************************/ int Offset; /* Offset of field within record */
/* Column definition block. */ int Long; /* Length of field in file record (!BIN) */
/***********************************************************************/ int Key; /* Key (greater than 1 if multiple) */
class DllExport COLDEF : public COLCRT { /* Column description block */ int Precision; /* Logical column length */
friend class CATALOG; int Scale; /* Decimals for float/decimal values */
friend class PLUGCAT; int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */
friend class MYCAT; int Freq; /* Estimated number of different values */
friend class COLBLK; char DataType; /* Internal data type (C, N, F, T) */
friend class DBFFAM; }; // end of COLCRT
friend class TDBASE;
public: /***********************************************************************/
COLDEF(void); // Constructor /* Column definition block. */
/***********************************************************************/
// Implementation class DllExport COLDEF : public COLCRT { /* Column description block */
PCOLDEF GetNext(void) {return (PCOLDEF)Next;} friend class TABDEF;
void SetNext(PCOLDEF pcdf) {Next = pcdf;} friend class COLBLK;
int GetLength(void) {return (int)F.Length;} friend class DBFFAM;
int GetClen(void) {return Clen;} friend class TDBASE;
int GetType(void) {return Buf_Type;} public:
int GetPoff(void) {return Poff;} COLDEF(void); // Constructor
void *GetMin(void) {return To_Min;}
void SetMin(void *minp) {To_Min = minp;} // Implementation
void *GetMax(void) {return To_Max;} PCOLDEF GetNext(void) {return (PCOLDEF)Next;}
void SetMax(void *maxp) {To_Max = maxp;} void SetNext(PCOLDEF pcdf) {Next = pcdf;}
bool GetXdb2(void) {return Xdb2;} int GetLength(void) {return (int)F.Length;}
void SetXdb2(bool b) {Xdb2 = b;} int GetClen(void) {return Clen;}
void *GetBmap(void) {return To_Bmap;} int GetType(void) {return Buf_Type;}
void SetBmap(void *bmp) {To_Bmap = bmp;} int GetPoff(void) {return Poff;}
void *GetDval(void) {return To_Dval;} void *GetMin(void) {return To_Min;}
void SetDval(void *dvp) {To_Dval = dvp;} void SetMin(void *minp) {To_Min = minp;}
int GetNdv(void) {return Ndv;} void *GetMax(void) {return To_Max;}
void SetNdv(int ndv) {Ndv = ndv;} void SetMax(void *maxp) {To_Max = maxp;}
int GetNbm(void) {return Nbm;} bool GetXdb2(void) {return Xdb2;}
void SetNbm(int nbm) {Nbm = nbm;} void SetXdb2(bool b) {Xdb2 = b;}
int Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff); void *GetBmap(void) {return To_Bmap;}
void Define(PGLOBAL g, PCOL colp); void SetBmap(void *bmp) {To_Bmap = bmp;}
void *GetDval(void) {return To_Dval;}
protected: void SetDval(void *dvp) {To_Dval = dvp;}
void *To_Min; /* Point to array of block min values */ int GetNdv(void) {return Ndv;}
void *To_Max; /* Point to array of block max values */ void SetNdv(int ndv) {Ndv = ndv;}
int *To_Pos; /* Point to array of block positions */ int GetNbm(void) {return Nbm;}
bool Xdb2; /* TRUE if to be optimized by XDB2 */ void SetNbm(int nbm) {Nbm = nbm;}
void *To_Bmap; /* To array of block bitmap values */ int Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff);
void *To_Dval; /* To array of column distinct values */ void Define(PGLOBAL g, PCOL colp);
int Ndv; /* Number of distinct values */
int Nbm; /* Number of ULONG in bitmap (XDB2) */ protected:
int Buf_Type; /* Internal data type */ void *To_Min; /* Point to array of block min values */
int Clen; /* Internal data size in chars (bytes) */ void *To_Max; /* Point to array of block max values */
int Poff; /* Calculated offset for Packed tables */ int *To_Pos; /* Point to array of block positions */
FORMAT F; /* Output format (should be in COLCRT) */ bool Xdb2; /* TRUE if to be optimized by XDB2 */
ushort Flags; /* Used by MariaDB CONNECT handler */ void *To_Bmap; /* To array of block bitmap values */
}; // end of COLDEF void *To_Dval; /* To array of column distinct values */
int Ndv; /* Number of distinct values */
#endif // __RELDEF_H 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

File diff suppressed because it is too large Load Diff

View File

@@ -415,10 +415,10 @@ bool CSVDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
if (DOSDEF::DefineAM(g, "CSV", poff)) if (DOSDEF::DefineAM(g, "CSV", poff))
return true; return true;
Cat->GetCharCatInfo("Separator", ",", buf, sizeof(buf)); GetCharCatInfo("Separator", ",", buf, sizeof(buf));
Sep = (strlen(buf) == 2 && buf[0] == '\\' && buf[1] == 't') ? '\t' : *buf; Sep = (strlen(buf) == 2 && buf[0] == '\\' && buf[1] == 't') ? '\t' : *buf;
Quoted = Cat->GetIntCatInfo("Quoted", -1); Quoted = GetIntCatInfo("Quoted", -1);
Cat->GetCharCatInfo("Qchar", "", buf, sizeof(buf)); GetCharCatInfo("Qchar", "", buf, sizeof(buf));
Qot = *buf; Qot = *buf;
if (Qot && Quoted < 0) if (Qot && Quoted < 0)
@@ -427,9 +427,9 @@ bool CSVDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Qot = '"'; Qot = '"';
Fmtd = (!Sep || (am && (*am == 'F' || *am == 'f'))); Fmtd = (!Sep || (am && (*am == 'F' || *am == 'f')));
Header = (Cat->GetIntCatInfo("Header", 0) != 0); Header = (GetIntCatInfo("Header", 0) != 0);
Maxerr = Cat->GetIntCatInfo("Maxerr", 0); Maxerr = GetIntCatInfo("Maxerr", 0);
Accept = (Cat->GetIntCatInfo("Accept", 0) != 0); Accept = (GetIntCatInfo("Accept", 0) != 0);
return false; return false;
} // end of DefineAM } // end of DefineAM

View File

@@ -591,9 +591,9 @@ void TDBMUL::CloseDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) bool DIRDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
Desc = Fn = Cat->GetStringCatInfo(g, "Filename", NULL); Desc = Fn = GetStringCatInfo(g, "Filename", NULL);
Incl = (Cat->GetIntCatInfo("Subdir", 0) != 0); Incl = (GetIntCatInfo("Subdir", 0) != 0);
Huge = (Cat->GetIntCatInfo("Huge", 0) != 0); Huge = (GetIntCatInfo("Huge", 0) != 0);
return false; return false;
} // end of DefineAM } // end of DefineAM

View File

@@ -267,23 +267,23 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b)
// For unspecified values, get the values of old style options // For unspecified values, get the values of old style options
// but only if called from MYSQLDEF, else set them to NULL // but only if called from MYSQLDEF, else set them to NULL
Portnumber = (sport && sport[0]) ? atoi(sport) Portnumber = (sport && sport[0]) ? atoi(sport)
: (b) ? Cat->GetIntCatInfo("Port", GetDefaultPort()) : 0; : (b) ? GetIntCatInfo("Port", GetDefaultPort()) : 0;
if (Username[0] == 0) if (Username[0] == 0)
Username = (b) ? Cat->GetStringCatInfo(g, "User", "*") : NULL; Username = (b) ? GetStringCatInfo(g, "User", "*") : NULL;
if (Hostname[0] == 0) if (Hostname[0] == 0)
Hostname = (b) ? Cat->GetStringCatInfo(g, "Host", "localhost") : NULL; Hostname = (b) ? GetStringCatInfo(g, "Host", "localhost") : NULL;
if (!Database || !*Database) if (!Database || !*Database)
Database = (b) ? Cat->GetStringCatInfo(g, "Database", "*") : NULL; Database = (b) ? GetStringCatInfo(g, "Database", "*") : NULL;
if (!Tabname || !*Tabname) if (!Tabname || !*Tabname)
Tabname = (b) ? Cat->GetStringCatInfo(g, "Tabname", Name) : NULL; Tabname = (b) ? GetStringCatInfo(g, "Tabname", Name) : NULL;
if (!Password) if (!Password)
Password = (b) ? Cat->GetStringCatInfo(g, "Password", NULL) : NULL; Password = (b) ? GetStringCatInfo(g, "Password", NULL) : NULL;
} // endif URL } // endif URL
#if 0 #if 0
@@ -308,37 +308,37 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
if (stricmp(am, "MYPRX")) { if (stricmp(am, "MYPRX")) {
// Normal case of specific MYSQL table // Normal case of specific MYSQL table
url = Cat->GetStringCatInfo(g, "Connect", NULL); url = GetStringCatInfo(g, "Connect", NULL);
if (!url || !*url) { if (!url || !*url) {
// Not using the connection URL // Not using the connection URL
Hostname = Cat->GetStringCatInfo(g, "Host", "localhost"); Hostname = GetStringCatInfo(g, "Host", "localhost");
Database = Cat->GetStringCatInfo(g, "Database", "*"); Database = GetStringCatInfo(g, "Database", "*");
Tabname = Cat->GetStringCatInfo(g, "Name", Name); // Deprecated Tabname = GetStringCatInfo(g, "Name", Name); // Deprecated
Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname); Tabname = GetStringCatInfo(g, "Tabname", Tabname);
Username = Cat->GetStringCatInfo(g, "User", "*"); Username = GetStringCatInfo(g, "User", "*");
Password = Cat->GetStringCatInfo(g, "Password", NULL); Password = GetStringCatInfo(g, "Password", NULL);
Portnumber = Cat->GetIntCatInfo("Port", GetDefaultPort()); Portnumber = GetIntCatInfo("Port", GetDefaultPort());
Server = Hostname; Server = Hostname;
} else if (ParseURL(g, url)) } else if (ParseURL(g, url))
return true; return true;
Bind = !!Cat->GetIntCatInfo("Bind", 0); Bind = !!GetIntCatInfo("Bind", 0);
Delayed = !!Cat->GetIntCatInfo("Delayed", 0); Delayed = !!GetIntCatInfo("Delayed", 0);
} else { } else {
// MYSQL access from a PROXY table // MYSQL access from a PROXY table
Database = Cat->GetStringCatInfo(g, "Database", "*"); Database = GetStringCatInfo(g, "Database", "*");
Isview = Cat->GetBoolCatInfo("View", FALSE); Isview = GetBoolCatInfo("View", FALSE);
// We must get other connection parms from the calling table // We must get other connection parms from the calling table
Remove_tshp(Cat); Remove_tshp(Cat);
url = Cat->GetStringCatInfo(g, "Connect", NULL); url = GetStringCatInfo(g, "Connect", NULL);
if (!url || !*url) { if (!url || !*url) {
Hostname = Cat->GetStringCatInfo(g, "Host", "localhost"); Hostname = GetStringCatInfo(g, "Host", "localhost");
Username = Cat->GetStringCatInfo(g, "User", "*"); Username = GetStringCatInfo(g, "User", "*");
Password = Cat->GetStringCatInfo(g, "Password", NULL); Password = GetStringCatInfo(g, "Password", NULL);
Portnumber = Cat->GetIntCatInfo("Port", GetDefaultPort()); Portnumber = GetIntCatInfo("Port", GetDefaultPort());
Server = Hostname; Server = Hostname;
} else { } else {
char *locdb = Database; char *locdb = Database;
@@ -352,16 +352,16 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Tabname = Name; Tabname = Name;
} // endif am } // endif am
if ((Srcdef = Cat->GetStringCatInfo(g, "Srcdef", NULL))) if ((Srcdef = GetStringCatInfo(g, "Srcdef", NULL)))
Isview = true; Isview = true;
// Used for Update and Delete // Used for Update and Delete
Qrystr = Cat->GetStringCatInfo(g, "Query_String", "?"); Qrystr = GetStringCatInfo(g, "Query_String", "?");
Quoted = Cat->GetIntCatInfo("Quoted", 0); Quoted = GetIntCatInfo("Quoted", 0);
// Specific for command executing tables // Specific for command executing tables
Xsrc = Cat->GetBoolCatInfo("Execsrc", false); Xsrc = GetBoolCatInfo("Execsrc", false);
Mxr = Cat->GetIntCatInfo("Maxerr", 0); Mxr = GetIntCatInfo("Maxerr", 0);
return FALSE; return FALSE;
} // end of DefineAM } // end of DefineAM

View File

@@ -264,9 +264,9 @@ bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col,
/***********************************************************************/ /***********************************************************************/
bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
Rcol = Cat->GetStringCatInfo(g, "RankCol", ""); Rcol = GetStringCatInfo(g, "RankCol", "");
Colist = Cat->GetStringCatInfo(g, "Colist", ""); Colist = GetStringCatInfo(g, "Colist", "");
Xcol = Cat->GetStringCatInfo(g, "OccurCol", Colist); Xcol = GetStringCatInfo(g, "OccurCol", Colist);
return PRXDEF::DefineAM(g, am, poff); return PRXDEF::DefineAM(g, am, poff);
} // end of DefineAM } // end of DefineAM

View File

@@ -100,22 +100,22 @@ ODBCDEF::ODBCDEF(void)
/***********************************************************************/ /***********************************************************************/
bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
Desc = Connect = Cat->GetStringCatInfo(g, "Connect", ""); Desc = Connect = GetStringCatInfo(g, "Connect", "");
Tabname = Cat->GetStringCatInfo(g, "Name", Tabname = GetStringCatInfo(g, "Name",
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name); (Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname); Tabname = GetStringCatInfo(g, "Tabname", Tabname);
Tabschema = Cat->GetStringCatInfo(g, "Dbname", NULL); Tabschema = GetStringCatInfo(g, "Dbname", NULL);
Tabschema = Cat->GetStringCatInfo(g, "Schema", Tabschema); Tabschema = GetStringCatInfo(g, "Schema", Tabschema);
Tabcat = Cat->GetStringCatInfo(g, "Qualifier", NULL); Tabcat = GetStringCatInfo(g, "Qualifier", NULL);
Tabcat = Cat->GetStringCatInfo(g, "Catalog", Tabcat); Tabcat = GetStringCatInfo(g, "Catalog", Tabcat);
Srcdef = Cat->GetStringCatInfo(g, "Srcdef", NULL); Srcdef = GetStringCatInfo(g, "Srcdef", NULL);
Qrystr = Cat->GetStringCatInfo(g, "Query_String", "?"); Qrystr = GetStringCatInfo(g, "Query_String", "?");
Sep = Cat->GetStringCatInfo(g, "Separator", NULL); Sep = GetStringCatInfo(g, "Separator", NULL);
Catver = Cat->GetIntCatInfo("Catver", 2); Catver = GetIntCatInfo("Catver", 2);
Xsrc = Cat->GetBoolCatInfo("Execsrc", FALSE); Xsrc = GetBoolCatInfo("Execsrc", FALSE);
Maxerr = Cat->GetIntCatInfo("Maxerr", 0); Maxerr = GetIntCatInfo("Maxerr", 0);
Maxres = Cat->GetIntCatInfo("Maxres", 0); Maxres = GetIntCatInfo("Maxres", 0);
Quoted = Cat->GetIntCatInfo("Quoted", 0); Quoted = GetIntCatInfo("Quoted", 0);
Options = ODBConn::noOdbcDialog; Options = ODBConn::noOdbcDialog;
Pseudo = 2; // FILID is Ok but not ROWID Pseudo = 2; // FILID is Ok but not ROWID
return false; return false;

View File

@@ -58,11 +58,11 @@ extern "C" int trace;
/***********************************************************************/ /***********************************************************************/
PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src, PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src,
const char *picol, const char *fncol, const char *picol, const char *fncol,
const char *host, const char *db, const char *skcol, const char *host,
const char *user, const char *pwd, const char *db, const char *user,
int port) const char *pwd, int port)
{ {
PIVAID pvd(tab, src, picol, fncol, host, db, user, pwd, port); PIVAID pvd(tab, src, picol, fncol, skcol, host, db, user, pwd, port);
return pvd.MakePivotColumns(g); return pvd.MakePivotColumns(g);
} // end of PivotColumns } // end of PivotColumns
@@ -72,10 +72,10 @@ PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src,
/***********************************************************************/ /***********************************************************************/
/* PIVAID constructor. */ /* PIVAID constructor. */
/***********************************************************************/ /***********************************************************************/
PIVAID::PIVAID(const char *tab, const char *src, const char *picol, PIVAID::PIVAID(const char *tab, const char *src, const char *picol,
const char *fncol, const char *host, const char *db, const char *fncol, const char *skcol, const char *host,
const char *user, const char *pwd, int port) const char *db, const char *user, const char *pwd,
: CSORT(false) int port) : CSORT(false)
{ {
Host = (char*)host; Host = (char*)host;
User = (char*)user; User = (char*)user;
@@ -86,19 +86,34 @@ PIVAID::PIVAID(const char *tab, const char *src, const char *picol,
Tabsrc = (char*)src; Tabsrc = (char*)src;
Picol = (char*)picol; Picol = (char*)picol;
Fncol = (char*)fncol; Fncol = (char*)fncol;
Skcol = (char*)skcol;
Rblkp = NULL; Rblkp = NULL;
Port = (port) ? port : GetDefaultPort(); Port = (port) ? port : GetDefaultPort();
} // end of PIVAID constructor } // end of PIVAID constructor
/***********************************************************************/
/* Skip columns that are in the skipped column list. */
/***********************************************************************/
bool PIVAID::SkipColumn(PCOLRES crp, char *skc)
{
if (skc)
for (char *p = skc; *p; p += (strlen(p) + 1))
if (!stricmp(crp->Name, p))
return true;
return false;
} // end of SkipColumn
/***********************************************************************/ /***********************************************************************/
/* Make the Pivot table column list. */ /* Make the Pivot table column list. */
/***********************************************************************/ /***********************************************************************/
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
{ {
char *query, *colname, buf[64]; char *p, *query, *colname, *skc, buf[64];
int rc, ndif, nblin, w = 0; int rc, ndif, nblin, w = 0;
bool b = false; bool b = false;
PVAL valp; PVAL valp;
PQRYRES qrp;
PCOLRES *pcrp, crp, fncrp = NULL; PCOLRES *pcrp, crp, fncrp = NULL;
// Save stack and allocation environment and prepare error return // Save stack and allocation environment and prepare error return
@@ -111,10 +126,25 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
goto err; goto err;
} // endif rc } // endif rc
// Are there columns to skip?
if (Skcol) {
uint n = strlen(Skcol);
skc = (char*)PlugSubAlloc(g, NULL, n + 2);
strcpy(skc, Skcol);
skc[n + 1] = 0;
// Replace ; by nulls in skc
for (p = strchr(skc, ';'); p; p = strchr(p, ';'))
*p++ = 0;
} else
skc = NULL;
if (!Tabsrc && Tabname) { if (!Tabsrc && Tabname) {
// Locate the query // Locate the query
query = (char*)PlugSubAlloc(g, NULL, strlen(Tabname) + 16); query = (char*)PlugSubAlloc(g, NULL, strlen(Tabname) + 26);
sprintf(query, "SELECT * FROM %s", Tabname); sprintf(query, "SELECT * FROM `%s` LIMIT 1", Tabname);
} else if (!Tabsrc) { } else if (!Tabsrc) {
strcpy(g->Message, MSG(SRC_TABLE_UNDEF)); strcpy(g->Message, MSG(SRC_TABLE_UNDEF));
return NULL; return NULL;
@@ -132,18 +162,17 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
goto err; goto err;
// We must have a storage query to get pivot column values // We must have a storage query to get pivot column values
Qryp = Myc.GetResult(g, true); if (!(Qryp = Myc.GetResult(g, true)))
Myc.Close(); goto err;
b = false;
if (!Fncol) { if (!Fncol) {
for (crp = Qryp->Colresp; crp; crp = crp->Next) for (crp = Qryp->Colresp; crp; crp = crp->Next)
if (!Picol || stricmp(Picol, crp->Name)) if ((!Picol || stricmp(Picol, crp->Name)) && !SkipColumn(crp, skc))
Fncol = crp->Name; Fncol = crp->Name;
if (!Fncol) { if (!Fncol) {
strcpy(g->Message, MSG(NO_DEF_FNCCOL)); strcpy(g->Message, MSG(NO_DEF_FNCCOL));
return NULL; goto err;
} // endif Fncol } // endif Fncol
} // endif Fncol } // endif Fncol
@@ -151,22 +180,25 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
if (!Picol) { if (!Picol) {
// Find default Picol as the last one not equal to Fncol // Find default Picol as the last one not equal to Fncol
for (crp = Qryp->Colresp; crp; crp = crp->Next) for (crp = Qryp->Colresp; crp; crp = crp->Next)
if (stricmp(Fncol, crp->Name)) if (stricmp(Fncol, crp->Name) && !SkipColumn(crp, skc))
Picol = crp->Name; Picol = crp->Name;
if (!Picol) { if (!Picol) {
strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); strcpy(g->Message, MSG(NO_DEF_PIVOTCOL));
return NULL; goto err;
} // endif Picol } // endif Picol
} // endif picol } // endif picol
// Prepare the column list // Prepare the column list
for (pcrp = &Qryp->Colresp; crp = *pcrp; ) for (pcrp = &Qryp->Colresp; crp = *pcrp; )
if (!stricmp(Picol, crp->Name)) { if (SkipColumn(crp, skc)) {
// Ignore this column
*pcrp = crp->Next;
} else if (!stricmp(Picol, crp->Name)) {
if (crp->Nulls) { if (crp->Nulls) {
sprintf(g->Message, "Pivot column %s cannot be nullable", Picol); sprintf(g->Message, "Pivot column %s cannot be nullable", Picol);
return NULL; goto err;
} // endif Nulls } // endif Nulls
Rblkp = crp->Kdata; Rblkp = crp->Kdata;
@@ -179,31 +211,59 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
if (!Rblkp) { if (!Rblkp) {
strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); strcpy(g->Message, MSG(NO_DEF_PIVOTCOL));
return NULL; goto err;
} else if (!fncrp) { } else if (!fncrp) {
strcpy(g->Message, MSG(NO_DEF_FNCCOL)); strcpy(g->Message, MSG(NO_DEF_FNCCOL));
return NULL; goto err;
} // endif } // endif
// Before calling sort, initialize all if (Tabsrc) {
nblin = Qryp->Nblin; Myc.Close();
b = false;
Index.Size = nblin * sizeof(int); // Before calling sort, initialize all
Index.Sub = TRUE; // Should be small enough nblin = Qryp->Nblin;
if (!PlgDBalloc(g, NULL, Index)) Index.Size = nblin * sizeof(int);
return NULL; Index.Sub = TRUE; // Should be small enough
Offset.Size = (nblin + 1) * sizeof(int); if (!PlgDBalloc(g, NULL, Index))
Offset.Sub = TRUE; // Should be small enough return NULL;
if (!PlgDBalloc(g, NULL, Offset)) Offset.Size = (nblin + 1) * sizeof(int);
return NULL; Offset.Sub = TRUE; // Should be small enough
ndif = Qsort(g, nblin); if (!PlgDBalloc(g, NULL, Offset))
return NULL;
if (ndif < 0) // error ndif = Qsort(g, nblin);
return NULL;
if (ndif < 0) // error
return NULL;
} else {
// The query was limited, we must get pivot column values
query = (char*)PlugSubAlloc(g, NULL, 0);
sprintf(query, "SELECT DISTINCT `%s` FROM `%s`", Picol, Tabname);
PlugSubAlloc(g, NULL, strlen(query) + 1);
Myc.FreeResult();
// Send the source command to MySQL
if (Myc.ExecSQL(g, query, &w) == RC_FX)
goto err;
// We must have a storage query to get pivot column values
if (!(qrp = Myc.GetResult(g, true)))
goto err;
Myc.Close();
b = false;
// Get the column list
crp = qrp->Colresp;
Rblkp = crp->Kdata;
ndif = qrp->Nblin;
} // endif Tabsrc
// Allocate the Value used to retieve column names // Allocate the Value used to retieve column names
if (!(valp = AllocateValue(g, Rblkp->GetType(), if (!(valp = AllocateValue(g, Rblkp->GetType(),
@@ -220,7 +280,11 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
crp = fncrp; crp = fncrp;
// Get the value that will be the generated column name // Get the value that will be the generated column name
valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]); if (Tabsrc)
valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]);
else
valp->SetValue_pvblk(Rblkp, i);
colname = valp->GetCharString(buf); colname = valp->GetCharString(buf);
crp->Name = (char*)PlugSubAlloc(g, NULL, strlen(colname) + 1); crp->Name = (char*)PlugSubAlloc(g, NULL, strlen(colname) + 1);
strcpy(crp->Name, colname); strcpy(crp->Name, colname);
@@ -280,11 +344,11 @@ bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
DB = (char*)Tablep->GetQualifier(); DB = (char*)Tablep->GetQualifier();
Tabsrc = (char*)Tablep->GetSrc(); Tabsrc = (char*)Tablep->GetSrc();
Host = Cat->GetStringCatInfo(g, "Host", "localhost"); Host = GetStringCatInfo(g, "Host", "localhost");
User = Cat->GetStringCatInfo(g, "User", "*"); User = GetStringCatInfo(g, "User", "*");
Pwd = Cat->GetStringCatInfo(g, "Password", NULL); Pwd = GetStringCatInfo(g, "Password", NULL);
Picol = Cat->GetStringCatInfo(g, "PivotCol", NULL); Picol = GetStringCatInfo(g, "PivotCol", NULL);
Fncol = Cat->GetStringCatInfo(g, "FncCol", NULL); Fncol = GetStringCatInfo(g, "FncCol", NULL);
// If fncol is like avg(colname), separate Fncol and Function // If fncol is like avg(colname), separate Fncol and Function
if (Fncol && (p1 = strchr(Fncol, '(')) && (p2 = strchr(p1, ')')) && if (Fncol && (p1 = strchr(Fncol, '(')) && (p2 = strchr(p1, ')')) &&
@@ -293,11 +357,11 @@ bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Function = Fncol; Function = Fncol;
Fncol = p1; Fncol = p1;
} else } else
Function = Cat->GetStringCatInfo(g, "Function", "SUM"); Function = GetStringCatInfo(g, "Function", "SUM");
GBdone = Cat->GetBoolCatInfo("Groupby", false); GBdone = GetBoolCatInfo("Groupby", false);
Accept = Cat->GetBoolCatInfo("Accept", false); Accept = GetBoolCatInfo("Accept", false);
Port = Cat->GetIntCatInfo("Port", 3306); Port = GetIntCatInfo("Port", 3306);
Desc = (Tabsrc) ? Tabsrc : Tabname; Desc = (Tabsrc) ? Tabsrc : Tabname;
return FALSE; return FALSE;
} // end of DefineAM } // end of DefineAM

View File

@@ -18,12 +18,13 @@ class PIVAID : public CSORT {
friend class SRCCOL; friend class SRCCOL;
public: public:
// Constructor // Constructor
PIVAID(const char *tab, const char *src, const char *picol, PIVAID(const char *tab, const char *src, const char *picol,
const char *fncol, const char *host, const char *db, const char *fncol, const char *skcol, const char *host,
const char *user, const char *pwd, int port); const char *db, const char *user, const char *pwd, int port);
// Methods // Methods
PQRYRES MakePivotColumns(PGLOBAL g); PQRYRES MakePivotColumns(PGLOBAL g);
bool SkipColumn(PCOLRES crp, char *skc);
// The sorting function // The sorting function
virtual int Qcompare(int *, int *); virtual int Qcompare(int *, int *);
@@ -40,6 +41,7 @@ class PIVAID : public CSORT {
char *Tabsrc; // SQL of source table char *Tabsrc; // SQL of source table
char *Picol; // Pivot column name char *Picol; // Pivot column name
char *Fncol; // Function column name char *Fncol; // Function column name
char *Skcol; // Skipped columns
PVBLK Rblkp; // The value block of the pivot column PVBLK Rblkp; // The value block of the pivot column
int Port; // MySQL port number int Port; // MySQL port number
}; // end of class PIVAID }; // end of class PIVAID
@@ -191,6 +193,6 @@ class SRCCOL : public PRXCOL {
PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src, PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src,
const char *picol, const char *fncol, const char *picol, const char *fncol,
const char *host, const char *db, const char *skcol, const char *host,
const char *user, const char *pwd, const char *db, const char *user,
int port); const char *pwd, int port);

View File

@@ -76,8 +76,8 @@ bool INIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
char buf[8]; char buf[8];
Fn = Cat->GetStringCatInfo(g, "Filename", NULL); Fn = GetStringCatInfo(g, "Filename", NULL);
Cat->GetCharCatInfo("Layout", "C", buf, sizeof(buf)); GetCharCatInfo("Layout", "C", buf, sizeof(buf));
Layout = toupper(*buf); Layout = toupper(*buf);
if (Fn) { if (Fn) {
@@ -90,7 +90,7 @@ bool INIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
return true; return true;
} // endif Fn } // endif Fn
Ln = Cat->GetSizeCatInfo("Secsize", "8K"); Ln = GetSizeCatInfo("Secsize", "8K");
Desc = Fn; Desc = Fn;
return false; return false;
} // end of DefineAM } // end of DefineAM

View File

@@ -111,9 +111,9 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
char *tablist, *dbname, *def = NULL; char *tablist, *dbname, *def = NULL;
Desc = "Table list table"; Desc = "Table list table";
tablist = Cat->GetStringCatInfo(g, "Tablist", ""); tablist = GetStringCatInfo(g, "Tablist", "");
dbname = Cat->GetStringCatInfo(g, "Dbname", "*"); dbname = GetStringCatInfo(g, "Dbname", "*");
def = Cat->GetStringCatInfo(g, "Srcdef", NULL); def = GetStringCatInfo(g, "Srcdef", NULL);
Ntables = 0; Ntables = 0;
if (*tablist) { if (*tablist) {
@@ -155,9 +155,9 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
} // endfor pdb } // endfor pdb
Maxerr = Cat->GetIntCatInfo("Maxerr", 0); Maxerr = GetIntCatInfo("Maxerr", 0);
Accept = Cat->GetBoolCatInfo("Accept", false); Accept = GetBoolCatInfo("Accept", false);
Thread = Cat->GetBoolCatInfo("Thread", false); Thread = GetBoolCatInfo("Thread", false);
} // endif tablist } // endif tablist
return FALSE; return FALSE;

View File

@@ -307,10 +307,10 @@ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
char *pn, *db, *tab, *def = NULL; char *pn, *db, *tab, *def = NULL;
db = Cat->GetStringCatInfo(g, "Dbname", "*"); db = GetStringCatInfo(g, "Dbname", "*");
def = Cat->GetStringCatInfo(g, "Srcdef", NULL); def = GetStringCatInfo(g, "Srcdef", NULL);
if (!(tab = Cat->GetStringCatInfo(g, "Tabname", NULL))) { if (!(tab = GetStringCatInfo(g, "Tabname", NULL))) {
if (!def) { if (!def) {
strcpy(g->Message, "Missing object table definition"); strcpy(g->Message, "Missing object table definition");
return TRUE; return TRUE;

View File

@@ -95,13 +95,13 @@ bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
DOSDEF::DefineAM(g, "BIN", poff); DOSDEF::DefineAM(g, "BIN", poff);
Estimate = Cat->GetIntCatInfo("Estimate", 0); Estimate = GetIntCatInfo("Estimate", 0);
Split = Cat->GetIntCatInfo("Split", (Estimate) ? 0 : 1); Split = GetIntCatInfo("Split", (Estimate) ? 0 : 1);
Header = Cat->GetIntCatInfo("Header", 0); Header = GetIntCatInfo("Header", 0);
// CONNECT must have Block/Last info for VEC tables // CONNECT must have Block/Last info for VEC tables
if (Estimate && !Split && !Header) { if (Estimate && !Split && !Header) {
char *fn = Cat->GetStringCatInfo(g, "Filename", "?"); char *fn = GetStringCatInfo(g, "Filename", "?");
// No separate header file fo urbi tables // No separate header file fo urbi tables
Header = (*fn == '?') ? 3 : 2; Header = (*fn == '?') ? 3 : 2;
@@ -112,7 +112,7 @@ bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
// For packed files the logical record length is calculated in poff // For packed files the logical record length is calculated in poff
if (poff != Lrecl) { if (poff != Lrecl) {
Lrecl = poff; Lrecl = poff;
Cat->SetIntCatInfo("Lrecl", poff); SetIntCatInfo("Lrecl", poff);
} // endif poff } // endif poff
Padded = false; Padded = false;

View File

@@ -335,8 +335,8 @@ PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info)
/***********************************************************************/ /***********************************************************************/
bool WMIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) bool WMIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
Nspace = Cat->GetStringCatInfo(g, "Namespace", "Root\\CimV2"); Nspace = GetStringCatInfo(g, "Namespace", "Root\\CimV2");
Wclass = Cat->GetStringCatInfo(g, "Class", Wclass = GetStringCatInfo(g, "Class",
(!stricmp(Nspace, "root\\cimv2") ? "ComputerSystemProduct" : (!stricmp(Nspace, "root\\cimv2") ? "ComputerSystemProduct" :
!stricmp(Nspace, "root\\cli") ? "Msft_CliAlias" : "")); !stricmp(Nspace, "root\\cli") ? "Msft_CliAlias" : ""));
@@ -349,7 +349,7 @@ bool WMIDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
} // endif Wclass } // endif Wclass
if (Catfunc == FNC_NO) if (Catfunc == FNC_NO)
Ems = Cat->GetIntCatInfo("Estimate", 100); Ems = GetIntCatInfo("Estimate", 100);
return false; return false;
} // end of DefineAM } // end of DefineAM

View File

@@ -78,10 +78,10 @@ bool XCLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
char buf[8]; char buf[8];
Xcol = Cat->GetStringCatInfo(g, "Colname", ""); Xcol = GetStringCatInfo(g, "Colname", "");
Cat->GetCharCatInfo("Separator", ",", buf, sizeof(buf)); GetCharCatInfo("Separator", ",", buf, sizeof(buf));
Sep = (strlen(buf) == 2 && buf[0] == '\\' && buf[1] == 't') ? '\t' : *buf; Sep = (strlen(buf) == 2 && buf[0] == '\\' && buf[1] == 't') ? '\t' : *buf;
Mult = Cat->GetIntCatInfo("Mult", 10); Mult = GetIntCatInfo("Mult", 10);
return PRXDEF::DefineAM(g, am, poff); return PRXDEF::DefineAM(g, am, poff);
} // end of DefineAM } // end of DefineAM

View File

@@ -95,21 +95,21 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
//void *memp = Cat->GetDescp(); //void *memp = Cat->GetDescp();
//PSZ dbfile = Cat->GetDescFile(); //PSZ dbfile = Cat->GetDescFile();
Fn = Cat->GetStringCatInfo(g, "Filename", NULL); Fn = GetStringCatInfo(g, "Filename", NULL);
Encoding = Cat->GetStringCatInfo(g, "Encoding", "UTF-8"); Encoding = GetStringCatInfo(g, "Encoding", "UTF-8");
if (*Fn == '?') { if (*Fn == '?') {
strcpy(g->Message, MSG(MISSING_FNAME)); strcpy(g->Message, MSG(MISSING_FNAME));
return true; return true;
} // endif fn } // endif fn
if ((signed)Cat->GetIntCatInfo("Flag", -1) != -1) { if ((signed)GetIntCatInfo("Flag", -1) != -1) {
strcpy(g->Message, MSG(DEPREC_FLAG)); strcpy(g->Message, MSG(DEPREC_FLAG));
return true; return true;
} // endif flag } // endif flag
defrow = defcol = ""; defrow = defcol = "";
Cat->GetCharCatInfo("Coltype", "", buf, sizeof(buf)); GetCharCatInfo("Coltype", "", buf, sizeof(buf));
switch (toupper(*buf)) { switch (toupper(*buf)) {
case 'A': // Attribute case 'A': // Attribute
@@ -136,25 +136,25 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
return true; return true;
} // endswitch typname } // endswitch typname
Tabname = Cat->GetStringCatInfo(g, "Name", Name); // Deprecated Tabname = GetStringCatInfo(g, "Name", Name); // Deprecated
Tabname = Cat->GetStringCatInfo(g, "Table_name", Tabname); // Deprecated Tabname = GetStringCatInfo(g, "Table_name", Tabname); // Deprecated
Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname); Tabname = GetStringCatInfo(g, "Tabname", Tabname);
Rowname = Cat->GetStringCatInfo(g, "Rownode", defrow); Rowname = GetStringCatInfo(g, "Rownode", defrow);
Colname = Cat->GetStringCatInfo(g, "Colnode", defcol); Colname = GetStringCatInfo(g, "Colnode", defcol);
Mulnode = Cat->GetStringCatInfo(g, "Mulnode", ""); Mulnode = GetStringCatInfo(g, "Mulnode", "");
XmlDB = Cat->GetStringCatInfo(g, "XmlDB", ""); XmlDB = GetStringCatInfo(g, "XmlDB", "");
Nslist = Cat->GetStringCatInfo(g, "Nslist", ""); Nslist = GetStringCatInfo(g, "Nslist", "");
DefNs = Cat->GetStringCatInfo(g, "DefNs", ""); DefNs = GetStringCatInfo(g, "DefNs", "");
Limit = Cat->GetIntCatInfo("Limit", 2); Limit = GetIntCatInfo("Limit", 2);
Xpand = (Cat->GetIntCatInfo("Expand", 0) != 0); Xpand = (GetIntCatInfo("Expand", 0) != 0);
Header = Cat->GetIntCatInfo("Header", 0); Header = GetIntCatInfo("Header", 0);
Cat->GetCharCatInfo("Xmlsup", "*", buf, sizeof(buf)); GetCharCatInfo("Xmlsup", "*", buf, sizeof(buf));
//if (*buf == '*') // Try the old (deprecated) option //if (*buf == '*') // Try the old (deprecated) option
// Cat->GetCharCatInfo("Method", "*", buf, sizeof(buf)); // GetCharCatInfo("Method", "*", buf, sizeof(buf));
//if (*buf == '*') // Is there a default for the database? //if (*buf == '*') // Is there a default for the database?
// Cat->GetCharCatInfo("Defxml", XMLSUP, buf, sizeof(buf)); // GetCharCatInfo("Defxml", XMLSUP, buf, sizeof(buf));
// Note that if no support is specified, the default is MS-DOM // Note that if no support is specified, the default is MS-DOM
// on Windows and libxml2 otherwise // on Windows and libxml2 otherwise
@@ -168,8 +168,8 @@ bool XMLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Usedom = (toupper(*buf) == 'M' || toupper(*buf) == 'D'); Usedom = (toupper(*buf) == 'M' || toupper(*buf) == 'D');
// Get eventual table node attribute // Get eventual table node attribute
Attrib = Cat->GetStringCatInfo(g, "Attribute", ""); Attrib = GetStringCatInfo(g, "Attribute", "");
Hdattr = Cat->GetStringCatInfo(g, "HeadAttr", ""); Hdattr = GetStringCatInfo(g, "HeadAttr", "");
return false; return false;
} // end of DefineAM } // end of DefineAM

View File

@@ -723,7 +723,7 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
return true; return true;
} // endswitch Ftype } // endswitch Ftype
if ((sep = dup->Catalog->GetBoolCatInfo("SepIndex", false))) { if ((sep = defp->GetBoolCatInfo("SepIndex", false))) {
// Index is saved in a separate file // Index is saved in a separate file
#if !defined(UNIX) #if !defined(UNIX)
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
@@ -1627,7 +1627,7 @@ int XINDEX::Fetch(PGLOBAL g)
switch (Op) { switch (Op) {
case OP_NEXT: // Read next case OP_NEXT: // Read next
if (NextVal(false)) if (NextVal(false))
return -1; // End of indexed file return -1; // End of indexed file
break; break;
case OP_FIRST: // Read first case OP_FIRST: // Read first
@@ -1643,7 +1643,7 @@ int XINDEX::Fetch(PGLOBAL g)
if (NextVal(true)) { if (NextVal(true)) {
Op = OP_EQ; Op = OP_EQ;
return -2; // no more equal values return -2; // no more equal values
} // endif NextVal } // endif NextVal
break; break;
@@ -1651,9 +1651,9 @@ int XINDEX::Fetch(PGLOBAL g)
// while (!NextVal(true)) ; // while (!NextVal(true)) ;
// if (Cur_K >= Num_K) // if (Cur_K >= Num_K)
// return -1; // End of indexed file // return -1; // End of indexed file
if (NextValDif()) if (NextValDif())
return -1; // End of indexed file return -1; // End of indexed file
break; break;
case OP_FSTDIF: // Read first diff case OP_FSTDIF: // Read first diff
@@ -1662,12 +1662,17 @@ int XINDEX::Fetch(PGLOBAL g)
Op = (Mul || Nval < Nk) ? OP_NXTDIF : OP_NEXT; Op = (Mul || Nval < Nk) ? OP_NXTDIF : OP_NEXT;
break; break;
case OP_LAST: // Read last key case OP_LAST: // Read last key
for (Cur_K = Num_K - 1, kp = To_KeyCol; kp; kp = kp->Next) for (Cur_K = Num_K - 1, kp = To_KeyCol; kp; kp = kp->Next)
kp->Val_K = kp->Kblp->GetNval() - 1; kp->Val_K = kp->Kblp->GetNval() - 1;
Op = OP_NEXT; Op = OP_NEXT;
break; break;
case OP_PREV: // Read previous
if (PrevVal())
return -1; // End of indexed file
break;
default: // Should be OP_EQ default: // Should be OP_EQ
// if (Tbxp->Key_Rank < 0) { // if (Tbxp->Key_Rank < 0) {
/***************************************************************/ /***************************************************************/