Commit 6b63c5b2 authored by Olivier Bertrand's avatar Olivier Bertrand

- FIX PIVOT bug MDEV-5869 caused by using fop (field option ptr) when NULL.

modified:
  storage/connect/ha_connect.cc

- Suppress the use of connect.in by adding the connect_xtrace system variable.
modified:
  storage/connect/ha_connect.cc

- Make column length, varchar, and temporal column types recognized in discovery
  when using SRCDEF,or PIVOT.
modified:
  storage/connect/ha_connect.cc
  storage/connect/myconn.cpp
  storage/connect/myutil.cpp
  storage/connect/plgdbsem.h

- Avoid (rare) crash when using DECIMAL type. (buf was too small)
modified:
  storage/connect/tabfmt.cpp
  storage/connect/tabmysql.cpp
  storage/connect/tabodbc.cpp
  storage/connect/tabpivot.cpp
  storage/connect/valblk.cpp
  storage/connect/value.cpp

- General cleaning of unused code, standardize tracing, and update version number
modified:
  storage/connect/block.h
  storage/connect/colblk.cpp
  storage/connect/connect.cc
  storage/connect/csort.h
  storage/connect/filamap.cpp
  storage/connect/filamdbf.cpp
  storage/connect/filamfix.cpp
  storage/connect/filamzip.cpp
  storage/connect/ha_connect.cc
  storage/connect/mycat.cc
  storage/connect/myconn.cpp
  storage/connect/mysql-test/connect/r/alter.result
  storage/connect/mysql-test/connect/r/xml.result
  storage/connect/myutil.cpp
  storage/connect/osutil.c
  storage/connect/plgdbsem.h
  storage/connect/plgdbutl.cpp
  storage/connect/plugutil.c
  storage/connect/reldef.cpp
  storage/connect/tabcol.cpp
  storage/connect/tabfmt.cpp
  storage/connect/tabmysql.cpp
  storage/connect/tabodbc.cpp
  storage/connect/tabpivot.cpp
  storage/connect/tabvct.cpp
  storage/connect/user_connect.cc
  storage/connect/valblk.cpp
  storage/connect/value.cpp
  storage/connect/xindex.cpp
parent e5729127
......@@ -38,10 +38,9 @@ typedef class BLOCK *PBLOCK;
class DllExport BLOCK {
public:
void * operator new(size_t size, PGLOBAL g, void *p = NULL) {
#ifdef DEBTRACE
if (debug != NULL)
htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
#endif
// if (trace > 2)
// htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
return (PlugSubAlloc(g, p, size));
} // end of new
......
......@@ -23,6 +23,8 @@
#include "xindex.h"
#include "xtable.h"
extern "C" int trace;
/***********************************************************************/
/* COLBLK protected constructor. */
/***********************************************************************/
......@@ -72,9 +74,8 @@ COLBLK::COLBLK(PCOL col1, PTDB tdbp)
//To_Orig = col1;
To_Tdb = tdbp;
#ifdef DEBTRACE
if (trace > 1)
htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this);
#endif
if (tdbp)
// Attach the new column to the table block
......@@ -112,10 +113,9 @@ bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
{
fmt = Format;
#ifdef DEBTRACE
if (trace > 1)
htrc("COLBLK: %p format=%c(%d,%d)\n",
this, *fmt.Type, fmt.Length, fmt.Prec);
#endif
return false;
} // end of SetFormat
......@@ -126,9 +126,8 @@ bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
/***********************************************************************/
bool COLBLK::Eval(PGLOBAL g)
{
#ifdef DEBTRACE
if (trace > 1)
htrc("Col Eval: %s status=%.4X\n", Name, Status);
#endif
if (!GetStatus(BUF_READ)) {
// if (To_Tdb->IsNull())
......@@ -164,10 +163,9 @@ bool COLBLK::InitValue(PGLOBAL g)
AddStatus(BUF_READY);
Value->SetNullable(Nullable);
#ifdef DEBTRACE
if (trace > 1)
htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
this, Buf_Type, Value, ColUse, Status);
#endif
return false;
} // end of InitValue
......
......@@ -51,7 +51,7 @@
/***********************************************************************/
/* DB static variables. */
/***********************************************************************/
extern int xtrace;
extern "C" int trace;
/***********************************************************************/
/* Routines called internally by semantic routines. */
......@@ -110,14 +110,14 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
bool rc= false;
PDBUSER dbuserp= PlgGetUser(g);
if (xtrace) {
if (trace) {
printf("CntCheckDB: dbuserp=%p\n", dbuserp);
} // endif xtrace
} // endif trace
if (!dbuserp || !handler)
return true;
if (xtrace)
if (trace)
printf("cat=%p oldhandler=%p newhandler=%p\n", dbuserp->Catalog,
(dbuserp->Catalog) ? ((MYCAT*)dbuserp->Catalog)->GetHandler() : NULL,
handler);
......@@ -149,7 +149,7 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
/*********************************************************************/
sprintf(g->Message, MSG(DATABASE_LOADED), "???");
if (xtrace)
if (trace)
printf("msg=%s\n", g->Message);
return rc;
......@@ -193,7 +193,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
PDBUSER dup= PlgGetUser(g);
PCATLG cat= (dup) ? dup->Catalog : NULL; // Safe over longjmp
if (xtrace)
if (trace)
printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat);
if (!cat)
......@@ -213,7 +213,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
// Get table object from the catalog
tabp= new(g) XTAB(name);
if (xtrace)
if (trace)
printf("CntGetTDB: tabp=%p\n", tabp);
// Perhaps this should be made thread safe
......@@ -223,7 +223,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
printf("CntGetTDB: %s\n", g->Message);
err:
if (xtrace)
if (trace)
printf("Returning tdbp=%p mode=%d\n", tdbp, mode);
g->jump_level--;
......@@ -243,7 +243,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
//PCOLUMN cp;
PDBUSER dup= PlgGetUser(g);
if (xtrace)
if (trace)
printf("CntOpenTable: tdbp=%p mode=%d\n", tdbp, mode);
if (!tdbp) {
......@@ -269,7 +269,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
} else for (p= c1; *p; p+= n) {
// Allocate only used column blocks
if (xtrace)
if (trace)
printf("Allocating column %s\n", p);
// if (*p == '*') {
......@@ -337,7 +337,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
((PTDBASE)tdbp)->SetSetCols(tdbp->GetColumns());
// Now do open the physical table
if (xtrace)
if (trace)
printf("Opening table %s in mode %d tdbp=%p\n",
tdbp->GetName(), mode, tdbp);
......@@ -353,7 +353,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
} // endif del
if (xtrace)
if (trace)
printf("About to open the table: tdbp=%p\n", tdbp);
if (mode != MODE_ANY && mode != MODE_ALTER) {
......@@ -394,7 +394,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool mrr)
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
if (xtrace) {
if (trace) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
printf("EvalColumns: %s\n", g->Message);
} // endif
......@@ -403,7 +403,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool mrr)
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level]) != 0) {
if (xtrace)
if (trace)
printf("Error reading columns: %s\n", g->Message);
rc= RC_FX;
......@@ -547,7 +547,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
if (!tdbp || tdbp->GetUse() != USE_OPEN)
return rc; // Nothing to do
if (xtrace)
if (trace)
printf("CntCloseTable: tdbp=%p mode=%d\n", tdbp, tdbp->GetMode());
if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN)
......@@ -571,7 +571,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
g->jump_level--;
if (xtrace > 1)
if (trace > 1)
printf("Table %s closed\n", tdbp->GetName());
//if (!((PTDBDOX)tdbp)->GetModified())
......@@ -580,7 +580,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
if (tdbp->GetMode() == MODE_READ || tdbp->GetMode() == MODE_ANY)
return 0;
if (xtrace > 1)
if (trace > 1)
printf("About to reset indexes\n");
// Make all the eventual indexes
......@@ -590,7 +590,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
rc= tbxp->ResetTableOpt(g, ((PTDBASE)tdbp)->GetDef()->Indexable());
err:
if (xtrace > 1)
if (trace > 1)
printf("Done rc=%d\n", rc);
return (rc == RC_OK || rc == RC_INFO) ? 0 : rc;
......@@ -859,10 +859,10 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
} else
valp->SetBinValue((void*)p);
if (xtrace) {
if (trace) {
char bf[32];
printf("i=%d n=%d key=%s\n", i, n, valp->GetCharString(bf));
} // endif xtrace
} // endif trace
p+= valp->GetClen();
......@@ -881,7 +881,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
xbp->SetNval(n);
if (xtrace)
if (trace)
printf("xbp=%p Nval=%d i=%d incl=%d\n", xbp, n, i, incl[i]);
k[i]= xbp->Range(g, i + 1, incl[i]);
......@@ -890,7 +890,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
} // endfor i
if (xtrace)
if (trace)
printf("k1=%d k0=%d\n", k[1], k[0]);
return k[1] - k[0];
......
......@@ -22,9 +22,7 @@
#define THRESH 4 /* Threshold for insertion (was 4) */
#define MTHRESH 6 /* Threshold for median */
#ifdef DEBTRACE
extern FILE *debug; /* Debug file */
#endif
//extern FILE *debug; /* Debug file */
typedef int* const CPINT;
......
......@@ -46,6 +46,8 @@
#include "filamap.h"
#include "tabdos.h"
extern "C" int trace;
/* --------------------------- Class MAPFAM -------------------------- */
/***********************************************************************/
......@@ -89,9 +91,8 @@ int MAPFAM::GetFileLength(PGLOBAL g)
len = (To_Fb) ? To_Fb->Length : TXTFAM::GetFileLength(g);
#ifdef DEBTRACE
if (trace)
htrc("Mapped file length=%d\n", len);
#endif
return len;
} // end of GetFileLength
......@@ -128,9 +129,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
&& fp->Count && fp->Mode == mode)
break;
#ifdef DEBTRACE
if (trace)
htrc("Mapping file, fp=%p\n", fp);
#endif
} else
fp = NULL;
......@@ -166,9 +167,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
"map", (int) rc, filename);
#ifdef DEBTRACE
htrc("%s\n", g->Message);
#endif
if (trace)
htrc("CreateFileMap: %s\n", g->Message);
return (mode == MODE_READ && rc == ENOENT)
? PushWarning(g, Tdbp) : true;
} // endif hFile
......@@ -228,10 +229,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
Fpos = Mempos = Memory;
Top = Memory + len;
#ifdef DEBTRACE
if (trace)
htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n",
fp, fp->Count, Memory, len, Top);
#endif
return AllocateBuffer(g); // Useful for DBF files
} // end of OpenTableFile
......@@ -365,20 +365,19 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
{
int n;
#ifdef DEBTRACE
fprintf(debug,
"MAP DeleteDB: irc=%d mempos=%p tobuf=%p Tpos=%p Spos=%p\n",
if (trace)
htrc("MAP DeleteDB: irc=%d mempos=%p tobuf=%p Tpos=%p Spos=%p\n",
irc, Mempos, To_Buf, Tpos, Spos);
#endif
if (irc != RC_OK) {
/*******************************************************************/
/* EOF: position Fpos at the top of map position. */
/*******************************************************************/
Fpos = Top;
#ifdef DEBTRACE
if (trace)
htrc("Fpos placed at file top=%p\n", Fpos);
#endif
} // endif irc
if (Tpos == Spos)
......@@ -394,17 +393,16 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
memmove(Tpos, Spos, n);
Tpos += n;
#ifdef DEBTRACE
if (trace)
htrc("move %d bytes\n", n);
#endif
} // endif n
if (irc == RC_OK) {
Spos = Mempos; // New start position
#ifdef DEBTRACE
if (trace)
htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos);
#endif
} else if (To_Fb) { // Can be NULL for deleted files
/*******************************************************************/
......@@ -432,9 +430,8 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
return RC_FX;
} // endif
#ifdef DEBTRACE
if (trace)
htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
#endif
if (!SetEndOfFile(fp->Handle)) {
sprintf(g->Message, MSG(FUNCTION_ERROR),
......@@ -466,10 +463,10 @@ void MAPFAM::CloseTableFile(PGLOBAL g)
PlugCloseFile(g, To_Fb);
To_Fb = NULL; // To get correct file size in Cardinality
#ifdef DEBTRACE
if (trace)
htrc("MAP Close: closing %s count=%d\n",
To_File, (To_Fb) ? To_Fb->Count : 0);
#endif
} // end of CloseTableFile
/***********************************************************************/
......
......@@ -485,16 +485,15 @@ bool DBFFAM::OpenTableFile(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath());
if (!(Stream = PlugOpenFile(g, filename, opmode))) {
#ifdef DEBTRACE
if (trace)
htrc("%s\n", g->Message);
#endif
return (mode == MODE_READ && errno == ENOENT)
? PushWarning(g, Tdbp) : true;
} // endif Stream
#ifdef DEBTRACE
if (trace)
htrc("File %s is open in mode %s\n", filename, opmode);
#endif
To_Fb = dbuserp->Openlist; // Keep track of File block
......@@ -853,10 +852,10 @@ void DBFFAM::CloseTableFile(PGLOBAL g)
rc = PlugCloseFile(g, To_Fb);
fin:
#ifdef DEBTRACE
if (trace)
htrc("DBF CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
To_File, mode, wrc, rc);
#endif
Stream = NULL; // So we can know whether table is open
} // end of CloseTableFile
......
......@@ -52,6 +52,7 @@
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
#endif
extern "C" int trace;
extern int num_read, num_there, num_eq[2]; // Statistics
/* --------------------------- Class FIXFAM -------------------------- */
......@@ -230,9 +231,8 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
return RC_FX;
} // endif fseek
#ifdef DEBTRACE
if (trace > 1)
htrc("File position is now %d\n", ftell(Stream));
#endif
//long tell = ftell(Stream); not used
......@@ -255,9 +255,9 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
#endif
#ifdef DEBTRACE
if (trace)
htrc("%s\n", g->Message);
#endif
return RC_FX;
} // endelse
......@@ -272,11 +272,9 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
/***********************************************************************/
int FIXFAM::WriteBuffer(PGLOBAL g)
{
#ifdef DEBTRACE
fprintf(debug,
"FIX WriteDB: Mode=%d buf=%p line=%p Nrec=%d Rbuf=%d CurNum=%d\n",
if (trace > 1)
htrc("FIX WriteDB: Mode=%d buf=%p line=%p Nrec=%d Rbuf=%d CurNum=%d\n",
Tdbp->GetMode(), To_Buf, Tdbp->GetLine(), Nrec, Rbuf, CurNum);
#endif
if (Tdbp->GetMode() == MODE_INSERT) {
/*******************************************************************/
......@@ -287,9 +285,8 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
return RC_OK; // We write only full blocks
} // endif CurNum
#ifdef DEBTRACE
if (trace > 1)
htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf);
#endif
// Now start the writing process.
if (fwrite(To_Buf, Lrecl, Rbuf, Stream) != (size_t)Rbuf) {
......@@ -302,9 +299,8 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
CurNum = 0;
Tdbp->SetLine(To_Buf);
#ifdef DEBTRACE
if (trace > 1)
htrc("write done\n");
#endif
} else { // Mode == MODE_UPDATE
// T_Stream is the temporary stream or the table file stream itself
......@@ -342,20 +338,19 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc)
/* file, and at the end erase all trailing records. */
/* This will be experimented. */
/*********************************************************************/
#ifdef DEBTRACE
fprintf(debug,
"DOS DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
if (trace > 1)
htrc("DOS DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
irc, UseTemp, Fpos, Tpos, Spos);
#endif
if (irc != RC_OK) {
/*******************************************************************/
/* EOF: position Fpos at the end-of-file position. */
/*******************************************************************/
Fpos = Tdbp->Cardinality(g);
#ifdef DEBTRACE
if (trace > 1)
htrc("Fpos placed at file end=%d\n", Fpos);
#endif
} else // Fpos is the deleted line position
Fpos = CurBlk * Nrec + CurNum;
......@@ -403,9 +398,8 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc)
OldBlk = -2; // To force fseek to be executed on next block
} // endif moved
#ifdef DEBTRACE
if (trace > 1)
htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
#endif
} else {
/*******************************************************************/
......@@ -453,9 +447,9 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc)
close(h);
#ifdef DEBTRACE
if (trace > 1)
htrc("done, h=%d irc=%d\n", h, irc);
#endif
} // endif UseTemp
} // endif irc
......@@ -485,9 +479,8 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
req = (size_t)min(n, Dbflen);
len = fread(DelBuf, Lrecl, req, Stream);
#ifdef DEBTRACE
if (trace > 1)
htrc("after read req=%d len=%d\n", req, len);
#endif
if (len != req) {
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
......@@ -505,16 +498,14 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
return true;
} // endif
#ifdef DEBTRACE
if (trace > 1)
htrc("after write pos=%d\n", ftell(Stream));
#endif
Tpos += (int)req;
Spos += (int)req;
#ifdef DEBTRACE
if (trace > 1)
htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
#endif
*b = true;
} // endfor n
......@@ -563,10 +554,10 @@ void FIXFAM::CloseTableFile(PGLOBAL g)
rc = PlugCloseFile(g, To_Fb);
fin:
#ifdef DEBTRACE
if (trace)
htrc("FIX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
To_File, mode, wrc, rc);
#endif
Stream = NULL; // So we can know whether table is open
} // end of CloseTableFile
......@@ -630,9 +621,8 @@ int BGXFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
DWORD nbr, drc, len = (DWORD)req;
bool brc = ReadFile(h, inbuf, len, &nbr, NULL);
#ifdef DEBTRACE
if (trace > 1)
htrc("after read req=%d brc=%d nbr=%d\n", req, brc, nbr);
#endif
if (!brc) {
char buf[256]; // , *fn = (h == Hfile) ? To_File : "Tempfile";
......@@ -642,9 +632,10 @@ int BGXFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
sprintf(g->Message, MSG(READ_ERROR), To_File, buf);
#ifdef DEBTRACE
if (trace > 1)
htrc("BIGREAD: %s\n", g->Message);
#endif
rc = -1;
} else
rc = (int)nbr;
......@@ -669,9 +660,8 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
DWORD nbw, drc, len = (DWORD)req;
bool brc = WriteFile(h, inbuf, len, &nbw, NULL);
#ifdef DEBTRACE
if (trace > 1)
htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
#endif
if (!brc || nbw != len) {
char buf[256], *fn = (h == Hfile) ? To_File : "Tempfile";
......@@ -687,10 +677,10 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
sprintf(g->Message, MSG(WRITE_STRERROR), fn, buf);
#ifdef DEBTRACE
if (trace > 1)
htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
nbw, len, drc, g->Message);
#endif
rc = true;
} // endif brc || nbw
#else // !WIN32
......@@ -701,10 +691,11 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
const char *fn = (h == Hfile) ? To_File : "Tempfile";
sprintf(g->Message, MSG(WRITE_STRERROR), fn, strerror(errno));
#ifdef DEBTRACE
if (trace > 1)
htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
nbw, len, errno, g->Message);
#endif
rc = true;
} // endif nbr
#endif // !WIN32
......@@ -739,9 +730,8 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath());
#ifdef DEBTRACE
if (trace)
htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode);
#endif
#if defined(WIN32)
DWORD rc, access, creation, share = 0;
......@@ -800,11 +790,9 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
} else
rc = 0;
#ifdef DEBTRACE
fprintf(debug,
" rc=%d access=%p share=%p creation=%d handle=%p fn=%s\n",
if (trace > 1)
htrc(" rc=%d access=%p share=%p creation=%d handle=%p fn=%s\n",
rc, access, share, creation, Hfile, filename);
#endif
if (mode == MODE_INSERT)
/*******************************************************************/
......@@ -855,10 +843,9 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
} else
rc = 0;
#ifdef DEBTRACE
if (trace > 1)
htrc(" rc=%d oflag=%p tmode=%p handle=%p fn=%s\n",
rc, oflag, tmode, Hfile, filename);
#endif
#endif // UNIX
......@@ -940,14 +927,13 @@ int BGXFAM::Cardinality(PGLOBAL g)
if (Hfile == INVALID_HANDLE_VALUE) {
int h = open64(filename, O_RDONLY, 0);
#ifdef DEBTRACE
if (trace)
htrc(" h=%d\n", h);
#endif
if (h == INVALID_HANDLE_VALUE) {
#ifdef DEBTRACE
if (trace)
htrc(" errno=%d ENOENT=%d\n", errno, ENOENT);
#endif
if (errno != ENOENT) {
sprintf(g->Message, MSG(OPEN_ERROR_IS),
filename, strerror(errno));
......@@ -989,10 +975,9 @@ int BGXFAM::Cardinality(PGLOBAL g)
} else
card = (int)(fsize / (BIGINT)Lrecl); // Fixed length file
#ifdef DEBTRACE
if (trace)
htrc(" Computed max_K=%d fsize=%lf lrecl=%d\n",
card, (double)fsize, Lrecl);
#endif
// Set number of blocks for later use
Block = (card + Nrec - 1) / Nrec;
......@@ -1078,9 +1063,8 @@ int BGXFAM::ReadBuffer(PGLOBAL g)
if (BigSeek(g, Hfile, (BIGINT)Fpos * (BIGINT)Lrecl))
return RC_FX;
#ifdef DEBTRACE
if (trace > 1)
htrc("File position is now %d\n", Fpos);
#endif
nbr = BigRead(g, Hfile, To_Buf, (Padded) ? Blksize : Lrecl * Nrec);
......@@ -1103,11 +1087,9 @@ int BGXFAM::ReadBuffer(PGLOBAL g)
/***********************************************************************/
int BGXFAM::WriteBuffer(PGLOBAL g)
{
#ifdef DEBTRACE
fprintf(debug,
"BIG WriteDB: Mode=%d buf=%p line=%p Nrec=%d Rbuf=%d CurNum=%d\n",
if (trace > 1)
htrc("BIG WriteDB: Mode=%d buf=%p line=%p Nrec=%d Rbuf=%d CurNum=%d\n",
Tdbp->GetMode(), To_Buf, Tdbp->GetLine(), Nrec, Rbuf, CurNum);
#endif
if (Tdbp->GetMode() == MODE_INSERT) {
/*******************************************************************/
......@@ -1118,9 +1100,8 @@ int BGXFAM::WriteBuffer(PGLOBAL g)
return RC_OK; // We write only full blocks
} // endif CurNum
#ifdef DEBTRACE
if (trace > 1)
htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf);
#endif
// Now start the writing process.
if (BigWrite(g, Hfile, To_Buf, Lrecl * Rbuf))
......@@ -1130,9 +1111,8 @@ int BGXFAM::WriteBuffer(PGLOBAL g)
CurNum = 0;
Tdbp->SetLine(To_Buf);
#ifdef DEBTRACE
if (trace > 1)
htrc("write done\n");
#endif
} else { // Mode == MODE_UPDATE
// Tfile is the temporary file or the table file handle itself
......@@ -1167,20 +1147,19 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
/* file, and at the end erase all trailing records. */
/* This will be experimented. */
/*********************************************************************/
#ifdef DEBTRACE
fprintf(debug,
"BGX DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
if (trace > 1)
htrc("BGX DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
irc, UseTemp, Fpos, Tpos, Spos);
#endif
if (irc != RC_OK) {
/*******************************************************************/
/* EOF: position Fpos at the end-of-file position. */
/*******************************************************************/
Fpos = Tdbp->Cardinality(g);
#ifdef DEBTRACE
if (trace > 1)
htrc("Fpos placed at file end=%d\n", Fpos);
#endif
} else // Fpos is the deleted line position
Fpos = CurBlk * Nrec + CurNum;
......@@ -1216,9 +1195,9 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
return RC_FX;
if (irc == RC_OK) {
#ifdef DEBTRACE
if (trace)
assert(Spos == Fpos);
#endif
Spos++; // New start position is on next line
if (moved) {
......@@ -1228,9 +1207,8 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
OldBlk = -2; // To force fseek to be executed on next block
} // endif moved
#ifdef DEBTRACE
if (trace > 1)
htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
#endif
} else {
/*******************************************************************/
......@@ -1362,9 +1340,8 @@ bool BGXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
Tpos += (int)req;
Spos += (int)req;
#ifdef DEBTRACE
if (trace > 1)
htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
#endif
*b = true;
} // endfor n
......@@ -1412,10 +1389,10 @@ void BGXFAM::CloseTableFile(PGLOBAL g)
rc = PlugCloseFile(g, To_Fb);
fin:
#ifdef DEBTRACE
if (trace)
htrc("BGX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
To_File, mode, wrc, rc);
#endif
Hfile = INVALID_HANDLE_VALUE; // So we can know whether table is open
} // end of CloseTableFile
......
......@@ -62,6 +62,7 @@
/* DB static variables. */
/***********************************************************************/
extern int num_read, num_there, num_eq[]; // Statistics
extern "C" int trace;
/* ------------------------------------------------------------------- */
......@@ -203,9 +204,8 @@ bool ZIPFAM::AllocateBuffer(PGLOBAL g)
Buflen = Lrecl + 2; // Lrecl does not include CRLF
//Buflen *= ((Mode == MODE_DELETE) ? DOS_BUFF_LEN : 1); NIY
#ifdef DEBTRACE
if (trace)
htrc("SubAllocating a buffer of %d bytes\n", Buflen);
#endif
To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen);
......@@ -331,9 +331,9 @@ int ZIPFAM::ReadBuffer(PGLOBAL g)
} else
rc = Zerror(g);
#ifdef DEBTRACE
if (trace > 1)
htrc(" Read: '%s' rc=%d\n", To_Buf, rc);
#endif
return rc;
} // end of ReadBuffer
......@@ -373,9 +373,8 @@ void ZIPFAM::CloseTableFile(PGLOBAL g)
{
int rc = gzclose(Zfile);
#ifdef DEBTRACE
if (trace)
htrc("ZIP CloseDB: closing %s rc=%d\n", To_File, rc);
#endif
Zfile = NULL; // So we can know whether table is open
//To_Fb->Count = 0; // Avoid double closing by PlugCloseAll
......@@ -599,9 +598,8 @@ void ZBKFAM::CloseTableFile(PGLOBAL g)
} else
rc = gzclose(Zfile);
#ifdef DEBTRACE
if (trace)
htrc("ZIP CloseDB: closing %s rc=%d\n", To_File, rc);
#endif
Zfile = NULL; // So we can know whether table is open
//To_Fb->Count = 0; // Avoid double closing by PlugCloseAll
......
......@@ -108,9 +108,6 @@
#include "sql_parse.h"
#include "sql_base.h"
#include <sys/stat.h>
#if defined(NEW_WAY)
#include "sql_table.h"
#endif // NEW_WAY
#undef OFFSET
#define NOPARSE
......@@ -143,35 +140,23 @@
#include "myutil.h"
#include "preparse.h"
#include "inihandl.h"
#define PLGXINI "plgcnx.ini" /* Configuration settings file */
#define my_strupr(p) my_caseup_str(default_charset_info, (p));
#define my_strlwr(p) my_casedn_str(default_charset_info, (p));
#define my_stricmp(a,b) my_strcasecmp(default_charset_info, (a), (b))
#ifdef LIBXML2_SUPPORT
#if defined(LIBXML2_SUPPORT)
#include "libdoc.h"
#endif // LIBXML2_SUPPORT
#include "taboccur.h"
#include "tabpivot.h"
#define my_strupr(p) my_caseup_str(default_charset_info, (p));
#define my_strlwr(p) my_casedn_str(default_charset_info, (p));
#define my_stricmp(a,b) my_strcasecmp(default_charset_info, (a), (b))
/***********************************************************************/
/* DB static variables. */
/***********************************************************************/
extern "C" char plgxini[];
extern "C" char plgini[];
extern "C" char nmfile[];
extern "C" char pdebug[];
/***********************************************************************/
/* Initialize the ha_connect static members. */
/***********************************************************************/
#define CONNECT_INI "connect.ini"
//efine CONNECT_INI "connect.ini"
extern "C" {
char connectini[_MAX_PATH]= CONNECT_INI;
char version[]= "Version 1.02.0001 February 03, 2014";
char version[]= "Version 1.02.0002 March 16, 2014";
#if defined(XMSG)
char msglang[]; // Default message language
......@@ -179,7 +164,8 @@ extern "C" {
int trace= 0; // The general trace value
} // extern "C"
int xtrace= 0;
static int xtrace= 0;
ulong ha_connect::num= 0;
//int DTVAL::Shift= 0;
......@@ -199,7 +185,15 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
TABLE_SHARE *table_s,
HA_CREATE_INFO *info);
handlerton *connect_hton;
static void update_connect_xtrace(MYSQL_THD thd,
struct st_mysql_sys_var *var,
void *var_ptr, const void *save)
{
xtrace= *(int *)save;
//xtrace= *(int *)var_ptr= *(int *)save;
} // end of update_connect_xtrace
handlerton *connect_hton;
/**
CREATE TABLE option list (table options)
......@@ -340,31 +334,15 @@ static const char *ha_connect_exts[]= {
static int connect_init_func(void *p)
{
DBUG_ENTER("connect_init_func");
char dir[_MAX_PATH - sizeof(CONNECT_INI) - 1];
#ifdef LIBXML2_SUPPORT
XmlInitParserLib();
#endif // LIBXML2_SUPPORT
/* Build connect.ini file name */
my_getwd(dir, sizeof(dir) - 1, MYF(0));
snprintf(connectini, sizeof(connectini), "%s%s", dir, CONNECT_INI);
sql_print_information("CONNECT: %s=%s", CONNECT_INI, connectini);
sql_print_information("CONNECT: %s", version);
if ((xtrace= GetPrivateProfileInt("CONNECT", "Trace", 0, connectini)))
{
sql_print_information("CONNECT: xtrace=%d", xtrace);
sql_print_information("CONNECT: plgini=%s", plgini);
sql_print_information("CONNECT: plgxini=%s", plgxini);
sql_print_information("CONNECT: nmfile=%s", nmfile);
sql_print_information("CONNECT: pdebug=%s", pdebug);
sql_print_information("CONNECT: version=%s", version);
// xtrace is now a system variable
trace= xtrace;
} // endif xtrace
#if !defined(WIN32)
PROFILE_Close(connectini);
#endif // !WIN32
#ifdef LIBXML2_SUPPORT
XmlInitParserLib();
#endif // LIBXML2_SUPPORT
init_connect_psi_keys();
......@@ -593,6 +571,7 @@ ulonglong ha_connect::table_flags() const
ulonglong flags= HA_CAN_VIRTUAL_COLUMNS | HA_REC_NOT_IN_SEQ |
HA_NO_AUTO_INCREMENT | HA_NO_PREFIX_CHAR_KEYS |
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
HA_PARTIAL_COLUMN_READ |
// HA_NULL_IN_KEY | not implemented yet
// HA_FAST_KEY_READ | causes error when sorting (???)
HA_NO_TRANSACTIONS | HA_DUPLICATE_KEY_NOT_IN_ORDER |
......@@ -966,7 +945,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
break;
case TYPE_DATE:
// Field_length is only used for DATE columns
if (fop->fldlen)
if (fop && fop->fldlen)
pcf->Length= (int)fop->fldlen;
else {
int len;
......@@ -2957,7 +2936,7 @@ bool ha_connect::IsSameIndex(PIXDEF xp1, PIXDEF xp2)
MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
MODE newmode, bool *chk, bool *cras)
{
if (xtrace) {
if ((trace= xtrace)) {
LEX_STRING *query_string= thd_query_string(thd);
htrc("%p check_mode: cmdtype=%d\n", this, thd_sql_command(thd));
htrc("Cmd=%.*s\n", (int) query_string->length, query_string->str);
......@@ -3648,83 +3627,6 @@ static char *encode(PGLOBAL g, char *cnm)
@return
Return 0 if ok
*/
#if defined(NEW_WAY)
static bool add_fields(PGLOBAL g,
THD *thd,
Alter_info *alter_info,
char *name,
int typ, int len, int dec,
uint type_modifier,
char *rem,
// CHARSET_INFO *cs,
// void *vcolinfo,
// engine_option_value *create_options,
int flg,
bool dbf,
char v)
{
register Create_field *new_field;
char *length, *decimals= NULL;
enum_field_types type;
//Virtual_column_info *vcol_info= (Virtual_column_info *)vcolinfo;
engine_option_value *crop;
LEX_STRING *comment;
LEX_STRING *field_name;
DBUG_ENTER("ha_connect::add_fields");
if (len) {
if (!v && typ == TYPE_STRING && len > 255)
v= 'V'; // Change CHAR to VARCHAR
length= (char*)PlugSubAlloc(g, NULL, 8);
sprintf(length, "%d", len);
if (typ == TYPE_DOUBLE) {
decimals= (char*)PlugSubAlloc(g, NULL, 8);
sprintf(decimals, "%d", min(dec, (min(len, 31) - 1)));
} // endif dec
} else
length= NULL;
if (!rem)
rem= "";
type= PLGtoMYSQL(typ, dbf, v);
comment= thd->make_lex_string(rem, strlen(rem));
field_name= thd->make_lex_string(name, strlen(name));
switch (v) {
case 'Z': type_modifier|= ZEROFILL_FLAG;
case 'U': type_modifier|= UNSIGNED_FLAG; break;
} // endswitch v
if (flg) {
engine_option_value *start= NULL, *end= NULL;
LEX_STRING *flag= thd->make_lex_string("flag", 4);
crop= new(thd->mem_root) engine_option_value(*flag, (ulonglong)flg,
&start, &end, thd->mem_root);
} else
crop= NULL;
if (check_string_char_length(field_name, "", NAME_CHAR_LEN,
system_charset_info, 1)) {
my_error(ER_TOO_LONG_IDENT, MYF(0), field_name->str); /* purecov: inspected */
DBUG_RETURN(1); /* purecov: inspected */
} // endif field_name
if (!(new_field= new Create_field()) ||
new_field->init(thd, field_name->str, type, length, decimals,
type_modifier, NULL, NULL, comment, NULL,
NULL, NULL, 0, NULL, crop, true))
DBUG_RETURN(1);
alter_info->create_list.push_back(new_field);
DBUG_RETURN(0);
} // end of add_fields
#else // !NEW_WAY
static bool add_field(String *sql, const char *field_name, int typ,
int len, int dec, uint tm, const char *rem,
char *dft, char *xtra, int flag, bool dbf, char v)
......@@ -3738,7 +3640,7 @@ static bool add_field(String *sql, const char *field_name, int typ,
error|= sql->append("` ");
error|= sql->append(type);
if (len) {
if (len && typ != TYPE_DATE) {
error|= sql->append('(');
error|= sql->append_ulonglong(len);
......@@ -3794,7 +3696,6 @@ static bool add_field(String *sql, const char *field_name, int typ,
error|= sql->append(',');
return error;
} // end of add_field
#endif // !NEW_WAY
/**
Initialise the table share with the new columns.
......@@ -3802,110 +3703,6 @@ static bool add_field(String *sql, const char *field_name, int typ,
@return
Return 0 if ok
*/
#if defined(NEW_WAY)
//static bool sql_unusable_for_discovery(THD *thd, const char *sql);
static int init_table_share(THD *thd,
TABLE_SHARE *table_s,
HA_CREATE_INFO *create_info,
Alter_info *alter_info)
{
KEY *not_used_1;
uint not_used_2;
int rc= 0;
handler *file;
LEX_CUSTRING frm= {0,0};
DBUG_ENTER("init_table_share");
#if 0
ulonglong saved_mode= thd->variables.sql_mode;
CHARSET_INFO *old_cs= thd->variables.character_set_client;
Parser_state parser_state;
char *sql_copy;
LEX *old_lex;
Query_arena *arena, backup;
LEX tmp_lex;
/*
Ouch. Parser may *change* the string it's working on.
Currently (2013-02-26) it is used to permanently disable
conditional comments.
Anyway, let's copy the caller's string...
*/
if (!(sql_copy= thd->strmake(sql, sql_length)))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
if (parser_state.init(thd, sql_copy, sql_length))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
thd->variables.sql_mode= MODE_NO_ENGINE_SUBSTITUTION | MODE_NO_DIR_IN_CREATE;
thd->variables.character_set_client= system_charset_info;
old_lex= thd->lex;
thd->lex= &tmp_lex;
arena= thd->stmt_arena;
if (arena->is_conventional())
arena= 0;
else
thd->set_n_backup_active_arena(arena, &backup);
lex_start(thd);
if ((error= parse_sql(thd, & parser_state, NULL)))
goto ret;
if (table_s->sql_unusable_for_discovery(thd, NULL)) {
my_error(ER_SQL_DISCOVER_ERROR, MYF(0), plugin_name(db_plugin)->str,
db.str, table_name.str, sql_copy);
goto ret;
} // endif unusable
thd->lex->create_info.db_type= plugin_data(db_plugin, handlerton *);
if (tabledef_version.str)
thd->lex->create_info.tabledef_version= tabledef_version;
#endif // 0
tmp_disable_binlog(thd);
file= mysql_create_frm_image(thd, table_s->db.str, table_s->table_name.str,
create_info, alter_info, C_ORDINARY_CREATE,
&not_used_1, &not_used_2, &frm);
if (file)
delete file;
else
rc= OPEN_FRM_CORRUPTED;
if (!rc && frm.str) {
table_s->option_list= 0; // cleanup existing options ...
table_s->option_struct= 0; // ... if it's an assisted discovery
rc= table_s->init_from_binary_frm_image(thd, true, frm.str, frm.length);
} // endif frm
//ret:
my_free(const_cast<uchar*>(frm.str));
reenable_binlog(thd);
#if 0
lex_end(thd->lex);
thd->lex= old_lex;
if (arena)
thd->restore_active_arena(arena, &backup);
thd->variables.sql_mode= saved_mode;
thd->variables.character_set_client= old_cs;
#endif // 0
if (thd->is_error() || rc) {
thd->clear_error();
my_error(ER_NO_SUCH_TABLE, MYF(0), table_s->db.str,
table_s->table_name.str);
DBUG_RETURN(HA_ERR_NOT_A_TABLE);
} else
DBUG_RETURN(0);
} // end of init_table_share
#else // !NEW_WAY
static int init_table_share(THD* thd,
TABLE_SHARE *table_s,
HA_CREATE_INFO *create_info,
......@@ -3997,23 +3794,6 @@ static int init_table_share(THD* thd,
return table_s->init_from_sql_statement_string(thd, true,
sql->ptr(), sql->length());
} // end of init_table_share
#endif // !NEW_WAY
// Add an option to the create_info option list
static void add_option(THD* thd, HA_CREATE_INFO *create_info,
const char *opname, const char *opval)
{
#if defined(NEW_WAY)
LEX_STRING *opn= thd->make_lex_string(opname, strlen(opname));
LEX_STRING *val= thd->make_lex_string(opval, strlen(opval));
engine_option_value *pov, **start= &create_info->option_list, *end= NULL;
for (pov= *start; pov; pov= pov->next)
end= pov;
pov= new(thd->mem_root) engine_option_value(*opn, *val, false, start, &end);
#endif // NEW_WAY
} // end of add_option
// Used to check whether a MYSQL table is created on itself
static bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host,
......@@ -4068,15 +3848,10 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
PCONNECT xp= NULL;
PGLOBAL g= GetPlug(thd, xp);
PTOS topt= table_s->option_struct;
#if defined(NEW_WAY)
//CHARSET_INFO *cs;
Alter_info alter_info;
#else // !NEW_WAY
char buf[1024];
String sql(buf, sizeof(buf), system_charset_info);
sql.copy(STRING_WITH_LEN("CREATE TABLE whatever ("), system_charset_info);
#endif // !NEW_WAY
if (!g)
return HA_ERR_INTERNAL_ERROR;
......@@ -4133,7 +3908,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
ttp= GetTypeID(topt->type);
sprintf(g->Message, "No table_type. Was set to %s", topt->type);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
add_option(thd, create_info, "table_type", topt->type);
} else if (ttp == TAB_NIY) {
sprintf(g->Message, "Unsupported table type %s", topt->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
......@@ -4166,9 +3940,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
} else if (ttp != TAB_ODBC || !(fnc & (FNC_TABLE | FNC_COL)))
tab= table_s->table_name.str; // Default value
#if defined(NEW_WAY)
// add_option(thd, create_info, "tabname", tab);
#endif // NEW_WAY
} // endif tab
switch (ttp) {
......@@ -4400,20 +4171,16 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
len= crp->Length;
dec= crp->Prec;
flg= crp->Flag;
v= crp->Var;
if (!len && typ == TYPE_STRING)
len= 256; // STRBLK's have 0 length
#if defined(NEW_WAY)
// Now add the field
rc= add_fields(g, thd, &alter_info, cnm, typ, len, dec,
NOT_NULL_FLAG, "", flg, dbf, 0);
#else // !NEW_WAY
// Now add the field
if (add_field(&sql, cnm, typ, len, dec, NOT_NULL_FLAG,
NULL, NULL, NULL, flg, dbf, 0))
NULL, NULL, NULL, flg, dbf, v))
rc= HA_ERR_OUT_OF_MEM;
#endif // !NEW_WAY
} // endfor crp
} else // Not a catalog table
......@@ -4422,12 +4189,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
tm= NOT_NULL_FLAG;
cnm= (char*)"noname";
dft= xtra= NULL;
#if defined(NEW_WAY)
rem= "";
// cs= NULL;
#else // !NEW_WAY
rem= NULL;
#endif // !NEW_WAY
for (crp= qrp->Colresp; crp; crp= crp->Next)
switch (crp->Fld) {
......@@ -4504,23 +4266,14 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
prec= len;
// Now add the field
#if defined(NEW_WAY)
rc= add_fields(g, thd, &alter_info, cnm, typ, prec, dec,
tm, rem, 0, dbf, v);
#else // !NEW_WAY
if (add_field(&sql, cnm, typ, prec, dec, tm, rem, dft, xtra,
0, dbf, v))
rc= HA_ERR_OUT_OF_MEM;
#endif // !NEW_WAY
} // endfor i
#if defined(NEW_WAY)
rc= init_table_share(thd, table_s, create_info, &alter_info);
#else // !NEW_WAY
if (!rc)
rc= init_table_share(thd, table_s, create_info, &sql);
// rc= init_table_share(thd, table_s, create_info, dsn, &sql);
#endif // !NEW_WAY
return rc;
} // endif ok
......@@ -5392,6 +5145,15 @@ bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *info,
struct st_mysql_storage_engine connect_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
static MYSQL_SYSVAR_INT(xtrace, xtrace,
PLUGIN_VAR_RQCMDARG, "Console trace value.",
NULL, update_connect_xtrace, 0, 0, INT_MAX, 1);
static struct st_mysql_sys_var* connect_system_variables[]= {
MYSQL_SYSVAR(xtrace),
NULL
};
maria_declare_plugin(connect)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
......@@ -5404,7 +5166,7 @@ maria_declare_plugin(connect)
connect_done_func, /* Plugin Deinit */
0x0102, /* version number (1.02) */
NULL, /* status variables */
NULL, /* system variables */
connect_system_variables, /* system variables */
"1.02", /* string version */
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
}
......
......@@ -96,7 +96,7 @@
extern "C" HINSTANCE s_hModule; // Saved module handle
#endif // !WIN32
extern int xtrace;
extern "C" int trace;
PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
......@@ -716,7 +716,7 @@ bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp)
PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
LPCSTR type, PRELDEF *prp)
{
if (xtrace)
if (trace)
printf("GetTableDesc: name=%s am=%s\n", name, SVP(type));
// If not specified get the type of this table
......@@ -735,7 +735,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am)
TABTYPE tc;
PRELDEF tdp= NULL;
if (xtrace)
if (trace)
printf("MakeTableDesc: name=%s am=%s\n", name, SVP(am));
/*********************************************************************/
......@@ -794,14 +794,14 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
PTDB tdbp= NULL;
LPCSTR name= tablep->GetName();
if (xtrace)
if (trace)
printf("GetTableDB: name=%s\n", name);
// Look for the description of the requested table
tdp= GetTableDesc(g, name, type);
if (tdp) {
if (xtrace)
if (trace)
printf("tdb=%p type=%s\n", tdp, tdp->GetType());
if (tablep->GetQualifier())
......@@ -811,7 +811,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
} // endif tdp
if (tdbp) {
if (xtrace)
if (trace)
printf("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(),
tdbp->GetAmType());
tablep->SetTo_Tdb(tdbp);
......
......@@ -295,7 +295,7 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db,
// Send the source command to MySQL
if (myc.ExecSQL(g, query, &w) == RC_OK)
qrp = myc.GetResult(g);
qrp = myc.GetResult(g, true);
myc.Close();
return qrp;
......@@ -676,7 +676,7 @@ MYSQL_FIELD *MYSQLC::GetNextField(void)
/***********************************************************************/
PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
{
char *fmt;
char *fmt, v;
int n;
bool uns;
PCOLRES *pcrp, crp;
......@@ -705,7 +705,6 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
qrp->Nblin = 0;
qrp->Cursor = 0;
//for (fld = mysql_fetch_field(m_Res); fld;
// fld = mysql_fetch_field(m_Res)) {
for (fld = GetNextField(); fld; fld = GetNextField()) {
......@@ -718,17 +717,19 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
crp->Name = (char*)PlugSubAlloc(g, NULL, fld->name_length + 1);
strcpy(crp->Name, fld->name);
if ((crp->Type = MYSQLtoPLG(fld->type)) == TYPE_ERROR) {
if ((crp->Type = MYSQLtoPLG(fld->type, &v)) == TYPE_ERROR) {
sprintf(g->Message, "Type %d not supported for column %s",
fld->type, crp->Name);
return NULL;
} else if (crp->Type == TYPE_DATE && !pdb)
// For direct MySQL connection, display the MySQL date string
crp->Type = TYPE_STRING;
else
crp->Var = v;
crp->Prec = (crp->Type == TYPE_DOUBLE || crp->Type == TYPE_DECIM)
? fld->decimals : 0;
crp->Length = fld->max_length;
crp->Length = max(fld->length, fld->max_length);
crp->Clen = GetTypeSize(crp->Type, crp->Length);
uns = (fld->flags & (UNSIGNED_FLAG | ZEROFILL_FLAG)) ? true : false;
......
......@@ -95,7 +95,7 @@ Warning 1105 This is an outward table, table data were not modified.
SELECT * FROM t2;
line
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by CONNECT Version 1.02.0001 February 03, 2014 -->
<!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<t1>
<row>
<TH>c</TH>
......@@ -131,7 +131,7 @@ t1 CREATE TABLE `t1` (
SELECT * FROM t2;
line
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by CONNECT Version 1.02.0001 February 03, 2014 -->
<!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<t1>
<row d="One">
<c>1</c>
......
......@@ -413,7 +413,7 @@ DROP TABLE t1;
SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml');
SELECT CAST(@a AS CHAR CHARACTER SET latin1);
CAST(@a AS CHAR CHARACTER SET latin1) <?xml version="1.0" encoding="iso-8859-1"?>
<!-- Created by CONNECT Version 1.02.0001 February 03, 2014 -->
<!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<t1>
<line>
<node>ÀÁÂÃ</node>
......
......@@ -58,12 +58,8 @@ int MYSQLtoPLG(char *typname, char *var)
type = TYPE_ERROR;
if (var) {
// This is to make the difference between CHAR and VARCHAR
if (type == TYPE_STRING && stricmp(typname, "char"))
*var = 'V';
// This is to make the difference between temporal values
if (type == TYPE_DATE) {
// This is to make the difference between temporal values
if (!stricmp(typname, "date"))
*var = 'D';
else if (!stricmp(typname, "datetime"))
......@@ -75,7 +71,11 @@ int MYSQLtoPLG(char *typname, char *var)
else if (!stricmp(typname, "year"))
*var = 'Y';
} // endif type
} else if (type == TYPE_STRING && stricmp(typname, "char"))
// This is to make the difference between CHAR and VARCHAR
*var = 'V';
else
*var = 0;
} // endif var
......@@ -200,7 +200,6 @@ int MYSQLtoPLG(int mytype, char *var)
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
if (var) *var = 'V';
case MYSQL_TYPE_STRING:
type = TYPE_STRING;
break;
......@@ -208,6 +207,25 @@ int MYSQLtoPLG(int mytype, char *var)
type = TYPE_ERROR;
} // endswitch mytype
if (var) switch (mytype) {
// This is to make the difference between CHAR and VARCHAR
case MYSQL_TYPE_VAR_STRING:
#if !defined(ALPHA)
case MYSQL_TYPE_VARCHAR:
#endif // !ALPHA)
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB: *var = 'V'; break;
// This is to make the difference between temporal values
case MYSQL_TYPE_TIMESTAMP: *var = 'S'; break;
case MYSQL_TYPE_DATE: *var = 'D'; break;
case MYSQL_TYPE_DATETIME: *var = 'A'; break;
case MYSQL_TYPE_YEAR: *var = 'Y'; break;
case MYSQL_TYPE_TIME: *var = 'T'; break;
default: *var = 0;
} // endswitch mytype
return type;
} // end of MYSQLtoPLG
......
......@@ -78,7 +78,7 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft)
LPCSTR p2, p = name;
#ifdef DEBTRACE
fprintf(debug,"SplitPath: name=%s [%s (%d)]\n",
htrc("SplitPath: name=%s [%s (%d)]\n",
XSTR(name), XSTR(__FILE__), __LINE__);
#endif
......@@ -100,7 +100,7 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft)
if (fn) strcpy(fn, p);
#ifdef DEBTRACE
fprintf(debug,"SplitPath: name=%s drive=%s dir=%s filename=%s type=%s [%s(%d)]\n",
htrc("SplitPath: name=%s drive=%s dir=%s filename=%s type=%s [%s(%d)]\n",
XSTR(name), XSTR(drive), XSTR(dir), XSTR(fn), XSTR(ft), __FILE__, __LINE__);
#endif
} /* end of _splitpath */
......
......@@ -512,6 +512,7 @@ typedef struct _colres {
int Prec; /* Precision */
int Flag; /* Flag option value */
XFLD Fld; /* Type of field info */
char Var; /* Type added information */
} COLRES;
#if defined(WIN32) && !defined(NOEX)
......
......@@ -80,9 +80,6 @@ extern pthread_mutex_t parmut;
#endif // !WIN32
#endif // THREAD
#define PLGINI "plugdb.ini" /* Configuration settings file */
#define PLGXINI "plgcnx.ini" /* Configuration settings file */
/***********************************************************************/
/* DB static variables. */
/***********************************************************************/
......@@ -90,27 +87,13 @@ bool Initdone = false;
bool plugin = false; // True when called by the XDB plugin handler
extern "C" {
extern char connectini[];
char plgxini[_MAX_PATH] = PLGXINI;
char plgini[_MAX_PATH] = PLGINI;
#if defined(WIN32)
char nmfile[_MAX_PATH] = ".\\Log\\plugdb.out";
char pdebug[_MAX_PATH] = ".\\Log\\plgthread.out";
HINSTANCE s_hModule; // Saved module handle
#else // !WIN32
char nmfile[_MAX_PATH] = "./Log/plugdb.out";
char pdebug[_MAX_PATH] = "./Log/plgthread.out";
#endif // !WIN32
#if defined(XMSG)
char msglang[16] = "ENGLISH"; // Default language
#endif
extern int trace;
extern char version[];
} // extern "C"
extern "C" int trace;
extern "C" char version[];
// The debug trace used by the main thread
FILE *pfile = NULL;
......@@ -219,27 +202,6 @@ int global_open(GLOBAL *g, int msgid, const char *path, int flags, int mode)
return h;
}
/**************************************************************************/
/* Utility for external callers (such as XDB) */
/**************************************************************************/
DllExport char *GetIni(int n)
{
switch (n) {
case 1: return plgxini; break;
case 2: return nmfile; break;
case 3: return pdebug; break;
case 4: return version; break;
#if defined(XMSG)
case 5: return msglang; break;
#endif // XMSG
case 6: return connectini; break;
// default: return plgini;
} // endswitch GetIni
return plgini;
} // end of GetIni
DllExport void SetTrc(void)
{
// If tracing is on, debug must be initialized.
......@@ -427,138 +389,9 @@ char *PlgGetDataPath(PGLOBAL g)
{
PCATLG cat = PlgGetCatalog(g, false);
//if (!cat)
// return GetIniString(g, NULL, "DataBase", "DataPath", "", plgini);
return (cat) ? cat->GetDataPath() : NULL;
} // end of PlgGetDataPath
#if 0
/***********************************************************************/
/* PlgGetXdbPath: sets the fully qualified file name of a database */
/* description file in lgn and the new datapath in dp. */
/* New database description file is a Configuration Settings file */
/* that will be used and updated in case of DB modifications such */
/* as Insert into a VCT file. Look for it and use it if found. */
/* By default the configuration file is DataPath\name.xdb but the */
/* configuration file name may also be specified in Plugdb.ini. */
/***********************************************************************/
bool PlgSetXdbPath(PGLOBAL g, PSZ dbname, PSZ dbpath,
char *lgn, int lgsize,
char *path, int psize)
{
char *dp, datapath[_MAX_PATH], ft[_MAX_EXT] = ".xdb";
int n;
if (path) {
dp = path;
n = psize;
} else {
dp = datapath;
n = sizeof(datapath);
} // endif path
GetPrivateProfileString("DataBase", "DataPath", "", dp, n, plgini);
if (trace)
htrc("PlgSetXdbPath: path=%s\n", dp);
if (dbpath) {
char fn[_MAX_FNAME];
strcpy(lgn, dbpath);
_splitpath(lgn, NULL, NULL, fn, NULL);
if (!*fn) // Old style use command
strcat(lgn, dbname);
_splitpath(lgn, NULL, NULL, dbname, NULL); // Extract DB name
} else if (strcspn(dbname, ":/\\.") < strlen(dbname)) {
// dbname name contains the path name of the XDB file
strcpy(lgn, dbname);
_splitpath(lgn, NULL, NULL, dbname, NULL); // Extract DB name
} else
/*******************************************************************/
/* New database description file is a Configuration Settings file */
/* that will be used and updated in case of DB modifications such */
/* as Insert into a VCT file. Look for it and use it if found. */
/* By default the configuration file is DataPath\name.xdb but the */
/* configuration file name may also be specified in Plugdb.ini. */
/*******************************************************************/
GetPrivateProfileString("DBnames", dbname, "", lgn, lgsize, plgini);
if (*lgn) {
#if !defined(UNIX)
char drive[_MAX_DRIVE];
char direc[_MAX_DIR];
#endif
char fname[_MAX_FNAME];
char ftype[_MAX_EXT];
_splitpath(lgn, NULL, NULL, fname, ftype);
if (!*ftype)
strcat(lgn, ft);
else if (!stricmp(ftype, ".var")) {
strcpy(g->Message, MSG(NO_MORE_VAR));
return true;
} // endif ftype
// Given DB description path may be relative to data path
PlugSetPath(lgn, lgn, dp);
// New data path is the path of the configuration setting file
#if !defined(UNIX)
_splitpath(lgn, drive, direc, NULL, NULL);
_makepath(dp, drive, direc, "", "");
#else
//#error This must be tested for trailing slash
_splitpath(lgn, NULL, dp, NULL, NULL);
#endif
} else {
// Try dbname[.ext] in the current directory
strcpy(lgn, dbname);
if (!strchr(dbname, '.'))
strcat(lgn, ft);
PlugSetPath(lgn, lgn, dp);
} // endif lgn
if (trace)
htrc("PlgSetXdbPath: new DB description file=%s\n", lgn);
return false;
} // end of PlgSetXdbPath
#endif // 0
/***********************************************************************/
/* Extract from a path name the required component. */
/* This function assumes there is enough space in the buffer. */
/***********************************************************************/
#if 0
char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op)
{
char *drive = NULL, *direc = NULL, *fname = NULL, *ftype = NULL;
switch (op) { // Determine which part to extract
#if !defined(UNIX)
case OP_FDISK: drive = pBuff; break;
#endif // !UNIX
case OP_FPATH: direc = pBuff; break;
case OP_FNAME: fname = pBuff; break;
case OP_FTYPE: ftype = pBuff; break;
default:
sprintf(g->Message, MSG(INVALID_OPER), op, "ExtractFromPath");
return NULL;
} // endswitch op
// Now do the extraction
_splitpath(FileName, drive, direc, fname, ftype);
return pBuff;
} // end of PlgExtractFromPath
#endif
/***********************************************************************/
/* Check the occurence and matching of a pattern against a string. */
/* Because this function is only used for catalog name checking, */
......@@ -1468,19 +1301,17 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */
pph = (PPOOLHEADER)memp;
#if defined(DEBTRACE)
if (trace > 1)
htrc("PlgDBSubAlloc: memp=%p size=%d used=%d free=%d\n",
memp, size, pph->To_Free, pph->FreeBlk);
#endif
if ((uint)size > pph->FreeBlk) { /* Not enough memory left in pool */
sprintf(g->Message,
"Not enough memory in Work area for request of %d (used=%d free=%d)",
(int) size, pph->To_Free, pph->FreeBlk);
#if defined(DEBTRACE)
if (trace)
htrc("%s\n", g->Message);
#endif
return NULL;
} // endif size
......@@ -1491,10 +1322,11 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
memp = MakePtr(memp, pph->To_Free); // Points to suballocated block
pph->To_Free += size; // New offset of pool free block
pph->FreeBlk -= size; // New size of pool free block
#if defined(DEBTRACE)
if (trace > 1)
htrc("Done memp=%p used=%d free=%d\n",
memp, pph->To_Free, pph->FreeBlk);
#endif
return (memp);
} // end of PlgDBSubAlloc
......
......@@ -37,8 +37,6 @@
/* IBM Linker */
/* */
/***********************************************************************/
//efine DEBTRACE 3
//efine DEBTRACE2
/***********************************************************************/
/* */
......@@ -83,7 +81,6 @@
extern HINSTANCE s_hModule; /* Saved module handle */
#endif // WIN32
extern char plgini[];
extern int trace;
#if defined(XMSG)
......
......@@ -47,10 +47,6 @@
#include "valblk.h"
#include "tabmul.h"
/***********************************************************************/
/* External static variables. */
/***********************************************************************/
//extern "C" char plgini[];
/* --------------------------- Class RELDEF -------------------------- */
......
......@@ -22,6 +22,8 @@
#include "xtable.h"
#include "tabcol.h"
extern "C" int trace;
/***********************************************************************/
/* XTAB public constructor. */
/***********************************************************************/
......@@ -33,9 +35,9 @@ XTAB::XTAB(LPCSTR name, LPCSTR srcdef) : Name(name)
Schema = NULL;
Qualifier = NULL;
#ifdef DEBTRACE
htrc(" making new TABLE %s %s\n", Name, Srcdef);
#endif
if (trace)
htrc("XTAB: making new TABLE %s %s\n", Name, Srcdef);
} // end of XTAB constructor
/***********************************************************************/
......@@ -49,9 +51,9 @@ XTAB::XTAB(PTABLE tp) : Name(tp->Name)
Schema = tp->Schema;
Qualifier = tp->Qualifier;
#ifdef DEBTRACE
if (trace)
htrc(" making copy TABLE %s %s\n", Name, Srcdef);
#endif
} // end of XTAB constructor
/***********************************************************************/
......@@ -61,9 +63,8 @@ PTABLE XTAB::Link(PTABLE tab2)
{
PTABLE tabp;
#ifdef DEBTRACE
if (trace)
htrc("Linking tables %s... to %s\n", Name, tab2->Name);
#endif
for (tabp = this; tabp->Next; tabp = tabp->Next) ;
......@@ -118,9 +119,9 @@ COLUMN::COLUMN(LPCSTR name) : Name(name)
To_Col = NULL;
Qualifier = NULL;
#ifdef DEBTRACE
if (trace)
htrc(" making new COLUMN %s\n", Name);
#endif
} // end of COLUMN constructor
/***********************************************************************/
......
......@@ -1333,7 +1333,7 @@ void CSVCOL::ReadColumn(PGLOBAL g)
/***********************************************************************/
void CSVCOL::WriteColumn(PGLOBAL g)
{
char *p, buf[32];
char *p, buf[64];
int flen;
PTDBCSV tdbp = (PTDBCSV)To_Tdb;
......
......@@ -1034,7 +1034,7 @@ int TDBMYSQL::WriteDB(PGLOBAL g)
// Statement was not prepared, we must construct and execute
// an insert query for each line to insert
int rc;
char buf[32];
char buf[64];
strcpy(Qbuf, Query);
......
......@@ -1066,7 +1066,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
} // endif Buf_Type
if (g->Trace) {
char buf[32];
char buf[64];
htrc("ODBC Column %s: rows=%d buf=%p type=%d value=%s\n",
Name, tdbp->Rows, Bufp, Buf_Type, Value->GetCharString(buf));
......
......@@ -95,7 +95,7 @@ PIVAID::PIVAID(const char *tab, const char *src, const char *picol,
/***********************************************************************/
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
{
char *query, *colname, buf[32];
char *query, *colname, buf[64];
int ndif, nblin, w = 0;
PVAL valp;
PCOLRES *pcrp, crp, fncrp = NULL;
......@@ -121,7 +121,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} // endif Exec
// We must have a storage query to get pivot column values
Qryp = Myc.GetResult(g);
Qryp = Myc.GetResult(g, true);
Myc.Close();
if (!Fncol) {
......
......@@ -76,6 +76,8 @@
char *strerror(int num);
#endif // UNIX
extern "C" int trace;
/***********************************************************************/
/* Char VCT column blocks are right filled with blanks (blank = true) */
/* Conversion of block values allowed conditionally for insert only. */
......@@ -287,10 +289,9 @@ PCOL TDBVCT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/***********************************************************************/
bool TDBVCT::OpenDB(PGLOBAL g)
{
#ifdef DEBTRACE
if (trace)
htrc("VCT OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n",
this, Tdb_No, Use, To_Key_Col, Mode);
#endif
if (Use == USE_OPEN) {
/*******************************************************************/
......@@ -338,12 +339,10 @@ bool TDBVCT::OpenDB(PGLOBAL g)
/***********************************************************************/
int TDBVCT::ReadDB(PGLOBAL g)
{
#ifdef DEBTRACE
fprintf(debug,
"VCT ReadDB: R%d Mode=%d CurBlk=%d CurNum=%d key=%p link=%p Kindex=%p\n",
if (trace)
htrc("VCT ReadDB: R%d Mode=%d CurBlk=%d CurNum=%d key=%p link=%p Kindex=%p\n",
GetTdb_No(), Mode, Txfp->CurBlk, Txfp->CurNum,
To_Key_Col, To_Link, To_Kindex);
#endif
if (To_Kindex) {
/*******************************************************************/
......@@ -518,15 +517,13 @@ void VCTCOL::ReadColumn(PGLOBAL g)
{
PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp;
#if defined(_DEBUG) || defined(DEBTRACE)
#if defined(_DEBUG)
assert (!To_Kcol);
#endif
#ifdef DEBTRACE
fprintf(debug,
"VCT ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
if (trace > 1)
htrc("VCT ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
#endif
if (ColBlk != txfp->CurBlk)
ReadBlock(g);
......@@ -552,11 +549,9 @@ void VCTCOL::WriteColumn(PGLOBAL g)
{
PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp;;
#ifdef DEBTRACE
fprintf(debug,
"VCT WriteColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
if (trace > 1)
htrc("VCT WriteColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
#endif
ColBlk = txfp->CurBlk;
ColPos = txfp->CurNum;
......
......@@ -47,8 +47,7 @@
#include "user_connect.h"
#include "mycat.h"
extern "C" char plgxini[];
extern int xtrace;
extern "C" int trace;
/****************************************************************************/
/* Initialize the user_connect static member. */
......@@ -149,7 +148,7 @@ bool user_connect::CheckCleanup(void)
g->Alchecked = 0;
last_query_id= thdp->query_id;
if (xtrace)
if (trace)
printf("=====> Begin new query %llu\n", last_query_id);
return true;
......
......@@ -43,6 +43,8 @@
#define CheckBlanks assert(!Blanks);
#define CheckParms(V, N) ChkIndx(N); ChkTyp(V);
extern "C" int trace;
/***********************************************************************/
/* AllocValBlock: allocate a VALBLK according to type. */
/***********************************************************************/
......@@ -51,10 +53,9 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
{
PVBLK blkp;
#ifdef DEBTRACE
if (trace)
htrc("AVB: mp=%p type=%d nval=%d len=%d check=%u blank=%u\n",
mp, type, nval, len, check, blank);
#endif
switch (type) {
case TYPE_STRING:
......@@ -546,7 +547,7 @@ int TYPBLK<TYPE>::Find(PVAL vp)
template <class TYPE>
int TYPBLK<TYPE>::GetMaxLength(void)
{
char buf[32];
char buf[64];
int i, n, m;
for (i = n = 0; i < Nval; i++) {
......@@ -737,13 +738,13 @@ void CHRBLK::SetValue(char *sp, uint len, int n)
{
char *p = Chrp + n * Long;
#if defined(_DEBUG) || defined(DEBTRACE)
#if defined(_DEBUG)
if (Check && (signed)len > Long) {
PGLOBAL& g = Global;
strcpy(g->Message, MSG(SET_STR_TRUNC));
longjmp(g->jumper[g->jump_level], Type);
} // endif Check
#endif
#endif // _DEBUG
if (sp)
memcpy(p, sp, min((unsigned)Long, len));
......@@ -786,13 +787,13 @@ void CHRBLK::SetValue(PVBLK pv, int n1, int n2)
/***********************************************************************/
void CHRBLK::SetValues(PVBLK pv, int k, int n)
{
#if defined(_DEBUG) || defined(DEBTRACE)
#if defined(_DEBUG)
if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
PGLOBAL& g = Global;
strcpy(g->Message, MSG(BLKTYPLEN_MISM));
longjmp(g->jumper[g->jump_level], Type);
} // endif Type
#endif
#endif // _DEBUG
char *p = ((CHRBLK*)pv)->Chrp;
if (!k)
......
......@@ -555,7 +555,7 @@ template <>
bool TYPVAL<double>::SetValue_char(char *p, int n)
{
if (p) {
char buf[32];
char buf[64];
for (; n > 0 && *p == ' '; p++)
n--;
......@@ -957,7 +957,7 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
if (chktype && (valp->GetType() != Type || valp->GetSize() > Len))
return true;
char buf[32];
char buf[64];
if (!(Null = valp->IsNull() && Nullable))
strncpy(Strp, valp->GetCharString(buf), Len);
......@@ -1126,7 +1126,7 @@ void TYPVAL<PSZ>::SetValue(ulonglong n)
/***********************************************************************/
void TYPVAL<PSZ>::SetValue(double f)
{
char *p, buf[32];
char *p, buf[64];
PGLOBAL& g = Global;
int k = sprintf(buf, "%lf", f);
......@@ -1220,7 +1220,7 @@ bool TYPVAL<PSZ>::IsEqual(PVAL vp, bool chktype)
else if (Null || vp->IsNull())
return false;
char buf[32];
char buf[64];
if (Ci || vp->IsCi())
return !stricmp(Strp, vp->GetCharString(buf));
......@@ -1351,7 +1351,7 @@ bool DECVAL::SetValue_pval(PVAL valp, bool chktype)
if (chktype && (valp->GetType() != Type || valp->GetSize() > Len))
return true;
char buf[32];
char buf[64];
if (!(Null = valp->IsNull() && Nullable))
strncpy(Strp, valp->GetCharString(buf), Len);
......@@ -1450,7 +1450,7 @@ bool DECVAL::IsEqual(PVAL vp, bool chktype)
else if (Null || vp->IsNull())
return false;
char buf[32];
char buf[64];
return !strcmp(Strp, vp->GetCharString(buf));
} // end of IsEqual
......
......@@ -60,6 +60,7 @@
/* DB static external variables. */
/***********************************************************************/
extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */
extern "C" int trace;
/***********************************************************************/
/* Last two parameters are true to enable type checking, and last one */
......@@ -267,10 +268,7 @@ int XINDEX::Qcompare(int *i1, int *i2)
if ((k = kcp->Compare(*i1, *i2)))
break;
#ifdef DEBTRACE
num_comp++;
#endif
//num_comp++;
return k;
} // end of Qcompare
......@@ -1801,10 +1799,7 @@ XINDXS::XINDXS(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp, PCOL *cp, PXOB *xp)
/***********************************************************************/
int XINDXS::Qcompare(int *i1, int *i2)
{
#ifdef DEBTRACE
num_comp++;
#endif
//num_comp++;
return To_KeyCol->Compare(*i1, *i2);
} // end of Qcompare
......@@ -2320,11 +2315,9 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
return true;
} // endif Hfile
#ifdef DEBTRACE
fprintf(debug,
" access=%p share=%p creation=%d handle=%p fn=%s\n",
if (trace)
htrc(" access=%p share=%p creation=%d handle=%p fn=%s\n",
access, share, creation, Hfile, filename);
#endif
if (mode == MODE_INSERT) {
/*******************************************************************/
......@@ -2767,10 +2760,9 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
Prefix = true;
} // endif kln
#ifdef DEBTRACE
if (trace)
htrc("KCOL(%p) Init: col=%s n=%d type=%d sm=%d\n",
this, colp->GetName(), n, colp->GetResultType(), sm);
#endif
// Allocate the Value object used when moving items
Type = colp->GetResultType();
......@@ -2822,10 +2814,9 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
Type = colp->GetResultType();
#ifdef DEBTRACE
if (trace)
htrc("MapInit(%p): colp=%p type=%d n=%d len=%d m=%p\n",
this, colp, Type, n[0], len, m);
#endif
// Allocate the Value object used when moving items
Valp = AllocateValue(g, Type, len, prec, false, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment