Commit 81ce7da7 authored by Olivier Bertrand's avatar Olivier Bertrand

- 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
parents 7b400a08 31560c44
...@@ -38,10 +38,9 @@ typedef class BLOCK *PBLOCK; ...@@ -38,10 +38,9 @@ typedef class BLOCK *PBLOCK;
class DllExport BLOCK { class DllExport BLOCK {
public: public:
void * operator new(size_t size, PGLOBAL g, void *p = NULL) { void * operator new(size_t size, PGLOBAL g, void *p = NULL) {
#ifdef DEBTRACE // if (trace > 2)
if (debug != NULL) // htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
#endif
return (PlugSubAlloc(g, p, size)); return (PlugSubAlloc(g, p, size));
} // end of new } // end of new
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "xindex.h" #include "xindex.h"
#include "xtable.h" #include "xtable.h"
extern "C" int trace;
/***********************************************************************/ /***********************************************************************/
/* COLBLK protected constructor. */ /* COLBLK protected constructor. */
/***********************************************************************/ /***********************************************************************/
...@@ -76,9 +78,8 @@ COLBLK::COLBLK(PCOL col1, PTDB tdbp) ...@@ -76,9 +78,8 @@ COLBLK::COLBLK(PCOL col1, PTDB tdbp)
//To_Orig = col1; //To_Orig = col1;
To_Tdb = tdbp; To_Tdb = tdbp;
#ifdef DEBTRACE if (trace > 1)
htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this); htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this);
#endif
if (tdbp) if (tdbp)
// Attach the new column to the table block // Attach the new column to the table block
...@@ -116,10 +117,9 @@ bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt) ...@@ -116,10 +117,9 @@ bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
{ {
fmt = Format; fmt = Format;
#ifdef DEBTRACE if (trace > 1)
htrc("COLBLK: %p format=%c(%d,%d)\n", htrc("COLBLK: %p format=%c(%d,%d)\n",
this, *fmt.Type, fmt.Length, fmt.Prec); this, *fmt.Type, fmt.Length, fmt.Prec);
#endif
return false; return false;
} // end of SetFormat } // end of SetFormat
...@@ -130,9 +130,8 @@ bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt) ...@@ -130,9 +130,8 @@ bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
/***********************************************************************/ /***********************************************************************/
bool COLBLK::Eval(PGLOBAL g) bool COLBLK::Eval(PGLOBAL g)
{ {
#ifdef DEBTRACE if (trace > 1)
htrc("Col Eval: %s status=%.4X\n", Name, Status); htrc("Col Eval: %s status=%.4X\n", Name, Status);
#endif
if (!GetStatus(BUF_READ)) { if (!GetStatus(BUF_READ)) {
// if (To_Tdb->IsNull()) // if (To_Tdb->IsNull())
...@@ -168,10 +167,9 @@ bool COLBLK::InitValue(PGLOBAL g) ...@@ -168,10 +167,9 @@ bool COLBLK::InitValue(PGLOBAL g)
AddStatus(BUF_READY); AddStatus(BUF_READY);
Value->SetNullable(Nullable); Value->SetNullable(Nullable);
#ifdef DEBTRACE if (trace > 1)
htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n", htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
this, Buf_Type, Value, ColUse, Status); this, Buf_Type, Value, ColUse, Status);
#endif
return false; return false;
} // end of InitValue } // end of InitValue
......
This diff is collapsed.
...@@ -22,9 +22,7 @@ ...@@ -22,9 +22,7 @@
#define THRESH 4 /* Threshold for insertion (was 4) */ #define THRESH 4 /* Threshold for insertion (was 4) */
#define MTHRESH 6 /* Threshold for median */ #define MTHRESH 6 /* Threshold for median */
#ifdef DEBTRACE //extern FILE *debug; /* Debug file */
extern FILE *debug; /* Debug file */
#endif
typedef int* const CPINT; typedef int* const CPINT;
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#include "filamap.h" #include "filamap.h"
#include "tabdos.h" #include "tabdos.h"
extern "C" int trace;
/* --------------------------- Class MAPFAM -------------------------- */ /* --------------------------- Class MAPFAM -------------------------- */
/***********************************************************************/ /***********************************************************************/
...@@ -89,9 +91,8 @@ int MAPFAM::GetFileLength(PGLOBAL g) ...@@ -89,9 +91,8 @@ int MAPFAM::GetFileLength(PGLOBAL g)
len = (To_Fb) ? To_Fb->Length : TXTFAM::GetFileLength(g); len = (To_Fb) ? To_Fb->Length : TXTFAM::GetFileLength(g);
#ifdef DEBTRACE if (trace)
htrc("Mapped file length=%d\n", len); htrc("Mapped file length=%d\n", len);
#endif
return len; return len;
} // end of GetFileLength } // end of GetFileLength
...@@ -166,9 +167,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) ...@@ -166,9 +167,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
sprintf(g->Message, MSG(OPEN_MODE_ERROR), sprintf(g->Message, MSG(OPEN_MODE_ERROR),
"map", (int) rc, filename); "map", (int) rc, filename);
#ifdef DEBTRACE if (trace)
htrc("%s\n", g->Message); htrc("CreateFileMap: %s\n", g->Message);
#endif
return (mode == MODE_READ && rc == ENOENT) return (mode == MODE_READ && rc == ENOENT)
? PushWarning(g, Tdbp) : true; ? PushWarning(g, Tdbp) : true;
} // endif hFile } // endif hFile
...@@ -228,10 +229,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) ...@@ -228,10 +229,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
Fpos = Mempos = Memory; Fpos = Mempos = Memory;
Top = Memory + len; Top = Memory + len;
#ifdef DEBTRACE if (trace)
htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n", htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n",
fp, fp->Count, Memory, len, Top); fp, fp->Count, Memory, len, Top);
#endif
return AllocateBuffer(g); // Useful for DBF files return AllocateBuffer(g); // Useful for DBF files
} // end of OpenTableFile } // end of OpenTableFile
...@@ -383,20 +383,19 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) ...@@ -383,20 +383,19 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
{ {
int n; int n;
#ifdef DEBTRACE if (trace)
fprintf(debug, htrc("MAP DeleteDB: irc=%d mempos=%p tobuf=%p Tpos=%p Spos=%p\n",
"MAP DeleteDB: irc=%d mempos=%p tobuf=%p Tpos=%p Spos=%p\n", irc, Mempos, To_Buf, Tpos, Spos);
irc, Mempos, To_Buf, Tpos, Spos);
#endif
if (irc != RC_OK) { if (irc != RC_OK) {
/*******************************************************************/ /*******************************************************************/
/* EOF: position Fpos at the top of map position. */ /* EOF: position Fpos at the top of map position. */
/*******************************************************************/ /*******************************************************************/
Fpos = Top; Fpos = Top;
#ifdef DEBTRACE
htrc("Fpos placed at file top=%p\n", Fpos); if (trace)
#endif htrc("Fpos placed at file top=%p\n", Fpos);
} // endif irc } // endif irc
if (Tpos == Spos) if (Tpos == Spos)
...@@ -412,17 +411,16 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) ...@@ -412,17 +411,16 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
memmove(Tpos, Spos, n); memmove(Tpos, Spos, n);
Tpos += n; Tpos += n;
#ifdef DEBTRACE if (trace)
htrc("move %d bytes\n", n); htrc("move %d bytes\n", n);
#endif
} // endif n } // endif n
if (irc == RC_OK) { if (irc == RC_OK) {
Spos = Mempos; // New start position Spos = Mempos; // New start position
#ifdef DEBTRACE if (trace)
htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos); htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos);
#endif
} else if (To_Fb) { // Can be NULL for deleted files } else if (To_Fb) { // Can be NULL for deleted files
/*******************************************************************/ /*******************************************************************/
...@@ -450,9 +448,8 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) ...@@ -450,9 +448,8 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
return RC_FX; return RC_FX;
} // endif } // endif
#ifdef DEBTRACE if (trace)
htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc); htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
#endif
if (!SetEndOfFile(fp->Handle)) { if (!SetEndOfFile(fp->Handle)) {
sprintf(g->Message, MSG(FUNCTION_ERROR), sprintf(g->Message, MSG(FUNCTION_ERROR),
...@@ -484,10 +481,10 @@ void MAPFAM::CloseTableFile(PGLOBAL g) ...@@ -484,10 +481,10 @@ void MAPFAM::CloseTableFile(PGLOBAL g)
PlugCloseFile(g, To_Fb); PlugCloseFile(g, To_Fb);
To_Fb = NULL; // To get correct file size in Cardinality To_Fb = NULL; // To get correct file size in Cardinality
#ifdef DEBTRACE if (trace)
htrc("MAP Close: closing %s count=%d\n", htrc("MAP Close: closing %s count=%d\n",
To_File, (To_Fb) ? To_Fb->Count : 0); To_File, (To_Fb) ? To_Fb->Count : 0);
#endif
} // end of CloseTableFile } // end of CloseTableFile
/***********************************************************************/ /***********************************************************************/
......
...@@ -485,16 +485,15 @@ bool DBFFAM::OpenTableFile(PGLOBAL g) ...@@ -485,16 +485,15 @@ bool DBFFAM::OpenTableFile(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath()); PlugSetPath(filename, To_File, Tdbp->GetPath());
if (!(Stream = PlugOpenFile(g, filename, opmode))) { if (!(Stream = PlugOpenFile(g, filename, opmode))) {
#ifdef DEBTRACE if (trace)
htrc("%s\n", g->Message); htrc("%s\n", g->Message);
#endif
return (mode == MODE_READ && errno == ENOENT) return (mode == MODE_READ && errno == ENOENT)
? PushWarning(g, Tdbp) : true; ? PushWarning(g, Tdbp) : true;
} // endif Stream } // endif Stream
#ifdef DEBTRACE if (trace)
htrc("File %s is open in mode %s\n", filename, opmode); htrc("File %s is open in mode %s\n", filename, opmode);
#endif
To_Fb = dbuserp->Openlist; // Keep track of File block To_Fb = dbuserp->Openlist; // Keep track of File block
...@@ -853,10 +852,10 @@ void DBFFAM::CloseTableFile(PGLOBAL g) ...@@ -853,10 +852,10 @@ void DBFFAM::CloseTableFile(PGLOBAL g)
rc = PlugCloseFile(g, To_Fb); rc = PlugCloseFile(g, To_Fb);
fin: fin:
#ifdef DEBTRACE if (trace)
htrc("DBF CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n", htrc("DBF CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
To_File, mode, wrc, rc); To_File, mode, wrc, rc);
#endif
Stream = NULL; // So we can know whether table is open Stream = NULL; // So we can know whether table is open
} // end of CloseTableFile } // end of CloseTableFile
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
extern "C" HINSTANCE s_hModule; // Saved module handle extern "C" HINSTANCE s_hModule; // Saved module handle
#endif // !WIN32 #endif // !WIN32
extern int xtrace; extern "C" int trace;
PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
...@@ -716,7 +716,7 @@ bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp) ...@@ -716,7 +716,7 @@ bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp)
PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name, PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
LPCSTR type, PRELDEF *prp) LPCSTR type, PRELDEF *prp)
{ {
if (xtrace) if (trace)
printf("GetTableDesc: name=%s am=%s\n", name, SVP(type)); printf("GetTableDesc: name=%s am=%s\n", name, SVP(type));
// If not specified get the type of this table // If not specified get the type of this table
...@@ -735,7 +735,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) ...@@ -735,7 +735,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am)
TABTYPE tc; TABTYPE tc;
PRELDEF tdp= NULL; PRELDEF tdp= NULL;
if (xtrace) if (trace)
printf("MakeTableDesc: name=%s am=%s\n", name, SVP(am)); 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) ...@@ -794,14 +794,14 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
PTDB tdbp= NULL; PTDB tdbp= NULL;
LPCSTR name= tablep->GetName(); LPCSTR name= tablep->GetName();
if (xtrace) if (trace)
printf("GetTableDB: name=%s\n", name); printf("GetTableDB: name=%s\n", name);
// Look for the description of the requested table // Look for the description of the requested table
tdp= GetTableDesc(g, name, type); tdp= GetTableDesc(g, name, type);
if (tdp) { if (tdp) {
if (xtrace) if (trace)
printf("tdb=%p type=%s\n", tdp, tdp->GetType()); printf("tdb=%p type=%s\n", tdp, tdp->GetType());
if (tablep->GetQualifier()) if (tablep->GetQualifier())
...@@ -811,7 +811,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type) ...@@ -811,7 +811,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
} // endif tdp } // endif tdp
if (tdbp) { if (tdbp) {
if (xtrace) if (trace)
printf("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(), printf("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(),
tdbp->GetAmType()); tdbp->GetAmType());
tablep->SetTo_Tdb(tdbp); tablep->SetTo_Tdb(tdbp);
......
...@@ -295,7 +295,7 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db, ...@@ -295,7 +295,7 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db,
// Send the source command to MySQL // Send the source command to MySQL
if (myc.ExecSQL(g, query, &w) == RC_OK) if (myc.ExecSQL(g, query, &w) == RC_OK)
qrp = myc.GetResult(g); qrp = myc.GetResult(g, true);
myc.Close(); myc.Close();
return qrp; return qrp;
...@@ -676,7 +676,7 @@ MYSQL_FIELD *MYSQLC::GetNextField(void) ...@@ -676,7 +676,7 @@ MYSQL_FIELD *MYSQLC::GetNextField(void)
/***********************************************************************/ /***********************************************************************/
PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
{ {
char *fmt; char *fmt, v;
int n; int n;
bool uns; bool uns;
PCOLRES *pcrp, crp; PCOLRES *pcrp, crp;
...@@ -705,7 +705,6 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) ...@@ -705,7 +705,6 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
qrp->Nblin = 0; qrp->Nblin = 0;
qrp->Cursor = 0; qrp->Cursor = 0;
//for (fld = mysql_fetch_field(m_Res); fld; //for (fld = mysql_fetch_field(m_Res); fld;
// fld = mysql_fetch_field(m_Res)) { // fld = mysql_fetch_field(m_Res)) {
for (fld = GetNextField(); fld; fld = GetNextField()) { for (fld = GetNextField(); fld; fld = GetNextField()) {
...@@ -718,17 +717,19 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) ...@@ -718,17 +717,19 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
crp->Name = (char*)PlugSubAlloc(g, NULL, fld->name_length + 1); crp->Name = (char*)PlugSubAlloc(g, NULL, fld->name_length + 1);
strcpy(crp->Name, fld->name); 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", sprintf(g->Message, "Type %d not supported for column %s",
fld->type, crp->Name); fld->type, crp->Name);
return NULL; return NULL;
} else if (crp->Type == TYPE_DATE && !pdb) } else if (crp->Type == TYPE_DATE && !pdb)
// For direct MySQL connection, display the MySQL date string // For direct MySQL connection, display the MySQL date string
crp->Type = TYPE_STRING; crp->Type = TYPE_STRING;
else
crp->Var = v;
crp->Prec = (crp->Type == TYPE_DOUBLE || crp->Type == TYPE_DECIM) crp->Prec = (crp->Type == TYPE_DOUBLE || crp->Type == TYPE_DECIM)
? fld->decimals : 0; ? fld->decimals : 0;
crp->Length = fld->max_length; crp->Length = max(fld->length, fld->max_length);
crp->Clen = GetTypeSize(crp->Type, crp->Length); crp->Clen = GetTypeSize(crp->Type, crp->Length);
uns = (fld->flags & (UNSIGNED_FLAG | ZEROFILL_FLAG)) ? true : false; uns = (fld->flags & (UNSIGNED_FLAG | ZEROFILL_FLAG)) ? true : false;
......
...@@ -58,12 +58,8 @@ int MYSQLtoPLG(char *typname, char *var) ...@@ -58,12 +58,8 @@ int MYSQLtoPLG(char *typname, char *var)
type = TYPE_ERROR; type = TYPE_ERROR;
if (var) { 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) { if (type == TYPE_DATE) {
// This is to make the difference between temporal values
if (!stricmp(typname, "date")) if (!stricmp(typname, "date"))
*var = 'D'; *var = 'D';
else if (!stricmp(typname, "datetime")) else if (!stricmp(typname, "datetime"))
...@@ -75,7 +71,11 @@ int MYSQLtoPLG(char *typname, char *var) ...@@ -75,7 +71,11 @@ int MYSQLtoPLG(char *typname, char *var)
else if (!stricmp(typname, "year")) else if (!stricmp(typname, "year"))
*var = 'Y'; *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 } // endif var
...@@ -200,7 +200,6 @@ int MYSQLtoPLG(int mytype, char *var) ...@@ -200,7 +200,6 @@ int MYSQLtoPLG(int mytype, char *var)
case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
if (var) *var = 'V';
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
type = TYPE_STRING; type = TYPE_STRING;
break; break;
...@@ -208,6 +207,25 @@ int MYSQLtoPLG(int mytype, char *var) ...@@ -208,6 +207,25 @@ int MYSQLtoPLG(int mytype, char *var)
type = TYPE_ERROR; type = TYPE_ERROR;
} // endswitch mytype } // 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; return type;
} // end of MYSQLtoPLG } // end of MYSQLtoPLG
......
...@@ -78,8 +78,8 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft) ...@@ -78,8 +78,8 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft)
LPCSTR p2, p = name; LPCSTR p2, p = name;
#ifdef DEBTRACE #ifdef DEBTRACE
fprintf(debug,"SplitPath: name=%s [%s (%d)]\n", htrc("SplitPath: name=%s [%s (%d)]\n",
XSTR(name), XSTR(__FILE__), __LINE__); XSTR(name), XSTR(__FILE__), __LINE__);
#endif #endif
if (drive) *drive = '\0'; if (drive) *drive = '\0';
...@@ -100,7 +100,7 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft) ...@@ -100,7 +100,7 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft)
if (fn) strcpy(fn, p); if (fn) strcpy(fn, p);
#ifdef DEBTRACE #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__); XSTR(name), XSTR(drive), XSTR(dir), XSTR(fn), XSTR(ft), __FILE__, __LINE__);
#endif #endif
} /* end of _splitpath */ } /* end of _splitpath */
......
...@@ -531,6 +531,7 @@ typedef struct _colres { ...@@ -531,6 +531,7 @@ typedef struct _colres {
int Prec; /* Precision */ int Prec; /* Precision */
int Flag; /* Flag option value */ int Flag; /* Flag option value */
XFLD Fld; /* Type of field info */ XFLD Fld; /* Type of field info */
char Var; /* Type added information */
} COLRES; } COLRES;
#if defined(WIN32) && !defined(NOEX) #if defined(WIN32) && !defined(NOEX)
......
...@@ -80,9 +80,6 @@ extern pthread_mutex_t parmut; ...@@ -80,9 +80,6 @@ extern pthread_mutex_t parmut;
#endif // !WIN32 #endif // !WIN32
#endif // THREAD #endif // THREAD
#define PLGINI "plugdb.ini" /* Configuration settings file */
#define PLGXINI "plgcnx.ini" /* Configuration settings file */
/***********************************************************************/ /***********************************************************************/
/* DB static variables. */ /* DB static variables. */
/***********************************************************************/ /***********************************************************************/
...@@ -90,27 +87,13 @@ bool Initdone = false; ...@@ -90,27 +87,13 @@ bool Initdone = false;
bool plugin = false; // True when called by the XDB plugin handler bool plugin = false; // True when called by the XDB plugin handler
extern "C" { 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) #if defined(XMSG)
char msglang[16] = "ENGLISH"; // Default language char msglang[16] = "ENGLISH"; // Default language
#endif #endif
extern int trace;
extern char version[];
} // extern "C" } // extern "C"
extern "C" int trace;
extern "C" char version[];
// The debug trace used by the main thread // The debug trace used by the main thread
FILE *pfile = NULL; FILE *pfile = NULL;
...@@ -219,27 +202,6 @@ int global_open(GLOBAL *g, int msgid, const char *path, int flags, int mode) ...@@ -219,27 +202,6 @@ int global_open(GLOBAL *g, int msgid, const char *path, int flags, int mode)
return h; 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) DllExport void SetTrc(void)
{ {
// If tracing is on, debug must be initialized. // If tracing is on, debug must be initialized.
...@@ -418,138 +380,9 @@ char *PlgGetDataPath(PGLOBAL g) ...@@ -418,138 +380,9 @@ char *PlgGetDataPath(PGLOBAL g)
{ {
PCATLG cat = PlgGetCatalog(g, false); PCATLG cat = PlgGetCatalog(g, false);
//if (!cat)
// return GetIniString(g, NULL, "DataBase", "DataPath", "", plgini);
return (cat) ? cat->GetDataPath() : NULL; return (cat) ? cat->GetDataPath() : NULL;
} // end of PlgGetDataPath } // 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. */ /* Check the occurence and matching of a pattern against a string. */
/* Because this function is only used for catalog name checking, */ /* Because this function is only used for catalog name checking, */
...@@ -1459,19 +1292,17 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size) ...@@ -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 */ size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */
pph = (PPOOLHEADER)memp; pph = (PPOOLHEADER)memp;
#if defined(DEBTRACE) if (trace > 1)
htrc("PlgDBSubAlloc: memp=%p size=%d used=%d free=%d\n", htrc("PlgDBSubAlloc: memp=%p size=%d used=%d free=%d\n",
memp, size, pph->To_Free, pph->FreeBlk); memp, size, pph->To_Free, pph->FreeBlk);
#endif
if ((uint)size > pph->FreeBlk) { /* Not enough memory left in pool */ if ((uint)size > pph->FreeBlk) { /* Not enough memory left in pool */
sprintf(g->Message, sprintf(g->Message,
"Not enough memory in Work area for request of %d (used=%d free=%d)", "Not enough memory in Work area for request of %d (used=%d free=%d)",
(int) size, pph->To_Free, pph->FreeBlk); (int) size, pph->To_Free, pph->FreeBlk);
#if defined(DEBTRACE) if (trace)
htrc("%s\n", g->Message); htrc("%s\n", g->Message);
#endif
return NULL; return NULL;
} // endif size } // endif size
...@@ -1482,10 +1313,11 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size) ...@@ -1482,10 +1313,11 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
memp = MakePtr(memp, pph->To_Free); // Points to suballocated block memp = MakePtr(memp, pph->To_Free); // Points to suballocated block
pph->To_Free += size; // New offset of pool free block pph->To_Free += size; // New offset of pool free block
pph->FreeBlk -= size; // New size 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", if (trace > 1)
memp, pph->To_Free, pph->FreeBlk); htrc("Done memp=%p used=%d free=%d\n",
#endif memp, pph->To_Free, pph->FreeBlk);
return (memp); return (memp);
} // end of PlgDBSubAlloc } // end of PlgDBSubAlloc
......
This diff is collapsed.
This diff is collapsed.
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "xtable.h" #include "xtable.h"
#include "tabcol.h" #include "tabcol.h"
extern "C" int trace;
/***********************************************************************/ /***********************************************************************/
/* XTAB public constructor. */ /* XTAB public constructor. */
/***********************************************************************/ /***********************************************************************/
...@@ -33,9 +35,9 @@ XTAB::XTAB(LPCSTR name, LPCSTR srcdef) : Name(name) ...@@ -33,9 +35,9 @@ XTAB::XTAB(LPCSTR name, LPCSTR srcdef) : Name(name)
Schema = NULL; Schema = NULL;
Qualifier = NULL; Qualifier = NULL;
#ifdef DEBTRACE if (trace)
htrc(" making new TABLE %s %s\n", Name, Srcdef); htrc("XTAB: making new TABLE %s %s\n", Name, Srcdef);
#endif
} // end of XTAB constructor } // end of XTAB constructor
/***********************************************************************/ /***********************************************************************/
...@@ -49,9 +51,9 @@ XTAB::XTAB(PTABLE tp) : Name(tp->Name) ...@@ -49,9 +51,9 @@ XTAB::XTAB(PTABLE tp) : Name(tp->Name)
Schema = tp->Schema; Schema = tp->Schema;
Qualifier = tp->Qualifier; Qualifier = tp->Qualifier;
#ifdef DEBTRACE if (trace)
htrc(" making copy TABLE %s %s\n", Name, Srcdef); htrc(" making copy TABLE %s %s\n", Name, Srcdef);
#endif
} // end of XTAB constructor } // end of XTAB constructor
/***********************************************************************/ /***********************************************************************/
...@@ -61,9 +63,8 @@ PTABLE XTAB::Link(PTABLE tab2) ...@@ -61,9 +63,8 @@ PTABLE XTAB::Link(PTABLE tab2)
{ {
PTABLE tabp; PTABLE tabp;
#ifdef DEBTRACE if (trace)
htrc("Linking tables %s... to %s\n", Name, tab2->Name); htrc("Linking tables %s... to %s\n", Name, tab2->Name);
#endif
for (tabp = this; tabp->Next; tabp = tabp->Next) ; for (tabp = this; tabp->Next; tabp = tabp->Next) ;
...@@ -118,9 +119,9 @@ COLUMN::COLUMN(LPCSTR name) : Name(name) ...@@ -118,9 +119,9 @@ COLUMN::COLUMN(LPCSTR name) : Name(name)
To_Col = NULL; To_Col = NULL;
Qualifier = NULL; Qualifier = NULL;
#ifdef DEBTRACE if (trace)
htrc(" making new COLUMN %s\n", Name); htrc(" making new COLUMN %s\n", Name);
#endif
} // end of COLUMN constructor } // end of COLUMN constructor
/***********************************************************************/ /***********************************************************************/
......
This diff is collapsed.
This diff is collapsed.
...@@ -1066,7 +1066,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g) ...@@ -1066,7 +1066,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
} // endif Buf_Type } // endif Buf_Type
if (g->Trace) { if (g->Trace) {
char buf[32]; char buf[64];
htrc("ODBC Column %s: rows=%d buf=%p type=%d value=%s\n", htrc("ODBC Column %s: rows=%d buf=%p type=%d value=%s\n",
Name, tdbp->Rows, Bufp, Buf_Type, Value->GetCharString(buf)); Name, tdbp->Rows, Bufp, Buf_Type, Value->GetCharString(buf));
......
...@@ -95,7 +95,7 @@ PIVAID::PIVAID(const char *tab, const char *src, const char *picol, ...@@ -95,7 +95,7 @@ PIVAID::PIVAID(const char *tab, const char *src, const char *picol,
/***********************************************************************/ /***********************************************************************/
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
{ {
char *query, *colname, buf[32]; char *query, *colname, buf[64];
int ndif, nblin, w = 0; int ndif, nblin, w = 0;
PVAL valp; PVAL valp;
PCOLRES *pcrp, crp, fncrp = NULL; PCOLRES *pcrp, crp, fncrp = NULL;
...@@ -121,7 +121,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) ...@@ -121,7 +121,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} // endif Exec } // endif Exec
// We must have a storage query to get pivot column values // We must have a storage query to get pivot column values
Qryp = Myc.GetResult(g); Qryp = Myc.GetResult(g, true);
Myc.Close(); Myc.Close();
if (!Fncol) { if (!Fncol) {
......
...@@ -76,6 +76,8 @@ ...@@ -76,6 +76,8 @@
char *strerror(int num); char *strerror(int num);
#endif // UNIX #endif // UNIX
extern "C" int trace;
/***********************************************************************/ /***********************************************************************/
/* Char VCT column blocks are right filled with blanks (blank = true) */ /* Char VCT column blocks are right filled with blanks (blank = true) */
/* Conversion of block values allowed conditionally for insert only. */ /* Conversion of block values allowed conditionally for insert only. */
...@@ -287,10 +289,9 @@ PCOL TDBVCT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) ...@@ -287,10 +289,9 @@ PCOL TDBVCT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/***********************************************************************/ /***********************************************************************/
bool TDBVCT::OpenDB(PGLOBAL g) bool TDBVCT::OpenDB(PGLOBAL g)
{ {
#ifdef DEBTRACE if (trace)
htrc("VCT OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n", htrc("VCT OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n",
this, Tdb_No, Use, To_Key_Col, Mode); this, Tdb_No, Use, To_Key_Col, Mode);
#endif
if (Use == USE_OPEN) { if (Use == USE_OPEN) {
/*******************************************************************/ /*******************************************************************/
...@@ -344,12 +345,10 @@ bool TDBVCT::OpenDB(PGLOBAL g) ...@@ -344,12 +345,10 @@ bool TDBVCT::OpenDB(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int TDBVCT::ReadDB(PGLOBAL g) int TDBVCT::ReadDB(PGLOBAL g)
{ {
#ifdef DEBTRACE if (trace)
fprintf(debug, htrc("VCT ReadDB: R%d Mode=%d CurBlk=%d CurNum=%d key=%p link=%p Kindex=%p\n",
"VCT ReadDB: R%d Mode=%d CurBlk=%d CurNum=%d key=%p link=%p Kindex=%p\n", GetTdb_No(), Mode, Txfp->CurBlk, Txfp->CurNum,
GetTdb_No(), Mode, Txfp->CurBlk, Txfp->CurNum, To_Key_Col, To_Link, To_Kindex);
To_Key_Col, To_Link, To_Kindex);
#endif
if (To_Kindex) { if (To_Kindex) {
/*******************************************************************/ /*******************************************************************/
...@@ -524,15 +523,13 @@ void VCTCOL::ReadColumn(PGLOBAL g) ...@@ -524,15 +523,13 @@ void VCTCOL::ReadColumn(PGLOBAL g)
{ {
PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp; PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp;
#if defined(_DEBUG) || defined(DEBTRACE) #if defined(_DEBUG)
assert (!To_Kcol); assert (!To_Kcol);
#endif #endif
#ifdef DEBTRACE if (trace > 1)
fprintf(debug, htrc("VCT ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
"VCT ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n", Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
#endif
if (ColBlk != txfp->CurBlk) if (ColBlk != txfp->CurBlk)
ReadBlock(g); ReadBlock(g);
...@@ -558,11 +555,9 @@ void VCTCOL::WriteColumn(PGLOBAL g) ...@@ -558,11 +555,9 @@ void VCTCOL::WriteColumn(PGLOBAL g)
{ {
PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp;; PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp;;
#ifdef DEBTRACE if (trace > 1)
fprintf(debug, htrc("VCT WriteColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
"VCT WriteColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n", Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
#endif
ColBlk = txfp->CurBlk; ColBlk = txfp->CurBlk;
ColPos = txfp->CurNum; ColPos = txfp->CurNum;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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