mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Replace setjmp-longjmp's by try_catch-throw
modified: storage/connect/CMakeLists.txt modified: storage/connect/array.cpp modified: storage/connect/blkfil.cpp modified: storage/connect/colblk.cpp modified: storage/connect/connect.cc modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/filter.cpp modified: storage/connect/global.h modified: storage/connect/ha_connect.cc modified: storage/connect/jdbconn.cpp modified: storage/connect/json.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/osutil.c modified: storage/connect/plgdbutl.cpp deleted: storage/connect/plugutil.c added: storage/connect/plugutil.cpp modified: storage/connect/tabdos.cpp modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabjdbc.h modified: storage/connect/tabjson.cpp modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h modified: storage/connect/tabmysql.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabodbc.h modified: storage/connect/tabpivot.cpp modified: storage/connect/tabsys.cpp modified: storage/connect/tabvct.cpp modified: storage/connect/tabvir.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/valblk.cpp modified: storage/connect/value.cpp modified: storage/connect/xindex.cpp modified: storage/connect/xobject.cpp
This commit is contained in:
@@ -18,10 +18,10 @@ SET(CONNECT_PLUGIN_DYNAMIC "connect")
|
|||||||
|
|
||||||
SET(CONNECT_SOURCES
|
SET(CONNECT_SOURCES
|
||||||
ha_connect.cc connect.cc user_connect.cc mycat.cc
|
ha_connect.cc connect.cc user_connect.cc mycat.cc
|
||||||
fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h
|
fmdlex.c osutil.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 filamgz.cpp filamtxt.cpp
|
filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp filter.cpp
|
||||||
filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp
|
json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp plugutil.cpp
|
||||||
reldef.cpp tabcol.cpp tabdos.cpp tabext.cpp tabfix.cpp tabfmt.cpp tabjson.cpp
|
reldef.cpp tabcol.cpp tabdos.cpp tabext.cpp tabfix.cpp tabfmt.cpp tabjson.cpp
|
||||||
table.cpp tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp
|
table.cpp tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp
|
||||||
tabutil.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp
|
tabutil.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp
|
||||||
|
@@ -518,8 +518,12 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm)
|
|||||||
vp = valp;
|
vp = valp;
|
||||||
|
|
||||||
} else if (opc != OP_EXIST) {
|
} else if (opc != OP_EXIST) {
|
||||||
sprintf(g->Message, MSG(MISSING_ARG), opc);
|
sprintf(g->Message, MSG(MISSING_ARG), opc);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_ARRAY;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||||
|
#endif // !USE_TRY
|
||||||
} else // OP_EXIST
|
} else // OP_EXIST
|
||||||
return Nval > 0;
|
return Nval > 0;
|
||||||
|
|
||||||
@@ -681,15 +685,23 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
|
|||||||
{
|
{
|
||||||
if (Vblp == NULL) {
|
if (Vblp == NULL) {
|
||||||
strcpy(g->Message, MSG(PREC_VBLP_NULL));
|
strcpy(g->Message, MSG(PREC_VBLP_NULL));
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_ARRAY;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||||
|
#endif // !USE_TRY
|
||||||
} // endif Vblp
|
} // endif Vblp
|
||||||
|
|
||||||
bool was = Vblp->IsCi();
|
bool was = Vblp->IsCi();
|
||||||
|
|
||||||
if (was && !p) {
|
if (was && !p) {
|
||||||
strcpy(g->Message, MSG(BAD_SET_CASE));
|
strcpy(g->Message, MSG(BAD_SET_CASE));
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
#if defined(USE_TRY)
|
||||||
} // endif Vblp
|
throw TYPE_ARRAY;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Vblp
|
||||||
|
|
||||||
if (was || !p)
|
if (was || !p)
|
||||||
return;
|
return;
|
||||||
@@ -699,7 +711,11 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
|
|||||||
if (!was && Type == TYPE_STRING)
|
if (!was && Type == TYPE_STRING)
|
||||||
// Must be resorted to eliminate duplicate strings
|
// Must be resorted to eliminate duplicate strings
|
||||||
if (Sort(g))
|
if (Sort(g))
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_ARRAY;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
} // end of SetPrecision
|
} // end of SetPrecision
|
||||||
|
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
/************* BlkFil C++ Program Source Code File (.CPP) **************/
|
/************* BlkFil C++ Program Source Code File (.CPP) **************/
|
||||||
/* PROGRAM NAME: BLKFIL */
|
/* PROGRAM NAME: BLKFIL */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 2.5 */
|
/* Version 2.6 */
|
||||||
/* */
|
/* */
|
||||||
/* COPYRIGHT: */
|
/* COPYRIGHT: */
|
||||||
/* ---------- */
|
/* ---------- */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
|
/* (C) Copyright to the author Olivier BERTRAND 2004-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* WHAT THIS PROGRAM DOES: */
|
/* WHAT THIS PROGRAM DOES: */
|
||||||
/* ----------------------- */
|
/* ----------------------- */
|
||||||
@@ -595,8 +595,12 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
|
|||||||
|
|
||||||
if (Colp->GetResultType() != Type) {
|
if (Colp->GetResultType() != Type) {
|
||||||
sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH));
|
sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH));
|
||||||
longjmp(g->jumper[g->jump_level], 99);
|
#if defined(USE_TRY)
|
||||||
} else if (Colp->GetValue()->IsCi())
|
throw g->Message;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 99);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (Colp->GetValue()->IsCi())
|
||||||
Arap->SetPrecision(g, 1); // Case insensitive
|
Arap->SetPrecision(g, 1); // Case insensitive
|
||||||
|
|
||||||
Sorted = Colp->IsSorted() > 0;
|
Sorted = Colp->IsSorted() > 0;
|
||||||
|
@@ -197,8 +197,12 @@ int COLBLK::GetLengthEx(void)
|
|||||||
void COLBLK::ReadColumn(PGLOBAL g)
|
void COLBLK::ReadColumn(PGLOBAL g)
|
||||||
{
|
{
|
||||||
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
|
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
#if defined(USE_TRY)
|
||||||
} // end of ReadColumn
|
throw TYPE_COLBLK;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // end of ReadColumn
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* WriteColumn: what this routine does is to access the last line */
|
/* WriteColumn: what this routine does is to access the last line */
|
||||||
@@ -208,8 +212,12 @@ void COLBLK::ReadColumn(PGLOBAL g)
|
|||||||
void COLBLK::WriteColumn(PGLOBAL g)
|
void COLBLK::WriteColumn(PGLOBAL g)
|
||||||
{
|
{
|
||||||
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
|
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
#if defined(USE_TRY)
|
||||||
} // end of WriteColumn
|
throw TYPE_COLBLK;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // end of WriteColumn
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Make file output of a column descriptor block. */
|
/* Make file output of a column descriptor block. */
|
||||||
@@ -262,8 +270,12 @@ SPCBLK::SPCBLK(PCOLUMN cp)
|
|||||||
void SPCBLK::WriteColumn(PGLOBAL g)
|
void SPCBLK::WriteColumn(PGLOBAL g)
|
||||||
{
|
{
|
||||||
sprintf(g->Message, MSG(SPCOL_READONLY), Name);
|
sprintf(g->Message, MSG(SPCOL_READONLY), Name);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
#if defined(USE_TRY)
|
||||||
} // end of WriteColumn
|
throw TYPE_COLBLK;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // end of WriteColumn
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* RIDBLK constructor for the ROWID special column. */
|
/* RIDBLK constructor for the ROWID special column. */
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) Olivier Bertrand 2004 - 2015
|
/* Copyright (C) Olivier Bertrand 2004 - 2017
|
||||||
|
|
||||||
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
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2015 */
|
/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* WHAT THIS PROGRAM DOES: */
|
/* WHAT THIS PROGRAM DOES: */
|
||||||
/* ----------------------- */
|
/* ----------------------- */
|
||||||
/* This program are the CONNECT general purpose semantic routines. */
|
/* This program are the CONNECT general purpose semantic routines. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#ifdef USE_PRAGMA_IMPLEMENTATION
|
#ifdef USE_PRAGMA_IMPLEMENTATION
|
||||||
@@ -188,47 +188,60 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
|
|||||||
/* GetTDB: Get the table description block of a CONNECT table. */
|
/* GetTDB: Get the table description block of a CONNECT table. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
|
PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
|
||||||
{
|
{
|
||||||
int rc;
|
PTDB tdbp;
|
||||||
PTDB tdbp;
|
PTABLE tabp;
|
||||||
PTABLE tabp;
|
PDBUSER dup = PlgGetUser(g);
|
||||||
PDBUSER dup= PlgGetUser(g);
|
volatile PCATLG cat = (dup) ? dup->Catalog : NULL; // Safe over longjmp
|
||||||
volatile PCATLG cat= (dup) ? dup->Catalog : NULL; // Safe over longjmp
|
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat);
|
printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat);
|
||||||
|
|
||||||
if (!cat)
|
if (!cat)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return NULL;
|
// Save stack and allocation environment and prepare error return
|
||||||
} // endif jump_level
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return NULL;
|
||||||
|
} // endif jump_level
|
||||||
|
|
||||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
if (setjmp(g->jumper[++g->jump_level])) {
|
||||||
tdbp= NULL;
|
tdbp = NULL;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
// Get table object from the catalog
|
// Get table object from the catalog
|
||||||
tabp= new(g) XTAB(name);
|
tabp = new(g) XTAB(name);
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
printf("CntGetTDB: tabp=%p\n", tabp);
|
printf("CntGetTDB: tabp=%p\n", tabp);
|
||||||
|
|
||||||
// Perhaps this should be made thread safe
|
// Perhaps this should be made thread safe
|
||||||
((MYCAT*)cat)->SetHandler(h);
|
((MYCAT*)cat)->SetHandler(h);
|
||||||
|
|
||||||
if (!(tdbp= cat->GetTable(g, tabp, mode)))
|
if (!(tdbp = cat->GetTable(g, tabp, mode)))
|
||||||
printf("CntGetTDB: %s\n", g->Message);
|
printf("CntGetTDB: %s\n", g->Message);
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
|
err:
|
||||||
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
err:
|
|
||||||
if (trace)
|
if (trace)
|
||||||
printf("Returning tdbp=%p mode=%d\n", tdbp, mode);
|
printf("Returning tdbp=%p mode=%d\n", tdbp, mode);
|
||||||
|
|
||||||
g->jump_level--;
|
|
||||||
return tdbp;
|
return tdbp;
|
||||||
} // end of CntGetTDB
|
} // end of CntGetTDB
|
||||||
|
|
||||||
@@ -239,7 +252,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
|||||||
bool del, PHC)
|
bool del, PHC)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
int i, n, rc;
|
int i, n;
|
||||||
bool rcop= true;
|
bool rcop= true;
|
||||||
PCOL colp;
|
PCOL colp;
|
||||||
//PCOLUMN cp;
|
//PCOLUMN cp;
|
||||||
@@ -254,15 +267,19 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
|||||||
return true;
|
return true;
|
||||||
} // endif tdbp
|
} // endif tdbp
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return true;
|
// Save stack and allocation environment and prepare error return
|
||||||
} // endif jump_level
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return true;
|
||||||
|
} // endif jump_level
|
||||||
|
|
||||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
if (setjmp(g->jumper[++g->jump_level])) {
|
||||||
goto err;
|
goto err;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (!c1) {
|
if (!c1) {
|
||||||
if (mode == MODE_INSERT)
|
if (mode == MODE_INSERT)
|
||||||
@@ -281,7 +298,11 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
|||||||
if (g->Message[0] == 0)
|
if (g->Message[0] == 0)
|
||||||
sprintf(g->Message, MSG(COL_ISNOT_TABLE), p, tdbp->GetName());
|
sprintf(g->Message, MSG(COL_ISNOT_TABLE), p, tdbp->GetName());
|
||||||
|
|
||||||
goto err;
|
#if defined(USE_TRY)
|
||||||
|
throw 1;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto err;
|
||||||
|
#endif // !USE_TRY
|
||||||
} // endif colp
|
} // endif colp
|
||||||
|
|
||||||
n= strlen(p) + 1;
|
n= strlen(p) + 1;
|
||||||
@@ -289,12 +310,20 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
|||||||
|
|
||||||
for (i= 0, colp= tdbp->GetColumns(); colp; i++, colp= colp->GetNext()) {
|
for (i= 0, colp= tdbp->GetColumns(); colp; i++, colp= colp->GetNext()) {
|
||||||
if (colp->InitValue(g))
|
if (colp->InitValue(g))
|
||||||
goto err;
|
#if defined(USE_TRY)
|
||||||
|
throw 2;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto err;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (mode == MODE_INSERT)
|
if (mode == MODE_INSERT)
|
||||||
// Allow type conversion
|
// Allow type conversion
|
||||||
if (colp->SetBuffer(g, colp->GetValue(), true, false))
|
if (colp->SetBuffer(g, colp->GetValue(), true, false))
|
||||||
goto err;
|
#if defined(USE_TRY)
|
||||||
|
throw 3;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto err;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
colp->AddColUse(U_P); // For PLG tables
|
colp->AddColUse(U_P); // For PLG tables
|
||||||
} // endfor colp
|
} // endfor colp
|
||||||
@@ -309,8 +338,12 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
|||||||
|
|
||||||
if (!(utp= (PTDBASE)tdbp->Duplicate(g))) {
|
if (!(utp= (PTDBASE)tdbp->Duplicate(g))) {
|
||||||
sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName());
|
sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName());
|
||||||
goto err;
|
#if defined(USE_TRY)
|
||||||
} // endif tp
|
throw 4;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto err;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif tp
|
||||||
|
|
||||||
if (!c2)
|
if (!c2)
|
||||||
// Allocate all column blocks for that table
|
// Allocate all column blocks for that table
|
||||||
@@ -323,10 +356,18 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
|||||||
|
|
||||||
for (i= 0, colp= utp->GetColumns(); colp; i++, colp= colp->GetNext()) {
|
for (i= 0, colp= utp->GetColumns(); colp; i++, colp= colp->GetNext()) {
|
||||||
if (colp->InitValue(g))
|
if (colp->InitValue(g))
|
||||||
goto err;
|
#if defined(USE_TRY)
|
||||||
|
throw 5;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto err;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (colp->SetBuffer(g, colp->GetValue(), true, false))
|
if (colp->SetBuffer(g, colp->GetValue(), true, false))
|
||||||
goto err;
|
#if defined(USE_TRY)
|
||||||
|
throw 6;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto err;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
} // endfor colp
|
} // endfor colp
|
||||||
|
|
||||||
@@ -358,16 +399,29 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
|||||||
if (mode != MODE_ANY && mode != MODE_ALTER) {
|
if (mode != MODE_ANY && mode != MODE_ALTER) {
|
||||||
if (tdbp->OpenDB(g)) {
|
if (tdbp->OpenDB(g)) {
|
||||||
printf("%s\n", g->Message);
|
printf("%s\n", g->Message);
|
||||||
goto err;
|
#if defined(USE_TRY)
|
||||||
} else
|
throw 7;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto err;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else
|
||||||
tdbp->SetNext(NULL);
|
tdbp->SetNext(NULL);
|
||||||
|
|
||||||
} // endif mode
|
} // endif mode
|
||||||
|
|
||||||
rcop= false;
|
rcop= false;
|
||||||
|
|
||||||
err:
|
#if defined(USE_TRY)
|
||||||
g->jump_level--;
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
|
err:
|
||||||
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
return rcop;
|
return rcop;
|
||||||
} // end of CntOpenTable
|
} // end of CntOpenTable
|
||||||
|
|
||||||
@@ -391,23 +445,27 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
|
|||||||
RCODE rc= RC_OK;
|
RCODE rc= RC_OK;
|
||||||
PCOL colp;
|
PCOL colp;
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
if (trace) {
|
#else // !USE_TRY
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
// Save stack and allocation environment and prepare error return
|
||||||
printf("EvalColumns: %s\n", g->Message);
|
if (g->jump_level == MAX_JUMP) {
|
||||||
} // endif
|
if (trace) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
printf("EvalColumns: %s\n", g->Message);
|
||||||
|
} // endif
|
||||||
|
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
} // endif jump_level
|
} // endif jump_level
|
||||||
|
|
||||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||||
if (trace)
|
if (trace)
|
||||||
printf("Error reading columns: %s\n", g->Message);
|
printf("Error reading columns: %s\n", g->Message);
|
||||||
|
|
||||||
rc= RC_FX;
|
rc = RC_FX;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
for (colp= tdbp->GetColumns(); rc == RC_OK && colp;
|
for (colp= tdbp->GetColumns(); rc == RC_OK && colp;
|
||||||
colp= colp->GetNext()) {
|
colp= colp->GetNext()) {
|
||||||
@@ -421,8 +479,19 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
|
|||||||
|
|
||||||
} // endfor colp
|
} // endfor colp
|
||||||
|
|
||||||
err:
|
#if defined(USE_TRY)
|
||||||
g->jump_level--;
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
printf("Error %d reading columns: %s\n", n, g->Message);
|
||||||
|
|
||||||
|
rc = RC_FX;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
|
err:
|
||||||
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
return rc;
|
return rc;
|
||||||
} // end of EvalColumns
|
} // end of EvalColumns
|
||||||
|
|
||||||
@@ -445,16 +514,20 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
|
|||||||
((PTDBASE)tdbp)->ResetKindex(g, NULL);
|
((PTDBASE)tdbp)->ResetKindex(g, NULL);
|
||||||
} // endif index
|
} // endif index
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return RC_FX;
|
// Save stack and allocation environment and prepare error return
|
||||||
} // endif jump_level
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return RC_FX;
|
||||||
|
} // endif jump_level
|
||||||
|
|
||||||
if ((setjmp(g->jumper[++g->jump_level])) != 0) {
|
if ((setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||||
rc= RC_FX;
|
rc = RC_FX;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
// Do it now to avoid double eval when filtering
|
// Do it now to avoid double eval when filtering
|
||||||
for (PCOL colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
|
for (PCOL colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
|
||||||
@@ -470,8 +543,17 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
|
|||||||
if (rc == RC_OK)
|
if (rc == RC_OK)
|
||||||
rc= EvalColumns(g, tdbp, false);
|
rc= EvalColumns(g, tdbp, false);
|
||||||
|
|
||||||
err:
|
#if defined(USE_TRY)
|
||||||
g->jump_level--;
|
} catch (int) {
|
||||||
|
rc = RC_FX;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
rc = RC_FX;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
|
err:
|
||||||
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
return rc;
|
return rc;
|
||||||
} // end of CntReadNext
|
} // end of CntReadNext
|
||||||
|
|
||||||
@@ -487,17 +569,21 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
|
|||||||
if (!tdbp)
|
if (!tdbp)
|
||||||
return RC_FX;
|
return RC_FX;
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return RC_FX;
|
// Save stack and allocation environment and prepare error return
|
||||||
} // endif jump_level
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return RC_FX;
|
||||||
|
} // endif jump_level
|
||||||
|
|
||||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||||
printf("%s\n", g->Message);
|
printf("%s\n", g->Message);
|
||||||
rc= RC_FX;
|
rc = RC_FX;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
// Store column values in table write buffer(s)
|
// Store column values in table write buffer(s)
|
||||||
for (colp= tdbp->GetSetCols(); colp; colp= colp->GetNext())
|
for (colp= tdbp->GetSetCols(); colp; colp= colp->GetNext())
|
||||||
@@ -511,8 +597,18 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
|
|||||||
// Return result code from write operation
|
// Return result code from write operation
|
||||||
rc= (RCODE)tdbp->WriteDB(g);
|
rc= (RCODE)tdbp->WriteDB(g);
|
||||||
|
|
||||||
err:
|
#if defined(USE_TRY)
|
||||||
g->jump_level--;
|
} catch (int n) {
|
||||||
|
printf("Exception %d: %s\n", n, g->Message);
|
||||||
|
rc = RC_FX;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
rc = RC_FX;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
|
err:
|
||||||
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
return rc;
|
return rc;
|
||||||
} // end of CntWriteRow
|
} // end of CntWriteRow
|
||||||
|
|
||||||
@@ -598,49 +694,59 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
|
|||||||
break;
|
break;
|
||||||
} // endswitch rc
|
} // endswitch rc
|
||||||
|
|
||||||
// Prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
rc= RC_FX;
|
// Prepare error return
|
||||||
goto err;
|
if (g->jump_level == MAX_JUMP) {
|
||||||
} // endif
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
rc = RC_FX;
|
||||||
|
goto err;
|
||||||
|
} // endif
|
||||||
|
|
||||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||||
rc= RC_FX;
|
rc = RC_FX;
|
||||||
g->jump_level--;
|
goto err;
|
||||||
goto err;
|
} // endif
|
||||||
} // endif
|
#endif // !USE_TRY
|
||||||
|
|
||||||
// This will close the table file(s) and also finalize write
|
// This will close the table file(s) and also finalize write
|
||||||
// operations such as Insert, Update, or Delete.
|
// operations such as Insert, Update, or Delete.
|
||||||
tdbp->SetAbort(abort);
|
tdbp->SetAbort(abort);
|
||||||
tdbp->CloseDB(g);
|
tdbp->CloseDB(g);
|
||||||
tdbp->SetAbort(false);
|
tdbp->SetAbort(false);
|
||||||
g->jump_level--;
|
|
||||||
|
|
||||||
if (trace > 1)
|
if (trace > 1)
|
||||||
printf("Table %s closed\n", tdbp->GetName());
|
printf("Table %s closed\n", tdbp->GetName());
|
||||||
|
|
||||||
//if (!((PTDBDOX)tdbp)->GetModified())
|
if (!nox && tdbp->GetMode() != MODE_READ && tdbp->GetMode() != MODE_ANY) {
|
||||||
// return 0;
|
if (trace > 1)
|
||||||
|
printf("About to reset opt\n");
|
||||||
|
|
||||||
if (nox || tdbp->GetMode() == MODE_READ || tdbp->GetMode() == MODE_ANY)
|
if (!tdbp->IsRemote()) {
|
||||||
return 0;
|
// Make all the eventual indexes
|
||||||
|
PTDBDOX tbxp = (PTDBDOX)tdbp;
|
||||||
|
tbxp->ResetKindex(g, NULL);
|
||||||
|
tbxp->SetKey_Col(NULL);
|
||||||
|
rc = tbxp->ResetTableOpt(g, true, tbxp->GetDef()->Indexable() == 1);
|
||||||
|
} // endif remote
|
||||||
|
|
||||||
|
} // endif nox
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
} catch (int) {
|
||||||
|
rc = RC_FX;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
rc = RC_FX;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
|
err:
|
||||||
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (trace > 1)
|
if (trace > 1)
|
||||||
printf("About to reset opt\n");
|
htrc("Done rc=%d\n", rc);
|
||||||
|
|
||||||
if (!tdbp->IsRemote()) {
|
|
||||||
// Make all the eventual indexes
|
|
||||||
PTDBDOX tbxp = (PTDBDOX)tdbp;
|
|
||||||
tbxp->ResetKindex(g, NULL);
|
|
||||||
tbxp->SetKey_Col(NULL);
|
|
||||||
rc = tbxp->ResetTableOpt(g, true, tbxp->GetDef()->Indexable() == 1);
|
|
||||||
} // endif remote
|
|
||||||
|
|
||||||
err:
|
|
||||||
if (trace > 1)
|
|
||||||
printf("Done rc=%d\n", rc);
|
|
||||||
|
|
||||||
return (rc == RC_OK || rc == RC_INFO) ? 0 : rc;
|
return (rc == RC_OK || rc == RC_INFO) ? 0 : rc;
|
||||||
} // end of CntCloseTable
|
} // end of CntCloseTable
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
/*********** File AM Txt C++ Program Source Code File (.CPP) ***********/
|
/*********** File AM Txt C++ Program Source Code File (.CPP) ***********/
|
||||||
/* PROGRAM NAME: FILAMTXT */
|
/* PROGRAM NAME: FILAMTXT */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 1.6 */
|
/* Version 1.7 */
|
||||||
/* */
|
/* */
|
||||||
/* COPYRIGHT: */
|
/* COPYRIGHT: */
|
||||||
/* ---------- */
|
/* ---------- */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
|
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* WHAT THIS PROGRAM DOES: */
|
/* WHAT THIS PROGRAM DOES: */
|
||||||
/* ----------------------- */
|
/* ----------------------- */
|
||||||
@@ -1161,13 +1161,21 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
|
|||||||
if (rename(filename, filetemp)) { // Save file for security
|
if (rename(filename, filetemp)) { // Save file for security
|
||||||
sprintf(g->Message, MSG(RENAME_ERROR),
|
sprintf(g->Message, MSG(RENAME_ERROR),
|
||||||
filename, filetemp, strerror(errno));
|
filename, filetemp, strerror(errno));
|
||||||
longjmp(g->jumper[g->jump_level], 51);
|
#if defined(USE_TRY)
|
||||||
} else if (rename(tempname, filename)) {
|
throw 51;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 51);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (rename(tempname, filename)) {
|
||||||
sprintf(g->Message, MSG(RENAME_ERROR),
|
sprintf(g->Message, MSG(RENAME_ERROR),
|
||||||
tempname, filename, strerror(errno));
|
tempname, filename, strerror(errno));
|
||||||
rc = rename(filetemp, filename); // Restore saved file
|
rc = rename(filetemp, filename); // Restore saved file
|
||||||
longjmp(g->jumper[g->jump_level], 52);
|
#if defined(USE_TRY)
|
||||||
} else if (remove(filetemp)) {
|
throw 52;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 52);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (remove(filetemp)) {
|
||||||
sprintf(g->Message, MSG(REMOVE_ERROR),
|
sprintf(g->Message, MSG(REMOVE_ERROR),
|
||||||
filetemp, strerror(errno));
|
filetemp, strerror(errno));
|
||||||
rc = RC_INFO; // Acceptable
|
rc = RC_INFO; // Acceptable
|
||||||
|
@@ -560,6 +560,8 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool VCTFAM::InitInsert(PGLOBAL g)
|
bool VCTFAM::InitInsert(PGLOBAL g)
|
||||||
{
|
{
|
||||||
|
bool rc = false;
|
||||||
|
|
||||||
// We come here in MODE_INSERT only
|
// We come here in MODE_INSERT only
|
||||||
if (Last == Nrec) {
|
if (Last == Nrec) {
|
||||||
CurBlk = Block;
|
CurBlk = Block;
|
||||||
@@ -573,27 +575,44 @@ bool VCTFAM::InitInsert(PGLOBAL g)
|
|||||||
CurBlk = Block - 1;
|
CurBlk = Block - 1;
|
||||||
CurNum = Last;
|
CurNum = Last;
|
||||||
|
|
||||||
// Prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return true;
|
// Prepare error return
|
||||||
} // endif
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return true;
|
||||||
|
} // endif
|
||||||
|
|
||||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
return true;
|
return true;
|
||||||
} // endif
|
} // endif
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
// Last block must be updated by new values
|
// Last block must be updated by new values
|
||||||
for (; cp; cp = (PVCTCOL)cp->Next)
|
for (; cp; cp = (PVCTCOL)cp->Next)
|
||||||
cp->ReadBlock(g);
|
cp->ReadBlock(g);
|
||||||
|
|
||||||
g->jump_level--;
|
#if defined(USE_TRY)
|
||||||
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
rc = true;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
rc = true;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
} // endif Last
|
} // endif Last
|
||||||
|
|
||||||
// We are not currently using a temporary file for Insert
|
if (!rc)
|
||||||
T_Stream = Stream;
|
// We are not currently using a temporary file for Insert
|
||||||
return false;
|
T_Stream = Stream;
|
||||||
|
|
||||||
|
return rc;
|
||||||
} // end of InitInsert
|
} // end of InitInsert
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1107,7 +1126,11 @@ void VCTFAM::CloseTableFile(PGLOBAL g, bool abort)
|
|||||||
} else if (AddBlock) {
|
} else if (AddBlock) {
|
||||||
// Last block was not written
|
// Last block was not written
|
||||||
rc = ResetTableSize(g, CurBlk, Nrec);
|
rc = ResetTableSize(g, CurBlk, Nrec);
|
||||||
longjmp(g->jumper[g->jump_level], 44);
|
#if defined(USE_TRY)
|
||||||
|
throw 44;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 44);
|
||||||
|
#endif // !USE_TRY
|
||||||
} // endif
|
} // endif
|
||||||
|
|
||||||
} else if (mode == MODE_UPDATE) {
|
} else if (mode == MODE_UPDATE) {
|
||||||
@@ -1528,7 +1551,7 @@ bool VCMFAM::AllocateBuffer(PGLOBAL g)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool VCMFAM::InitInsert(PGLOBAL g)
|
bool VCMFAM::InitInsert(PGLOBAL g)
|
||||||
{
|
{
|
||||||
int rc;
|
bool rc = false;
|
||||||
volatile PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
|
volatile PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
|
||||||
|
|
||||||
// We come here in MODE_INSERT only
|
// We come here in MODE_INSERT only
|
||||||
@@ -1542,23 +1565,38 @@ bool VCMFAM::InitInsert(PGLOBAL g)
|
|||||||
CurNum = Last;
|
CurNum = Last;
|
||||||
} // endif Last
|
} // endif Last
|
||||||
|
|
||||||
// Prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return true;
|
// Prepare error return
|
||||||
} // endif
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return true;
|
||||||
|
} // endif
|
||||||
|
|
||||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
return true;
|
return true;
|
||||||
} // endif
|
} // endif
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
// Initialize the column block pointer
|
// Initialize the column block pointer
|
||||||
for (; cp; cp = (PVCTCOL)cp->Next)
|
for (; cp; cp = (PVCTCOL)cp->Next)
|
||||||
cp->ReadBlock(g);
|
cp->ReadBlock(g);
|
||||||
|
|
||||||
g->jump_level--;
|
#if defined(USE_TRY)
|
||||||
return false;
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
rc = true;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
rc = true;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
return rc;
|
||||||
} // end of InitInsert
|
} // end of InitInsert
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -2503,7 +2541,11 @@ void VECFAM::CloseTableFile(PGLOBAL g, bool abort)
|
|||||||
if (wrc != RC_FX)
|
if (wrc != RC_FX)
|
||||||
rc = ResetTableSize(g, Block, Last);
|
rc = ResetTableSize(g, Block, Last);
|
||||||
else
|
else
|
||||||
longjmp(g->jumper[g->jump_level], 44);
|
#if defined(USE_TRY)
|
||||||
|
throw 44;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 44);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
} else if (mode == MODE_UPDATE) {
|
} else if (mode == MODE_UPDATE) {
|
||||||
if (UseTemp && !InitUpdate && !Abort) {
|
if (UseTemp && !InitUpdate && !Abort) {
|
||||||
@@ -4164,8 +4206,12 @@ void BGVFAM::CloseTableFile(PGLOBAL g, bool abort)
|
|||||||
} else if (AddBlock) {
|
} else if (AddBlock) {
|
||||||
// Last block was not written
|
// Last block was not written
|
||||||
rc = ResetTableSize(g, CurBlk, Nrec);
|
rc = ResetTableSize(g, CurBlk, Nrec);
|
||||||
longjmp(g->jumper[g->jump_level], 44);
|
#if defined(USE_TRY)
|
||||||
} // endif
|
throw 44;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 44);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif
|
||||||
|
|
||||||
} else if (mode == MODE_UPDATE) {
|
} else if (mode == MODE_UPDATE) {
|
||||||
// Write back to file any pending modifications
|
// Write back to file any pending modifications
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/***************** Filter C++ Class Filter Code (.CPP) *****************/
|
/***************** Filter C++ Class Filter Code (.CPP) *****************/
|
||||||
/* Name: FILTER.CPP Version 3.9 */
|
/* Name: FILTER.CPP Version 4.0 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
|
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the class FILTER function code. */
|
/* This file contains the class FILTER function code. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -87,8 +87,12 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc)
|
|||||||
case OP_EXIST: bt = 0x00; break;
|
case OP_EXIST: bt = 0x00; break;
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
|
sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
#if defined(USE_TRY)
|
||||||
} // endswitch opc
|
throw TYPE_ARRAY;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endswitch opc
|
||||||
|
|
||||||
return bt;
|
return bt;
|
||||||
} // end of OpBmp
|
} // end of OpBmp
|
||||||
@@ -1711,7 +1715,11 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
|
|||||||
break; // Remove eventual ending separator(s)
|
break; // Remove eventual ending separator(s)
|
||||||
|
|
||||||
// if (fp->Convert(g, having))
|
// if (fp->Convert(g, having))
|
||||||
// longjmp(g->jumper[g->jump_level], TYPE_FILTER);
|
//#if defined(USE_TRY)
|
||||||
|
// throw TYPE_ARRAY;
|
||||||
|
//#else // !USE_TRY
|
||||||
|
// longjmp(g->jumper[g->jump_level], TYPE_FILTER);
|
||||||
|
//#endif // !USE_TRY
|
||||||
|
|
||||||
filp = fp;
|
filp = fp;
|
||||||
fp = fp->Next;
|
fp = fp->Next;
|
||||||
@@ -1744,7 +1752,11 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
|
|||||||
// return TRUE;
|
// return TRUE;
|
||||||
|
|
||||||
if (filp->Eval(g))
|
if (filp->Eval(g))
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_FILTER);
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_FILTER;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_FILTER);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (trace > 1)
|
if (trace > 1)
|
||||||
htrc("PlugFilter filp=%p result=%d\n",
|
htrc("PlugFilter filp=%p result=%d\n",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */
|
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */
|
||||||
/* (C) Copyright Olivier Bertrand 1993-2014 */
|
/* (C) Copyright Olivier Bertrand 1993-2017 */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -229,9 +229,10 @@ typedef struct _parm {
|
|||||||
typedef struct _global { /* Global structure */
|
typedef struct _global { /* Global structure */
|
||||||
void *Sarea; /* Points to work area */
|
void *Sarea; /* Points to work area */
|
||||||
uint Sarea_Size; /* Work area size */
|
uint Sarea_Size; /* Work area size */
|
||||||
PACTIVITY Activityp, ActivityStart;
|
PACTIVITY Activityp;
|
||||||
char Message[MAX_STR];
|
char Message[MAX_STR];
|
||||||
int Createas; /* To pass info to created table */
|
ulong More; /* Used by jsonudf */
|
||||||
|
int Createas; /* To pass info to created table */
|
||||||
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 */
|
||||||
|
@@ -1895,40 +1895,62 @@ int ha_connect::OpenTable(PGLOBAL g, bool del)
|
|||||||
bool ha_connect::CheckColumnList(PGLOBAL g)
|
bool ha_connect::CheckColumnList(PGLOBAL g)
|
||||||
{
|
{
|
||||||
// Check the list of used fields (columns)
|
// Check the list of used fields (columns)
|
||||||
int rc;
|
|
||||||
bool brc= false;
|
bool brc= false;
|
||||||
PCOL colp;
|
PCOL colp;
|
||||||
Field* *field;
|
Field* *field;
|
||||||
Field* fp;
|
Field* fp;
|
||||||
MY_BITMAP *map= table->read_set;
|
MY_BITMAP *map= table->read_set;
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return true;
|
// Save stack and allocation environment and prepare error return
|
||||||
} // endif jump_level
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return true;
|
||||||
|
} // endif jump_level
|
||||||
|
|
||||||
if ((rc= setjmp(g->jumper[++g->jump_level])) == 0) {
|
if (!setjmp(g->jumper[++g->jump_level])) {
|
||||||
|
#endif // !USE_TRY
|
||||||
for (field= table->field; fp= *field; field++)
|
for (field= table->field; fp= *field; field++)
|
||||||
if (bitmap_is_set(map, fp->field_index)) {
|
if (bitmap_is_set(map, fp->field_index)) {
|
||||||
if (!(colp= tdbp->ColDB(g, (PSZ)fp->field_name, 0))) {
|
if (!(colp= tdbp->ColDB(g, (PSZ)fp->field_name, 0))) {
|
||||||
sprintf(g->Message, "Column %s not found in %s",
|
sprintf(g->Message, "Column %s not found in %s",
|
||||||
fp->field_name, tdbp->GetName());
|
fp->field_name, tdbp->GetName());
|
||||||
brc= true;
|
#if defined(USE_TRY)
|
||||||
goto fin;
|
throw 1;
|
||||||
} // endif colp
|
#else // !USE_TRY
|
||||||
|
brc = true;
|
||||||
|
goto fin;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif colp
|
||||||
|
|
||||||
if ((brc= colp->InitValue(g)))
|
if ((brc= colp->InitValue(g)))
|
||||||
goto fin;
|
#if defined(USE_TRY)
|
||||||
|
throw 2;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto fin;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
colp->AddColUse(U_P); // For PLG tables
|
colp->AddColUse(U_P); // For PLG tables
|
||||||
} // endif
|
} // endif
|
||||||
|
|
||||||
} else
|
#if defined(USE_TRY)
|
||||||
brc= true;
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
brc = true;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
brc = true;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
|
} else
|
||||||
|
brc = true;
|
||||||
|
|
||||||
fin:
|
fin:
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
return brc;
|
return brc;
|
||||||
} // end of CheckColumnList
|
} // end of CheckColumnList
|
||||||
|
|
||||||
@@ -3054,7 +3076,6 @@ const COND *ha_connect::cond_push(const COND *cond)
|
|||||||
DBUG_ENTER("ha_connect::cond_push");
|
DBUG_ENTER("ha_connect::cond_push");
|
||||||
|
|
||||||
if (tdbp) {
|
if (tdbp) {
|
||||||
int rc;
|
|
||||||
PGLOBAL& g= xp->g;
|
PGLOBAL& g= xp->g;
|
||||||
AMT tty= tdbp->GetAmType();
|
AMT tty= tdbp->GetAmType();
|
||||||
bool x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC);
|
bool x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC);
|
||||||
@@ -3062,15 +3083,19 @@ const COND *ha_connect::cond_push(const COND *cond)
|
|||||||
tty == TYPE_AM_TBL || tty == TYPE_AM_MYSQL ||
|
tty == TYPE_AM_TBL || tty == TYPE_AM_MYSQL ||
|
||||||
tty == TYPE_AM_PLG || tty == TYPE_AM_JDBC || x);
|
tty == TYPE_AM_PLG || tty == TYPE_AM_JDBC || x);
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
// This should never happen but is done to avoid crashing
|
||||||
if (g->jump_level == MAX_JUMP) {
|
#if defined(USE_TRY)
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
try {
|
||||||
DBUG_RETURN(cond);
|
#else // !USE_TRY
|
||||||
} // endif jump_level
|
// Save stack and allocation environment and prepare error return
|
||||||
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
DBUG_RETURN(cond);
|
||||||
|
} // endif jump_level
|
||||||
|
|
||||||
// This should never happen but is done to avoid crashing
|
if (setjmp(g->jumper[++g->jump_level]))
|
||||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0)
|
goto fin;
|
||||||
goto fin;
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
PCFIL filp;
|
PCFIL filp;
|
||||||
@@ -3078,7 +3103,7 @@ const COND *ha_connect::cond_push(const COND *cond)
|
|||||||
|
|
||||||
if ((filp= tdbp->GetCondFil()) && filp->Cond == cond &&
|
if ((filp= tdbp->GetCondFil()) && filp->Cond == cond &&
|
||||||
filp->Idx == active_index && filp->Type == tty)
|
filp->Idx == active_index && filp->Type == tty)
|
||||||
goto fin; // Already done
|
goto fin;
|
||||||
|
|
||||||
filp= new(g) CONDFIL(cond, active_index, tty);
|
filp= new(g) CONDFIL(cond, active_index, tty);
|
||||||
rc = filp->Init(g, this);
|
rc = filp->Init(g, this);
|
||||||
@@ -3111,9 +3136,20 @@ const COND *ha_connect::cond_push(const COND *cond)
|
|||||||
} else if (tty != TYPE_AM_JSN && tty != TYPE_AM_JSON)
|
} else if (tty != TYPE_AM_JSN && tty != TYPE_AM_JSON)
|
||||||
tdbp->SetFilter(CondFilter(g, (Item *)cond));
|
tdbp->SetFilter(CondFilter(g, (Item *)cond));
|
||||||
|
|
||||||
fin:
|
#if defined(USE_TRY)
|
||||||
g->jump_level--;
|
} catch (int n) {
|
||||||
} // endif tdbp
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
fin:;
|
||||||
|
#else // !USE_TRY
|
||||||
|
fin:
|
||||||
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif tdbp
|
||||||
|
|
||||||
// Let MySQL do the filtering
|
// Let MySQL do the filtering
|
||||||
DBUG_RETURN(cond);
|
DBUG_RETURN(cond);
|
||||||
@@ -3263,6 +3299,22 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
|
|||||||
PGLOBAL& g= xp->g;
|
PGLOBAL& g= xp->g;
|
||||||
PDBUSER dup= PlgGetUser(g);
|
PDBUSER dup= PlgGetUser(g);
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
try {
|
||||||
|
#else // !USE_TRY
|
||||||
|
// Prepare error return
|
||||||
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
|
goto err;
|
||||||
|
} // endif
|
||||||
|
|
||||||
|
if (setjmp(g->jumper[++g->jump_level])) {
|
||||||
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
|
goto err;
|
||||||
|
} // endif setjmp
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
// Ignore error on the opt file
|
// Ignore error on the opt file
|
||||||
dup->Check &= ~CHK_OPT;
|
dup->Check &= ~CHK_OPT;
|
||||||
tdbp= GetTDB(g);
|
tdbp= GetTDB(g);
|
||||||
@@ -3284,6 +3336,20 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
|
|||||||
} else if (!tdbp)
|
} else if (!tdbp)
|
||||||
rc= HA_ERR_INTERNAL_ERROR;
|
rc= HA_ERR_INTERNAL_ERROR;
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
|
err:
|
||||||
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
} // end of optimize
|
} // end of optimize
|
||||||
|
|
||||||
@@ -5292,7 +5358,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
if (topt->oplist) {
|
if (topt->oplist) {
|
||||||
host= GetListOption(g, "host", topt->oplist, "localhost");
|
host= GetListOption(g, "host", topt->oplist, "localhost");
|
||||||
user= GetListOption(g, "user", topt->oplist,
|
user= GetListOption(g, "user", topt->oplist,
|
||||||
(ttp == TAB_ODBC ? NULL : "root"));
|
((ttp == TAB_ODBC || ttp == TAB_JDBC) ? NULL : "root"));
|
||||||
// Default value db can come from the DBNAME=xxx option.
|
// Default value db can come from the DBNAME=xxx option.
|
||||||
db= GetListOption(g, "database", topt->oplist, db);
|
db= GetListOption(g, "database", topt->oplist, db);
|
||||||
col= GetListOption(g, "colist", topt->oplist, col);
|
col= GetListOption(g, "colist", topt->oplist, col);
|
||||||
@@ -5329,22 +5395,26 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
#endif // ZIP_SUPPORT
|
#endif // ZIP_SUPPORT
|
||||||
} else {
|
} else {
|
||||||
host= "localhost";
|
host= "localhost";
|
||||||
user= (ttp == TAB_ODBC ? NULL : "root");
|
user= ((ttp == TAB_ODBC || ttp == TAB_JDBC) ? NULL : "root");
|
||||||
} // endif option_list
|
} // endif option_list
|
||||||
|
|
||||||
if (!(shm= (char*)db))
|
if (!(shm= (char*)db))
|
||||||
db= table_s->db.str; // Default value
|
db= table_s->db.str; // Default value
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
try {
|
||||||
|
#else // !USE_TRY
|
||||||
// Save stack and allocation environment and prepare error return
|
// Save stack and allocation environment and prepare error return
|
||||||
if (g->jump_level == MAX_JUMP) {
|
if (g->jump_level == MAX_JUMP) {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
goto jer;
|
goto jer;
|
||||||
} // endif jump_level
|
} // endif jump_level
|
||||||
|
|
||||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
// Check table type
|
// Check table type
|
||||||
if (ttp == TAB_UNDEF) {
|
if (ttp == TAB_UNDEF) {
|
||||||
@@ -5354,7 +5424,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
|
||||||
} else if (ttp == TAB_NIY) {
|
} else if (ttp == TAB_NIY) {
|
||||||
sprintf(g->Message, "Unsupported table type %s", topt->type);
|
sprintf(g->Message, "Unsupported table type %s", topt->type);
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif ttp
|
} // endif ttp
|
||||||
|
|
||||||
@@ -5365,8 +5435,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
|
|
||||||
if (!tbl) {
|
if (!tbl) {
|
||||||
strcpy(g->Message, "Missing table list");
|
strcpy(g->Message, "Missing table list");
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif tbl
|
} // endif tbl
|
||||||
|
|
||||||
tab= PlugDup(g, tbl);
|
tab= PlugDup(g, tbl);
|
||||||
@@ -5558,320 +5628,320 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
if (src && fnc != FNC_NO) {
|
if (src && fnc != FNC_NO) {
|
||||||
strcpy(g->Message, "Cannot make catalog table from srcdef");
|
strcpy(g->Message, "Cannot make catalog table from srcdef");
|
||||||
ok= false;
|
ok= false;
|
||||||
} // endif src
|
} // endif src
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
char *cnm, *rem, *dft, *xtra, *key, *fmt;
|
char *cnm, *rem, *dft, *xtra, *key, *fmt;
|
||||||
int i, len, prec, dec, typ, flg;
|
int i, len, prec, dec, typ, flg;
|
||||||
|
|
||||||
// if (cat)
|
// if (cat)
|
||||||
// cat->SetDataPath(g, table_s->db.str);
|
// cat->SetDataPath(g, table_s->db.str);
|
||||||
// else
|
// else
|
||||||
// return HA_ERR_INTERNAL_ERROR; // Should never happen
|
// return HA_ERR_INTERNAL_ERROR; // Should never happen
|
||||||
|
|
||||||
dpath= SetPath(g, table_s->db.str);
|
dpath = SetPath(g, table_s->db.str);
|
||||||
|
|
||||||
if (src && ttp != TAB_PIVOT && ttp != TAB_ODBC && ttp != TAB_JDBC) {
|
if (src && ttp != TAB_PIVOT && ttp != TAB_ODBC && ttp != TAB_JDBC) {
|
||||||
qrp= SrcColumns(g, host, db, user, pwd, src, port);
|
qrp = SrcColumns(g, host, db, user, pwd, src, port);
|
||||||
|
|
||||||
if (qrp && ttp == TAB_OCCUR)
|
if (qrp && ttp == TAB_OCCUR)
|
||||||
if (OcrSrcCols(g, qrp, col, ocl, rnk)) {
|
if (OcrSrcCols(g, qrp, col, ocl, rnk)) {
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif OcrSrcCols
|
} // endif OcrSrcCols
|
||||||
|
|
||||||
} else switch (ttp) {
|
} else switch (ttp) {
|
||||||
case TAB_DBF:
|
case TAB_DBF:
|
||||||
qrp= DBFColumns(g, dpath, fn, fnc == FNC_COL);
|
qrp = DBFColumns(g, dpath, fn, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
#if defined(ODBC_SUPPORT)
|
#if defined(ODBC_SUPPORT)
|
||||||
case TAB_ODBC:
|
case TAB_ODBC:
|
||||||
switch (fnc) {
|
switch (fnc) {
|
||||||
case FNC_NO:
|
case FNC_NO:
|
||||||
case FNC_COL:
|
case FNC_COL:
|
||||||
if (src) {
|
if (src) {
|
||||||
qrp= ODBCSrcCols(g, dsn, (char*)src, sop);
|
qrp = ODBCSrcCols(g, dsn, (char*)src, sop);
|
||||||
src= NULL; // for next tests
|
src = NULL; // for next tests
|
||||||
} else
|
} else
|
||||||
qrp= ODBCColumns(g, dsn, shm, tab, NULL,
|
qrp = ODBCColumns(g, dsn, shm, tab, NULL,
|
||||||
mxr, fnc == FNC_COL, sop);
|
mxr, fnc == FNC_COL, sop);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FNC_TABLE:
|
case FNC_TABLE:
|
||||||
qrp= ODBCTables(g, dsn, shm, tab, NULL, mxr, true, sop);
|
qrp = ODBCTables(g, dsn, shm, tab, NULL, mxr, true, sop);
|
||||||
break;
|
break;
|
||||||
case FNC_DSN:
|
case FNC_DSN:
|
||||||
qrp= ODBCDataSources(g, mxr, true);
|
qrp = ODBCDataSources(g, mxr, true);
|
||||||
break;
|
break;
|
||||||
case FNC_DRIVER:
|
case FNC_DRIVER:
|
||||||
qrp= ODBCDrivers(g, mxr, true);
|
qrp = ODBCDrivers(g, mxr, true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, "invalid catfunc %s", fncn);
|
sprintf(g->Message, "invalid catfunc %s", fncn);
|
||||||
break;
|
break;
|
||||||
} // endswitch info
|
} // endswitch info
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#endif // ODBC_SUPPORT
|
#endif // ODBC_SUPPORT
|
||||||
#if defined(JDBC_SUPPORT)
|
#if defined(JDBC_SUPPORT)
|
||||||
case TAB_JDBC:
|
case TAB_JDBC:
|
||||||
switch (fnc) {
|
switch (fnc) {
|
||||||
case FNC_NO:
|
case FNC_NO:
|
||||||
case FNC_COL:
|
case FNC_COL:
|
||||||
if (src) {
|
if (src) {
|
||||||
qrp= JDBCSrcCols(g, (char*)src, sjp);
|
qrp = JDBCSrcCols(g, (char*)src, sjp);
|
||||||
src= NULL; // for next tests
|
src = NULL; // for next tests
|
||||||
} else
|
} else
|
||||||
qrp= JDBCColumns(g, shm, tab, NULL, mxr, fnc == FNC_COL, sjp);
|
qrp = JDBCColumns(g, shm, tab, NULL, mxr, fnc == FNC_COL, sjp);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FNC_TABLE:
|
case FNC_TABLE:
|
||||||
qrp= JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp);
|
qrp = JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp);
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
case FNC_DSN:
|
case FNC_DSN:
|
||||||
qrp= JDBCDataSources(g, mxr, true);
|
qrp = JDBCDataSources(g, mxr, true);
|
||||||
break;
|
break;
|
||||||
#endif // 0
|
#endif // 0
|
||||||
case FNC_DRIVER:
|
case FNC_DRIVER:
|
||||||
qrp= JDBCDrivers(g, mxr, true);
|
qrp = JDBCDrivers(g, mxr, true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, "invalid catfunc %s", fncn);
|
sprintf(g->Message, "invalid catfunc %s", fncn);
|
||||||
break;
|
break;
|
||||||
} // endswitch info
|
} // endswitch info
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#endif // JDBC_SUPPORT
|
#endif // JDBC_SUPPORT
|
||||||
case TAB_MYSQL:
|
case TAB_MYSQL:
|
||||||
qrp= MyColumns(g, thd, host, db, user, pwd, tab,
|
qrp = MyColumns(g, thd, host, db, user, pwd, tab,
|
||||||
NULL, port, fnc == FNC_COL);
|
NULL, port, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
case TAB_CSV:
|
case TAB_CSV:
|
||||||
qrp = CSVColumns(g, dpath, topt, fnc == FNC_COL);
|
qrp = CSVColumns(g, dpath, topt, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
#if defined(__WIN__)
|
#if defined(__WIN__)
|
||||||
case TAB_WMI:
|
case TAB_WMI:
|
||||||
qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL);
|
qrp = WMIColumns(g, nsp, cls, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
#endif // __WIN__
|
#endif // __WIN__
|
||||||
case TAB_PRX:
|
case TAB_PRX:
|
||||||
case TAB_TBL:
|
case TAB_TBL:
|
||||||
case TAB_XCL:
|
case TAB_XCL:
|
||||||
case TAB_OCCUR:
|
case TAB_OCCUR:
|
||||||
bif= fnc == FNC_COL;
|
bif = fnc == FNC_COL;
|
||||||
qrp= TabColumns(g, thd, db, tab, bif);
|
qrp = TabColumns(g, thd, db, tab, bif);
|
||||||
|
|
||||||
if (!qrp && bif && fnc != FNC_COL) // tab is a view
|
if (!qrp && bif && fnc != FNC_COL) // tab is a view
|
||||||
qrp= MyColumns(g, thd, host, db, user, pwd, tab, NULL, port, false);
|
qrp = MyColumns(g, thd, host, db, user, pwd, tab, NULL, port, false);
|
||||||
|
|
||||||
if (qrp && ttp == TAB_OCCUR && fnc != FNC_COL)
|
if (qrp && ttp == TAB_OCCUR && fnc != FNC_COL)
|
||||||
if (OcrColumns(g, qrp, col, ocl, rnk)) {
|
if (OcrColumns(g, qrp, col, ocl, rnk)) {
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif OcrColumns
|
} // endif OcrColumns
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#if defined(PIVOT_SUPPORT)
|
#if defined(PIVOT_SUPPORT)
|
||||||
case TAB_PIVOT:
|
case TAB_PIVOT:
|
||||||
qrp= PivotColumns(g, tab, src, pic, fcl, skc, host, db, user, pwd, port);
|
qrp = PivotColumns(g, tab, src, pic, fcl, skc, host, db, user, pwd, port);
|
||||||
break;
|
break;
|
||||||
#endif // PIVOT_SUPPORT
|
#endif // PIVOT_SUPPORT
|
||||||
case TAB_VIR:
|
case TAB_VIR:
|
||||||
qrp= VirColumns(g, fnc == FNC_COL);
|
qrp = VirColumns(g, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
case TAB_JSON:
|
case TAB_JSON:
|
||||||
qrp= JSONColumns(g, (char*)db, topt, fnc == FNC_COL);
|
qrp = JSONColumns(g, (char*)db, topt, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
#if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT)
|
#if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT)
|
||||||
case TAB_XML:
|
case TAB_XML:
|
||||||
qrp= XMLColumns(g, (char*)db, tab, topt, fnc == FNC_COL);
|
qrp = XMLColumns(g, (char*)db, tab, topt, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
#endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT
|
#endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT
|
||||||
case TAB_OEM:
|
case TAB_OEM:
|
||||||
qrp= OEMColumns(g, topt, tab, (char*)db, fnc == FNC_COL);
|
qrp = OEMColumns(g, topt, tab, (char*)db, fnc == FNC_COL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strcpy(g->Message, "System error during assisted discovery");
|
strcpy(g->Message, "System error during assisted discovery");
|
||||||
break;
|
break;
|
||||||
} // endswitch ttp
|
} // endswitch ttp
|
||||||
|
|
||||||
if (!qrp) {
|
if (!qrp) {
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif !qrp
|
} // endif !qrp
|
||||||
|
|
||||||
if (fnc != FNC_NO || src || ttp == TAB_PIVOT) {
|
if (fnc != FNC_NO || src || ttp == TAB_PIVOT) {
|
||||||
// Catalog like table
|
// Catalog like table
|
||||||
for (crp= qrp->Colresp; !rc && crp; crp= crp->Next) {
|
for (crp = qrp->Colresp; !rc && crp; crp = crp->Next) {
|
||||||
cnm= (ttp == TAB_PIVOT) ? crp->Name : encode(g, crp->Name);
|
cnm = (ttp == TAB_PIVOT) ? crp->Name : encode(g, crp->Name);
|
||||||
typ= crp->Type;
|
typ = crp->Type;
|
||||||
len= crp->Length;
|
len = crp->Length;
|
||||||
dec= crp->Prec;
|
dec = crp->Prec;
|
||||||
flg= crp->Flag;
|
flg = crp->Flag;
|
||||||
v= (crp->Kdata->IsUnsigned()) ? 'U' : crp->Var;
|
v = (crp->Kdata->IsUnsigned()) ? 'U' : crp->Var;
|
||||||
tm= (crp->Kdata->IsNullable()) ? 0 : NOT_NULL_FLAG;
|
tm = (crp->Kdata->IsNullable()) ? 0 : NOT_NULL_FLAG;
|
||||||
|
|
||||||
if (!len && typ == TYPE_STRING)
|
if (!len && typ == TYPE_STRING)
|
||||||
len= 256; // STRBLK's have 0 length
|
len = 256; // STRBLK's have 0 length
|
||||||
|
|
||||||
// Now add the field
|
// Now add the field
|
||||||
if (add_field(&sql, cnm, typ, len, dec, NULL, tm,
|
if (add_field(&sql, cnm, typ, len, dec, NULL, tm,
|
||||||
NULL, NULL, NULL, NULL, flg, dbf, v))
|
NULL, NULL, NULL, NULL, flg, dbf, v))
|
||||||
rc= HA_ERR_OUT_OF_MEM;
|
rc = HA_ERR_OUT_OF_MEM;
|
||||||
} // endfor crp
|
} // endfor crp
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
char *schem= NULL;
|
char *schem = NULL;
|
||||||
char *tn= NULL;
|
char *tn = NULL;
|
||||||
|
|
||||||
// Not a catalog table
|
// Not a catalog table
|
||||||
if (!qrp->Nblin) {
|
if (!qrp->Nblin) {
|
||||||
if (tab)
|
if (tab)
|
||||||
sprintf(g->Message, "Cannot get columns from %s", tab);
|
sprintf(g->Message, "Cannot get columns from %s", tab);
|
||||||
else
|
else
|
||||||
strcpy(g->Message, "Fail to retrieve columns");
|
strcpy(g->Message, "Fail to retrieve columns");
|
||||||
|
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif !nblin
|
} // endif !nblin
|
||||||
|
|
||||||
for (i= 0; !rc && i < qrp->Nblin; i++) {
|
for (i = 0; !rc && i < qrp->Nblin; i++) {
|
||||||
typ= len= prec= dec= 0;
|
typ = len = prec = dec = 0;
|
||||||
tm= NOT_NULL_FLAG;
|
tm = NOT_NULL_FLAG;
|
||||||
cnm= (char*)"noname";
|
cnm = (char*)"noname";
|
||||||
dft= xtra= key= fmt= tn= NULL;
|
dft = xtra = key = fmt = tn = NULL;
|
||||||
v= ' ';
|
v = ' ';
|
||||||
rem= NULL;
|
rem = NULL;
|
||||||
|
|
||||||
for (crp= qrp->Colresp; crp; crp= crp->Next)
|
for (crp = qrp->Colresp; crp; crp = crp->Next)
|
||||||
switch (crp->Fld) {
|
switch (crp->Fld) {
|
||||||
case FLD_NAME:
|
case FLD_NAME:
|
||||||
if (ttp == TAB_PRX ||
|
if (ttp == TAB_PRX ||
|
||||||
(ttp == TAB_CSV && topt->data_charset &&
|
(ttp == TAB_CSV && topt->data_charset &&
|
||||||
(!stricmp(topt->data_charset, "UTF8") ||
|
(!stricmp(topt->data_charset, "UTF8") ||
|
||||||
!stricmp(topt->data_charset, "UTF-8"))))
|
!stricmp(topt->data_charset, "UTF-8"))))
|
||||||
cnm= crp->Kdata->GetCharValue(i);
|
cnm = crp->Kdata->GetCharValue(i);
|
||||||
else
|
else
|
||||||
cnm= encode(g, crp->Kdata->GetCharValue(i));
|
cnm = encode(g, crp->Kdata->GetCharValue(i));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FLD_TYPE:
|
case FLD_TYPE:
|
||||||
typ= crp->Kdata->GetIntValue(i);
|
typ = crp->Kdata->GetIntValue(i);
|
||||||
v = (crp->Nulls) ? crp->Nulls[i] : 0;
|
v = (crp->Nulls) ? crp->Nulls[i] : 0;
|
||||||
break;
|
break;
|
||||||
case FLD_TYPENAME:
|
case FLD_TYPENAME:
|
||||||
tn= crp->Kdata->GetCharValue(i);
|
tn = crp->Kdata->GetCharValue(i);
|
||||||
break;
|
break;
|
||||||
case FLD_PREC:
|
case FLD_PREC:
|
||||||
// PREC must be always before LENGTH
|
// PREC must be always before LENGTH
|
||||||
len= prec= crp->Kdata->GetIntValue(i);
|
len = prec = crp->Kdata->GetIntValue(i);
|
||||||
break;
|
break;
|
||||||
case FLD_LENGTH:
|
case FLD_LENGTH:
|
||||||
len= crp->Kdata->GetIntValue(i);
|
len = crp->Kdata->GetIntValue(i);
|
||||||
break;
|
break;
|
||||||
case FLD_SCALE:
|
case FLD_SCALE:
|
||||||
dec = (!crp->Kdata->IsNull(i)) ? crp->Kdata->GetIntValue(i) : -1;
|
dec = (!crp->Kdata->IsNull(i)) ? crp->Kdata->GetIntValue(i) : -1;
|
||||||
break;
|
break;
|
||||||
case FLD_NULL:
|
case FLD_NULL:
|
||||||
if (crp->Kdata->GetIntValue(i))
|
if (crp->Kdata->GetIntValue(i))
|
||||||
tm= 0; // Nullable
|
tm = 0; // Nullable
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FLD_FORMAT:
|
case FLD_FORMAT:
|
||||||
fmt= (crp->Kdata) ? crp->Kdata->GetCharValue(i) : NULL;
|
fmt = (crp->Kdata) ? crp->Kdata->GetCharValue(i) : NULL;
|
||||||
break;
|
break;
|
||||||
case FLD_REM:
|
case FLD_REM:
|
||||||
rem= crp->Kdata->GetCharValue(i);
|
rem = crp->Kdata->GetCharValue(i);
|
||||||
break;
|
break;
|
||||||
// case FLD_CHARSET:
|
// case FLD_CHARSET:
|
||||||
// No good because remote table is already translated
|
// No good because remote table is already translated
|
||||||
// if (*(csn= crp->Kdata->GetCharValue(i)))
|
// if (*(csn= crp->Kdata->GetCharValue(i)))
|
||||||
// cs= get_charset_by_name(csn, 0);
|
// cs= get_charset_by_name(csn, 0);
|
||||||
|
|
||||||
// break;
|
// break;
|
||||||
case FLD_DEFAULT:
|
case FLD_DEFAULT:
|
||||||
dft= crp->Kdata->GetCharValue(i);
|
dft = crp->Kdata->GetCharValue(i);
|
||||||
break;
|
break;
|
||||||
case FLD_EXTRA:
|
case FLD_EXTRA:
|
||||||
xtra= crp->Kdata->GetCharValue(i);
|
xtra = crp->Kdata->GetCharValue(i);
|
||||||
|
|
||||||
// Auto_increment is not supported yet
|
// Auto_increment is not supported yet
|
||||||
if (!stricmp(xtra, "AUTO_INCREMENT"))
|
if (!stricmp(xtra, "AUTO_INCREMENT"))
|
||||||
xtra= NULL;
|
xtra = NULL;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FLD_KEY:
|
case FLD_KEY:
|
||||||
if (ttp == TAB_VIR)
|
if (ttp == TAB_VIR)
|
||||||
key= crp->Kdata->GetCharValue(i);
|
key = crp->Kdata->GetCharValue(i);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FLD_SCHEM:
|
case FLD_SCHEM:
|
||||||
#if defined(ODBC_SUPPORT) || defined(JDBC_SUPPORT)
|
#if defined(ODBC_SUPPORT) || defined(JDBC_SUPPORT)
|
||||||
if ((ttp == TAB_ODBC || ttp == TAB_JDBC) && crp->Kdata) {
|
if ((ttp == TAB_ODBC || ttp == TAB_JDBC) && crp->Kdata) {
|
||||||
if (schem && stricmp(schem, crp->Kdata->GetCharValue(i))) {
|
if (schem && stricmp(schem, crp->Kdata->GetCharValue(i))) {
|
||||||
sprintf(g->Message,
|
sprintf(g->Message,
|
||||||
"Several %s tables found, specify DBNAME", tab);
|
"Several %s tables found, specify DBNAME", tab);
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
} else if (!schem)
|
} else if (!schem)
|
||||||
schem= crp->Kdata->GetCharValue(i);
|
schem = crp->Kdata->GetCharValue(i);
|
||||||
|
|
||||||
} // endif ttp
|
} // endif ttp
|
||||||
#endif // ODBC_SUPPORT || JDBC_SUPPORT
|
#endif // ODBC_SUPPORT || JDBC_SUPPORT
|
||||||
default:
|
default:
|
||||||
break; // Ignore
|
break; // Ignore
|
||||||
} // endswitch Fld
|
} // endswitch Fld
|
||||||
|
|
||||||
#if defined(ODBC_SUPPORT)
|
#if defined(ODBC_SUPPORT)
|
||||||
if (ttp == TAB_ODBC) {
|
if (ttp == TAB_ODBC) {
|
||||||
int plgtyp;
|
int plgtyp;
|
||||||
bool w= false; // Wide character type
|
bool w = false; // Wide character type
|
||||||
|
|
||||||
// typ must be PLG type, not SQL type
|
// typ must be PLG type, not SQL type
|
||||||
if (!(plgtyp= TranslateSQLType(typ, dec, prec, v, w))) {
|
if (!(plgtyp = TranslateSQLType(typ, dec, prec, v, w))) {
|
||||||
if (GetTypeConv() == TPC_SKIP) {
|
if (GetTypeConv() == TPC_SKIP) {
|
||||||
// Skip this column
|
// Skip this column
|
||||||
sprintf(g->Message, "Column %s skipped (unsupported type %d)",
|
sprintf(g->Message, "Column %s skipped (unsupported type %d)",
|
||||||
cnm, typ);
|
cnm, typ);
|
||||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
sprintf(g->Message, "Unsupported SQL type %d", typ);
|
sprintf(g->Message, "Unsupported SQL type %d", typ);
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif type_conv
|
} // endif type_conv
|
||||||
|
|
||||||
} else
|
} else
|
||||||
typ= plgtyp;
|
typ = plgtyp;
|
||||||
|
|
||||||
switch (typ) {
|
switch (typ) {
|
||||||
case TYPE_STRING:
|
case TYPE_STRING:
|
||||||
if (w) {
|
if (w) {
|
||||||
sprintf(g->Message, "Column %s is wide characters", cnm);
|
sprintf(g->Message, "Column %s is wide characters", cnm);
|
||||||
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message);
|
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message);
|
||||||
} // endif w
|
} // endif w
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case TYPE_DOUBLE:
|
case TYPE_DOUBLE:
|
||||||
// Some data sources do not count dec in length (prec)
|
// Some data sources do not count dec in length (prec)
|
||||||
prec += (dec + 2); // To be safe
|
prec += (dec + 2); // To be safe
|
||||||
break;
|
break;
|
||||||
case TYPE_DECIM:
|
case TYPE_DECIM:
|
||||||
prec= len;
|
prec = len;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dec= 0;
|
dec = 0;
|
||||||
} // endswitch typ
|
} // endswitch typ
|
||||||
|
|
||||||
} else
|
} else
|
||||||
#endif // ODBC_SUPPORT
|
#endif // ODBC_SUPPORT
|
||||||
#if defined(JDBC_SUPPORT)
|
#if defined(JDBC_SUPPORT)
|
||||||
if (ttp == TAB_JDBC) {
|
if (ttp == TAB_JDBC) {
|
||||||
int plgtyp;
|
int plgtyp;
|
||||||
|
|
||||||
// typ must be PLG type, not SQL type
|
// typ must be PLG type, not SQL type
|
||||||
if (!(plgtyp= TranslateJDBCType(typ, tn, dec, prec, v))) {
|
if (!(plgtyp = TranslateJDBCType(typ, tn, dec, prec, v))) {
|
||||||
if (GetTypeConv() == TPC_SKIP) {
|
if (GetTypeConv() == TPC_SKIP) {
|
||||||
// Skip this column
|
// Skip this column
|
||||||
sprintf(g->Message, "Column %s skipped (unsupported type %d)",
|
sprintf(g->Message, "Column %s skipped (unsupported type %d)",
|
||||||
@@ -5880,55 +5950,73 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
sprintf(g->Message, "Unsupported SQL type %d", typ);
|
sprintf(g->Message, "Unsupported SQL type %d", typ);
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif type_conv
|
} // endif type_conv
|
||||||
|
|
||||||
} else
|
} else
|
||||||
typ= plgtyp;
|
typ = plgtyp;
|
||||||
|
|
||||||
switch (typ) {
|
switch (typ) {
|
||||||
case TYPE_DOUBLE:
|
case TYPE_DOUBLE:
|
||||||
case TYPE_DECIM:
|
case TYPE_DECIM:
|
||||||
// Some data sources do not count dec in length (prec)
|
// Some data sources do not count dec in length (prec)
|
||||||
prec += (dec + 2); // To be safe
|
prec += (dec + 2); // To be safe
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dec= 0;
|
dec = 0;
|
||||||
} // endswitch typ
|
} // endswitch typ
|
||||||
|
|
||||||
} else
|
} else
|
||||||
#endif // ODBC_SUPPORT
|
#endif // ODBC_SUPPORT
|
||||||
// Make the arguments as required by add_fields
|
// Make the arguments as required by add_fields
|
||||||
if (typ == TYPE_DOUBLE)
|
if (typ == TYPE_DOUBLE)
|
||||||
prec= len;
|
prec = len;
|
||||||
|
|
||||||
if (typ == TYPE_DATE)
|
if (typ == TYPE_DATE)
|
||||||
prec= 0;
|
prec = 0;
|
||||||
|
|
||||||
// Now add the field
|
// Now add the field
|
||||||
if (add_field(&sql, cnm, typ, prec, dec, key, tm, rem, dft, xtra,
|
if (add_field(&sql, cnm, typ, prec, dec, key, tm, rem, dft, xtra,
|
||||||
fmt, 0, dbf, v))
|
fmt, 0, dbf, v))
|
||||||
rc= HA_ERR_OUT_OF_MEM;
|
rc = HA_ERR_OUT_OF_MEM;
|
||||||
} // endfor i
|
} // endfor i
|
||||||
|
|
||||||
} // endif fnc
|
} // endif fnc
|
||||||
|
|
||||||
if (!rc)
|
if (!rc)
|
||||||
rc= init_table_share(thd, table_s, create_info, &sql);
|
rc = init_table_share(thd, table_s, create_info, &sql);
|
||||||
|
|
||||||
g->jump_level--;
|
//g->jump_level--;
|
||||||
PopUser(xp);
|
//PopUser(xp);
|
||||||
return rc;
|
//return rc;
|
||||||
} // endif ok
|
} else {
|
||||||
|
rc = HA_ERR_UNSUPPORTED;
|
||||||
|
} // endif ok
|
||||||
|
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
#if defined(USE_TRY)
|
||||||
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
rc = HA_ERR_INTERNAL_ERROR;
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
err:
|
||||||
|
#else // !USE_TRY
|
||||||
err:
|
err:
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
if (rc)
|
||||||
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||||
|
|
||||||
|
#if !defined(USE_TRY)
|
||||||
jer:
|
jer:
|
||||||
|
#endif // !USE_TRY
|
||||||
PopUser(xp);
|
PopUser(xp);
|
||||||
return HA_ERR_INTERNAL_ERROR;
|
return rc;
|
||||||
} // end of connect_assisted_discovery
|
} // end of connect_assisted_discovery
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1200,7 +1200,11 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
|||||||
if (rank == 0)
|
if (rank == 0)
|
||||||
if (!name || (jn = env->NewStringUTF(name)) == nullptr) {
|
if (!name || (jn = env->NewStringUTF(name)) == nullptr) {
|
||||||
sprintf(g->Message, "Fail to allocate jstring %s", SVP(name));
|
sprintf(g->Message, "Fail to allocate jstring %s", SVP(name));
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_AM_JDBC;
|
||||||
|
#else // !USE_TRY
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
||||||
|
#endif // !USE_TRY
|
||||||
} // endif name
|
} // endif name
|
||||||
|
|
||||||
// Returns 666 is case of error
|
// Returns 666 is case of error
|
||||||
@@ -1208,7 +1212,11 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
|||||||
|
|
||||||
if (Check((ctyp == 666) ? -1 : 1)) {
|
if (Check((ctyp == 666) ? -1 : 1)) {
|
||||||
sprintf(g->Message, "Getting ctyp: %s", Msg);
|
sprintf(g->Message, "Getting ctyp: %s", Msg);
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_AM_JDBC;
|
||||||
|
#else // !USE_TRY
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
||||||
|
#endif // !USE_TRY
|
||||||
} // endif Check
|
} // endif Check
|
||||||
|
|
||||||
if (val->GetNullable())
|
if (val->GetNullable())
|
||||||
@@ -1314,7 +1322,11 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
|||||||
env->DeleteLocalRef(jn);
|
env->DeleteLocalRef(jn);
|
||||||
|
|
||||||
sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp);
|
sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp);
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_AM_JDBC;
|
||||||
|
#else // !USE_TRY
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
||||||
|
#endif // !USE_TRY
|
||||||
} // endif Check
|
} // endif Check
|
||||||
|
|
||||||
if (rank == 0)
|
if (rank == 0)
|
||||||
|
@@ -60,7 +60,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e);
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
||||||
{
|
{
|
||||||
int i, rc, pretty = (ptyp) ? *ptyp : 3;
|
int i, pretty = (ptyp) ? *ptyp : 3;
|
||||||
bool b = false, pty[3] = {true, true, true};
|
bool b = false, pty[3] = {true, true, true};
|
||||||
PJSON jsp = NULL;
|
PJSON jsp = NULL;
|
||||||
STRG src;
|
STRG src;
|
||||||
@@ -82,36 +82,40 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
|||||||
pty[0] = false;
|
pty[0] = false;
|
||||||
|
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return NULL;
|
// Save stack and allocation environment and prepare error return
|
||||||
} // endif jump_level
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return NULL;
|
||||||
|
} // endif jump_level
|
||||||
|
|
||||||
#if defined(SE_CATCH)
|
#if defined(SE_CATCH)
|
||||||
// Let's try to recover from any kind of interrupt
|
// Let's try to recover from any kind of interrupt
|
||||||
_se_translator_function f = _set_se_translator(trans_func);
|
_se_translator_function f = _set_se_translator(trans_func);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
#endif // SE_CATCH --------------------- try section --------------------
|
#endif // SE_CATCH --------------------- try section --------------------
|
||||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
if (setjmp(g->jumper[++g->jump_level])) {
|
||||||
goto err;
|
goto fin;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
|
||||||
#if defined(SE_CATCH) // ------------- end of try section -----------------
|
#if defined(SE_CATCH) // ------------- end of try section -----------------
|
||||||
} catch (SE_Exception e) {
|
} catch (SE_Exception e) {
|
||||||
sprintf(g->Message, "ParseJson: exception doing setjmp: %s (rc=%hd)",
|
sprintf(g->Message, "ParseJson: exception doing setjmp: %s (rc=%hd)",
|
||||||
GetExceptionDesc(g, e.nSE), e.nSE);
|
GetExceptionDesc(g, e.nSE), e.nSE);
|
||||||
_set_se_translator(f);
|
|
||||||
goto err;
|
|
||||||
} catch (...) {
|
|
||||||
strcpy(g->Message, "Exception doing setjmp");
|
|
||||||
_set_se_translator(f);
|
|
||||||
goto err;
|
|
||||||
} // end of try-catches
|
|
||||||
|
|
||||||
_set_se_translator(f);
|
_set_se_translator(f);
|
||||||
|
goto err;
|
||||||
|
} catch (...) {
|
||||||
|
strcpy(g->Message, "Exception doing setjmp");
|
||||||
|
_set_se_translator(f);
|
||||||
|
goto err;
|
||||||
|
} // end of try-catches
|
||||||
|
|
||||||
|
_set_se_translator(f);
|
||||||
#endif // SE_CATCH
|
#endif // SE_CATCH
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
switch (s[i]) {
|
switch (s[i]) {
|
||||||
@@ -119,14 +123,22 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
|||||||
if (jsp)
|
if (jsp)
|
||||||
goto tryit;
|
goto tryit;
|
||||||
else if (!(jsp = ParseArray(g, ++i, src, pty)))
|
else if (!(jsp = ParseArray(g, ++i, src, pty)))
|
||||||
goto err;
|
#if defined(USE_TRY)
|
||||||
|
throw 1;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto fin;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case '{':
|
case '{':
|
||||||
if (jsp)
|
if (jsp)
|
||||||
goto tryit;
|
goto tryit;
|
||||||
else if (!(jsp = ParseObject(g, ++i, src, pty)))
|
else if (!(jsp = ParseObject(g, ++i, src, pty)))
|
||||||
goto err;
|
#if defined(USE_TRY)
|
||||||
|
throw 2;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto fin;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
@@ -144,7 +156,12 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
|||||||
} // endif pretty
|
} // endif pretty
|
||||||
|
|
||||||
sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty);
|
sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty);
|
||||||
goto err;
|
#if defined(USE_TRY)
|
||||||
|
throw 3;
|
||||||
|
#else // !USE_TRY
|
||||||
|
jsp = NULL;
|
||||||
|
goto fin;
|
||||||
|
#endif // !USE_TRY
|
||||||
case '(':
|
case '(':
|
||||||
b = true;
|
b = true;
|
||||||
break;
|
break;
|
||||||
@@ -158,7 +175,11 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
|||||||
if (jsp)
|
if (jsp)
|
||||||
goto tryit;
|
goto tryit;
|
||||||
else if (!(jsp = ParseValue(g, i, src, pty)))
|
else if (!(jsp = ParseValue(g, i, src, pty)))
|
||||||
goto err;
|
#if defined(USE_TRY)
|
||||||
|
throw 4;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto fin;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}; // endswitch s[i]
|
}; // endswitch s[i]
|
||||||
@@ -176,22 +197,36 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
|||||||
|
|
||||||
} // endif ptyp
|
} // endif ptyp
|
||||||
|
|
||||||
g->jump_level--;
|
#if defined(USE_TRY)
|
||||||
return jsp;
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
jsp = NULL;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
jsp = NULL;
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
return jsp;
|
||||||
|
#else // !USE_TRY
|
||||||
|
fin:
|
||||||
|
g->jump_level--;
|
||||||
|
return jsp;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
tryit:
|
tryit:
|
||||||
if (pty[0] && (!pretty || pretty > 2)) {
|
if (pty[0] && (!pretty || pretty > 2)) {
|
||||||
if ((jsp = ParseArray(g, (i = 0), src, pty)) && ptyp && pretty == 3)
|
if ((jsp = ParseArray(g, (i = 0), src, pty)) && ptyp && pretty == 3)
|
||||||
*ptyp = (pty[0]) ? 0 : 3;
|
*ptyp = (pty[0]) ? 0 : 3;
|
||||||
|
|
||||||
|
#if !defined(USE_TRY)
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
return jsp;
|
return jsp;
|
||||||
} else
|
} else
|
||||||
strcpy(g->Message, "More than one item in file");
|
strcpy(g->Message, "More than one item in file");
|
||||||
|
|
||||||
err:
|
return NULL;
|
||||||
g->jump_level--;
|
|
||||||
return NULL;
|
|
||||||
} // end of ParseJson
|
} // end of ParseJson
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -591,6 +626,9 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
|||||||
|
|
||||||
g->Message[0] = 0;
|
g->Message[0] = 0;
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
try {
|
||||||
|
#else // !USE_TRY
|
||||||
// Save stack and allocation environment and prepare error return
|
// Save stack and allocation environment and prepare error return
|
||||||
if (g->jump_level == MAX_JUMP) {
|
if (g->jump_level == MAX_JUMP) {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
@@ -601,11 +639,16 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
|||||||
str = NULL;
|
str = NULL;
|
||||||
goto fin;
|
goto fin;
|
||||||
} // endif jmp
|
} // endif jmp
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (!jsp) {
|
if (!jsp) {
|
||||||
strcpy(g->Message, "Null json tree");
|
strcpy(g->Message, "Null json tree");
|
||||||
goto fin;
|
#if defined(USE_TRY)
|
||||||
} else if (!fn) {
|
throw 1;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto fin;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (!fn) {
|
||||||
// Serialize to a string
|
// Serialize to a string
|
||||||
jp = new(g) JOUTSTR(g);
|
jp = new(g) JOUTSTR(g);
|
||||||
b = pretty == 1;
|
b = pretty == 1;
|
||||||
@@ -614,7 +657,11 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
|||||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||||
"w", (int)errno, fn);
|
"w", (int)errno, fn);
|
||||||
strcat(strcat(g->Message, ": "), strerror(errno));
|
strcat(strcat(g->Message, ": "), strerror(errno));
|
||||||
goto fin;;
|
#if defined(USE_TRY)
|
||||||
|
throw 2;
|
||||||
|
#else // !USE_TRY
|
||||||
|
goto fin;
|
||||||
|
#endif // !USE_TRY
|
||||||
} else if (pretty >= 2) {
|
} else if (pretty >= 2) {
|
||||||
// Serialize to a pretty file
|
// Serialize to a pretty file
|
||||||
jp = new(g)JOUTPRT(g, fs);
|
jp = new(g)JOUTPRT(g, fs);
|
||||||
@@ -655,8 +702,19 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
|||||||
|
|
||||||
} // endif's
|
} // endif's
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
str = NULL;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
str = NULL;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
fin:
|
fin:
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
return str;
|
return str;
|
||||||
} // end of Serialize
|
} // end of Serialize
|
||||||
|
|
||||||
|
@@ -1104,7 +1104,7 @@ static my_bool JsonInit(UDF_INIT *initid, UDF_ARGS *args,
|
|||||||
} // endif g
|
} // endif g
|
||||||
|
|
||||||
g->Mrr = (args->arg_count && args->args[0]) ? 1 : 0;
|
g->Mrr = (args->arg_count && args->args[0]) ? 1 : 0;
|
||||||
g->ActivityStart = (PACTIVITY)more;
|
g->More = more;
|
||||||
initid->maybe_null = mbn;
|
initid->maybe_null = mbn;
|
||||||
initid->max_length = reslen;
|
initid->max_length = reslen;
|
||||||
initid->ptr = (char*)g;
|
initid->ptr = (char*)g;
|
||||||
@@ -1449,7 +1449,7 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
|
|||||||
|
|
||||||
} // endif b
|
} // endif b
|
||||||
|
|
||||||
ml += (unsigned long)g->ActivityStart; // more
|
ml += g->More;
|
||||||
|
|
||||||
if (ml > g->Sarea_Size) {
|
if (ml > g->Sarea_Size) {
|
||||||
free(g->Sarea);
|
free(g->Sarea);
|
||||||
@@ -2914,7 +2914,6 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
unsigned long *res_length, char *is_null, char *)
|
unsigned long *res_length, char *is_null, char *)
|
||||||
{
|
{
|
||||||
char *p, *path, *str = NULL;
|
char *p, *path, *str = NULL;
|
||||||
int rc;
|
|
||||||
PJSON jsp;
|
PJSON jsp;
|
||||||
PJSNX jsx;
|
PJSNX jsx;
|
||||||
PJVAL jvp;
|
PJVAL jvp;
|
||||||
@@ -2926,6 +2925,9 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} else if (initid->const_item)
|
} else if (initid->const_item)
|
||||||
g->N = 1;
|
g->N = 1;
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
try {
|
||||||
|
#else // !USE_TRY
|
||||||
// Save stack and allocation environment and prepare error return
|
// Save stack and allocation environment and prepare error return
|
||||||
if (g->jump_level == MAX_JUMP) {
|
if (g->jump_level == MAX_JUMP) {
|
||||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||||
@@ -2933,11 +2935,12 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
return NULL;
|
return NULL;
|
||||||
} // endif jump_level
|
} // endif jump_level
|
||||||
|
|
||||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
if (setjmp(g->jumper[++g->jump_level])) {
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
str = NULL;
|
str = NULL;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
if (CheckMemory(g, initid, args, 1, true)) {
|
if (CheckMemory(g, initid, args, 1, true)) {
|
||||||
@@ -2980,8 +2983,23 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Activityp = (PACTIVITY)str;
|
g->Activityp = (PACTIVITY)str;
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
PUSH_WARNING(g->Message);
|
||||||
|
str = NULL;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
PUSH_WARNING(g->Message);
|
||||||
|
str = NULL;
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
err:
|
||||||
|
#else // !USE_TRY
|
||||||
err:
|
err:
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
fin:
|
fin:
|
||||||
if (!str) {
|
if (!str) {
|
||||||
@@ -3254,7 +3272,7 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
{
|
{
|
||||||
char *p, *path = NULL;
|
char *p, *path = NULL;
|
||||||
int k, rc;
|
int k;
|
||||||
PJVAL jvp, jvp2;
|
PJVAL jvp, jvp2;
|
||||||
PJSON jsp;
|
PJSON jsp;
|
||||||
PJSNX jsx;
|
PJSNX jsx;
|
||||||
@@ -3274,6 +3292,9 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} else if (initid->const_item)
|
} else if (initid->const_item)
|
||||||
g->N = 1;
|
g->N = 1;
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
try {
|
||||||
|
#else // !USE_TRY
|
||||||
// Save stack and allocation environment and prepare error return
|
// Save stack and allocation environment and prepare error return
|
||||||
if (g->jump_level == MAX_JUMP) {
|
if (g->jump_level == MAX_JUMP) {
|
||||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||||
@@ -3282,12 +3303,13 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
return NULL;
|
return NULL;
|
||||||
} // endif jump_level
|
} // endif jump_level
|
||||||
|
|
||||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
if (setjmp(g->jumper[++g->jump_level])) {
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
*error = 1;
|
*error = 1;
|
||||||
path = NULL;
|
path = NULL;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
if (CheckMemory(g, initid, args, 1, !g->Xchk)) {
|
if (CheckMemory(g, initid, args, 1, !g->Xchk)) {
|
||||||
@@ -3326,8 +3348,25 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Activityp = (PACTIVITY)path;
|
g->Activityp = (PACTIVITY)path;
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
PUSH_WARNING(g->Message);
|
||||||
|
*error = 1;
|
||||||
|
path = NULL;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
PUSH_WARNING(g->Message);
|
||||||
|
*error = 1;
|
||||||
|
path = NULL;
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
err:
|
||||||
|
#else // !USE_TRY
|
||||||
err:
|
err:
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (!path) {
|
if (!path) {
|
||||||
*res_length = 0;
|
*res_length = 0;
|
||||||
@@ -3379,7 +3418,7 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
{
|
{
|
||||||
char *p, *path = NULL;
|
char *p, *path = NULL;
|
||||||
int rc, mx = 10;
|
int mx = 10;
|
||||||
PJVAL jvp, jvp2;
|
PJVAL jvp, jvp2;
|
||||||
PJSON jsp;
|
PJSON jsp;
|
||||||
PJSNX jsx;
|
PJSNX jsx;
|
||||||
@@ -3400,6 +3439,9 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
} else if (initid->const_item)
|
} else if (initid->const_item)
|
||||||
g->N = 1;
|
g->N = 1;
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
try {
|
||||||
|
#else // !USE_TRY
|
||||||
// Save stack and allocation environment and prepare error return
|
// Save stack and allocation environment and prepare error return
|
||||||
if (g->jump_level == MAX_JUMP) {
|
if (g->jump_level == MAX_JUMP) {
|
||||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||||
@@ -3408,12 +3450,13 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
return NULL;
|
return NULL;
|
||||||
} // endif jump_level
|
} // endif jump_level
|
||||||
|
|
||||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
if (setjmp(g->jumper[++g->jump_level])) {
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
*error = 1;
|
*error = 1;
|
||||||
path = NULL;
|
path = NULL;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
if (CheckMemory(g, initid, args, 1, true)) {
|
if (CheckMemory(g, initid, args, 1, true)) {
|
||||||
@@ -3453,8 +3496,25 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Activityp = (PACTIVITY)path;
|
g->Activityp = (PACTIVITY)path;
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
PUSH_WARNING(g->Message);
|
||||||
|
*error = 1;
|
||||||
|
path = NULL;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
PUSH_WARNING(g->Message);
|
||||||
|
*error = 1;
|
||||||
|
path = NULL;
|
||||||
|
} // end catch
|
||||||
|
|
||||||
|
err:
|
||||||
|
#else // !USE_TRY
|
||||||
err:
|
err:
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (!path) {
|
if (!path) {
|
||||||
*res_length = 0;
|
*res_length = 0;
|
||||||
@@ -3637,7 +3697,7 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
unsigned long *res_length, char *is_null, char *error)
|
unsigned long *res_length, char *is_null, char *error)
|
||||||
{
|
{
|
||||||
char *p, *path, *str = NULL;
|
char *p, *path, *str = NULL;
|
||||||
int w, rc;
|
int w;
|
||||||
my_bool b = true;
|
my_bool b = true;
|
||||||
PJSON jsp;
|
PJSON jsp;
|
||||||
PJSNX jsx;
|
PJSNX jsx;
|
||||||
@@ -3659,33 +3719,45 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
w = 2;
|
w = 2;
|
||||||
else {
|
else {
|
||||||
PUSH_WARNING("Logical error, please contact CONNECT developer");
|
PUSH_WARNING("Logical error, please contact CONNECT developer");
|
||||||
goto err;
|
goto fin;
|
||||||
} // endelse
|
} // endelse
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
#if defined(USE_TRY)
|
||||||
|
try {
|
||||||
|
#else // !USE_TRY
|
||||||
|
// Save stack and allocation environment and prepare error return
|
||||||
if (g->jump_level == MAX_JUMP) {
|
if (g->jump_level == MAX_JUMP) {
|
||||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||||
*error = 1;
|
*error = 1;
|
||||||
goto fin;
|
goto fin;
|
||||||
} // endif jump_level
|
} // endif jump_level
|
||||||
|
|
||||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
if (setjmp(g->jumper[++g->jump_level])) {
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
str = NULL;
|
str = NULL;
|
||||||
goto err;
|
goto err;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (!g->Xchk) {
|
if (!g->Xchk) {
|
||||||
if (CheckMemory(g, initid, args, 1, true, false, true)) {
|
if (CheckMemory(g, initid, args, 1, true, false, true)) {
|
||||||
PUSH_WARNING("CheckMemory error");
|
PUSH_WARNING("CheckMemory error");
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
throw 1;
|
||||||
|
#else // !USE_TRY
|
||||||
goto err;
|
goto err;
|
||||||
|
#endif // !USE_TRY
|
||||||
} else
|
} else
|
||||||
jvp = MakeValue(g, args, 0);
|
jvp = MakeValue(g, args, 0);
|
||||||
|
|
||||||
if ((p = jvp->GetString())) {
|
if ((p = jvp->GetString())) {
|
||||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
throw 2;
|
||||||
|
#else // !USE_TRY
|
||||||
PUSH_WARNING(g->Message);
|
PUSH_WARNING(g->Message);
|
||||||
goto err;
|
goto err;
|
||||||
|
#endif // !USE_TRY
|
||||||
} // endif jsp
|
} // endif jsp
|
||||||
|
|
||||||
} else
|
} else
|
||||||
@@ -3729,8 +3801,21 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||||||
// Keep result of constant function
|
// Keep result of constant function
|
||||||
g->Activityp = (PACTIVITY)str;
|
g->Activityp = (PACTIVITY)str;
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
PUSH_WARNING(g->Message);
|
||||||
|
str = NULL;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
PUSH_WARNING(g->Message);
|
||||||
|
str = NULL;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
err:
|
err:
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
fin:
|
fin:
|
||||||
if (!str) {
|
if (!str) {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************ Odbconn C++ Functions Source Code File (.CPP) ************/
|
/***********************************************************************/
|
||||||
/* Name: ODBCONN.CPP Version 2.2 */
|
/* Name: ODBCONN.CPP Version 2.3 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
|
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the ODBC connection classes functions. */
|
/* This file contains the ODBC connection classes functions. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -249,17 +249,21 @@ static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db,
|
|||||||
assert(qrp);
|
assert(qrp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return NULL;
|
// Save stack and allocation environment and prepare error return
|
||||||
} // endif jump_level
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return NULL;
|
||||||
|
} // endif jump_level
|
||||||
|
|
||||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||||
printf("%s\n", g->Message);
|
printf("%s\n", g->Message);
|
||||||
cap = NULL;
|
cap = NULL;
|
||||||
goto fin;
|
goto fin;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
m = (size_t)qrp->Maxres;
|
m = (size_t)qrp->Maxres;
|
||||||
n = (size_t)qrp->Nbcol;
|
n = (size_t)qrp->Nbcol;
|
||||||
@@ -276,9 +280,20 @@ static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db,
|
|||||||
|
|
||||||
cap->Status = (UWORD *)PlugSubAlloc(g, NULL, m * sizeof(UWORD));
|
cap->Status = (UWORD *)PlugSubAlloc(g, NULL, m * sizeof(UWORD));
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
} catch (int n) {
|
||||||
|
htrc("Exeption %d: %s\n", n, g->Message);
|
||||||
|
cap = NULL;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
htrc(g->Message, msg);
|
||||||
|
printf("%s\n", g->Message);
|
||||||
|
cap = NULL;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
fin:
|
fin:
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
return cap;
|
#endif // !USE_TRY
|
||||||
|
return cap;
|
||||||
} // end of AllocCatInfo
|
} // end of AllocCatInfo
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@@ -43,34 +43,6 @@ PSZ strlwr(PSZ p)
|
|||||||
return (p);
|
return (p);
|
||||||
} /* end of strlwr */
|
} /* end of strlwr */
|
||||||
|
|
||||||
#if defined(NOT_USED) /*&& !defined(sun) && !defined(LINUX) && !defined(AIX)*/
|
|
||||||
/***********************************************************************/
|
|
||||||
/* Define stricmp function not existing in some UNIX libraries. */
|
|
||||||
/***********************************************************************/
|
|
||||||
int stricmp(char *str1, char *str2)
|
|
||||||
{
|
|
||||||
register int i;
|
|
||||||
int n;
|
|
||||||
char c;
|
|
||||||
char *sup1 = malloc(strlen(str1) + 1);
|
|
||||||
char *sup2 = malloc(strlen(str2) + 1);
|
|
||||||
|
|
||||||
for (i = 0; c = str1[i]; i++)
|
|
||||||
sup1[i] = toupper(c);
|
|
||||||
|
|
||||||
sup1[i] = 0;
|
|
||||||
|
|
||||||
for (i = 0; c = str2[i]; i++)
|
|
||||||
sup2[i] = toupper(c);
|
|
||||||
|
|
||||||
sup2[i] = 0;
|
|
||||||
n = strcmp(sup1, sup2);
|
|
||||||
free(sup1);
|
|
||||||
free(sup2);
|
|
||||||
return (n);
|
|
||||||
} /* end of stricmp */
|
|
||||||
#endif /* sun */
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Define the splitpath function not existing in the UNIX library. */
|
/* Define the splitpath function not existing in the UNIX library. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -143,13 +115,6 @@ my_bool CloseFileHandle(HANDLE h)
|
|||||||
return (close(h)) ? TRUE : FALSE;
|
return (close(h)) ? TRUE : FALSE;
|
||||||
} /* end of CloseFileHandle */
|
} /* end of CloseFileHandle */
|
||||||
|
|
||||||
#if 0
|
|
||||||
void Sleep(DWORD time)
|
|
||||||
{
|
|
||||||
//FIXME: TODO
|
|
||||||
} /* end of Sleep */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int GetLastError()
|
int GetLastError()
|
||||||
{
|
{
|
||||||
return errno;
|
return errno;
|
||||||
@@ -210,21 +175,4 @@ BOOL MessageBeep(uint i __attribute__((unused)))
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
} /* end of MessageBeep */
|
} /* end of MessageBeep */
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* This function is ridiculous and should be revisited */
|
|
||||||
DWORD FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId,
|
|
||||||
DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, ...)
|
|
||||||
{
|
|
||||||
char buff[32];
|
|
||||||
int n;
|
|
||||||
|
|
||||||
//if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER)
|
|
||||||
// return 0; /* means error */
|
|
||||||
|
|
||||||
n = sprintf(buff, "Error code: %d", (int) dwMessageId);
|
|
||||||
strncpy(lpBuffer, buff, nSize);
|
|
||||||
return min(n, nSize);
|
|
||||||
} /* end of FormatMessage */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // UNIX
|
#endif // UNIX
|
||||||
|
@@ -244,17 +244,21 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
|
|||||||
PCOLRES *pcrp, crp;
|
PCOLRES *pcrp, crp;
|
||||||
PQRYRES qrp;
|
PQRYRES qrp;
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return NULL;
|
// Save stack and allocation environment and prepare error return
|
||||||
} // endif jump_level
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return NULL;
|
||||||
|
} // endif jump_level
|
||||||
|
|
||||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||||
printf("%s\n", g->Message);
|
printf("%s\n", g->Message);
|
||||||
qrp = NULL;
|
qrp = NULL;
|
||||||
goto fin;
|
goto fin;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Allocate the structure used to contain the result set. */
|
/* Allocate the structure used to contain the result set. */
|
||||||
@@ -316,9 +320,20 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
|
|||||||
|
|
||||||
*pcrp = NULL;
|
*pcrp = NULL;
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
} catch (int n) {
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
qrp = NULL;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
htrc("%s\n", g->Message);
|
||||||
|
qrp = NULL;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
fin:
|
fin:
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
return qrp;
|
#endif // !USE_TRY
|
||||||
|
return qrp;
|
||||||
} // end of PlgAllocResult
|
} // end of PlgAllocResult
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -365,8 +380,12 @@ PCATLG PlgGetCatalog(PGLOBAL g, bool jump)
|
|||||||
if (!cat && jump) {
|
if (!cat && jump) {
|
||||||
// Raise exception so caller doesn't have to check return value
|
// Raise exception so caller doesn't have to check return value
|
||||||
strcpy(g->Message, MSG(NO_ACTIVE_DB));
|
strcpy(g->Message, MSG(NO_ACTIVE_DB));
|
||||||
longjmp(g->jumper[g->jump_level], 1);
|
#if defined(USE_TRY)
|
||||||
} // endif cat
|
throw 1;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 1);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif cat
|
||||||
|
|
||||||
return cat;
|
return cat;
|
||||||
} // end of PlgGetCatalog
|
} // end of PlgGetCatalog
|
||||||
@@ -476,8 +495,12 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
|
|||||||
tp = g->Message;
|
tp = g->Message;
|
||||||
else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) {
|
else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) {
|
||||||
strcpy(g->Message, MSG(NEW_RETURN_NULL));
|
strcpy(g->Message, MSG(NEW_RETURN_NULL));
|
||||||
longjmp(g->jumper[g->jump_level], OP_LIKE);
|
#if defined(USE_TRY)
|
||||||
} /* endif tp */
|
throw OP_LIKE;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], OP_LIKE);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} /* endif tp */
|
||||||
|
|
||||||
sp = tp + strlen(pat) + 1;
|
sp = tp + strlen(pat) + 1;
|
||||||
strlwr(strcpy(tp, pat)); /* Make a lower case copy of pat */
|
strlwr(strcpy(tp, pat)); /* Make a lower case copy of pat */
|
||||||
@@ -487,8 +510,12 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
|
|||||||
tp = g->Message; /* Use this as temporary work space. */
|
tp = g->Message; /* Use this as temporary work space. */
|
||||||
else if (!(tp = new char[strlen(pat) + 1])) {
|
else if (!(tp = new char[strlen(pat) + 1])) {
|
||||||
strcpy(g->Message, MSG(NEW_RETURN_NULL));
|
strcpy(g->Message, MSG(NEW_RETURN_NULL));
|
||||||
longjmp(g->jumper[g->jump_level], OP_LIKE);
|
#if defined(USE_TRY)
|
||||||
} /* endif tp */
|
throw OP_LIKE;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], OP_LIKE);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} /* endif tp */
|
||||||
|
|
||||||
strcpy(tp, pat); /* Make a copy to be worked into */
|
strcpy(tp, pat); /* Make a copy to be worked into */
|
||||||
sp = (char*)strg;
|
sp = (char*)strg;
|
||||||
@@ -1520,8 +1547,12 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv)
|
|||||||
PGLOBAL g = t->G;
|
PGLOBAL g = t->G;
|
||||||
|
|
||||||
sprintf(g->Message, "NewPointer: %s", MSG(MEM_ALLOC_ERROR));
|
sprintf(g->Message, "NewPointer: %s", MSG(MEM_ALLOC_ERROR));
|
||||||
longjmp(g->jumper[g->jump_level], 3);
|
#if defined(USE_TRY)
|
||||||
} else {
|
throw 3;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 3);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else {
|
||||||
tp->Next = t->P1;
|
tp->Next = t->P1;
|
||||||
tp->Num = 0;
|
tp->Num = 0;
|
||||||
t->P1 = tp;
|
t->P1 = tp;
|
||||||
@@ -1557,15 +1588,23 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
|
|||||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||||
"rb", (int)errno, fn[i]);
|
"rb", (int)errno, fn[i]);
|
||||||
strcat(strcat(g->Message, ": "), strerror(errno));
|
strcat(strcat(g->Message, ": "), strerror(errno));
|
||||||
longjmp(g->jumper[g->jump_level], 666);
|
#if defined(USE_TRY)
|
||||||
// } else
|
throw 666;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 666);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
// } else
|
||||||
// len[i] = 0; // File does not exist yet
|
// len[i] = 0; // File does not exist yet
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ((len[i] = _filelength(h[i])) < 0) {
|
if ((len[i] = _filelength(h[i])) < 0) {
|
||||||
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", fn[i]);
|
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", fn[i]);
|
||||||
longjmp(g->jumper[g->jump_level], 666);
|
#if defined(USE_TRY)
|
||||||
} // endif len
|
throw 666;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 666);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif len
|
||||||
|
|
||||||
} // endif h
|
} // endif h
|
||||||
|
|
||||||
|
@@ -139,7 +139,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
|
|||||||
htrc("PlugInit: Language='%s'\n",
|
htrc("PlugInit: Language='%s'\n",
|
||||||
((!Language) ? "Null" : (char*)Language));
|
((!Language) ? "Null" : (char*)Language));
|
||||||
|
|
||||||
if (!(g = malloc(sizeof(GLOBAL)))) {
|
if (!(g = (PGLOBAL)malloc(sizeof(GLOBAL)))) {
|
||||||
fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL));
|
fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL));
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
@@ -147,9 +147,10 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
|
|||||||
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 = NULL;
|
||||||
g->Xchk = NULL;
|
g->Xchk = NULL;
|
||||||
g->N = 0;
|
g->N = 0;
|
||||||
|
g->More = 0;
|
||||||
strcpy(g->Message, "");
|
strcpy(g->Message, "");
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
@@ -475,7 +476,7 @@ void *PlugAllocMem(PGLOBAL g, uint size)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
BOOL PlugSubSet(PGLOBAL g __attribute__((unused)), void *memp, uint size)
|
BOOL PlugSubSet(PGLOBAL g __attribute__((unused)), void *memp, uint size)
|
||||||
{
|
{
|
||||||
PPOOLHEADER pph = memp;
|
PPOOLHEADER pph = (PPOOLHEADER)memp;
|
||||||
|
|
||||||
pph->To_Free = (OFFSET)sizeof(POOLHEADER);
|
pph->To_Free = (OFFSET)sizeof(POOLHEADER);
|
||||||
pph->FreeBlk = size - pph->To_Free;
|
pph->FreeBlk = size - pph->To_Free;
|
||||||
@@ -501,7 +502,6 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
|
|||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
memp = g->Sarea;
|
memp = g->Sarea;
|
||||||
|
|
||||||
//size = ((size + 3) / 4) * 4; /* Round up size to multiple of 4 */
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -514,22 +514,26 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
|
|||||||
|
|
||||||
sprintf(g->Message,
|
sprintf(g->Message,
|
||||||
"Not enough memory in %s area for request of %u (used=%d free=%d)",
|
"Not enough memory in %s area for request of %u (used=%d free=%d)",
|
||||||
pname, (uint) size, pph->To_Free, pph->FreeBlk);
|
pname, (uint)size, pph->To_Free, pph->FreeBlk);
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
htrc("PlugSubAlloc: %s\n", g->Message);
|
htrc("PlugSubAlloc: %s\n", g->Message);
|
||||||
|
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
throw 1234;
|
||||||
|
#else // !USE_TRY
|
||||||
/* Nothing we can do if longjmp is not initialized. */
|
/* Nothing we can do if longjmp is not initialized. */
|
||||||
assert(g->jump_level >= 0);
|
assert(g->jump_level >= 0);
|
||||||
longjmp(g->jumper[g->jump_level], 1);
|
longjmp(g->jumper[g->jump_level], 1);
|
||||||
|
#endif // !USE_TRY
|
||||||
} /* endif size OS32 code */
|
} /* endif size OS32 code */
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Do the suballocation the simplest way. */
|
/* Do the suballocation the simplest way. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
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 += (OFFSET)size; /* New offset of pool free block */
|
||||||
pph->FreeBlk -= size; /* New size of pool free block */
|
pph->FreeBlk -= (uint)size; /* New size of pool free block */
|
||||||
|
|
||||||
if (trace > 3)
|
if (trace > 3)
|
||||||
htrc("Done memp=%p used=%d free=%d\n",
|
htrc("Done memp=%p used=%d free=%d\n",
|
@@ -1,11 +1,11 @@
|
|||||||
/************* TabDos C++ Program Source Code File (.CPP) **************/
|
/************* TabDos C++ Program Source Code File (.CPP) **************/
|
||||||
/* PROGRAM NAME: TABDOS */
|
/* PROGRAM NAME: TABDOS */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 4.9.2 */
|
/* Version 4.9.3 */
|
||||||
/* */
|
/* */
|
||||||
/* COPYRIGHT: */
|
/* COPYRIGHT: */
|
||||||
/* ---------- */
|
/* ---------- */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
|
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* WHAT THIS PROGRAM DOES: */
|
/* WHAT THIS PROGRAM DOES: */
|
||||||
/* ----------------------- */
|
/* ----------------------- */
|
||||||
@@ -1509,8 +1509,12 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv)
|
|||||||
if (n == 8 && ctype != TYPE_LIST) {
|
if (n == 8 && ctype != TYPE_LIST) {
|
||||||
// Should never happen
|
// Should never happen
|
||||||
strcpy(g->Message, "Block opt: bad constant");
|
strcpy(g->Message, "Block opt: bad constant");
|
||||||
longjmp(g->jumper[g->jump_level], 99);
|
#if defined(USE_TRY)
|
||||||
} // endif Conv
|
throw 99;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 99);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Conv
|
||||||
|
|
||||||
if (type[0] == 1) {
|
if (type[0] == 1) {
|
||||||
// Make it always as Column-op-Value
|
// Make it always as Column-op-Value
|
||||||
@@ -1791,7 +1795,7 @@ err:
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
||||||
{
|
{
|
||||||
int k, rc;
|
int k;
|
||||||
volatile bool dynamic;
|
volatile bool dynamic;
|
||||||
bool brc;
|
bool brc;
|
||||||
PCOL colp;
|
PCOL colp;
|
||||||
@@ -1861,13 +1865,17 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
|||||||
} else // Column contains same values as ROWID
|
} else // Column contains same values as ROWID
|
||||||
kxp = new(g) XXROW(this);
|
kxp = new(g) XXROW(this);
|
||||||
|
|
||||||
// Prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return true;
|
// Prepare error return
|
||||||
} // endif
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return true;
|
||||||
|
} // endif
|
||||||
|
|
||||||
if (!(rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
if (!setjmp(g->jumper[++g->jump_level])) {
|
||||||
|
#endif // !USE_TRY
|
||||||
if (dynamic) {
|
if (dynamic) {
|
||||||
ResetBlockFilter(g);
|
ResetBlockFilter(g);
|
||||||
kxp->SetDynamic(dynamic);
|
kxp->SetDynamic(dynamic);
|
||||||
@@ -1892,11 +1900,22 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
|||||||
|
|
||||||
} // endif brc
|
} // endif brc
|
||||||
|
|
||||||
} else
|
#if defined(USE_TRY)
|
||||||
brc = true;
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
brc = true;
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
brc = true;
|
||||||
|
} // end catch
|
||||||
|
#else // !USE_TRY
|
||||||
|
} else
|
||||||
|
brc = true;
|
||||||
|
|
||||||
g->jump_level--;
|
g->jump_level--;
|
||||||
return brc;
|
#endif // !USE_TRY
|
||||||
|
return brc;
|
||||||
} // end of InitialyzeIndex
|
} // end of InitialyzeIndex
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -2156,16 +2175,18 @@ bool TDBDOS::OpenDB(PGLOBAL g)
|
|||||||
To_BlkFil = InitBlockFilter(g, To_Filter);
|
To_BlkFil = InitBlockFilter(g, To_Filter);
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Allocate the line buffer plus a null character. */
|
/* Lrecl does not include line ending */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
To_Line = (char*)PlugSubAlloc(g, NULL, Lrecl + 1);
|
size_t linelen = Lrecl + ((PDOSDEF)To_Def)->Ending + 1;
|
||||||
|
|
||||||
|
To_Line = (char*)PlugSubAlloc(g, NULL, linelen);
|
||||||
|
|
||||||
if (Mode == MODE_INSERT) {
|
if (Mode == MODE_INSERT) {
|
||||||
// Spaces between fields must be filled with blanks
|
// Spaces between fields must be filled with blanks
|
||||||
memset(To_Line, ' ', Lrecl);
|
memset(To_Line, ' ', Lrecl);
|
||||||
To_Line[Lrecl] = '\0';
|
To_Line[Lrecl] = '\0';
|
||||||
} else
|
} else
|
||||||
memset(To_Line, 0, Lrecl + 1);
|
memset(To_Line, 0, linelen);
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
htrc("OpenDos: R%hd mode=%d To_Line=%p\n", Tdb_No, Mode, To_Line);
|
htrc("OpenDos: R%hd mode=%d To_Line=%p\n", Tdb_No, Mode, To_Line);
|
||||||
@@ -2514,8 +2535,12 @@ void DOSCOL::ReadColumn(PGLOBAL g)
|
|||||||
if (rc == RC_EF)
|
if (rc == RC_EF)
|
||||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||||
|
|
||||||
longjmp(g->jumper[g->jump_level], 11);
|
#if defined(USE_TRY)
|
||||||
} // endif
|
throw 11;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 11);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif
|
||||||
|
|
||||||
p = tdbp->To_Line + Deplac;
|
p = tdbp->To_Line + Deplac;
|
||||||
field = Long;
|
field = Long;
|
||||||
@@ -2570,8 +2595,12 @@ void DOSCOL::ReadColumn(PGLOBAL g)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, MSG(BAD_RECFM), tdbp->Ftype);
|
sprintf(g->Message, MSG(BAD_RECFM), tdbp->Ftype);
|
||||||
longjmp(g->jumper[g->jump_level], 34);
|
#if defined(USE_TRY)
|
||||||
} // endswitch Ftype
|
throw 34;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 34);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endswitch Ftype
|
||||||
|
|
||||||
// Set null when applicable
|
// Set null when applicable
|
||||||
if (Nullable)
|
if (Nullable)
|
||||||
@@ -2679,8 +2708,12 @@ void DOSCOL::WriteColumn(PGLOBAL g)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, "Invalid field format for column %s", Name);
|
sprintf(g->Message, "Invalid field format for column %s", Name);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} // endswitch BufType
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endswitch BufType
|
||||||
|
|
||||||
p2 = Buf;
|
p2 = Buf;
|
||||||
} else // Standard CONNECT format
|
} else // Standard CONNECT format
|
||||||
@@ -2691,8 +2724,12 @@ void DOSCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if ((len = strlen(p2)) > field) {
|
if ((len = strlen(p2)) > field) {
|
||||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p2, Name, field);
|
sprintf(g->Message, MSG(VALUE_TOO_LONG), p2, Name, field);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} else if (Dsp)
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (Dsp)
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
if (p2[i] == '.')
|
if (p2[i] == '.')
|
||||||
p2[i] = Dsp;
|
p2[i] = Dsp;
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
/************* TabFix C++ Program Source Code File (.CPP) **************/
|
/************* TabFix C++ Program Source Code File (.CPP) **************/
|
||||||
/* PROGRAM NAME: TABFIX */
|
/* PROGRAM NAME: TABFIX */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 4.9.1 */
|
/* Version 4.9.2 */
|
||||||
/* */
|
/* */
|
||||||
/* COPYRIGHT: */
|
/* COPYRIGHT: */
|
||||||
/* ---------- */
|
/* ---------- */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
|
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* WHAT THIS PROGRAM DOES: */
|
/* WHAT THIS PROGRAM DOES: */
|
||||||
/* ----------------------- */
|
/* ----------------------- */
|
||||||
@@ -411,8 +411,12 @@ BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
|
|||||||
case 'D': M = sizeof(double); break;
|
case 'D': M = sizeof(double); break;
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||||
longjmp(g->jumper[g->jump_level], 11);
|
#if defined(USE_TRY)
|
||||||
} // endswitch Fmt
|
throw 11;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 11);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endswitch Fmt
|
||||||
|
|
||||||
} else if (IsTypeChar(Buf_Type))
|
} else if (IsTypeChar(Buf_Type))
|
||||||
Eds = 0;
|
Eds = 0;
|
||||||
@@ -486,8 +490,12 @@ void BINCOL::ReadColumn(PGLOBAL g)
|
|||||||
if (rc == RC_EF)
|
if (rc == RC_EF)
|
||||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||||
|
|
||||||
longjmp(g->jumper[g->jump_level], 11);
|
#if defined(USE_TRY)
|
||||||
} // endif
|
throw 11;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 11);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif
|
||||||
|
|
||||||
p = tdbp->To_Line + Deplac;
|
p = tdbp->To_Line + Deplac;
|
||||||
|
|
||||||
@@ -545,8 +553,12 @@ void BINCOL::ReadColumn(PGLOBAL g)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||||
longjmp(g->jumper[g->jump_level], 11);
|
#if defined(USE_TRY)
|
||||||
} // endswitch Fmt
|
throw 11;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 11);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endswitch Fmt
|
||||||
|
|
||||||
// Set null when applicable
|
// Set null when applicable
|
||||||
if (Nullable)
|
if (Nullable)
|
||||||
@@ -595,8 +607,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||||||
} else if (Value->GetBinValue(p, Long, Status)) {
|
} else if (Value->GetBinValue(p, Long, Status)) {
|
||||||
sprintf(g->Message, MSG(BIN_F_TOO_LONG),
|
sprintf(g->Message, MSG(BIN_F_TOO_LONG),
|
||||||
Name, Value->GetSize(), Long);
|
Name, Value->GetSize(), Long);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} // endif p
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif p
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'S': // Short integer
|
case 'S': // Short integer
|
||||||
@@ -604,8 +620,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (n > 32767LL || n < -32768LL) {
|
if (n > 32767LL || n < -32768LL) {
|
||||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} else if (Status)
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (Status)
|
||||||
Value->GetValueNonAligned<short>(p, (short)n);
|
Value->GetValueNonAligned<short>(p, (short)n);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -614,8 +634,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (n > 255LL || n < -256LL) {
|
if (n > 255LL || n < -256LL) {
|
||||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} else if (Status)
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (Status)
|
||||||
*p = (char)n;
|
*p = (char)n;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -624,8 +648,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (n > INT_MAX || n < INT_MIN) {
|
if (n > INT_MAX || n < INT_MIN) {
|
||||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} else if (Status)
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (Status)
|
||||||
Value->GetValueNonAligned<int>(p, (int)n);
|
Value->GetValueNonAligned<int>(p, (int)n);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -648,8 +676,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||||||
case 'C': // Characters
|
case 'C': // Characters
|
||||||
if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) {
|
if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) {
|
||||||
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long);
|
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} // endif n
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif n
|
||||||
|
|
||||||
if (Status) {
|
if (Status) {
|
||||||
s = Value->GetCharString(Buf);
|
s = Value->GetCharString(Buf);
|
||||||
@@ -660,8 +692,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||||
longjmp(g->jumper[g->jump_level], 11);
|
#if defined(USE_TRY)
|
||||||
} // endswitch Fmt
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endswitch Fmt
|
||||||
|
|
||||||
if (Eds && Status) {
|
if (Eds && Status) {
|
||||||
p = tdbp->To_Line + Deplac;
|
p = tdbp->To_Line + Deplac;
|
||||||
|
@@ -1435,8 +1435,12 @@ void CSVCOL::ReadColumn(PGLOBAL g)
|
|||||||
if (rc == RC_EF)
|
if (rc == RC_EF)
|
||||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||||
|
|
||||||
longjmp(g->jumper[g->jump_level], 34);
|
#if defined(USE_TRY)
|
||||||
} // endif
|
throw 34;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 34);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif
|
||||||
|
|
||||||
if (tdbp->Mode != MODE_UPDATE) {
|
if (tdbp->Mode != MODE_UPDATE) {
|
||||||
int colen = Long; // Column length
|
int colen = Long; // Column length
|
||||||
@@ -1453,8 +1457,12 @@ void CSVCOL::ReadColumn(PGLOBAL g)
|
|||||||
Long = colen; // Restore column length
|
Long = colen; // Restore column length
|
||||||
sprintf(g->Message, MSG(FLD_TOO_LNG_FOR),
|
sprintf(g->Message, MSG(FLD_TOO_LNG_FOR),
|
||||||
Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g));
|
Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g));
|
||||||
longjmp(g->jumper[g->jump_level], 34);
|
#if defined(USE_TRY)
|
||||||
} // endif Long
|
throw 34;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 34);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Long
|
||||||
|
|
||||||
// Now do the reading
|
// Now do the reading
|
||||||
DOSCOL::ReadColumn(g);
|
DOSCOL::ReadColumn(g);
|
||||||
@@ -1516,8 +1524,12 @@ void CSVCOL::WriteColumn(PGLOBAL g)
|
|||||||
if ((signed)strlen(p) > flen) {
|
if ((signed)strlen(p) > flen) {
|
||||||
sprintf(g->Message, MSG(BAD_FLD_LENGTH), Name, p, flen,
|
sprintf(g->Message, MSG(BAD_FLD_LENGTH), Name, p, flen,
|
||||||
tdbp->RowNumber(g), tdbp->GetFile(g));
|
tdbp->RowNumber(g), tdbp->GetFile(g));
|
||||||
longjmp(g->jumper[g->jump_level], 34);
|
#if defined(USE_TRY)
|
||||||
} else if (Dsp)
|
throw 34;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 34);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (Dsp)
|
||||||
for (int i = 0; p[i]; i++)
|
for (int i = 0; p[i]; i++)
|
||||||
if (p[i] == '.')
|
if (p[i] == '.')
|
||||||
p[i] = Dsp;
|
p[i] = Dsp;
|
||||||
@@ -1532,8 +1544,12 @@ void CSVCOL::WriteColumn(PGLOBAL g)
|
|||||||
if (Fldnum < 0) {
|
if (Fldnum < 0) {
|
||||||
// This can happen for wrong offset value in XDB files
|
// This can happen for wrong offset value in XDB files
|
||||||
sprintf(g->Message, MSG(BAD_FIELD_RANK), Fldnum + 1, Name);
|
sprintf(g->Message, MSG(BAD_FIELD_RANK), Fldnum + 1, Name);
|
||||||
longjmp(g->jumper[g->jump_level], 34);
|
#if defined(USE_TRY)
|
||||||
} else
|
throw 34;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 34);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else
|
||||||
strncpy(tdbp->Field[Fldnum], p, flen);
|
strncpy(tdbp->Field[Fldnum], p, flen);
|
||||||
|
|
||||||
if (trace > 1)
|
if (trace > 1)
|
||||||
|
@@ -227,41 +227,8 @@ bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
|||||||
|
|
||||||
if (rc == RC_FX) // Error
|
if (rc == RC_FX) // Error
|
||||||
return true;
|
return true;
|
||||||
//else if (rc == RC_OK) { // Url was not a server name
|
|
||||||
// Tabname = GetStringCatInfo(g, "Name",
|
|
||||||
// (Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
|
||||||
// Tabname = GetStringCatInfo(g, "Tabname", Tabname);
|
|
||||||
// Username = GetStringCatInfo(g, "User", NULL);
|
|
||||||
// Password = GetStringCatInfo(g, "Password", NULL);
|
|
||||||
//} // endif rc
|
|
||||||
|
|
||||||
//if ((Srcdef = GetStringCatInfo(g, "Srcdef", NULL)))
|
|
||||||
// Read_Only = true;
|
|
||||||
|
|
||||||
Wrapname = GetStringCatInfo(g, "Wrapper", NULL);
|
Wrapname = GetStringCatInfo(g, "Wrapper", NULL);
|
||||||
//Prop = GetStringCatInfo(g, "Properties", NULL);
|
|
||||||
//Tabcat = GetStringCatInfo(g, "Qualifier", NULL);
|
|
||||||
//Tabcat = GetStringCatInfo(g, "Catalog", Tabcat);
|
|
||||||
//Tabschema = GetStringCatInfo(g, "Dbname", NULL);
|
|
||||||
//Tabschema = GetStringCatInfo(g, "Schema", Tabschema);
|
|
||||||
|
|
||||||
//if (Catfunc == FNC_COL)
|
|
||||||
// Colpat = GetStringCatInfo(g, "Colpat", NULL);
|
|
||||||
|
|
||||||
//if (Catfunc == FNC_TABLE)
|
|
||||||
// Tabtyp = GetStringCatInfo(g, "Tabtype", NULL);
|
|
||||||
|
|
||||||
//Qrystr = GetStringCatInfo(g, "Query_String", "?");
|
|
||||||
//Sep = GetStringCatInfo(g, "Separator", NULL);
|
|
||||||
//Xsrc = GetBoolCatInfo("Execsrc", FALSE);
|
|
||||||
//Maxerr = GetIntCatInfo("Maxerr", 0);
|
|
||||||
//Maxres = GetIntCatInfo("Maxres", 0);
|
|
||||||
//Quoted = GetIntCatInfo("Quoted", 0);
|
|
||||||
// Cto= GetIntCatInfo("ConnectTimeout", DEFAULT_LOGIN_TIMEOUT);
|
|
||||||
// Qto= GetIntCatInfo("QueryTimeout", DEFAULT_QUERY_TIMEOUT);
|
|
||||||
//Scrollable = GetBoolCatInfo("Scrollable", false);
|
|
||||||
//Memory = GetIntCatInfo("Memory", 0);
|
|
||||||
//Pseudo = 2; // FILID is Ok but not ROWID
|
|
||||||
return false;
|
return false;
|
||||||
} // end of DefineAM
|
} // end of DefineAM
|
||||||
|
|
||||||
@@ -341,9 +308,6 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBEXT(tdp)
|
|||||||
WrapName = tdp->Wrapname;
|
WrapName = tdp->Wrapname;
|
||||||
Ops.User = tdp->Username;
|
Ops.User = tdp->Username;
|
||||||
Ops.Pwd = tdp->Password;
|
Ops.Pwd = tdp->Password;
|
||||||
// Ops.Properties = tdp->Prop;
|
|
||||||
// Ops.Cto = tdp->Cto;
|
|
||||||
// Ops.Qto = tdp->Qto;
|
|
||||||
Ops.Scrollable = tdp->Scrollable;
|
Ops.Scrollable = tdp->Scrollable;
|
||||||
} else {
|
} else {
|
||||||
WrapName = NULL;
|
WrapName = NULL;
|
||||||
@@ -351,13 +315,9 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBEXT(tdp)
|
|||||||
Ops.Url = NULL;
|
Ops.Url = NULL;
|
||||||
Ops.User = NULL;
|
Ops.User = NULL;
|
||||||
Ops.Pwd = NULL;
|
Ops.Pwd = NULL;
|
||||||
// Ops.Properties = NULL;
|
|
||||||
// Ops.Cto = DEFAULT_LOGIN_TIMEOUT;
|
|
||||||
// Ops.Qto = DEFAULT_QUERY_TIMEOUT;
|
|
||||||
Ops.Scrollable = false;
|
Ops.Scrollable = false;
|
||||||
} // endif tdp
|
} // endif tdp
|
||||||
|
|
||||||
//Ncol = 0;
|
|
||||||
Prepared = false;
|
Prepared = false;
|
||||||
Werr = false;
|
Werr = false;
|
||||||
Rerr = false;
|
Rerr = false;
|
||||||
@@ -370,7 +330,6 @@ TDBJDBC::TDBJDBC(PTDBJDBC tdbp) : TDBEXT(tdbp)
|
|||||||
Cnp = tdbp->Cnp;
|
Cnp = tdbp->Cnp;
|
||||||
WrapName = tdbp->WrapName;
|
WrapName = tdbp->WrapName;
|
||||||
Ops = tdbp->Ops;
|
Ops = tdbp->Ops;
|
||||||
//Ncol = tdbp->Ncol;
|
|
||||||
Prepared = tdbp->Prepared;
|
Prepared = tdbp->Prepared;
|
||||||
Werr = tdbp->Werr;
|
Werr = tdbp->Werr;
|
||||||
Rerr = tdbp->Rerr;
|
Rerr = tdbp->Rerr;
|
||||||
@@ -737,18 +696,12 @@ bool TDBJDBC::SetRecpos(PGLOBAL g, int recpos)
|
|||||||
{
|
{
|
||||||
if (Jcp->m_Full) {
|
if (Jcp->m_Full) {
|
||||||
Fpos = 0;
|
Fpos = 0;
|
||||||
// CurNum = 0;
|
|
||||||
CurNum = 1;
|
CurNum = 1;
|
||||||
} else if (Memory == 3) {
|
} else if (Memory == 3) {
|
||||||
// Fpos = recpos;
|
|
||||||
// CurNum = -1;
|
|
||||||
Fpos = 0;
|
Fpos = 0;
|
||||||
CurNum = recpos;
|
CurNum = recpos;
|
||||||
} else if (Ops.Scrollable) {
|
} else if (Ops.Scrollable) {
|
||||||
// Is new position in the current row set?
|
// Is new position in the current row set?
|
||||||
// if (recpos >= Curpos && recpos < Curpos + Rbuf) {
|
|
||||||
// CurNum = recpos - Curpos;
|
|
||||||
// Fpos = 0;
|
|
||||||
if (recpos > 0 && recpos <= Rbuf) {
|
if (recpos > 0 && recpos <= Rbuf) {
|
||||||
CurNum = recpos;
|
CurNum = recpos;
|
||||||
Fpos = recpos;
|
Fpos = recpos;
|
||||||
@@ -990,11 +943,6 @@ int TDBJDBC::DeleteDB(PGLOBAL g, int irc)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void TDBJDBC::CloseDB(PGLOBAL g)
|
void TDBJDBC::CloseDB(PGLOBAL g)
|
||||||
{
|
{
|
||||||
//if (To_Kindex) {
|
|
||||||
// To_Kindex->Close();
|
|
||||||
// To_Kindex = NULL;
|
|
||||||
// } // endif
|
|
||||||
|
|
||||||
if (Jcp)
|
if (Jcp)
|
||||||
Jcp->Close();
|
Jcp->Close();
|
||||||
|
|
||||||
@@ -1039,54 +987,6 @@ JDBCCOL::JDBCCOL(JDBCCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp)
|
|||||||
{
|
{
|
||||||
} // end of JDBCCOL copy constructor
|
} // end of JDBCCOL copy constructor
|
||||||
|
|
||||||
#if 0
|
|
||||||
/***********************************************************************/
|
|
||||||
/* SetBuffer: prepare a column block for write operation. */
|
|
||||||
/***********************************************************************/
|
|
||||||
bool JDBCCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
|
|
||||||
{
|
|
||||||
if (!(To_Val = value)) {
|
|
||||||
sprintf(g->Message, MSG(VALUE_ERROR), Name);
|
|
||||||
return true;
|
|
||||||
} else if (Buf_Type == value->GetType()) {
|
|
||||||
// Values are of the (good) column type
|
|
||||||
if (Buf_Type == TYPE_DATE) {
|
|
||||||
// If any of the date values is formatted
|
|
||||||
// output format must be set for the receiving table
|
|
||||||
if (GetDomain() || ((DTVAL *)value)->IsFormatted())
|
|
||||||
goto newval; // This will make a new value;
|
|
||||||
|
|
||||||
} else if (Buf_Type == TYPE_DOUBLE)
|
|
||||||
// Float values must be written with the correct (column) precision
|
|
||||||
// Note: maybe this should be forced by ShowValue instead of this ?
|
|
||||||
value->SetPrec(GetScale());
|
|
||||||
|
|
||||||
Value = value; // Directly access the external value
|
|
||||||
} else {
|
|
||||||
// Values are not of the (good) column type
|
|
||||||
if (check) {
|
|
||||||
sprintf(g->Message, MSG(TYPE_VALUE_ERR), Name,
|
|
||||||
GetTypeName(Buf_Type), GetTypeName(value->GetType()));
|
|
||||||
return true;
|
|
||||||
} // endif check
|
|
||||||
|
|
||||||
newval:
|
|
||||||
if (InitValue(g)) // Allocate the matching value block
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} // endif's Value, Buf_Type
|
|
||||||
|
|
||||||
// Because Colblk's have been made from a copy of the original TDB in
|
|
||||||
// case of Update, we must reset them to point to the original one.
|
|
||||||
if (To_Tdb->GetOrig())
|
|
||||||
To_Tdb = (PTDB)To_Tdb->GetOrig();
|
|
||||||
|
|
||||||
// Set the Column
|
|
||||||
Status = (ok) ? BUF_EMPTY : BUF_NO;
|
|
||||||
return false;
|
|
||||||
} // end of SetBuffer
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* ReadColumn: when SQLFetch is used there is nothing to do as the */
|
/* ReadColumn: when SQLFetch is used there is nothing to do as the */
|
||||||
/* column buffer was bind to the record set. This is also the case */
|
/* column buffer was bind to the record set. This is also the case */
|
||||||
@@ -1196,26 +1096,6 @@ PCMD TDBXJDC::MakeCMD(PGLOBAL g)
|
|||||||
return xcmd;
|
return xcmd;
|
||||||
} // end of MakeCMD
|
} // end of MakeCMD
|
||||||
|
|
||||||
#if 0
|
|
||||||
/***********************************************************************/
|
|
||||||
/* JDBC Bind Parameter function. */
|
|
||||||
/***********************************************************************/
|
|
||||||
bool TDBXJDC::BindParameters(PGLOBAL g)
|
|
||||||
{
|
|
||||||
PJDBCCOL colp;
|
|
||||||
|
|
||||||
for (colp = (PJDBCCOL)Columns; colp; colp = (PJDBCCOL)colp->Next) {
|
|
||||||
colp->AllocateBuffers(g, 0);
|
|
||||||
|
|
||||||
if (Jcp->BindParam(colp))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} // endfor colp
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} // end of BindParameters
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* XDBC GetMaxSize: returns table size (not always one row). */
|
/* XDBC GetMaxSize: returns table size (not always one row). */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1416,17 +1296,3 @@ PQRYRES TDBJDBCL::GetResult(PGLOBAL g)
|
|||||||
{
|
{
|
||||||
return JDBCColumns(g, Schema, Tab, Colpat, Maxres, false, &Ops);
|
return JDBCColumns(g, Schema, Tab, Colpat, Maxres, false, &Ops);
|
||||||
} // end of GetResult
|
} // end of GetResult
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* ---------------------------TDBJSRC class -------------------------- */
|
|
||||||
|
|
||||||
/***********************************************************************/
|
|
||||||
/* GetResult: Get the list of JDBC data sources. */
|
|
||||||
/***********************************************************************/
|
|
||||||
PQRYRES TDBJSRC::GetResult(PGLOBAL g)
|
|
||||||
{
|
|
||||||
return JDBCDataSources(g, Maxres, false);
|
|
||||||
} // end of GetResult
|
|
||||||
|
|
||||||
/* ------------------------ End of TabJDBC --------------------------- */
|
|
||||||
#endif // 0
|
|
||||||
|
@@ -14,9 +14,6 @@ typedef class TDBJDBC *PTDBJDBC;
|
|||||||
typedef class JDBCCOL *PJDBCCOL;
|
typedef class JDBCCOL *PJDBCCOL;
|
||||||
typedef class TDBXJDC *PTDBXJDC;
|
typedef class TDBXJDC *PTDBXJDC;
|
||||||
typedef class JSRCCOL *PJSRCCOL;
|
typedef class JSRCCOL *PJSRCCOL;
|
||||||
//typedef class TDBOIF *PTDBOIF;
|
|
||||||
//typedef class OIFCOL *POIFCOL;
|
|
||||||
//typedef class TDBJSRC *PTDBJSRC;
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* JDBC table. */
|
/* JDBC table. */
|
||||||
@@ -68,20 +65,14 @@ public:
|
|||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual PTDB Clone(PTABS t);
|
virtual PTDB Clone(PTABS t);
|
||||||
//virtual int GetRecpos(void);
|
|
||||||
virtual bool SetRecpos(PGLOBAL g, int recpos);
|
virtual bool SetRecpos(PGLOBAL g, int recpos);
|
||||||
//virtual PSZ GetFile(PGLOBAL g);
|
|
||||||
//virtual void SetFile(PGLOBAL g, PSZ fn);
|
|
||||||
virtual void ResetSize(void);
|
virtual void ResetSize(void);
|
||||||
//virtual int GetAffectedRows(void) {return AftRows;}
|
|
||||||
virtual PSZ GetServer(void) { return "JDBC"; }
|
virtual PSZ GetServer(void) { return "JDBC"; }
|
||||||
virtual int Indexable(void) { return 2; }
|
virtual int Indexable(void) { return 2; }
|
||||||
|
|
||||||
// Database routines
|
// Database routines
|
||||||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
||||||
virtual int Cardinality(PGLOBAL g);
|
virtual int Cardinality(PGLOBAL g);
|
||||||
//virtual int GetMaxSize(PGLOBAL g);
|
|
||||||
//virtual int GetProgMax(PGLOBAL g);
|
|
||||||
virtual bool OpenDB(PGLOBAL g);
|
virtual bool OpenDB(PGLOBAL g);
|
||||||
virtual int ReadDB(PGLOBAL g);
|
virtual int ReadDB(PGLOBAL g);
|
||||||
virtual int WriteDB(PGLOBAL g);
|
virtual int WriteDB(PGLOBAL g);
|
||||||
@@ -91,21 +82,14 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Internal functions
|
// Internal functions
|
||||||
//int Decode(char *utf, char *buf, size_t n);
|
|
||||||
//bool MakeSQL(PGLOBAL g, bool cnt);
|
|
||||||
bool MakeInsert(PGLOBAL g);
|
bool MakeInsert(PGLOBAL g);
|
||||||
//virtual bool MakeCommand(PGLOBAL g);
|
|
||||||
//bool MakeFilter(PGLOBAL g, bool c);
|
|
||||||
bool SetParameters(PGLOBAL g);
|
bool SetParameters(PGLOBAL g);
|
||||||
//char *MakeUpdate(PGLOBAL g);
|
|
||||||
//char *MakeDelete(PGLOBAL g);
|
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
JDBConn *Jcp; // Points to a JDBC connection class
|
JDBConn *Jcp; // Points to a JDBC connection class
|
||||||
JDBCCOL *Cnp; // Points to count(*) column
|
JDBCCOL *Cnp; // Points to count(*) column
|
||||||
JDBCPARM Ops; // Additional parameters
|
JDBCPARM Ops; // Additional parameters
|
||||||
char *WrapName; // Points to Java wrapper name
|
char *WrapName; // Points to Java wrapper name
|
||||||
//int Ncol; // The column number
|
|
||||||
bool Prepared; // True when using prepared statement
|
bool Prepared; // True when using prepared statement
|
||||||
bool Werr; // Write error
|
bool Werr; // Write error
|
||||||
bool Rerr; // Rewind error
|
bool Rerr; // Rewind error
|
||||||
@@ -152,12 +136,6 @@ public:
|
|||||||
virtual AMT GetAmType(void) {return TYPE_AM_XDBC;}
|
virtual AMT GetAmType(void) {return TYPE_AM_XDBC;}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
//virtual int GetRecpos(void);
|
|
||||||
//virtual PSZ GetFile(PGLOBAL g);
|
|
||||||
//virtual void SetFile(PGLOBAL g, PSZ fn);
|
|
||||||
//virtual void ResetSize(void);
|
|
||||||
//virtual int GetAffectedRows(void) {return AftRows;}
|
|
||||||
//virtual PSZ GetServer(void) {return "JDBC";}
|
|
||||||
|
|
||||||
// Database routines
|
// Database routines
|
||||||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
||||||
@@ -172,7 +150,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
// Internal functions
|
// Internal functions
|
||||||
PCMD MakeCMD(PGLOBAL g);
|
PCMD MakeCMD(PGLOBAL g);
|
||||||
//bool BindParameters(PGLOBAL g);
|
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
PCMD Cmdlist; // The commands to execute
|
PCMD Cmdlist; // The commands to execute
|
||||||
@@ -255,21 +232,4 @@ protected:
|
|||||||
char *Colpat; // Points to catalog column pattern
|
char *Colpat; // Points to catalog column pattern
|
||||||
}; // end of class TDBJDBCL
|
}; // end of class TDBJDBCL
|
||||||
|
|
||||||
#if 0
|
|
||||||
/***********************************************************************/
|
|
||||||
/* This is the class declaration for the Data Sources catalog table. */
|
|
||||||
/***********************************************************************/
|
|
||||||
class TDBJSRC : public TDBJDRV {
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
TDBJSRC(PJDBCDEF tdp) : TDBJDRV(tdp) {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Specific routines
|
|
||||||
virtual PQRYRES GetResult(PGLOBAL g);
|
|
||||||
|
|
||||||
// No additional Members
|
|
||||||
}; // end of class TDBJSRC
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
#endif // !NJDBC
|
#endif // !NJDBC
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/************* tabjson C++ Program Source Code File (.CPP) *************/
|
/************* tabjson C++ Program Source Code File (.CPP) *************/
|
||||||
/* PROGRAM NAME: tabjson Version 1.3 */
|
/* PROGRAM NAME: tabjson Version 1.4 */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2016 */
|
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
|
||||||
/* This program are the JSON class DB execution routines. */
|
/* This program are the JSON class DB execution routines. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
|||||||
G->Sarea_Size = tdp->Lrecl * 10;
|
G->Sarea_Size = tdp->Lrecl * 10;
|
||||||
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
||||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||||
G->jump_level = -1;
|
G->jump_level = 0;
|
||||||
tjnp->SetG(G);
|
tjnp->SetG(G);
|
||||||
#else
|
#else
|
||||||
tjnp->SetG(g);
|
tjnp->SetG(g);
|
||||||
@@ -478,7 +478,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
|||||||
G->Sarea_Size = Lrecl * 10;
|
G->Sarea_Size = Lrecl * 10;
|
||||||
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
||||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||||
G->jump_level = -1;
|
G->jump_level = 0;
|
||||||
((TDBJSN*)tdbp)->G = G;
|
((TDBJSN*)tdbp)->G = G;
|
||||||
#else
|
#else
|
||||||
((TDBJSN*)tdbp)->G = g;
|
((TDBJSN*)tdbp)->G = g;
|
||||||
@@ -1289,8 +1289,12 @@ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n)
|
|||||||
|
|
||||||
if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) {
|
if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) {
|
||||||
strcpy(g->Message, "Logical error expanding array");
|
strcpy(g->Message, "Logical error expanding array");
|
||||||
longjmp(g->jumper[g->jump_level], 666);
|
#if defined(USE_TRY)
|
||||||
} // endif jvp
|
throw 666;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 666);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif jvp
|
||||||
|
|
||||||
if (n < Nod - 1 && jvp->GetJson()) {
|
if (n < Nod - 1 && jvp->GetJson()) {
|
||||||
jval.SetValue(GetColumnValue(g, jvp->GetJson(), n + 1));
|
jval.SetValue(GetColumnValue(g, jvp->GetJson(), n + 1));
|
||||||
@@ -1475,8 +1479,12 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
|||||||
{
|
{
|
||||||
if (Xpd && Tjp->Pretty < 2) {
|
if (Xpd && Tjp->Pretty < 2) {
|
||||||
strcpy(g->Message, "Cannot write expanded column when Pretty is not 2");
|
strcpy(g->Message, "Cannot write expanded column when Pretty is not 2");
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
throw 666;
|
||||||
|
#else // !USE_TRY
|
||||||
longjmp(g->jumper[g->jump_level], 666);
|
longjmp(g->jumper[g->jump_level], 666);
|
||||||
} // endif Xpd
|
#endif // !USE_TRY
|
||||||
|
} // endif Xpd
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Check whether this node must be written. */
|
/* Check whether this node must be written. */
|
||||||
@@ -1510,8 +1518,12 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (!(jsp = ParseJson(G, s, (int)strlen(s)))) {
|
if (!(jsp = ParseJson(G, s, (int)strlen(s)))) {
|
||||||
strcpy(g->Message, s);
|
strcpy(g->Message, s);
|
||||||
longjmp(g->jumper[g->jump_level], 666);
|
#if defined(USE_TRY)
|
||||||
} // endif jsp
|
throw 666;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 666);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif jsp
|
||||||
|
|
||||||
if (arp) {
|
if (arp) {
|
||||||
if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ)
|
if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ)
|
||||||
|
@@ -958,8 +958,12 @@ void DIRCOL::ReadColumn(PGLOBAL g)
|
|||||||
#endif // !__WIN__
|
#endif // !__WIN__
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, MSG(INV_DIRCOL_OFST), N);
|
sprintf(g->Message, MSG(INV_DIRCOL_OFST), N);
|
||||||
longjmp(g->jumper[g->jump_level], GetAmType());
|
#if defined(USE_TRY)
|
||||||
} // endswitch N
|
throw GetAmType();
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], GetAmType());
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endswitch N
|
||||||
|
|
||||||
} // end of ReadColumn
|
} // end of ReadColumn
|
||||||
|
|
||||||
@@ -1423,8 +1427,12 @@ void TDBDHR::CloseDB(PGLOBAL g)
|
|||||||
// Close the search handle.
|
// Close the search handle.
|
||||||
if (!FindClose(Hsearch)) {
|
if (!FindClose(Hsearch)) {
|
||||||
strcpy(g->Message, MSG(SRCH_CLOSE_ERR));
|
strcpy(g->Message, MSG(SRCH_CLOSE_ERR));
|
||||||
longjmp(g->jumper[g->jump_level], GetAmType());
|
#if defined(USE_TRY)
|
||||||
} // endif FindClose
|
throw GetAmType();
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], GetAmType());
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif FindClose
|
||||||
|
|
||||||
iFile = 0;
|
iFile = 0;
|
||||||
Hsearch = INVALID_HANDLE_VALUE;
|
Hsearch = INVALID_HANDLE_VALUE;
|
||||||
|
@@ -134,7 +134,7 @@ class TDBDIR : public TDBASE {
|
|||||||
int iFile; // Index of currently retrieved file
|
int iFile; // Index of currently retrieved file
|
||||||
#if defined(__WIN__)
|
#if defined(__WIN__)
|
||||||
_finddata_t FileData; // Find data structure
|
_finddata_t FileData; // Find data structure
|
||||||
int Hsearch; // Search handle
|
intptr_t Hsearch; // Search handle
|
||||||
char Drive[_MAX_DRIVE]; // Drive name
|
char Drive[_MAX_DRIVE]; // Drive name
|
||||||
#else // !__WIN__
|
#else // !__WIN__
|
||||||
struct stat Fileinfo; // File info structure
|
struct stat Fileinfo; // File info structure
|
||||||
@@ -184,7 +184,7 @@ class TDBSDR : public TDBDIR {
|
|||||||
struct _Sub_Dir *Next;
|
struct _Sub_Dir *Next;
|
||||||
struct _Sub_Dir *Prev;
|
struct _Sub_Dir *Prev;
|
||||||
#if defined(__WIN__)
|
#if defined(__WIN__)
|
||||||
int H; // Search handle
|
intptr_t H; // Search handle
|
||||||
#else // !__WIN__
|
#else // !__WIN__
|
||||||
DIR *D;
|
DIR *D;
|
||||||
#endif // !__WIN__
|
#endif // !__WIN__
|
||||||
|
@@ -1407,8 +1407,12 @@ void MYSQLCOL::ReadColumn(PGLOBAL g)
|
|||||||
if (rc == RC_EF)
|
if (rc == RC_EF)
|
||||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||||
|
|
||||||
longjmp(g->jumper[g->jump_level], 11);
|
#if defined(USE_TRY)
|
||||||
} else
|
throw 11;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 11);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else
|
||||||
tdbp->Fetched = true;
|
tdbp->Fetched = true;
|
||||||
|
|
||||||
if ((buf = ((PTDBMY)To_Tdb)->Myc.GetCharField(Rank))) {
|
if ((buf = ((PTDBMY)To_Tdb)->Myc.GetCharField(Rank))) {
|
||||||
|
@@ -116,47 +116,12 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
|||||||
if (EXTDEF::DefineAM(g, am, poff))
|
if (EXTDEF::DefineAM(g, am, poff))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Tabname = GetStringCatInfo(g, "Name",
|
|
||||||
// (Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
|
||||||
// Tabname = GetStringCatInfo(g, "Tabname", Tabname);
|
|
||||||
// Tabschema = GetStringCatInfo(g, "Dbname", NULL);
|
|
||||||
// Tabschema = GetStringCatInfo(g, "Schema", Tabschema);
|
|
||||||
// Tabcat = GetStringCatInfo(g, "Qualifier", NULL);
|
|
||||||
// Tabcat = GetStringCatInfo(g, "Catalog", Tabcat);
|
|
||||||
//Username = GetStringCatInfo(g, "User", NULL);
|
|
||||||
// Password = GetStringCatInfo(g, "Password", NULL);
|
|
||||||
|
|
||||||
// if ((Srcdef = GetStringCatInfo(g, "Srcdef", NULL)))
|
|
||||||
// Read_Only = true;
|
|
||||||
|
|
||||||
// Qrystr = GetStringCatInfo(g, "Query_String", "?");
|
|
||||||
// Sep = GetStringCatInfo(g, "Separator", NULL);
|
|
||||||
Catver = GetIntCatInfo("Catver", 2);
|
Catver = GetIntCatInfo("Catver", 2);
|
||||||
//Xsrc = GetBoolCatInfo("Execsrc", FALSE);
|
|
||||||
//Maxerr = GetIntCatInfo("Maxerr", 0);
|
|
||||||
//Maxres = GetIntCatInfo("Maxres", 0);
|
|
||||||
//Quoted = GetIntCatInfo("Quoted", 0);
|
|
||||||
Options = ODBConn::noOdbcDialog;
|
Options = ODBConn::noOdbcDialog;
|
||||||
//Options = ODBConn::noOdbcDialog | ODBConn::useCursorLib;
|
//Options = ODBConn::noOdbcDialog | ODBConn::useCursorLib;
|
||||||
Cto= GetIntCatInfo("ConnectTimeout", DEFAULT_LOGIN_TIMEOUT);
|
Cto= GetIntCatInfo("ConnectTimeout", DEFAULT_LOGIN_TIMEOUT);
|
||||||
Qto= GetIntCatInfo("QueryTimeout", DEFAULT_QUERY_TIMEOUT);
|
Qto= GetIntCatInfo("QueryTimeout", DEFAULT_QUERY_TIMEOUT);
|
||||||
|
|
||||||
//if ((Scrollable = GetBoolCatInfo("Scrollable", false)) && !Elemt)
|
|
||||||
// Elemt = 1; // Cannot merge SQLFetch and SQLExtendedFetch
|
|
||||||
|
|
||||||
//if (Catfunc == FNC_COL)
|
|
||||||
// Colpat = GetStringCatInfo(g, "Colpat", NULL);
|
|
||||||
|
|
||||||
//if (Catfunc == FNC_TABLE)
|
|
||||||
// Tabtyp = GetStringCatInfo(g, "Tabtype", NULL);
|
|
||||||
|
|
||||||
UseCnc = GetBoolCatInfo("UseDSN", false);
|
UseCnc = GetBoolCatInfo("UseDSN", false);
|
||||||
|
|
||||||
// Memory was Boolean, it is now integer
|
|
||||||
//if (!(Memory = GetIntCatInfo("Memory", 0)))
|
|
||||||
// Memory = GetBoolCatInfo("Memory", false) ? 1 : 0;
|
|
||||||
|
|
||||||
//Pseudo = 2; // FILID is Ok but not ROWID
|
|
||||||
return false;
|
return false;
|
||||||
} // end of DefineAM
|
} // end of DefineAM
|
||||||
|
|
||||||
@@ -210,59 +175,22 @@ TDBODBC::TDBODBC(PODEF tdp) : TDBEXT(tdp)
|
|||||||
|
|
||||||
if (tdp) {
|
if (tdp) {
|
||||||
Connect = tdp->Connect;
|
Connect = tdp->Connect;
|
||||||
//TableName = tdp->Tabname;
|
|
||||||
//Schema = tdp->Tabschema;
|
|
||||||
Ops.User = tdp->Username;
|
Ops.User = tdp->Username;
|
||||||
Ops.Pwd = tdp->Password;
|
Ops.Pwd = tdp->Password;
|
||||||
//Catalog = tdp->Tabcat;
|
|
||||||
//Srcdef = tdp->Srcdef;
|
|
||||||
//Qrystr = tdp->Qrystr;
|
|
||||||
//Sep = tdp->GetSep();
|
|
||||||
//Options = tdp->Options;
|
|
||||||
Ops.Cto = tdp->Cto;
|
Ops.Cto = tdp->Cto;
|
||||||
Ops.Qto = tdp->Qto;
|
Ops.Qto = tdp->Qto;
|
||||||
//Quoted = MY_MAX(0, tdp->GetQuoted());
|
|
||||||
//Rows = tdp->GetElemt();
|
|
||||||
Catver = tdp->Catver;
|
Catver = tdp->Catver;
|
||||||
//Memory = tdp->Memory;
|
|
||||||
//Scrollable = tdp->Scrollable;
|
|
||||||
Ops.UseCnc = tdp->UseCnc;
|
Ops.UseCnc = tdp->UseCnc;
|
||||||
} else {
|
} else {
|
||||||
Connect = NULL;
|
Connect = NULL;
|
||||||
//TableName = NULL;
|
|
||||||
//Schema = NULL;
|
|
||||||
Ops.User = NULL;
|
Ops.User = NULL;
|
||||||
Ops.Pwd = NULL;
|
Ops.Pwd = NULL;
|
||||||
//Catalog = NULL;
|
|
||||||
//Srcdef = NULL;
|
|
||||||
//Qrystr = NULL;
|
|
||||||
//Sep = 0;
|
|
||||||
//Options = 0;
|
|
||||||
Ops.Cto = DEFAULT_LOGIN_TIMEOUT;
|
Ops.Cto = DEFAULT_LOGIN_TIMEOUT;
|
||||||
Ops.Qto = DEFAULT_QUERY_TIMEOUT;
|
Ops.Qto = DEFAULT_QUERY_TIMEOUT;
|
||||||
//Quoted = 0;
|
|
||||||
//Rows = 0;
|
|
||||||
Catver = 0;
|
Catver = 0;
|
||||||
//Memory = 0;
|
|
||||||
//Scrollable = false;
|
|
||||||
Ops.UseCnc = false;
|
Ops.UseCnc = false;
|
||||||
} // endif tdp
|
} // endif tdp
|
||||||
|
|
||||||
//Quote = NULL;
|
|
||||||
//Query = NULL;
|
|
||||||
//Count = NULL;
|
|
||||||
//Where = NULL;
|
|
||||||
//MulConn = NULL;
|
|
||||||
//DBQ = NULL;
|
|
||||||
//Qrp = NULL;
|
|
||||||
//Fpos = 0;
|
|
||||||
//Curpos = 0;
|
|
||||||
//AftRows = 0;
|
|
||||||
//CurNum = 0;
|
|
||||||
//Rbuf = 0;
|
|
||||||
//BufSize = 0;
|
|
||||||
//Nparm = 0;
|
|
||||||
//Placed = false;
|
|
||||||
} // end of TDBODBC standard constructor
|
} // end of TDBODBC standard constructor
|
||||||
|
|
||||||
TDBODBC::TDBODBC(PTDBODBC tdbp) : TDBEXT(tdbp)
|
TDBODBC::TDBODBC(PTDBODBC tdbp) : TDBEXT(tdbp)
|
||||||
@@ -270,32 +198,7 @@ TDBODBC::TDBODBC(PTDBODBC tdbp) : TDBEXT(tdbp)
|
|||||||
Ocp = tdbp->Ocp; // is that right ?
|
Ocp = tdbp->Ocp; // is that right ?
|
||||||
Cnp = tdbp->Cnp;
|
Cnp = tdbp->Cnp;
|
||||||
Connect = tdbp->Connect;
|
Connect = tdbp->Connect;
|
||||||
//TableName = tdbp->TableName;
|
|
||||||
//Schema = tdbp->Schema;
|
|
||||||
Ops = tdbp->Ops;
|
Ops = tdbp->Ops;
|
||||||
//Catalog = tdbp->Catalog;
|
|
||||||
//Srcdef = tdbp->Srcdef;
|
|
||||||
//Qrystr = tdbp->Qrystr;
|
|
||||||
//Memory = tdbp->Memory;
|
|
||||||
//Scrollable = tdbp->Scrollable;
|
|
||||||
//Quote = tdbp->Quote;
|
|
||||||
//Query = tdbp->Query;
|
|
||||||
//Count = tdbp->Count;
|
|
||||||
//Where = tdbp->Where;
|
|
||||||
//MulConn = tdbp->MulConn;
|
|
||||||
//DBQ = tdbp->DBQ;
|
|
||||||
//Options = tdbp->Options;
|
|
||||||
//Quoted = tdbp->Quoted;
|
|
||||||
//Rows = tdbp->Rows;
|
|
||||||
//Fpos = 0;
|
|
||||||
//Curpos = 0;
|
|
||||||
//AftRows = 0;
|
|
||||||
//CurNum = 0;
|
|
||||||
//Rbuf = 0;
|
|
||||||
//BufSize = tdbp->BufSize;
|
|
||||||
//Nparm = tdbp->Nparm;
|
|
||||||
//Qrp = tdbp->Qrp;
|
|
||||||
//Placed = false;
|
|
||||||
} // end of TDBODBC copy constructor
|
} // end of TDBODBC copy constructor
|
||||||
|
|
||||||
// Method
|
// Method
|
||||||
@@ -389,144 +292,6 @@ void TDBODBC::SetFile(PGLOBAL g, PSZ fn)
|
|||||||
DBQ = fn;
|
DBQ = fn;
|
||||||
} // end of SetFile
|
} // end of SetFile
|
||||||
|
|
||||||
#if 0
|
|
||||||
/******************************************************************/
|
|
||||||
/* Convert an UTF-8 string to latin characters. */
|
|
||||||
/******************************************************************/
|
|
||||||
int TDBODBC::Decode(char *txt, char *buf, size_t n)
|
|
||||||
{
|
|
||||||
uint dummy_errors;
|
|
||||||
uint32 len= copy_and_convert(buf, n, &my_charset_latin1,
|
|
||||||
txt, strlen(txt),
|
|
||||||
&my_charset_utf8_general_ci,
|
|
||||||
&dummy_errors);
|
|
||||||
buf[len]= '\0';
|
|
||||||
return 0;
|
|
||||||
} // end of Decode
|
|
||||||
|
|
||||||
/***********************************************************************/
|
|
||||||
/* MakeSQL: make the SQL statement use with ODBC connection. */
|
|
||||||
/* Note: when implementing EOM filtering, column only used in local */
|
|
||||||
/* filter should be removed from column list. */
|
|
||||||
/***********************************************************************/
|
|
||||||
bool TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
|
|
||||||
{
|
|
||||||
char *schmp = NULL, *catp = NULL, buf[NAM_LEN * 3];
|
|
||||||
int len;
|
|
||||||
bool oom = false, first = true;
|
|
||||||
PTABLE tablep = To_Table;
|
|
||||||
PCOL colp;
|
|
||||||
|
|
||||||
if (Srcdef) {
|
|
||||||
if (strstr(Srcdef, "%s")) {
|
|
||||||
char *fil;
|
|
||||||
|
|
||||||
fil = (To_CondFil) ? To_CondFil->Body : PlugDup(g, "1=1");
|
|
||||||
Query = new(g)STRING(g, strlen(Srcdef) + strlen(fil));
|
|
||||||
Query->SetLength(sprintf(Query->GetStr(), Srcdef, fil));
|
|
||||||
} else
|
|
||||||
Query = new(g)STRING(g, 0, Srcdef);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} // endif Srcdef
|
|
||||||
|
|
||||||
// Allocate the string used to contain the Query
|
|
||||||
Query = new(g)STRING(g, 1023, "SELECT ");
|
|
||||||
|
|
||||||
if (!cnt) {
|
|
||||||
if (Columns) {
|
|
||||||
// Normal SQL statement to retrieve results
|
|
||||||
for (colp = Columns; colp; colp = colp->GetNext())
|
|
||||||
if (!colp->IsSpecial()) {
|
|
||||||
if (!first)
|
|
||||||
oom |= Query->Append(", ");
|
|
||||||
else
|
|
||||||
first = false;
|
|
||||||
|
|
||||||
// Column name can be encoded in UTF-8
|
|
||||||
Decode(colp->GetName(), buf, sizeof(buf));
|
|
||||||
|
|
||||||
if (Quote) {
|
|
||||||
// Put column name between identifier quotes in case in contains blanks
|
|
||||||
oom |= Query->Append(Quote);
|
|
||||||
oom |= Query->Append(buf);
|
|
||||||
oom |= Query->Append(Quote);
|
|
||||||
} else
|
|
||||||
oom |= Query->Append(buf);
|
|
||||||
|
|
||||||
((PEXTCOL)colp)->SetRank(++Ncol);
|
|
||||||
} // endif colp
|
|
||||||
|
|
||||||
} else
|
|
||||||
// !Columns can occur for queries such that sql count(*) from...
|
|
||||||
// for which we will count the rows from sql * from...
|
|
||||||
oom |= Query->Append('*');
|
|
||||||
|
|
||||||
} else
|
|
||||||
// SQL statement used to retrieve the size of the result
|
|
||||||
oom |= Query->Append("count(*)");
|
|
||||||
|
|
||||||
oom |= Query->Append(" FROM ");
|
|
||||||
|
|
||||||
if (Catalog && *Catalog)
|
|
||||||
catp = Catalog;
|
|
||||||
|
|
||||||
//if (tablep->GetSchema())
|
|
||||||
// schmp = (char*)tablep->GetSchema();
|
|
||||||
//else
|
|
||||||
if (Schema && *Schema)
|
|
||||||
schmp = Schema;
|
|
||||||
|
|
||||||
if (catp) {
|
|
||||||
oom |= Query->Append(catp);
|
|
||||||
|
|
||||||
if (schmp) {
|
|
||||||
oom |= Query->Append('.');
|
|
||||||
oom |= Query->Append(schmp);
|
|
||||||
} // endif schmp
|
|
||||||
|
|
||||||
oom |= Query->Append('.');
|
|
||||||
} else if (schmp) {
|
|
||||||
oom |= Query->Append(schmp);
|
|
||||||
oom |= Query->Append('.');
|
|
||||||
} // endif schmp
|
|
||||||
|
|
||||||
// Table name can be encoded in UTF-8
|
|
||||||
Decode(TableName, buf, sizeof(buf));
|
|
||||||
|
|
||||||
if (Quote) {
|
|
||||||
// Put table name between identifier quotes in case in contains blanks
|
|
||||||
oom |= Query->Append(Quote);
|
|
||||||
oom |= Query->Append(buf);
|
|
||||||
oom |= Query->Append(Quote);
|
|
||||||
} else
|
|
||||||
oom |= Query->Append(buf);
|
|
||||||
|
|
||||||
len = Query->GetLength();
|
|
||||||
|
|
||||||
if (To_CondFil) {
|
|
||||||
if (Mode == MODE_READ) {
|
|
||||||
oom |= Query->Append(" WHERE ");
|
|
||||||
oom |= Query->Append(To_CondFil->Body);
|
|
||||||
len = Query->GetLength() + 1;
|
|
||||||
} else
|
|
||||||
len += (strlen(To_CondFil->Body) + 256);
|
|
||||||
|
|
||||||
} else
|
|
||||||
len += ((Mode == MODE_READX) ? 256 : 1);
|
|
||||||
|
|
||||||
if (oom || Query->Resize(len)) {
|
|
||||||
strcpy(g->Message, "MakeSQL: Out of memory");
|
|
||||||
return true;
|
|
||||||
} // endif oom
|
|
||||||
|
|
||||||
if (trace)
|
|
||||||
htrc("Query=%s\n", Query->GetStr());
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} // end of MakeSQL
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* MakeInsert: make the Insert statement used with ODBC connection. */
|
/* MakeInsert: make the Insert statement used with ODBC connection. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -645,73 +410,6 @@ bool TDBODBC::BindParameters(PGLOBAL g)
|
|||||||
} // end of BindParameters
|
} // end of BindParameters
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/***********************************************************************/
|
|
||||||
/* MakeCommand: make the Update or Delete statement to send to the */
|
|
||||||
/* MySQL server. Limited to remote values and filtering. */
|
|
||||||
/***********************************************************************/
|
|
||||||
bool TDBODBC::MakeCommand(PGLOBAL g)
|
|
||||||
{
|
|
||||||
char *p, *stmt, name[68], *body = NULL, *qc = Ocp->GetQuoteChar();
|
|
||||||
char *qrystr = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 1);
|
|
||||||
bool qtd = Quoted > 0;
|
|
||||||
int i = 0, k = 0;
|
|
||||||
|
|
||||||
// Make a lower case copy of the originale query and change
|
|
||||||
// back ticks to the data source identifier quoting character
|
|
||||||
do {
|
|
||||||
qrystr[i] = (Qrystr[i] == '`') ? *qc : tolower(Qrystr[i]);
|
|
||||||
} while (Qrystr[i++]);
|
|
||||||
|
|
||||||
if (To_CondFil && (p = strstr(qrystr, " where "))) {
|
|
||||||
p[7] = 0; // Remove where clause
|
|
||||||
Qrystr[(p - qrystr) + 7] = 0;
|
|
||||||
body = To_CondFil->Body;
|
|
||||||
stmt = (char*)PlugSubAlloc(g, NULL, strlen(qrystr)
|
|
||||||
+ strlen(body) + 64);
|
|
||||||
} else
|
|
||||||
stmt = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 64);
|
|
||||||
|
|
||||||
// Check whether the table name is equal to a keyword
|
|
||||||
// If so, it must be quoted in the original query
|
|
||||||
strlwr(strcat(strcat(strcpy(name, " "), Name), " "));
|
|
||||||
|
|
||||||
if (strstr(" update delete low_priority ignore quick from ", name)) {
|
|
||||||
strlwr(strcat(strcat(strcpy(name, qc), Name), qc));
|
|
||||||
k += 2;
|
|
||||||
} else
|
|
||||||
strlwr(strcpy(name, Name)); // Not a keyword
|
|
||||||
|
|
||||||
if ((p = strstr(qrystr, name))) {
|
|
||||||
for (i = 0; i < p - qrystr; i++)
|
|
||||||
stmt[i] = (Qrystr[i] == '`') ? *qc : Qrystr[i];
|
|
||||||
|
|
||||||
stmt[i] = 0;
|
|
||||||
k += i + (int)strlen(Name);
|
|
||||||
|
|
||||||
if (qtd && *(p - 1) == ' ')
|
|
||||||
strcat(strcat(strcat(stmt, qc), TableName), qc);
|
|
||||||
else
|
|
||||||
strcat(stmt, TableName);
|
|
||||||
|
|
||||||
i = (int)strlen(stmt);
|
|
||||||
|
|
||||||
do {
|
|
||||||
stmt[i++] = (Qrystr[k] == '`') ? *qc : Qrystr[k];
|
|
||||||
} while (Qrystr[k++]);
|
|
||||||
|
|
||||||
if (body)
|
|
||||||
strcat(stmt, body);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
sprintf(g->Message, "Cannot use this %s command",
|
|
||||||
(Mode == MODE_UPDATE) ? "UPDATE" : "DELETE");
|
|
||||||
return true;
|
|
||||||
} // endif p
|
|
||||||
|
|
||||||
Query = new(g) STRING(g, 0, stmt);
|
|
||||||
return (!Query->GetSize());
|
|
||||||
} // end of MakeCommand
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* MakeUpdate: make the SQL statement to send to ODBC connection. */
|
/* MakeUpdate: make the SQL statement to send to ODBC connection. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -829,35 +527,6 @@ int TDBODBC::Cardinality(PGLOBAL g)
|
|||||||
return Cardinal;
|
return Cardinal;
|
||||||
} // end of Cardinality
|
} // end of Cardinality
|
||||||
|
|
||||||
#if 0
|
|
||||||
/***********************************************************************/
|
|
||||||
/* ODBC GetMaxSize: returns table size estimate in number of lines. */
|
|
||||||
/***********************************************************************/
|
|
||||||
int TDBODBC::GetMaxSize(PGLOBAL g)
|
|
||||||
{
|
|
||||||
if (MaxSize < 0) {
|
|
||||||
if (Mode == MODE_DELETE)
|
|
||||||
// Return 0 in mode DELETE in case of delete all.
|
|
||||||
MaxSize = 0;
|
|
||||||
else if (!Cardinality(NULL))
|
|
||||||
MaxSize = 10; // To make MySQL happy
|
|
||||||
else if ((MaxSize = Cardinality(g)) < 0)
|
|
||||||
MaxSize = 12; // So we can see an error occurred
|
|
||||||
|
|
||||||
} // endif MaxSize
|
|
||||||
|
|
||||||
return MaxSize;
|
|
||||||
} // end of GetMaxSize
|
|
||||||
|
|
||||||
/***********************************************************************/
|
|
||||||
/* Return max size value. */
|
|
||||||
/***********************************************************************/
|
|
||||||
int TDBODBC::GetProgMax(PGLOBAL g)
|
|
||||||
{
|
|
||||||
return GetMaxSize(g);
|
|
||||||
} // end of GetProgMax
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* ODBC Access Method opening routine. */
|
/* ODBC Access Method opening routine. */
|
||||||
/* New method now that this routine is called recursively (last table */
|
/* New method now that this routine is called recursively (last table */
|
||||||
@@ -1097,8 +766,6 @@ int TDBODBC::ReadDB(PGLOBAL g)
|
|||||||
|
|
||||||
if (trace > 1)
|
if (trace > 1)
|
||||||
htrc("ODBC ReadDB: R%d Mode=%d\n", GetTdb_No(), Mode);
|
htrc("ODBC ReadDB: R%d Mode=%d\n", GetTdb_No(), Mode);
|
||||||
//htrc("ODBC ReadDB: R%d Mode=%d key=%p link=%p Kindex=%p\n",
|
|
||||||
// GetTdb_No(), Mode, To_Key_Col, To_Link, To_Kindex);
|
|
||||||
|
|
||||||
if (Mode == MODE_UPDATE || Mode == MODE_DELETE) {
|
if (Mode == MODE_UPDATE || Mode == MODE_DELETE) {
|
||||||
if (!Query && MakeCommand(g))
|
if (!Query && MakeCommand(g))
|
||||||
@@ -1118,12 +785,6 @@ int TDBODBC::ReadDB(PGLOBAL g)
|
|||||||
|
|
||||||
} // endif Mode
|
} // endif Mode
|
||||||
|
|
||||||
//if (To_Kindex) {
|
|
||||||
// // Direct access of ODBC tables is not implemented yet
|
|
||||||
// strcpy(g->Message, MSG(NO_ODBC_DIRECT));
|
|
||||||
// return RC_FX;
|
|
||||||
// } // endif To_Kindex
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Now start the reading process. */
|
/* Now start the reading process. */
|
||||||
/* Here is the place to fetch the line(s). */
|
/* Here is the place to fetch the line(s). */
|
||||||
@@ -1208,11 +869,6 @@ int TDBODBC::DeleteDB(PGLOBAL g, int irc)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void TDBODBC::CloseDB(PGLOBAL g)
|
void TDBODBC::CloseDB(PGLOBAL g)
|
||||||
{
|
{
|
||||||
//if (To_Kindex) {
|
|
||||||
// To_Kindex->Close();
|
|
||||||
// To_Kindex = NULL;
|
|
||||||
// } // endif
|
|
||||||
|
|
||||||
if (Ocp)
|
if (Ocp)
|
||||||
|
|
||||||
Ocp->Close();
|
Ocp->Close();
|
||||||
@@ -1231,16 +887,9 @@ ODBCCOL::ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
|
|||||||
: EXTCOL(cdp, tdbp, cprec, i, am)
|
: EXTCOL(cdp, tdbp, cprec, i, am)
|
||||||
{
|
{
|
||||||
// Set additional ODBC access method information for column.
|
// Set additional ODBC access method information for column.
|
||||||
//Crp = NULL;
|
|
||||||
//Long = Precision;
|
|
||||||
//strcpy(F_Date, cdp->F_Date);
|
|
||||||
//To_Val = NULL;
|
|
||||||
Slen = 0;
|
Slen = 0;
|
||||||
StrLen = &Slen;
|
StrLen = &Slen;
|
||||||
Sqlbuf = NULL;
|
Sqlbuf = NULL;
|
||||||
//Bufp = NULL;
|
|
||||||
//Blkp = NULL;
|
|
||||||
//Rank = 0; // Not known yet
|
|
||||||
} // end of ODBCCOL constructor
|
} // end of ODBCCOL constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1248,17 +897,9 @@ ODBCCOL::ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
ODBCCOL::ODBCCOL(void) : EXTCOL()
|
ODBCCOL::ODBCCOL(void) : EXTCOL()
|
||||||
{
|
{
|
||||||
//Crp = NULL;
|
|
||||||
//Buf_Type = TYPE_INT; // This is a count(*) column
|
|
||||||
//// Set additional Dos access method information for column.
|
|
||||||
//Long = sizeof(int);
|
|
||||||
//To_Val = NULL;
|
|
||||||
Slen = 0;
|
Slen = 0;
|
||||||
StrLen = &Slen;
|
StrLen = &Slen;
|
||||||
Sqlbuf = NULL;
|
Sqlbuf = NULL;
|
||||||
//Bufp = NULL;
|
|
||||||
//Blkp = NULL;
|
|
||||||
//Rank = 1;
|
|
||||||
} // end of ODBCCOL constructor
|
} // end of ODBCCOL constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1267,66 +908,11 @@ ODBCCOL::ODBCCOL(void) : EXTCOL()
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
ODBCCOL::ODBCCOL(ODBCCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp)
|
ODBCCOL::ODBCCOL(ODBCCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp)
|
||||||
{
|
{
|
||||||
//Crp = col1->Crp;
|
|
||||||
//Long = col1->Long;
|
|
||||||
//strcpy(F_Date, col1->F_Date);
|
|
||||||
//To_Val = col1->To_Val;
|
|
||||||
Slen = col1->Slen;
|
Slen = col1->Slen;
|
||||||
StrLen = col1->StrLen;
|
StrLen = col1->StrLen;
|
||||||
Sqlbuf = col1->Sqlbuf;
|
Sqlbuf = col1->Sqlbuf;
|
||||||
//Bufp = col1->Bufp;
|
|
||||||
//Blkp = col1->Blkp;
|
|
||||||
//Rank = col1->Rank;
|
|
||||||
} // end of ODBCCOL copy constructor
|
} // end of ODBCCOL copy constructor
|
||||||
|
|
||||||
#if 0
|
|
||||||
/***********************************************************************/
|
|
||||||
/* SetBuffer: prepare a column block for write operation. */
|
|
||||||
/***********************************************************************/
|
|
||||||
bool ODBCCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
|
|
||||||
{
|
|
||||||
if (!(To_Val = value)) {
|
|
||||||
sprintf(g->Message, MSG(VALUE_ERROR), Name);
|
|
||||||
return true;
|
|
||||||
} else if (Buf_Type == value->GetType()) {
|
|
||||||
// Values are of the (good) column type
|
|
||||||
if (Buf_Type == TYPE_DATE) {
|
|
||||||
// If any of the date values is formatted
|
|
||||||
// output format must be set for the receiving table
|
|
||||||
if (GetDomain() || ((DTVAL *)value)->IsFormatted())
|
|
||||||
goto newval; // This will make a new value;
|
|
||||||
|
|
||||||
} else if (Buf_Type == TYPE_DOUBLE)
|
|
||||||
// Float values must be written with the correct (column) precision
|
|
||||||
// Note: maybe this should be forced by ShowValue instead of this ?
|
|
||||||
value->SetPrec(GetScale());
|
|
||||||
|
|
||||||
Value = value; // Directly access the external value
|
|
||||||
} else {
|
|
||||||
// Values are not of the (good) column type
|
|
||||||
if (check) {
|
|
||||||
sprintf(g->Message, MSG(TYPE_VALUE_ERR), Name,
|
|
||||||
GetTypeName(Buf_Type), GetTypeName(value->GetType()));
|
|
||||||
return true;
|
|
||||||
} // endif check
|
|
||||||
|
|
||||||
newval:
|
|
||||||
if (InitValue(g)) // Allocate the matching value block
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} // endif's Value, Buf_Type
|
|
||||||
|
|
||||||
// Because Colblk's have been made from a copy of the original TDB in
|
|
||||||
// case of Update, we must reset them to point to the original one.
|
|
||||||
if (To_Tdb->GetOrig())
|
|
||||||
To_Tdb = (PTDB)To_Tdb->GetOrig();
|
|
||||||
|
|
||||||
// Set the Column
|
|
||||||
Status = (ok) ? BUF_EMPTY : BUF_NO;
|
|
||||||
return false;
|
|
||||||
} // end of SetBuffer
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* ReadColumn: when SQLFetch is used there is nothing to do as the */
|
/* ReadColumn: when SQLFetch is used there is nothing to do as the */
|
||||||
/* column buffer was bind to the record set. This is also the case */
|
/* column buffer was bind to the record set. This is also the case */
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*************** Tabodbc H Declares Source Code File (.H) **************/
|
/*************** Tabodbc H Declares Source Code File (.H) **************/
|
||||||
/* Name: TABODBC.H Version 1.8 */
|
/* Name: TABODBC.H Version 1.9 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2000-2015 */
|
/* (C) Copyright to the author Olivier BERTRAND 2000-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the TDBODBC classes declares. */
|
/* This file contains the TDBODBC classes declares. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -33,14 +33,7 @@ public:
|
|||||||
// Implementation
|
// Implementation
|
||||||
virtual const char *GetType(void) {return "ODBC";}
|
virtual const char *GetType(void) {return "ODBC";}
|
||||||
PSZ GetConnect(void) {return Connect;}
|
PSZ GetConnect(void) {return Connect;}
|
||||||
//PSZ GetTabname(void) {return Tabname;}
|
|
||||||
//PSZ GetTabschema(void) {return Tabschema;}
|
|
||||||
//PSZ GetTabcat(void) {return Tabcat;}
|
|
||||||
//PSZ GetSrcdef(void) {return Srcdef;}
|
|
||||||
//char GetSep(void) {return (Sep) ? *Sep : 0;}
|
|
||||||
//int GetQuoted(void) {return Quoted;}
|
|
||||||
int GetCatver(void) {return Catver;}
|
int GetCatver(void) {return Catver;}
|
||||||
//int GetOptions(void) {return Options;}
|
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual int Indexable(void) {return 2;}
|
virtual int Indexable(void) {return 2;}
|
||||||
@@ -50,27 +43,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
// Members
|
// Members
|
||||||
PSZ Connect; /* ODBC connection string */
|
PSZ Connect; /* ODBC connection string */
|
||||||
//PSZ Tabname; /* External table name */
|
|
||||||
//PSZ Tabschema; /* External table schema */
|
|
||||||
//PSZ Username; /* User connect name */
|
|
||||||
//PSZ Password; /* Password connect info */
|
|
||||||
//PSZ Tabcat; /* External table catalog */
|
|
||||||
//PSZ Tabtyp; /* Catalog table type */
|
|
||||||
//PSZ Colpat; /* Catalog column pattern */
|
|
||||||
//PSZ Srcdef; /* The source table SQL definition */
|
|
||||||
//PSZ Qchar; /* Identifier quoting character */
|
|
||||||
//PSZ Qrystr; /* The original query */
|
|
||||||
//PSZ Sep; /* Decimal separator */
|
|
||||||
int Catver; /* ODBC version for catalog functions */
|
int Catver; /* ODBC version for catalog functions */
|
||||||
//int Options; /* Open connection options */
|
|
||||||
//int Cto; /* Open connection timeout */
|
|
||||||
//int Qto; /* Query (command) timeout */
|
|
||||||
//int Quoted; /* Identifier quoting level */
|
|
||||||
//int Maxerr; /* Maxerr for an Exec table */
|
|
||||||
//int Maxres; /* Maxres for a catalog table */
|
|
||||||
//int Memory; /* Put result set in memory */
|
|
||||||
//bool Scrollable; /* Use scrollable cursor */
|
|
||||||
//bool Xsrc; /* Execution type */
|
|
||||||
bool UseCnc; /* Use SQLConnect (!SQLDriverConnect) */
|
bool UseCnc; /* Use SQLConnect (!SQLDriverConnect) */
|
||||||
}; // end of ODBCDEF
|
}; // end of ODBCDEF
|
||||||
|
|
||||||
@@ -96,20 +69,16 @@ class TDBODBC : public TDBEXT {
|
|||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual PTDB Clone(PTABS t);
|
virtual PTDB Clone(PTABS t);
|
||||||
//virtual int GetRecpos(void);
|
|
||||||
virtual bool SetRecpos(PGLOBAL g, int recpos);
|
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);
|
||||||
//virtual int GetAffectedRows(void) {return AftRows;}
|
|
||||||
virtual PSZ GetServer(void) {return "ODBC";}
|
virtual PSZ GetServer(void) {return "ODBC";}
|
||||||
virtual int Indexable(void) {return 2;}
|
virtual int Indexable(void) {return 2;}
|
||||||
|
|
||||||
// Database routines
|
// Database routines
|
||||||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
||||||
virtual int Cardinality(PGLOBAL g);
|
virtual int Cardinality(PGLOBAL g);
|
||||||
//virtual int GetMaxSize(PGLOBAL g);
|
|
||||||
//virtual int GetProgMax(PGLOBAL g);
|
|
||||||
virtual bool OpenDB(PGLOBAL g);
|
virtual bool OpenDB(PGLOBAL g);
|
||||||
virtual int ReadDB(PGLOBAL g);
|
virtual int ReadDB(PGLOBAL g);
|
||||||
virtual int WriteDB(PGLOBAL g);
|
virtual int WriteDB(PGLOBAL g);
|
||||||
@@ -119,14 +88,8 @@ class TDBODBC : public TDBEXT {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Internal functions
|
// Internal functions
|
||||||
//int Decode(char *utf, char *buf, size_t n);
|
|
||||||
//bool MakeSQL(PGLOBAL g, bool cnt);
|
|
||||||
bool MakeInsert(PGLOBAL g);
|
bool MakeInsert(PGLOBAL g);
|
||||||
//virtual bool MakeCommand(PGLOBAL g);
|
|
||||||
//bool MakeFilter(PGLOBAL g, bool c);
|
|
||||||
bool BindParameters(PGLOBAL g);
|
bool BindParameters(PGLOBAL g);
|
||||||
//char *MakeUpdate(PGLOBAL g);
|
|
||||||
//char *MakeDelete(PGLOBAL g);
|
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
ODBConn *Ocp; // Points to an ODBC connection class
|
ODBConn *Ocp; // Points to an ODBC connection class
|
||||||
@@ -151,9 +114,6 @@ class ODBCCOL : public EXTCOL {
|
|||||||
// Implementation
|
// Implementation
|
||||||
virtual int GetAmType(void) {return TYPE_AM_ODBC;}
|
virtual int GetAmType(void) {return TYPE_AM_ODBC;}
|
||||||
SQLLEN *GetStrLen(void) {return StrLen;}
|
SQLLEN *GetStrLen(void) {return StrLen;}
|
||||||
// int GetRank(void) {return Rank;}
|
|
||||||
// PVBLK GetBlkp(void) {return Blkp;}
|
|
||||||
// void SetCrp(PCOLRES crp) {Crp = crp;}
|
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
//virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
//virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
|
||||||
@@ -162,7 +122,6 @@ class ODBCCOL : public EXTCOL {
|
|||||||
void AllocateBuffers(PGLOBAL g, int rows);
|
void AllocateBuffers(PGLOBAL g, int rows);
|
||||||
void *GetBuffer(DWORD rows);
|
void *GetBuffer(DWORD rows);
|
||||||
SWORD GetBuflen(void);
|
SWORD GetBuflen(void);
|
||||||
// void Print(PGLOBAL g, FILE *, uint);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Constructor for count(*) column
|
// Constructor for count(*) column
|
||||||
@@ -170,14 +129,8 @@ class ODBCCOL : public EXTCOL {
|
|||||||
|
|
||||||
// Members
|
// Members
|
||||||
TIMESTAMP_STRUCT *Sqlbuf; // To get SQL_TIMESTAMP's
|
TIMESTAMP_STRUCT *Sqlbuf; // To get SQL_TIMESTAMP's
|
||||||
//PCOLRES Crp; // To storage result
|
|
||||||
//void *Bufp; // To extended buffer
|
|
||||||
//PVBLK Blkp; // To Value Block
|
|
||||||
//char F_Date[12]; // Internal Date format
|
|
||||||
//PVAL To_Val; // To value used for Insert
|
|
||||||
SQLLEN *StrLen; // As returned by ODBC
|
SQLLEN *StrLen; // As returned by ODBC
|
||||||
SQLLEN Slen; // Used with Fetch
|
SQLLEN Slen; // Used with Fetch
|
||||||
//int Rank; // Rank (position) number in the query
|
|
||||||
}; // end of class ODBCCOL
|
}; // end of class ODBCCOL
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -230,7 +183,6 @@ class XSRCCOL : public ODBCCOL {
|
|||||||
XSRCCOL(XSRCCOL *colp, PTDB tdbp); // Constructor used in copy process
|
XSRCCOL(XSRCCOL *colp, PTDB tdbp); // Constructor used in copy process
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
//virtual int GetAmType(void) {return TYPE_AM_ODBC;}
|
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual void ReadColumn(PGLOBAL g);
|
virtual void ReadColumn(PGLOBAL g);
|
||||||
|
@@ -108,21 +108,25 @@ bool PIVAID::SkipColumn(PCOLRES crp, char *skc)
|
|||||||
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||||
{
|
{
|
||||||
char *p, *query, *colname, *skc, buf[64];
|
char *p, *query, *colname, *skc, buf[64];
|
||||||
int rc, ndif, nblin, w = 0;
|
int ndif, nblin, w = 0;
|
||||||
bool b = false;
|
bool b = false;
|
||||||
PVAL valp;
|
PVAL valp;
|
||||||
PQRYRES qrp;
|
PQRYRES qrp;
|
||||||
PCOLRES *pcrp, crp, fncrp = NULL;
|
PCOLRES *pcrp, crp, fncrp = NULL;
|
||||||
|
|
||||||
// Save stack and allocation environment and prepare error return
|
#if defined(USE_TRY)
|
||||||
if (g->jump_level == MAX_JUMP) {
|
try {
|
||||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
#else // !USE_TRY
|
||||||
return NULL;
|
// Save stack and allocation environment and prepare error return
|
||||||
} // endif jump_level
|
if (g->jump_level == MAX_JUMP) {
|
||||||
|
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||||
|
return NULL;
|
||||||
|
} // endif jump_level
|
||||||
|
|
||||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
if (setjmp(g->jumper[++g->jump_level])) {
|
||||||
goto err;
|
goto err;
|
||||||
} // endif rc
|
} // endif rc
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
// Are there columns to skip?
|
// Are there columns to skip?
|
||||||
if (Skcol) {
|
if (Skcol) {
|
||||||
@@ -145,7 +149,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||||||
sprintf(query, "SELECT * FROM `%s` LIMIT 1", Tabname);
|
sprintf(query, "SELECT * FROM `%s` LIMIT 1", Tabname);
|
||||||
} else if (!Tabsrc) {
|
} else if (!Tabsrc) {
|
||||||
strcpy(g->Message, MSG(SRC_TABLE_UNDEF));
|
strcpy(g->Message, MSG(SRC_TABLE_UNDEF));
|
||||||
return NULL;
|
goto err;
|
||||||
} else
|
} else
|
||||||
query = Tabsrc;
|
query = Tabsrc;
|
||||||
|
|
||||||
@@ -160,7 +164,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||||||
Myc.FreeResult();
|
Myc.FreeResult();
|
||||||
|
|
||||||
} else
|
} else
|
||||||
return NULL;
|
goto err;
|
||||||
|
|
||||||
// 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)
|
||||||
@@ -233,18 +237,18 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||||||
Index.Sub = TRUE; // Should be small enough
|
Index.Sub = TRUE; // Should be small enough
|
||||||
|
|
||||||
if (!PlgDBalloc(g, NULL, Index))
|
if (!PlgDBalloc(g, NULL, Index))
|
||||||
return NULL;
|
goto err;
|
||||||
|
|
||||||
Offset.Size = (nblin + 1) * sizeof(int);
|
Offset.Size = (nblin + 1) * sizeof(int);
|
||||||
Offset.Sub = TRUE; // Should be small enough
|
Offset.Sub = TRUE; // Should be small enough
|
||||||
|
|
||||||
if (!PlgDBalloc(g, NULL, Offset))
|
if (!PlgDBalloc(g, NULL, Offset))
|
||||||
return NULL;
|
goto err;
|
||||||
|
|
||||||
ndif = Qsort(g, nblin);
|
ndif = Qsort(g, nblin);
|
||||||
|
|
||||||
if (ndif < 0) // error
|
if (ndif < 0) // error
|
||||||
return NULL;
|
goto err;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// The query was limited, we must get pivot column values
|
// The query was limited, we must get pivot column values
|
||||||
@@ -278,7 +282,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||||||
if (!(valp = AllocateValue(g, Rblkp->GetType(),
|
if (!(valp = AllocateValue(g, Rblkp->GetType(),
|
||||||
Rblkp->GetVlen(),
|
Rblkp->GetVlen(),
|
||||||
Rblkp->GetPrec())))
|
Rblkp->GetPrec())))
|
||||||
return NULL;
|
goto err;
|
||||||
|
|
||||||
// Now make the functional columns
|
// Now make the functional columns
|
||||||
for (int i = 0; i < ndif; i++) {
|
for (int i = 0; i < ndif; i++) {
|
||||||
@@ -306,9 +310,25 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||||||
|
|
||||||
// We added ndif columns and removed 2 (picol and fncol)
|
// We added ndif columns and removed 2 (picol and fncol)
|
||||||
Qryp->Nbcol += (ndif - 2);
|
Qryp->Nbcol += (ndif - 2);
|
||||||
return Qryp;
|
#if defined(USE_TRY)
|
||||||
|
return Qryp;
|
||||||
|
|
||||||
|
} catch (int n) {
|
||||||
|
if (trace)
|
||||||
|
htrc("Exception %d: %s\n", n, g->Message);
|
||||||
|
} catch (const char *msg) {
|
||||||
|
strcpy(g->Message, msg);
|
||||||
|
} // end catch
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
#else // !USE_TRY
|
||||||
|
g->jump_level--;
|
||||||
|
return Qryp;
|
||||||
|
|
||||||
|
err:
|
||||||
|
g->jump_level--;
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
if (b)
|
if (b)
|
||||||
Myc.Close();
|
Myc.Close();
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
/************* TabSys C++ Program Source Code File (.CPP) **************/
|
/************* TabSys C++ Program Source Code File (.CPP) **************/
|
||||||
/* PROGRAM NAME: TABSYS */
|
/* PROGRAM NAME: TABSYS */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 2.3 */
|
/* Version 2.4 */
|
||||||
/* */
|
/* */
|
||||||
/* Author Olivier BERTRAND 2004-2015 */
|
/* Author Olivier BERTRAND 2004-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* This program are the INI/CFG tables classes. */
|
/* This program are the INI/CFG tables classes. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -511,12 +511,20 @@ void INICOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (strlen(p) > (unsigned)Long) {
|
if (strlen(p) > (unsigned)Long) {
|
||||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} else if (Flag == 1) {
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (Flag == 1) {
|
||||||
if (tdbp->Mode == MODE_UPDATE) {
|
if (tdbp->Mode == MODE_UPDATE) {
|
||||||
strcpy(g->Message, MSG(NO_SEC_UPDATE));
|
strcpy(g->Message, MSG(NO_SEC_UPDATE));
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} else if (*p) {
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (*p) {
|
||||||
tdbp->Section = p;
|
tdbp->Section = p;
|
||||||
} else
|
} else
|
||||||
tdbp->Section = NULL;
|
tdbp->Section = NULL;
|
||||||
@@ -524,8 +532,12 @@ void INICOL::WriteColumn(PGLOBAL g)
|
|||||||
return;
|
return;
|
||||||
} else if (!tdbp->Section) {
|
} else if (!tdbp->Section) {
|
||||||
strcpy(g->Message, MSG(SEC_NAME_FIRST));
|
strcpy(g->Message, MSG(SEC_NAME_FIRST));
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} // endif's
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif's
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Updating must be done only when not in checking pass. */
|
/* Updating must be done only when not in checking pass. */
|
||||||
@@ -536,8 +548,12 @@ void INICOL::WriteColumn(PGLOBAL g)
|
|||||||
if (!rc) {
|
if (!rc) {
|
||||||
sprintf(g->Message, "Error %d writing to %s",
|
sprintf(g->Message, "Error %d writing to %s",
|
||||||
GetLastError(), tdbp->Ifile);
|
GetLastError(), tdbp->Ifile);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} // endif rc
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif rc
|
||||||
|
|
||||||
} // endif Status
|
} // endif Status
|
||||||
|
|
||||||
@@ -837,12 +853,20 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (strlen(p) > (unsigned)Long) {
|
if (strlen(p) > (unsigned)Long) {
|
||||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} else if (Flag == 1) {
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (Flag == 1) {
|
||||||
if (tdbp->Mode == MODE_UPDATE) {
|
if (tdbp->Mode == MODE_UPDATE) {
|
||||||
strcpy(g->Message, MSG(NO_SEC_UPDATE));
|
strcpy(g->Message, MSG(NO_SEC_UPDATE));
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} else if (*p) {
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (*p) {
|
||||||
tdbp->Section = p;
|
tdbp->Section = p;
|
||||||
} else
|
} else
|
||||||
tdbp->Section = NULL;
|
tdbp->Section = NULL;
|
||||||
@@ -851,8 +875,12 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
|||||||
} else if (Flag == 2) {
|
} else if (Flag == 2) {
|
||||||
if (tdbp->Mode == MODE_UPDATE) {
|
if (tdbp->Mode == MODE_UPDATE) {
|
||||||
strcpy(g->Message, MSG(NO_KEY_UPDATE));
|
strcpy(g->Message, MSG(NO_KEY_UPDATE));
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} else if (*p) {
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (*p) {
|
||||||
tdbp->Keycur = p;
|
tdbp->Keycur = p;
|
||||||
} else
|
} else
|
||||||
tdbp->Keycur = NULL;
|
tdbp->Keycur = NULL;
|
||||||
@@ -860,8 +888,12 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
|||||||
return;
|
return;
|
||||||
} else if (!tdbp->Section || !tdbp->Keycur) {
|
} else if (!tdbp->Section || !tdbp->Keycur) {
|
||||||
strcpy(g->Message, MSG(SEC_KEY_FIRST));
|
strcpy(g->Message, MSG(SEC_KEY_FIRST));
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} // endif's
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif's
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Updating must be done only when not in checking pass. */
|
/* Updating must be done only when not in checking pass. */
|
||||||
@@ -872,8 +904,12 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
|||||||
if (!rc) {
|
if (!rc) {
|
||||||
sprintf(g->Message, "Error %d writing to %s",
|
sprintf(g->Message, "Error %d writing to %s",
|
||||||
GetLastError(), tdbp->Ifile);
|
GetLastError(), tdbp->Ifile);
|
||||||
longjmp(g->jumper[g->jump_level], 31);
|
#if defined(USE_TRY)
|
||||||
} // endif rc
|
throw 31;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 31);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif rc
|
||||||
|
|
||||||
} // endif Status
|
} // endif Status
|
||||||
|
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
/************* TabVct C++ Program Source Code File (.CPP) **************/
|
/************* TabVct C++ Program Source Code File (.CPP) **************/
|
||||||
/* PROGRAM NAME: TABVCT */
|
/* PROGRAM NAME: TABVCT */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 3.8 */
|
/* Version 3.9 */
|
||||||
/* */
|
/* */
|
||||||
/* COPYRIGHT: */
|
/* COPYRIGHT: */
|
||||||
/* ---------- */
|
/* ---------- */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */
|
/* (C) Copyright to the author Olivier BERTRAND 1999-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* WHAT THIS PROGRAM DOES: */
|
/* WHAT THIS PROGRAM DOES: */
|
||||||
/* ----------------------- */
|
/* ----------------------- */
|
||||||
@@ -490,15 +490,23 @@ void VCTCOL::ReadBlock(PGLOBAL g)
|
|||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
if (!Blk) {
|
if (!Blk) {
|
||||||
strcpy(g->Message, MSG(TO_BLK_IS_NULL));
|
strcpy(g->Message, MSG(TO_BLK_IS_NULL));
|
||||||
longjmp(g->jumper[g->jump_level], 58);
|
#if defined(USE_TRY)
|
||||||
} // endif
|
throw 58;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 58);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Read column block according to used access method. */
|
/* Read column block according to used access method. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
if (txfp->ReadBlock(g, this))
|
if (txfp->ReadBlock(g, this))
|
||||||
longjmp(g->jumper[g->jump_level], 6);
|
#if defined(USE_TRY)
|
||||||
|
throw 6;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 6);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
ColBlk = txfp->CurBlk;
|
ColBlk = txfp->CurBlk;
|
||||||
ColPos = -1; // Any invalid position
|
ColPos = -1; // Any invalid position
|
||||||
@@ -518,15 +526,23 @@ void VCTCOL::WriteBlock(PGLOBAL g)
|
|||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
if (!Blk) {
|
if (!Blk) {
|
||||||
strcpy(g->Message, MSG(BLK_IS_NULL));
|
strcpy(g->Message, MSG(BLK_IS_NULL));
|
||||||
longjmp(g->jumper[g->jump_level], 56);
|
#if defined(USE_TRY)
|
||||||
} // endif
|
throw 56;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 56);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
/* Write column block according to used access method. */
|
/* Write column block according to used access method. */
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
if (txfp->WriteBlock(g, this))
|
if (txfp->WriteBlock(g, this))
|
||||||
longjmp(g->jumper[g->jump_level], 6);
|
#if defined(USE_TRY)
|
||||||
|
throw 6;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 6);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
Modif = 0;
|
Modif = 0;
|
||||||
} // endif Modif
|
} // endif Modif
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/************* tdbvir C++ Program Source Code File (.CPP) **************/
|
/************* tdbvir C++ Program Source Code File (.CPP) **************/
|
||||||
/* PROGRAM NAME: tdbvir.cpp Version 1.1 */
|
/* PROGRAM NAME: tdbvir.cpp Version 1.2 */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2014 */
|
/* (C) Copyright to the author Olivier BERTRAND 2014-2017 */
|
||||||
/* This program are the VIR classes DB execution routines. */
|
/* This program are the VIR classes DB execution routines. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
@@ -289,8 +289,12 @@ void VIRCOL::ReadColumn(PGLOBAL g)
|
|||||||
{
|
{
|
||||||
// This should never be called
|
// This should never be called
|
||||||
sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name);
|
sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
#if defined(USE_TRY)
|
||||||
} // end of ReadColumn
|
throw TYPE_COLBLK;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // end of ReadColumn
|
||||||
|
|
||||||
/* ---------------------------TDBVICL class -------------------------- */
|
/* ---------------------------TDBVICL class -------------------------- */
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
/************* Tabxml C++ Program Source Code File (.CPP) **************/
|
/************* Tabxml C++ Program Source Code File (.CPP) **************/
|
||||||
/* PROGRAM NAME: TABXML */
|
/* PROGRAM NAME: TABXML */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 2.9 */
|
/* Version 3.0 */
|
||||||
/* */
|
/* */
|
||||||
/* Author Olivier BERTRAND 2007 - 2016 */
|
/* Author Olivier BERTRAND 2007 - 2017 */
|
||||||
/* */
|
/* */
|
||||||
/* This program are the XML tables classes using MS-DOM or libxml2. */
|
/* This program are the XML tables classes using MS-DOM or libxml2. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1314,8 +1314,12 @@ void TDBXML::CloseDB(PGLOBAL g)
|
|||||||
Docp->CloseDoc(g, To_Xb);
|
Docp->CloseDoc(g, To_Xb);
|
||||||
|
|
||||||
// This causes a crash in Diagnostics_area::set_error_status
|
// This causes a crash in Diagnostics_area::set_error_status
|
||||||
// longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
//#if defined(USE_TRY)
|
||||||
} // endif DumpDoc
|
// throw TYPE_AM_XML;
|
||||||
|
//#else // !USE_TRY
|
||||||
|
// longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
//#endif // !USE_TRY
|
||||||
|
} // endif DumpDoc
|
||||||
|
|
||||||
} // endif Changed
|
} // endif Changed
|
||||||
|
|
||||||
@@ -1637,8 +1641,12 @@ void XMLCOL::ReadColumn(PGLOBAL g)
|
|||||||
if (ValNode->GetType() != XML_ELEMENT_NODE &&
|
if (ValNode->GetType() != XML_ELEMENT_NODE &&
|
||||||
ValNode->GetType() != XML_ATTRIBUTE_NODE) {
|
ValNode->GetType() != XML_ATTRIBUTE_NODE) {
|
||||||
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} // endif type
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif type
|
||||||
|
|
||||||
// Get the Xname value from the XML file
|
// Get the Xname value from the XML file
|
||||||
switch (ValNode->GetContent(g, Valbuf, Long + 1)) {
|
switch (ValNode->GetContent(g, Valbuf, Long + 1)) {
|
||||||
@@ -1648,8 +1656,12 @@ void XMLCOL::ReadColumn(PGLOBAL g)
|
|||||||
PushWarning(g, Tdbp);
|
PushWarning(g, Tdbp);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} // endswitch
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endswitch
|
||||||
|
|
||||||
Value->SetValue_psz(Valbuf);
|
Value->SetValue_psz(Valbuf);
|
||||||
} else {
|
} else {
|
||||||
@@ -1699,7 +1711,11 @@ void XMLCOL::WriteColumn(PGLOBAL g)
|
|||||||
/* For columns having an Xpath, the Clist must be updated. */
|
/* For columns having an Xpath, the Clist must be updated. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
if (Tdbp->CheckRow(g, Nod || Tdbp->Colname))
|
if (Tdbp->CheckRow(g, Nod || Tdbp->Colname))
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Null values are represented by no node. */
|
/* Null values are represented by no node. */
|
||||||
@@ -1771,8 +1787,16 @@ void XMLCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (ColNode == NULL) {
|
if (ColNode == NULL) {
|
||||||
strcpy(g->Message, MSG(COL_ALLOC_ERR));
|
strcpy(g->Message, MSG(COL_ALLOC_ERR));
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} // endif ColNode
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif ColNode
|
||||||
|
|
||||||
} // endif ColNode
|
} // endif ColNode
|
||||||
|
|
||||||
@@ -1800,8 +1824,12 @@ void XMLCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (strlen(p) > (unsigned)Long) {
|
if (strlen(p) > (unsigned)Long) {
|
||||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} else
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else
|
||||||
strcpy(Valbuf, p);
|
strcpy(Valbuf, p);
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@@ -1850,8 +1878,12 @@ void XMULCOL::ReadColumn(PGLOBAL g)
|
|||||||
if (ValNode->GetType() != XML_ELEMENT_NODE &&
|
if (ValNode->GetType() != XML_ELEMENT_NODE &&
|
||||||
ValNode->GetType() != XML_ATTRIBUTE_NODE) {
|
ValNode->GetType() != XML_ATTRIBUTE_NODE) {
|
||||||
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} // endif type
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif type
|
||||||
|
|
||||||
// Get the Xname value from the XML file
|
// Get the Xname value from the XML file
|
||||||
switch (ValNode->GetContent(g, p, (b ? Long : len))) {
|
switch (ValNode->GetContent(g, p, (b ? Long : len))) {
|
||||||
@@ -1936,7 +1968,11 @@ void XMULCOL::WriteColumn(PGLOBAL g)
|
|||||||
/* For columns having an Xpath, the Clist must be updated. */
|
/* For columns having an Xpath, the Clist must be updated. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
if (Tdbp->CheckRow(g, Nod))
|
if (Tdbp->CheckRow(g, Nod))
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Find the column and value nodes to update or insert. */
|
/* Find the column and value nodes to update or insert. */
|
||||||
@@ -1985,8 +2021,12 @@ void XMULCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (len > 1 && !Tdbp->Xpand) {
|
if (len > 1 && !Tdbp->Xpand) {
|
||||||
sprintf(g->Message, MSG(BAD_VAL_UPDATE), Name);
|
sprintf(g->Message, MSG(BAD_VAL_UPDATE), Name);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} else
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else
|
||||||
ValNode = Nlx->GetItem(g, Tdbp->Nsub, Vxnp);
|
ValNode = Nlx->GetItem(g, Tdbp->Nsub, Vxnp);
|
||||||
|
|
||||||
} else // Inod != Nod
|
} else // Inod != Nod
|
||||||
@@ -2027,8 +2067,12 @@ void XMULCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (ColNode == NULL) {
|
if (ColNode == NULL) {
|
||||||
strcpy(g->Message, MSG(COL_ALLOC_ERR));
|
strcpy(g->Message, MSG(COL_ALLOC_ERR));
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} // endif ColNode
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif ColNode
|
||||||
|
|
||||||
} // endif ColNode
|
} // endif ColNode
|
||||||
|
|
||||||
@@ -2056,8 +2100,12 @@ void XMULCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (strlen(p) > (unsigned)Long) {
|
if (strlen(p) > (unsigned)Long) {
|
||||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} else
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else
|
||||||
strcpy(Valbuf, p);
|
strcpy(Valbuf, p);
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@@ -2088,8 +2136,12 @@ void XPOSCOL::ReadColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (Tdbp->Clist == NULL) {
|
if (Tdbp->Clist == NULL) {
|
||||||
strcpy(g->Message, MSG(MIS_TAG_LIST));
|
strcpy(g->Message, MSG(MIS_TAG_LIST));
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} // endif Clist
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Clist
|
||||||
|
|
||||||
if ((ValNode = Tdbp->Clist->GetItem(g, Rank, Vxnp))) {
|
if ((ValNode = Tdbp->Clist->GetItem(g, Rank, Vxnp))) {
|
||||||
// Get the column value from the XML file
|
// Get the column value from the XML file
|
||||||
@@ -2100,8 +2152,12 @@ void XPOSCOL::ReadColumn(PGLOBAL g)
|
|||||||
PushWarning(g, Tdbp);
|
PushWarning(g, Tdbp);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} // endswitch
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endswitch
|
||||||
|
|
||||||
Value->SetValue_psz(Valbuf);
|
Value->SetValue_psz(Valbuf);
|
||||||
} else {
|
} else {
|
||||||
@@ -2151,15 +2207,23 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
|
|||||||
/* For all columns the Clist must be updated. */
|
/* For all columns the Clist must be updated. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
if (Tdbp->CheckRow(g, true))
|
if (Tdbp->CheckRow(g, true))
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* Find the column and value nodes to update or insert. */
|
/* Find the column and value nodes to update or insert. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
if (Tdbp->Clist == NULL) {
|
if (Tdbp->Clist == NULL) {
|
||||||
strcpy(g->Message, MSG(MIS_TAG_LIST));
|
strcpy(g->Message, MSG(MIS_TAG_LIST));
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} // endif Clist
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Clist
|
||||||
|
|
||||||
n = Tdbp->Clist->GetLength();
|
n = Tdbp->Clist->GetLength();
|
||||||
k = Rank;
|
k = Rank;
|
||||||
@@ -2183,8 +2247,12 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
|
|||||||
|
|
||||||
if (strlen(p) > (unsigned)Long) {
|
if (strlen(p) > (unsigned)Long) {
|
||||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
#if defined(USE_TRY)
|
||||||
} else
|
throw TYPE_AM_XML;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else
|
||||||
strcpy(Valbuf, p);
|
strcpy(Valbuf, p);
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************ Valblk C++ Functions Source Code File (.CPP) *************/
|
/************ Valblk C++ Functions Source Code File (.CPP) *************/
|
||||||
/* Name: VALBLK.CPP Version 2.1 */
|
/* Name: VALBLK.CPP Version 2.2 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
|
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the VALBLK and derived classes functions. */
|
/* This file contains the VALBLK and derived classes functions. */
|
||||||
/* Second family is VALBLK, representing simple suballocated arrays */
|
/* Second family is VALBLK, representing simple suballocated arrays */
|
||||||
@@ -138,8 +138,12 @@ PSZ VALBLK::GetCharValue(int)
|
|||||||
|
|
||||||
assert(g);
|
assert(g);
|
||||||
sprintf(g->Message, MSG(NO_CHAR_FROM), Type);
|
sprintf(g->Message, MSG(NO_CHAR_FROM), Type);
|
||||||
longjmp(g->jumper[g->jump_level], Type);
|
#if defined(USE_TRY)
|
||||||
return NULL;
|
throw Type;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], Type);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
return NULL;
|
||||||
} // end of GetCharValue
|
} // end of GetCharValue
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -206,8 +210,12 @@ void VALBLK::ChkIndx(int n)
|
|||||||
if (n < 0 || n >= Nval) {
|
if (n < 0 || n >= Nval) {
|
||||||
PGLOBAL& g = Global;
|
PGLOBAL& g = Global;
|
||||||
strcpy(g->Message, MSG(BAD_VALBLK_INDX));
|
strcpy(g->Message, MSG(BAD_VALBLK_INDX));
|
||||||
longjmp(g->jumper[g->jump_level], Type);
|
#if defined(USE_TRY)
|
||||||
} // endif n
|
throw Type;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], Type);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif n
|
||||||
|
|
||||||
} // end of ChkIndx
|
} // end of ChkIndx
|
||||||
|
|
||||||
@@ -216,8 +224,12 @@ void VALBLK::ChkTyp(PVAL v)
|
|||||||
if (Check && (Type != v->GetType() || Unsigned != v->IsUnsigned())) {
|
if (Check && (Type != v->GetType() || Unsigned != v->IsUnsigned())) {
|
||||||
PGLOBAL& g = Global;
|
PGLOBAL& g = Global;
|
||||||
strcpy(g->Message, MSG(VALTYPE_NOMATCH));
|
strcpy(g->Message, MSG(VALTYPE_NOMATCH));
|
||||||
longjmp(g->jumper[g->jump_level], Type);
|
#if defined(USE_TRY)
|
||||||
} // endif Type
|
throw Type;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], Type);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Type
|
||||||
|
|
||||||
} // end of ChkTyp
|
} // end of ChkTyp
|
||||||
|
|
||||||
@@ -226,8 +238,12 @@ void VALBLK::ChkTyp(PVBLK vb)
|
|||||||
if (Check && (Type != vb->GetType() || Unsigned != vb->IsUnsigned())) {
|
if (Check && (Type != vb->GetType() || Unsigned != vb->IsUnsigned())) {
|
||||||
PGLOBAL& g = Global;
|
PGLOBAL& g = Global;
|
||||||
strcpy(g->Message, MSG(VALTYPE_NOMATCH));
|
strcpy(g->Message, MSG(VALTYPE_NOMATCH));
|
||||||
longjmp(g->jumper[g->jump_level], Type);
|
#if defined(USE_TRY)
|
||||||
} // endif Type
|
throw Type;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], Type);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Type
|
||||||
|
|
||||||
} // end of ChkTyp
|
} // end of ChkTyp
|
||||||
|
|
||||||
@@ -342,8 +358,12 @@ void TYPBLK<TYPE>::SetValue(PSZ p, int n)
|
|||||||
if (Check) {
|
if (Check) {
|
||||||
PGLOBAL& g = Global;
|
PGLOBAL& g = Global;
|
||||||
strcpy(g->Message, MSG(BAD_SET_STRING));
|
strcpy(g->Message, MSG(BAD_SET_STRING));
|
||||||
longjmp(g->jumper[g->jump_level], Type);
|
#if defined(USE_TRY)
|
||||||
} // endif Check
|
throw Type;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], Type);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Check
|
||||||
|
|
||||||
bool minus;
|
bool minus;
|
||||||
ulonglong maxval = MaxVal();
|
ulonglong maxval = MaxVal();
|
||||||
@@ -392,8 +412,12 @@ void TYPBLK<double>::SetValue(PSZ p, int n)
|
|||||||
if (Check) {
|
if (Check) {
|
||||||
PGLOBAL& g = Global;
|
PGLOBAL& g = Global;
|
||||||
strcpy(g->Message, MSG(BAD_SET_STRING));
|
strcpy(g->Message, MSG(BAD_SET_STRING));
|
||||||
longjmp(g->jumper[g->jump_level], Type);
|
#if defined(USE_TRY)
|
||||||
} // endif Check
|
throw Type;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], Type);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Check
|
||||||
|
|
||||||
Typp[n] = atof(p);
|
Typp[n] = atof(p);
|
||||||
SetNull(n, false);
|
SetNull(n, false);
|
||||||
@@ -795,8 +819,12 @@ void CHRBLK::SetValue(char *sp, uint len, int n)
|
|||||||
if (Check && (signed)len > Long) {
|
if (Check && (signed)len > Long) {
|
||||||
PGLOBAL& g = Global;
|
PGLOBAL& g = Global;
|
||||||
strcpy(g->Message, MSG(SET_STR_TRUNC));
|
strcpy(g->Message, MSG(SET_STR_TRUNC));
|
||||||
longjmp(g->jumper[g->jump_level], Type);
|
#if defined(USE_TRY)
|
||||||
} // endif Check
|
throw Type;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], Type);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Check
|
||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||
|
|
||||||
if (sp)
|
if (sp)
|
||||||
@@ -823,8 +851,12 @@ void CHRBLK::SetValue(PVBLK pv, int n1, int n2)
|
|||||||
if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
|
if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
|
||||||
PGLOBAL& g = Global;
|
PGLOBAL& g = Global;
|
||||||
strcpy(g->Message, MSG(BLKTYPLEN_MISM));
|
strcpy(g->Message, MSG(BLKTYPLEN_MISM));
|
||||||
longjmp(g->jumper[g->jump_level], Type);
|
#if defined(USE_TRY)
|
||||||
} // endif Type
|
throw Type;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], Type);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Type
|
||||||
|
|
||||||
if (!(b = pv->IsNull(n2)))
|
if (!(b = pv->IsNull(n2)))
|
||||||
memcpy(Chrp + n1 * Long, ((CHRBLK*)pv)->Chrp + n2 * Long, Long);
|
memcpy(Chrp + n1 * Long, ((CHRBLK*)pv)->Chrp + n2 * Long, Long);
|
||||||
@@ -874,8 +906,12 @@ void CHRBLK::SetValues(PVBLK pv, int k, int n)
|
|||||||
if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
|
if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
|
||||||
PGLOBAL& g = Global;
|
PGLOBAL& g = Global;
|
||||||
strcpy(g->Message, MSG(BLKTYPLEN_MISM));
|
strcpy(g->Message, MSG(BLKTYPLEN_MISM));
|
||||||
longjmp(g->jumper[g->jump_level], Type);
|
#if defined(USE_TRY)
|
||||||
} // endif Type
|
throw Type;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], Type);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Type
|
||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||
char *p = ((CHRBLK*)pv)->Chrp;
|
char *p = ((CHRBLK*)pv)->Chrp;
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************* Value C++ Functions Source Code File (.CPP) *************/
|
/************* Value C++ Functions Source Code File (.CPP) *************/
|
||||||
/* Name: VALUE.CPP Version 2.6 */
|
/* Name: VALUE.CPP Version 2.7 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2001-2016 */
|
/* (C) Copyright to the author Olivier BERTRAND 2001-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the VALUE and derived classes family functions. */
|
/* This file contains the VALUE and derived classes family functions. */
|
||||||
/* These classes contain values of different types. They are used so */
|
/* These classes contain values of different types. They are used so */
|
||||||
@@ -57,10 +57,17 @@
|
|||||||
/* Check macro's. */
|
/* Check macro's. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
|
#if defined(USE_TRY)
|
||||||
#define CheckType(V) if (Type != V->GetType()) { \
|
#define CheckType(V) if (Type != V->GetType()) { \
|
||||||
PGLOBAL& g = Global; \
|
PGLOBAL& g = Global; \
|
||||||
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); \
|
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); \
|
||||||
longjmp(g->jumper[g->jump_level], Type); }
|
throw Type;
|
||||||
|
#else // !USE_TRY
|
||||||
|
#define CheckType(V) if (Type != V->GetType()) { \
|
||||||
|
PGLOBAL& g = Global; \
|
||||||
|
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); \
|
||||||
|
longjmp(g->jumper[g->jump_level], Type);
|
||||||
|
#endif // !USE_TRY
|
||||||
#else
|
#else
|
||||||
#define CheckType(V)
|
#define CheckType(V)
|
||||||
#endif
|
#endif
|
||||||
@@ -1019,12 +1026,20 @@ TYPE TYPVAL<TYPE>::SafeAdd(TYPE n1, TYPE n2)
|
|||||||
if ((n2 > 0) && (n < n1)) {
|
if ((n2 > 0) && (n < n1)) {
|
||||||
// Overflow
|
// Overflow
|
||||||
strcpy(g->Message, MSG(FIX_OVFLW_ADD));
|
strcpy(g->Message, MSG(FIX_OVFLW_ADD));
|
||||||
longjmp(g->jumper[g->jump_level], 138);
|
#if defined(USE_TRY)
|
||||||
} else if ((n2 < 0) && (n > n1)) {
|
throw 138;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 138);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if ((n2 < 0) && (n > n1)) {
|
||||||
// Underflow
|
// Underflow
|
||||||
strcpy(g->Message, MSG(FIX_UNFLW_ADD));
|
strcpy(g->Message, MSG(FIX_UNFLW_ADD));
|
||||||
longjmp(g->jumper[g->jump_level], 138);
|
#if defined(USE_TRY)
|
||||||
} // endif's n2
|
throw 138;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 138);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif's n2
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
} // end of SafeAdd
|
} // end of SafeAdd
|
||||||
@@ -1047,12 +1062,20 @@ TYPE TYPVAL<TYPE>::SafeMult(TYPE n1, TYPE n2)
|
|||||||
if (n > MinMaxVal(true)) {
|
if (n > MinMaxVal(true)) {
|
||||||
// Overflow
|
// Overflow
|
||||||
strcpy(g->Message, MSG(FIX_OVFLW_TIMES));
|
strcpy(g->Message, MSG(FIX_OVFLW_TIMES));
|
||||||
longjmp(g->jumper[g->jump_level], 138);
|
#if defined(USE_TRY)
|
||||||
} else if (n < MinMaxVal(false)) {
|
throw 138;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 138);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else if (n < MinMaxVal(false)) {
|
||||||
// Underflow
|
// Underflow
|
||||||
strcpy(g->Message, MSG(FIX_UNFLW_TIMES));
|
strcpy(g->Message, MSG(FIX_UNFLW_TIMES));
|
||||||
longjmp(g->jumper[g->jump_level], 138);
|
#if defined(USE_TRY)
|
||||||
} // endif's n2
|
throw 138;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 138);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif's n2
|
||||||
|
|
||||||
return (TYPE)n;
|
return (TYPE)n;
|
||||||
} // end of SafeMult
|
} // end of SafeMult
|
||||||
@@ -1432,8 +1455,16 @@ void TYPVAL<PSZ>::SetValue(int n)
|
|||||||
|
|
||||||
if (k > Len) {
|
if (k > Len) {
|
||||||
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
||||||
longjmp(g->jumper[g->jump_level], 138);
|
#if defined(USE_TRY)
|
||||||
} else
|
throw 138;
|
||||||
|
#else // !USE_TRY
|
||||||
|
#if defined(USE_TRY)
|
||||||
|
throw 138;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 138);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else
|
||||||
SetValue_psz(buf);
|
SetValue_psz(buf);
|
||||||
|
|
||||||
Null = false;
|
Null = false;
|
||||||
@@ -1486,8 +1517,12 @@ void TYPVAL<PSZ>::SetValue(longlong n)
|
|||||||
|
|
||||||
if (k > Len) {
|
if (k > Len) {
|
||||||
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
||||||
longjmp(g->jumper[g->jump_level], 138);
|
#if defined(USE_TRY)
|
||||||
} else
|
throw 138;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 138);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else
|
||||||
SetValue_psz(buf);
|
SetValue_psz(buf);
|
||||||
|
|
||||||
Null = false;
|
Null = false;
|
||||||
@@ -1529,8 +1564,12 @@ void TYPVAL<PSZ>::SetValue(double f)
|
|||||||
|
|
||||||
if (k > Len) {
|
if (k > Len) {
|
||||||
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
||||||
longjmp(g->jumper[g->jump_level], 138);
|
#if defined(USE_TRY)
|
||||||
} else
|
throw 138;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 138);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} else
|
||||||
SetValue_psz(buf);
|
SetValue_psz(buf);
|
||||||
|
|
||||||
Null = false;
|
Null = false;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/***************** Xindex C++ Class Xindex Code (.CPP) *****************/
|
/***************** Xindex C++ Class Xindex Code (.CPP) *****************/
|
||||||
/* Name: XINDEX.CPP Version 2.9 */
|
/* Name: XINDEX.CPP Version 3.0 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
|
/* (C) Copyright to the author Olivier BERTRAND 2004-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the class XINDEX implementation code. */
|
/* This file contains the class XINDEX implementation code. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -446,8 +446,12 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
|
|||||||
#if 0
|
#if 0
|
||||||
if (!dup->Step) {
|
if (!dup->Step) {
|
||||||
strcpy(g->Message, MSG(QUERY_CANCELLED));
|
strcpy(g->Message, MSG(QUERY_CANCELLED));
|
||||||
longjmp(g->jumper[g->jump_level], 99);
|
#if defined(USE_TRY)
|
||||||
} // endif Step
|
throw 99;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], 99);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
} // endif Step
|
||||||
#endif // 0
|
#endif // 0
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************ Xobject C++ Functions Source Code File (.CPP) ************/
|
/************ Xobject C++ Functions Source Code File (.CPP) ************/
|
||||||
/* Name: XOBJECT.CPP Version 2.4 */
|
/* Name: XOBJECT.CPP Version 2.5 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
|
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains base XOBJECT class functions. */
|
/* This file contains base XOBJECT class functions. */
|
||||||
/* Also here is the implementation of the CONSTANT class. */
|
/* Also here is the implementation of the CONSTANT class. */
|
||||||
@@ -84,7 +84,11 @@ double XOBJECT::GetFloatValue(void)
|
|||||||
CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
|
CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
|
||||||
{
|
{
|
||||||
if (!(Value = AllocateValue(g, value, (int)type)))
|
if (!(Value = AllocateValue(g, value, (int)type)))
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_CONST);
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_CONST;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_CONST);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
Constant = true;
|
Constant = true;
|
||||||
} // end of CONSTANT constructor
|
} // end of CONSTANT constructor
|
||||||
@@ -95,7 +99,11 @@ CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
|
|||||||
CONSTANT::CONSTANT(PGLOBAL g, int n)
|
CONSTANT::CONSTANT(PGLOBAL g, int n)
|
||||||
{
|
{
|
||||||
if (!(Value = AllocateValue(g, &n, TYPE_INT)))
|
if (!(Value = AllocateValue(g, &n, TYPE_INT)))
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_CONST);
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_CONST;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_CONST);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
Constant = true;
|
Constant = true;
|
||||||
} // end of CONSTANT constructor
|
} // end of CONSTANT constructor
|
||||||
@@ -117,7 +125,11 @@ void CONSTANT::Convert(PGLOBAL g, int newtype)
|
|||||||
{
|
{
|
||||||
if (Value->GetType() != newtype)
|
if (Value->GetType() != newtype)
|
||||||
if (!(Value = AllocateValue(g, Value, newtype)))
|
if (!(Value = AllocateValue(g, Value, newtype)))
|
||||||
longjmp(g->jumper[g->jump_level], TYPE_CONST);
|
#if defined(USE_TRY)
|
||||||
|
throw TYPE_CONST;
|
||||||
|
#else // !USE_TRY
|
||||||
|
longjmp(g->jumper[g->jump_level], TYPE_CONST);
|
||||||
|
#endif // !USE_TRY
|
||||||
|
|
||||||
} // end of Convert
|
} // end of Convert
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user