mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01: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:
parent
180fe61c1a
commit
e52bf14714
37 changed files with 1637 additions and 1471 deletions
|
@ -18,10 +18,10 @@ SET(CONNECT_PLUGIN_DYNAMIC "connect")
|
|||
|
||||
SET(CONNECT_SOURCES
|
||||
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
|
||||
filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp
|
||||
filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp
|
||||
filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp filter.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
|
||||
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
|
||||
|
|
|
@ -518,8 +518,12 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm)
|
|||
vp = valp;
|
||||
|
||||
} else if (opc != OP_EXIST) {
|
||||
sprintf(g->Message, MSG(MISSING_ARG), opc);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
sprintf(g->Message, MSG(MISSING_ARG), opc);
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_ARRAY;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
#endif // !USE_TRY
|
||||
} else // OP_EXIST
|
||||
return Nval > 0;
|
||||
|
||||
|
@ -681,15 +685,23 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
|
|||
{
|
||||
if (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
|
||||
|
||||
bool was = Vblp->IsCi();
|
||||
|
||||
if (was && !p) {
|
||||
strcpy(g->Message, MSG(BAD_SET_CASE));
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
} // endif Vblp
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_ARRAY;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
#endif // !USE_TRY
|
||||
} // endif Vblp
|
||||
|
||||
if (was || !p)
|
||||
return;
|
||||
|
@ -699,7 +711,11 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
|
|||
if (!was && Type == TYPE_STRING)
|
||||
// Must be resorted to eliminate duplicate strings
|
||||
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
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/************* BlkFil C++ Program Source Code File (.CPP) **************/
|
||||
/* PROGRAM NAME: BLKFIL */
|
||||
/* ------------- */
|
||||
/* Version 2.5 */
|
||||
/* Version 2.6 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2004-2017 */
|
||||
/* */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
|
@ -595,8 +595,12 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
|
|||
|
||||
if (Colp->GetResultType() != Type) {
|
||||
sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH));
|
||||
longjmp(g->jumper[g->jump_level], 99);
|
||||
} else if (Colp->GetValue()->IsCi())
|
||||
#if defined(USE_TRY)
|
||||
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
|
||||
|
||||
Sorted = Colp->IsSorted() > 0;
|
||||
|
|
|
@ -197,8 +197,12 @@ int COLBLK::GetLengthEx(void)
|
|||
void COLBLK::ReadColumn(PGLOBAL g)
|
||||
{
|
||||
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
} // end of ReadColumn
|
||||
#if defined(USE_TRY)
|
||||
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 */
|
||||
|
@ -208,8 +212,12 @@ void COLBLK::ReadColumn(PGLOBAL g)
|
|||
void COLBLK::WriteColumn(PGLOBAL g)
|
||||
{
|
||||
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
} // end of WriteColumn
|
||||
#if defined(USE_TRY)
|
||||
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. */
|
||||
|
@ -262,8 +270,12 @@ SPCBLK::SPCBLK(PCOLUMN cp)
|
|||
void SPCBLK::WriteColumn(PGLOBAL g)
|
||||
{
|
||||
sprintf(g->Message, MSG(SPCOL_READONLY), Name);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
} // end of WriteColumn
|
||||
#if defined(USE_TRY)
|
||||
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. */
|
||||
|
|
|
@ -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
|
||||
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 */
|
||||
|
||||
/***********************************************************************/
|
||||
/* 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. */
|
||||
/***********************************************************************/
|
||||
#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. */
|
||||
/***********************************************************************/
|
||||
PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
|
||||
{
|
||||
int rc;
|
||||
PTDB tdbp;
|
||||
PTABLE tabp;
|
||||
PDBUSER dup= PlgGetUser(g);
|
||||
volatile PCATLG cat= (dup) ? dup->Catalog : NULL; // Safe over longjmp
|
||||
{
|
||||
PTDB tdbp;
|
||||
PTABLE tabp;
|
||||
PDBUSER dup = PlgGetUser(g);
|
||||
volatile PCATLG cat = (dup) ? dup->Catalog : NULL; // Safe over longjmp
|
||||
|
||||
if (trace)
|
||||
printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat);
|
||||
if (trace)
|
||||
printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat);
|
||||
|
||||
if (!cat)
|
||||
return NULL;
|
||||
if (!cat)
|
||||
return NULL;
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
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) {
|
||||
tdbp= NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
tdbp = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Get table object from the catalog
|
||||
tabp= new(g) XTAB(name);
|
||||
// Get table object from the catalog
|
||||
tabp = new(g) XTAB(name);
|
||||
|
||||
if (trace)
|
||||
printf("CntGetTDB: tabp=%p\n", tabp);
|
||||
if (trace)
|
||||
printf("CntGetTDB: tabp=%p\n", tabp);
|
||||
|
||||
// Perhaps this should be made thread safe
|
||||
((MYCAT*)cat)->SetHandler(h);
|
||||
// Perhaps this should be made thread safe
|
||||
((MYCAT*)cat)->SetHandler(h);
|
||||
|
||||
if (!(tdbp= cat->GetTable(g, tabp, mode)))
|
||||
printf("CntGetTDB: %s\n", g->Message);
|
||||
if (!(tdbp = cat->GetTable(g, tabp, mode)))
|
||||
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)
|
||||
printf("Returning tdbp=%p mode=%d\n", tdbp, mode);
|
||||
|
||||
g->jump_level--;
|
||||
return tdbp;
|
||||
} // end of CntGetTDB
|
||||
|
||||
|
@ -239,7 +252,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
|||
bool del, PHC)
|
||||
{
|
||||
char *p;
|
||||
int i, n, rc;
|
||||
int i, n;
|
||||
bool rcop= true;
|
||||
PCOL colp;
|
||||
//PCOLUMN cp;
|
||||
|
@ -254,15 +267,19 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
|||
return true;
|
||||
} // endif tdbp
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif jump_level
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
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) {
|
||||
goto err;
|
||||
} // endif rc
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!c1) {
|
||||
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)
|
||||
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
|
||||
|
||||
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()) {
|
||||
if (colp->InitValue(g))
|
||||
goto err;
|
||||
#if defined(USE_TRY)
|
||||
throw 2;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (mode == MODE_INSERT)
|
||||
// Allow type conversion
|
||||
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
|
||||
} // endfor colp
|
||||
|
@ -309,8 +338,12 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
|||
|
||||
if (!(utp= (PTDBASE)tdbp->Duplicate(g))) {
|
||||
sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName());
|
||||
goto err;
|
||||
} // endif tp
|
||||
#if defined(USE_TRY)
|
||||
throw 4;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
} // endif tp
|
||||
|
||||
if (!c2)
|
||||
// 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()) {
|
||||
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))
|
||||
goto err;
|
||||
#if defined(USE_TRY)
|
||||
throw 6;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
|
||||
} // 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 (tdbp->OpenDB(g)) {
|
||||
printf("%s\n", g->Message);
|
||||
goto err;
|
||||
} else
|
||||
#if defined(USE_TRY)
|
||||
throw 7;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
tdbp->SetNext(NULL);
|
||||
|
||||
} // endif mode
|
||||
|
||||
rcop= false;
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
#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
|
||||
return rcop;
|
||||
} // end of CntOpenTable
|
||||
|
||||
|
@ -391,23 +445,27 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
|
|||
RCODE rc= RC_OK;
|
||||
PCOL colp;
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
if (trace) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
printf("EvalColumns: %s\n", g->Message);
|
||||
} // endif
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
if (trace) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
printf("EvalColumns: %s\n", g->Message);
|
||||
} // endif
|
||||
|
||||
return RC_FX;
|
||||
} // endif jump_level
|
||||
return RC_FX;
|
||||
} // endif jump_level
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
if (trace)
|
||||
printf("Error reading columns: %s\n", g->Message);
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
if (trace)
|
||||
printf("Error reading columns: %s\n", g->Message);
|
||||
|
||||
rc= RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
rc = RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
for (colp= tdbp->GetColumns(); rc == RC_OK && colp;
|
||||
colp= colp->GetNext()) {
|
||||
|
@ -421,8 +479,19 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
|
|||
|
||||
} // endfor colp
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
#if defined(USE_TRY)
|
||||
} 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;
|
||||
} // end of EvalColumns
|
||||
|
||||
|
@ -445,16 +514,20 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
|
|||
((PTDBASE)tdbp)->ResetKindex(g, NULL);
|
||||
} // endif index
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return RC_FX;
|
||||
} // endif jump_level
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
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) {
|
||||
rc= RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
if ((setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
rc = RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Do it now to avoid double eval when filtering
|
||||
for (PCOL colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
|
||||
|
@ -470,8 +543,17 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
|
|||
if (rc == RC_OK)
|
||||
rc= EvalColumns(g, tdbp, false);
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
#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
|
||||
return rc;
|
||||
} // end of CntReadNext
|
||||
|
||||
|
@ -487,17 +569,21 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
|
|||
if (!tdbp)
|
||||
return RC_FX;
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return RC_FX;
|
||||
} // endif jump_level
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
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) {
|
||||
printf("%s\n", g->Message);
|
||||
rc= RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
printf("%s\n", g->Message);
|
||||
rc = RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Store column values in table write buffer(s)
|
||||
for (colp= tdbp->GetSetCols(); colp; colp= colp->GetNext())
|
||||
|
@ -511,8 +597,18 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
|
|||
// Return result code from write operation
|
||||
rc= (RCODE)tdbp->WriteDB(g);
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
#if defined(USE_TRY)
|
||||
} 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;
|
||||
} // end of CntWriteRow
|
||||
|
||||
|
@ -598,49 +694,59 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
|
|||
break;
|
||||
} // endswitch rc
|
||||
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
rc= RC_FX;
|
||||
goto err;
|
||||
} // endif
|
||||
#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 = RC_FX;
|
||||
goto err;
|
||||
} // endif
|
||||
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
rc= RC_FX;
|
||||
g->jump_level--;
|
||||
goto err;
|
||||
} // endif
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
rc = RC_FX;
|
||||
goto err;
|
||||
} // endif
|
||||
#endif // !USE_TRY
|
||||
|
||||
// This will close the table file(s) and also finalize write
|
||||
// operations such as Insert, Update, or Delete.
|
||||
tdbp->SetAbort(abort);
|
||||
tdbp->CloseDB(g);
|
||||
tdbp->SetAbort(false);
|
||||
g->jump_level--;
|
||||
|
||||
if (trace > 1)
|
||||
printf("Table %s closed\n", tdbp->GetName());
|
||||
|
||||
//if (!((PTDBDOX)tdbp)->GetModified())
|
||||
// return 0;
|
||||
if (!nox && tdbp->GetMode() != MODE_READ && tdbp->GetMode() != MODE_ANY) {
|
||||
if (trace > 1)
|
||||
printf("About to reset opt\n");
|
||||
|
||||
if (nox || tdbp->GetMode() == MODE_READ || tdbp->GetMode() == MODE_ANY)
|
||||
return 0;
|
||||
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
|
||||
|
||||
} // 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)
|
||||
printf("About to reset opt\n");
|
||||
|
||||
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);
|
||||
htrc("Done rc=%d\n", rc);
|
||||
|
||||
return (rc == RC_OK || rc == RC_INFO) ? 0 : rc;
|
||||
} // end of CntCloseTable
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*********** File AM Txt C++ Program Source Code File (.CPP) ***********/
|
||||
/* PROGRAM NAME: FILAMTXT */
|
||||
/* ------------- */
|
||||
/* Version 1.6 */
|
||||
/* Version 1.7 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
|
||||
/* */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
|
@ -1161,13 +1161,21 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
|
|||
if (rename(filename, filetemp)) { // Save file for security
|
||||
sprintf(g->Message, MSG(RENAME_ERROR),
|
||||
filename, filetemp, strerror(errno));
|
||||
longjmp(g->jumper[g->jump_level], 51);
|
||||
} else if (rename(tempname, filename)) {
|
||||
#if defined(USE_TRY)
|
||||
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),
|
||||
tempname, filename, strerror(errno));
|
||||
rc = rename(filetemp, filename); // Restore saved file
|
||||
longjmp(g->jumper[g->jump_level], 52);
|
||||
} else if (remove(filetemp)) {
|
||||
#if defined(USE_TRY)
|
||||
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),
|
||||
filetemp, strerror(errno));
|
||||
rc = RC_INFO; // Acceptable
|
||||
|
|
|
@ -560,6 +560,8 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g)
|
|||
/***********************************************************************/
|
||||
bool VCTFAM::InitInsert(PGLOBAL g)
|
||||
{
|
||||
bool rc = false;
|
||||
|
||||
// We come here in MODE_INSERT only
|
||||
if (Last == Nrec) {
|
||||
CurBlk = Block;
|
||||
|
@ -573,27 +575,44 @@ bool VCTFAM::InitInsert(PGLOBAL g)
|
|||
CurBlk = Block - 1;
|
||||
CurNum = Last;
|
||||
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Prepare error return
|
||||
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) {
|
||||
g->jump_level--;
|
||||
return true;
|
||||
} // endif
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
g->jump_level--;
|
||||
return true;
|
||||
} // endif
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Last block must be updated by new values
|
||||
for (; cp; cp = (PVCTCOL)cp->Next)
|
||||
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
|
||||
|
||||
// We are not currently using a temporary file for Insert
|
||||
T_Stream = Stream;
|
||||
return false;
|
||||
if (!rc)
|
||||
// We are not currently using a temporary file for Insert
|
||||
T_Stream = Stream;
|
||||
|
||||
return rc;
|
||||
} // end of InitInsert
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -1107,7 +1126,11 @@ void VCTFAM::CloseTableFile(PGLOBAL g, bool abort)
|
|||
} else if (AddBlock) {
|
||||
// Last block was not written
|
||||
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
|
||||
|
||||
} else if (mode == MODE_UPDATE) {
|
||||
|
@ -1528,7 +1551,7 @@ bool VCMFAM::AllocateBuffer(PGLOBAL g)
|
|||
/***********************************************************************/
|
||||
bool VCMFAM::InitInsert(PGLOBAL g)
|
||||
{
|
||||
int rc;
|
||||
bool rc = false;
|
||||
volatile PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
|
||||
|
||||
// We come here in MODE_INSERT only
|
||||
|
@ -1542,23 +1565,38 @@ bool VCMFAM::InitInsert(PGLOBAL g)
|
|||
CurNum = Last;
|
||||
} // endif Last
|
||||
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Prepare error return
|
||||
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) {
|
||||
g->jump_level--;
|
||||
return true;
|
||||
} // endif
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
g->jump_level--;
|
||||
return true;
|
||||
} // endif
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Initialize the column block pointer
|
||||
for (; cp; cp = (PVCTCOL)cp->Next)
|
||||
cp->ReadBlock(g);
|
||||
|
||||
g->jump_level--;
|
||||
return false;
|
||||
#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
|
||||
return rc;
|
||||
} // end of InitInsert
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -2503,7 +2541,11 @@ void VECFAM::CloseTableFile(PGLOBAL g, bool abort)
|
|||
if (wrc != RC_FX)
|
||||
rc = ResetTableSize(g, Block, Last);
|
||||
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) {
|
||||
if (UseTemp && !InitUpdate && !Abort) {
|
||||
|
@ -4164,8 +4206,12 @@ void BGVFAM::CloseTableFile(PGLOBAL g, bool abort)
|
|||
} else if (AddBlock) {
|
||||
// Last block was not written
|
||||
rc = ResetTableSize(g, CurBlk, Nrec);
|
||||
longjmp(g->jumper[g->jump_level], 44);
|
||||
} // endif
|
||||
#if defined(USE_TRY)
|
||||
throw 44;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 44);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
|
||||
} else if (mode == MODE_UPDATE) {
|
||||
// Write back to file any pending modifications
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/***************** 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. */
|
||||
/***********************************************************************/
|
||||
|
@ -87,8 +87,12 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc)
|
|||
case OP_EXIST: bt = 0x00; break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
} // endswitch opc
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_ARRAY;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch opc
|
||||
|
||||
return bt;
|
||||
} // end of OpBmp
|
||||
|
@ -1711,7 +1715,11 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
|
|||
break; // Remove eventual ending separator(s)
|
||||
|
||||
// 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;
|
||||
fp = fp->Next;
|
||||
|
@ -1744,7 +1752,11 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
|
|||
// return TRUE;
|
||||
|
||||
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)
|
||||
htrc("PlugFilter filp=%p result=%d\n",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/***********************************************************************/
|
||||
/* 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 */
|
||||
void *Sarea; /* Points to work area */
|
||||
uint Sarea_Size; /* Work area size */
|
||||
PACTIVITY Activityp, ActivityStart;
|
||||
PACTIVITY Activityp;
|
||||
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 */
|
||||
short Alchecked; /* Checked for ALTER */
|
||||
short Mrr; /* True when doing mrr */
|
||||
|
|
|
@ -1895,40 +1895,62 @@ int ha_connect::OpenTable(PGLOBAL g, bool del)
|
|||
bool ha_connect::CheckColumnList(PGLOBAL g)
|
||||
{
|
||||
// Check the list of used fields (columns)
|
||||
int rc;
|
||||
bool brc= false;
|
||||
PCOL colp;
|
||||
Field* *field;
|
||||
Field* fp;
|
||||
MY_BITMAP *map= table->read_set;
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif jump_level
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
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++)
|
||||
if (bitmap_is_set(map, fp->field_index)) {
|
||||
if (!(colp= tdbp->ColDB(g, (PSZ)fp->field_name, 0))) {
|
||||
sprintf(g->Message, "Column %s not found in %s",
|
||||
fp->field_name, tdbp->GetName());
|
||||
brc= true;
|
||||
goto fin;
|
||||
} // endif colp
|
||||
#if defined(USE_TRY)
|
||||
throw 1;
|
||||
#else // !USE_TRY
|
||||
brc = true;
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
} // endif colp
|
||||
|
||||
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
|
||||
} // endif
|
||||
|
||||
} else
|
||||
brc= true;
|
||||
#if defined(USE_TRY)
|
||||
} 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:
|
||||
g->jump_level--;
|
||||
fin:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
return brc;
|
||||
} // end of CheckColumnList
|
||||
|
||||
|
@ -3054,7 +3076,6 @@ const COND *ha_connect::cond_push(const COND *cond)
|
|||
DBUG_ENTER("ha_connect::cond_push");
|
||||
|
||||
if (tdbp) {
|
||||
int rc;
|
||||
PGLOBAL& g= xp->g;
|
||||
AMT tty= tdbp->GetAmType();
|
||||
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_PLG || tty == TYPE_AM_JDBC || x);
|
||||
|
||||
// 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 defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// 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 ((rc= setjmp(g->jumper[++g->jump_level])) != 0)
|
||||
goto fin;
|
||||
if (setjmp(g->jumper[++g->jump_level]))
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (b) {
|
||||
PCFIL filp;
|
||||
|
@ -3078,7 +3103,7 @@ const COND *ha_connect::cond_push(const COND *cond)
|
|||
|
||||
if ((filp= tdbp->GetCondFil()) && filp->Cond == cond &&
|
||||
filp->Idx == active_index && filp->Type == tty)
|
||||
goto fin; // Already done
|
||||
goto fin;
|
||||
|
||||
filp= new(g) CONDFIL(cond, active_index, tty);
|
||||
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)
|
||||
tdbp->SetFilter(CondFilter(g, (Item *)cond));
|
||||
|
||||
fin:
|
||||
g->jump_level--;
|
||||
} // endif tdbp
|
||||
#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
|
||||
|
||||
fin:;
|
||||
#else // !USE_TRY
|
||||
fin:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
} // endif tdbp
|
||||
|
||||
// Let MySQL do the filtering
|
||||
DBUG_RETURN(cond);
|
||||
|
@ -3263,6 +3299,22 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
|
|||
PGLOBAL& g= xp->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
|
||||
dup->Check &= ~CHK_OPT;
|
||||
tdbp= GetTDB(g);
|
||||
|
@ -3284,6 +3336,20 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
|
|||
} else if (!tdbp)
|
||||
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;
|
||||
} // end of optimize
|
||||
|
||||
|
@ -5292,7 +5358,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||
if (topt->oplist) {
|
||||
host= GetListOption(g, "host", topt->oplist, "localhost");
|
||||
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.
|
||||
db= GetListOption(g, "database", topt->oplist, db);
|
||||
col= GetListOption(g, "colist", topt->oplist, col);
|
||||
|
@ -5329,22 +5395,26 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||
#endif // ZIP_SUPPORT
|
||||
} else {
|
||||
host= "localhost";
|
||||
user= (ttp == TAB_ODBC ? NULL : "root");
|
||||
user= ((ttp == TAB_ODBC || ttp == TAB_JDBC) ? NULL : "root");
|
||||
} // endif option_list
|
||||
|
||||
if (!(shm= (char*)db))
|
||||
db= table_s->db.str; // Default value
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
goto jer;
|
||||
} // endif jump_level
|
||||
|
||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Check table type
|
||||
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);
|
||||
} else if (ttp == TAB_NIY) {
|
||||
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;
|
||||
} // endif ttp
|
||||
|
||||
|
@ -5365,8 +5435,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||
|
||||
if (!tbl) {
|
||||
strcpy(g->Message, "Missing table list");
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
goto err;
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} // endif tbl
|
||||
|
||||
tab= PlugDup(g, tbl);
|
||||
|
@ -5558,320 +5628,320 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||
if (src && fnc != FNC_NO) {
|
||||
strcpy(g->Message, "Cannot make catalog table from srcdef");
|
||||
ok= false;
|
||||
} // endif src
|
||||
} // endif src
|
||||
|
||||
if (ok) {
|
||||
char *cnm, *rem, *dft, *xtra, *key, *fmt;
|
||||
int i, len, prec, dec, typ, flg;
|
||||
if (ok) {
|
||||
char *cnm, *rem, *dft, *xtra, *key, *fmt;
|
||||
int i, len, prec, dec, typ, flg;
|
||||
|
||||
// if (cat)
|
||||
// cat->SetDataPath(g, table_s->db.str);
|
||||
// else
|
||||
// return HA_ERR_INTERNAL_ERROR; // Should never happen
|
||||
// if (cat)
|
||||
// cat->SetDataPath(g, table_s->db.str);
|
||||
// else
|
||||
// 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) {
|
||||
qrp= SrcColumns(g, host, db, user, pwd, src, port);
|
||||
qrp = SrcColumns(g, host, db, user, pwd, src, port);
|
||||
|
||||
if (qrp && ttp == TAB_OCCUR)
|
||||
if (OcrSrcCols(g, qrp, col, ocl, rnk)) {
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
goto err;
|
||||
} // endif OcrSrcCols
|
||||
if (qrp && ttp == TAB_OCCUR)
|
||||
if (OcrSrcCols(g, qrp, col, ocl, rnk)) {
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} // endif OcrSrcCols
|
||||
|
||||
} else switch (ttp) {
|
||||
case TAB_DBF:
|
||||
qrp= DBFColumns(g, dpath, fn, fnc == FNC_COL);
|
||||
break;
|
||||
} else switch (ttp) {
|
||||
case TAB_DBF:
|
||||
qrp = DBFColumns(g, dpath, fn, fnc == FNC_COL);
|
||||
break;
|
||||
#if defined(ODBC_SUPPORT)
|
||||
case TAB_ODBC:
|
||||
switch (fnc) {
|
||||
case FNC_NO:
|
||||
case FNC_COL:
|
||||
if (src) {
|
||||
qrp= ODBCSrcCols(g, dsn, (char*)src, sop);
|
||||
src= NULL; // for next tests
|
||||
} else
|
||||
qrp= ODBCColumns(g, dsn, shm, tab, NULL,
|
||||
mxr, fnc == FNC_COL, sop);
|
||||
case TAB_ODBC:
|
||||
switch (fnc) {
|
||||
case FNC_NO:
|
||||
case FNC_COL:
|
||||
if (src) {
|
||||
qrp = ODBCSrcCols(g, dsn, (char*)src, sop);
|
||||
src = NULL; // for next tests
|
||||
} else
|
||||
qrp = ODBCColumns(g, dsn, shm, tab, NULL,
|
||||
mxr, fnc == FNC_COL, sop);
|
||||
|
||||
break;
|
||||
case FNC_TABLE:
|
||||
qrp= ODBCTables(g, dsn, shm, tab, NULL, mxr, true, sop);
|
||||
break;
|
||||
case FNC_DSN:
|
||||
qrp= ODBCDataSources(g, mxr, true);
|
||||
break;
|
||||
case FNC_DRIVER:
|
||||
qrp= ODBCDrivers(g, mxr, true);
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, "invalid catfunc %s", fncn);
|
||||
break;
|
||||
} // endswitch info
|
||||
break;
|
||||
case FNC_TABLE:
|
||||
qrp = ODBCTables(g, dsn, shm, tab, NULL, mxr, true, sop);
|
||||
break;
|
||||
case FNC_DSN:
|
||||
qrp = ODBCDataSources(g, mxr, true);
|
||||
break;
|
||||
case FNC_DRIVER:
|
||||
qrp = ODBCDrivers(g, mxr, true);
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, "invalid catfunc %s", fncn);
|
||||
break;
|
||||
} // endswitch info
|
||||
|
||||
break;
|
||||
break;
|
||||
#endif // ODBC_SUPPORT
|
||||
#if defined(JDBC_SUPPORT)
|
||||
case TAB_JDBC:
|
||||
switch (fnc) {
|
||||
case FNC_NO:
|
||||
case FNC_COL:
|
||||
if (src) {
|
||||
qrp= JDBCSrcCols(g, (char*)src, sjp);
|
||||
src= NULL; // for next tests
|
||||
} else
|
||||
qrp= JDBCColumns(g, shm, tab, NULL, mxr, fnc == FNC_COL, sjp);
|
||||
case FNC_NO:
|
||||
case FNC_COL:
|
||||
if (src) {
|
||||
qrp = JDBCSrcCols(g, (char*)src, sjp);
|
||||
src = NULL; // for next tests
|
||||
} else
|
||||
qrp = JDBCColumns(g, shm, tab, NULL, mxr, fnc == FNC_COL, sjp);
|
||||
|
||||
break;
|
||||
case FNC_TABLE:
|
||||
qrp= JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp);
|
||||
break;
|
||||
break;
|
||||
case FNC_TABLE:
|
||||
qrp = JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp);
|
||||
break;
|
||||
#if 0
|
||||
case FNC_DSN:
|
||||
qrp= JDBCDataSources(g, mxr, true);
|
||||
break;
|
||||
case FNC_DSN:
|
||||
qrp = JDBCDataSources(g, mxr, true);
|
||||
break;
|
||||
#endif // 0
|
||||
case FNC_DRIVER:
|
||||
qrp= JDBCDrivers(g, mxr, true);
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, "invalid catfunc %s", fncn);
|
||||
break;
|
||||
case FNC_DRIVER:
|
||||
qrp = JDBCDrivers(g, mxr, true);
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, "invalid catfunc %s", fncn);
|
||||
break;
|
||||
} // endswitch info
|
||||
|
||||
break;
|
||||
#endif // JDBC_SUPPORT
|
||||
case TAB_MYSQL:
|
||||
qrp= MyColumns(g, thd, host, db, user, pwd, tab,
|
||||
NULL, port, fnc == FNC_COL);
|
||||
break;
|
||||
case TAB_CSV:
|
||||
qrp = MyColumns(g, thd, host, db, user, pwd, tab,
|
||||
NULL, port, fnc == FNC_COL);
|
||||
break;
|
||||
case TAB_CSV:
|
||||
qrp = CSVColumns(g, dpath, topt, fnc == FNC_COL);
|
||||
break;
|
||||
break;
|
||||
#if defined(__WIN__)
|
||||
case TAB_WMI:
|
||||
qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL);
|
||||
break;
|
||||
case TAB_WMI:
|
||||
qrp = WMIColumns(g, nsp, cls, fnc == FNC_COL);
|
||||
break;
|
||||
#endif // __WIN__
|
||||
case TAB_PRX:
|
||||
case TAB_TBL:
|
||||
case TAB_XCL:
|
||||
case TAB_OCCUR:
|
||||
bif= fnc == FNC_COL;
|
||||
qrp= TabColumns(g, thd, db, tab, bif);
|
||||
case TAB_PRX:
|
||||
case TAB_TBL:
|
||||
case TAB_XCL:
|
||||
case TAB_OCCUR:
|
||||
bif = fnc == FNC_COL;
|
||||
qrp = TabColumns(g, thd, db, tab, bif);
|
||||
|
||||
if (!qrp && bif && fnc != FNC_COL) // tab is a view
|
||||
qrp= MyColumns(g, thd, host, db, user, pwd, tab, NULL, port, false);
|
||||
if (!qrp && bif && fnc != FNC_COL) // tab is a view
|
||||
qrp = MyColumns(g, thd, host, db, user, pwd, tab, NULL, port, false);
|
||||
|
||||
if (qrp && ttp == TAB_OCCUR && fnc != FNC_COL)
|
||||
if (OcrColumns(g, qrp, col, ocl, rnk)) {
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
goto err;
|
||||
} // endif OcrColumns
|
||||
if (qrp && ttp == TAB_OCCUR && fnc != FNC_COL)
|
||||
if (OcrColumns(g, qrp, col, ocl, rnk)) {
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} // endif OcrColumns
|
||||
|
||||
break;
|
||||
break;
|
||||
#if defined(PIVOT_SUPPORT)
|
||||
case TAB_PIVOT:
|
||||
qrp= PivotColumns(g, tab, src, pic, fcl, skc, host, db, user, pwd, port);
|
||||
break;
|
||||
case TAB_PIVOT:
|
||||
qrp = PivotColumns(g, tab, src, pic, fcl, skc, host, db, user, pwd, port);
|
||||
break;
|
||||
#endif // PIVOT_SUPPORT
|
||||
case TAB_VIR:
|
||||
qrp= VirColumns(g, fnc == FNC_COL);
|
||||
break;
|
||||
case TAB_JSON:
|
||||
qrp= JSONColumns(g, (char*)db, topt, fnc == FNC_COL);
|
||||
break;
|
||||
case TAB_VIR:
|
||||
qrp = VirColumns(g, fnc == FNC_COL);
|
||||
break;
|
||||
case TAB_JSON:
|
||||
qrp = JSONColumns(g, (char*)db, topt, fnc == FNC_COL);
|
||||
break;
|
||||
#if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT)
|
||||
case TAB_XML:
|
||||
qrp= XMLColumns(g, (char*)db, tab, topt, fnc == FNC_COL);
|
||||
break;
|
||||
case TAB_XML:
|
||||
qrp = XMLColumns(g, (char*)db, tab, topt, fnc == FNC_COL);
|
||||
break;
|
||||
#endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT
|
||||
case TAB_OEM:
|
||||
qrp= OEMColumns(g, topt, tab, (char*)db, fnc == FNC_COL);
|
||||
break;
|
||||
default:
|
||||
strcpy(g->Message, "System error during assisted discovery");
|
||||
break;
|
||||
} // endswitch ttp
|
||||
case TAB_OEM:
|
||||
qrp = OEMColumns(g, topt, tab, (char*)db, fnc == FNC_COL);
|
||||
break;
|
||||
default:
|
||||
strcpy(g->Message, "System error during assisted discovery");
|
||||
break;
|
||||
} // endswitch ttp
|
||||
|
||||
if (!qrp) {
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
goto err;
|
||||
} // endif !qrp
|
||||
if (!qrp) {
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} // endif !qrp
|
||||
|
||||
if (fnc != FNC_NO || src || ttp == TAB_PIVOT) {
|
||||
// Catalog like table
|
||||
for (crp= qrp->Colresp; !rc && crp; crp= crp->Next) {
|
||||
cnm= (ttp == TAB_PIVOT) ? crp->Name : encode(g, crp->Name);
|
||||
typ= crp->Type;
|
||||
len= crp->Length;
|
||||
dec= crp->Prec;
|
||||
flg= crp->Flag;
|
||||
v= (crp->Kdata->IsUnsigned()) ? 'U' : crp->Var;
|
||||
tm= (crp->Kdata->IsNullable()) ? 0 : NOT_NULL_FLAG;
|
||||
if (fnc != FNC_NO || src || ttp == TAB_PIVOT) {
|
||||
// Catalog like table
|
||||
for (crp = qrp->Colresp; !rc && crp; crp = crp->Next) {
|
||||
cnm = (ttp == TAB_PIVOT) ? crp->Name : encode(g, crp->Name);
|
||||
typ = crp->Type;
|
||||
len = crp->Length;
|
||||
dec = crp->Prec;
|
||||
flg = crp->Flag;
|
||||
v = (crp->Kdata->IsUnsigned()) ? 'U' : crp->Var;
|
||||
tm = (crp->Kdata->IsNullable()) ? 0 : NOT_NULL_FLAG;
|
||||
|
||||
if (!len && typ == TYPE_STRING)
|
||||
len= 256; // STRBLK's have 0 length
|
||||
if (!len && typ == TYPE_STRING)
|
||||
len = 256; // STRBLK's have 0 length
|
||||
|
||||
// Now add the field
|
||||
if (add_field(&sql, cnm, typ, len, dec, NULL, tm,
|
||||
NULL, NULL, NULL, NULL, flg, dbf, v))
|
||||
rc= HA_ERR_OUT_OF_MEM;
|
||||
} // endfor crp
|
||||
// Now add the field
|
||||
if (add_field(&sql, cnm, typ, len, dec, NULL, tm,
|
||||
NULL, NULL, NULL, NULL, flg, dbf, v))
|
||||
rc = HA_ERR_OUT_OF_MEM;
|
||||
} // endfor crp
|
||||
|
||||
} else {
|
||||
char *schem= NULL;
|
||||
char *tn= NULL;
|
||||
} else {
|
||||
char *schem = NULL;
|
||||
char *tn = NULL;
|
||||
|
||||
// Not a catalog table
|
||||
if (!qrp->Nblin) {
|
||||
if (tab)
|
||||
sprintf(g->Message, "Cannot get columns from %s", tab);
|
||||
else
|
||||
strcpy(g->Message, "Fail to retrieve columns");
|
||||
// Not a catalog table
|
||||
if (!qrp->Nblin) {
|
||||
if (tab)
|
||||
sprintf(g->Message, "Cannot get columns from %s", tab);
|
||||
else
|
||||
strcpy(g->Message, "Fail to retrieve columns");
|
||||
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
goto err;
|
||||
} // endif !nblin
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} // endif !nblin
|
||||
|
||||
for (i= 0; !rc && i < qrp->Nblin; i++) {
|
||||
typ= len= prec= dec= 0;
|
||||
tm= NOT_NULL_FLAG;
|
||||
cnm= (char*)"noname";
|
||||
dft= xtra= key= fmt= tn= NULL;
|
||||
v= ' ';
|
||||
rem= NULL;
|
||||
for (i = 0; !rc && i < qrp->Nblin; i++) {
|
||||
typ = len = prec = dec = 0;
|
||||
tm = NOT_NULL_FLAG;
|
||||
cnm = (char*)"noname";
|
||||
dft = xtra = key = fmt = tn = NULL;
|
||||
v = ' ';
|
||||
rem = NULL;
|
||||
|
||||
for (crp= qrp->Colresp; crp; crp= crp->Next)
|
||||
switch (crp->Fld) {
|
||||
case FLD_NAME:
|
||||
if (ttp == TAB_PRX ||
|
||||
(ttp == TAB_CSV && topt->data_charset &&
|
||||
(!stricmp(topt->data_charset, "UTF8") ||
|
||||
!stricmp(topt->data_charset, "UTF-8"))))
|
||||
cnm= crp->Kdata->GetCharValue(i);
|
||||
else
|
||||
cnm= encode(g, crp->Kdata->GetCharValue(i));
|
||||
for (crp = qrp->Colresp; crp; crp = crp->Next)
|
||||
switch (crp->Fld) {
|
||||
case FLD_NAME:
|
||||
if (ttp == TAB_PRX ||
|
||||
(ttp == TAB_CSV && topt->data_charset &&
|
||||
(!stricmp(topt->data_charset, "UTF8") ||
|
||||
!stricmp(topt->data_charset, "UTF-8"))))
|
||||
cnm = crp->Kdata->GetCharValue(i);
|
||||
else
|
||||
cnm = encode(g, crp->Kdata->GetCharValue(i));
|
||||
|
||||
break;
|
||||
case FLD_TYPE:
|
||||
typ= crp->Kdata->GetIntValue(i);
|
||||
v = (crp->Nulls) ? crp->Nulls[i] : 0;
|
||||
break;
|
||||
break;
|
||||
case FLD_TYPE:
|
||||
typ = crp->Kdata->GetIntValue(i);
|
||||
v = (crp->Nulls) ? crp->Nulls[i] : 0;
|
||||
break;
|
||||
case FLD_TYPENAME:
|
||||
tn= crp->Kdata->GetCharValue(i);
|
||||
tn = crp->Kdata->GetCharValue(i);
|
||||
break;
|
||||
case FLD_PREC:
|
||||
// PREC must be always before LENGTH
|
||||
len= prec= crp->Kdata->GetIntValue(i);
|
||||
break;
|
||||
case FLD_LENGTH:
|
||||
len= crp->Kdata->GetIntValue(i);
|
||||
break;
|
||||
case FLD_SCALE:
|
||||
// PREC must be always before LENGTH
|
||||
len = prec = crp->Kdata->GetIntValue(i);
|
||||
break;
|
||||
case FLD_LENGTH:
|
||||
len = crp->Kdata->GetIntValue(i);
|
||||
break;
|
||||
case FLD_SCALE:
|
||||
dec = (!crp->Kdata->IsNull(i)) ? crp->Kdata->GetIntValue(i) : -1;
|
||||
break;
|
||||
case FLD_NULL:
|
||||
if (crp->Kdata->GetIntValue(i))
|
||||
tm= 0; // Nullable
|
||||
break;
|
||||
case FLD_NULL:
|
||||
if (crp->Kdata->GetIntValue(i))
|
||||
tm = 0; // Nullable
|
||||
|
||||
break;
|
||||
case FLD_FORMAT:
|
||||
fmt= (crp->Kdata) ? crp->Kdata->GetCharValue(i) : NULL;
|
||||
break;
|
||||
case FLD_REM:
|
||||
rem= crp->Kdata->GetCharValue(i);
|
||||
break;
|
||||
// case FLD_CHARSET:
|
||||
// No good because remote table is already translated
|
||||
// if (*(csn= crp->Kdata->GetCharValue(i)))
|
||||
// cs= get_charset_by_name(csn, 0);
|
||||
break;
|
||||
case FLD_FORMAT:
|
||||
fmt = (crp->Kdata) ? crp->Kdata->GetCharValue(i) : NULL;
|
||||
break;
|
||||
case FLD_REM:
|
||||
rem = crp->Kdata->GetCharValue(i);
|
||||
break;
|
||||
// case FLD_CHARSET:
|
||||
// No good because remote table is already translated
|
||||
// if (*(csn= crp->Kdata->GetCharValue(i)))
|
||||
// cs= get_charset_by_name(csn, 0);
|
||||
|
||||
// break;
|
||||
case FLD_DEFAULT:
|
||||
dft= crp->Kdata->GetCharValue(i);
|
||||
break;
|
||||
case FLD_EXTRA:
|
||||
xtra= crp->Kdata->GetCharValue(i);
|
||||
// break;
|
||||
case FLD_DEFAULT:
|
||||
dft = crp->Kdata->GetCharValue(i);
|
||||
break;
|
||||
case FLD_EXTRA:
|
||||
xtra = crp->Kdata->GetCharValue(i);
|
||||
|
||||
// Auto_increment is not supported yet
|
||||
if (!stricmp(xtra, "AUTO_INCREMENT"))
|
||||
xtra= NULL;
|
||||
// Auto_increment is not supported yet
|
||||
if (!stricmp(xtra, "AUTO_INCREMENT"))
|
||||
xtra = NULL;
|
||||
|
||||
break;
|
||||
case FLD_KEY:
|
||||
if (ttp == TAB_VIR)
|
||||
key= crp->Kdata->GetCharValue(i);
|
||||
break;
|
||||
case FLD_KEY:
|
||||
if (ttp == TAB_VIR)
|
||||
key = crp->Kdata->GetCharValue(i);
|
||||
|
||||
break;
|
||||
case FLD_SCHEM:
|
||||
break;
|
||||
case FLD_SCHEM:
|
||||
#if defined(ODBC_SUPPORT) || defined(JDBC_SUPPORT)
|
||||
if ((ttp == TAB_ODBC || ttp == TAB_JDBC) && crp->Kdata) {
|
||||
if (schem && stricmp(schem, crp->Kdata->GetCharValue(i))) {
|
||||
sprintf(g->Message,
|
||||
"Several %s tables found, specify DBNAME", tab);
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
goto err;
|
||||
} else if (!schem)
|
||||
schem= crp->Kdata->GetCharValue(i);
|
||||
if ((ttp == TAB_ODBC || ttp == TAB_JDBC) && crp->Kdata) {
|
||||
if (schem && stricmp(schem, crp->Kdata->GetCharValue(i))) {
|
||||
sprintf(g->Message,
|
||||
"Several %s tables found, specify DBNAME", tab);
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} else if (!schem)
|
||||
schem = crp->Kdata->GetCharValue(i);
|
||||
|
||||
} // endif ttp
|
||||
} // endif ttp
|
||||
#endif // ODBC_SUPPORT || JDBC_SUPPORT
|
||||
default:
|
||||
break; // Ignore
|
||||
} // endswitch Fld
|
||||
default:
|
||||
break; // Ignore
|
||||
} // endswitch Fld
|
||||
|
||||
#if defined(ODBC_SUPPORT)
|
||||
if (ttp == TAB_ODBC) {
|
||||
int plgtyp;
|
||||
bool w= false; // Wide character type
|
||||
if (ttp == TAB_ODBC) {
|
||||
int plgtyp;
|
||||
bool w = false; // Wide character type
|
||||
|
||||
// typ must be PLG type, not SQL type
|
||||
if (!(plgtyp= TranslateSQLType(typ, dec, prec, v, w))) {
|
||||
if (GetTypeConv() == TPC_SKIP) {
|
||||
// Skip this column
|
||||
sprintf(g->Message, "Column %s skipped (unsupported type %d)",
|
||||
cnm, typ);
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
|
||||
continue;
|
||||
} else {
|
||||
sprintf(g->Message, "Unsupported SQL type %d", typ);
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
goto err;
|
||||
} // endif type_conv
|
||||
// typ must be PLG type, not SQL type
|
||||
if (!(plgtyp = TranslateSQLType(typ, dec, prec, v, w))) {
|
||||
if (GetTypeConv() == TPC_SKIP) {
|
||||
// Skip this column
|
||||
sprintf(g->Message, "Column %s skipped (unsupported type %d)",
|
||||
cnm, typ);
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
|
||||
continue;
|
||||
} else {
|
||||
sprintf(g->Message, "Unsupported SQL type %d", typ);
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} // endif type_conv
|
||||
|
||||
} else
|
||||
typ= plgtyp;
|
||||
} else
|
||||
typ = plgtyp;
|
||||
|
||||
switch (typ) {
|
||||
case TYPE_STRING:
|
||||
if (w) {
|
||||
sprintf(g->Message, "Column %s is wide characters", cnm);
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message);
|
||||
} // endif w
|
||||
switch (typ) {
|
||||
case TYPE_STRING:
|
||||
if (w) {
|
||||
sprintf(g->Message, "Column %s is wide characters", cnm);
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message);
|
||||
} // endif w
|
||||
|
||||
break;
|
||||
case TYPE_DOUBLE:
|
||||
// Some data sources do not count dec in length (prec)
|
||||
prec += (dec + 2); // To be safe
|
||||
break;
|
||||
case TYPE_DECIM:
|
||||
prec= len;
|
||||
break;
|
||||
default:
|
||||
dec= 0;
|
||||
} // endswitch typ
|
||||
break;
|
||||
case TYPE_DOUBLE:
|
||||
// Some data sources do not count dec in length (prec)
|
||||
prec += (dec + 2); // To be safe
|
||||
break;
|
||||
case TYPE_DECIM:
|
||||
prec = len;
|
||||
break;
|
||||
default:
|
||||
dec = 0;
|
||||
} // endswitch typ
|
||||
|
||||
} else
|
||||
} else
|
||||
#endif // ODBC_SUPPORT
|
||||
#if defined(JDBC_SUPPORT)
|
||||
if (ttp == TAB_JDBC) {
|
||||
int plgtyp;
|
||||
|
||||
// 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) {
|
||||
// Skip this column
|
||||
sprintf(g->Message, "Column %s skipped (unsupported type %d)",
|
||||
|
@ -5880,55 +5950,73 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||
continue;
|
||||
} else {
|
||||
sprintf(g->Message, "Unsupported SQL type %d", typ);
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
rc = HA_ERR_INTERNAL_ERROR;
|
||||
goto err;
|
||||
} // endif type_conv
|
||||
|
||||
} else
|
||||
typ= plgtyp;
|
||||
typ = plgtyp;
|
||||
|
||||
switch (typ) {
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_DECIM:
|
||||
// Some data sources do not count dec in length (prec)
|
||||
prec += (dec + 2); // To be safe
|
||||
break;
|
||||
default:
|
||||
dec= 0;
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_DECIM:
|
||||
// Some data sources do not count dec in length (prec)
|
||||
prec += (dec + 2); // To be safe
|
||||
break;
|
||||
default:
|
||||
dec = 0;
|
||||
} // endswitch typ
|
||||
|
||||
} else
|
||||
#endif // ODBC_SUPPORT
|
||||
// Make the arguments as required by add_fields
|
||||
if (typ == TYPE_DOUBLE)
|
||||
prec= len;
|
||||
if (typ == TYPE_DOUBLE)
|
||||
prec = len;
|
||||
|
||||
if (typ == TYPE_DATE)
|
||||
prec= 0;
|
||||
if (typ == TYPE_DATE)
|
||||
prec = 0;
|
||||
|
||||
// Now add the field
|
||||
if (add_field(&sql, cnm, typ, prec, dec, key, tm, rem, dft, xtra,
|
||||
fmt, 0, dbf, v))
|
||||
rc= HA_ERR_OUT_OF_MEM;
|
||||
} // endfor i
|
||||
// Now add the field
|
||||
if (add_field(&sql, cnm, typ, prec, dec, key, tm, rem, dft, xtra,
|
||||
fmt, 0, dbf, v))
|
||||
rc = HA_ERR_OUT_OF_MEM;
|
||||
} // endfor i
|
||||
|
||||
} // endif fnc
|
||||
} // endif fnc
|
||||
|
||||
if (!rc)
|
||||
rc= init_table_share(thd, table_s, create_info, &sql);
|
||||
if (!rc)
|
||||
rc = init_table_share(thd, table_s, create_info, &sql);
|
||||
|
||||
g->jump_level--;
|
||||
PopUser(xp);
|
||||
return rc;
|
||||
} // endif ok
|
||||
//g->jump_level--;
|
||||
//PopUser(xp);
|
||||
//return rc;
|
||||
} 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:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
if (rc)
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
|
||||
#if !defined(USE_TRY)
|
||||
jer:
|
||||
#endif // !USE_TRY
|
||||
PopUser(xp);
|
||||
return HA_ERR_INTERNAL_ERROR;
|
||||
return rc;
|
||||
} // end of connect_assisted_discovery
|
||||
|
||||
/**
|
||||
|
|
|
@ -1200,7 +1200,11 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
|||
if (rank == 0)
|
||||
if (!name || (jn = env->NewStringUTF(name)) == nullptr) {
|
||||
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);
|
||||
#endif // !USE_TRY
|
||||
} // endif name
|
||||
|
||||
// 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)) {
|
||||
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);
|
||||
#endif // !USE_TRY
|
||||
} // endif Check
|
||||
|
||||
if (val->GetNullable())
|
||||
|
@ -1314,7 +1322,11 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
|||
env->DeleteLocalRef(jn);
|
||||
|
||||
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);
|
||||
#endif // !USE_TRY
|
||||
} // endif Check
|
||||
|
||||
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)
|
||||
{
|
||||
int i, rc, pretty = (ptyp) ? *ptyp : 3;
|
||||
int i, pretty = (ptyp) ? *ptyp : 3;
|
||||
bool b = false, pty[3] = {true, true, true};
|
||||
PJSON jsp = NULL;
|
||||
STRG src;
|
||||
|
@ -82,36 +82,40 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
|||
pty[0] = false;
|
||||
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
#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);
|
||||
|
||||
try {
|
||||
#endif // SE_CATCH --------------------- try section --------------------
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
goto err;
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
goto fin;
|
||||
} // endif rc
|
||||
|
||||
#if defined(SE_CATCH) // ------------- end of try section -----------------
|
||||
} catch (SE_Exception e) {
|
||||
sprintf(g->Message, "ParseJson: exception doing setjmp: %s (rc=%hd)",
|
||||
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
|
||||
|
||||
} catch (SE_Exception e) {
|
||||
sprintf(g->Message, "ParseJson: exception doing setjmp: %s (rc=%hd)",
|
||||
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);
|
||||
#endif // SE_CATCH
|
||||
#endif // !USE_TRY
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
switch (s[i]) {
|
||||
|
@ -119,14 +123,22 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
|||
if (jsp)
|
||||
goto tryit;
|
||||
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;
|
||||
case '{':
|
||||
if (jsp)
|
||||
goto tryit;
|
||||
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;
|
||||
case ' ':
|
||||
|
@ -144,7 +156,12 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
|||
} // endif 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 '(':
|
||||
b = true;
|
||||
break;
|
||||
|
@ -158,7 +175,11 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
|||
if (jsp)
|
||||
goto tryit;
|
||||
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;
|
||||
}; // endswitch s[i]
|
||||
|
@ -176,22 +197,36 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
|||
|
||||
} // endif ptyp
|
||||
|
||||
g->jump_level--;
|
||||
return jsp;
|
||||
#if defined(USE_TRY)
|
||||
} 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:
|
||||
if (pty[0] && (!pretty || pretty > 2)) {
|
||||
if ((jsp = ParseArray(g, (i = 0), src, pty)) && ptyp && pretty == 3)
|
||||
*ptyp = (pty[0]) ? 0 : 3;
|
||||
|
||||
#if !defined(USE_TRY)
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
return jsp;
|
||||
} else
|
||||
strcpy(g->Message, "More than one item in file");
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
return NULL;
|
||||
return NULL;
|
||||
} // end of ParseJson
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -591,6 +626,9 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
|||
|
||||
g->Message[0] = 0;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
|
@ -601,11 +639,16 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
|||
str = NULL;
|
||||
goto fin;
|
||||
} // endif jmp
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!jsp) {
|
||||
strcpy(g->Message, "Null json tree");
|
||||
goto fin;
|
||||
} else if (!fn) {
|
||||
#if defined(USE_TRY)
|
||||
throw 1;
|
||||
#else // !USE_TRY
|
||||
goto fin;
|
||||
#endif // !USE_TRY
|
||||
} else if (!fn) {
|
||||
// Serialize to a string
|
||||
jp = new(g) JOUTSTR(g);
|
||||
b = pretty == 1;
|
||||
|
@ -614,7 +657,11 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
|||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||
"w", (int)errno, fn);
|
||||
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) {
|
||||
// Serialize to a pretty file
|
||||
jp = new(g)JOUTPRT(g, fs);
|
||||
|
@ -655,8 +702,19 @@ PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
|||
|
||||
} // 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:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
return str;
|
||||
} // end of Serialize
|
||||
|
||||
|
|
|
@ -1104,7 +1104,7 @@ static my_bool JsonInit(UDF_INIT *initid, UDF_ARGS *args,
|
|||
} // endif g
|
||||
|
||||
g->Mrr = (args->arg_count && args->args[0]) ? 1 : 0;
|
||||
g->ActivityStart = (PACTIVITY)more;
|
||||
g->More = more;
|
||||
initid->maybe_null = mbn;
|
||||
initid->max_length = reslen;
|
||||
initid->ptr = (char*)g;
|
||||
|
@ -1449,7 +1449,7 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
|
|||
|
||||
} // endif b
|
||||
|
||||
ml += (unsigned long)g->ActivityStart; // more
|
||||
ml += g->More;
|
||||
|
||||
if (ml > g->Sarea_Size) {
|
||||
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 *)
|
||||
{
|
||||
char *p, *path, *str = NULL;
|
||||
int rc;
|
||||
PJSON jsp;
|
||||
PJSNX jsx;
|
||||
PJVAL jvp;
|
||||
|
@ -2926,6 +2925,9 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
} else if (initid->const_item)
|
||||
g->N = 1;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
|
@ -2933,11 +2935,12 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
PUSH_WARNING(g->Message);
|
||||
str = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!g->Xchk) {
|
||||
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
|
||||
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:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
fin:
|
||||
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)
|
||||
{
|
||||
char *p, *path = NULL;
|
||||
int k, rc;
|
||||
int k;
|
||||
PJVAL jvp, jvp2;
|
||||
PJSON jsp;
|
||||
PJSNX jsx;
|
||||
|
@ -3274,6 +3292,9 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
} else if (initid->const_item)
|
||||
g->N = 1;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
|
@ -3282,12 +3303,13 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
PUSH_WARNING(g->Message);
|
||||
*error = 1;
|
||||
path = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!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
|
||||
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:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!path) {
|
||||
*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)
|
||||
{
|
||||
char *p, *path = NULL;
|
||||
int rc, mx = 10;
|
||||
int mx = 10;
|
||||
PJVAL jvp, jvp2;
|
||||
PJSON jsp;
|
||||
PJSNX jsx;
|
||||
|
@ -3400,6 +3439,9 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
} else if (initid->const_item)
|
||||
g->N = 1;
|
||||
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
|
@ -3408,12 +3450,13 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
return NULL;
|
||||
} // endif jump_level
|
||||
|
||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
PUSH_WARNING(g->Message);
|
||||
*error = 1;
|
||||
path = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!g->Xchk) {
|
||||
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
|
||||
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:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!path) {
|
||||
*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)
|
||||
{
|
||||
char *p, *path, *str = NULL;
|
||||
int w, rc;
|
||||
int w;
|
||||
my_bool b = true;
|
||||
PJSON jsp;
|
||||
PJSNX jsx;
|
||||
|
@ -3659,33 +3719,45 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
w = 2;
|
||||
else {
|
||||
PUSH_WARNING("Logical error, please contact CONNECT developer");
|
||||
goto err;
|
||||
goto fin;
|
||||
} // 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) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
*error = 1;
|
||||
goto fin;
|
||||
} // endif jump_level
|
||||
|
||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
PUSH_WARNING(g->Message);
|
||||
str = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, true, false, true)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
#if defined(USE_TRY)
|
||||
throw 1;
|
||||
#else // !USE_TRY
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
jvp = MakeValue(g, args, 0);
|
||||
|
||||
if ((p = jvp->GetString())) {
|
||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||
#if defined(USE_TRY)
|
||||
throw 2;
|
||||
#else // !USE_TRY
|
||||
PUSH_WARNING(g->Message);
|
||||
goto err;
|
||||
#endif // !USE_TRY
|
||||
} // endif jsp
|
||||
|
||||
} else
|
||||
|
@ -3729,8 +3801,21 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
// Keep result of constant function
|
||||
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:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
fin:
|
||||
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. */
|
||||
/***********************************************************************/
|
||||
|
@ -249,17 +249,21 @@ static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db,
|
|||
assert(qrp);
|
||||
#endif
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
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) {
|
||||
printf("%s\n", g->Message);
|
||||
cap = NULL;
|
||||
goto fin;
|
||||
} // endif rc
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
printf("%s\n", g->Message);
|
||||
cap = NULL;
|
||||
goto fin;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
m = (size_t)qrp->Maxres;
|
||||
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));
|
||||
|
||||
#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:
|
||||
g->jump_level--;
|
||||
return cap;
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
return cap;
|
||||
} // end of AllocCatInfo
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -43,34 +43,6 @@ PSZ strlwr(PSZ p)
|
|||
return (p);
|
||||
} /* 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. */
|
||||
/***********************************************************************/
|
||||
|
@ -143,13 +115,6 @@ my_bool CloseFileHandle(HANDLE h)
|
|||
return (close(h)) ? TRUE : FALSE;
|
||||
} /* end of CloseFileHandle */
|
||||
|
||||
#if 0
|
||||
void Sleep(DWORD time)
|
||||
{
|
||||
//FIXME: TODO
|
||||
} /* end of Sleep */
|
||||
#endif
|
||||
|
||||
int GetLastError()
|
||||
{
|
||||
return errno;
|
||||
|
@ -210,21 +175,4 @@ BOOL MessageBeep(uint i __attribute__((unused)))
|
|||
return TRUE;
|
||||
} /* 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
|
||||
|
|
|
@ -244,17 +244,21 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
|
|||
PCOLRES *pcrp, crp;
|
||||
PQRYRES qrp;
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
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) {
|
||||
printf("%s\n", g->Message);
|
||||
qrp = NULL;
|
||||
goto fin;
|
||||
} // endif rc
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
printf("%s\n", g->Message);
|
||||
qrp = NULL;
|
||||
goto fin;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
/************************************************************************/
|
||||
/* 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;
|
||||
|
||||
#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:
|
||||
g->jump_level--;
|
||||
return qrp;
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
return qrp;
|
||||
} // end of PlgAllocResult
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -365,8 +380,12 @@ PCATLG PlgGetCatalog(PGLOBAL g, bool jump)
|
|||
if (!cat && jump) {
|
||||
// Raise exception so caller doesn't have to check return value
|
||||
strcpy(g->Message, MSG(NO_ACTIVE_DB));
|
||||
longjmp(g->jumper[g->jump_level], 1);
|
||||
} // endif cat
|
||||
#if defined(USE_TRY)
|
||||
throw 1;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 1);
|
||||
#endif // !USE_TRY
|
||||
} // endif cat
|
||||
|
||||
return cat;
|
||||
} // end of PlgGetCatalog
|
||||
|
@ -476,8 +495,12 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
|
|||
tp = g->Message;
|
||||
else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) {
|
||||
strcpy(g->Message, MSG(NEW_RETURN_NULL));
|
||||
longjmp(g->jumper[g->jump_level], OP_LIKE);
|
||||
} /* endif tp */
|
||||
#if defined(USE_TRY)
|
||||
throw OP_LIKE;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], OP_LIKE);
|
||||
#endif // !USE_TRY
|
||||
} /* endif tp */
|
||||
|
||||
sp = tp + strlen(pat) + 1;
|
||||
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. */
|
||||
else if (!(tp = new char[strlen(pat) + 1])) {
|
||||
strcpy(g->Message, MSG(NEW_RETURN_NULL));
|
||||
longjmp(g->jumper[g->jump_level], OP_LIKE);
|
||||
} /* endif tp */
|
||||
#if defined(USE_TRY)
|
||||
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 */
|
||||
sp = (char*)strg;
|
||||
|
@ -1520,8 +1547,12 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv)
|
|||
PGLOBAL g = t->G;
|
||||
|
||||
sprintf(g->Message, "NewPointer: %s", MSG(MEM_ALLOC_ERROR));
|
||||
longjmp(g->jumper[g->jump_level], 3);
|
||||
} else {
|
||||
#if defined(USE_TRY)
|
||||
throw 3;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 3);
|
||||
#endif // !USE_TRY
|
||||
} else {
|
||||
tp->Next = t->P1;
|
||||
tp->Num = 0;
|
||||
t->P1 = tp;
|
||||
|
@ -1557,15 +1588,23 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
|
|||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||
"rb", (int)errno, fn[i]);
|
||||
strcat(strcat(g->Message, ": "), strerror(errno));
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
// } else
|
||||
#if defined(USE_TRY)
|
||||
throw 666;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
#endif // !USE_TRY
|
||||
// } else
|
||||
// len[i] = 0; // File does not exist yet
|
||||
|
||||
} else {
|
||||
if ((len[i] = _filelength(h[i])) < 0) {
|
||||
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", fn[i]);
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
} // endif len
|
||||
#if defined(USE_TRY)
|
||||
throw 666;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
#endif // !USE_TRY
|
||||
} // endif len
|
||||
|
||||
} // endif h
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
|
|||
htrc("PlugInit: Language='%s'\n",
|
||||
((!Language) ? "Null" : (char*)Language));
|
||||
|
||||
if (!(g = malloc(sizeof(GLOBAL)))) {
|
||||
if (!(g = (PGLOBAL)malloc(sizeof(GLOBAL)))) {
|
||||
fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL));
|
||||
return NULL;
|
||||
} else {
|
||||
|
@ -147,9 +147,10 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
|
|||
g->Createas = 0;
|
||||
g->Alchecked = 0;
|
||||
g->Mrr = 0;
|
||||
g->Activityp = g->ActivityStart = NULL;
|
||||
g->Activityp = NULL;
|
||||
g->Xchk = NULL;
|
||||
g->N = 0;
|
||||
g->More = 0;
|
||||
strcpy(g->Message, "");
|
||||
|
||||
/*******************************************************************/
|
||||
|
@ -475,7 +476,7 @@ void *PlugAllocMem(PGLOBAL g, 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->FreeBlk = size - pph->To_Free;
|
||||
|
@ -501,7 +502,6 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
|
|||
/*******************************************************************/
|
||||
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 */
|
||||
pph = (PPOOLHEADER)memp;
|
||||
|
||||
|
@ -514,22 +514,26 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
|
|||
|
||||
sprintf(g->Message,
|
||||
"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)
|
||||
htrc("PlugSubAlloc: %s\n", g->Message);
|
||||
|
||||
#if defined(USE_TRY)
|
||||
throw 1234;
|
||||
#else // !USE_TRY
|
||||
/* Nothing we can do if longjmp is not initialized. */
|
||||
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 */
|
||||
|
||||
/*********************************************************************/
|
||||
/* Do the suballocation the simplest way. */
|
||||
/*********************************************************************/
|
||||
memp = MakePtr(memp, pph->To_Free); /* Points to suballocated block */
|
||||
pph->To_Free += size; /* New offset of pool free block */
|
||||
pph->FreeBlk -= size; /* New size of pool free block */
|
||||
pph->To_Free += (OFFSET)size; /* New offset of pool free block */
|
||||
pph->FreeBlk -= (uint)size; /* New size of pool free block */
|
||||
|
||||
if (trace > 3)
|
||||
htrc("Done memp=%p used=%d free=%d\n",
|
|
@ -1,11 +1,11 @@
|
|||
/************* TabDos C++ Program Source Code File (.CPP) **************/
|
||||
/* PROGRAM NAME: TABDOS */
|
||||
/* ------------- */
|
||||
/* Version 4.9.2 */
|
||||
/* Version 4.9.3 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
|
||||
/* */
|
||||
/* 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) {
|
||||
// Should never happen
|
||||
strcpy(g->Message, "Block opt: bad constant");
|
||||
longjmp(g->jumper[g->jump_level], 99);
|
||||
} // endif Conv
|
||||
#if defined(USE_TRY)
|
||||
throw 99;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 99);
|
||||
#endif // !USE_TRY
|
||||
} // endif Conv
|
||||
|
||||
if (type[0] == 1) {
|
||||
// Make it always as Column-op-Value
|
||||
|
@ -1791,7 +1795,7 @@ err:
|
|||
/***********************************************************************/
|
||||
bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
||||
{
|
||||
int k, rc;
|
||||
int k;
|
||||
volatile bool dynamic;
|
||||
bool brc;
|
||||
PCOL colp;
|
||||
|
@ -1861,13 +1865,17 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
|||
} else // Column contains same values as ROWID
|
||||
kxp = new(g) XXROW(this);
|
||||
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Prepare error return
|
||||
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) {
|
||||
ResetBlockFilter(g);
|
||||
kxp->SetDynamic(dynamic);
|
||||
|
@ -1892,11 +1900,22 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
|||
|
||||
} // endif brc
|
||||
|
||||
} else
|
||||
brc = true;
|
||||
#if defined(USE_TRY)
|
||||
} 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--;
|
||||
return brc;
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
return brc;
|
||||
} // end of InitialyzeIndex
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -2156,16 +2175,18 @@ bool TDBDOS::OpenDB(PGLOBAL g)
|
|||
To_BlkFil = InitBlockFilter(g, To_Filter);
|
||||
|
||||
/*********************************************************************/
|
||||
/* Allocate the line buffer plus a null character. */
|
||||
/*********************************************************************/
|
||||
To_Line = (char*)PlugSubAlloc(g, NULL, Lrecl + 1);
|
||||
/* Lrecl does not include line ending */
|
||||
/*********************************************************************/
|
||||
size_t linelen = Lrecl + ((PDOSDEF)To_Def)->Ending + 1;
|
||||
|
||||
To_Line = (char*)PlugSubAlloc(g, NULL, linelen);
|
||||
|
||||
if (Mode == MODE_INSERT) {
|
||||
// Spaces between fields must be filled with blanks
|
||||
memset(To_Line, ' ', Lrecl);
|
||||
To_Line[Lrecl] = '\0';
|
||||
} else
|
||||
memset(To_Line, 0, Lrecl + 1);
|
||||
memset(To_Line, 0, linelen);
|
||||
|
||||
if (trace)
|
||||
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)
|
||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
} // endif
|
||||
#if defined(USE_TRY)
|
||||
throw 11;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
|
||||
p = tdbp->To_Line + Deplac;
|
||||
field = Long;
|
||||
|
@ -2570,8 +2595,12 @@ void DOSCOL::ReadColumn(PGLOBAL g)
|
|||
break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_RECFM), tdbp->Ftype);
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
} // endswitch Ftype
|
||||
#if defined(USE_TRY)
|
||||
throw 34;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch Ftype
|
||||
|
||||
// Set null when applicable
|
||||
if (Nullable)
|
||||
|
@ -2679,8 +2708,12 @@ void DOSCOL::WriteColumn(PGLOBAL g)
|
|||
break;
|
||||
default:
|
||||
sprintf(g->Message, "Invalid field format for column %s", Name);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} // endswitch BufType
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch BufType
|
||||
|
||||
p2 = Buf;
|
||||
} else // Standard CONNECT format
|
||||
|
@ -2691,8 +2724,12 @@ void DOSCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if ((len = strlen(p2)) > field) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p2, Name, field);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (Dsp)
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Dsp)
|
||||
for (i = 0; i < len; i++)
|
||||
if (p2[i] == '.')
|
||||
p2[i] = Dsp;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/************* TabFix C++ Program Source Code File (.CPP) **************/
|
||||
/* PROGRAM NAME: TABFIX */
|
||||
/* ------------- */
|
||||
/* Version 4.9.1 */
|
||||
/* Version 4.9.2 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
|
||||
/* */
|
||||
/* 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;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
} // endswitch Fmt
|
||||
#if defined(USE_TRY)
|
||||
throw 11;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch Fmt
|
||||
|
||||
} else if (IsTypeChar(Buf_Type))
|
||||
Eds = 0;
|
||||
|
@ -486,8 +490,12 @@ void BINCOL::ReadColumn(PGLOBAL g)
|
|||
if (rc == RC_EF)
|
||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
} // endif
|
||||
#if defined(USE_TRY)
|
||||
throw 11;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
|
||||
p = tdbp->To_Line + Deplac;
|
||||
|
||||
|
@ -545,8 +553,12 @@ void BINCOL::ReadColumn(PGLOBAL g)
|
|||
break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
} // endswitch Fmt
|
||||
#if defined(USE_TRY)
|
||||
throw 11;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch Fmt
|
||||
|
||||
// Set null when applicable
|
||||
if (Nullable)
|
||||
|
@ -595,8 +607,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||
} else if (Value->GetBinValue(p, Long, Status)) {
|
||||
sprintf(g->Message, MSG(BIN_F_TOO_LONG),
|
||||
Name, Value->GetSize(), Long);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} // endif p
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endif p
|
||||
|
||||
break;
|
||||
case 'S': // Short integer
|
||||
|
@ -604,8 +620,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (n > 32767LL || n < -32768LL) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (Status)
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Status)
|
||||
Value->GetValueNonAligned<short>(p, (short)n);
|
||||
|
||||
break;
|
||||
|
@ -614,8 +634,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (n > 255LL || n < -256LL) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (Status)
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Status)
|
||||
*p = (char)n;
|
||||
|
||||
break;
|
||||
|
@ -624,8 +648,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (n > INT_MAX || n < INT_MIN) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (Status)
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Status)
|
||||
Value->GetValueNonAligned<int>(p, (int)n);
|
||||
|
||||
break;
|
||||
|
@ -648,8 +676,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||
case 'C': // Characters
|
||||
if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) {
|
||||
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} // endif n
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endif n
|
||||
|
||||
if (Status) {
|
||||
s = Value->GetCharString(Buf);
|
||||
|
@ -660,8 +692,12 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||
break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
} // endswitch Fmt
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch Fmt
|
||||
|
||||
if (Eds && Status) {
|
||||
p = tdbp->To_Line + Deplac;
|
||||
|
|
|
@ -1435,8 +1435,12 @@ void CSVCOL::ReadColumn(PGLOBAL g)
|
|||
if (rc == RC_EF)
|
||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
} // endif
|
||||
#if defined(USE_TRY)
|
||||
throw 34;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
|
||||
if (tdbp->Mode != MODE_UPDATE) {
|
||||
int colen = Long; // Column length
|
||||
|
@ -1453,8 +1457,12 @@ void CSVCOL::ReadColumn(PGLOBAL g)
|
|||
Long = colen; // Restore column length
|
||||
sprintf(g->Message, MSG(FLD_TOO_LNG_FOR),
|
||||
Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g));
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
} // endif Long
|
||||
#if defined(USE_TRY)
|
||||
throw 34;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
#endif // !USE_TRY
|
||||
} // endif Long
|
||||
|
||||
// Now do the reading
|
||||
DOSCOL::ReadColumn(g);
|
||||
|
@ -1516,8 +1524,12 @@ void CSVCOL::WriteColumn(PGLOBAL g)
|
|||
if ((signed)strlen(p) > flen) {
|
||||
sprintf(g->Message, MSG(BAD_FLD_LENGTH), Name, p, flen,
|
||||
tdbp->RowNumber(g), tdbp->GetFile(g));
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
} else if (Dsp)
|
||||
#if defined(USE_TRY)
|
||||
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++)
|
||||
if (p[i] == '.')
|
||||
p[i] = Dsp;
|
||||
|
@ -1532,8 +1544,12 @@ void CSVCOL::WriteColumn(PGLOBAL g)
|
|||
if (Fldnum < 0) {
|
||||
// This can happen for wrong offset value in XDB files
|
||||
sprintf(g->Message, MSG(BAD_FIELD_RANK), Fldnum + 1, Name);
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
} else
|
||||
#if defined(USE_TRY)
|
||||
throw 34;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
strncpy(tdbp->Field[Fldnum], p, flen);
|
||||
|
||||
if (trace > 1)
|
||||
|
|
|
@ -227,41 +227,8 @@ bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
|||
|
||||
if (rc == RC_FX) // Error
|
||||
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);
|
||||
//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;
|
||||
} // end of DefineAM
|
||||
|
||||
|
@ -341,9 +308,6 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBEXT(tdp)
|
|||
WrapName = tdp->Wrapname;
|
||||
Ops.User = tdp->Username;
|
||||
Ops.Pwd = tdp->Password;
|
||||
// Ops.Properties = tdp->Prop;
|
||||
// Ops.Cto = tdp->Cto;
|
||||
// Ops.Qto = tdp->Qto;
|
||||
Ops.Scrollable = tdp->Scrollable;
|
||||
} else {
|
||||
WrapName = NULL;
|
||||
|
@ -351,13 +315,9 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBEXT(tdp)
|
|||
Ops.Url = NULL;
|
||||
Ops.User = NULL;
|
||||
Ops.Pwd = NULL;
|
||||
// Ops.Properties = NULL;
|
||||
// Ops.Cto = DEFAULT_LOGIN_TIMEOUT;
|
||||
// Ops.Qto = DEFAULT_QUERY_TIMEOUT;
|
||||
Ops.Scrollable = false;
|
||||
} // endif tdp
|
||||
|
||||
//Ncol = 0;
|
||||
Prepared = false;
|
||||
Werr = false;
|
||||
Rerr = false;
|
||||
|
@ -370,7 +330,6 @@ TDBJDBC::TDBJDBC(PTDBJDBC tdbp) : TDBEXT(tdbp)
|
|||
Cnp = tdbp->Cnp;
|
||||
WrapName = tdbp->WrapName;
|
||||
Ops = tdbp->Ops;
|
||||
//Ncol = tdbp->Ncol;
|
||||
Prepared = tdbp->Prepared;
|
||||
Werr = tdbp->Werr;
|
||||
Rerr = tdbp->Rerr;
|
||||
|
@ -737,18 +696,12 @@ bool TDBJDBC::SetRecpos(PGLOBAL g, int recpos)
|
|||
{
|
||||
if (Jcp->m_Full) {
|
||||
Fpos = 0;
|
||||
// CurNum = 0;
|
||||
CurNum = 1;
|
||||
} else if (Memory == 3) {
|
||||
// Fpos = recpos;
|
||||
// CurNum = -1;
|
||||
Fpos = 0;
|
||||
CurNum = recpos;
|
||||
} else if (Ops.Scrollable) {
|
||||
// Is new position in the current row set?
|
||||
// if (recpos >= Curpos && recpos < Curpos + Rbuf) {
|
||||
// CurNum = recpos - Curpos;
|
||||
// Fpos = 0;
|
||||
if (recpos > 0 && recpos <= Rbuf) {
|
||||
CurNum = recpos;
|
||||
Fpos = recpos;
|
||||
|
@ -990,11 +943,6 @@ int TDBJDBC::DeleteDB(PGLOBAL g, int irc)
|
|||
/***********************************************************************/
|
||||
void TDBJDBC::CloseDB(PGLOBAL g)
|
||||
{
|
||||
//if (To_Kindex) {
|
||||
// To_Kindex->Close();
|
||||
// To_Kindex = NULL;
|
||||
// } // endif
|
||||
|
||||
if (Jcp)
|
||||
Jcp->Close();
|
||||
|
||||
|
@ -1039,54 +987,6 @@ JDBCCOL::JDBCCOL(JDBCCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp)
|
|||
{
|
||||
} // 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 */
|
||||
/* column buffer was bind to the record set. This is also the case */
|
||||
|
@ -1196,26 +1096,6 @@ PCMD TDBXJDC::MakeCMD(PGLOBAL g)
|
|||
return xcmd;
|
||||
} // 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). */
|
||||
/***********************************************************************/
|
||||
|
@ -1416,17 +1296,3 @@ PQRYRES TDBJDBCL::GetResult(PGLOBAL g)
|
|||
{
|
||||
return JDBCColumns(g, Schema, Tab, Colpat, Maxres, false, &Ops);
|
||||
} // 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 TDBXJDC *PTDBXJDC;
|
||||
typedef class JSRCCOL *PJSRCCOL;
|
||||
//typedef class TDBOIF *PTDBOIF;
|
||||
//typedef class OIFCOL *POIFCOL;
|
||||
//typedef class TDBJSRC *PTDBJSRC;
|
||||
|
||||
/***********************************************************************/
|
||||
/* JDBC table. */
|
||||
|
@ -68,20 +65,14 @@ public:
|
|||
|
||||
// Methods
|
||||
virtual PTDB Clone(PTABS t);
|
||||
//virtual int GetRecpos(void);
|
||||
virtual bool SetRecpos(PGLOBAL g, int recpos);
|
||||
//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"; }
|
||||
virtual int Indexable(void) { return 2; }
|
||||
|
||||
// Database routines
|
||||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
||||
virtual int Cardinality(PGLOBAL g);
|
||||
//virtual int GetMaxSize(PGLOBAL g);
|
||||
//virtual int GetProgMax(PGLOBAL g);
|
||||
virtual bool OpenDB(PGLOBAL g);
|
||||
virtual int ReadDB(PGLOBAL g);
|
||||
virtual int WriteDB(PGLOBAL g);
|
||||
|
@ -91,21 +82,14 @@ public:
|
|||
|
||||
protected:
|
||||
// Internal functions
|
||||
//int Decode(char *utf, char *buf, size_t n);
|
||||
//bool MakeSQL(PGLOBAL g, bool cnt);
|
||||
bool MakeInsert(PGLOBAL g);
|
||||
//virtual bool MakeCommand(PGLOBAL g);
|
||||
//bool MakeFilter(PGLOBAL g, bool c);
|
||||
bool SetParameters(PGLOBAL g);
|
||||
//char *MakeUpdate(PGLOBAL g);
|
||||
//char *MakeDelete(PGLOBAL g);
|
||||
|
||||
// Members
|
||||
JDBConn *Jcp; // Points to a JDBC connection class
|
||||
JDBCCOL *Cnp; // Points to count(*) column
|
||||
JDBCPARM Ops; // Additional parameters
|
||||
char *WrapName; // Points to Java wrapper name
|
||||
//int Ncol; // The column number
|
||||
bool Prepared; // True when using prepared statement
|
||||
bool Werr; // Write error
|
||||
bool Rerr; // Rewind error
|
||||
|
@ -152,12 +136,6 @@ public:
|
|||
virtual AMT GetAmType(void) {return TYPE_AM_XDBC;}
|
||||
|
||||
// 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
|
||||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
||||
|
@ -172,7 +150,6 @@ public:
|
|||
protected:
|
||||
// Internal functions
|
||||
PCMD MakeCMD(PGLOBAL g);
|
||||
//bool BindParameters(PGLOBAL g);
|
||||
|
||||
// Members
|
||||
PCMD Cmdlist; // The commands to execute
|
||||
|
@ -255,21 +232,4 @@ protected:
|
|||
char *Colpat; // Points to catalog column pattern
|
||||
}; // 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/************* tabjson C++ Program Source Code File (.CPP) *************/
|
||||
/* PROGRAM NAME: tabjson Version 1.3 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2016 */
|
||||
/* PROGRAM NAME: tabjson Version 1.4 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
|
||||
/* 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 = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||
G->jump_level = -1;
|
||||
G->jump_level = 0;
|
||||
tjnp->SetG(G);
|
||||
#else
|
||||
tjnp->SetG(g);
|
||||
|
@ -478,7 +478,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
|||
G->Sarea_Size = Lrecl * 10;
|
||||
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||
G->jump_level = -1;
|
||||
G->jump_level = 0;
|
||||
((TDBJSN*)tdbp)->G = G;
|
||||
#else
|
||||
((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)))) {
|
||||
strcpy(g->Message, "Logical error expanding array");
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
} // endif jvp
|
||||
#if defined(USE_TRY)
|
||||
throw 666;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
#endif // !USE_TRY
|
||||
} // endif jvp
|
||||
|
||||
if (n < Nod - 1 && jvp->GetJson()) {
|
||||
jval.SetValue(GetColumnValue(g, jvp->GetJson(), n + 1));
|
||||
|
@ -1475,8 +1479,12 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
|||
{
|
||||
if (Xpd && Tjp->Pretty < 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);
|
||||
} // endif Xpd
|
||||
#endif // !USE_TRY
|
||||
} // endif Xpd
|
||||
|
||||
/*********************************************************************/
|
||||
/* Check whether this node must be written. */
|
||||
|
@ -1510,8 +1518,12 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (!(jsp = ParseJson(G, s, (int)strlen(s)))) {
|
||||
strcpy(g->Message, s);
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
} // endif jsp
|
||||
#if defined(USE_TRY)
|
||||
throw 666;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
#endif // !USE_TRY
|
||||
} // endif jsp
|
||||
|
||||
if (arp) {
|
||||
if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ)
|
||||
|
|
|
@ -958,8 +958,12 @@ void DIRCOL::ReadColumn(PGLOBAL g)
|
|||
#endif // !__WIN__
|
||||
default:
|
||||
sprintf(g->Message, MSG(INV_DIRCOL_OFST), N);
|
||||
longjmp(g->jumper[g->jump_level], GetAmType());
|
||||
} // endswitch N
|
||||
#if defined(USE_TRY)
|
||||
throw GetAmType();
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], GetAmType());
|
||||
#endif // !USE_TRY
|
||||
} // endswitch N
|
||||
|
||||
} // end of ReadColumn
|
||||
|
||||
|
@ -1423,8 +1427,12 @@ void TDBDHR::CloseDB(PGLOBAL g)
|
|||
// Close the search handle.
|
||||
if (!FindClose(Hsearch)) {
|
||||
strcpy(g->Message, MSG(SRCH_CLOSE_ERR));
|
||||
longjmp(g->jumper[g->jump_level], GetAmType());
|
||||
} // endif FindClose
|
||||
#if defined(USE_TRY)
|
||||
throw GetAmType();
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], GetAmType());
|
||||
#endif // !USE_TRY
|
||||
} // endif FindClose
|
||||
|
||||
iFile = 0;
|
||||
Hsearch = INVALID_HANDLE_VALUE;
|
||||
|
|
|
@ -134,7 +134,7 @@ class TDBDIR : public TDBASE {
|
|||
int iFile; // Index of currently retrieved file
|
||||
#if defined(__WIN__)
|
||||
_finddata_t FileData; // Find data structure
|
||||
int Hsearch; // Search handle
|
||||
intptr_t Hsearch; // Search handle
|
||||
char Drive[_MAX_DRIVE]; // Drive name
|
||||
#else // !__WIN__
|
||||
struct stat Fileinfo; // File info structure
|
||||
|
@ -184,7 +184,7 @@ class TDBSDR : public TDBDIR {
|
|||
struct _Sub_Dir *Next;
|
||||
struct _Sub_Dir *Prev;
|
||||
#if defined(__WIN__)
|
||||
int H; // Search handle
|
||||
intptr_t H; // Search handle
|
||||
#else // !__WIN__
|
||||
DIR *D;
|
||||
#endif // !__WIN__
|
||||
|
|
|
@ -1407,8 +1407,12 @@ void MYSQLCOL::ReadColumn(PGLOBAL g)
|
|||
if (rc == RC_EF)
|
||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
} else
|
||||
#if defined(USE_TRY)
|
||||
throw 11;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
tdbp->Fetched = true;
|
||||
|
||||
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))
|
||||
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);
|
||||
//Xsrc = GetBoolCatInfo("Execsrc", FALSE);
|
||||
//Maxerr = GetIntCatInfo("Maxerr", 0);
|
||||
//Maxres = GetIntCatInfo("Maxres", 0);
|
||||
//Quoted = GetIntCatInfo("Quoted", 0);
|
||||
Options = ODBConn::noOdbcDialog;
|
||||
//Options = ODBConn::noOdbcDialog | ODBConn::useCursorLib;
|
||||
Cto= GetIntCatInfo("ConnectTimeout", DEFAULT_LOGIN_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);
|
||||
|
||||
// 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;
|
||||
} // end of DefineAM
|
||||
|
||||
|
@ -210,59 +175,22 @@ TDBODBC::TDBODBC(PODEF tdp) : TDBEXT(tdp)
|
|||
|
||||
if (tdp) {
|
||||
Connect = tdp->Connect;
|
||||
//TableName = tdp->Tabname;
|
||||
//Schema = tdp->Tabschema;
|
||||
Ops.User = tdp->Username;
|
||||
Ops.Pwd = tdp->Password;
|
||||
//Catalog = tdp->Tabcat;
|
||||
//Srcdef = tdp->Srcdef;
|
||||
//Qrystr = tdp->Qrystr;
|
||||
//Sep = tdp->GetSep();
|
||||
//Options = tdp->Options;
|
||||
Ops.Cto = tdp->Cto;
|
||||
Ops.Qto = tdp->Qto;
|
||||
//Quoted = MY_MAX(0, tdp->GetQuoted());
|
||||
//Rows = tdp->GetElemt();
|
||||
Catver = tdp->Catver;
|
||||
//Memory = tdp->Memory;
|
||||
//Scrollable = tdp->Scrollable;
|
||||
Ops.UseCnc = tdp->UseCnc;
|
||||
} else {
|
||||
Connect = NULL;
|
||||
//TableName = NULL;
|
||||
//Schema = NULL;
|
||||
Ops.User = NULL;
|
||||
Ops.Pwd = NULL;
|
||||
//Catalog = NULL;
|
||||
//Srcdef = NULL;
|
||||
//Qrystr = NULL;
|
||||
//Sep = 0;
|
||||
//Options = 0;
|
||||
Ops.Cto = DEFAULT_LOGIN_TIMEOUT;
|
||||
Ops.Qto = DEFAULT_QUERY_TIMEOUT;
|
||||
//Quoted = 0;
|
||||
//Rows = 0;
|
||||
Catver = 0;
|
||||
//Memory = 0;
|
||||
//Scrollable = false;
|
||||
Ops.UseCnc = false;
|
||||
} // 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
|
||||
|
||||
TDBODBC::TDBODBC(PTDBODBC tdbp) : TDBEXT(tdbp)
|
||||
|
@ -270,32 +198,7 @@ TDBODBC::TDBODBC(PTDBODBC tdbp) : TDBEXT(tdbp)
|
|||
Ocp = tdbp->Ocp; // is that right ?
|
||||
Cnp = tdbp->Cnp;
|
||||
Connect = tdbp->Connect;
|
||||
//TableName = tdbp->TableName;
|
||||
//Schema = tdbp->Schema;
|
||||
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
|
||||
|
||||
// Method
|
||||
|
@ -389,144 +292,6 @@ void TDBODBC::SetFile(PGLOBAL g, PSZ fn)
|
|||
DBQ = fn;
|
||||
} // 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. */
|
||||
/***********************************************************************/
|
||||
|
@ -645,73 +410,6 @@ bool TDBODBC::BindParameters(PGLOBAL g)
|
|||
} // end of BindParameters
|
||||
|
||||
#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. */
|
||||
/***********************************************************************/
|
||||
|
@ -829,35 +527,6 @@ int TDBODBC::Cardinality(PGLOBAL g)
|
|||
return Cardinal;
|
||||
} // 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. */
|
||||
/* New method now that this routine is called recursively (last table */
|
||||
|
@ -1097,8 +766,6 @@ int TDBODBC::ReadDB(PGLOBAL g)
|
|||
|
||||
if (trace > 1)
|
||||
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 (!Query && MakeCommand(g))
|
||||
|
@ -1118,12 +785,6 @@ int TDBODBC::ReadDB(PGLOBAL g)
|
|||
|
||||
} // 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. */
|
||||
/* 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)
|
||||
{
|
||||
//if (To_Kindex) {
|
||||
// To_Kindex->Close();
|
||||
// To_Kindex = NULL;
|
||||
// } // endif
|
||||
|
||||
if (Ocp)
|
||||
|
||||
Ocp->Close();
|
||||
|
@ -1231,16 +887,9 @@ ODBCCOL::ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
|
|||
: EXTCOL(cdp, tdbp, cprec, i, am)
|
||||
{
|
||||
// Set additional ODBC access method information for column.
|
||||
//Crp = NULL;
|
||||
//Long = Precision;
|
||||
//strcpy(F_Date, cdp->F_Date);
|
||||
//To_Val = NULL;
|
||||
Slen = 0;
|
||||
StrLen = &Slen;
|
||||
Sqlbuf = NULL;
|
||||
//Bufp = NULL;
|
||||
//Blkp = NULL;
|
||||
//Rank = 0; // Not known yet
|
||||
} // end of ODBCCOL constructor
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -1248,17 +897,9 @@ ODBCCOL::ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
|
|||
/***********************************************************************/
|
||||
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;
|
||||
StrLen = &Slen;
|
||||
Sqlbuf = NULL;
|
||||
//Bufp = NULL;
|
||||
//Blkp = NULL;
|
||||
//Rank = 1;
|
||||
} // end of ODBCCOL constructor
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -1267,66 +908,11 @@ ODBCCOL::ODBCCOL(void) : EXTCOL()
|
|||
/***********************************************************************/
|
||||
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;
|
||||
StrLen = col1->StrLen;
|
||||
Sqlbuf = col1->Sqlbuf;
|
||||
//Bufp = col1->Bufp;
|
||||
//Blkp = col1->Blkp;
|
||||
//Rank = col1->Rank;
|
||||
} // 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 */
|
||||
/* column buffer was bind to the record set. This is also the case */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*************** 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. */
|
||||
/***********************************************************************/
|
||||
|
@ -33,14 +33,7 @@ public:
|
|||
// Implementation
|
||||
virtual const char *GetType(void) {return "ODBC";}
|
||||
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 GetOptions(void) {return Options;}
|
||||
|
||||
// Methods
|
||||
virtual int Indexable(void) {return 2;}
|
||||
|
@ -50,27 +43,7 @@ public:
|
|||
protected:
|
||||
// Members
|
||||
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 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) */
|
||||
}; // end of ODBCDEF
|
||||
|
||||
|
@ -96,20 +69,16 @@ class TDBODBC : public TDBEXT {
|
|||
|
||||
// Methods
|
||||
virtual PTDB Clone(PTABS t);
|
||||
//virtual int GetRecpos(void);
|
||||
virtual bool SetRecpos(PGLOBAL g, int recpos);
|
||||
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 "ODBC";}
|
||||
virtual int Indexable(void) {return 2;}
|
||||
|
||||
// Database routines
|
||||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
||||
virtual int Cardinality(PGLOBAL g);
|
||||
//virtual int GetMaxSize(PGLOBAL g);
|
||||
//virtual int GetProgMax(PGLOBAL g);
|
||||
virtual bool OpenDB(PGLOBAL g);
|
||||
virtual int ReadDB(PGLOBAL g);
|
||||
virtual int WriteDB(PGLOBAL g);
|
||||
|
@ -119,14 +88,8 @@ class TDBODBC : public TDBEXT {
|
|||
|
||||
protected:
|
||||
// Internal functions
|
||||
//int Decode(char *utf, char *buf, size_t n);
|
||||
//bool MakeSQL(PGLOBAL g, bool cnt);
|
||||
bool MakeInsert(PGLOBAL g);
|
||||
//virtual bool MakeCommand(PGLOBAL g);
|
||||
//bool MakeFilter(PGLOBAL g, bool c);
|
||||
bool BindParameters(PGLOBAL g);
|
||||
//char *MakeUpdate(PGLOBAL g);
|
||||
//char *MakeDelete(PGLOBAL g);
|
||||
|
||||
// Members
|
||||
ODBConn *Ocp; // Points to an ODBC connection class
|
||||
|
@ -151,9 +114,6 @@ class ODBCCOL : public EXTCOL {
|
|||
// Implementation
|
||||
virtual int GetAmType(void) {return TYPE_AM_ODBC;}
|
||||
SQLLEN *GetStrLen(void) {return StrLen;}
|
||||
// int GetRank(void) {return Rank;}
|
||||
// PVBLK GetBlkp(void) {return Blkp;}
|
||||
// void SetCrp(PCOLRES crp) {Crp = crp;}
|
||||
|
||||
// Methods
|
||||
//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 *GetBuffer(DWORD rows);
|
||||
SWORD GetBuflen(void);
|
||||
// void Print(PGLOBAL g, FILE *, uint);
|
||||
|
||||
protected:
|
||||
// Constructor for count(*) column
|
||||
|
@ -170,14 +129,8 @@ class ODBCCOL : public EXTCOL {
|
|||
|
||||
// Members
|
||||
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 Slen; // Used with Fetch
|
||||
//int Rank; // Rank (position) number in the query
|
||||
}; // end of class ODBCCOL
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -230,7 +183,6 @@ class XSRCCOL : public ODBCCOL {
|
|||
XSRCCOL(XSRCCOL *colp, PTDB tdbp); // Constructor used in copy process
|
||||
|
||||
// Implementation
|
||||
//virtual int GetAmType(void) {return TYPE_AM_ODBC;}
|
||||
|
||||
// Methods
|
||||
virtual void ReadColumn(PGLOBAL g);
|
||||
|
|
|
@ -108,21 +108,25 @@ bool PIVAID::SkipColumn(PCOLRES crp, char *skc)
|
|||
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||
{
|
||||
char *p, *query, *colname, *skc, buf[64];
|
||||
int rc, ndif, nblin, w = 0;
|
||||
int ndif, nblin, w = 0;
|
||||
bool b = false;
|
||||
PVAL valp;
|
||||
PQRYRES qrp;
|
||||
PCOLRES *pcrp, crp, fncrp = NULL;
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
#if defined(USE_TRY)
|
||||
try {
|
||||
#else // !USE_TRY
|
||||
// Save stack and allocation environment and prepare error return
|
||||
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) {
|
||||
goto err;
|
||||
} // endif rc
|
||||
if (setjmp(g->jumper[++g->jump_level])) {
|
||||
goto err;
|
||||
} // endif rc
|
||||
#endif // !USE_TRY
|
||||
|
||||
// Are there columns to skip?
|
||||
if (Skcol) {
|
||||
|
@ -145,7 +149,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||
sprintf(query, "SELECT * FROM `%s` LIMIT 1", Tabname);
|
||||
} else if (!Tabsrc) {
|
||||
strcpy(g->Message, MSG(SRC_TABLE_UNDEF));
|
||||
return NULL;
|
||||
goto err;
|
||||
} else
|
||||
query = Tabsrc;
|
||||
|
||||
|
@ -160,7 +164,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||
Myc.FreeResult();
|
||||
|
||||
} else
|
||||
return NULL;
|
||||
goto err;
|
||||
|
||||
// Send the source command to MySQL
|
||||
if (Myc.ExecSQL(g, query, &w) == RC_FX)
|
||||
|
@ -233,18 +237,18 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||
Index.Sub = TRUE; // Should be small enough
|
||||
|
||||
if (!PlgDBalloc(g, NULL, Index))
|
||||
return NULL;
|
||||
goto err;
|
||||
|
||||
Offset.Size = (nblin + 1) * sizeof(int);
|
||||
Offset.Sub = TRUE; // Should be small enough
|
||||
|
||||
if (!PlgDBalloc(g, NULL, Offset))
|
||||
return NULL;
|
||||
goto err;
|
||||
|
||||
ndif = Qsort(g, nblin);
|
||||
|
||||
if (ndif < 0) // error
|
||||
return NULL;
|
||||
goto err;
|
||||
|
||||
} else {
|
||||
// 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(),
|
||||
Rblkp->GetVlen(),
|
||||
Rblkp->GetPrec())))
|
||||
return NULL;
|
||||
goto err;
|
||||
|
||||
// Now make the functional columns
|
||||
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)
|
||||
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:
|
||||
#else // !USE_TRY
|
||||
g->jump_level--;
|
||||
return Qryp;
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
#endif // !USE_TRY
|
||||
|
||||
if (b)
|
||||
Myc.Close();
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/************* TabSys C++ Program Source Code File (.CPP) **************/
|
||||
/* 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. */
|
||||
/***********************************************************************/
|
||||
|
@ -511,12 +511,20 @@ void INICOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (strlen(p) > (unsigned)Long) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (Flag == 1) {
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Flag == 1) {
|
||||
if (tdbp->Mode == MODE_UPDATE) {
|
||||
strcpy(g->Message, MSG(NO_SEC_UPDATE));
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (*p) {
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (*p) {
|
||||
tdbp->Section = p;
|
||||
} else
|
||||
tdbp->Section = NULL;
|
||||
|
@ -524,8 +532,12 @@ void INICOL::WriteColumn(PGLOBAL g)
|
|||
return;
|
||||
} else if (!tdbp->Section) {
|
||||
strcpy(g->Message, MSG(SEC_NAME_FIRST));
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} // endif's
|
||||
#if defined(USE_TRY)
|
||||
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. */
|
||||
|
@ -536,8 +548,12 @@ void INICOL::WriteColumn(PGLOBAL g)
|
|||
if (!rc) {
|
||||
sprintf(g->Message, "Error %d writing to %s",
|
||||
GetLastError(), tdbp->Ifile);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} // endif rc
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endif rc
|
||||
|
||||
} // endif Status
|
||||
|
||||
|
@ -837,12 +853,20 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (strlen(p) > (unsigned)Long) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (Flag == 1) {
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (Flag == 1) {
|
||||
if (tdbp->Mode == MODE_UPDATE) {
|
||||
strcpy(g->Message, MSG(NO_SEC_UPDATE));
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (*p) {
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (*p) {
|
||||
tdbp->Section = p;
|
||||
} else
|
||||
tdbp->Section = NULL;
|
||||
|
@ -851,8 +875,12 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
|||
} else if (Flag == 2) {
|
||||
if (tdbp->Mode == MODE_UPDATE) {
|
||||
strcpy(g->Message, MSG(NO_KEY_UPDATE));
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (*p) {
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} else if (*p) {
|
||||
tdbp->Keycur = p;
|
||||
} else
|
||||
tdbp->Keycur = NULL;
|
||||
|
@ -860,8 +888,12 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
|||
return;
|
||||
} else if (!tdbp->Section || !tdbp->Keycur) {
|
||||
strcpy(g->Message, MSG(SEC_KEY_FIRST));
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} // endif's
|
||||
#if defined(USE_TRY)
|
||||
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. */
|
||||
|
@ -872,8 +904,12 @@ void XINCOL::WriteColumn(PGLOBAL g)
|
|||
if (!rc) {
|
||||
sprintf(g->Message, "Error %d writing to %s",
|
||||
GetLastError(), tdbp->Ifile);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} // endif rc
|
||||
#if defined(USE_TRY)
|
||||
throw 31;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
#endif // !USE_TRY
|
||||
} // endif rc
|
||||
|
||||
} // endif Status
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/************* TabVct C++ Program Source Code File (.CPP) **************/
|
||||
/* PROGRAM NAME: TABVCT */
|
||||
/* ------------- */
|
||||
/* Version 3.8 */
|
||||
/* Version 3.9 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1999-2017 */
|
||||
/* */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
|
@ -490,15 +490,23 @@ void VCTCOL::ReadBlock(PGLOBAL g)
|
|||
#if defined(_DEBUG)
|
||||
if (!Blk) {
|
||||
strcpy(g->Message, MSG(TO_BLK_IS_NULL));
|
||||
longjmp(g->jumper[g->jump_level], 58);
|
||||
} // endif
|
||||
#if defined(USE_TRY)
|
||||
throw 58;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 58);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
#endif
|
||||
|
||||
/*********************************************************************/
|
||||
/* Read column block according to used access method. */
|
||||
/*********************************************************************/
|
||||
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;
|
||||
ColPos = -1; // Any invalid position
|
||||
|
@ -518,15 +526,23 @@ void VCTCOL::WriteBlock(PGLOBAL g)
|
|||
#if defined(_DEBUG)
|
||||
if (!Blk) {
|
||||
strcpy(g->Message, MSG(BLK_IS_NULL));
|
||||
longjmp(g->jumper[g->jump_level], 56);
|
||||
} // endif
|
||||
#if defined(USE_TRY)
|
||||
throw 56;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 56);
|
||||
#endif // !USE_TRY
|
||||
} // endif
|
||||
#endif
|
||||
|
||||
/*******************************************************************/
|
||||
/* Write column block according to used access method. */
|
||||
/*******************************************************************/
|
||||
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;
|
||||
} // endif Modif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/************* tdbvir C++ Program Source Code File (.CPP) **************/
|
||||
/* PROGRAM NAME: tdbvir.cpp Version 1.1 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2014 */
|
||||
/* PROGRAM NAME: tdbvir.cpp Version 1.2 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2014-2017 */
|
||||
/* This program are the VIR classes DB execution routines. */
|
||||
/***********************************************************************/
|
||||
|
||||
|
@ -289,8 +289,12 @@ void VIRCOL::ReadColumn(PGLOBAL g)
|
|||
{
|
||||
// This should never be called
|
||||
sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
} // end of ReadColumn
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_COLBLK;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
#endif // !USE_TRY
|
||||
} // end of ReadColumn
|
||||
|
||||
/* ---------------------------TDBVICL class -------------------------- */
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/************* Tabxml C++ Program Source Code File (.CPP) **************/
|
||||
/* 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. */
|
||||
/***********************************************************************/
|
||||
|
@ -1314,8 +1314,12 @@ void TDBXML::CloseDB(PGLOBAL g)
|
|||
Docp->CloseDoc(g, To_Xb);
|
||||
|
||||
// This causes a crash in Diagnostics_area::set_error_status
|
||||
// longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} // endif DumpDoc
|
||||
//#if defined(USE_TRY)
|
||||
// throw TYPE_AM_XML;
|
||||
//#else // !USE_TRY
|
||||
// longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
//#endif // !USE_TRY
|
||||
} // endif DumpDoc
|
||||
|
||||
} // endif Changed
|
||||
|
||||
|
@ -1637,8 +1641,12 @@ void XMLCOL::ReadColumn(PGLOBAL g)
|
|||
if (ValNode->GetType() != XML_ELEMENT_NODE &&
|
||||
ValNode->GetType() != XML_ATTRIBUTE_NODE) {
|
||||
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} // endif type
|
||||
#if defined(USE_TRY)
|
||||
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
|
||||
switch (ValNode->GetContent(g, Valbuf, Long + 1)) {
|
||||
|
@ -1648,8 +1656,12 @@ void XMLCOL::ReadColumn(PGLOBAL g)
|
|||
PushWarning(g, Tdbp);
|
||||
break;
|
||||
default:
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} // endswitch
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch
|
||||
|
||||
Value->SetValue_psz(Valbuf);
|
||||
} else {
|
||||
|
@ -1699,7 +1711,11 @@ void XMLCOL::WriteColumn(PGLOBAL g)
|
|||
/* For columns having an Xpath, the Clist must be updated. */
|
||||
/*********************************************************************/
|
||||
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. */
|
||||
|
@ -1771,8 +1787,16 @@ void XMLCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (ColNode == NULL) {
|
||||
strcpy(g->Message, MSG(COL_ALLOC_ERR));
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} // endif ColNode
|
||||
#if defined(USE_TRY)
|
||||
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
|
||||
|
||||
|
@ -1800,8 +1824,12 @@ void XMLCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (strlen(p) > (unsigned)Long) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} else
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
strcpy(Valbuf, p);
|
||||
|
||||
/*********************************************************************/
|
||||
|
@ -1850,8 +1878,12 @@ void XMULCOL::ReadColumn(PGLOBAL g)
|
|||
if (ValNode->GetType() != XML_ELEMENT_NODE &&
|
||||
ValNode->GetType() != XML_ATTRIBUTE_NODE) {
|
||||
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} // endif type
|
||||
#if defined(USE_TRY)
|
||||
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
|
||||
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. */
|
||||
/*********************************************************************/
|
||||
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. */
|
||||
|
@ -1985,8 +2021,12 @@ void XMULCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (len > 1 && !Tdbp->Xpand) {
|
||||
sprintf(g->Message, MSG(BAD_VAL_UPDATE), Name);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} else
|
||||
#if defined(USE_TRY)
|
||||
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);
|
||||
|
||||
} else // Inod != Nod
|
||||
|
@ -2027,8 +2067,12 @@ void XMULCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (ColNode == NULL) {
|
||||
strcpy(g->Message, MSG(COL_ALLOC_ERR));
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} // endif ColNode
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} // endif ColNode
|
||||
|
||||
} // endif ColNode
|
||||
|
||||
|
@ -2056,8 +2100,12 @@ void XMULCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (strlen(p) > (unsigned)Long) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} else
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
strcpy(Valbuf, p);
|
||||
|
||||
/*********************************************************************/
|
||||
|
@ -2088,8 +2136,12 @@ void XPOSCOL::ReadColumn(PGLOBAL g)
|
|||
|
||||
if (Tdbp->Clist == NULL) {
|
||||
strcpy(g->Message, MSG(MIS_TAG_LIST));
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} // endif Clist
|
||||
#if defined(USE_TRY)
|
||||
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))) {
|
||||
// Get the column value from the XML file
|
||||
|
@ -2100,8 +2152,12 @@ void XPOSCOL::ReadColumn(PGLOBAL g)
|
|||
PushWarning(g, Tdbp);
|
||||
break;
|
||||
default:
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} // endswitch
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} // endswitch
|
||||
|
||||
Value->SetValue_psz(Valbuf);
|
||||
} else {
|
||||
|
@ -2151,15 +2207,23 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
|
|||
/* For all columns the Clist must be updated. */
|
||||
/*********************************************************************/
|
||||
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. */
|
||||
/*********************************************************************/
|
||||
if (Tdbp->Clist == NULL) {
|
||||
strcpy(g->Message, MSG(MIS_TAG_LIST));
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} // endif Clist
|
||||
#if defined(USE_TRY)
|
||||
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();
|
||||
k = Rank;
|
||||
|
@ -2183,8 +2247,12 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (strlen(p) > (unsigned)Long) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} else
|
||||
#if defined(USE_TRY)
|
||||
throw TYPE_AM_XML;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
strcpy(Valbuf, p);
|
||||
|
||||
/*********************************************************************/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/************ 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. */
|
||||
/* Second family is VALBLK, representing simple suballocated arrays */
|
||||
|
@ -138,8 +138,12 @@ PSZ VALBLK::GetCharValue(int)
|
|||
|
||||
assert(g);
|
||||
sprintf(g->Message, MSG(NO_CHAR_FROM), Type);
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
return NULL;
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
return NULL;
|
||||
} // end of GetCharValue
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -206,8 +210,12 @@ void VALBLK::ChkIndx(int n)
|
|||
if (n < 0 || n >= Nval) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(BAD_VALBLK_INDX));
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
} // endif n
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif n
|
||||
|
||||
} // end of ChkIndx
|
||||
|
||||
|
@ -216,8 +224,12 @@ void VALBLK::ChkTyp(PVAL v)
|
|||
if (Check && (Type != v->GetType() || Unsigned != v->IsUnsigned())) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(VALTYPE_NOMATCH));
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
} // endif Type
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Type
|
||||
|
||||
} // end of ChkTyp
|
||||
|
||||
|
@ -226,8 +238,12 @@ void VALBLK::ChkTyp(PVBLK vb)
|
|||
if (Check && (Type != vb->GetType() || Unsigned != vb->IsUnsigned())) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(VALTYPE_NOMATCH));
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
} // endif Type
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Type
|
||||
|
||||
} // end of ChkTyp
|
||||
|
||||
|
@ -342,8 +358,12 @@ void TYPBLK<TYPE>::SetValue(PSZ p, int n)
|
|||
if (Check) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(BAD_SET_STRING));
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
} // endif Check
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Check
|
||||
|
||||
bool minus;
|
||||
ulonglong maxval = MaxVal();
|
||||
|
@ -392,8 +412,12 @@ void TYPBLK<double>::SetValue(PSZ p, int n)
|
|||
if (Check) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(BAD_SET_STRING));
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
} // endif Check
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Check
|
||||
|
||||
Typp[n] = atof(p);
|
||||
SetNull(n, false);
|
||||
|
@ -795,8 +819,12 @@ void CHRBLK::SetValue(char *sp, uint len, int n)
|
|||
if (Check && (signed)len > Long) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(SET_STR_TRUNC));
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
} // endif Check
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Check
|
||||
#endif // _DEBUG
|
||||
|
||||
if (sp)
|
||||
|
@ -823,8 +851,12 @@ void CHRBLK::SetValue(PVBLK pv, int n1, int n2)
|
|||
if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(BLKTYPLEN_MISM));
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
} // endif Type
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Type
|
||||
|
||||
if (!(b = pv->IsNull(n2)))
|
||||
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) {
|
||||
PGLOBAL& g = Global;
|
||||
strcpy(g->Message, MSG(BLKTYPLEN_MISM));
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
} // endif Type
|
||||
#if defined(USE_TRY)
|
||||
throw Type;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], Type);
|
||||
#endif // !USE_TRY
|
||||
} // endif Type
|
||||
#endif // _DEBUG
|
||||
char *p = ((CHRBLK*)pv)->Chrp;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/************* 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. */
|
||||
/* These classes contain values of different types. They are used so */
|
||||
|
@ -57,10 +57,17 @@
|
|||
/* Check macro's. */
|
||||
/***********************************************************************/
|
||||
#if defined(_DEBUG)
|
||||
#if defined(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); }
|
||||
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
|
||||
#define CheckType(V)
|
||||
#endif
|
||||
|
@ -1019,12 +1026,20 @@ TYPE TYPVAL<TYPE>::SafeAdd(TYPE n1, TYPE n2)
|
|||
if ((n2 > 0) && (n < n1)) {
|
||||
// Overflow
|
||||
strcpy(g->Message, MSG(FIX_OVFLW_ADD));
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
} else if ((n2 < 0) && (n > n1)) {
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} else if ((n2 < 0) && (n > n1)) {
|
||||
// Underflow
|
||||
strcpy(g->Message, MSG(FIX_UNFLW_ADD));
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
} // endif's n2
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} // endif's n2
|
||||
|
||||
return n;
|
||||
} // end of SafeAdd
|
||||
|
@ -1047,12 +1062,20 @@ TYPE TYPVAL<TYPE>::SafeMult(TYPE n1, TYPE n2)
|
|||
if (n > MinMaxVal(true)) {
|
||||
// Overflow
|
||||
strcpy(g->Message, MSG(FIX_OVFLW_TIMES));
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
} else if (n < MinMaxVal(false)) {
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} else if (n < MinMaxVal(false)) {
|
||||
// Underflow
|
||||
strcpy(g->Message, MSG(FIX_UNFLW_TIMES));
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
} // endif's n2
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} // endif's n2
|
||||
|
||||
return (TYPE)n;
|
||||
} // end of SafeMult
|
||||
|
@ -1432,8 +1455,16 @@ void TYPVAL<PSZ>::SetValue(int n)
|
|||
|
||||
if (k > Len) {
|
||||
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
} else
|
||||
#if defined(USE_TRY)
|
||||
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);
|
||||
|
||||
Null = false;
|
||||
|
@ -1486,8 +1517,12 @@ void TYPVAL<PSZ>::SetValue(longlong n)
|
|||
|
||||
if (k > Len) {
|
||||
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
} else
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
SetValue_psz(buf);
|
||||
|
||||
Null = false;
|
||||
|
@ -1529,8 +1564,12 @@ void TYPVAL<PSZ>::SetValue(double f)
|
|||
|
||||
if (k > Len) {
|
||||
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
} else
|
||||
#if defined(USE_TRY)
|
||||
throw 138;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 138);
|
||||
#endif // !USE_TRY
|
||||
} else
|
||||
SetValue_psz(buf);
|
||||
|
||||
Null = false;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/***************** 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. */
|
||||
/***********************************************************************/
|
||||
|
@ -446,8 +446,12 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
|
|||
#if 0
|
||||
if (!dup->Step) {
|
||||
strcpy(g->Message, MSG(QUERY_CANCELLED));
|
||||
longjmp(g->jumper[g->jump_level], 99);
|
||||
} // endif Step
|
||||
#if defined(USE_TRY)
|
||||
throw 99;
|
||||
#else // !USE_TRY
|
||||
longjmp(g->jumper[g->jump_level], 99);
|
||||
#endif // !USE_TRY
|
||||
} // endif Step
|
||||
#endif // 0
|
||||
|
||||
/*******************************************************************/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/************ 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. */
|
||||
/* 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)
|
||||
{
|
||||
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;
|
||||
} // end of CONSTANT constructor
|
||||
|
@ -95,7 +99,11 @@ CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
|
|||
CONSTANT::CONSTANT(PGLOBAL g, int n)
|
||||
{
|
||||
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;
|
||||
} // end of CONSTANT constructor
|
||||
|
@ -117,7 +125,11 @@ void CONSTANT::Convert(PGLOBAL g, int newtype)
|
|||
{
|
||||
if (Value->GetType() != 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
|
||||
|
||||
|
|
Loading…
Reference in a new issue