Commit 7733b247 authored by Olivier Bertrand's avatar Olivier Bertrand

Same changes than in version 10.0.17

parent 73d04275
...@@ -21,10 +21,10 @@ ha_connect.cc connect.cc user_connect.cc mycat.cc ...@@ -21,10 +21,10 @@ ha_connect.cc connect.cc user_connect.cc mycat.cc
fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h
array.cpp blkfil.cpp colblk.cpp csort.cpp array.cpp blkfil.cpp colblk.cpp csort.cpp
filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamvct.cpp filamzip.cpp filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamvct.cpp filamzip.cpp
filter.cpp json.cpp maputil.cpp myutil.cpp plgdbutl.cpp reldef.cpp tabcol.cpp filter.cpp json.cpp jsonudf.cpp maputil.cpp myutil.cpp plgdbutl.cpp reldef.cpp
tabdos.cpp tabfix.cpp tabfmt.cpp tabjson.cpp table.cpp tabmul.cpp taboccur.cpp tabcol.cpp tabdos.cpp tabfix.cpp tabfmt.cpp tabjson.cpp table.cpp tabmul.cpp
tabpivot.cpp tabsys.cpp tabtbl.cpp tabutil.cpp tabvct.cpp tabvir.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp tabutil.cpp tabvct.cpp
tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp
array.h blkfil.h block.h catalog.h checklvl.h colblk.h connect.h csort.h array.h blkfil.h block.h catalog.h checklvl.h colblk.h connect.h csort.h
engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamvct.h filamzip.h engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamvct.h filamzip.h
......
...@@ -50,6 +50,7 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock ...@@ -50,6 +50,7 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
// void SetCorrel(bool b) {Correlated = b;} // void SetCorrel(bool b) {Correlated = b;}
// Methods // Methods
using XOBJECT::GetIntValue;
virtual void Reset(void) {Bot = -1;} virtual void Reset(void) {Bot = -1;}
virtual int Qcompare(int *, int *); virtual int Qcompare(int *, int *);
virtual bool Compare(PXOB) {assert(FALSE); return FALSE;} virtual bool Compare(PXOB) {assert(FALSE); return FALSE;}
......
...@@ -40,4 +40,11 @@ enum USETEMP {TMP_NO = 0, /* Never */ ...@@ -40,4 +40,11 @@ enum USETEMP {TMP_NO = 0, /* Never */
TMP_FORCE = 3, /* Forced for MAP tables */ TMP_FORCE = 3, /* Forced for MAP tables */
TMP_TEST = 4}; /* Testing value */ TMP_TEST = 4}; /* Testing value */
/***********************************************************************/
/* Following definitions indicate conversion of TEXT columns. */
/***********************************************************************/
enum TYPCONV {TPC_NO = 0, /* Never */
TPC_YES = 1, /* Always */
TPC_SKIP = 2}; /* Skip TEXT columns */
#endif // _CHKLVL_DEFINED_ #endif // _CHKLVL_DEFINED_
...@@ -469,9 +469,12 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp) ...@@ -469,9 +469,12 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
} while (rc == RC_NF); } while (rc == RC_NF);
if (rc == RC_OK)
rc= EvalColumns(g, tdbp, false);
err: err:
g->jump_level--; g->jump_level--;
return (rc != RC_OK) ? rc : EvalColumns(g, tdbp, false); return rc;
} // end of CntReadNext } // end of CntReadNext
/***********************************************************************/ /***********************************************************************/
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -207,8 +207,7 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) ...@@ -207,8 +207,7 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK)); fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
fp->Type = TYPE_FB_MAP; fp->Type = TYPE_FB_MAP;
fp->Fname = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); fp->Fname = PlugDup(g, filename);
strcpy((char*)fp->Fname, filename);
fp->Next = dbuserp->Openlist; fp->Next = dbuserp->Openlist;
dbuserp->Openlist = fp; dbuserp->Openlist = fp;
fp->Count = 1; fp->Count = 1;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -289,8 +289,7 @@ bool TXTFAM::AddListValue(PGLOBAL g, int type, void *val, PPARM *top) ...@@ -289,8 +289,7 @@ bool TXTFAM::AddListValue(PGLOBAL g, int type, void *val, PPARM *top)
pp->Intval = *(int*)val; pp->Intval = *(int*)val;
break; break;
// case TYPE_STRING: // case TYPE_STRING:
// pp->Value = PlugSubAlloc(g, NULL, strlen((char*)val) + 1); // pp->Value = PlugDup(g, (char*)val);
// strcpy((char*)pp->Value, (char*)val);
// break; // break;
case TYPE_PCHAR: case TYPE_PCHAR:
pp->Value = val; pp->Value = val;
...@@ -325,8 +324,7 @@ int TXTFAM::StoreValues(PGLOBAL g, bool upd) ...@@ -325,8 +324,7 @@ int TXTFAM::StoreValues(PGLOBAL g, bool upd)
if (Tdbp->PrepareWriting(g)) if (Tdbp->PrepareWriting(g))
return RC_FX; return RC_FX;
buf = (char*)PlugSubAlloc(g, NULL, strlen(Tdbp->GetLine()) + 1); buf = PlugDup(g, Tdbp->GetLine());
strcpy(buf, Tdbp->GetLine());
rc = AddListValue(g, TYPE_PCHAR, buf, &To_Upd); rc = AddListValue(g, TYPE_PCHAR, buf, &To_Upd);
} // endif upd } // endif upd
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -1451,8 +1451,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g) ...@@ -1451,8 +1451,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK)); fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
fp->Type = TYPE_FB_MAP; fp->Type = TYPE_FB_MAP;
fp->Fname = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); fp->Fname = PlugDup(g, filename);
strcpy((char*)fp->Fname, filename);
fp->Next = dbuserp->Openlist; fp->Next = dbuserp->Openlist;
dbuserp->Openlist = fp; dbuserp->Openlist = fp;
fp->Count = 1; fp->Count = 1;
...@@ -2844,8 +2843,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i) ...@@ -2844,8 +2843,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i)
/*******************************************************************/ /*******************************************************************/
fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK)); fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK));
fp->Type = TYPE_FB_MAP; fp->Type = TYPE_FB_MAP;
fp->Fname = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); fp->Fname = PlugDup(g, filename);
strcpy((char*)fp->Fname, filename);
fp->Next = dup->Openlist; fp->Next = dup->Openlist;
dup->Openlist = fp; dup->Openlist = fp;
fp->Count = 1; fp->Count = 1;
......
...@@ -235,7 +235,7 @@ typedef struct _global { /* Global structure */ ...@@ -235,7 +235,7 @@ typedef struct _global { /* Global structure */
void *Xchk; /* indexes in create/alter */ void *Xchk; /* indexes in create/alter */
short Alchecked; /* Checked for ALTER */ short Alchecked; /* Checked for ALTER */
short Mrr; /* True when doing mrr */ short Mrr; /* True when doing mrr */
short Trace; int N; /* Utility */
int jump_level; int jump_level;
jmp_buf jumper[MAX_JUMP + 2]; jmp_buf jumper[MAX_JUMP + 2];
} GLOBAL; } GLOBAL;
......
This diff is collapsed.
/* Copyright (C) Olivier Bertrand 2004 - 2014 /* Copyright (C) Olivier Bertrand 2004 - 2015
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -56,11 +56,7 @@ class XCHK : public BLOCK { ...@@ -56,11 +56,7 @@ class XCHK : public BLOCK {
oldopn= newopn= NULL; oldopn= newopn= NULL;
oldpix= newpix= NULL;} oldpix= newpix= NULL;}
inline char *SetName(PGLOBAL g, char *name) { inline char *SetName(PGLOBAL g, char *name) {return PlugDup(g, name);}
char *nm= NULL;
if (name) {nm= (char*)PlugSubAlloc(g, NULL, strlen(name) + 1);
strcpy(nm, name);}
return nm;}
bool oldsep; // Sepindex before create/alter bool oldsep; // Sepindex before create/alter
bool newsep; // Sepindex after create/alter bool newsep; // Sepindex after create/alter
......
This diff is collapsed.
/**************** json H Declares Source Code File (.H) ****************/ /**************** json H Declares Source Code File (.H) ****************/
/* Name: json.h Version 1.0 */ /* Name: json.h Version 1.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */
/* */ /* */
...@@ -18,7 +18,8 @@ enum JTYP {TYPE_STRG = 1, ...@@ -18,7 +18,8 @@ enum JTYP {TYPE_STRG = 1,
TYPE_BOOL = 4, TYPE_BOOL = 4,
TYPE_INTG = 7, TYPE_INTG = 7,
TYPE_JSON = 12, TYPE_JSON = 12,
TYPE_JAR, TYPE_JOB, TYPE_JAR,
TYPE_JOB,
TYPE_JVAL}; TYPE_JVAL};
class JOUT; class JOUT;
...@@ -122,6 +123,10 @@ class JPAIR : public BLOCK { ...@@ -122,6 +123,10 @@ class JPAIR : public BLOCK {
public: public:
JPAIR(PSZ key) : BLOCK() {Key = key; Val = NULL; Next = NULL;} JPAIR(PSZ key) : BLOCK() {Key = key; Val = NULL; Next = NULL;}
inline PSZ GetKey(void) {return Key;}
inline PJVAL GetVal(void) {return Val;}
inline PJPR GetNext(void) {return Next;}
protected: protected:
PSZ Key; // This pair key name PSZ Key; // This pair key name
PJVAL Val; // To the value of the pair PJVAL Val; // To the value of the pair
...@@ -143,20 +148,25 @@ class JSON : public BLOCK { ...@@ -143,20 +148,25 @@ class JSON : public BLOCK {
virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL) {X return NULL;} virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL) {X return NULL;}
virtual PJPR AddPair(PGLOBAL g, PSZ key) {X return NULL;} virtual PJPR AddPair(PGLOBAL g, PSZ key) {X return NULL;}
virtual PJVAL GetValue(const char *key) {X return NULL;} virtual PJVAL GetValue(const char *key) {X return NULL;}
virtual PJOB GetObject(void) {X return NULL;} virtual PJOB GetObject(void) {return NULL;}
virtual PJAR GetArray(void) {X return NULL;} virtual PJAR GetArray(void) {return NULL;}
virtual PJVAL GetValue(int i) {X return NULL;} virtual PJVAL GetValue(int i) {X return NULL;}
virtual PVAL GetValue(void) {X return NULL;} virtual PVAL GetValue(void) {X return NULL;}
virtual PJSON GetJson(void) {X return NULL;} virtual PJSON GetJson(void) {X return NULL;}
virtual PJPR GetFirst(void) {X return NULL;}
virtual int GetInteger(void) {X return 0;} virtual int GetInteger(void) {X return 0;}
virtual double GetFloat() {X return 0.0;} virtual double GetFloat() {X return 0.0;}
virtual PSZ GetString() {X return NULL;} virtual PSZ GetString() {X return NULL;}
virtual PSZ GetText(PGLOBAL g) {X return NULL;} virtual PSZ GetText(PGLOBAL g, PSZ text) {X return NULL;}
virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) {X return true;} virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) {X return true;}
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key) {X} virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key) {X}
virtual void SetValue(PVAL valp) {X} virtual void SetValue(PVAL valp) {X}
virtual void SetValue(PJSON jsp) {X} virtual void SetValue(PJSON jsp) {X}
virtual void SetString(PGLOBAL g, PSZ s) {X}
virtual void SetInteger(PGLOBAL g, int n) {X}
virtual void SetFloat(PGLOBAL g, double f) {X}
virtual bool DeleteValue(int i) {X return true;} virtual bool DeleteValue(int i) {X return true;}
virtual bool IsNull(void) {X return true;}
protected: protected:
int Size; int Size;
...@@ -171,13 +181,17 @@ class JOBJECT : public JSON { ...@@ -171,13 +181,17 @@ class JOBJECT : public JSON {
public: public:
JOBJECT(void) : JSON() {First = Last = NULL;} JOBJECT(void) : JSON() {First = Last = NULL;}
using JSON::GetValue;
using JSON::SetValue;
virtual void Clear(void) {First = Last = NULL; Size = 0;} virtual void Clear(void) {First = Last = NULL; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JOB;} virtual JTYP GetType(void) {return TYPE_JOB;}
virtual PJPR GetFirst(void) {return First;}
virtual PJPR AddPair(PGLOBAL g, PSZ key); virtual PJPR AddPair(PGLOBAL g, PSZ key);
virtual PJOB GetObject(void) {return this;} virtual PJOB GetObject(void) {return this;}
virtual PJVAL GetValue(const char* key); virtual PJVAL GetValue(const char* key);
virtual PSZ GetText(PGLOBAL g); virtual PSZ GetText(PGLOBAL g, PSZ text);
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key); virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key);
virtual bool IsNull(void);
protected: protected:
PJPR First; PJPR First;
...@@ -192,6 +206,8 @@ class JARRAY : public JSON { ...@@ -192,6 +206,8 @@ class JARRAY : public JSON {
public: public:
JARRAY(void) : JSON() {Alloc = 0; First = Last = NULL; Mvals = NULL;} JARRAY(void) : JSON() {Alloc = 0; First = Last = NULL; Mvals = NULL;}
using JSON::GetValue;
using JSON::SetValue;
virtual void Clear(void) {First = Last = NULL; Size = 0;} virtual void Clear(void) {First = Last = NULL; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JAR;} virtual JTYP GetType(void) {return TYPE_JAR;}
virtual PJAR GetArray(void) {return this;} virtual PJAR GetArray(void) {return this;}
...@@ -200,6 +216,7 @@ class JARRAY : public JSON { ...@@ -200,6 +216,7 @@ class JARRAY : public JSON {
virtual PJVAL GetValue(int i); virtual PJVAL GetValue(int i);
virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i); virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i);
virtual bool DeleteValue(int n); virtual bool DeleteValue(int n);
virtual bool IsNull(void);
protected: protected:
// Members // Members
...@@ -223,6 +240,8 @@ class JVALUE : public JSON { ...@@ -223,6 +240,8 @@ class JVALUE : public JSON {
{Jsp = jsp; Value = NULL; Next = NULL; Del = false;} {Jsp = jsp; Value = NULL; Next = NULL; Del = false;}
JVALUE(PGLOBAL g, PVAL valp); JVALUE(PGLOBAL g, PVAL valp);
using JSON::GetValue;
using JSON::SetValue;
virtual void Clear(void) virtual void Clear(void)
{Jsp = NULL; Value = NULL; Next = NULL; Del = false; Size = 0;} {Jsp = NULL; Value = NULL; Next = NULL; Del = false; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JVAL;} virtual JTYP GetType(void) {return TYPE_JVAL;}
...@@ -234,8 +253,13 @@ class JVALUE : public JSON { ...@@ -234,8 +253,13 @@ class JVALUE : public JSON {
virtual int GetInteger(void); virtual int GetInteger(void);
virtual double GetFloat(void); virtual double GetFloat(void);
virtual PSZ GetString(void); virtual PSZ GetString(void);
virtual PSZ GetText(PGLOBAL g, PSZ text);
virtual void SetValue(PVAL valp) {Value = valp;} virtual void SetValue(PVAL valp) {Value = valp;}
virtual void SetValue(PJSON jsp) {Jsp = jsp;} virtual void SetValue(PJSON jsp) {Jsp = jsp;}
virtual void SetString(PGLOBAL g, PSZ s);
virtual void SetInteger(PGLOBAL g, int n);
virtual void SetFloat(PGLOBAL g, double f);
virtual bool IsNull(void);
protected: protected:
PJSON Jsp; // To the json value PJSON Jsp; // To the json value
......
This diff is collapsed.
/******************************************************************/ /******************************************************************/
/* Implementation of XML document processing using libxml2 */ /* Implementation of XML document processing using libxml2 */
/* Author: Olivier Bertrand 2007-2013 */ /* Author: Olivier Bertrand 2007-2015 */
/******************************************************************/ /******************************************************************/
#include "my_global.h" #include "my_global.h"
#include <string.h> #include <string.h>
...@@ -408,8 +408,7 @@ PFBLOCK LIBXMLDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn) ...@@ -408,8 +408,7 @@ PFBLOCK LIBXMLDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn)
xp->Next = (PX2BLOCK)dup->Openlist; xp->Next = (PX2BLOCK)dup->Openlist;
dup->Openlist = (PFBLOCK)xp; dup->Openlist = (PFBLOCK)xp;
xp->Type = TYPE_FB_XML2; xp->Type = TYPE_FB_XML2;
xp->Fname = (LPCSTR)PlugSubAlloc(g, NULL, strlen(fn) + 1); xp->Fname = (LPCSTR)PlugDup(g, fn);
strcpy((char*)xp->Fname, fn);
xp->Count = 1; xp->Count = 1;
xp->Length = (m == MODE_READ) ? 1 : 0; xp->Length = (m == MODE_READ) ? 1 : 0;
xp->Retcode = rc; xp->Retcode = rc;
......
...@@ -51,7 +51,8 @@ ...@@ -51,7 +51,8 @@
#define DLL_EXPORT // Items are exported from this DLL #define DLL_EXPORT // Items are exported from this DLL
#include "myconn.h" #include "myconn.h"
extern "C" int zconv; //extern "C" int zconv;
int GetConvSize(void);
extern MYSQL_PLUGIN_IMPORT uint mysqld_port; extern MYSQL_PLUGIN_IMPORT uint mysqld_port;
extern MYSQL_PLUGIN_IMPORT char *mysqld_unix_port; extern MYSQL_PLUGIN_IMPORT char *mysqld_unix_port;
...@@ -265,7 +266,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db, ...@@ -265,7 +266,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
return NULL; return NULL;
} else if (type == TYPE_STRING) { } else if (type == TYPE_STRING) {
if (v == 'X') { if (v == 'X') {
len = zconv; len = GetConvSize();
sprintf(g->Message, "Column %s converted to varchar(%d)", sprintf(g->Message, "Column %s converted to varchar(%d)",
colname, len); colname, len);
PushWarning(g, thd); PushWarning(g, thd);
......
...@@ -26,14 +26,16 @@ ...@@ -26,14 +26,16 @@
#include "myutil.h" #include "myutil.h"
#define DLL_EXPORT // Items are exported from this DLL #define DLL_EXPORT // Items are exported from this DLL
extern "C" int xconv; //extern "C" int xconv;
TYPCONV GetTypeConv(void);
/************************************************************************/ /************************************************************************/
/* Convert from MySQL type name to PlugDB type number */ /* Convert from MySQL type name to PlugDB type number */
/************************************************************************/ /************************************************************************/
int MYSQLtoPLG(char *typname, char *var) int MYSQLtoPLG(char *typname, char *var)
{ {
int type; int type;
TYPCONV xconv = GetTypeConv();
if (!stricmp(typname, "int") || !stricmp(typname, "mediumint") || if (!stricmp(typname, "int") || !stricmp(typname, "mediumint") ||
!stricmp(typname, "integer")) !stricmp(typname, "integer"))
...@@ -57,13 +59,13 @@ int MYSQLtoPLG(char *typname, char *var) ...@@ -57,13 +59,13 @@ int MYSQLtoPLG(char *typname, char *var)
type = TYPE_TINY; type = TYPE_TINY;
else if (!stricmp(typname, "text") && var) { else if (!stricmp(typname, "text") && var) {
switch (xconv) { switch (xconv) {
case 1: case TPC_YES:
type = TYPE_STRING; type = TYPE_STRING;
*var = 'X'; *var = 'X';
break; break;
case 2: case TPC_SKIP:
*var = 'K'; *var = 'K';
default: default: // TPC_NO
type = TYPE_ERROR; type = TYPE_ERROR;
} // endswitch xconv } // endswitch xconv
...@@ -88,7 +90,7 @@ int MYSQLtoPLG(char *typname, char *var) ...@@ -88,7 +90,7 @@ int MYSQLtoPLG(char *typname, char *var)
} else if (type == TYPE_STRING && !stricmp(typname, "varchar")) } else if (type == TYPE_STRING && !stricmp(typname, "varchar"))
// This is to make the difference between CHAR and VARCHAR // This is to make the difference between CHAR and VARCHAR
*var = 'V'; *var = 'V';
else if (type == TYPE_ERROR && xconv == 2) else if (type == TYPE_ERROR && xconv == TPC_SKIP)
*var = 'K'; *var = 'K';
else else
*var = 0; *var = 0;
...@@ -174,7 +176,7 @@ const char *PLGtoMYSQLtype(int type, bool dbf, char v) ...@@ -174,7 +176,7 @@ const char *PLGtoMYSQLtype(int type, bool dbf, char v)
/************************************************************************/ /************************************************************************/
int MYSQLtoPLG(int mytype, char *var) int MYSQLtoPLG(int mytype, char *var)
{ {
int type; int type, xconv = GetTypeConv();
switch (mytype) { switch (mytype) {
case MYSQL_TYPE_SHORT: case MYSQL_TYPE_SHORT:
...@@ -221,7 +223,7 @@ int MYSQLtoPLG(int mytype, char *var) ...@@ -221,7 +223,7 @@ int MYSQLtoPLG(int mytype, char *var)
case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
if (var) { if (var) {
switch (xconv) { switch (xconv) {
case 1: case TPC_YES:
if (*var != 'B') { if (*var != 'B') {
// This is a TEXT column // This is a TEXT column
type = TYPE_STRING; type = TYPE_STRING;
...@@ -230,9 +232,9 @@ int MYSQLtoPLG(int mytype, char *var) ...@@ -230,9 +232,9 @@ int MYSQLtoPLG(int mytype, char *var)
type = TYPE_ERROR; type = TYPE_ERROR;
break; break;
case 2: case TPC_SKIP:
*var = 'K'; // Skip *var = 'K'; // Skip
default: default: // TPC_NO
type = TYPE_ERROR; type = TYPE_ERROR;
} // endswitch xconv } // endswitch xconv
......
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
#define DEFAULT_LOGIN_TIMEOUT -1 // means do not set #define DEFAULT_LOGIN_TIMEOUT -1 // means do not set
#define DEFAULT_QUERY_TIMEOUT -1 // means do not set #define DEFAULT_QUERY_TIMEOUT -1 // means do not set
typedef struct odbc_parms {
char *User; // User connect info
char *Pwd; // Password connect info
int Cto; // Connect timeout
int Qto; // Query timeout
bool UseCnc; // Use SQLConnect (!SQLDriverConnect)
} ODBCPARM, *POPARM;
/***********************************************************************/ /***********************************************************************/
/* ODBC catalog function prototypes. */ /* ODBC catalog function prototypes. */
/***********************************************************************/ /***********************************************************************/
...@@ -10,8 +18,8 @@ char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop); ...@@ -10,8 +18,8 @@ char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop);
#endif // PROMPT_OK #endif // PROMPT_OK
PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info); PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info);
PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table, PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table,
char *colpat, int maxres, int cto, int qto, bool info); char *colpat, int maxres, bool info, POPARM sop);
PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, int cto, int qto); PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop);
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat, PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat,
int maxres, int cto, int qto, bool info); int maxres, bool info, POPARM sop);
PQRYRES ODBCDrivers(PGLOBAL g, int maxres, bool info); PQRYRES ODBCDrivers(PGLOBAL g, int maxres, bool info);
This diff is collapsed.
...@@ -119,7 +119,7 @@ class ODBConn : public BLOCK { ...@@ -119,7 +119,7 @@ class ODBConn : public BLOCK {
noOdbcDialog = 0x0008, // Don't display ODBC Connect dialog noOdbcDialog = 0x0008, // Don't display ODBC Connect dialog
forceOdbcDialog = 0x0010}; // Always display ODBC connect dialog forceOdbcDialog = 0x0010}; // Always display ODBC connect dialog
int Open(PSZ ConnectString, DWORD Options = 0); int Open(PSZ ConnectString, POPARM sop, DWORD Options = 0);
int Rewind(char *sql, ODBCCOL *tocols); int Rewind(char *sql, ODBCCOL *tocols);
void Close(void); void Close(void);
PQRYRES AllocateResult(PGLOBAL g); PQRYRES AllocateResult(PGLOBAL g);
...@@ -135,11 +135,13 @@ class ODBConn : public BLOCK { ...@@ -135,11 +135,13 @@ class ODBConn : public BLOCK {
public: public:
// Operations // Operations
void SetLoginTimeout(DWORD sec) {m_LoginTimeout = sec;} //void SetLoginTimeout(DWORD sec) {m_LoginTimeout = sec;}
void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;} //void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;}
//void SetUserName(PSZ user) {m_User = user;}
//void SetUserPwd(PSZ pwd) {m_Pwd = pwd;}
int GetResultSize(char *sql, ODBCCOL *colp); int GetResultSize(char *sql, ODBCCOL *colp);
int ExecDirectSQL(char *sql, ODBCCOL *tocols); int ExecDirectSQL(char *sql, ODBCCOL *tocols);
int Fetch(void); int Fetch(int pos = 0);
int PrepareSQL(char *sql); int PrepareSQL(char *sql);
int ExecuteSQL(void); int ExecuteSQL(void);
bool BindParam(ODBCCOL *colp); bool BindParam(ODBCCOL *colp);
...@@ -155,7 +157,7 @@ class ODBConn : public BLOCK { ...@@ -155,7 +157,7 @@ class ODBConn : public BLOCK {
// Implementation // Implementation
public: public:
// virtual ~ODBConn(); //virtual ~ODBConn();
// ODBC operations // ODBC operations
protected: protected:
...@@ -163,7 +165,8 @@ class ODBConn : public BLOCK { ...@@ -163,7 +165,8 @@ class ODBConn : public BLOCK {
void ThrowDBX(RETCODE rc, PSZ msg, HSTMT hstmt = SQL_NULL_HSTMT); void ThrowDBX(RETCODE rc, PSZ msg, HSTMT hstmt = SQL_NULL_HSTMT);
void ThrowDBX(PSZ msg); void ThrowDBX(PSZ msg);
void AllocConnect(DWORD dwOptions); void AllocConnect(DWORD dwOptions);
bool Connect(DWORD Options); void Connect(void);
bool DriverConnect(DWORD Options);
void VerifyConnect(void); void VerifyConnect(void);
void GetConnectInfo(void); void GetConnectInfo(void);
void Free(void); void Free(void);
...@@ -185,11 +188,14 @@ class ODBConn : public BLOCK { ...@@ -185,11 +188,14 @@ class ODBConn : public BLOCK {
DWORD m_RowsetSize; DWORD m_RowsetSize;
char m_IDQuoteChar[2]; char m_IDQuoteChar[2];
PSZ m_Connect; PSZ m_Connect;
PSZ m_User;
PSZ m_Pwd;
int m_Catver; int m_Catver;
int m_Rows; int m_Rows;
int m_Fetch;
bool m_Updatable; bool m_Updatable;
bool m_Transact; bool m_Transact;
bool m_Scrollable; bool m_Scrollable;
bool m_First; bool m_UseCnc;
bool m_Full; bool m_Full;
}; // end of ODBConn class definition }; // end of ODBConn class definition
/************** PlgDBSem H Declares Source Code File (.H) **************/ /************** PlgDBSem H Declares Source Code File (.H) **************/
/* Name: PLGDBSEM.H Version 3.6 */ /* Name: PLGDBSEM.H Version 3.6 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
/* */ /* */
/* This file contains the PlugDB++ application type definitions. */ /* This file contains the PlugDB++ application type definitions. */
/***********************************************************************/ /***********************************************************************/
...@@ -504,9 +504,10 @@ enum XFLD {FLD_NO = 0, /* Not a field definition item */ ...@@ -504,9 +504,10 @@ enum XFLD {FLD_NO = 0, /* Not a field definition item */
FLD_EXTRA = 13, /* Field extra info */ FLD_EXTRA = 13, /* Field extra info */
FLD_PRIV = 14, /* Field priviledges */ FLD_PRIV = 14, /* Field priviledges */
FLD_DATEFMT = 15, /* Field date format */ FLD_DATEFMT = 15, /* Field date format */
FLD_CAT = 16, /* Table catalog */ FLD_FORMAT = 16, /* Field format */
FLD_SCHEM = 17, /* Table schema */ FLD_CAT = 17, /* Table catalog */
FLD_TABNAME = 18}; /* Column Table name */ FLD_SCHEM = 18, /* Table schema */
FLD_TABNAME = 19}; /* Column Table name */
/***********************************************************************/ /***********************************************************************/
/* Result of last SQL noconv query. */ /* Result of last SQL noconv query. */
...@@ -584,6 +585,7 @@ DllExport PCATLG PlgGetCatalog(PGLOBAL g, bool jump = true); ...@@ -584,6 +585,7 @@ DllExport PCATLG PlgGetCatalog(PGLOBAL g, bool jump = true);
DllExport bool PlgSetXdbPath(PGLOBAL g, PSZ, PSZ, char *, int, char *, int); DllExport bool PlgSetXdbPath(PGLOBAL g, PSZ, PSZ, char *, int, char *, int);
DllExport void PlgDBfree(MBLOCK&); DllExport void PlgDBfree(MBLOCK&);
DllExport void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size); DllExport void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size);
DllExport char *PlgDBDup(PGLOBAL g, const char *str);
DllExport void *PlgDBalloc(PGLOBAL, void *, MBLOCK&); DllExport void *PlgDBalloc(PGLOBAL, void *, MBLOCK&);
DllExport void *PlgDBrealloc(PGLOBAL, void *, MBLOCK&, size_t); DllExport void *PlgDBrealloc(PGLOBAL, void *, MBLOCK&, size_t);
DllExport void NewPointer(PTABS, void *, void *); DllExport void NewPointer(PTABS, void *, void *);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -294,8 +294,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, ...@@ -294,8 +294,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
#else // !XMSG #else // !XMSG
GetRcString(ids + crp->Ncol, cname, sizeof(cname)); GetRcString(ids + crp->Ncol, cname, sizeof(cname));
#endif // !XMSG #endif // !XMSG
crp->Name = (PSZ)PlugSubAlloc(g, NULL, strlen(cname) + 1); crp->Name = (PSZ)PlugDup(g, cname);
strcpy(crp->Name, cname);
} else } else
crp->Name = NULL; // Will be set by caller crp->Name = NULL; // Will be set by caller
...@@ -311,7 +310,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, ...@@ -311,7 +310,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
else else
crp->Kdata = NULL; crp->Kdata = NULL;
if (g->Trace) if (trace)
htrc("Column(%d) %s type=%d len=%d value=%p\n", htrc("Column(%d) %s type=%d len=%d value=%p\n",
crp->Ncol, crp->Name, crp->Type, crp->Length, crp->Kdata); crp->Ncol, crp->Name, crp->Type, crp->Length, crp->Kdata);
...@@ -853,8 +852,7 @@ FILE *PlugOpenFile(PGLOBAL g, LPCSTR fname, LPCSTR ftype) ...@@ -853,8 +852,7 @@ FILE *PlugOpenFile(PGLOBAL g, LPCSTR fname, LPCSTR ftype)
htrc(" fp=%p\n", fp); htrc(" fp=%p\n", fp);
// fname may be in volatile memory such as stack // fname may be in volatile memory such as stack
fp->Fname = (char*)PlugSubAlloc(g, NULL, strlen(fname) + 1); fp->Fname = PlugDup(g, fname);
strcpy((char*)fp->Fname, fname);
fp->Count = 1; fp->Count = 1;
fp->Type = TYPE_FB_FILE; fp->Type = TYPE_FB_FILE;
fp->File = fop; fp->File = fop;
...@@ -1400,6 +1398,23 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size) ...@@ -1400,6 +1398,23 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
return (memp); return (memp);
} // end of PlgDBSubAlloc } // end of PlgDBSubAlloc
/***********************************************************************/
/* Program for sub-allocating and copying a string in a storage area. */
/***********************************************************************/
char *PlgDBDup(PGLOBAL g, const char *str)
{
if (str) {
char *sm = (char*)PlgDBSubAlloc(g, NULL, strlen(str) + 1);
if (sm)
strcpy(sm, str);
return sm;
} else
return NULL;
} // end of PlgDBDup
/***********************************************************************/ /***********************************************************************/
/* PUTOUT: Plug DB object typing routine. */ /* PUTOUT: Plug DB object typing routine. */
/***********************************************************************/ /***********************************************************************/
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1993-2014 */ /* (C) Copyright to the author Olivier BERTRAND 1993-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -144,12 +144,12 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize) ...@@ -144,12 +144,12 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
return NULL; return NULL;
} else { } else {
g->Sarea_Size = worksize; g->Sarea_Size = worksize;
g->Trace = 0;
g->Createas = 0; g->Createas = 0;
g->Alchecked = 0; g->Alchecked = 0;
g->Mrr = 0; g->Mrr = 0;
g->Activityp = g->ActivityStart = NULL; g->Activityp = g->ActivityStart = NULL;
g->Xchk = NULL; g->Xchk = NULL;
g->N = 0;
strcpy(g->Message, ""); strcpy(g->Message, "");
/*******************************************************************/ /*******************************************************************/
...@@ -228,7 +228,6 @@ BOOL PlugIsAbsolutePath(LPCSTR path) ...@@ -228,7 +228,6 @@ BOOL PlugIsAbsolutePath(LPCSTR path)
#endif #endif
} }
/***********************************************************************/ /***********************************************************************/
/* Set the full path of a file relatively to a given path. */ /* Set the full path of a file relatively to a given path. */
/* Note: this routine is not really implemented for Unix. */ /* Note: this routine is not really implemented for Unix. */
...@@ -385,8 +384,7 @@ char *PlugReadMessage(PGLOBAL g, int mid, char *m) ...@@ -385,8 +384,7 @@ char *PlugReadMessage(PGLOBAL g, int mid, char *m)
err: err:
if (g) { if (g) {
// Called by STEP // Called by STEP
msg = (char *)PlugSubAlloc(g, NULL, strlen(stmsg) + 1); msg = PlugDup(g, stmsg);
strcpy(msg, stmsg);
} else // Called by MSG or PlgGetErrorMsg } else // Called by MSG or PlgGetErrorMsg
msg = stmsg; msg = stmsg;
...@@ -421,8 +419,7 @@ char *PlugGetMessage(PGLOBAL g, int mid) ...@@ -421,8 +419,7 @@ char *PlugGetMessage(PGLOBAL g, int mid)
if (g) { if (g) {
// Called by STEP // Called by STEP
msg = (char *)PlugSubAlloc(g, NULL, strlen(stmsg) + 1); msg = PlugDup(g, stmsg);
strcpy(msg, stmsg);
} else // Called by MSG or PlgGetErrorMsg } else // Called by MSG or PlgGetErrorMsg
msg = stmsg; msg = stmsg;
...@@ -536,6 +533,22 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) ...@@ -536,6 +533,22 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
return (memp); return (memp);
} /* end of PlugSubAlloc */ } /* end of PlugSubAlloc */
/***********************************************************************/
/* Program for sub-allocating and copying a string in a storage area. */
/***********************************************************************/
char *PlugDup(PGLOBAL g, const char *str)
{
if (str) {
char *sm = (char*)PlugSubAlloc(g, NULL, strlen(str) + 1);
strcpy(sm, str);
return sm;
} else
return NULL;
} // end of PlugDup
#if 0
/***********************************************************************/ /***********************************************************************/
/* This routine suballocate a copy of the passed string. */ /* This routine suballocate a copy of the passed string. */
/***********************************************************************/ /***********************************************************************/
...@@ -552,6 +565,7 @@ char *PlugDup(PGLOBAL g, const char *str) ...@@ -552,6 +565,7 @@ char *PlugDup(PGLOBAL g, const char *str)
return(buf); return(buf);
} /* end of PlugDup */ } /* end of PlugDup */
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* This routine makes a pointer from an offset to a memory pointer. */ /* This routine makes a pointer from an offset to a memory pointer. */
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -153,10 +153,9 @@ char *RELDEF::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) ...@@ -153,10 +153,9 @@ char *RELDEF::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
if (s) { if (s) {
if (!Hc->IsPartitioned() || if (!Hc->IsPartitioned() ||
(stricmp(what, "filename") && stricmp(what, "tabname") (stricmp(what, "filename") && stricmp(what, "tabname")
&& stricmp(what, "connect"))) { && stricmp(what, "connect")))
sval= (char*)PlugSubAlloc(g, NULL, strlen(s) + 1); sval= PlugDup(g, s);
strcpy(sval, s); else
} else
sval= s; sval= s;
} else if (!stricmp(what, "filename")) { } else if (!stricmp(what, "filename")) {
...@@ -213,8 +212,7 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) ...@@ -213,8 +212,7 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
{ {
int poff = 0; int poff = 0;
Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1); Name = (PSZ)PlugDup(g, name);
strcpy(Name, name);
Cat = cat; Cat = cat;
Hc = ((MYCAT*)cat)->GetHandler(); Hc = ((MYCAT*)cat)->GetHandler();
Catfunc = GetFuncID(GetStringCatInfo(g, "Catfunc", NULL)); Catfunc = GetFuncID(GetStringCatInfo(g, "Catfunc", NULL));
...@@ -712,8 +710,7 @@ COLDEF::COLDEF(void) : COLCRT() ...@@ -712,8 +710,7 @@ COLDEF::COLDEF(void) : COLCRT()
/***********************************************************************/ /***********************************************************************/
int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
{ {
Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1); Name = (PSZ)PlugDup(g, cfp->Name);
strcpy(Name, cfp->Name);
if (!(cfp->Flags & U_SPECIAL)) { if (!(cfp->Flags & U_SPECIAL)) {
Poff = poff; Poff = poff;
...@@ -735,22 +732,16 @@ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) ...@@ -735,22 +732,16 @@ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
Key = cfp->Key; Key = cfp->Key;
Freq = cfp->Freq; Freq = cfp->Freq;
if (cfp->Remark && *cfp->Remark) { if (cfp->Remark && *cfp->Remark)
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1); Desc = (PSZ)PlugDup(g, cfp->Remark);
strcpy(Desc, cfp->Remark);
} // endif Remark
if (cfp->Datefmt) { if (cfp->Datefmt)
Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1); Decode = (PSZ)PlugDup(g, cfp->Datefmt);
strcpy(Decode, cfp->Datefmt);
} // endif Datefmt
} // endif special } // endif special
if (cfp->Fieldfmt) { if (cfp->Fieldfmt)
Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1); Fmt = (PSZ)PlugDup(g, cfp->Fieldfmt);
strcpy(Fmt, cfp->Fieldfmt);
} // endif Fieldfmt
Flags = cfp->Flags; Flags = cfp->Flags;
return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long; return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long;
......
...@@ -222,6 +222,7 @@ class DllExport DOSCOL : public COLBLK { ...@@ -222,6 +222,7 @@ class DllExport DOSCOL : public COLBLK {
virtual PVBLK GetDval(void) {return Dval;} virtual PVBLK GetDval(void) {return Dval;}
// Methods // Methods
using COLBLK::Print;
virtual bool VarSize(void); virtual bool VarSize(void);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
......
This diff is collapsed.
/*************** tabjson H Declares Source Code File (.H) **************/ /*************** tabjson H Declares Source Code File (.H) **************/
/* Name: tabjson.h Version 1.0 */ /* Name: tabjson.h Version 1.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */
/* */ /* */
...@@ -16,8 +16,6 @@ typedef class JSONDEF *PJDEF; ...@@ -16,8 +16,6 @@ typedef class JSONDEF *PJDEF;
typedef class TDBJSON *PJTDB; typedef class TDBJSON *PJTDB;
typedef class JSONCOL *PJCOL; typedef class JSONCOL *PJCOL;
class TDBJSN;
/***********************************************************************/ /***********************************************************************/
/* The JSON tree node. Can be an Object or an Array. */ /* The JSON tree node. Can be an Object or an Array. */
/***********************************************************************/ /***********************************************************************/
...@@ -25,7 +23,9 @@ typedef struct _jnode { ...@@ -25,7 +23,9 @@ typedef struct _jnode {
PSZ Key; // The key used for object PSZ Key; // The key used for object
OPVAL Op; // Operator used for this node OPVAL Op; // Operator used for this node
PVAL CncVal; // To cont value used for OP_CNC PVAL CncVal; // To cont value used for OP_CNC
PVAL Valp; // The internal array VALUE
int Rank; // The rank in array int Rank; // The rank in array
int Nx; // Same row number
} JNODE, *PJNODE; } JNODE, *PJNODE;
/***********************************************************************/ /***********************************************************************/
...@@ -34,6 +34,7 @@ typedef struct _jnode { ...@@ -34,6 +34,7 @@ typedef struct _jnode {
class JSONDEF : public DOSDEF { /* Table description */ class JSONDEF : public DOSDEF { /* Table description */
friend class TDBJSON; friend class TDBJSON;
friend class TDBJSN; friend class TDBJSN;
friend class TDBJCL;
public: public:
// Constructor // Constructor
JSONDEF(void); JSONDEF(void);
...@@ -52,6 +53,7 @@ class JSONDEF : public DOSDEF { /* Table description */ ...@@ -52,6 +53,7 @@ class JSONDEF : public DOSDEF { /* Table description */
char *Xcol; /* Name of expandable column */ char *Xcol; /* Name of expandable column */
int Limit; /* Limit of multiple values */ int Limit; /* Limit of multiple values */
int Pretty; /* Depends on file structure */ int Pretty; /* Depends on file structure */
int Level; /* Used for catalog table */
bool Strict; /* Strict syntax checking */ bool Strict; /* Strict syntax checking */
}; // end of JSONDEF }; // end of JSONDEF
...@@ -77,7 +79,7 @@ class TDBJSN : public TDBDOS { ...@@ -77,7 +79,7 @@ class TDBJSN : public TDBDOS {
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp);
virtual int RowNumber(PGLOBAL g, BOOL b = FALSE) virtual int RowNumber(PGLOBAL g, bool b = FALSE)
{return (b) ? N : Fpos + 1;} {return (b) ? N : Fpos + 1;}
// Database routines // Database routines
...@@ -94,15 +96,15 @@ class TDBJSN : public TDBDOS { ...@@ -94,15 +96,15 @@ class TDBJSN : public TDBDOS {
JMODE Jmode; // MODE_OBJECT by default JMODE Jmode; // MODE_OBJECT by default
char *Xcol; // Name of expandable column char *Xcol; // Name of expandable column
int Fpos; // The current row index int Fpos; // The current row index
int Spos; // DELETE start index //int Spos; // DELETE start index
int N; // The current Rownum int N; // The current Rownum
int Limit; // Limit of multiple values int Limit; // Limit of multiple values
int Pretty; // Depends on file structure int Pretty; // Depends on file structure
bool Strict; // Strict syntax checking int NextSame; // Same next row
bool NextSame; // Same next row
bool Comma; // Row has final comma
int SameRow; // Same row nb int SameRow; // Same row nb
int Xval; // Index of expandable array int Xval; // Index of expandable array
bool Strict; // Strict syntax checking
bool Comma; // Row has final comma
}; // end of class TDBJSN }; // end of class TDBJSN
/* -------------------------- JSONCOL class -------------------------- */ /* -------------------------- JSONCOL class -------------------------- */
...@@ -130,8 +132,12 @@ class JSONCOL : public DOSCOL { ...@@ -130,8 +132,12 @@ class JSONCOL : public DOSCOL {
protected: protected:
bool CheckExpand(PGLOBAL g, int i, PSZ nm, bool b); bool CheckExpand(PGLOBAL g, int i, PSZ nm, bool b);
bool SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm); bool SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm);
PJSON GetRow(PGLOBAL g, int mode); PVAL GetColumnValue(PGLOBAL g, PJSON row, int i);
PVAL ExpandArray(PGLOBAL g, PJAR arp, int n);
PVAL CalculateArray(PGLOBAL g, PJAR arp, int n);
PVAL MakeJson(PGLOBAL g, PJSON jsp);
void SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n); void SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n);
PJSON GetRow(PGLOBAL g);
// Default constructor not to be used // Default constructor not to be used
JSONCOL(void) {} JSONCOL(void) {}
...@@ -139,12 +145,10 @@ class JSONCOL : public DOSCOL { ...@@ -139,12 +145,10 @@ class JSONCOL : public DOSCOL {
// Members // Members
TDBJSN *Tjp; // To the JSN table block TDBJSN *Tjp; // To the JSN table block
PVAL MulVal; // To value used by multiple column PVAL MulVal; // To value used by multiple column
PJAR Arp; // The intermediate array
char *Jpath; // The json path char *Jpath; // The json path
JNODE *Nodes ; // The intermediate objects JNODE *Nodes; // The intermediate objects
int Nod; // The number of intermediate objects int Nod; // The number of intermediate objects
int Ival; // Index of multiple values int Xnod; // Index of multiple values
int Nx; // The last read sub-row
bool Xpd; // True for expandable column bool Xpd; // True for expandable column
bool Parsed; // True when parsed bool Parsed; // True when parsed
}; // end of class JSONCOL }; // end of class JSONCOL
...@@ -172,7 +176,9 @@ class TDBJSON : public TDBJSN { ...@@ -172,7 +176,9 @@ class TDBJSON : public TDBJSN {
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual void ResetSize(void); virtual void ResetSize(void);
virtual int GetRecpos(void) {return Fpos;} virtual int GetProgCur(void) {return N;}
virtual int GetRecpos(void);
virtual bool SetRecpos(PGLOBAL g, int recpos);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual bool PrepareWriting(PGLOBAL g) {return false;} virtual bool PrepareWriting(PGLOBAL g) {return false;}
...@@ -195,3 +201,25 @@ class TDBJSON : public TDBJSN { ...@@ -195,3 +201,25 @@ class TDBJSON : public TDBJSN {
bool Done; // True when document parsing is done bool Done; // True when document parsing is done
bool Changed; // After Update, Insert or Delete bool Changed; // After Update, Insert or Delete
}; // end of class TDBJSON }; // end of class TDBJSON
/***********************************************************************/
/* This is the class declaration for the JSON catalog table. */
/***********************************************************************/
class TDBJCL : public TDBCAT {
public:
// Constructor
TDBJCL(PJDEF tdp);
protected:
// Specific routines
virtual PQRYRES GetResult(PGLOBAL g);
// Members
//char *Dp;
const char *Fn;
char *Objn;
int Pretty;
int Lrecl;
int lvl;
}; // end of class TDBJCL
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to PlugDB Software Development 2003 - 2012 */ /* (C) Copyright to PlugDB Software Development 2003 - 2015 */
/* Author: Olivier BERTRAND */ /* Author: Olivier BERTRAND */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
...@@ -172,8 +172,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) ...@@ -172,8 +172,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
while (n < PFNZ) { while (n < PFNZ) {
strcat(strcat(strcpy(filename, drive), direc), FileData.cFileName); strcat(strcat(strcpy(filename, drive), direc), FileData.cFileName);
pfn[n] = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); pfn[n++] = PlugDup(g, filename);
strcpy(pfn[n++], filename);
if (!FindNextFile(hSearch, &FileData)) { if (!FindNextFile(hSearch, &FileData)) {
rc = GetLastError(); rc = GetLastError();
...@@ -239,8 +238,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) ...@@ -239,8 +238,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
continue; // Not a match continue; // Not a match
strcat(strcpy(filename, direc), entry->d_name); strcat(strcpy(filename, direc), entry->d_name);
pfn[n] = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); pfn[n] = PlugDup(g, filename);
strcpy(pfn[n++], filename);
if (trace) if (trace)
htrc("Adding pfn[%d] %s\n", n, filename); htrc("Adding pfn[%d] %s\n", n, filename);
...@@ -292,8 +290,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) ...@@ -292,8 +290,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
*(++p) = '\0'; *(++p) = '\0';
// Suballocate the file name // Suballocate the file name
pfn[n] = (char*)PlugSubAlloc(g, NULL, strlen(filename) + 1); pfn[n++] = PlugDup(g, filename);
strcpy(pfn[n++], filename);
} // endfor n } // endfor n
} // endif Mul } // endif Mul
......
...@@ -1141,19 +1141,16 @@ int TDBMYSQL::WriteDB(PGLOBAL g) ...@@ -1141,19 +1141,16 @@ int TDBMYSQL::WriteDB(PGLOBAL g)
int rc; int rc;
uint len = Query->GetLength(); uint len = Query->GetLength();
char buf[64]; char buf[64];
bool b, oom = false; bool oom = false;
// Make the Insert command value list // Make the Insert command value list
for (PCOL colp = Columns; colp; colp = colp->GetNext()) { for (PCOL colp = Columns; colp; colp = colp->GetNext()) {
if (!colp->GetValue()->IsNull()) { if (!colp->GetValue()->IsNull()) {
if ((b = colp->GetResultType() == TYPE_STRING || if (colp->GetResultType() == TYPE_STRING ||
colp->GetResultType() == TYPE_DATE)) colp->GetResultType() == TYPE_DATE)
oom |= Query->Append('\''); oom |= Query->Append_quoted(colp->GetValue()->GetCharString(buf));
else
oom |= Query->Append(colp->GetValue()->GetCharString(buf)); oom |= Query->Append(colp->GetValue()->GetCharString(buf));
if (b)
oom |= Query->Append('\'');
} else } else
oom |= Query->Append("NULL"); oom |= Query->Append("NULL");
......
/************ TabOccur CPP Declares Source Code File (.CPP) ************/ /************ TabOccur CPP Declares Source Code File (.CPP) ************/
/* Name: TABOCCUR.CPP Version 1.1 */ /* Name: TABOCCUR.CPP Version 1.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2013 */ /* (C) Copyright to the author Olivier BERTRAND 2013 - 2015 */
/* */ /* */
/* OCCUR: Table that provides a view of a source table where the */ /* OCCUR: Table that provides a view of a source table where the */
/* contain of several columns of the source table is placed in only */ /* contain of several columns of the source table is placed in only */
...@@ -93,8 +93,7 @@ bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col, ...@@ -93,8 +93,7 @@ bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col,
} // endif col } // endif col
// Prepare the column list // Prepare the column list
colist = (char*)PlugSubAlloc(g, NULL, strlen(col) + 1); colist = PlugDup(g, col);
strcpy(colist, col);
m = PrepareColist(colist); m = PrepareColist(colist);
if ((rk = (rank && *rank))) { if ((rk = (rank && *rank))) {
...@@ -191,8 +190,7 @@ bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col, ...@@ -191,8 +190,7 @@ bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col,
} // endif col } // endif col
// Prepare the column list // Prepare the column list
colist = (char*)PlugSubAlloc(g, NULL, strlen(col) + 1); colist = PlugDup(g, col);
strcpy(colist, col);
m = PrepareColist(colist); m = PrepareColist(colist);
if ((rk = (rank && *rank))) if ((rk = (rank && *rank)))
...@@ -355,7 +353,7 @@ bool TDBOCCUR::MakeColumnList(PGLOBAL g) ...@@ -355,7 +353,7 @@ bool TDBOCCUR::MakeColumnList(PGLOBAL g)
for (colp = Columns; colp; colp = colp->GetNext()) for (colp = Columns; colp; colp = colp->GetNext())
if (colp->GetAmType() == TYPE_AM_PRX) if (colp->GetAmType() == TYPE_AM_PRX)
if (((PPRXCOL)colp)->Init(g)) if (((PPRXCOL)colp)->Init(g, NULL))
return true; return true;
Col = (PCOL*)PlugSubAlloc(g, NULL, Mult * sizeof(PCOL)); Col = (PCOL*)PlugSubAlloc(g, NULL, Mult * sizeof(PCOL));
......
This diff is collapsed.
...@@ -50,6 +50,8 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */ ...@@ -50,6 +50,8 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */
PSZ Connect; /* ODBC connection string */ PSZ Connect; /* ODBC connection string */
PSZ Tabname; /* External table name */ PSZ Tabname; /* External table name */
PSZ Tabschema; /* External table schema */ PSZ Tabschema; /* External table schema */
PSZ Username; /* User connect name */
PSZ Password; /* Password connect info */
PSZ Tabcat; /* External table catalog */ PSZ Tabcat; /* External table catalog */
PSZ Srcdef; /* The source table SQL definition */ PSZ Srcdef; /* The source table SQL definition */
PSZ Qchar; /* Identifier quoting character */ PSZ Qchar; /* Identifier quoting character */
...@@ -62,9 +64,10 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */ ...@@ -62,9 +64,10 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */
int Quoted; /* Identifier quoting level */ int Quoted; /* Identifier quoting level */
int Maxerr; /* Maxerr for an Exec table */ int Maxerr; /* Maxerr for an Exec table */
int Maxres; /* Maxres for a catalog table */ int Maxres; /* Maxres for a catalog table */
int Memory; /* Put result set in memory */
bool Scrollable; /* Use scrollable cursor */ bool Scrollable; /* Use scrollable cursor */
bool Memory; /* Put result set in memory */
bool Xsrc; /* Execution type */ bool Xsrc; /* Execution type */
bool UseCnc; /* Use SQLConnect (!SQLDriverConnect) */
}; // end of ODBCDEF }; // end of ODBCDEF
#if !defined(NODBC) #if !defined(NODBC)
...@@ -90,6 +93,7 @@ class TDBODBC : public TDBASE { ...@@ -90,6 +93,7 @@ class TDBODBC : public TDBASE {
// Methods // Methods
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
virtual int GetRecpos(void); virtual int GetRecpos(void);
virtual bool SetRecpos(PGLOBAL g, int recpos);
virtual PSZ GetFile(PGLOBAL g); virtual PSZ GetFile(PGLOBAL g);
virtual void SetFile(PGLOBAL g, PSZ fn); virtual void SetFile(PGLOBAL g, PSZ fn);
virtual void ResetSize(void); virtual void ResetSize(void);
...@@ -124,9 +128,12 @@ class TDBODBC : public TDBASE { ...@@ -124,9 +128,12 @@ class TDBODBC : public TDBASE {
// Members // Members
ODBConn *Ocp; // Points to an ODBC connection class ODBConn *Ocp; // Points to an ODBC connection class
ODBCCOL *Cnp; // Points to count(*) column ODBCCOL *Cnp; // Points to count(*) column
ODBCPARM Ops; // Additional parameters
char *Connect; // Points to connection string char *Connect; // Points to connection string
char *TableName; // Points to ODBC table name char *TableName; // Points to ODBC table name
char *Schema; // Points to ODBC table Schema char *Schema; // Points to ODBC table Schema
char *User; // User connect info
char *Pwd; // Password connect info
char *Catalog; // Points to ODBC table Catalog char *Catalog; // Points to ODBC table Catalog
char *Srcdef; // The source table SQL definition char *Srcdef; // The source table SQL definition
char *Query; // Points to SQL statement char *Query; // Points to SQL statement
...@@ -142,6 +149,7 @@ class TDBODBC : public TDBASE { ...@@ -142,6 +149,7 @@ class TDBODBC : public TDBASE {
int Qto; // Query timeout int Qto; // Query timeout
int Quoted; // The identifier quoting level int Quoted; // The identifier quoting level
int Fpos; // Position of last read record int Fpos; // Position of last read record
int Curpos; // Cursor position of last fetch
int AftRows; // The number of affected rows int AftRows; // The number of affected rows
int Rows; // Rowset size int Rows; // Rowset size
int Catver; // Catalog ODBC version int Catver; // Catalog ODBC version
...@@ -151,6 +159,8 @@ class TDBODBC : public TDBASE { ...@@ -151,6 +159,8 @@ class TDBODBC : public TDBASE {
int Nparm; // The number of statement parameters int Nparm; // The number of statement parameters
int Memory; // 0: No 1: Alloc 2: Put 3: Get int Memory; // 0: No 1: Alloc 2: Put 3: Get
bool Scrollable; // Use scrollable cursor bool Scrollable; // Use scrollable cursor
bool Placed; // True for position reading
bool UseCnc; // Use SQLConnect (!SQLDriverConnect)
PQRYRES Qrp; // Points to storage result PQRYRES Qrp; // Points to storage result
}; // end of class TDBODBC }; // end of class TDBODBC
...@@ -316,8 +326,7 @@ class TDBOTB : public TDBDRV { ...@@ -316,8 +326,7 @@ class TDBOTB : public TDBDRV {
char *Dsn; // Points to connection string char *Dsn; // Points to connection string
char *Schema; // Points to schema name or NULL char *Schema; // Points to schema name or NULL
char *Tab; // Points to ODBC table name or pattern char *Tab; // Points to ODBC table name or pattern
int Cto; // Connect timeout ODBCPARM Ops; // Additional parameters
int Qto; // Query timeout
}; // end of class TDBOTB }; // end of class TDBOTB
/***********************************************************************/ /***********************************************************************/
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -150,11 +150,18 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) ...@@ -150,11 +150,18 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
query = Tabsrc; query = Tabsrc;
// Open a MySQL connection for this table // Open a MySQL connection for this table
if (Myc.Open(g, Host, Database, User, Pwd, Port)) if (!Myc.Open(g, Host, Database, User, Pwd, Port)) {
return NULL;
else
b = true; b = true;
// Returned values must be in their original character set
if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX)
goto err;
else
Myc.FreeResult();
} else
return NULL;
// Send the source command to MySQL // Send the source command to MySQL
if (Myc.ExecSQL(g, query, &w) == RC_FX) if (Myc.ExecSQL(g, query, &w) == RC_FX)
goto err; goto err;
...@@ -241,6 +248,10 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) ...@@ -241,6 +248,10 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} else { } else {
// The query was limited, we must get pivot column values // The query was limited, we must get pivot column values
// Returned values must be in their original character set
// if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX)
// goto err;
query = (char*)PlugSubAlloc(g, NULL, 0); query = (char*)PlugSubAlloc(g, NULL, 0);
sprintf(query, "SELECT DISTINCT `%s` FROM `%s`", Picol, Tabname); sprintf(query, "SELECT DISTINCT `%s` FROM `%s`", Picol, Tabname);
PlugSubAlloc(g, NULL, strlen(query) + 1); PlugSubAlloc(g, NULL, strlen(query) + 1);
...@@ -284,8 +295,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) ...@@ -284,8 +295,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
valp->SetValue_pvblk(Rblkp, i); valp->SetValue_pvblk(Rblkp, i);
colname = valp->GetCharString(buf); colname = valp->GetCharString(buf);
crp->Name = (char*)PlugSubAlloc(g, NULL, strlen(colname) + 1); crp->Name = PlugDup(g, colname);
strcpy(crp->Name, colname);
crp->Flag = 1; crp->Flag = 1;
// Add this column // Add this column
...@@ -558,7 +568,7 @@ bool TDBPIVOT::MakePivotColumns(PGLOBAL g) ...@@ -558,7 +568,7 @@ bool TDBPIVOT::MakePivotColumns(PGLOBAL g)
// Check and initialize the subtable columns // Check and initialize the subtable columns
for (PCOL cp = Columns; cp; cp = cp->GetNext()) for (PCOL cp = Columns; cp; cp = cp->GetNext())
if (cp->GetAmType() == TYPE_AM_SRC) { if (cp->GetAmType() == TYPE_AM_SRC) {
if (((PSRCCOL)cp)->Init(g)) if (((PSRCCOL)cp)->Init(g, NULL))
return TRUE; return TRUE;
} else if (cp->GetAmType() == TYPE_AM_FNC) } else if (cp->GetAmType() == TYPE_AM_FNC)
...@@ -874,9 +884,9 @@ SRCCOL::SRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int n) ...@@ -874,9 +884,9 @@ SRCCOL::SRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int n)
/***********************************************************************/ /***********************************************************************/
/* Initialize the column as pointing to the source column. */ /* Initialize the column as pointing to the source column. */
/***********************************************************************/ /***********************************************************************/
bool SRCCOL::Init(PGLOBAL g) bool SRCCOL::Init(PGLOBAL g, PTDBASE tp)
{ {
if (PRXCOL::Init(g)) if (PRXCOL::Init(g, tp))
return true; return true;
AddStatus(BUF_READ); // All is done here AddStatus(BUF_READ); // All is done here
......
...@@ -180,9 +180,10 @@ class SRCCOL : public PRXCOL { ...@@ -180,9 +180,10 @@ class SRCCOL : public PRXCOL {
virtual int GetAmType(void) {return TYPE_AM_SRC;} virtual int GetAmType(void) {return TYPE_AM_SRC;}
// Methods // Methods
using PRXCOL::Init;
virtual void Reset(void) {} virtual void Reset(void) {}
void SetColumn(void); void SetColumn(void);
bool Init(PGLOBAL g); virtual bool Init(PGLOBAL g, PTDBASE tp);
bool CompareLast(void); bool CompareLast(void);
protected: protected:
......
...@@ -266,7 +266,7 @@ bool TDBTBL::InitTableList(PGLOBAL g) ...@@ -266,7 +266,7 @@ bool TDBTBL::InitTableList(PGLOBAL g)
// Real initialization will be done later. // Real initialization will be done later.
for (colp = Columns; colp; colp = colp->GetNext()) for (colp = Columns; colp; colp = colp->GetNext())
if (!colp->IsSpecial()) if (!colp->IsSpecial())
if (((PPRXCOL)colp)->Init(g) && !Accept) if (((PPRXCOL)colp)->Init(g, NULL) && !Accept)
return TRUE; return TRUE;
if (Tablist) if (Tablist)
...@@ -352,7 +352,9 @@ bool TDBTBL::TestFil(PGLOBAL g, PCFIL filp, PTABLE tabp) ...@@ -352,7 +352,9 @@ bool TDBTBL::TestFil(PGLOBAL g, PCFIL filp, PTABLE tabp)
/***********************************************************************/ /***********************************************************************/
int TDBTBL::Cardinality(PGLOBAL g) int TDBTBL::Cardinality(PGLOBAL g)
{ {
if (Cardinal < 0) { if (!g)
return 0; // Cannot make the table list
else if (Cardinal < 0) {
int tsz; int tsz;
if (!Tablist && InitTableList(g)) if (!Tablist && InitTableList(g))
...@@ -468,7 +470,7 @@ bool TDBTBL::OpenDB(PGLOBAL g) ...@@ -468,7 +470,7 @@ bool TDBTBL::OpenDB(PGLOBAL g)
for (PCOL cp = Columns; cp; cp = cp->GetNext()) for (PCOL cp = Columns; cp; cp = cp->GetNext())
if (cp->GetAmType() == TYPE_AM_TABID) if (cp->GetAmType() == TYPE_AM_TABID)
cp->COLBLK::Reset(); cp->COLBLK::Reset();
else if (((PPRXCOL)cp)->Init(g) && !Accept) else if (((PPRXCOL)cp)->Init(g, NULL) && !Accept)
return TRUE; return TRUE;
if (trace) if (trace)
...@@ -523,7 +525,7 @@ int TDBTBL::ReadDB(PGLOBAL g) ...@@ -523,7 +525,7 @@ int TDBTBL::ReadDB(PGLOBAL g)
if (cp->GetAmType() == TYPE_AM_TABID || if (cp->GetAmType() == TYPE_AM_TABID ||
cp->GetAmType() == TYPE_AM_SRVID) cp->GetAmType() == TYPE_AM_SRVID)
cp->COLBLK::Reset(); cp->COLBLK::Reset();
else if (((PPRXCOL)cp)->Init(g) && !Accept) else if (((PPRXCOL)cp)->Init(g, NULL) && !Accept)
return RC_FX; return RC_FX;
if (trace) if (trace)
...@@ -716,7 +718,7 @@ bool TDBTBM::OpenDB(PGLOBAL g) ...@@ -716,7 +718,7 @@ bool TDBTBM::OpenDB(PGLOBAL g)
for (PCOL cp = Columns; cp; cp = cp->GetNext()) for (PCOL cp = Columns; cp; cp = cp->GetNext())
if (cp->GetAmType() == TYPE_AM_TABID) if (cp->GetAmType() == TYPE_AM_TABID)
cp->COLBLK::Reset(); cp->COLBLK::Reset();
else if (((PPRXCOL)cp)->Init(g) && !Accept) else if (((PPRXCOL)cp)->Init(g, NULL) && !Accept)
return TRUE; return TRUE;
if (trace) if (trace)
...@@ -807,7 +809,7 @@ int TDBTBM::ReadNextRemote(PGLOBAL g) ...@@ -807,7 +809,7 @@ int TDBTBM::ReadNextRemote(PGLOBAL g)
for (PCOL cp = Columns; cp; cp = cp->GetNext()) for (PCOL cp = Columns; cp; cp = cp->GetNext())
if (cp->GetAmType() == TYPE_AM_TABID) if (cp->GetAmType() == TYPE_AM_TABID)
cp->COLBLK::Reset(); cp->COLBLK::Reset();
else if (((PPRXCOL)cp)->Init(g) && !Accept) else if (((PPRXCOL)cp)->Init(g, NULL) && !Accept)
return RC_FX; return RC_FX;
if (trace) if (trace)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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