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

Merge connect/10.0 into 10.0

Squash all connect/10.0's commits into one and keep only
changes from storage/connect directory.
This commit is contained in:
Vicențiu Ciorbaru
2017-08-01 11:39:10 +03:00
parent 31f4df4505
commit 60c9485a8e
52 changed files with 983 additions and 464 deletions

View File

@@ -520,7 +520,7 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm)
} else if (opc != OP_EXIST) { } else if (opc != OP_EXIST) {
sprintf(g->Message, MSG(MISSING_ARG), opc); sprintf(g->Message, MSG(MISSING_ARG), opc);
throw TYPE_ARRAY; throw (int)TYPE_ARRAY;
} else // OP_EXIST } else // OP_EXIST
return Nval > 0; return Nval > 0;
@@ -683,14 +683,14 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
{ {
if (Vblp == NULL) { if (Vblp == NULL) {
strcpy(g->Message, MSG(PREC_VBLP_NULL)); strcpy(g->Message, MSG(PREC_VBLP_NULL));
throw TYPE_ARRAY; throw (int)TYPE_ARRAY;
} // endif Vblp } // endif Vblp
bool was = Vblp->IsCi(); bool was = Vblp->IsCi();
if (was && !p) { if (was && !p) {
strcpy(g->Message, MSG(BAD_SET_CASE)); strcpy(g->Message, MSG(BAD_SET_CASE));
throw TYPE_ARRAY; throw (int)TYPE_ARRAY;
} // endif Vblp } // endif Vblp
if (was || !p) if (was || !p)
@@ -701,7 +701,7 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
if (!was && Type == TYPE_STRING) if (!was && Type == TYPE_STRING)
// Must be resorted to eliminate duplicate strings // Must be resorted to eliminate duplicate strings
if (Sort(g)) if (Sort(g))
throw TYPE_ARRAY; throw (int)TYPE_ARRAY;
} // end of SetPrecision } // end of SetPrecision
@@ -1035,7 +1035,7 @@ void ARRAY::Printf(PGLOBAL g, FILE *f, uint n)
} else } else
fprintf(f, "%sVALLST: numval=%d\n", m, Nval); fprintf(f, "%sVALLST: numval=%d\n", m, Nval);
} // end of Print } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of ARRAY contents. */ /* Make string output of ARRAY contents. */
@@ -1047,7 +1047,7 @@ void ARRAY::Prints(PGLOBAL, char *ps, uint z)
sprintf(ps, "ARRAY: type=%d\n", Type); sprintf(ps, "ARRAY: type=%d\n", Type);
// More to be implemented later // More to be implemented later
} // end of Print } // end of Prints
/* -------------------------- Class MULAR ---------------------------- */ /* -------------------------- Class MULAR ---------------------------- */

View File

@@ -65,7 +65,7 @@ void BLOCKFILTER::Printf(PGLOBAL, FILE *f, uint n)
fprintf(f, "%sBLOCKFILTER: at %p opc=%d opm=%d result=%d\n", fprintf(f, "%sBLOCKFILTER: at %p opc=%d opm=%d result=%d\n",
m, this, Opc, Opm, Result); m, this, Opc, Opm, Result);
} // end of Print } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of BLOCKFILTER contents. */ /* Make string output of BLOCKFILTER contents. */
@@ -73,7 +73,7 @@ void BLOCKFILTER::Printf(PGLOBAL, FILE *f, uint n)
void BLOCKFILTER::Prints(PGLOBAL, char *ps, uint z) void BLOCKFILTER::Prints(PGLOBAL, char *ps, uint z)
{ {
strncat(ps, "BlockFilter(s)", z); strncat(ps, "BlockFilter(s)", z);
} // end of Print } // end of Prints
/* ---------------------- Class BLKFILLOG ---------------------------- */ /* ---------------------- Class BLKFILLOG ---------------------------- */
@@ -1006,9 +1006,9 @@ void BLOCKINDEX::Printf(PGLOBAL g, FILE *f, UINT n)
m, this, Next, (Colp) ? Colp->GetName() : "Rowid", Kxp, Result); m, this, Next, (Colp) ? Colp->GetName() : "Rowid", Kxp, Result);
if (Next) if (Next)
Next->Print(g, f, n); Next->Printf(g, f, n);
} // end of Print } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of BLOCKINDEX contents. */ /* Make string output of BLOCKINDEX contents. */
@@ -1016,7 +1016,7 @@ void BLOCKINDEX::Printf(PGLOBAL g, FILE *f, UINT n)
void BLOCKINDEX::Prints(PGLOBAL g, char *ps, UINT z) void BLOCKINDEX::Prints(PGLOBAL g, char *ps, UINT z)
{ {
strncat(ps, "BlockIndex(es)", z); strncat(ps, "BlockIndex(es)", z);
} // end of Print } // end of Prints
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */

View File

@@ -197,7 +197,7 @@ int COLBLK::GetLengthEx(void)
void COLBLK::ReadColumn(PGLOBAL g) void COLBLK::ReadColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn"); sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
throw TYPE_COLBLK; throw (int)TYPE_COLBLK;
} // end of ReadColumn } // end of ReadColumn
/***********************************************************************/ /***********************************************************************/
@@ -208,7 +208,7 @@ void COLBLK::ReadColumn(PGLOBAL g)
void COLBLK::WriteColumn(PGLOBAL g) void COLBLK::WriteColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn"); sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
throw TYPE_COLBLK; throw (int)TYPE_COLBLK;
} // end of WriteColumn } // end of WriteColumn
/***********************************************************************/ /***********************************************************************/
@@ -232,7 +232,7 @@ void COLBLK::Printf(PGLOBAL, FILE *f, uint n)
fprintf(f, fprintf(f,
" coluse=%04X status=%04X buftyp=%d value=%p name=%s\n", " coluse=%04X status=%04X buftyp=%d value=%p name=%s\n",
ColUse, Status, Buf_Type, Value, Name); ColUse, Status, Buf_Type, Value, Name);
} // end of Print } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of a column descriptor block. */ /* Make string output of a column descriptor block. */
@@ -240,7 +240,7 @@ void COLBLK::Printf(PGLOBAL, FILE *f, uint n)
void COLBLK::Prints(PGLOBAL, char *ps, uint) void COLBLK::Prints(PGLOBAL, char *ps, uint)
{ {
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name); sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name);
} // end of Print } // end of Prints
/***********************************************************************/ /***********************************************************************/
@@ -262,7 +262,7 @@ SPCBLK::SPCBLK(PCOLUMN cp)
void SPCBLK::WriteColumn(PGLOBAL g) void SPCBLK::WriteColumn(PGLOBAL g)
{ {
sprintf(g->Message, MSG(SPCOL_READONLY), Name); sprintf(g->Message, MSG(SPCOL_READONLY), Name);
throw TYPE_COLBLK; throw (int)TYPE_COLBLK;
} // end of WriteColumn } // end of WriteColumn
/***********************************************************************/ /***********************************************************************/

View File

@@ -1,4 +1,5 @@
/* Copyright (C) Olivier Bertrand 2004 - 2017 /* Copyright (C) Olivier Bertrand 2004 - 2017
Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -66,8 +67,10 @@ PGLOBAL CntExit(PGLOBAL g)
if (g) { if (g) {
CntEndDB(g); CntEndDB(g);
if (g->Activityp) if (g->Activityp) {
delete g->Activityp; delete g->Activityp;
g->Activityp = NULL;
} // endif Activityp
PlugExit(g); PlugExit(g);
g= NULL; g= NULL;
@@ -185,10 +188,10 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
/***********************************************************************/ /***********************************************************************/
PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h) PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
{ {
PTDB tdbp; PTDB tdbp = NULL;
PTABLE tabp; PTABLE tabp;
PDBUSER dup = PlgGetUser(g); PDBUSER dup = PlgGetUser(g);
volatile PCATLG cat = (dup) ? dup->Catalog : NULL; // Safe over longjmp volatile PCATLG cat = (dup) ? dup->Catalog : NULL; // Safe over throw
if (trace) if (trace)
printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat); printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat);

View File

@@ -1,4 +1,4 @@
/* Copyright (C) Olivier Bertrand 2004 - 2011 /* Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -15,6 +15,7 @@
/**************** Cnt H Declares Source Code File (.H) *****************/ /**************** Cnt H Declares Source Code File (.H) *****************/
/* Name: CONNECT.H Version 2.4 */ /* Name: CONNECT.H Version 2.4 */
/* Author Olivier BERTRAND bertrandop@gmail.com */
/* This file contains the some based classes declares. */ /* This file contains the some based classes declares. */
/***********************************************************************/ /***********************************************************************/
#include "filamtxt.h" #include "filamtxt.h"

View File

@@ -1,3 +1,4 @@
/* Copyright (C) MariaDB Corporation Ab */
#define MSG_ACCESS_VIOLATN "Access violation" #define MSG_ACCESS_VIOLATN "Access violation"
#define MSG_ADD_BAD_TYPE "Array add value type mismatch (%s -> %s)" #define MSG_ADD_BAD_TYPE "Array add value type mismatch (%s -> %s)"
#define MSG_ALLOC_ERROR "Error allocating %s" #define MSG_ALLOC_ERROR "Error allocating %s"

View File

@@ -87,7 +87,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc)
case OP_EXIST: bt = 0x00; break; case OP_EXIST: bt = 0x00; break;
default: default:
sprintf(g->Message, MSG(BAD_FILTER_OP), opc); sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
throw TYPE_ARRAY; throw (int)TYPE_FILTER;
} // endswitch opc } // endswitch opc
return bt; return bt;
@@ -1437,7 +1437,7 @@ void FILTER::Printf(PGLOBAL g, FILE *f, uint n)
} // endfor fp } // endfor fp
} // end of Print } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of TABLE contents (z should be checked). */ /* Make string output of TABLE contents (z should be checked). */
@@ -1579,7 +1579,7 @@ void FILTER::Prints(PGLOBAL g, char *ps, uint z)
bcp = bxp; bcp = bxp;
} while (bcp); // enddo } while (bcp); // enddo
} // end of Print } // end of Prints
/* -------------------- Derived Classes Functions -------------------- */ /* -------------------- Derived Classes Functions -------------------- */
@@ -1697,8 +1697,6 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
if (trace) if (trace)
htrc("PrepareFilter: fp=%p having=%d\n", fp, having); htrc("PrepareFilter: fp=%p having=%d\n", fp, having);
//if (fp)
// fp->Print(g, debug, 0);
while (fp) { while (fp) {
if (fp->Opc == OP_SEP) if (fp->Opc == OP_SEP)
@@ -1712,7 +1710,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
break; // Remove eventual ending separator(s) break; // Remove eventual ending separator(s)
// if (fp->Convert(g, having)) // if (fp->Convert(g, having))
// throw TYPE_ARRAY; // throw (int)TYPE_FILTER;
filp = fp; filp = fp;
fp = fp->Next; fp = fp->Next;
@@ -1721,8 +1719,6 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
if (trace) if (trace)
htrc(" returning filp=%p\n", filp); htrc(" returning filp=%p\n", filp);
//if (filp)
// filp->Print(g, debug, 0);
return filp; return filp;
} // end of PrepareFilter } // end of PrepareFilter
@@ -1745,7 +1741,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
// return TRUE; // return TRUE;
if (filp->Eval(g)) if (filp->Eval(g))
throw TYPE_FILTER; throw (int)TYPE_FILTER;
if (trace > 1) if (trace > 1)
htrc("PlugFilter filp=%p result=%d\n", htrc("PlugFilter filp=%p result=%d\n",

View File

@@ -1,6 +1,7 @@
/***********************************************************************/ /***********************************************************************/
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */ /* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright Olivier Bertrand 1993-2017 */ /* (C) Copyright MariaDB Corporation Ab */
/* Author Olivier Bertrand 1993-2017 */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
@@ -90,6 +91,7 @@
#define TYPE_BIGINT 5 #define TYPE_BIGINT 5
#define TYPE_LIST 6 #define TYPE_LIST 6
#define TYPE_INT 7 #define TYPE_INT 7
#define TYPE_DATE 8
#define TYPE_DECIM 9 #define TYPE_DECIM 9
#define TYPE_BIN 10 #define TYPE_BIN 10
#define TYPE_PCHAR 11 #define TYPE_PCHAR 11

View File

@@ -1,4 +1,4 @@
/* Copyright (C) Olivier Bertrand 2004 - 2017 /* Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -98,9 +98,8 @@
rnd_next signals that it has reached the end of its data. Calls to rnd_next signals that it has reached the end of its data. Calls to
ha_connect::extra() are hints as to what will be occuring to the request. ha_connect::extra() are hints as to what will be occuring to the request.
Happy use!<br> Author Olivier Bertrand
-Olivier */
*/
#ifdef USE_PRAGMA_IMPLEMENTATION #ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation #pragma implementation // gcc: Class implementation
@@ -198,11 +197,13 @@ extern "C" {
char *ClassPath; char *ClassPath;
#endif // JDBC_SUPPORT #endif // JDBC_SUPPORT
#if defined(__WIN__) //#if defined(__WIN__)
CRITICAL_SECTION parsec; // Used calling the Flex parser //CRITICAL_SECTION parsec; // Used calling the Flex parser
#else // !__WIN__ //#else // !__WIN__
pthread_mutex_t parmut = PTHREAD_MUTEX_INITIALIZER; //pthread_mutex_t parmut = PTHREAD_MUTEX_INITIALIZER;
#endif // !__WIN__ //#endif // !__WIN__
pthread_mutex_t parmut;
pthread_mutex_t usrmut;
/***********************************************************************/ /***********************************************************************/
/* Utility functions. */ /* Utility functions. */
@@ -221,6 +222,7 @@ void mongo_init(bool);
USETEMP UseTemp(void); USETEMP UseTemp(void);
int GetConvSize(void); int GetConvSize(void);
TYPCONV GetTypeConv(void); TYPCONV GetTypeConv(void);
char *GetJsonNull(void);
uint GetJsonGrpSize(void); uint GetJsonGrpSize(void);
char *GetJavaWrapper(void); char *GetJavaWrapper(void);
uint GetWorkSize(void); uint GetWorkSize(void);
@@ -330,6 +332,13 @@ static MYSQL_THDVAR_ENUM(
0, // def (no) 0, // def (no)
&xconv_typelib); // typelib &xconv_typelib); // typelib
// Null representation for JSON values
static MYSQL_THDVAR_STR(json_null,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
"Representation of Json null values",
// check_json_null, update_json_null,
NULL, NULL, "<null>");
// Estimate max number of rows for JSON aggregate functions // Estimate max number of rows for JSON aggregate functions
static MYSQL_THDVAR_UINT(json_grp_size, static MYSQL_THDVAR_UINT(json_grp_size,
PLUGIN_VAR_RQCMDARG, // opt PLUGIN_VAR_RQCMDARG, // opt
@@ -381,6 +390,8 @@ bool ExactInfo(void) {return THDVAR(current_thd, exact_info);}
USETEMP UseTemp(void) {return (USETEMP)THDVAR(current_thd, use_tempfile);} USETEMP UseTemp(void) {return (USETEMP)THDVAR(current_thd, use_tempfile);}
int GetConvSize(void) {return THDVAR(current_thd, conv_size);} int GetConvSize(void) {return THDVAR(current_thd, conv_size);}
TYPCONV GetTypeConv(void) {return (TYPCONV)THDVAR(current_thd, type_conv);} TYPCONV GetTypeConv(void) {return (TYPCONV)THDVAR(current_thd, type_conv);}
char *GetJsonNull(void)
{return connect_hton ? THDVAR(current_thd, json_null) : NULL;}
uint GetJsonGrpSize(void) uint GetJsonGrpSize(void)
{return connect_hton ? THDVAR(current_thd, json_grp_size) : 10;} {return connect_hton ? THDVAR(current_thd, json_grp_size) : 10;}
uint GetWorkSize(void) {return THDVAR(current_thd, work_size);} uint GetWorkSize(void) {return THDVAR(current_thd, work_size);}
@@ -666,10 +677,12 @@ static int connect_init_func(void *p)
#if defined(__WIN__) #if defined(__WIN__)
sql_print_information("CONNECT: %s", compver); sql_print_information("CONNECT: %s", compver);
InitializeCriticalSection((LPCRITICAL_SECTION)&parsec); //InitializeCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !__WIN__ #else // !__WIN__
sql_print_information("CONNECT: %s", version); sql_print_information("CONNECT: %s", version);
#endif // !__WIN__ #endif // !__WIN__
pthread_mutex_init(&parmut, NULL);
pthread_mutex_init(&usrmut, NULL);
#if defined(LIBXML2_SUPPORT) #if defined(LIBXML2_SUPPORT)
XmlInitParserLib(); XmlInitParserLib();
@@ -718,11 +731,12 @@ static int connect_done_func(void *)
#endif // JDBC_SUPPORT #endif // JDBC_SUPPORT
#if defined(__WIN__) #if defined(__WIN__)
DeleteCriticalSection((LPCRITICAL_SECTION)&parsec); //DeleteCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !__WIN__ #else // !__WIN__
PROFILE_End(); PROFILE_End();
#endif // !__WIN__ #endif // !__WIN__
pthread_mutex_lock(&usrmut);
for (pc= user_connect::to_users; pc; pc= pn) { for (pc= user_connect::to_users; pc; pc= pn) {
if (pc->g) if (pc->g)
PlugCleanup(pc->g, true); PlugCleanup(pc->g, true);
@@ -731,6 +745,10 @@ static int connect_done_func(void *)
delete pc; delete pc;
} // endfor pc } // endfor pc
pthread_mutex_unlock(&usrmut);
pthread_mutex_destroy(&usrmut);
pthread_mutex_destroy(&parmut);
connect_hton= NULL; connect_hton= NULL;
DBUG_RETURN(error); DBUG_RETURN(error);
} // end of connect_done_func } // end of connect_done_func
@@ -843,6 +861,7 @@ ha_connect::~ha_connect(void)
static void PopUser(PCONNECT xp) static void PopUser(PCONNECT xp)
{ {
if (xp) { if (xp) {
pthread_mutex_lock(&usrmut);
xp->count--; xp->count--;
if (!xp->count) { if (!xp->count) {
@@ -867,6 +886,7 @@ static void PopUser(PCONNECT xp)
delete xp; delete xp;
} // endif count } // endif count
pthread_mutex_unlock(&usrmut);
} // endif xp } // endif xp
} // end of PopUser } // end of PopUser
@@ -880,13 +900,24 @@ static PCONNECT GetUser(THD *thd, PCONNECT xp)
if (!thd) if (!thd)
return NULL; return NULL;
if (xp && thd == xp->thdp) if (xp) {
if (thd == xp->thdp)
return xp; return xp;
PopUser(xp); // Avoid memory leak
} // endif xp
pthread_mutex_lock(&usrmut);
for (xp= user_connect::to_users; xp; xp= xp->next) for (xp= user_connect::to_users; xp; xp= xp->next)
if (thd == xp->thdp) if (thd == xp->thdp)
break; break;
if (xp)
xp->count++;
pthread_mutex_unlock(&usrmut);
if (!xp) { if (!xp) {
xp= new user_connect(thd); xp= new user_connect(thd);
@@ -895,8 +926,7 @@ static PCONNECT GetUser(THD *thd, PCONNECT xp)
xp= NULL; xp= NULL;
} // endif user_init } // endif user_init
} else } // endif xp
xp->count++;
return xp; return xp;
} // end of GetUser } // end of GetUser
@@ -1025,35 +1055,53 @@ PCSZ GetListOption(PGLOBAL g, PCSZ opname, PCSZ oplist, PCSZ def)
return (char*)def; return (char*)def;
char key[16], val[256]; char key[16], val[256];
char *pk, *pv, *pn; char *pv, *pn, *pk = (char*)oplist;
PCSZ opval= def; PCSZ opval = def;
int n; int n;
for (pk= (char*)oplist; pk; pk= ++pn) { while (*pk == ' ')
pn= strchr(pk, ','); pk++;
pv= strchr(pk, '=');
for (; pk; pk = pn) {
pn = strchr(pk, ',');
pv = strchr(pk, '=');
if (pv && (!pn || pv < pn)) { if (pv && (!pn || pv < pn)) {
n= MY_MIN(pv - pk, (int)sizeof(key) - 1); n = MY_MIN(static_cast<size_t>(pv - pk), sizeof(key) - 1);
memcpy(key, pk, n); memcpy(key, pk, n);
key[n]= 0;
pv++; while (n && key[n - 1] == ' ')
n= MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1); n--;
key[n] = 0;
while (*(++pv) == ' ');
n = MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1);
memcpy(val, pv, n); memcpy(val, pv, n);
val[n]= 0;
while (n && val[n - 1] == ' ')
n--;
val[n] = 0;
} else { } else {
n= MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1); n = MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1);
memcpy(key, pk, n); memcpy(key, pk, n);
key[n]= 0;
val[0]= 0; while (n && key[n - 1] == ' ')
n--;
key[n] = 0;
val[0] = 0;
} // endif pv } // endif pv
if (!stricmp(opname, key)) { if (!stricmp(opname, key)) {
opval= PlugDup(g, val); opval = PlugDup(g, val);
break; break;
} else if (!pn) } else if (!pn)
break; break;
while (*(++pn) == ' ');
} // endfor pk } // endfor pk
return opval; return opval;
@@ -1427,7 +1475,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VAR_STRING:
pcf->Flags |= U_VAR; pcf->Flags |= U_VAR;
/* fall through */ // fall through
default: default:
pcf->Type= MYSQLtoPLG(fp->type(), &v); pcf->Type= MYSQLtoPLG(fp->type(), &v);
break; break;
@@ -2802,7 +2850,7 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
case Item_func::LIKE_FUNC: vop= OP_LIKE; break; case Item_func::LIKE_FUNC: vop= OP_LIKE; break;
case Item_func::ISNOTNULL_FUNC: case Item_func::ISNOTNULL_FUNC:
neg = true; neg = true;
/* fall through */ // fall through
case Item_func::ISNULL_FUNC: vop= OP_NULL; break; case Item_func::ISNULL_FUNC: vop= OP_NULL; break;
case Item_func::IN_FUNC: vop= OP_IN; case Item_func::IN_FUNC: vop= OP_IN;
case Item_func::BETWEEN: case Item_func::BETWEEN:
@@ -4052,6 +4100,11 @@ int ha_connect::info(uint flag)
DBUG_ENTER("ha_connect::info"); DBUG_ENTER("ha_connect::info");
if (!g) {
my_message(ER_UNKNOWN_ERROR, "Cannot get g pointer", MYF(0));
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
} // endif g
if (trace) if (trace)
htrc("%p In info: flag=%u valid_info=%d\n", this, flag, valid_info); htrc("%p In info: flag=%u valid_info=%d\n", this, flag, valid_info);
@@ -4063,7 +4116,7 @@ int ha_connect::info(uint flag)
if (xmod == MODE_ANY || xmod == MODE_ALTER) { if (xmod == MODE_ANY || xmod == MODE_ALTER) {
// Pure info, not a query // Pure info, not a query
pure= true; pure= true;
xp->CheckCleanup(); xp->CheckCleanup(xmod == MODE_ANY && valid_query_id == 0);
} // endif xmod } // endif xmod
// This is necessary for getting file length // This is necessary for getting file length
@@ -4247,8 +4300,8 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
} else } else
return false; return false;
/* check FILE_ACL */ // check FILE_ACL
/* fall through */ // fall through
case TAB_ODBC: case TAB_ODBC:
case TAB_JDBC: case TAB_JDBC:
case TAB_MYSQL: case TAB_MYSQL:
@@ -7060,6 +7113,7 @@ static struct st_mysql_sys_var* connect_system_variables[]= {
#if defined(XMSG) #if defined(XMSG)
MYSQL_SYSVAR(errmsg_dir_path), MYSQL_SYSVAR(errmsg_dir_path),
#endif // XMSG #endif // XMSG
MYSQL_SYSVAR(json_null),
MYSQL_SYSVAR(json_grp_size), MYSQL_SYSVAR(json_grp_size),
#if defined(JDBC_SUPPORT) #if defined(JDBC_SUPPORT)
MYSQL_SYSVAR(jvm_path), MYSQL_SYSVAR(jvm_path),
@@ -7083,6 +7137,6 @@ maria_declare_plugin(connect)
NULL, /* status variables */ NULL, /* status variables */
connect_system_variables, /* system variables */ connect_system_variables, /* system variables */
"1.06.0001", /* string version */ "1.06.0001", /* string version */
MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */ MariaDB_PLUGIN_MATURITY_BETA /* maturity */
} }
maria_declare_plugin_end; maria_declare_plugin_end;

View File

@@ -1,4 +1,4 @@
/* Copyright (C) Olivier Bertrand 2004 - 2015 /* Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -14,6 +14,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
/** @file ha_connect.h /** @file ha_connect.h
Author Olivier Bertrand
@brief @brief
The ha_connect engine is a prototype storage engine to access external data. The ha_connect engine is a prototype storage engine to access external data.

View File

@@ -121,13 +121,17 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
switch (stp) { switch (stp) {
case -1: // LONGVARCHAR case -1: // LONGVARCHAR
case -16: // LONGNVARCHAR (unicode)
if (GetTypeConv() != TPC_YES) if (GetTypeConv() != TPC_YES)
return TYPE_ERROR; return TYPE_ERROR;
else else
len = MY_MIN(abs(len), GetConvSize()); len = MY_MIN(abs(len), GetConvSize());
case 12: // VARCHAR case 12: // VARCHAR
case -9: // NVARCHAR (unicode)
v = 'V'; v = 'V';
case 1: // CHAR case 1: // CHAR
case -15: // NCHAR (unicode)
case -8: // ROWID
type = TYPE_STRING; type = TYPE_STRING;
break; break;
case 2: // NUMERIC case 2: // NUMERIC
@@ -143,6 +147,7 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
break; break;
case -6: // TINYINT case -6: // TINYINT
case -7: // BIT case -7: // BIT
case 16: // BOOLEAN
type = TYPE_TINY; type = TYPE_TINY;
break; break;
case 6: // FLOAT case 6: // FLOAT
@@ -152,7 +157,7 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
break; break;
case 93: // TIMESTAMP, DATETIME case 93: // TIMESTAMP, DATETIME
type = TYPE_DATE; type = TYPE_DATE;
len = 19 + ((prec) ? (prec+1) : 0); len = 19 + ((prec) ? (prec + 1) : 0);
v = (tn && toupper(tn[0]) == 'T') ? 'S' : 'E'; v = (tn && toupper(tn[0]) == 'T') ? 'S' : 'E';
break; break;
case 91: // DATE, YEAR case 91: // DATE, YEAR
@@ -169,7 +174,7 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
break; break;
case 92: // TIME case 92: // TIME
type = TYPE_DATE; type = TYPE_DATE;
len = 8 + ((prec) ? (prec+1) : 0); len = 8 + ((prec) ? (prec + 1) : 0);
v = 'T'; v = 'T';
break; break;
case -5: // BIGINT case -5: // BIGINT
@@ -178,6 +183,16 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
case 0: // NULL case 0: // NULL
case -2: // BINARY case -2: // BINARY
case -4: // LONGVARBINARY case -4: // LONGVARBINARY
case 70: // DATALINK
case 2000: // JAVA_OBJECT
case 2001: // DISTINCT
case 2002: // STRUCT
case 2003: // ARRAY
case 2004: // BLOB
case 2005: // CLOB
case 2006: // REF
case 2009: // SQLXML
case 2011: // NCLOB
default: default:
type = TYPE_ERROR; type = TYPE_ERROR;
len = 0; len = 0;
@@ -1200,7 +1215,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
if (rank == 0) if (rank == 0)
if (!name || (jn = env->NewStringUTF(name)) == nullptr) { if (!name || (jn = env->NewStringUTF(name)) == nullptr) {
sprintf(g->Message, "Fail to allocate jstring %s", SVP(name)); sprintf(g->Message, "Fail to allocate jstring %s", SVP(name));
throw TYPE_AM_JDBC; throw (int)TYPE_AM_JDBC;
} // endif name } // endif name
// Returns 666 is case of error // Returns 666 is case of error
@@ -1208,7 +1223,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
if (Check((ctyp == 666) ? -1 : 1)) { if (Check((ctyp == 666) ? -1 : 1)) {
sprintf(g->Message, "Getting ctyp: %s", Msg); sprintf(g->Message, "Getting ctyp: %s", Msg);
throw TYPE_AM_JDBC; throw (int)TYPE_AM_JDBC;
} // endif Check } // endif Check
if (val->GetNullable()) if (val->GetNullable())
@@ -1225,9 +1240,12 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
switch (ctyp) { switch (ctyp) {
case 12: // VARCHAR case 12: // VARCHAR
case -9: // NVARCHAR
case -1: // LONGVARCHAR case -1: // LONGVARCHAR
case 1: // CHAR case 1: // CHAR
case -15: // NCHAR
case 3: // DECIMAL case 3: // DECIMAL
case -8: // ROWID
if (jb && ctyp != 3) if (jb && ctyp != 3)
cn = (jstring)jb; cn = (jstring)jb;
else if (!gmID(g, chrfldid, "StringField", "(ILjava/lang/String;)Ljava/lang/String;")) else if (!gmID(g, chrfldid, "StringField", "(ILjava/lang/String;)Ljava/lang/String;"))
@@ -1245,6 +1263,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
case 4: // INTEGER case 4: // INTEGER
case 5: // SMALLINT case 5: // SMALLINT
case -6: // TINYINT case -6: // TINYINT
case 16: // BOOLEAN
case -7: // BIT case -7: // BIT
if (!gmID(g, intfldid, "IntField", "(ILjava/lang/String;)I")) if (!gmID(g, intfldid, "IntField", "(ILjava/lang/String;)I"))
val->SetValue((int)env->CallIntMethod(job, intfldid, rank, jn)); val->SetValue((int)env->CallIntMethod(job, intfldid, rank, jn));
@@ -1315,7 +1334,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
env->DeleteLocalRef(jn); env->DeleteLocalRef(jn);
sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp); sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp);
throw TYPE_AM_JDBC; throw (int)TYPE_AM_JDBC;
} // endif Check } // endif Check
if (rank == 0) if (rank == 0)

View File

@@ -1,5 +1,5 @@
/*************** json CPP Declares Source Code File (.H) ***************/ /*************** json CPP Declares Source Code File (.H) ***************/
/* Name: json.cpp Version 1.3 */ /* Name: json.cpp Version 1.4 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
/* */ /* */
@@ -53,6 +53,38 @@ void trans_func(unsigned int u, _EXCEPTION_POINTERS* pExp)
char *GetExceptionDesc(PGLOBAL g, unsigned int e); char *GetExceptionDesc(PGLOBAL g, unsigned int e);
#endif // SE_CATCH #endif // SE_CATCH
char *GetJsonNull(void);
/***********************************************************************/
/* IsNum: check whether this string is all digits. */
/***********************************************************************/
bool IsNum(PSZ s)
{
for (char *p = s; *p; p++)
if (*p == ']')
break;
else if (!isdigit(*p) || *p == '-')
return false;
return true;
} // end of IsNum
/***********************************************************************/
/* NextChr: return the first found '[' or Sep pointer. */
/***********************************************************************/
char *NextChr(PSZ s, char sep)
{
char *p1 = strchr(s, '[');
char *p2 = strchr(s, sep);
if (!p2)
return p1;
else if (p1)
return MY_MIN(p1, p2);
return p2;
} // end of NextChr
/***********************************************************************/ /***********************************************************************/
/* Parse a json string. */ /* Parse a json string. */
@@ -933,6 +965,25 @@ return false;
/* -------------------------- Class JOBJECT -------------------------- */ /* -------------------------- Class JOBJECT -------------------------- */
/***********************************************************************/
/* Return the number of pairs in this object. */
/***********************************************************************/
int JOBJECT::GetSize(bool b)
{
if (b) {
// Return only non null pairs
int n = 0;
for (PJPR jpp = First; jpp; jpp = jpp->Next)
if (jpp->Val && !jpp->Val->IsNull())
n++;
return n;
} else
return Size;
} // end of GetSize
/***********************************************************************/ /***********************************************************************/
/* Add a new pair to an Object. */ /* Add a new pair to an Object. */
/***********************************************************************/ /***********************************************************************/
@@ -992,14 +1043,31 @@ PSZ JOBJECT::GetText(PGLOBAL g, PSZ text)
if (!First && n) if (!First && n)
return NULL; return NULL;
else for (PJPR jp = First; jp; jp = jp->Next) else if (n == 1 && Size == 1 && !strcmp(First->GetKey(), "$date")) {
int i;
First->Val->GetText(g, text);
i = (text[1] == '-' ? 2 : 1);
if (IsNum(text + i)) {
// Date is in milliseconds
int j = (int)strlen(text);
if (j >= 4 + i)
text[j - 3] = 0; // Change it to seconds
else
strcpy(text, " 0");
} // endif text
} else for (PJPR jp = First; jp; jp = jp->Next)
jp->Val->GetText(g, text); jp->Val->GetText(g, text);
if (n) if (n)
PlugSubAlloc(g, NULL, strlen(text) + 1); PlugSubAlloc(g, NULL, strlen(text) + 1);
return text + n; return text + n;
} // end of GetValue; } // end of GetText;
/***********************************************************************/ /***********************************************************************/
/* Merge two objects. */ /* Merge two objects. */
@@ -1070,6 +1138,25 @@ bool JOBJECT::IsNull(void)
/* -------------------------- Class JARRAY --------------------------- */ /* -------------------------- Class JARRAY --------------------------- */
/***********************************************************************/
/* Return the number of values in this object. */
/***********************************************************************/
int JARRAY::GetSize(bool b)
{
if (b) {
// Return only non null values
int n = 0;
for (PJVAL jvp = First; jvp; jvp = jvp->Next)
if (!jvp->IsNull())
n++;
return n;
} else
return Size;
} // end of GetSize
/***********************************************************************/ /***********************************************************************/
/* Make the array of values from the values list. */ /* Make the array of values from the values list. */
/***********************************************************************/ /***********************************************************************/
@@ -1178,6 +1265,30 @@ bool JARRAY::SetValue(PGLOBAL g, PJVAL jvp, int n)
return false; return false;
} // end of SetValue } // end of SetValue
/***********************************************************************/
/* Return the text corresponding to all values. */
/***********************************************************************/
PSZ JARRAY::GetText(PGLOBAL g, PSZ text)
{
int n;
PJVAL jp;
if (!text) {
text = (char*)PlugSubAlloc(g, NULL, 0);
text[0] = 0;
n = 1;
} else
n = 0;
for (jp = First; jp; jp = jp->Next)
jp->GetText(g, text);
if (n)
PlugSubAlloc(g, NULL, strlen(text) + 1);
return text + n;
} // end of GetText;
/***********************************************************************/ /***********************************************************************/
/* Delete a Value from the Arrays Value list. */ /* Delete a Value from the Arrays Value list. */
/***********************************************************************/ /***********************************************************************/
@@ -1239,7 +1350,7 @@ JTYP JVALUE::GetValType(void)
else if (Value) else if (Value)
return (JTYP)Value->GetType(); return (JTYP)Value->GetType();
else else
return (JTYP)TYPE_VOID; return TYPE_NULL;
} // end of GetValType } // end of GetValType
@@ -1303,7 +1414,7 @@ PSZ JVALUE::GetString(void)
/***********************************************************************/ /***********************************************************************/
PSZ JVALUE::GetText(PGLOBAL g, PSZ text) PSZ JVALUE::GetText(PGLOBAL g, PSZ text)
{ {
if (Jsp && Jsp->GetType() == TYPE_JOB) if (Jsp)
return Jsp->GetText(g, text); return Jsp->GetText(g, text);
char buf[32]; char buf[32];
@@ -1311,8 +1422,8 @@ PSZ JVALUE::GetText(PGLOBAL g, PSZ text)
if (s) if (s)
strcat(strcat(text, " "), s); strcat(strcat(text, " "), s);
else else if (GetJsonNull())
strcat(text, " ???"); strcat(strcat(text, " "), GetJsonNull());
return text; return text;
} // end of GetText } // end of GetText

View File

@@ -1,7 +1,7 @@
/**************** json H Declares Source Code File (.H) ****************/ /**************** json H Declares Source Code File (.H) ****************/
/* Name: json.h Version 1.2 */ /* Name: json.h Version 1.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */ /* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
/* */ /* */
/* This file contains the JSON classes declares. */ /* This file contains the JSON classes declares. */
/***********************************************************************/ /***********************************************************************/
@@ -13,11 +13,13 @@
#define X #define X
#endif #endif
enum JTYP {TYPE_STRG = 1, enum JTYP {TYPE_NULL = TYPE_VOID,
TYPE_DBL = 2, TYPE_STRG = TYPE_STRING,
TYPE_BOOL = 4, TYPE_DBL = TYPE_DOUBLE,
TYPE_BINT = 5, TYPE_BOOL = TYPE_TINY,
TYPE_INTG = 7, TYPE_BINT = TYPE_BIGINT,
TYPE_DTM = TYPE_DATE,
TYPE_INTG = TYPE_INT,
TYPE_JSON = 12, TYPE_JSON = 12,
TYPE_JAR, TYPE_JAR,
TYPE_JOB, TYPE_JOB,
@@ -145,6 +147,7 @@ class JSON : public BLOCK {
JSON(void) {Size = 0;} JSON(void) {Size = 0;}
int size(void) {return Size;} int size(void) {return Size;}
virtual int GetSize(bool b) {return Size;}
virtual void Clear(void) {Size = 0;} virtual void Clear(void) {Size = 0;}
virtual JTYP GetType(void) {return TYPE_JSON;} virtual JTYP GetType(void) {return TYPE_JSON;}
virtual JTYP GetValType(void) {X return TYPE_JSON;} virtual JTYP GetValType(void) {X return TYPE_JSON;}
@@ -195,6 +198,7 @@ class JOBJECT : public JSON {
virtual void Clear(void) {First = Last = NULL; Size = 0;} virtual void Clear(void) {First = Last = NULL; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JOB;} virtual JTYP GetType(void) {return TYPE_JOB;}
virtual PJPR GetFirst(void) {return First;} virtual PJPR GetFirst(void) {return First;}
virtual int GetSize(bool b);
virtual PJPR AddPair(PGLOBAL g, PCSZ key); virtual PJPR AddPair(PGLOBAL g, PCSZ key);
virtual PJOB GetObject(void) {return this;} virtual PJOB GetObject(void) {return this;}
virtual PJVAL GetValue(const char* key); virtual PJVAL GetValue(const char* key);
@@ -223,9 +227,11 @@ class JARRAY : public JSON {
virtual void Clear(void) {First = Last = NULL; Size = 0;} virtual void Clear(void) {First = Last = NULL; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JAR;} virtual JTYP GetType(void) {return TYPE_JAR;}
virtual PJAR GetArray(void) {return this;} virtual PJAR GetArray(void) {return this;}
virtual int GetSize(bool b);
PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL); PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL);
virtual void InitArray(PGLOBAL g); virtual void InitArray(PGLOBAL g);
virtual PJVAL GetValue(int i); virtual PJVAL GetValue(int i);
virtual PSZ GetText(PGLOBAL g, PSZ text);
virtual bool Merge(PGLOBAL g, PJSON jsp); virtual bool Merge(PGLOBAL g, PJSON jsp);
virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i); virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i);
virtual bool DeleteValue(int n); virtual bool DeleteValue(int n);
@@ -245,20 +251,20 @@ class JARRAY : public JSON {
class JVALUE : public JSON { class JVALUE : public JSON {
friend class JARRAY; friend class JARRAY;
friend class JSNX; friend class JSNX;
friend class JSONCOL;
friend PJVAL ParseValue(PGLOBAL, int&, STRG&, bool*); friend PJVAL ParseValue(PGLOBAL, int&, STRG&, bool*);
friend bool SerializeValue(JOUT *, PJVAL); friend bool SerializeValue(JOUT *, PJVAL);
public: public:
JVALUE(void) : JSON() JVALUE(void) : JSON() {Clear();}
{Jsp = NULL; Value = NULL; Next = NULL; Del = false;}
JVALUE(PJSON jsp) : JSON() JVALUE(PJSON jsp) : JSON()
{Jsp = jsp; Value = NULL; Next = NULL; Del = false;} {Jsp = jsp; Value = NULL; Next = NULL; Del = false; Size = 1;}
JVALUE(PGLOBAL g, PVAL valp); JVALUE(PGLOBAL g, PVAL valp);
JVALUE(PGLOBAL g, PCSZ strp); JVALUE(PGLOBAL g, PCSZ strp);
using JSON::GetValue; using JSON::GetValue;
using JSON::SetValue; using JSON::SetValue;
virtual void Clear(void) virtual void Clear(void)
{Jsp = NULL; Value = NULL; Next = NULL; Del = false; Size = 0;} {Jsp = NULL; Value = NULL; Next = NULL; Del = false; Size = 1;}
virtual JTYP GetType(void) {return TYPE_JVAL;} virtual JTYP GetType(void) {return TYPE_JVAL;}
virtual JTYP GetValType(void); virtual JTYP GetValType(void);
virtual PJOB GetObject(void); virtual PJOB GetObject(void);

View File

@@ -1,5 +1,5 @@
/****************** jsonudf C++ Program Source Code File (.CPP) ******************/ /****************** jsonudf C++ Program Source Code File (.CPP) ******************/
/* PROGRAM NAME: jsonudf Version 1.5 */ /* PROGRAM NAME: jsonudf Version 1.6 */
/* (C) Copyright to the author Olivier BERTRAND 2015-2017 */ /* (C) Copyright to the author Olivier BERTRAND 2015-2017 */
/* This program are the JSON User Defined Functions . */ /* This program are the JSON User Defined Functions . */
/*********************************************************************************/ /*********************************************************************************/
@@ -27,6 +27,7 @@
#endif #endif
#define M 7 #define M 7
char *GetJsonNull(void);
uint GetJsonGrpSize(void); uint GetJsonGrpSize(void);
static int IsJson(UDF_ARGS *args, uint i); static int IsJson(UDF_ARGS *args, uint i);
static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i); static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i);
@@ -327,11 +328,13 @@ void JSNX::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n)
SetJsonValue(g, vp, val->GetArray()->GetValue(0), n); SetJsonValue(g, vp, val->GetArray()->GetValue(0), n);
break; break;
case TYPE_JOB: case TYPE_JOB:
// if (!vp->IsTypeNum() || !Strict) { // if (!vp->IsTypeNum() || !Strict) {
vp->SetValue_psz(val->GetObject()->GetText(g, NULL)); vp->SetValue_psz(val->GetObject()->GetText(g, NULL));
break; break;
// } // endif Type // } // endif Type
case TYPE_NULL:
vp->SetNull(true);
default: default:
vp->Reset(); vp->Reset();
} // endswitch Type } // endswitch Type
@@ -459,7 +462,7 @@ PVAL JSNX::ExpandArray(PGLOBAL g, PJAR arp, int n)
/*********************************************************************************/ /*********************************************************************************/
PVAL JSNX::CalculateArray(PGLOBAL g, PJAR arp, int n) PVAL JSNX::CalculateArray(PGLOBAL g, PJAR arp, int n)
{ {
//int i, ars, nv = 0, nextsame = Tjp->NextSame; //int i, ars, nv = 0, nextsame = Tjp->NextSame;
int i, ars, nv = 0, nextsame = 0; int i, ars, nv = 0, nextsame = 0;
my_bool err; my_bool err;
OPVAL op = Nodes[n].Op; OPVAL op = Nodes[n].Op;
@@ -468,15 +471,16 @@ PVAL JSNX::CalculateArray(PGLOBAL g, PJAR arp, int n)
JVALUE jval; JVALUE jval;
vp->Reset(); vp->Reset();
//ars = MY_MIN(Tjp->Limit, arp->size());
ars = arp->size(); ars = arp->size();
for (i = 0; i < ars; i++) { for (i = 0; i < ars; i++) {
jvrp = arp->GetValue(i); jvrp = arp->GetValue(i);
// do { if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) {
if (n < Nod - 1 && jvrp->GetJson()) { if (jvrp->IsNull()) {
// Tjp->NextSame = nextsame; jvrp->Value = AllocateValue(g, GetJsonNull(), TYPE_STRING);
jvp = jvrp;
} else if (n < Nod - 1 && jvrp->GetJson()) {
jval.SetValue(GetColumnValue(g, jvrp->GetJson(), n + 1)); jval.SetValue(GetColumnValue(g, jvrp->GetJson(), n + 1));
jvp = &jval; jvp = &jval;
} else } else
@@ -516,7 +520,7 @@ PVAL JSNX::CalculateArray(PGLOBAL g, PJAR arp, int n)
} // endif Zero } // endif Zero
// } while (Tjp->NextSame > nextsame); } // endif jvrp
} // endfor i } // endfor i
@@ -1081,6 +1085,7 @@ inline void JsonMemSave(PGLOBAL g)
/*********************************************************************************/ /*********************************************************************************/
inline void JsonFreeMem(PGLOBAL g) inline void JsonFreeMem(PGLOBAL g)
{ {
g->Activityp = NULL;
PlugExit(g); PlugExit(g);
} /* end of JsonFreeMem */ } /* end of JsonFreeMem */

View File

@@ -1,3 +1,4 @@
/* Copyright (C) MariaDB Corporation Ab */
#define MSG_ACCESS_VIOLATN 200 #define MSG_ACCESS_VIOLATN 200
#define MSG_ADD_BAD_TYPE 201 #define MSG_ADD_BAD_TYPE 201
#define MSG_ALLOC_ERROR 202 #define MSG_ALLOC_ERROR 202

View File

@@ -1,4 +1,4 @@
/* Copyright (C) Olivier Bertrand 2004 - 2017 /* Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -1,4 +1,4 @@
/* Copyright (C) Olivier Bertrand 2004 - 2015 /* Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
/**************** MYCAT H Declares Source Code File (.H) ***************/ /**************** MYCAT H Declares Source Code File (.H) ***************/
/* Name: MYCAT.H Version 2.3 */ /* Name: MYCAT.H Version 2.3 */
/* */ /* Author: Olivier Bertrand */
/* This file contains the CONNECT plugin MYCAT class definitions. */ /* This file contains the CONNECT plugin MYCAT class definitions. */
/***********************************************************************/ /***********************************************************************/
#ifndef __MYCAT__H #ifndef __MYCAT__H

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,7 @@
# #
# MDEV-7574 Security definer views don't work with CONNECT ODBC tables # MDEV-7574 Security definer views don't work with CONNECT ODBC tables
# #
CREATE USER user@localhost;
GRANT ALL PRIVILEGES ON *.* TO user@localhost; GRANT ALL PRIVILEGES ON *.* TO user@localhost;
REVOKE FILE ON *.* FROM user@localhost; REVOKE FILE ON *.* FROM user@localhost;
# Testing SQLCOM_SELECT # Testing SQLCOM_SELECT
@@ -621,7 +622,7 @@ test.t1 optimize status OK
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize Error Access denied for user 'user'@'localhost' (using password: NO) test.t1 optimize Error Access denied for user 'user'@'localhost' (using password: NO)
test.t1 optimize Error Can't lock file (errno: 122 "Internal (unspecified) error in handler") test.t1 optimize Error Got error 122 'This operation requires the FILE privilege' from CONNECT
test.t1 optimize error Corrupt test.t1 optimize error Corrupt
DROP TABLE t1; DROP TABLE t1;
# Testing SQLCOM_ALTER_TABLE (adding columns) # Testing SQLCOM_ALTER_TABLE (adding columns)

View File

@@ -0,0 +1,12 @@
Warnings:
Warning 1105 No file name. Table will use t1.xml
create table t1 (i int) engine=Connect table_type=XML;
Warnings:
Warning 1105 No file name. Table will use t1.xml
select * from information_schema.tables where create_options like '%table_type=XML%';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT
Warnings:
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1296 Got error 174 'File t1.xml not found' from CONNECT
drop table t1;

View File

@@ -608,7 +608,7 @@ JsonGet_String(Json_File('test/fx.json'), '[1]:*')
{"_id":6,"type":"car","item":"roadster","mileage":56000,"ratings":[6,9]} {"_id":6,"type":"car","item":"roadster","mileage":56000,"ratings":[6,9]}
SELECT JsonGet_String(Json_File('test/fx.json'), '[1]'); SELECT JsonGet_String(Json_File('test/fx.json'), '[1]');
JsonGet_String(Json_File('test/fx.json'), '[1]') JsonGet_String(Json_File('test/fx.json'), '[1]')
6 car roadster 56000 ??? 6 car roadster 56000 6 9
SELECT JsonGet_Int(Json_File('test/fx.json'), '[1]:mileage') AS Mileage; SELECT JsonGet_Int(Json_File('test/fx.json'), '[1]:mileage') AS Mileage;
Mileage Mileage
56000 56000

View File

@@ -178,7 +178,7 @@ DROP TABLE t1;
# #
# Testing temporal data types # Testing temporal data types
# #
CREATE TABLE t1 (a date, b datetime, c time, d timestamp, e year); CREATE TABLE t1 (a date, b datetime, c time, d timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, e year);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (

View File

@@ -0,0 +1,165 @@
SET NAMES utf8;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='Bad connection string';
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Sources;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`Name` varchar(256) NOT NULL,
`Description` varchar(256) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='ODBC' `CATFUNC`='Sources'
SELECT * FROM t1;
Name Description
dBASE Files Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)
PLUGDB_DEBUG PLUGODBC_Driver
PLUGDB_ODBC PLUGODBC_Driver
SafeDB_ODBC SDB_ODBC_Driver
Firebird Firebird/InterBase(r) driver
ConnectEngineXLS Microsoft Excel Driver (*.xls)
Excel Files Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)
MariaODBC MySQL ODBC 5.2a Driver
MariaODBCbeta MariaDB ODBC 1.0 Driver
MyODBC MySQL ODBC 5.2a Driver
MS Access Database Microsoft Access Driver (*.mdb, *.accdb)
MS Access Db1 Microsoft Access Driver (*.mdb)
MySQL-ANSI MySQL ODBC 5.3 ANSI Driver
MySQL-Unicode MySQL ODBC 5.3 Unicode Driver
Xtreme Sample Database 2008 Microsoft Access Driver (*.mdb)
PlugDB test PLUGODBC_Driver
SQLite3 Datasource SQLite3 ODBC Driver
SQLite Datasource SQLite ODBC Driver
SQLite UTF-8 Datasource SQLite ODBC (UTF-8) Driver
ORACLE_TEST Oracle in XE
ConnectEnginePostgresql PostgreSQL ODBC Driver(ANSI)
ConnectEngineOracle Oracle in XE
ConnectEngineSQLServer SQL Server
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Drivers;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`Description` char(128) NOT NULL,
`Attributes` varchar(256) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='ODBC' `CATFUNC`='Drivers'
SELECT * FROM t1;
Description Attributes
SQL Server UsageCount=1;SQLLevel=1;FileUsage=0;DriverODBCVer=03.50;ConnectFunctions=YYY;APILevel=2;CPTimeout=60;
Microsoft ODBC for Oracle UsageCount=1;SQLLevel=1;FileUsage=0;DriverODBCVer=02.50;ConnectFunctions=YYY;APILevel=1;CPTimeout=120;
Microsoft Access Driver (*.mdb) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=2;FileExtns=*.mdb;SQLLevel=0;
Microsoft Access-Treiber (*.mdb) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=2;FileExtns=*.mdb;SQLLevel=0;
Driver do Microsoft Access (*.mdb) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=2;FileExtns=*.mdb;SQLLevel=0;
Microsoft dBase Driver (*.dbf) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.dbf,*.ndx,*.mdx;SQLLevel=0;
Microsoft dBase-Treiber (*.dbf) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.dbf,*.ndx,*.mdx;SQLLevel=0;
Driver do Microsoft dBase (*.dbf) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.dbf,*.ndx,*.mdx;SQLLevel=0;
Microsoft Excel Driver (*.xls) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.xls;SQLLevel=0;
Microsoft Excel-Treiber (*.xls) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.xls;SQLLevel=0;
Driver do Microsoft Excel(*.xls) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.xls;SQLLevel=0;
Microsoft Paradox Driver (*.db ) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.db;SQLLevel=0;
Microsoft Paradox-Treiber (*.db ) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.db;SQLLevel=0;
Driver do Microsoft Paradox (*.db ) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.db;SQLLevel=0;
Microsoft Text Driver (*.txt; *.csv) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.,*.asc,*.csv,*.tab,*.txt,*.csv;SQLLevel=0;
Microsoft Text-Treiber (*.txt; *.csv) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.,*.asc,*.csv,*.tab,*.txt,*.csv;SQLLevel=0;
Driver da Microsoft para arquivos texto (*.txt; *.csv) UsageCount=1;APILevel=1;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.,*.asc,*.csv,*.tab,*.txt,*.csv;SQLLevel=0;
Microsoft Visual FoxPro Driver UsageCount=1;APILevel=0;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.dbf,*.cdx,*.idx,*.fpt;SQLLevel=0;
Microsoft FoxPro VFP Driver (*.dbf) UsageCount=1;APILevel=0;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.dbf,*.cdx,*.idx,*.fpt;SQLLevel=0;
Microsoft dBase VFP Driver (*.dbf) UsageCount=1;APILevel=0;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.dbf,*.cdx,*.idx,*.fpt;SQLLevel=0;
Microsoft Visual FoxPro-Treiber UsageCount=1;APILevel=0;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.dbf,*.cdx,*.idx,*.fpt;SQLLevel=0;
Driver para o Microsoft Visual FoxPro UsageCount=1;APILevel=0;ConnectFunctions=YYN;DriverODBCVer=02.50;FileUsage=1;FileExtns=*.dbf,*.cdx,*.idx,*.fpt;SQLLevel=0;
SQL Native Client UsageCount=1;APILevel=2;ConnectFunctions=YYY;CPTimeout=60;DriverODBCVer=09.00;FileUsage=0;SQLLevel=1;
CR Sybase Wire Protocol ODBC Driver 6.0 UsageCount=1;APILevel=1;ConnectFunctions=YYY;DriverODBCVer=3.52;FileUsage=0;SQLLevel=0;CPTimeout=60;HelpRootDirectory=C:\Program Files\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\odbc\help;
CR SQL Server Native Wire Protocol ODBC Driver 6.0 UsageCount=1;APILevel=1;ConnectFunctions=YYY;DriverODBCVer=3.52;FileUsage=0;SQLLevel=1;CPTimeout=60;HelpRootDirectory=C:\Program Files\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\odbc\help;
CR SQL Server Classic Wire Protocol ODBC Driver 6.0 UsageCount=1;APILevel=1;ConnectFunctions=YYY;DriverODBCVer=3.52;FileUsage=0;SQLLevel=1;CPTimeout=60;HelpRootDirectory=C:\Program Files\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\odbc\help;
CR TextFile ODBC Driver 6.0 UsageCount=1;APILevel=1;ConnectFunctions=YYY;DriverODBCVer=3.52;FileUsage=1;FileExtns=*.*;SQLLevel=0;CPTimeout=60;HelpRootDirectory=C:\Program Files\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\odbc\help;
PLUGODBC_Driver UsageCount=1;
SDB_ODBC_Driver UsageCount=2;
Microsoft Access Text Driver (*.txt, *.csv) SQLLevel=0;FileExtns=*.txt, *.csv;FileUsage=2;DriverODBCVer=02.50;ConnectFunctions=YYN;APILevel=1;UsageCount=3;
Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx) SQLLevel=0;FileExtns=*.dbf, *.ndx, *.mdx;FileUsage=2;DriverODBCVer=02.50;ConnectFunctions=YYN;APILevel=1;UsageCount=3;
Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb) SQLLevel=0;FileExtns=*.xls,*.xlsx, *.xlsb;FileUsage=2;DriverODBCVer=02.50;ConnectFunctions=YYN;APILevel=1;UsageCount=3;
Microsoft Access Driver (*.mdb, *.accdb) SQLLevel=0;FileExtns=*.mdb,*.accdb;FileUsage=2;DriverODBCVer=02.50;ConnectFunctions=YYN;APILevel=1;UsageCount=3;
SQLite3 ODBC Driver UsageCount=1;
SQLite ODBC Driver UsageCount=1;
SQLite ODBC (UTF-8) Driver UsageCount=1;
Oracle in XE ConnectionFunctions=YYY;DriverODBCVer=03.51;CPTimeout=60;FileUsage=0;APILevel=1;SQLLevel=1;
Oracle in instantclient_12_1 APILevel=1;ConnectionFunctions=YYY;CPTimeout=60;DriverODBCVer=03.51;FileUsage=0;SQLLevel=1;
PostgreSQL ODBC Driver(ANSI) APILevel=1;ConnectFunctions=YYN;DriverODBCVer=09.02.0100;FileUsage=0;SQLLevel=1;
PostgreSQL ODBC Driver(UNICODE) APILevel=1;ConnectFunctions=YYN;DriverODBCVer=09.02.0100;FileUsage=0;SQLLevel=1;
SQL Server Native Client 11.0 UsageCount=1;APILevel=2;ConnectFunctions=YYY;CPTimeout=60;DriverODBCVer=03.80;FileUsage=0;SQLLevel=1;
MariaDB ODBC 1.0 Driver UsageCount=1;
Firebird/InterBase(r) driver UsageCount=1;FileExtns=*.fdb,*.gdb;APILevel=1;ConnectFunctions=YYY;FileUsage=0;DriverODBCVer=03.51;SQLLevel=1;
MySQL ODBC 5.3 ANSI Driver UsageCount=1;
MySQL ODBC 5.3 Unicode Driver UsageCount=1;
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Tables CONNECTION='Not important';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`Table_Cat` char(128) DEFAULT NULL,
`Table_Schema` char(128) DEFAULT NULL,
`Table_Name` char(128) NOT NULL,
`Table_Type` char(16) NOT NULL,
`Remark` char(255) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='Not important' `TABLE_TYPE`='ODBC' `CATFUNC`='Tables'
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Columns CONNECTION='Not important';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`Table_Cat` char(128) DEFAULT NULL,
`Table_Schema` char(128) DEFAULT NULL,
`Table_Name` char(128) NOT NULL,
`Column_Name` char(128) NOT NULL,
`Data_Type` smallint(6) NOT NULL,
`Type_Name` char(30) NOT NULL,
`Column_Size` int(10) NOT NULL,
`Buffer_Length` int(10) NOT NULL,
`Decimal_Digits` smallint(6) DEFAULT NULL,
`Radix` smallint(6) DEFAULT NULL,
`Nullable` smallint(6) NOT NULL,
`Remarks` char(255) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='Not important' `TABLE_TYPE`='ODBC' `CATFUNC`='Columns'
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC TABNAME='EMPLOYEE' CONNECTION='DSN=Firebird;UID=SYSDBA;PWD=masterkey';
SELECT * FROM t1;
EMP_NO FIRST_NAME LAST_NAME PHONE_EXT HIRE_DATE DEPT_NO JOB_CODE JOB_GRADE JOB_COUNTRY SALARY FULL_NAME
2 Robert Nelson 250 1988-12-28 00:00:00 600 VP 2 USA 105900.00 Nelson, Robert
4 Bruce Young 233 1988-12-28 00:00:00 621 Eng 2 USA 97500.00 Young, Bruce
5 Kim Lambert 22 1989-02-06 00:00:00 130 Eng 2 USA 102750.00 Lambert, Kim
8 Leslie Johnson 410 1989-04-05 00:00:00 180 Mktg 3 USA 64635.00 Johnson, Leslie
9 Phil Forest 229 1989-04-17 00:00:00 622 Mngr 3 USA 75060.00 Forest, Phil
11 K. J. Weston 34 1990-01-17 00:00:00 130 SRep 4 USA 86292.94 Weston, K. J.
12 Terri Lee 256 1990-05-01 00:00:00 000 Admin 4 USA 53793.00 Lee, Terri
14 Stewart Hall 227 1990-06-04 00:00:00 900 Finan 3 USA 69482.63 Hall, Stewart
15 Katherine Young 231 1990-06-14 00:00:00 623 Mngr 3 USA 67241.25 Young, Katherine
20 Chris Papadopoulos 887 1990-01-01 00:00:00 671 Mngr 3 USA 89655.00 Papadopoulos, Chris
24 Pete Fisher 888 1990-09-12 00:00:00 671 Eng 3 USA 81810.19 Fisher, Pete
28 Ann Bennet 5 1991-02-01 00:00:00 120 Admin 5 England 22935.00 Bennet, Ann
29 Roger De Souza 288 1991-02-18 00:00:00 623 Eng 3 USA 69482.63 De Souza, Roger
34 Janet Baldwin 2 1991-03-21 00:00:00 110 Sales 3 USA 61637.81 Baldwin, Janet
36 Roger Reeves 6 1991-04-25 00:00:00 120 Sales 3 England 33620.63 Reeves, Roger
37 Willie Stansbury 7 1991-04-25 00:00:00 120 Eng 4 England 39224.06 Stansbury, Willie
44 Leslie Phong 216 1991-06-03 00:00:00 623 Eng 4 USA 56034.38 Phong, Leslie
45 Ashok Ramanathan 209 1991-08-01 00:00:00 621 Eng 3 USA 80689.50 Ramanathan, Ashok
46 Walter Steadman 210 1991-08-09 00:00:00 900 CFO 1 USA 116100.00 Steadman, Walter
52 Carol Nordstrom 420 1991-10-02 00:00:00 180 PRel 4 USA 42742.50 Nordstrom, Carol
61 Luke Leung 3 1992-02-18 00:00:00 110 SRep 4 USA 68805.00 Leung, Luke
65 Sue Anne O'Brien 877 1992-03-23 00:00:00 670 Admin 5 USA 31275.00 O'Brien, Sue Anne
71 Jennifer M. Burbank 289 1992-04-15 00:00:00 622 Eng 3 USA 53167.50 Burbank, Jennifer M.
72 Claudia Sutherland NULL 1992-04-20 00:00:00 140 SRep 4 Canada 100914.00 Sutherland, Claudia
83 Dana Bishop 290 1992-06-01 00:00:00 621 Eng 3 USA 62550.00 Bishop, Dana
85 Mary S. MacDonald 477 1992-06-01 00:00:00 100 VP 2 USA 111262.50 MacDonald, Mary S.
94 Randy Williams 892 1992-08-08 00:00:00 672 Mngr 4 USA 56295.00 Williams, Randy
105 Oliver H. Bender 255 1992-10-08 00:00:00 000 CEO 1 USA 212850.00 Bender, Oliver H.
107 Kevin Cook 894 1993-02-01 00:00:00 670 Dir 2 USA 111262.50 Cook, Kevin
109 Kelly Brown 202 1993-02-04 00:00:00 600 Admin 5 USA 27000.00 Brown, Kelly
110 Yuki Ichida 22 1993-02-04 00:00:00 115 Eng 3 Japan 6000000.00 Ichida, Yuki
113 Mary Page 845 1993-04-12 00:00:00 671 Eng 4 USA 48000.00 Page, Mary
114 Bill Parker 247 1993-06-01 00:00:00 623 Eng 5 USA 35000.00 Parker, Bill
118 Takashi Yamamoto 23 1993-07-01 00:00:00 115 SRep 4 Japan 7480000.00 Yamamoto, Takashi
121 Roberto Ferrari 1 1993-07-12 00:00:00 125 SRep 4 Italy 99000000.00 Ferrari, Roberto
127 Michael Yanowski 492 1993-08-09 00:00:00 100 SRep 4 USA 44000.00 Yanowski, Michael
134 Jacques Glon NULL 1993-08-23 00:00:00 123 SRep 4 France 390500.00 Glon, Jacques
136 Scott Johnson 265 1993-09-13 00:00:00 623 Doc 3 USA 60000.00 Johnson, Scott
138 T.J. Green 218 1993-11-01 00:00:00 621 Eng 4 USA 36000.00 Green, T.J.
141 Pierre Osborne NULL 1994-01-03 00:00:00 121 SRep 4 Switzerland 110000.00 Osborne, Pierre
144 John Montgomery 820 1994-03-30 00:00:00 672 Eng 5 USA 35000.00 Montgomery, John
145 Mark Guckenheimer 221 1994-05-02 00:00:00 622 Eng 5 USA 32000.00 Guckenheimer, Mark
DROP TABLE t1;

View File

@@ -0,0 +1 @@
--secure-file-priv=""

File diff suppressed because one or more lines are too long

View File

@@ -9,6 +9,7 @@ let $MYSQLD_DATADIR= `select @@datadir`;
--echo # MDEV-7574 Security definer views don't work with CONNECT ODBC tables --echo # MDEV-7574 Security definer views don't work with CONNECT ODBC tables
--echo # --echo #
CREATE USER user@localhost;
GRANT ALL PRIVILEGES ON *.* TO user@localhost; GRANT ALL PRIVILEGES ON *.* TO user@localhost;
REVOKE FILE ON *.* FROM user@localhost; REVOKE FILE ON *.* FROM user@localhost;

View File

@@ -0,0 +1,9 @@
#
# MDEV-9739 Assertion `m_status == DA_ERROR || m_status == DA_OK' failed in Diagnostics_area::message() ; connect.xml* tests fail in buildbot
#
--source have_libxml2.inc
create table t1 (i int) engine=Connect table_type=XML;
select * from information_schema.tables where create_options like '%table_type=XML%';
drop table t1;

View File

@@ -304,7 +304,7 @@ DROP TABLE t1;
--echo # Testing temporal data types --echo # Testing temporal data types
--echo # --echo #
CREATE TABLE t1 (a date, b datetime, c time, d timestamp, e year); CREATE TABLE t1 (a date, b datetime, c time, d timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, e year);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES('2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23'); INSERT INTO t1 VALUES('2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23','2003-05-27 10:45:23');
SELECT * FROM t1; SELECT * FROM t1;

View File

@@ -0,0 +1,35 @@
--source have_odbc.inc
SET NAMES utf8;
# MS ODBC and unixODBC return different error message text,
# so disable displaying error messages
--disable_result_log ONCE
--error ER_UNKNOWN_ERROR
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='Bad connection string';
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Sources;
if (`select count(*)=0 from t1 where name='firebird'`) {
DROP TABLE t1;
skip No Firebird;
}
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Drivers;
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Tables CONNECTION='Not important';
SHOW CREATE TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Columns CONNECTION='Not important';
SHOW CREATE TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC TABNAME='EMPLOYEE' CONNECTION='DSN=Firebird;UID=SYSDBA;PWD=masterkey';
SELECT * FROM t1;
DROP TABLE t1;

View File

@@ -10,4 +10,4 @@ let $SECUREDIR= `select @@secure_file_priv`;
INSERT INTO t1 VALUES (10); INSERT INTO t1 VALUES (10);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--remove_file $SECUREDIR/t1.dbf --remove_file $MYSQL_TMP_DIR/t1.dbf

38
storage/connect/noconst.c Normal file
View File

@@ -0,0 +1,38 @@
/***********************************************************************/
/* (C) Copyright to the author Olivier BERTRAND 2015 */
/***********************************************************************/
#include <my_global.h>
#include <mysqld.h>
#include <string.h>
#if defined(__WIN__)
#define DllExport __declspec( dllexport )
#else // !__WIN__
#define DllExport
#endif // !__WIN__
extern "C" {
DllExport my_bool noconst_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *noconst(UDF_INIT*, UDF_ARGS*, char*, unsigned long*, char*, char*);
} // extern "C"
/***********************************************************************/
/* Returns its argument saying it is not a constant. */
/***********************************************************************/
my_bool noconst_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
if (args->arg_count != 1 || args->arg_type[0] != STRING_RESULT) {
strcpy(message, "noconst unique argument must be a string");
return true;
} // endif arg
initid->const_item = false; // The trick!
return false;
} // end of noconst_init
char *noconst(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *)
{
return args->args[0];
} // end of noconst

View File

@@ -1,3 +1,4 @@
/* Copyright (C) MariaDB Corporation Ab */
#ifndef _OS_H_INCLUDED #ifndef _OS_H_INCLUDED
#define _OS_H_INCLUDED #define _OS_H_INCLUDED

View File

@@ -1,3 +1,4 @@
/* Copyright (C) MariaDB Corporation Ab */
#include "my_global.h" #include "my_global.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@@ -1,3 +1,4 @@
/* Copyright (C) MariaDB Corporation Ab */
#ifndef __OSUTIL_H__ #ifndef __OSUTIL_H__
#define __OSUTIL_H__ #define __OSUTIL_H__

View File

@@ -36,8 +36,6 @@ enum BLKTYP {TYPE_TABLE = 50, /* Table Name/Srcdef/... Block */
TYPE_COLCRT = 71, /* Column creation block */ TYPE_COLCRT = 71, /* Column creation block */
TYPE_CONST = 72, /* Constant */ TYPE_CONST = 72, /* Constant */
/*-------------------- type tokenized string --------------------------*/
TYPE_DATE = 8, /* Timestamp */
/*-------------------- additional values used by LNA ------------------*/ /*-------------------- additional values used by LNA ------------------*/
TYPE_COLIST = 14, /* Column list */ TYPE_COLIST = 14, /* Column list */
TYPE_COL = 41, /* Column */ TYPE_COL = 41, /* Column */

View File

@@ -82,14 +82,10 @@ extern "C" {
extern char version[]; extern char version[];
} // extern "C" } // extern "C"
#if defined(__WIN__)
extern CRITICAL_SECTION parsec; // Used calling the Flex parser
#else // !__WIN__
extern pthread_mutex_t parmut; extern pthread_mutex_t parmut;
#endif // !__WIN__
// The debug trace used by the main thread // The debug trace used by the main thread
FILE *pfile = NULL; FILE *pfile = NULL;
MBLOCK Nmblk = {NULL, false, 0, false, NULL}; // Used to init MBLOCK's MBLOCK Nmblk = {NULL, false, 0, false, NULL}; // Used to init MBLOCK's
@@ -473,7 +469,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
tp = g->Message; tp = g->Message;
else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) { else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) {
strcpy(g->Message, MSG(NEW_RETURN_NULL)); strcpy(g->Message, MSG(NEW_RETURN_NULL));
throw OP_LIKE; throw (int)OP_LIKE;
} /* endif tp */ } /* endif tp */
sp = tp + strlen(pat) + 1; sp = tp + strlen(pat) + 1;
@@ -484,7 +480,7 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
tp = g->Message; /* Use this as temporary work space. */ tp = g->Message; /* Use this as temporary work space. */
else if (!(tp = new char[strlen(pat) + 1])) { else if (!(tp = new char[strlen(pat) + 1])) {
strcpy(g->Message, MSG(NEW_RETURN_NULL)); strcpy(g->Message, MSG(NEW_RETURN_NULL));
throw OP_LIKE; throw (int)OP_LIKE;
} /* endif tp */ } /* endif tp */
strcpy(tp, pat); /* Make a copy to be worked into */ strcpy(tp, pat); /* Make a copy to be worked into */
@@ -697,21 +693,9 @@ PDTP MakeDateFormat(PGLOBAL g, PCSZ dfmt, bool in, bool out, int flag)
/* Call the FLEX generated parser. In multi-threading mode the next */ /* Call the FLEX generated parser. In multi-threading mode the next */
/* instruction is included in an Enter/LeaveCriticalSection bracket. */ /* instruction is included in an Enter/LeaveCriticalSection bracket. */
/*********************************************************************/ /*********************************************************************/
//#if defined(THREAD)
#if defined(__WIN__)
EnterCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !__WIN__
pthread_mutex_lock(&parmut); pthread_mutex_lock(&parmut);
#endif // !__WIN__
//#endif // THREAD
rc = fmdflex(pdp); rc = fmdflex(pdp);
//#if defined(THREAD)
#if defined(__WIN__)
LeaveCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !__WIN__
pthread_mutex_unlock(&parmut); pthread_mutex_unlock(&parmut);
#endif // !__WIN__
//#endif // THREAD
if (trace) if (trace)
htrc("Done: in=%s out=%s rc=%d\n", SVP(pdp->InFmt), SVP(pdp->OutFmt), rc); htrc("Done: in=%s out=%s rc=%d\n", SVP(pdp->InFmt), SVP(pdp->OutFmt), rc);

View File

@@ -2,11 +2,11 @@
/* */ /* */
/* PROGRAM NAME: PLUGUTIL */ /* PROGRAM NAME: PLUGUTIL */
/* ------------- */ /* ------------- */
/* Version 2.9 */ /* Version 3.0 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1993-2015 */ /* (C) Copyright to the author Olivier BERTRAND 1993-2017 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
@@ -76,6 +76,7 @@
#include "osutil.h" #include "osutil.h"
#include "global.h" #include "global.h"
#include "plgdbsem.h"
#if defined(NEWMSG) #if defined(NEWMSG)
#include "rcmsg.h" #include "rcmsg.h"
#endif // NEWMSG #endif // NEWMSG
@@ -132,7 +133,7 @@ void htrc(char const *fmt, ...)
/* Return value is the pointer to the Global structure. */ /* Return value is the pointer to the Global structure. */
/***********************************************************************/ /***********************************************************************/
PGLOBAL PlugInit(LPCSTR Language, uint worksize) PGLOBAL PlugInit(LPCSTR Language, uint worksize)
{ {
PGLOBAL g; PGLOBAL g;
if (trace > 1) if (trace > 1)
@@ -146,10 +147,6 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
return NULL; return NULL;
} // end try/catch } // end try/catch
//if (!(g = (PGLOBAL)malloc(sizeof(GLOBAL)))) {
// fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL));
// return NULL;
// } else {
g->Sarea = NULL; g->Sarea = NULL;
g->Createas = 0; g->Createas = 0;
g->Alchecked = 0; g->Alchecked = 0;
@@ -171,28 +168,33 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
} else } else
g->Sarea_Size = worksize; g->Sarea_Size = worksize;
//} /* endif g */
g->jump_level = -1; /* New setting to allow recursive call of Plug */ g->jump_level = -1; /* New setting to allow recursive call of Plug */
return(g); return(g);
} /* end of PlugInit */ } /* end of PlugInit */
/***********************************************************************/ /***********************************************************************/
/* PlugExit: Terminate Plug operations. */ /* PlugExit: Terminate Plug operations. */
/***********************************************************************/ /***********************************************************************/
int PlugExit(PGLOBAL g) int PlugExit(PGLOBAL g)
{ {
int rc = 0; if (g) {
PDBUSER dup = PlgGetUser(g);
if (!g) if (dup)
return rc; free(dup);
if (g->Sarea) {
if (trace)
htrc("Freeing Sarea size=%d\n", g->Sarea_Size);
if (g->Sarea)
free(g->Sarea); free(g->Sarea);
} // endif Sarea
delete g; delete g;
return rc; } // endif g
} /* end of PlugExit */
return 0;
} // end of PlugExit
/***********************************************************************/ /***********************************************************************/
/* Remove the file type from a file name. */ /* Remove the file type from a file name. */
@@ -456,7 +458,7 @@ short GetLineLength(PGLOBAL g)
/* Program for memory allocation of work and language areas. */ /* Program for memory allocation of work and language areas. */
/***********************************************************************/ /***********************************************************************/
void *PlugAllocMem(PGLOBAL g, uint size) void *PlugAllocMem(PGLOBAL g, uint size)
{ {
void *areap; /* Pointer to allocated area */ void *areap; /* Pointer to allocated area */
/*********************************************************************/ /*********************************************************************/
@@ -465,7 +467,7 @@ void *PlugAllocMem(PGLOBAL g, uint size)
if (!(areap = malloc(size))) if (!(areap = malloc(size)))
sprintf(g->Message, MSG(MALLOC_ERROR), "malloc"); sprintf(g->Message, MSG(MALLOC_ERROR), "malloc");
if (trace > 1) { if (trace) {
if (areap) if (areap)
htrc("Memory of %u allocated at %p\n", size, areap); htrc("Memory of %u allocated at %p\n", size, areap);
else else
@@ -474,7 +476,7 @@ void *PlugAllocMem(PGLOBAL g, uint size)
} // endif trace } // endif trace
return (areap); return (areap);
} /* end of PlugAllocMem */ } // end of PlugAllocMem
/***********************************************************************/ /***********************************************************************/
/* Program for SubSet initialization of memory pools. */ /* Program for SubSet initialization of memory pools. */

View File

@@ -86,7 +86,7 @@ void XTAB::Printf(PGLOBAL g, FILE *f, uint n)
PlugPutOut(g, f, TYPE_TDB, tp->To_Tdb, n + 2); PlugPutOut(g, f, TYPE_TDB, tp->To_Tdb, n + 2);
} /* endfor tp */ } /* endfor tp */
} /* end of Print */ } /* end of Printf */
/***********************************************************************/ /***********************************************************************/
/* Make string output of XTAB contents. */ /* Make string output of XTAB contents. */
@@ -105,7 +105,7 @@ void XTAB::Prints(PGLOBAL, char *ps, uint z)
n -= i; n -= i;
} // endif tp } // endif tp
} /* end of Print */ } /* end of Prints */
/***********************************************************************/ /***********************************************************************/
@@ -149,7 +149,7 @@ void COLUMN::Printf(PGLOBAL g, FILE *f, uint n)
PlugPutOut(g, f, TYPE_TABLE, To_Table, n + 2); PlugPutOut(g, f, TYPE_TABLE, To_Table, n + 2);
PlugPutOut(g, f, TYPE_XOBJECT, To_Col, n + 2); PlugPutOut(g, f, TYPE_XOBJECT, To_Col, n + 2);
} /* end of Print */ } /* end of Printf */
/***********************************************************************/ /***********************************************************************/
/* Make string output of COLUMN contents. */ /* Make string output of COLUMN contents. */
@@ -166,4 +166,4 @@ void COLUMN::Prints(PGLOBAL, char *ps, uint z)
strncpy(ps, buf, z); strncpy(ps, buf, z);
ps[z - 1] = '\0'; ps[z - 1] = '\0';
} /* end of Print */ } /* end of Prints */

View File

@@ -1309,7 +1309,7 @@ PBF TDBDOS::InitBlockFilter(PGLOBAL g, PFIL filp)
} // endif !opm } // endif !opm
// if opm, pass thru // if opm, pass thru
/* fall through */ // fall through
case OP_IN: case OP_IN:
if (filp->GetArgType(0) == TYPE_COLBLK && if (filp->GetArgType(0) == TYPE_COLBLK &&
filp->GetArgType(1) == TYPE_ARRAY) { filp->GetArgType(1) == TYPE_ARRAY) {
@@ -1645,7 +1645,7 @@ int TDBDOS::TestBlock(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
{ {
int k, n; int k, n, rc = RC_OK;
bool fixed, doit, sep, b = (pxdf != NULL); bool fixed, doit, sep, b = (pxdf != NULL);
PCOL *keycols, colp; PCOL *keycols, colp;
PIXDEF xdp, sxp = NULL; PIXDEF xdp, sxp = NULL;
@@ -1690,6 +1690,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
} else if (!(pxdf = dfp->GetIndx())) } else if (!(pxdf = dfp->GetIndx()))
return RC_INFO; // No index to make return RC_INFO; // No index to make
try {
// Allocate all columns that will be used by indexes. // Allocate all columns that will be used by indexes.
// This must be done before opening the table so specific // This must be done before opening the table so specific
// column initialization can be done (in particular by TDBVCT) // column initialization can be done (in particular by TDBVCT)
@@ -1756,7 +1757,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
if (!x->Make(g, sxp)) { if (!x->Make(g, sxp)) {
// Retreive define values from the index // Retreive define values from the index
xdp->SetMaxSame(x->GetMaxSame()); xdp->SetMaxSame(x->GetMaxSame());
// xdp->SetSize(x->GetSize()); // xdp->SetSize(x->GetSize());
// store KXYCOL Mxs in KPARTDEF Mxsame // store KXYCOL Mxs in KPARTDEF Mxsame
xdp->SetMxsame(x); xdp->SetMxsame(x);
@@ -1765,7 +1766,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
printf("Make done...\n"); printf("Make done...\n");
#endif // TRACE #endif // TRACE
// if (x->GetSize() > 0) // if (x->GetSize() > 0)
sxp = xdp; sxp = xdp;
xdp->SetInvalid(false); xdp->SetInvalid(false);
@@ -1775,10 +1776,19 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
} else } else
return RC_INFO; // Error or Physical table does not exist return RC_INFO; // Error or Physical table does not exist
} catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
rc = RC_FX;
} catch (const char *msg) {
strcpy(g->Message, msg);
rc = RC_FX;
} // end catch
if (Use == USE_OPEN) if (Use == USE_OPEN)
CloseDB(g); CloseDB(g);
return RC_OK; return rc;
err: err:
if (sxp) if (sxp)
@@ -2725,7 +2735,7 @@ void DOSCOL::WriteColumn(PGLOBAL g)
if (Value->GetBinValue(p, Long, Status)) { if (Value->GetBinValue(p, Long, Status)) {
sprintf(g->Message, MSG(BIN_F_TOO_LONG), sprintf(g->Message, MSG(BIN_F_TOO_LONG),
Name, Value->GetSize(), Long); Name, Value->GetSize(), Long);
longjmp(g->jumper[g->jump_level], 31); throw 31;
} // endif } // endif
} // end of WriteColumn } // end of WriteColumn
@@ -2874,7 +2884,7 @@ bool DOSCOL::AddDistinctValue(PGLOBAL g)
void DOSCOL::Printf(PGLOBAL g, FILE *f, uint n) void DOSCOL::Printf(PGLOBAL g, FILE *f, uint n)
{ {
COLBLK::Printf(g, f, n); COLBLK::Printf(g, f, n);
} // end of Print } // end of Printf
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */

View File

@@ -41,12 +41,12 @@
/***********************************************************************/ /***********************************************************************/
#define MAXCOL 200 /* Default max column nb in result */ #define MAXCOL 200 /* Default max column nb in result */
#define TYPE_UNKNOWN 12 /* Must be greater than other types */ #define TYPE_UNKNOWN 12 /* Must be greater than other types */
#define USE_G 1 /* Use recoverable memory if 1 */
/***********************************************************************/ /***********************************************************************/
/* External function. */ /* External function. */
/***********************************************************************/ /***********************************************************************/
USETEMP UseTemp(void); USETEMP UseTemp(void);
char *GetJsonNull(void);
typedef struct _jncol { typedef struct _jncol {
struct _jncol *Next; struct _jncol *Next;
@@ -163,7 +163,6 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
tjnp->SetMode(MODE_READ); tjnp->SetMode(MODE_READ);
#if USE_G
// Allocate the parse work memory // Allocate the parse work memory
PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL)); PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL));
memset(G, 0, sizeof(GLOBAL)); memset(G, 0, sizeof(GLOBAL));
@@ -172,9 +171,6 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
PlugSubSet(G, G->Sarea, G->Sarea_Size); PlugSubSet(G, G->Sarea, G->Sarea_Size);
G->jump_level = 0; G->jump_level = 0;
tjnp->SetG(G); tjnp->SetG(G);
#else
tjnp->SetG(g);
#endif
if (tjnp->OpenDB(g)) if (tjnp->OpenDB(g))
return NULL; return NULL;
@@ -478,7 +474,6 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
// Txfp must be set for TDBDOS // Txfp must be set for TDBDOS
tdbp = new(g) TDBJSN(this, txfp); tdbp = new(g) TDBJSN(this, txfp);
#if USE_G
// Allocate the parse work memory // Allocate the parse work memory
PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL)); PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL));
memset(G, 0, sizeof(GLOBAL)); memset(G, 0, sizeof(GLOBAL));
@@ -487,9 +482,6 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
PlugSubSet(G, G->Sarea, G->Sarea_Size); PlugSubSet(G, G->Sarea, G->Sarea_Size);
G->jump_level = 0; G->jump_level = 0;
((TDBJSN*)tdbp)->G = G; ((TDBJSN*)tdbp)->G = G;
#else
((TDBJSN*)tdbp)->G = g;
#endif
} else { } else {
if (Zipped) { if (Zipped) {
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
@@ -762,10 +754,8 @@ int TDBJSN::ReadDB(PGLOBAL g)
// Deferred reading failed // Deferred reading failed
return rc; return rc;
#if USE_G
// Recover the memory used for parsing // Recover the memory used for parsing
PlugSubSet(G, G->Sarea, G->Sarea_Size); PlugSubSet(G, G->Sarea, G->Sarea_Size);
#endif
if ((Row = ParseJson(G, To_Line, strlen(To_Line), &Pretty, &Comma))) { if ((Row = ParseJson(G, To_Line, strlen(To_Line), &Pretty, &Comma))) {
Row = FindRow(g); Row = FindRow(g);
@@ -774,9 +764,7 @@ int TDBJSN::ReadDB(PGLOBAL g)
M = 1; M = 1;
rc = RC_OK; rc = RC_OK;
} else if (Pretty != 1 || strcmp(To_Line, "]")) { } else if (Pretty != 1 || strcmp(To_Line, "]")) {
#if USE_G
strcpy(g->Message, G->Message); strcpy(g->Message, G->Message);
#endif
rc = RC_FX; rc = RC_FX;
} else } else
rc = RC_EF; rc = RC_EF;
@@ -882,9 +870,7 @@ int TDBJSN::WriteDB(PGLOBAL g)
{ {
int rc = TDBDOS::WriteDB(g); int rc = TDBDOS::WriteDB(g);
#if USE_G
PlugSubSet(G, G->Sarea, G->Sarea_Size); PlugSubSet(G, G->Sarea, G->Sarea_Size);
#endif
Row->Clear(); Row->Clear();
return rc; return rc;
} // end of WriteDB } // end of WriteDB
@@ -1228,7 +1214,7 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n)
case TYPE_INTG: case TYPE_INTG:
case TYPE_BINT: case TYPE_BINT:
case TYPE_DBL: case TYPE_DBL:
case TYPE_DATE: case TYPE_DTM:
vp->SetValue_pval(val->GetValue()); vp->SetValue_pval(val->GetValue());
break; break;
case TYPE_BOOL: case TYPE_BOOL:
@@ -1390,8 +1376,11 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
for (i = 0; i < ars; i++) { for (i = 0; i < ars; i++) {
jvrp = arp->GetValue(i); jvrp = arp->GetValue(i);
do { if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) do {
if (n < Nod - 1 && jvrp->GetJson()) { if (jvrp->IsNull()) {
jvrp->Value = AllocateValue(g, GetJsonNull(), TYPE_STRING);
jvp = jvrp;
} else if (n < Nod - 1 && jvrp->GetJson()) {
Tjp->NextSame = nextsame; Tjp->NextSame = nextsame;
jval.SetValue(GetColumnValue(g, jvrp->GetJson(), n + 1)); jval.SetValue(GetColumnValue(g, jvrp->GetJson(), n + 1));
jvp = &jval; jvp = &jval;
@@ -1404,7 +1393,8 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
} else } else
SetJsonValue(g, MulVal, jvp, n); SetJsonValue(g, MulVal, jvp, n);
if (!MulVal->IsZero()) { // if (!MulVal->IsZero()) {
if (!MulVal->IsNull()) {
switch (op) { switch (op) {
case OP_CNC: case OP_CNC:
if (Nodes[n].CncVal) { if (Nodes[n].CncVal) {

View File

@@ -324,7 +324,7 @@ void TDB::Printf(PGLOBAL g, FILE *f, uint n)
void TDB::Prints(PGLOBAL, char *ps, uint) void TDB::Prints(PGLOBAL, char *ps, uint)
{ {
sprintf(ps, "R%d.%s", Tdb_No, Name); sprintf(ps, "R%d.%s", Tdb_No, Name);
} // end of Print } // end of Prints
/* -------------------------- class TDBASE --------------------------- */ /* -------------------------- class TDBASE --------------------------- */

View File

@@ -273,7 +273,7 @@ PCSZ TDBODBC::GetFile(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
/* Set DBQ and get the new file name into the connect string. */ /* Set DBQ and get the new file name into the connect string. */
/***********************************************************************/ /***********************************************************************/
void TDBODBC::SetFile(PGLOBAL g, PSZ fn) void TDBODBC::SetFile(PGLOBAL g, PCSZ fn)
{ {
if (MulConn) { if (MulConn) {
int n = strlen(MulConn) + strlen(fn) - 1; int n = strlen(MulConn) + strlen(fn) - 1;
@@ -289,7 +289,7 @@ void TDBODBC::SetFile(PGLOBAL g, PSZ fn)
sprintf(Connect, MulConn, fn); sprintf(Connect, MulConn, fn);
} // endif MultConn } // endif MultConn
DBQ = fn; DBQ = PlugDup(g, fn);
} // end of SetFile } // end of SetFile
/***********************************************************************/ /***********************************************************************/

View File

@@ -71,7 +71,7 @@ class TDBODBC : public TDBEXT {
virtual PTDB Clone(PTABS t); virtual PTDB Clone(PTABS t);
virtual bool SetRecpos(PGLOBAL g, int recpos); virtual bool SetRecpos(PGLOBAL g, int recpos);
virtual PCSZ GetFile(PGLOBAL g); virtual PCSZ GetFile(PGLOBAL g);
virtual void SetFile(PGLOBAL g, PSZ fn); virtual void SetFile(PGLOBAL g, PCSZ fn);
virtual void ResetSize(void); virtual void ResetSize(void);
virtual PCSZ GetServer(void) {return "ODBC";} virtual PCSZ GetServer(void) {return "ODBC";}
virtual int Indexable(void) {return 2;} virtual int Indexable(void) {return 2;}

View File

@@ -289,7 +289,7 @@ void VIRCOL::ReadColumn(PGLOBAL g)
{ {
// This should never be called // This should never be called
sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name); sprintf(g->Message, "ReadColumn: Column %s is not virtual", Name);
throw TYPE_COLBLK; throw (int)TYPE_COLBLK;
} // end of ReadColumn } // end of ReadColumn
/* ---------------------------TDBVICL class -------------------------- */ /* ---------------------------TDBVICL class -------------------------- */

View File

@@ -1319,7 +1319,7 @@ void TDBXML::CloseDB(PGLOBAL g)
Docp->CloseDoc(g, To_Xb); Docp->CloseDoc(g, To_Xb);
// This causes a crash in Diagnostics_area::set_error_status // This causes a crash in Diagnostics_area::set_error_status
// throw TYPE_AM_XML; // throw (int)TYPE_AM_XML;
} // endif DumpDoc } // endif DumpDoc
} // endif Changed } // endif Changed
@@ -1642,7 +1642,7 @@ void XMLCOL::ReadColumn(PGLOBAL g)
if (ValNode->GetType() != XML_ELEMENT_NODE && if (ValNode->GetType() != XML_ELEMENT_NODE &&
ValNode->GetType() != XML_ATTRIBUTE_NODE) { ValNode->GetType() != XML_ATTRIBUTE_NODE) {
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name); sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} // endif type } // endif type
// Get the Xname value from the XML file // Get the Xname value from the XML file
@@ -1653,7 +1653,7 @@ void XMLCOL::ReadColumn(PGLOBAL g)
PushWarning(g, Tdbp); PushWarning(g, Tdbp);
break; break;
default: default:
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} // endswitch } // endswitch
Value->SetValue_psz(Valbuf); Value->SetValue_psz(Valbuf);
@@ -1704,7 +1704,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
/* For columns having an Xpath, the Clist must be updated. */ /* For columns having an Xpath, the Clist must be updated. */
/*********************************************************************/ /*********************************************************************/
if (Tdbp->CheckRow(g, Nod || Tdbp->Colname)) if (Tdbp->CheckRow(g, Nod || Tdbp->Colname))
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
/*********************************************************************/ /*********************************************************************/
/* Null values are represented by no node. */ /* Null values are represented by no node. */
@@ -1776,7 +1776,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
if (ColNode == NULL) { if (ColNode == NULL) {
strcpy(g->Message, MSG(COL_ALLOC_ERR)); strcpy(g->Message, MSG(COL_ALLOC_ERR));
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} // endif ColNode } // endif ColNode
} // endif ColNode } // endif ColNode
@@ -1795,7 +1795,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
if (ValNode == NULL && AttNode == NULL) { if (ValNode == NULL && AttNode == NULL) {
strcpy(g->Message, MSG(VAL_ALLOC_ERR)); strcpy(g->Message, MSG(VAL_ALLOC_ERR));
longjmp(g->jumper[g->jump_level], TYPE_AM_XML); throw (int)TYPE_AM_XML;
} // endif ValNode } // endif ValNode
/*********************************************************************/ /*********************************************************************/
@@ -1805,7 +1805,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} else } else
strcpy(Valbuf, p); strcpy(Valbuf, p);
@@ -1855,7 +1855,7 @@ void XMULCOL::ReadColumn(PGLOBAL g)
if (ValNode->GetType() != XML_ELEMENT_NODE && if (ValNode->GetType() != XML_ELEMENT_NODE &&
ValNode->GetType() != XML_ATTRIBUTE_NODE) { ValNode->GetType() != XML_ATTRIBUTE_NODE) {
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name); sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} // endif type } // endif type
// Get the Xname value from the XML file // Get the Xname value from the XML file
@@ -1866,7 +1866,7 @@ void XMULCOL::ReadColumn(PGLOBAL g)
PushWarning(g, Tdbp); PushWarning(g, Tdbp);
break; break;
default: default:
longjmp(g->jumper[g->jump_level], TYPE_AM_XML); throw (int)TYPE_AM_XML;
} // endswitch } // endswitch
if (!b) { if (!b) {
@@ -1941,7 +1941,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
/* For columns having an Xpath, the Clist must be updated. */ /* For columns having an Xpath, the Clist must be updated. */
/*********************************************************************/ /*********************************************************************/
if (Tdbp->CheckRow(g, Nod)) if (Tdbp->CheckRow(g, Nod))
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
/*********************************************************************/ /*********************************************************************/
/* Find the column and value nodes to update or insert. */ /* Find the column and value nodes to update or insert. */
@@ -1990,7 +1990,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
if (len > 1 && !Tdbp->Xpand) { if (len > 1 && !Tdbp->Xpand) {
sprintf(g->Message, MSG(BAD_VAL_UPDATE), Name); sprintf(g->Message, MSG(BAD_VAL_UPDATE), Name);
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} else } else
ValNode = Nlx->GetItem(g, Tdbp->Nsub, Vxnp); ValNode = Nlx->GetItem(g, Tdbp->Nsub, Vxnp);
@@ -2032,7 +2032,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
if (ColNode == NULL) { if (ColNode == NULL) {
strcpy(g->Message, MSG(COL_ALLOC_ERR)); strcpy(g->Message, MSG(COL_ALLOC_ERR));
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} // endif ColNode } // endif ColNode
} // endif ColNode } // endif ColNode
@@ -2051,7 +2051,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
if (ValNode == NULL && AttNode == NULL) { if (ValNode == NULL && AttNode == NULL) {
strcpy(g->Message, MSG(VAL_ALLOC_ERR)); strcpy(g->Message, MSG(VAL_ALLOC_ERR));
longjmp(g->jumper[g->jump_level], TYPE_AM_XML); throw (int)TYPE_AM_XML;
} // endif ValNode } // endif ValNode
/*********************************************************************/ /*********************************************************************/
@@ -2061,7 +2061,7 @@ void XMULCOL::WriteColumn(PGLOBAL g)
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} else } else
strcpy(Valbuf, p); strcpy(Valbuf, p);
@@ -2093,7 +2093,7 @@ void XPOSCOL::ReadColumn(PGLOBAL g)
if (Tdbp->Clist == NULL) { if (Tdbp->Clist == NULL) {
strcpy(g->Message, MSG(MIS_TAG_LIST)); strcpy(g->Message, MSG(MIS_TAG_LIST));
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} // endif Clist } // endif Clist
if ((ValNode = Tdbp->Clist->GetItem(g, Rank, Vxnp))) { if ((ValNode = Tdbp->Clist->GetItem(g, Rank, Vxnp))) {
@@ -2105,7 +2105,7 @@ void XPOSCOL::ReadColumn(PGLOBAL g)
PushWarning(g, Tdbp); PushWarning(g, Tdbp);
break; break;
default: default:
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} // endswitch } // endswitch
Value->SetValue_psz(Valbuf); Value->SetValue_psz(Valbuf);
@@ -2156,14 +2156,14 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
/* For all columns the Clist must be updated. */ /* For all columns the Clist must be updated. */
/*********************************************************************/ /*********************************************************************/
if (Tdbp->CheckRow(g, true)) if (Tdbp->CheckRow(g, true))
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
/*********************************************************************/ /*********************************************************************/
/* Find the column and value nodes to update or insert. */ /* Find the column and value nodes to update or insert. */
/*********************************************************************/ /*********************************************************************/
if (Tdbp->Clist == NULL) { if (Tdbp->Clist == NULL) {
strcpy(g->Message, MSG(MIS_TAG_LIST)); strcpy(g->Message, MSG(MIS_TAG_LIST));
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} // endif Clist } // endif Clist
n = Tdbp->Clist->GetLength(); n = Tdbp->Clist->GetLength();
@@ -2188,7 +2188,7 @@ void XPOSCOL::WriteColumn(PGLOBAL g)
if (strlen(p) > (unsigned)Long) { if (strlen(p) > (unsigned)Long) {
sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long); sprintf(g->Message, MSG(VALUE_TOO_LONG), p, Name, Long);
throw TYPE_AM_XML; throw (int)TYPE_AM_XML;
} else } else
strcpy(Valbuf, p); strcpy(Valbuf, p);

View File

@@ -1,4 +1,4 @@
/* Copyright (C) Olivier Bertrand 2004 - 2015 /* Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
that is a connection with its personnal memory allocation. that is a connection with its personnal memory allocation.
@note @note
Author Olivier Bertrand
*/ */
/****************************************************************************/ /****************************************************************************/
@@ -47,6 +47,8 @@
#include "user_connect.h" #include "user_connect.h"
#include "mycat.h" #include "mycat.h"
extern pthread_mutex_t usrmut;
/****************************************************************************/ /****************************************************************************/
/* Initialize the user_connect static member. */ /* Initialize the user_connect static member. */
/****************************************************************************/ /****************************************************************************/
@@ -111,7 +113,10 @@ bool user_connect::user_init()
int rc= PlugExit(g); int rc= PlugExit(g);
g= NULL; g= NULL;
if (dup)
free(dup); free(dup);
return true; return true;
} // endif g-> } // endif g->
@@ -122,14 +127,18 @@ bool user_connect::user_init()
strcpy(ap->Ap_Name, "CONNECT"); strcpy(ap->Ap_Name, "CONNECT");
g->Activityp= ap; g->Activityp= ap;
g->Activityp->Aptr= dup; g->Activityp->Aptr= dup;
pthread_mutex_lock(&usrmut);
next= to_users; next= to_users;
to_users= this; to_users= this;
if (next) if (next)
next->previous= this; next->previous= this;
last_query_id= thdp->query_id;
count= 1; count= 1;
pthread_mutex_unlock(&usrmut);
last_query_id = thdp->query_id;
return false; return false;
} // end of user_init } // end of user_init
@@ -144,18 +153,22 @@ void user_connect::SetHandler(ha_connect *hc)
/****************************************************************************/ /****************************************************************************/
/* Check whether we begin a new query and if so cleanup the previous one. */ /* Check whether we begin a new query and if so cleanup the previous one. */
/****************************************************************************/ /****************************************************************************/
bool user_connect::CheckCleanup(void) bool user_connect::CheckCleanup(bool force)
{ {
if (thdp->query_id > last_query_id) { if (thdp->query_id > last_query_id || force) {
uint worksize= GetWorkSize(); uint worksize= GetWorkSize();
PlugCleanup(g, true); PlugCleanup(g, true);
if (g->Sarea_Size != worksize) { if (g->Sarea_Size != worksize) {
if (g->Sarea) if (g->Sarea) {
free(g->Sarea); if (trace)
htrc("CheckCleanup: Free Sarea %d\n", g->Sarea_Size);
// Check whether the work area size was changed free(g->Sarea);
} // endif Size
// Check whether the work area could be allocated
if (!(g->Sarea = PlugAllocMem(g, worksize))) { if (!(g->Sarea = PlugAllocMem(g, worksize))) {
g->Sarea = PlugAllocMem(g, g->Sarea_Size); g->Sarea = PlugAllocMem(g, g->Sarea_Size);
SetWorkSize(g->Sarea_Size); // Was too big SetWorkSize(g->Sarea_Size); // Was too big
@@ -171,7 +184,7 @@ bool user_connect::CheckCleanup(void)
g->Mrr = 0; g->Mrr = 0;
last_query_id= thdp->query_id; last_query_id= thdp->query_id;
if (trace) if (trace && !force)
printf("=====> Begin new query %llu\n", last_query_id); printf("=====> Begin new query %llu\n", last_query_id);
return true; return true;

View File

@@ -1,4 +1,4 @@
/* Copyright (C) Olivier Bertrand 2004 - 2011 /* Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
Declaration of the user_connect class. Declaration of the user_connect class.
@note @note
Author Olivier Bertrand
@see @see
/sql/handler.h and /storage/connect/user_connect.cc /sql/handler.h and /storage/connect/user_connect.cc
@@ -53,7 +54,7 @@ public:
// Implementation // Implementation
bool user_init(); bool user_init();
void SetHandler(ha_connect *hc); void SetHandler(ha_connect *hc);
bool CheckCleanup(void); bool CheckCleanup(bool force = false);
bool CheckQueryID(void) {return thdp->query_id > last_query_id;} bool CheckQueryID(void) {return thdp->query_id > last_query_id;}
bool CheckQuery(query_id_t vid) {return last_query_id > vid;} bool CheckQuery(query_id_t vid) {return last_query_id > vid;}

View File

@@ -118,7 +118,8 @@ ulonglong CharToNumber(const char *p, int n, ulonglong maxval,
maxval++; maxval++;
if (minus) *minus = true; if (minus) *minus = true;
} // endif Unsigned } // endif Unsigned
/* fall through */
// Fall through
case '+': case '+':
p++; p++;
break; break;
@@ -571,9 +572,9 @@ void VALUE::Printf(PGLOBAL g, FILE *f, uint n)
if (Null) if (Null)
fprintf(f, "%s<null>\n", m); fprintf(f, "%s<null>\n", m);
else else
fprintf(f, "%s%s%s", GetCharString(buf), "\n", m); fprintf(f, "%s%s\n", m, GetCharString(buf));
} /* end of Print */ } /* end of Printf */
/***********************************************************************/ /***********************************************************************/
/* Make string output of an object value. */ /* Make string output of an object value. */
@@ -588,7 +589,7 @@ void VALUE::Prints(PGLOBAL g, char *ps, uint z)
p = GetCharString(buf); p = GetCharString(buf);
strncpy(ps, p, z); strncpy(ps, p, z);
} // end of Print } // end of Prints
/* -------------------------- Class TYPVAL ---------------------------- */ /* -------------------------- Class TYPVAL ---------------------------- */
@@ -1349,7 +1350,7 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
char buf[64]; char buf[64];
if (!(Null = valp->IsNull() && Nullable)) if (!(Null = (valp->IsNull() && Nullable)))
strncpy(Strp, valp->GetCharString(buf), Len); strncpy(Strp, valp->GetCharString(buf), Len);
else else
Reset(); Reset();
@@ -1451,7 +1452,7 @@ void TYPVAL<PSZ>::SetValue(uint n)
if (k > Len) { if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
longjmp(g->jumper[g->jump_level], 138); throw 138;
} else } else
SetValue_psz(buf); SetValue_psz(buf);
@@ -1505,7 +1506,7 @@ void TYPVAL<PSZ>::SetValue(ulonglong n)
if (k > Len) { if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len); sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
longjmp(g->jumper[g->jump_level], 138); throw 138;
} else } else
SetValue_psz(buf); SetValue_psz(buf);
@@ -1655,8 +1656,9 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
int i; int i;
for (i = 0; i < np; i++) for (i = 0; i < np; i++)
p[i] = vp[i]->GetCharString(val[i]); p[i] = vp[i]->IsNull() ? NULL : vp[i]->GetCharString(val[i]);
if (p[i-1]) {
switch (op) { switch (op) {
case OP_CNC: case OP_CNC:
assert(np == 1 || np == 2); assert(np == 1 || np == 2);
@@ -1677,11 +1679,14 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]); SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]);
break; break;
default: default:
// sprintf(g->Message, MSG(BAD_EXP_OPER), op); // sprintf(g->Message, MSG(BAD_EXP_OPER), op);
strcpy(g->Message, "Function not supported"); strcpy(g->Message, "Function not supported");
return true; return true;
} // endswitch op } // endswitch op
Null = false;
} // endif p[i]
return false; return false;
} // end of Compute } // end of Compute
@@ -1719,10 +1724,14 @@ void TYPVAL<PSZ>::Prints(PGLOBAL g, char *ps, uint z)
else else
strcat(strncat(strncpy(ps, "\"", z), Strp, z-2), "\""); strcat(strncat(strncpy(ps, "\"", z), Strp, z-2), "\"");
} // end of Print } // end of Prints
/* -------------------------- Class DECIMAL -------------------------- */ /* -------------------------- Class DECIMAL -------------------------- */
/***********************************************************************/
/* DECIMAL public constructor from a constant string. */
/* -------------------------- Class DECIMAL -------------------------- */
/***********************************************************************/ /***********************************************************************/
/* DECIMAL public constructor from a constant string. */ /* DECIMAL public constructor from a constant string. */
/***********************************************************************/ /***********************************************************************/
@@ -2562,7 +2571,7 @@ bool DTVAL::SetValue_pval(PVAL valp, bool chktype)
} else if (valp->GetType() == TYPE_BIGINT && } else if (valp->GetType() == TYPE_BIGINT &&
!(valp->GetBigintValue() % 1000)) { !(valp->GetBigintValue() % 1000)) {
// Assuming that this timestamp is in milliseconds // Assuming that this timestamp is in milliseconds
Tval = valp->GetBigintValue() / 1000; Tval = (int)(valp->GetBigintValue() / 1000);
} else } else
Tval = valp->GetIntValue(); Tval = valp->GetIntValue();

View File

@@ -90,8 +90,8 @@ class DllExport VALUE : public BLOCK {
virtual double GetFloatValue(void) = 0; virtual double GetFloatValue(void) = 0;
virtual void *GetTo_Val(void) = 0; virtual void *GetTo_Val(void) = 0;
virtual void SetPrec(int prec) {Prec = prec;} virtual void SetPrec(int prec) {Prec = prec;}
bool IsNull(void) {return Null;} bool IsNull(void) {return (Nullable && Null);}
void SetNull(bool b) {Null = b;} void SetNull(bool b) {Null = (Nullable ? b : false);}
bool GetNullable(void) {return Nullable;} bool GetNullable(void) {return Nullable;}
void SetNullable(bool b) {Nullable = b;} void SetNullable(bool b) {Nullable = b;}
int GetType(void) {return Type;} int GetType(void) {return Type;}

View File

@@ -188,7 +188,7 @@ void XXBASE::Printf(PGLOBAL, FILE *f, uint n)
memset(m, ' ', n); // Make margin string memset(m, ' ', n); // Make margin string
m[n] = '\0'; m[n] = '\0';
fprintf(f, "%sXINDEX: Tbxp=%p Num=%d\n", m, Tbxp, Num_K); fprintf(f, "%sXINDEX: Tbxp=%p Num=%d\n", m, Tbxp, Num_K);
} // end of Print } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of XINDEX contents. */ /* Make string output of XINDEX contents. */
@@ -197,7 +197,7 @@ void XXBASE::Prints(PGLOBAL, char *ps, uint z)
{ {
*ps = '\0'; *ps = '\0';
strncat(ps, "Xindex", z); strncat(ps, "Xindex", z);
} // end of Print } // end of Prints
/* -------------------------- XINDEX Class --------------------------- */ /* -------------------------- XINDEX Class --------------------------- */
@@ -3009,6 +3009,7 @@ KXYCOL::KXYCOL(PKXBASE kp) : To_Keys(Keys.Memp),
bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln) bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
{ {
int len = colp->GetLength(), prec = colp->GetScale(); int len = colp->GetLength(), prec = colp->GetScale();
bool un = colp->IsUnsigned();
// Currently no indexing on NULL columns // Currently no indexing on NULL columns
if (colp->IsNullable() && kln) { if (colp->IsNullable() && kln) {
@@ -3028,7 +3029,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
// Allocate the Value object used when moving items // Allocate the Value object used when moving items
Type = colp->GetResultType(); Type = colp->GetResultType();
if (!(Valp = AllocateValue(g, Type, len, prec, colp->IsUnsigned()))) if (!(Valp = AllocateValue(g, Type, len, prec, un)))
return true; return true;
Klen = Valp->GetClen(); Klen = Valp->GetClen();
@@ -3044,7 +3045,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
// Currently we set it to true to be compatible with QRY blocks, // Currently we set it to true to be compatible with QRY blocks,
// and the one before last is to enable length/type checking, set to // and the one before last is to enable length/type checking, set to
// true if not a prefix key. // true if not a prefix key.
Kblp = AllocValBlock(g, To_Keys, Type, n, len, prec, !Prefix, true); Kblp = AllocValBlock(g, To_Keys, Type, n, len, prec, !Prefix, true, un);
Asc = sm; // Sort mode: Asc=true Desc=false Asc = sm; // Sort mode: Asc=true Desc=false
Ndf = n; Ndf = n;
@@ -3065,6 +3066,7 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m) BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
{ {
int len = colp->GetLength(), prec = colp->GetScale(); int len = colp->GetLength(), prec = colp->GetScale();
bool un = colp->IsUnsigned();
if (n[3] && colp->GetLength() > n[3] if (n[3] && colp->GetLength() > n[3]
&& colp->GetResultType() == TYPE_STRING) { && colp->GetResultType() == TYPE_STRING) {
@@ -3079,7 +3081,7 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
this, colp, Type, n[0], len, m); this, colp, Type, n[0], len, m);
// Allocate the Value object used when moving items // Allocate the Value object used when moving items
Valp = AllocateValue(g, Type, len, prec, colp->IsUnsigned()); Valp = AllocateValue(g, Type, len, prec, un);
Klen = Valp->GetClen(); Klen = Valp->GetClen();
if (n[2]) { if (n[2]) {
@@ -3088,7 +3090,7 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
Bkeys.Sub = true; Bkeys.Sub = true;
// Allocate the Valblk containing initial block key values // Allocate the Valblk containing initial block key values
Blkp = AllocValBlock(g, To_Bkeys, Type, n[2], len, prec, true, true); Blkp = AllocValBlock(g, To_Bkeys, Type, n[2], len, prec, true, true, un);
} // endif nb } // endif nb
Keys.Size = n[0] * Klen; Keys.Size = n[0] * Klen;
@@ -3099,7 +3101,7 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
// by blanks (if true) or keep the zero ending char (if false). // by blanks (if true) or keep the zero ending char (if false).
// Currently we set it to true to be compatible with QRY blocks, // Currently we set it to true to be compatible with QRY blocks,
// and last one to enable type checking (no conversion). // and last one to enable type checking (no conversion).
Kblp = AllocValBlock(g, To_Keys, Type, n[0], len, prec, !Prefix, true); Kblp = AllocValBlock(g, To_Keys, Type, n[0], len, prec, !Prefix, true, un);
if (n[1]) { if (n[1]) {
Koff.Size = n[1] * sizeof(int); Koff.Size = n[1] * sizeof(int);

View File

@@ -84,7 +84,7 @@ double XOBJECT::GetFloatValue(void)
CONSTANT::CONSTANT(PGLOBAL g, void *value, short type) CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
{ {
if (!(Value = AllocateValue(g, value, (int)type))) if (!(Value = AllocateValue(g, value, (int)type)))
throw TYPE_CONST; throw (int)TYPE_CONST;
Constant = true; Constant = true;
} // end of CONSTANT constructor } // end of CONSTANT constructor
@@ -95,7 +95,7 @@ CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
CONSTANT::CONSTANT(PGLOBAL g, int n) CONSTANT::CONSTANT(PGLOBAL g, int n)
{ {
if (!(Value = AllocateValue(g, &n, TYPE_INT))) if (!(Value = AllocateValue(g, &n, TYPE_INT)))
throw TYPE_CONST; throw (int)TYPE_CONST;
Constant = true; Constant = true;
} // end of CONSTANT constructor } // end of CONSTANT constructor
@@ -117,7 +117,7 @@ void CONSTANT::Convert(PGLOBAL g, int newtype)
{ {
if (Value->GetType() != newtype) if (Value->GetType() != newtype)
if (!(Value = AllocateValue(g, Value, newtype))) if (!(Value = AllocateValue(g, Value, newtype)))
throw TYPE_CONST; throw (int)TYPE_CONST;
} // end of Convert } // end of Convert
@@ -176,7 +176,7 @@ bool CONSTANT::Rephrase(PGLOBAL g, PSZ work)
void CONSTANT::Printf(PGLOBAL g, FILE *f, uint n) void CONSTANT::Printf(PGLOBAL g, FILE *f, uint n)
{ {
Value->Printf(g, f, n); Value->Printf(g, f, n);
} /* end of Print */ } /* end of Printf */
/***********************************************************************/ /***********************************************************************/
/* Make string output of a constant object. */ /* Make string output of a constant object. */
@@ -184,7 +184,7 @@ void CONSTANT::Printf(PGLOBAL g, FILE *f, uint n)
void CONSTANT::Prints(PGLOBAL g, char *ps, uint z) void CONSTANT::Prints(PGLOBAL g, char *ps, uint z)
{ {
Value->Prints(g, ps, z); Value->Prints(g, ps, z);
} /* end of Print */ } /* end of Prints */
/* -------------------------- Class STRING --------------------------- */ /* -------------------------- Class STRING --------------------------- */