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

- Resolving conflicts

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/filamtxt.cpp
  storage/connect/filamzip.cpp
  storage/connect/ha_connect.cc
  storage/connect/mycat.cc
  storage/connect/myconn.cpp
  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
This commit is contained in:
Olivier Bertrand
2014-03-22 08:57:32 +01:00
28 changed files with 19075 additions and 19287 deletions

View File

@@ -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

View File

@@ -23,6 +23,8 @@
#include "xindex.h"
#include "xtable.h"
extern "C" int trace;
/***********************************************************************/
/* COLBLK protected constructor. */
/***********************************************************************/
@@ -76,9 +78,8 @@ COLBLK::COLBLK(PCOL col1, PTDB tdbp)
//To_Orig = col1;
To_Tdb = tdbp;
#ifdef DEBTRACE
htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this);
#endif
if (trace > 1)
htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this);
if (tdbp)
// Attach the new column to the table block
@@ -116,10 +117,9 @@ bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
{
fmt = Format;
#ifdef DEBTRACE
htrc("COLBLK: %p format=%c(%d,%d)\n",
this, *fmt.Type, fmt.Length, fmt.Prec);
#endif
if (trace > 1)
htrc("COLBLK: %p format=%c(%d,%d)\n",
this, *fmt.Type, fmt.Length, fmt.Prec);
return false;
} // end of SetFormat
@@ -130,9 +130,8 @@ bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
/***********************************************************************/
bool COLBLK::Eval(PGLOBAL g)
{
#ifdef DEBTRACE
htrc("Col Eval: %s status=%.4X\n", Name, Status);
#endif
if (trace > 1)
htrc("Col Eval: %s status=%.4X\n", Name, Status);
if (!GetStatus(BUF_READ)) {
// if (To_Tdb->IsNull())
@@ -168,10 +167,9 @@ bool COLBLK::InitValue(PGLOBAL g)
AddStatus(BUF_READY);
Value->SetNullable(Nullable);
#ifdef DEBTRACE
htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
this, Buf_Type, Value, ColUse, Status);
#endif
if (trace > 1)
htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
this, Buf_Type, Value, ColUse, Status);
return false;
} // end of InitValue

File diff suppressed because it is too large Load Diff

View File

@@ -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;

View File

@@ -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
htrc("Mapped file length=%d\n", len);
#endif
if (trace)
htrc("Mapped file length=%d\n", len);
return len;
} // end of GetFileLength
@@ -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
htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n",
fp, fp->Count, Memory, len, Top);
#endif
if (trace)
htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n",
fp, fp->Count, Memory, len, Top);
return AllocateBuffer(g); // Useful for DBF files
} // end of OpenTableFile
@@ -383,20 +383,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",
irc, Mempos, To_Buf, Tpos, Spos);
#endif
if (trace)
htrc("MAP DeleteDB: irc=%d mempos=%p tobuf=%p Tpos=%p Spos=%p\n",
irc, Mempos, To_Buf, Tpos, Spos);
if (irc != RC_OK) {
/*******************************************************************/
/* EOF: position Fpos at the top of map position. */
/*******************************************************************/
Fpos = Top;
#ifdef DEBTRACE
htrc("Fpos placed at file top=%p\n", Fpos);
#endif
if (trace)
htrc("Fpos placed at file top=%p\n", Fpos);
} // endif irc
if (Tpos == Spos)
@@ -412,17 +411,16 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
memmove(Tpos, Spos, n);
Tpos += n;
#ifdef DEBTRACE
htrc("move %d bytes\n", n);
#endif
if (trace)
htrc("move %d bytes\n", n);
} // endif n
if (irc == RC_OK) {
Spos = Mempos; // New start position
#ifdef DEBTRACE
htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos);
#endif
if (trace)
htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos);
} else if (To_Fb) { // Can be NULL for deleted files
/*******************************************************************/
@@ -450,9 +448,8 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
return RC_FX;
} // endif
#ifdef DEBTRACE
htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
#endif
if (trace)
htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
if (!SetEndOfFile(fp->Handle)) {
sprintf(g->Message, MSG(FUNCTION_ERROR),
@@ -484,10 +481,10 @@ void MAPFAM::CloseTableFile(PGLOBAL g)
PlugCloseFile(g, To_Fb);
To_Fb = NULL; // To get correct file size in Cardinality
#ifdef DEBTRACE
htrc("MAP Close: closing %s count=%d\n",
To_File, (To_Fb) ? To_Fb->Count : 0);
#endif
if (trace)
htrc("MAP Close: closing %s count=%d\n",
To_File, (To_Fb) ? To_Fb->Count : 0);
} // end of CloseTableFile
/***********************************************************************/

View File

@@ -485,16 +485,15 @@ bool DBFFAM::OpenTableFile(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath());
if (!(Stream = PlugOpenFile(g, filename, opmode))) {
#ifdef DEBTRACE
htrc("%s\n", g->Message);
#endif
if (trace)
htrc("%s\n", g->Message);
return (mode == MODE_READ && errno == ENOENT)
? PushWarning(g, Tdbp) : true;
} // endif Stream
#ifdef DEBTRACE
htrc("File %s is open in mode %s\n", filename, opmode);
#endif
if (trace)
htrc("File %s is open in mode %s\n", filename, opmode);
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
htrc("DBF CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
To_File, mode, wrc, rc);
#endif
if (trace)
htrc("DBF CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
To_File, mode, wrc, rc);
Stream = NULL; // So we can know whether table is open
} // end of CloseTableFile

View File

@@ -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 -------------------------- */
@@ -241,9 +242,8 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
return RC_FX;
} // endif fseek
#ifdef DEBTRACE
htrc("File position is now %d\n", ftell(Stream));
#endif
if (trace > 1)
htrc("File position is now %d\n", ftell(Stream));
//long tell = ftell(Stream); not used
@@ -266,9 +266,9 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
#endif
#ifdef DEBTRACE
htrc("%s\n", g->Message);
#endif
if (trace)
htrc("%s\n", g->Message);
return RC_FX;
} // endelse
@@ -283,11 +283,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",
Tdbp->GetMode(), To_Buf, Tdbp->GetLine(), Nrec, Rbuf, CurNum);
#endif
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);
if (Tdbp->GetMode() == MODE_INSERT) {
/*******************************************************************/
@@ -298,9 +296,8 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
return RC_OK; // We write only full blocks
} // endif CurNum
#ifdef DEBTRACE
htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf);
#endif
if (trace > 1)
htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf);
// Now start the writing process.
if (fwrite(To_Buf, Lrecl, Rbuf, Stream) != (size_t)Rbuf) {
@@ -313,9 +310,8 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
CurNum = 0;
Tdbp->SetLine(To_Buf);
#ifdef DEBTRACE
htrc("write done\n");
#endif
if (trace > 1)
htrc("write done\n");
} else { // Mode == MODE_UPDATE
// T_Stream is the temporary stream or the table file stream itself
@@ -353,20 +349,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",
irc, UseTemp, Fpos, Tpos, Spos);
#endif
if (trace > 1)
htrc("DOS DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
irc, UseTemp, Fpos, Tpos, Spos);
if (irc != RC_OK) {
/*******************************************************************/
/* EOF: position Fpos at the end-of-file position. */
/*******************************************************************/
Fpos = Tdbp->Cardinality(g);
#ifdef DEBTRACE
htrc("Fpos placed at file end=%d\n", Fpos);
#endif
if (trace > 1)
htrc("Fpos placed at file end=%d\n", Fpos);
} else // Fpos is the deleted line position
Fpos = CurBlk * Nrec + CurNum;
@@ -414,9 +409,8 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc)
OldBlk = -2; // To force fseek to be executed on next block
} // endif moved
#ifdef DEBTRACE
htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
#endif
if (trace > 1)
htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
} else {
/*******************************************************************/
@@ -464,9 +458,9 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc)
close(h);
#ifdef DEBTRACE
htrc("done, h=%d irc=%d\n", h, irc);
#endif
if (trace > 1)
htrc("done, h=%d irc=%d\n", h, irc);
} // endif UseTemp
} // endif irc
@@ -496,9 +490,8 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
req = (size_t)min(n, Dbflen);
len = fread(DelBuf, Lrecl, req, Stream);
#ifdef DEBTRACE
htrc("after read req=%d len=%d\n", req, len);
#endif
if (trace > 1)
htrc("after read req=%d len=%d\n", req, len);
if (len != req) {
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
@@ -516,16 +509,14 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
return true;
} // endif
#ifdef DEBTRACE
htrc("after write pos=%d\n", ftell(Stream));
#endif
if (trace > 1)
htrc("after write pos=%d\n", ftell(Stream));
Tpos += (int)req;
Spos += (int)req;
#ifdef DEBTRACE
htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
#endif
if (trace > 1)
htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
*b = true;
} // endfor n
@@ -574,10 +565,10 @@ void FIXFAM::CloseTableFile(PGLOBAL g)
rc = PlugCloseFile(g, To_Fb);
fin:
#ifdef DEBTRACE
htrc("FIX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
To_File, mode, wrc, rc);
#endif
if (trace)
htrc("FIX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
To_File, mode, wrc, rc);
Stream = NULL; // So we can know whether table is open
} // end of CloseTableFile
@@ -641,9 +632,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
htrc("after read req=%d brc=%d nbr=%d\n", req, brc, nbr);
#endif
if (trace > 1)
htrc("after read req=%d brc=%d nbr=%d\n", req, brc, nbr);
if (!brc) {
char buf[256]; // , *fn = (h == Hfile) ? To_File : "Tempfile";
@@ -653,9 +643,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
htrc("BIGREAD: %s\n", g->Message);
#endif
if (trace > 1)
htrc("BIGREAD: %s\n", g->Message);
rc = -1;
} else
rc = (int)nbr;
@@ -680,9 +671,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
htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
#endif
if (trace > 1)
htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
if (!brc || nbw != len) {
char buf[256], *fn = (h == Hfile) ? To_File : "Tempfile";
@@ -698,10 +688,10 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
sprintf(g->Message, MSG(WRITE_STRERROR), fn, buf);
#ifdef DEBTRACE
htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
nbw, len, drc, g->Message);
#endif
if (trace > 1)
htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
nbw, len, drc, g->Message);
rc = true;
} // endif brc || nbw
#else // !WIN32
@@ -712,10 +702,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
htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
nbw, len, errno, g->Message);
#endif
if (trace > 1)
htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
nbw, len, errno, g->Message);
rc = true;
} // endif nbr
#endif // !WIN32
@@ -750,9 +741,8 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath());
#ifdef DEBTRACE
htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode);
#endif
if (trace)
htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode);
#if defined(WIN32)
DWORD rc, access, creation, share = 0;
@@ -811,11 +801,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",
rc, access, share, creation, Hfile, filename);
#endif
if (trace > 1)
htrc(" rc=%d access=%p share=%p creation=%d handle=%p fn=%s\n",
rc, access, share, creation, Hfile, filename);
if (mode == MODE_INSERT)
/*******************************************************************/
@@ -866,10 +854,9 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
} else
rc = 0;
#ifdef DEBTRACE
htrc(" rc=%d oflag=%p tmode=%p handle=%p fn=%s\n",
rc, oflag, tmode, Hfile, filename);
#endif
if (trace > 1)
htrc(" rc=%d oflag=%p tmode=%p handle=%p fn=%s\n",
rc, oflag, tmode, Hfile, filename);
#endif // UNIX
@@ -951,14 +938,13 @@ int BGXFAM::Cardinality(PGLOBAL g)
if (Hfile == INVALID_HANDLE_VALUE) {
int h = open64(filename, O_RDONLY, 0);
#ifdef DEBTRACE
htrc(" h=%d\n", h);
#endif
if (trace)
htrc(" h=%d\n", h);
if (h == INVALID_HANDLE_VALUE) {
#ifdef DEBTRACE
htrc(" errno=%d ENOENT=%d\n", errno, ENOENT);
#endif
if (trace)
htrc(" errno=%d ENOENT=%d\n", errno, ENOENT);
if (errno != ENOENT) {
sprintf(g->Message, MSG(OPEN_ERROR_IS),
filename, strerror(errno));
@@ -1000,10 +986,9 @@ int BGXFAM::Cardinality(PGLOBAL g)
} else
card = (int)(fsize / (BIGINT)Lrecl); // Fixed length file
#ifdef DEBTRACE
htrc(" Computed max_K=%d fsize=%lf lrecl=%d\n",
card, (double)fsize, Lrecl);
#endif
if (trace)
htrc(" Computed max_K=%d fsize=%lf lrecl=%d\n",
card, (double)fsize, Lrecl);
// Set number of blocks for later use
Block = (card + Nrec - 1) / Nrec;
@@ -1101,9 +1086,8 @@ int BGXFAM::ReadBuffer(PGLOBAL g)
if (BigSeek(g, Hfile, (BIGINT)Fpos * (BIGINT)Lrecl))
return RC_FX;
#ifdef DEBTRACE
htrc("File position is now %d\n", Fpos);
#endif
if (trace > 1)
htrc("File position is now %d\n", Fpos);
nbr = BigRead(g, Hfile, To_Buf, (Padded) ? Blksize : Lrecl * Nrec);
@@ -1126,11 +1110,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",
Tdbp->GetMode(), To_Buf, Tdbp->GetLine(), Nrec, Rbuf, CurNum);
#endif
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);
if (Tdbp->GetMode() == MODE_INSERT) {
/*******************************************************************/
@@ -1141,9 +1123,8 @@ int BGXFAM::WriteBuffer(PGLOBAL g)
return RC_OK; // We write only full blocks
} // endif CurNum
#ifdef DEBTRACE
htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf);
#endif
if (trace > 1)
htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf);
// Now start the writing process.
if (BigWrite(g, Hfile, To_Buf, Lrecl * Rbuf))
@@ -1153,9 +1134,8 @@ int BGXFAM::WriteBuffer(PGLOBAL g)
CurNum = 0;
Tdbp->SetLine(To_Buf);
#ifdef DEBTRACE
htrc("write done\n");
#endif
if (trace > 1)
htrc("write done\n");
} else { // Mode == MODE_UPDATE
// Tfile is the temporary file or the table file handle itself
@@ -1190,20 +1170,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",
irc, UseTemp, Fpos, Tpos, Spos);
#endif
if (trace > 1)
htrc("BGX DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
irc, UseTemp, Fpos, Tpos, Spos);
if (irc != RC_OK) {
/*******************************************************************/
/* EOF: position Fpos at the end-of-file position. */
/*******************************************************************/
Fpos = Tdbp->Cardinality(g);
#ifdef DEBTRACE
htrc("Fpos placed at file end=%d\n", Fpos);
#endif
if (trace > 1)
htrc("Fpos placed at file end=%d\n", Fpos);
} else // Fpos is the deleted line position
Fpos = CurBlk * Nrec + CurNum;
@@ -1239,9 +1218,9 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
return RC_FX;
if (irc == RC_OK) {
#ifdef DEBTRACE
assert(Spos == Fpos);
#endif
if (trace)
assert(Spos == Fpos);
Spos++; // New start position is on next line
if (moved) {
@@ -1251,9 +1230,8 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
OldBlk = -2; // To force fseek to be executed on next block
} // endif moved
#ifdef DEBTRACE
htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
#endif
if (trace > 1)
htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
} else {
/*******************************************************************/
@@ -1385,9 +1363,8 @@ bool BGXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
Tpos += (int)req;
Spos += (int)req;
#ifdef DEBTRACE
htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
#endif
if (trace > 1)
htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
*b = true;
} // endfor n
@@ -1435,10 +1412,10 @@ void BGXFAM::CloseTableFile(PGLOBAL g)
rc = PlugCloseFile(g, To_Fb);
fin:
#ifdef DEBTRACE
htrc("BGX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
To_File, mode, wrc, rc);
#endif
if (trace)
htrc("BGX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
To_File, mode, wrc, rc);
Hfile = INVALID_HANDLE_VALUE; // So we can know whether table is open
} // end of CloseTableFile

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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);

View File

@@ -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;

View File

@@ -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

View File

@@ -78,8 +78,8 @@ 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",
XSTR(name), XSTR(__FILE__), __LINE__);
htrc("SplitPath: name=%s [%s (%d)]\n",
XSTR(name), XSTR(__FILE__), __LINE__);
#endif
if (drive) *drive = '\0';
@@ -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 */

View File

@@ -531,6 +531,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)

View File

@@ -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.
@@ -418,138 +380,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, */
@@ -1459,19 +1292,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)
htrc("PlgDBSubAlloc: memp=%p size=%d used=%d free=%d\n",
memp, size, pph->To_Free, pph->FreeBlk);
#endif
if (trace > 1)
htrc("PlgDBSubAlloc: memp=%p size=%d used=%d free=%d\n",
memp, size, pph->To_Free, pph->FreeBlk);
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)
htrc("%s\n", g->Message);
#endif
if (trace)
htrc("%s\n", g->Message);
return NULL;
} // endif size
@@ -1482,10 +1313,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)
htrc("Done memp=%p used=%d free=%d\n",
memp, pph->To_Free, pph->FreeBlk);
#endif
if (trace > 1)
htrc("Done memp=%p used=%d free=%d\n",
memp, pph->To_Free, pph->FreeBlk);
return (memp);
} // end of PlgDBSubAlloc

File diff suppressed because it is too large Load Diff

View File

@@ -1,436 +1,432 @@
/************* RelDef CPP Program Source Code File (.CPP) **************/
/* PROGRAM NAME: REFDEF */
/* ------------- */
/* Version 1.4 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
/* This program are the DB definition related routines. */
/* */
/***********************************************************************/
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
#if defined(WIN32)
#include <sqlext.h>
#else
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
#include "osutil.h"
//#include "sqlext.h"
#endif
/***********************************************************************/
/* Include application header files */
/* */
/* global.h is header containing all global declarations. */
/* plgdbsem.h is header containing DB application declarations. */
/* catalog.h is header containing DB description declarations. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "mycat.h"
#include "reldef.h"
#include "colblk.h"
#include "filamap.h"
#include "filamfix.h"
#include "filamvct.h"
#if defined(ZIP_SUPPORT)
#include "filamzip.h"
#endif // ZIP_SUPPORT
#include "tabdos.h"
#include "valblk.h"
#include "tabmul.h"
/***********************************************************************/
/* External static variables. */
/***********************************************************************/
//extern "C" char plgini[];
/* --------------------------- Class RELDEF -------------------------- */
/***********************************************************************/
/* RELDEF Constructor. */
/***********************************************************************/
RELDEF::RELDEF(void)
{
Next = NULL;
To_Cols = NULL;
Name = NULL;
Database = NULL;
Cat = NULL;
} // end of RELDEF constructor
/* --------------------------- Class TABDEF -------------------------- */
/***********************************************************************/
/* TABDEF Constructor. */
/***********************************************************************/
TABDEF::TABDEF(void)
{
Schema = NULL;
Desc = NULL;
Catfunc = FNC_NO;
Card = 0;
Elemt = 0;
Sort = 0;
Multiple = 0;
Degree = 0;
Pseudo = 0;
Read_Only = false;
} // end of TABDEF constructor
/***********************************************************************/
/* Define: initialize the table definition block from XDB file. */
/***********************************************************************/
bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
{
int poff = 0;
Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1);
strcpy(Name, name);
Cat = cat;
Catfunc = GetFuncID(Cat->GetStringCatInfo(g, "Catfunc", NULL));
Elemt = cat->GetIntCatInfo("Elements", 0);
Multiple = cat->GetIntCatInfo("Multiple", 0);
Degree = cat->GetIntCatInfo("Degree", 0);
Read_Only = cat->GetBoolCatInfo("ReadOnly", false);
const char *data_charset_name= cat->GetStringCatInfo(g, "Data_charset", NULL);
m_data_charset= data_charset_name ?
get_charset_by_csname(data_charset_name, MY_CS_PRIMARY, 0):
NULL;
// Get The column definitions
if ((poff = cat->GetColCatInfo(g, this)) < 0)
return true;
// Do the definition of AM specific fields
return DefineAM(g, am, poff);
} // end of Define
/* --------------------------- Class OEMDEF -------------------------- */
/***********************************************************************/
/* GetXdef: get the external TABDEF from OEM module. */
/***********************************************************************/
PTABDEF OEMDEF::GetXdef(PGLOBAL g)
{
typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *);
char c, getname[40] = "Get";
PTABDEF xdefp;
XGETDEF getdef = NULL;
PCATLG cat = Cat;
#if defined(WIN32)
// Is the DLL already loaded?
if (!Hdll && !(Hdll = GetModuleHandle(Module)))
// No, load the Dll implementing the function
if (!(Hdll = LoadLibrary(Module))) {
char buf[256];
DWORD rc = GetLastError();
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
strcat(strcat(g->Message, ": "), buf);
return NULL;
} // endif hDll
// The exported name is always in uppercase
for (int i = 0; ; i++) {
c = Subtype[i];
getname[i + 3] = toupper(c);
if (!c) break;
} // endfor i
// Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) {
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname);
FreeLibrary((HMODULE)Hdll);
return NULL;
} // endif getdef
#else // !WIN32
const char *error = NULL;
// Is the library already loaded?
// if (!Hdll && !(Hdll = ???))
// Load the desired shared library
if (!(Hdll = dlopen(Module, RTLD_LAZY))) {
error = dlerror();
sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error));
return NULL;
} // endif Hdll
// The exported name is always in uppercase
for (int i = 0; ; i++) {
c = Subtype[i];
getname[i + 3] = toupper(c);
if (!c) break;
} // endfor i
// Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)dlsym(Hdll, getname))) {
error = dlerror();
sprintf(g->Message, MSG(GET_FUNC_ERR), getname, SVP(error));
dlclose(Hdll);
return NULL;
} // endif getdef
#endif // !WIN32
// Just in case the external Get function does not set error messages
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype);
// Get the table definition block
if (!(xdefp = getdef(g, NULL)))
return NULL;
// Have the external class do its complete definition
if (!cat->Cbuf) {
// Suballocate a temporary buffer for the entire column section
cat->Cblen = cat->GetSizeCatInfo("Colsize", "8K");
cat->Cbuf = (char*)PlugSubAlloc(g, NULL, cat->Cblen);
} // endif Cbuf
// Here "OEM" should be replace by a more useful value
if (xdefp->Define(g, cat, Name, "OEM"))
return NULL;
// Ok, return external block
return xdefp;
} // end of GetXdef
#if 0
/***********************************************************************/
/* DeleteTableFile: Delete an OEM table file if applicable. */
/***********************************************************************/
bool OEMDEF::DeleteTableFile(PGLOBAL g)
{
if (!Pxdef)
Pxdef = GetXdef(g);
return (Pxdef) ? Pxdef->DeleteTableFile(g) : true;
} // end of DeleteTableFile
#endif // 0
/***********************************************************************/
/* Define: initialize the table definition block from XDB file. */
/***********************************************************************/
bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
Module = Cat->GetStringCatInfo(g, "Module", "");
Subtype = Cat->GetStringCatInfo(g, "Subtype", Module);
if (!*Module)
Module = Subtype;
Desc = (char*)PlugSubAlloc(g, NULL, strlen(Module)
+ strlen(Subtype) + 3);
sprintf(Desc, "%s(%s)", Module, Subtype);
return false;
} // end of DefineAM
/***********************************************************************/
/* GetTable: makes a new Table Description Block. */
/***********************************************************************/
PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
{
RECFM rfm;
PTDBASE tdbp = NULL;
// If define block not here yet, get it now
if (!Pxdef && !(Pxdef = GetXdef(g)))
return NULL; // Error
/*********************************************************************/
/* Allocate a TDB of the proper type. */
/* Column blocks will be allocated only when needed. */
/*********************************************************************/
if (!(tdbp = (PTDBASE)Pxdef->GetTable(g, mode)))
return NULL;
else
rfm = tdbp->GetFtype();
if (rfm == RECFM_NAF)
return tdbp;
else if (rfm == RECFM_OEM) {
if (Multiple)
tdbp = new(g) TDBMUL(tdbp); // No block optimization yet
return tdbp;
} // endif OEM
/*********************************************************************/
/* The OEM table is based on a file type (currently DOS+ only) */
/*********************************************************************/
assert (rfm == RECFM_VAR || rfm == RECFM_FIX ||
rfm == RECFM_BIN || rfm == RECFM_VCT);
PTXF txfp = NULL;
PDOSDEF defp = (PDOSDEF)Pxdef;
bool map = defp->Mapped && mode != MODE_INSERT &&
!(PlgGetUser(g)->UseTemp == TMP_FORCE &&
(mode == MODE_UPDATE || mode == MODE_DELETE));
int cmpr = defp->Compressed;
/*********************************************************************/
/* Allocate table and file processing class of the proper type. */
/* Column blocks will be allocated only when needed. */
/*********************************************************************/
if (!((PTDBDOS)tdbp)->GetTxfp()) {
if (cmpr) {
#if defined(ZIP_SUPPORT)
if (cmpr == 1)
txfp = new(g) ZIPFAM(defp);
else
txfp = new(g) ZLBFAM(defp);
#else // !ZIP_SUPPORT
strcpy(g->Message, "Compress not supported");
return NULL;
#endif // !ZIP_SUPPORT
} else if (rfm == RECFM_VAR) {
if (map)
txfp = new(g) MAPFAM(defp);
else
txfp = new(g) DOSFAM(defp);
} else if (rfm == RECFM_FIX || rfm == RECFM_BIN) {
if (map)
txfp = new(g) MPXFAM(defp);
else
txfp = new(g) FIXFAM(defp);
} else if (rfm == RECFM_VCT) {
assert (Pxdef->GetDefType() == TYPE_AM_VCT);
if (map)
txfp = new(g) VCMFAM((PVCTDEF)defp);
else
txfp = new(g) VCTFAM((PVCTDEF)defp);
} // endif's
((PTDBDOS)tdbp)->SetTxfp(txfp);
} // endif Txfp
if (Multiple)
tdbp = new(g) TDBMUL(tdbp);
return tdbp;
} // end of GetTable
/* --------------------------- Class COLCRT -------------------------- */
/***********************************************************************/
/* COLCRT Constructors. */
/***********************************************************************/
COLCRT::COLCRT(PSZ name)
{
Next = NULL;
Name = name;
Desc = NULL;
Decode = NULL;
Fmt = NULL;
Offset = -1;
Long = -1;
Precision = -1;
Freq = -1;
Key = -1;
Scale = -1;
Opt = -1;
DataType = '*';
} // end of COLCRT constructor for table creation
COLCRT::COLCRT(void)
{
Next = NULL;
Name = NULL;
Desc = NULL;
Decode = NULL;
Fmt = NULL;
Offset = 0;
Long = 0;
Precision = 0;
Freq = 0;
Key = 0;
Scale = 0;
Opt = 0;
DataType = '*';
} // end of COLCRT constructor for table & view definition
/* --------------------------- Class COLDEF -------------------------- */
/***********************************************************************/
/* COLDEF Constructor. */
/***********************************************************************/
COLDEF::COLDEF(void) : COLCRT()
{
To_Min = NULL;
To_Max = NULL;
To_Pos = NULL;
Xdb2 = FALSE;
To_Bmap = NULL;
To_Dval = NULL;
Ndv = 0;
Nbm = 0;
Buf_Type = TYPE_ERROR;
Clen = 0;
Poff = 0;
memset(&F, 0, sizeof(FORMAT));
Flags = 0;
} // end of COLDEF constructor
/***********************************************************************/
/* Define: initialize a column definition from a COLINFO structure. */
/***********************************************************************/
int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
{
Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1);
strcpy(Name, cfp->Name);
if (!(cfp->Flags & U_SPECIAL)) {
Poff = poff;
Buf_Type = cfp->Type;
if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) <= 0) {
sprintf(g->Message, MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name);
return -1;
} // endswitch
strcpy(F.Type, GetFormatType(Buf_Type));
F.Length = cfp->Length;
F.Prec = cfp->Scale;
Offset = (cfp->Offset < 0) ? poff : cfp->Offset;
Precision = cfp->Precision;
Scale = cfp->Scale;
Long = cfp->Length;
Opt = cfp->Opt;
Key = cfp->Key;
Freq = cfp->Freq;
if (cfp->Remark && *cfp->Remark) {
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1);
strcpy(Desc, cfp->Remark);
} // endif Remark
if (cfp->Datefmt) {
Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1);
strcpy(Decode, cfp->Datefmt);
} // endif Datefmt
} // endif special
if (cfp->Fieldfmt) {
Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1);
strcpy(Fmt, cfp->Fieldfmt);
} // endif Fieldfmt
Flags = cfp->Flags;
return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long;
} // end of Define
/* ------------------------- End of RelDef --------------------------- */
/************* RelDef CPP Program Source Code File (.CPP) **************/
/* PROGRAM NAME: REFDEF */
/* ------------- */
/* Version 1.4 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
/* This program are the DB definition related routines. */
/* */
/***********************************************************************/
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
#include "my_global.h"
#if defined(WIN32)
#include <sqlext.h>
#else
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
#include "osutil.h"
//#include "sqlext.h"
#endif
/***********************************************************************/
/* Include application header files */
/* */
/* global.h is header containing all global declarations. */
/* plgdbsem.h is header containing DB application declarations. */
/* catalog.h is header containing DB description declarations. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "mycat.h"
#include "reldef.h"
#include "colblk.h"
#include "filamap.h"
#include "filamfix.h"
#include "filamvct.h"
#if defined(ZIP_SUPPORT)
#include "filamzip.h"
#endif // ZIP_SUPPORT
#include "tabdos.h"
#include "valblk.h"
#include "tabmul.h"
/* --------------------------- Class RELDEF -------------------------- */
/***********************************************************************/
/* RELDEF Constructor. */
/***********************************************************************/
RELDEF::RELDEF(void)
{
Next = NULL;
To_Cols = NULL;
Name = NULL;
Database = NULL;
Cat = NULL;
} // end of RELDEF constructor
/* --------------------------- Class TABDEF -------------------------- */
/***********************************************************************/
/* TABDEF Constructor. */
/***********************************************************************/
TABDEF::TABDEF(void)
{
Schema = NULL;
Desc = NULL;
Catfunc = FNC_NO;
Card = 0;
Elemt = 0;
Sort = 0;
Multiple = 0;
Degree = 0;
Pseudo = 0;
Read_Only = false;
} // end of TABDEF constructor
/***********************************************************************/
/* Define: initialize the table definition block from XDB file. */
/***********************************************************************/
bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
{
int poff = 0;
Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1);
strcpy(Name, name);
Cat = cat;
Catfunc = GetFuncID(Cat->GetStringCatInfo(g, "Catfunc", NULL));
Elemt = cat->GetIntCatInfo("Elements", 0);
Multiple = cat->GetIntCatInfo("Multiple", 0);
Degree = cat->GetIntCatInfo("Degree", 0);
Read_Only = cat->GetBoolCatInfo("ReadOnly", false);
const char *data_charset_name= cat->GetStringCatInfo(g, "Data_charset", NULL);
m_data_charset= data_charset_name ?
get_charset_by_csname(data_charset_name, MY_CS_PRIMARY, 0):
NULL;
// Get The column definitions
if ((poff = cat->GetColCatInfo(g, this)) < 0)
return true;
// Do the definition of AM specific fields
return DefineAM(g, am, poff);
} // end of Define
/* --------------------------- Class OEMDEF -------------------------- */
/***********************************************************************/
/* GetXdef: get the external TABDEF from OEM module. */
/***********************************************************************/
PTABDEF OEMDEF::GetXdef(PGLOBAL g)
{
typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *);
char c, getname[40] = "Get";
PTABDEF xdefp;
XGETDEF getdef = NULL;
PCATLG cat = Cat;
#if defined(WIN32)
// Is the DLL already loaded?
if (!Hdll && !(Hdll = GetModuleHandle(Module)))
// No, load the Dll implementing the function
if (!(Hdll = LoadLibrary(Module))) {
char buf[256];
DWORD rc = GetLastError();
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
strcat(strcat(g->Message, ": "), buf);
return NULL;
} // endif hDll
// The exported name is always in uppercase
for (int i = 0; ; i++) {
c = Subtype[i];
getname[i + 3] = toupper(c);
if (!c) break;
} // endfor i
// Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) {
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname);
FreeLibrary((HMODULE)Hdll);
return NULL;
} // endif getdef
#else // !WIN32
const char *error = NULL;
// Is the library already loaded?
// if (!Hdll && !(Hdll = ???))
// Load the desired shared library
if (!(Hdll = dlopen(Module, RTLD_LAZY))) {
error = dlerror();
sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error));
return NULL;
} // endif Hdll
// The exported name is always in uppercase
for (int i = 0; ; i++) {
c = Subtype[i];
getname[i + 3] = toupper(c);
if (!c) break;
} // endfor i
// Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)dlsym(Hdll, getname))) {
error = dlerror();
sprintf(g->Message, MSG(GET_FUNC_ERR), getname, SVP(error));
dlclose(Hdll);
return NULL;
} // endif getdef
#endif // !WIN32
// Just in case the external Get function does not set error messages
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype);
// Get the table definition block
if (!(xdefp = getdef(g, NULL)))
return NULL;
// Have the external class do its complete definition
if (!cat->Cbuf) {
// Suballocate a temporary buffer for the entire column section
cat->Cblen = cat->GetSizeCatInfo("Colsize", "8K");
cat->Cbuf = (char*)PlugSubAlloc(g, NULL, cat->Cblen);
} // endif Cbuf
// Here "OEM" should be replace by a more useful value
if (xdefp->Define(g, cat, Name, "OEM"))
return NULL;
// Ok, return external block
return xdefp;
} // end of GetXdef
#if 0
/***********************************************************************/
/* DeleteTableFile: Delete an OEM table file if applicable. */
/***********************************************************************/
bool OEMDEF::DeleteTableFile(PGLOBAL g)
{
if (!Pxdef)
Pxdef = GetXdef(g);
return (Pxdef) ? Pxdef->DeleteTableFile(g) : true;
} // end of DeleteTableFile
#endif // 0
/***********************************************************************/
/* Define: initialize the table definition block from XDB file. */
/***********************************************************************/
bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
Module = Cat->GetStringCatInfo(g, "Module", "");
Subtype = Cat->GetStringCatInfo(g, "Subtype", Module);
if (!*Module)
Module = Subtype;
Desc = (char*)PlugSubAlloc(g, NULL, strlen(Module)
+ strlen(Subtype) + 3);
sprintf(Desc, "%s(%s)", Module, Subtype);
return false;
} // end of DefineAM
/***********************************************************************/
/* GetTable: makes a new Table Description Block. */
/***********************************************************************/
PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
{
RECFM rfm;
PTDBASE tdbp = NULL;
// If define block not here yet, get it now
if (!Pxdef && !(Pxdef = GetXdef(g)))
return NULL; // Error
/*********************************************************************/
/* Allocate a TDB of the proper type. */
/* Column blocks will be allocated only when needed. */
/*********************************************************************/
if (!(tdbp = (PTDBASE)Pxdef->GetTable(g, mode)))
return NULL;
else
rfm = tdbp->GetFtype();
if (rfm == RECFM_NAF)
return tdbp;
else if (rfm == RECFM_OEM) {
if (Multiple)
tdbp = new(g) TDBMUL(tdbp); // No block optimization yet
return tdbp;
} // endif OEM
/*********************************************************************/
/* The OEM table is based on a file type (currently DOS+ only) */
/*********************************************************************/
assert (rfm == RECFM_VAR || rfm == RECFM_FIX ||
rfm == RECFM_BIN || rfm == RECFM_VCT);
PTXF txfp = NULL;
PDOSDEF defp = (PDOSDEF)Pxdef;
bool map = defp->Mapped && mode != MODE_INSERT &&
!(PlgGetUser(g)->UseTemp == TMP_FORCE &&
(mode == MODE_UPDATE || mode == MODE_DELETE));
int cmpr = defp->Compressed;
/*********************************************************************/
/* Allocate table and file processing class of the proper type. */
/* Column blocks will be allocated only when needed. */
/*********************************************************************/
if (!((PTDBDOS)tdbp)->GetTxfp()) {
if (cmpr) {
#if defined(ZIP_SUPPORT)
if (cmpr == 1)
txfp = new(g) ZIPFAM(defp);
else
txfp = new(g) ZLBFAM(defp);
#else // !ZIP_SUPPORT
strcpy(g->Message, "Compress not supported");
return NULL;
#endif // !ZIP_SUPPORT
} else if (rfm == RECFM_VAR) {
if (map)
txfp = new(g) MAPFAM(defp);
else
txfp = new(g) DOSFAM(defp);
} else if (rfm == RECFM_FIX || rfm == RECFM_BIN) {
if (map)
txfp = new(g) MPXFAM(defp);
else
txfp = new(g) FIXFAM(defp);
} else if (rfm == RECFM_VCT) {
assert (Pxdef->GetDefType() == TYPE_AM_VCT);
if (map)
txfp = new(g) VCMFAM((PVCTDEF)defp);
else
txfp = new(g) VCTFAM((PVCTDEF)defp);
} // endif's
((PTDBDOS)tdbp)->SetTxfp(txfp);
} // endif Txfp
if (Multiple)
tdbp = new(g) TDBMUL(tdbp);
return tdbp;
} // end of GetTable
/* --------------------------- Class COLCRT -------------------------- */
/***********************************************************************/
/* COLCRT Constructors. */
/***********************************************************************/
COLCRT::COLCRT(PSZ name)
{
Next = NULL;
Name = name;
Desc = NULL;
Decode = NULL;
Fmt = NULL;
Offset = -1;
Long = -1;
Precision = -1;
Freq = -1;
Key = -1;
Scale = -1;
Opt = -1;
DataType = '*';
} // end of COLCRT constructor for table creation
COLCRT::COLCRT(void)
{
Next = NULL;
Name = NULL;
Desc = NULL;
Decode = NULL;
Fmt = NULL;
Offset = 0;
Long = 0;
Precision = 0;
Freq = 0;
Key = 0;
Scale = 0;
Opt = 0;
DataType = '*';
} // end of COLCRT constructor for table & view definition
/* --------------------------- Class COLDEF -------------------------- */
/***********************************************************************/
/* COLDEF Constructor. */
/***********************************************************************/
COLDEF::COLDEF(void) : COLCRT()
{
To_Min = NULL;
To_Max = NULL;
To_Pos = NULL;
Xdb2 = FALSE;
To_Bmap = NULL;
To_Dval = NULL;
Ndv = 0;
Nbm = 0;
Buf_Type = TYPE_ERROR;
Clen = 0;
Poff = 0;
memset(&F, 0, sizeof(FORMAT));
Flags = 0;
} // end of COLDEF constructor
/***********************************************************************/
/* Define: initialize a column definition from a COLINFO structure. */
/***********************************************************************/
int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
{
Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1);
strcpy(Name, cfp->Name);
if (!(cfp->Flags & U_SPECIAL)) {
Poff = poff;
Buf_Type = cfp->Type;
if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) <= 0) {
sprintf(g->Message, MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name);
return -1;
} // endswitch
strcpy(F.Type, GetFormatType(Buf_Type));
F.Length = cfp->Length;
F.Prec = cfp->Scale;
Offset = (cfp->Offset < 0) ? poff : cfp->Offset;
Precision = cfp->Precision;
Scale = cfp->Scale;
Long = cfp->Length;
Opt = cfp->Opt;
Key = cfp->Key;
Freq = cfp->Freq;
if (cfp->Remark && *cfp->Remark) {
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1);
strcpy(Desc, cfp->Remark);
} // endif Remark
if (cfp->Datefmt) {
Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1);
strcpy(Decode, cfp->Datefmt);
} // endif Datefmt
} // endif special
if (cfp->Fieldfmt) {
Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1);
strcpy(Fmt, cfp->Fieldfmt);
} // endif Fieldfmt
Flags = cfp->Flags;
return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long;
} // end of Define
/* ------------------------- End of RelDef --------------------------- */

View File

@@ -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
htrc(" making copy TABLE %s %s\n", Name, Srcdef);
#endif
if (trace)
htrc(" making copy TABLE %s %s\n", Name, Srcdef);
} // end of XTAB constructor
/***********************************************************************/
@@ -61,9 +63,8 @@ PTABLE XTAB::Link(PTABLE tab2)
{
PTABLE tabp;
#ifdef DEBTRACE
htrc("Linking tables %s... to %s\n", Name, tab2->Name);
#endif
if (trace)
htrc("Linking tables %s... to %s\n", Name, tab2->Name);
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
htrc(" making new COLUMN %s\n", Name);
#endif
if (trace)
htrc(" making new COLUMN %s\n", Name);
} // end of COLUMN constructor
/***********************************************************************/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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));

View File

@@ -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) {

View File

@@ -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
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 (trace)
htrc("VCT OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n",
this, Tdb_No, Use, To_Key_Col, Mode);
if (Use == USE_OPEN) {
/*******************************************************************/
@@ -344,12 +345,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",
GetTdb_No(), Mode, Txfp->CurBlk, Txfp->CurNum,
To_Key_Col, To_Link, To_Kindex);
#endif
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);
if (To_Kindex) {
/*******************************************************************/
@@ -524,15 +523,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",
Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
#endif
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);
if (ColBlk != txfp->CurBlk)
ReadBlock(g);
@@ -558,11 +555,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",
Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
#endif
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);
ColBlk = txfp->CurBlk;
ColPos = txfp->CurNum;

View File

@@ -1,161 +1,160 @@
/* Copyright (C) Olivier Bertrand 2004 - 2012
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**
@file user_connect.cc
@brief
Implements the user_connect class.
@details
To support multi_threading, each query creates and use a PlugDB "user"
that is a connection with its personnal memory allocation.
@note
*/
/****************************************************************************/
/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2012 */
/****************************************************************************/
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#define DONT_DEFINE_VOID
#define MYSQL_SERVER
#include "sql_class.h"
#undef OFFSET
#define NOPARSE
#include "osutil.h"
#include "global.h"
#include "plgdbsem.h"
#include "connect.h"
#include "user_connect.h"
#include "mycat.h"
extern "C" char plgxini[];
extern int xtrace;
/****************************************************************************/
/* Initialize the user_connect static member. */
/****************************************************************************/
PCONNECT user_connect::to_users= NULL;
/* -------------------------- class user_connect -------------------------- */
/****************************************************************************/
/* Constructor. */
/****************************************************************************/
user_connect::user_connect(THD *thd, const char *dbn)
{
thdp= thd;
next= NULL;
previous= NULL;
g= NULL;
last_query_id= 0;
count= 0;
// Statistics
nrd= fnd= nfd= 0;
tb1= 0;
} // end of user_connect constructor
/****************************************************************************/
/* Destructor. */
/****************************************************************************/
user_connect::~user_connect()
{
// Terminate CONNECT and Plug-like environment, should return NULL
g= CntExit(g);
} // end of user_connect destructor
/****************************************************************************/
/* Initialization. */
/****************************************************************************/
bool user_connect::user_init()
{
// Initialize Plug-like environment
PACTIVITY ap= NULL;
PDBUSER dup= NULL;
// Areasize= 64M because of VEC tables. Should be parameterisable
g= PlugInit(NULL, 67108864);
//g= PlugInit(NULL, 134217728); // 128M was because of old embedded tests
// Check whether the initialization is complete
if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size)
|| !(dup= PlgMakeUser(g))) {
if (g)
printf("%s\n", g->Message);
int rc= PlugExit(g);
g= NULL;
free(dup);
return true;
} // endif g->
dup->Catalog= new MYCAT(NULL);
ap= new ACTIVITY;
memset(ap, 0, sizeof(ACTIVITY));
strcpy(ap->Ap_Name, "CONNECT");
g->Activityp= ap;
g->Activityp->Aptr= dup;
next= to_users;
to_users= this;
if (next)
next->previous= this;
last_query_id= thdp->query_id;
count= 1;
return false;
} // end of user_init
void user_connect::SetHandler(ha_connect *hc)
{
PDBUSER dup= (PDBUSER)g->Activityp->Aptr;
MYCAT *mc= (MYCAT*)dup->Catalog;
mc->SetHandler(hc);
}
/****************************************************************************/
/* Check whether we begin a new query and if so cleanup the previous one. */
/****************************************************************************/
bool user_connect::CheckCleanup(void)
{
if (thdp->query_id > last_query_id) {
PlugCleanup(g, true);
PlugSubSet(g, g->Sarea, g->Sarea_Size);
g->Xchk = NULL;
g->Createas = 0;
g->Alchecked = 0;
g->Mrr = 0;
last_query_id= thdp->query_id;
if (xtrace)
printf("=====> Begin new query %llu\n", last_query_id);
return true;
} // endif query_id
return false;
} // end of CheckCleanup
/* Copyright (C) Olivier Bertrand 2004 - 2014
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**
@file user_connect.cc
@brief
Implements the user_connect class.
@details
To support multi_threading, each query creates and use a PlugDB "user"
that is a connection with its personnal memory allocation.
@note
*/
/****************************************************************************/
/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2014 */
/****************************************************************************/
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#define DONT_DEFINE_VOID
#define MYSQL_SERVER
#include "sql_class.h"
#undef OFFSET
#define NOPARSE
#include "osutil.h"
#include "global.h"
#include "plgdbsem.h"
#include "connect.h"
#include "user_connect.h"
#include "mycat.h"
extern "C" int trace;
/****************************************************************************/
/* Initialize the user_connect static member. */
/****************************************************************************/
PCONNECT user_connect::to_users= NULL;
/* -------------------------- class user_connect -------------------------- */
/****************************************************************************/
/* Constructor. */
/****************************************************************************/
user_connect::user_connect(THD *thd, const char *dbn)
{
thdp= thd;
next= NULL;
previous= NULL;
g= NULL;
last_query_id= 0;
count= 0;
// Statistics
nrd= fnd= nfd= 0;
tb1= 0;
} // end of user_connect constructor
/****************************************************************************/
/* Destructor. */
/****************************************************************************/
user_connect::~user_connect()
{
// Terminate CONNECT and Plug-like environment, should return NULL
g= CntExit(g);
} // end of user_connect destructor
/****************************************************************************/
/* Initialization. */
/****************************************************************************/
bool user_connect::user_init()
{
// Initialize Plug-like environment
PACTIVITY ap= NULL;
PDBUSER dup= NULL;
// Areasize= 64M because of VEC tables. Should be parameterisable
g= PlugInit(NULL, 67108864);
//g= PlugInit(NULL, 134217728); // 128M was because of old embedded tests
// Check whether the initialization is complete
if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size)
|| !(dup= PlgMakeUser(g))) {
if (g)
printf("%s\n", g->Message);
int rc= PlugExit(g);
g= NULL;
free(dup);
return true;
} // endif g->
dup->Catalog= new MYCAT(NULL);
ap= new ACTIVITY;
memset(ap, 0, sizeof(ACTIVITY));
strcpy(ap->Ap_Name, "CONNECT");
g->Activityp= ap;
g->Activityp->Aptr= dup;
next= to_users;
to_users= this;
if (next)
next->previous= this;
last_query_id= thdp->query_id;
count= 1;
return false;
} // end of user_init
void user_connect::SetHandler(ha_connect *hc)
{
PDBUSER dup= (PDBUSER)g->Activityp->Aptr;
MYCAT *mc= (MYCAT*)dup->Catalog;
mc->SetHandler(hc);
}
/****************************************************************************/
/* Check whether we begin a new query and if so cleanup the previous one. */
/****************************************************************************/
bool user_connect::CheckCleanup(void)
{
if (thdp->query_id > last_query_id) {
PlugCleanup(g, true);
PlugSubSet(g, g->Sarea, g->Sarea_Size);
g->Xchk = NULL;
g->Createas = 0;
g->Alchecked = 0;
g->Mrr = 0;
last_query_id= thdp->query_id;
if (trace)
printf("=====> Begin new query %llu\n", last_query_id);
return true;
} // endif query_id
return false;
} // end of CheckCleanup

View File

@@ -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
htrc("AVB: mp=%p type=%d nval=%d len=%d check=%u blank=%u\n",
mp, type, nval, len, check, blank);
#endif
if (trace)
htrc("AVB: mp=%p type=%d nval=%d len=%d check=%u blank=%u\n",
mp, type, nval, len, check, blank);
switch (type) {
case TYPE_STRING:
@@ -576,7 +577,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++) {
@@ -767,13 +768,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));
@@ -846,13 +847,13 @@ void CHRBLK::SetMax(PVAL valp, int n)
/***********************************************************************/
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)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff