Commit 8f34d454 authored by Olivier Bertrand's avatar Olivier Bertrand

- Add the new BSON temporary type for testing

  modified:   storage/connect/CMakeLists.txt
  modified:   storage/connect/bson.cpp
  modified:   storage/connect/bson.h
  modified:   storage/connect/bsonudf.cpp
  modified:   storage/connect/bsonudf.h
  modified:   storage/connect/global.h
  modified:   storage/connect/json.cpp
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/mysql-test/connect/disabled.def
  modified:   storage/connect/mysql-test/connect/t/mongo_test.inc
  modified:   storage/connect/plugutil.cpp
  modified:   storage/connect/tabbson.cpp
  modified:   storage/connect/tabjson.cpp
parent cba46c99
......@@ -80,6 +80,19 @@ ELSE(NOT UNIX)
ENDIF()
ENDIF(UNIX)
#
# BSON: this the new version of JSON that is temporarily included here for testing
# When fully tested, it will replace the old support (and be renamed to JSON)
#
OPTION(CONNECT_WITH_BSON "Compile CONNECT storage engine with BSON support" ON)
IF(CONNECT_WITH_BSON)
SET(CONNECT_SOURCES ${CONNECT_SOURCES}
bson.cpp tabbson.cpp bsonudf.cpp bson.h tabbson.h bsonudf.h)
add_definitions(-DBSON_SUPPORT)
ENDIF(CONNECT_WITH_BSON)
#
# VCT: the VEC format might be not supported in future versions
......
......@@ -544,9 +544,9 @@ void BDOC::ParseNumeric(int& i, PBVAL vlp)
buf[n] = 0;
if (has_dot || has_e) {
double dv = strtod(buf, NULL);
double dv = atof(buf);
if (nd > 5 || dv > FLT_MAX || dv < FLT_MIN) {
if (nd >= 6 || dv > FLT_MAX || dv < FLT_MIN) {
double* dvp = (double*)PlugSubAlloc(G, NULL, sizeof(double));
*dvp = dv;
......@@ -557,7 +557,7 @@ void BDOC::ParseNumeric(int& i, PBVAL vlp)
vlp->Type = TYPE_FLOAT;
} // endif nd
vlp->Nd = nd;
vlp->Nd = MY_MIN(nd, 16);
} else {
longlong iv = strtoll(buf, NULL, 10);
......@@ -765,6 +765,8 @@ bool BDOC::SerializeValue(PBVAL jvp)
return jp->WriteStr(buf);
case TYPE_NULL:
return jp->WriteStr("null");
case TYPE_JVAL:
return SerializeValue(MVP(jvp->To_Val));
default:
return jp->WriteStr("???"); // TODO
} // endswitch Type
......@@ -793,7 +795,12 @@ void* BJSON::BsonSubAlloc(size_t size)
"Not enough memory for request of %zd (used=%zd free=%zd)",
size, pph->To_Free, pph->FreeBlk);
xtrc(1, "BsonSubAlloc: %s\n", G->Message);
throw(1234);
if (Throw)
throw(1234);
else
return NULL;
} /* endif size OS32 code */
// Do the suballocation the simplest way
......@@ -1066,7 +1073,7 @@ PBVAL BJSON::MergeObject(PBVAL bop1, PBVAL bop2)
/***********************************************************************/
/* Delete a value corresponding to the given key. */
/***********************************************************************/
void BJSON::DeleteKey(PBVAL bop, PCSZ key)
bool BJSON::DeleteKey(PBVAL bop, PCSZ key)
{
CheckType(bop, TYPE_JOB);
PBPR brp, pbrp = NULL;
......@@ -1079,10 +1086,11 @@ void BJSON::DeleteKey(PBVAL bop, PCSZ key)
bop->To_Val = brp->Vlp.Next;
bop->Nd--;
break;
return true;;
} else
pbrp = brp;
return false;
} // end of DeleteKey
/***********************************************************************/
......@@ -1247,24 +1255,25 @@ PSZ BJSON::GetArrayText(PGLOBAL g, PBVAL bap, PSTRG text)
/***********************************************************************/
/* Delete a Value from the Arrays Value list. */
/***********************************************************************/
void BJSON::DeleteValue(PBVAL bap, int n)
bool BJSON::DeleteValue(PBVAL bap, int n)
{
CheckType(bap, TYPE_JAR);
int i = 0;
PBVAL bvp, pvp = NULL;
for (bvp = GetArray(bap); bvp; i++, bvp = GetNext(bvp))
if (i == n) {
if (pvp)
pvp->Next = bvp->Next;
else
bap->To_Val = bvp->Next;
for (bvp = GetArray(bap); bvp; i++, bvp = GetNext(bvp))
if (i == n) {
if (pvp)
pvp->Next = bvp->Next;
else
bap->To_Val = bvp->Next;
bap->Nd--;
break;
} else
pvp = bvp;
bap->Nd--;
return true;;
} else
pvp = bvp;
return false;
} // end of DeleteValue
/***********************************************************************/
......@@ -1510,7 +1519,7 @@ double BJSON::GetDouble(PBVAL vp)
} // endswitch Type
return d;
} // end of GetFloat
} // end of GetDouble
/***********************************************************************/
/* Return the Value's String value. */
......@@ -1603,61 +1612,64 @@ PBVAL BJSON::SetValue(PBVAL vlp, PVAL valp)
if (!valp || valp->IsNull()) {
vlp->Type = TYPE_NULL;
} else switch (valp->GetType()) {
case TYPE_DATE:
if (((DTVAL*)valp)->IsFormatted())
vlp->To_Val = DupStr(valp->GetCharValue());
else {
char buf[32];
case TYPE_DATE:
if (((DTVAL*)valp)->IsFormatted())
vlp->To_Val = DupStr(valp->GetCharValue());
else {
char buf[32];
vlp->To_Val = DupStr(valp->GetCharString(buf));
} // endif Formatted
vlp->To_Val = DupStr(valp->GetCharString(buf));
} // endif Formatted
vlp->Type = TYPE_DTM;
break;
case TYPE_STRING:
vlp->To_Val = DupStr(valp->GetCharValue());
vlp->Type = TYPE_STRG;
break;
case TYPE_DOUBLE:
case TYPE_DECIM:
vlp->Nd = (IsTypeNum(valp->GetType())) ? valp->GetValPrec() : 0;
vlp->Type = TYPE_DTM;
break;
case TYPE_STRING:
vlp->To_Val = DupStr(valp->GetCharValue());
vlp->Type = TYPE_STRG;
break;
case TYPE_DOUBLE:
case TYPE_DECIM:
{ double d = valp->GetFloatValue();
int nd = (IsTypeNum(valp->GetType())) ? valp->GetValPrec() : 0;
if (vlp->Nd <= 6) {
vlp->F = (float)valp->GetFloatValue();
vlp->Type = TYPE_FLOAT;
} else {
double *dp = (double*)BsonSubAlloc(sizeof(double));
if (nd <= 6 && d >= FLT_MIN && d <= FLT_MAX) {
vlp->F = (float)valp->GetFloatValue();
vlp->Type = TYPE_FLOAT;
} else {
double* dp = (double*)BsonSubAlloc(sizeof(double));
*dp = valp->GetFloatValue();
vlp->To_Val = MOF(dp);
vlp->Type = TYPE_DBL;
} // endif Nd
*dp = d;
vlp->To_Val = MOF(dp);
vlp->Type = TYPE_DBL;
} // endif Nd
break;
case TYPE_TINY:
vlp->B = valp->GetTinyValue() != 0;
vlp->Type = TYPE_BOOL;
case TYPE_INT:
vlp->N = valp->GetIntValue();
vlp->Type = TYPE_INTG;
break;
case TYPE_BIGINT:
if (valp->GetBigintValue() >= INT_MIN32 &&
valp->GetBigintValue() <= INT_MAX32) {
vlp->Nd = MY_MIN(nd, 16);
} break;
case TYPE_TINY:
vlp->B = valp->GetTinyValue() != 0;
vlp->Type = TYPE_BOOL;
break;
case TYPE_INT:
vlp->N = valp->GetIntValue();
vlp->Type = TYPE_INTG;
} else {
longlong* llp = (longlong*)BsonSubAlloc(sizeof(longlong));
break;
case TYPE_BIGINT:
if (valp->GetBigintValue() >= INT_MIN32 &&
valp->GetBigintValue() <= INT_MAX32) {
vlp->N = valp->GetIntValue();
vlp->Type = TYPE_INTG;
} else {
longlong* llp = (longlong*)BsonSubAlloc(sizeof(longlong));
*llp = valp->GetBigintValue();
vlp->To_Val = MOF(llp);
vlp->Type = TYPE_BINT;
} // endif BigintValue
*llp = valp->GetBigintValue();
vlp->To_Val = MOF(llp);
vlp->Type = TYPE_BINT;
} // endif BigintValue
break;
default:
sprintf(G->Message, "Unsupported typ %d\n", valp->GetType());
throw(777);
break;
default:
sprintf(G->Message, "Unsupported typ %d\n", valp->GetType());
throw(777);
} // endswitch Type
return vlp;
......@@ -1702,16 +1714,44 @@ void BJSON::SetBigint(PBVAL vlp, longlong ll)
/***********************************************************************/
/* Set the Value's value as the given DOUBLE. */
/***********************************************************************/
void BJSON::SetFloat(PBVAL vlp, double f) {
vlp->F = (float)f;
vlp->Nd = 6;
vlp->Type = TYPE_FLOAT;
void BJSON::SetFloat(PBVAL vlp, double d, int nd)
{
double* dp = (double*)BsonSubAlloc(sizeof(double));
*dp = d;
vlp->To_Val = MOF(dp);
vlp->Nd = MY_MIN(nd, 16);
vlp->Type = TYPE_DBL;
} // end of SetFloat
/***********************************************************************/
/* Set the Value's value as the given DOUBLE representation. */
/***********************************************************************/
void BJSON::SetFloat(PBVAL vlp, PSZ s)
{
char *p = strchr(s, '.');
int nd = 0;
double d = atof(s);
if (p) {
for (++p; isdigit(*p); nd++, p++);
for (--p; *p == '0'; nd--, p--);
} // endif p
if (nd < 6 && d >= FLT_MIN && d <= FLT_MAX) {
vlp->F = (float)d;
vlp->Nd = nd;
vlp->Type = TYPE_FLOAT;
} else
SetFloat(vlp, d, nd);
} // end of SetFloat
/***********************************************************************/
/* Set the Value's value as the given string. */
/***********************************************************************/
void BJSON::SetString(PBVAL vlp, PSZ s, int ci) {
void BJSON::SetString(PBVAL vlp, PSZ s, int ci)
{
vlp->To_Val = MOF(s);
vlp->Nd = ci;
vlp->Type = TYPE_STRG;
......@@ -1720,7 +1760,8 @@ void BJSON::SetString(PBVAL vlp, PSZ s, int ci) {
/***********************************************************************/
/* True when its JSON or normal value is null. */
/***********************************************************************/
bool BJSON::IsValueNull(PBVAL vlp) {
bool BJSON::IsValueNull(PBVAL vlp)
{
bool b;
switch (vlp->Type) {
......
......@@ -62,7 +62,8 @@ DllExport bool IsNum(PSZ s);
class BJSON : public BLOCK {
public:
// Constructor
BJSON(PGLOBAL g, PBVAL vp = NULL) { G = g, Base = G->Sarea; Bvp = vp; }
BJSON(PGLOBAL g, PBVAL vp = NULL)
{ G = g, Base = G->Sarea; Bvp = vp; Throw = true; }
// Utility functions
inline OFFSET MOF(void *p) {return MakeOff(Base, p);}
......@@ -73,6 +74,7 @@ class BJSON : public BLOCK {
inline longlong LLN(OFFSET o) {return *(longlong*)MakePtr(Base, o);}
inline double DBL(OFFSET o) {return *(double*)MakePtr(Base, o);}
void Reset(void) {Base = G->Sarea;}
void* GetBase(void) { return Base; }
void SubSet(bool b = false);
void MemSave(void) {G->Saved_Size = ((PPOOLHEADER)G->Sarea)->To_Free;}
......@@ -102,7 +104,7 @@ class BJSON : public BLOCK {
PBVAL GetArrayValue(PBVAL bap, int i);
PSZ GetArrayText(PGLOBAL g, PBVAL bap, PSTRG text);
void MergeArray(PBVAL bap1,PBVAL bap2);
void DeleteValue(PBVAL bap, int n);
bool DeleteValue(PBVAL bap, int n);
void AddArrayValue(PBVAL bap, OFFSET nvp = NULL, int* x = NULL);
inline void AddArrayValue(PBVAL bap, PBVAL nvp = NULL, int* x = NULL)
{AddArrayValue(bap, MOF(nvp), x);}
......@@ -126,7 +128,7 @@ class BJSON : public BLOCK {
void SetKeyValue(PBVAL bop, OFFSET bvp, PSZ key);
inline void SetKeyValue(PBVAL bop, PBVAL vlp, PSZ key)
{SetKeyValue(bop, MOF(vlp), key);}
void DeleteKey(PBVAL bop, PCSZ k);
bool DeleteKey(PBVAL bop, PCSZ k);
bool IsObjectNull(PBVAL bop);
// Value functions
......@@ -147,17 +149,20 @@ class BJSON : public BLOCK {
void SetString(PBVAL vlp, PSZ s, int ci = 0);
void SetInteger(PBVAL vlp, int n);
void SetBigint(PBVAL vlp, longlong ll);
void SetFloat(PBVAL vlp, double f);
void SetFloat(PBVAL vlp, double f, int nd = 16);
void SetFloat(PBVAL vlp, PSZ s);
void SetBool(PBVAL vlp, bool b);
void Clear(PBVAL vlp) { vlp->N = 0; vlp->Nd = 0; vlp->Next = 0; }
bool IsValueNull(PBVAL vlp);
bool IsJson(PBVAL vlp)
{return vlp ? vlp->Type == TYPE_JAR || vlp->Type == TYPE_JOB : false;}
bool IsJson(PBVAL vlp) {return vlp ? vlp->Type == TYPE_JAR ||
vlp->Type == TYPE_JOB ||
vlp->Type == TYPE_JVAL : false;}
// Members
PGLOBAL G;
PBVAL Bvp;
void *Base;
bool Throw;
protected:
// Default constructor not to be used
......
This diff is collapsed.
/******************** tabjson H Declares Source Code File (.H) *******************/
/* Name: bsonudf.h Version 1.0 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2020 */
/* (C) Copyright to the author Olivier BERTRAND 2020 - 2021 */
/* */
/* This file contains the BSON UDF function and class declares. */
/*********************************************************************************/
......@@ -96,6 +96,7 @@ class BJNX : public BDOC {
int GetPrecision(void) { return Prec; }
PVAL GetValue(void) { return Value; }
void SetRow(PBVAL vp) { Row = vp; }
void SetChanged(my_bool b) { Changed = b; }
// Methods
my_bool SetJpath(PGLOBAL g, char* path, my_bool jb = false);
......@@ -106,14 +107,16 @@ class BJNX : public BDOC {
my_bool CheckPath(PGLOBAL g);
my_bool CheckPath(PGLOBAL g, UDF_ARGS* args, PBVAL jsp, PBVAL& jvp, int n);
my_bool WriteValue(PGLOBAL g, PBVAL jvalp);
my_bool DeleteItem(PGLOBAL g, PBVAL vlp);
char *Locate(PGLOBAL g, PBVAL jsp, PBVAL jvp, int k = 1);
char *LocateAll(PGLOBAL g, PBVAL jsp, PBVAL jvp, int mx = 10);
PSZ MakeKey(UDF_ARGS* args, int i);
PBVAL MakeBinValue(PGLOBAL g, UDF_ARGS* args, uint i);
PBVAL MakeValue(PGLOBAL g, UDF_ARGS* args, uint i, PBVAL* top = NULL);
PBVAL MakeValue(UDF_ARGS* args, uint i, bool b = false, PBVAL* top = NULL);
PBVAL MakeTypedValue(PGLOBAL g, UDF_ARGS* args, uint i,
JTYP type, PBVAL* top = NULL);
PBVAL ParseJsonFile(PGLOBAL g, char* fn, int& pty, size_t& len);
char *MakeResult(UDF_ARGS* args, PBVAL top, uint n = 2);
PBSON MakeBinResult(PGLOBAL g, UDF_ARGS* args, PBVAL top, ulong len, int n = 2);
protected:
my_bool SetArrayOptions(PGLOBAL g, char* p, int i, PSZ nm);
......@@ -159,6 +162,7 @@ class BJNX : public BDOC {
my_bool Found; // Item found by locate
my_bool Wr; // Write mode
my_bool Jb; // Must return json item
my_bool Changed; // True when contains was modified
}; // end of class BJNX
extern "C" {
......@@ -268,6 +272,10 @@ extern "C" {
DllExport char *bson_object_grp(UDF_EXEC_ARGS);
DllExport void bson_object_grp_deinit(UDF_INIT*);
DllExport my_bool bson_delete_item_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bson_delete_item(UDF_EXEC_ARGS);
DllExport void bson_delete_item_deinit(UDF_INIT*);
DllExport my_bool bson_set_item_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bson_set_item(UDF_EXEC_ARGS);
DllExport void bson_set_item_deinit(UDF_INIT*);
......@@ -295,4 +303,92 @@ extern "C" {
DllExport my_bool bfile_bjson_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bfile_bjson(UDF_EXEC_ARGS);
DllExport void bfile_bjson_deinit(UDF_INIT*);
DllExport my_bool bson_serialize_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bson_serialize(UDF_EXEC_ARGS);
DllExport void bson_serialize_deinit(UDF_INIT*);
DllExport my_bool bbin_make_array_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bbin_make_array(UDF_EXEC_ARGS);
DllExport void bbin_make_array_deinit(UDF_INIT*);
DllExport my_bool bbin_array_add_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bbin_array_add(UDF_EXEC_ARGS);
DllExport void bbin_array_add_deinit(UDF_INIT*);
DllExport my_bool bbin_array_add_values_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bbin_array_add_values(UDF_EXEC_ARGS);
DllExport void bbin_array_add_values_deinit(UDF_INIT*);
DllExport my_bool bbin_array_delete_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bbin_array_delete(UDF_EXEC_ARGS);
DllExport void bbin_array_delete_deinit(UDF_INIT*);
DllExport my_bool bbin_array_grp_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport void bbin_array_grp_clear(UDF_INIT *, char *, char *);
DllExport void bbin_array_grp_add(UDF_INIT *, UDF_ARGS *, char *, char *);
DllExport char *bbin_array_grp(UDF_EXEC_ARGS);
DllExport void bbin_array_grp_deinit(UDF_INIT*);
DllExport my_bool bbin_object_grp_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport void bbin_object_grp_clear(UDF_INIT *, char *, char *);
DllExport void bbin_object_grp_add(UDF_INIT *, UDF_ARGS *, char *, char *);
DllExport char *bbin_object_grp(UDF_EXEC_ARGS);
DllExport void bbin_object_grp_deinit(UDF_INIT*);
DllExport my_bool bbin_make_object_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bbin_make_object(UDF_EXEC_ARGS);
DllExport void bbin_make_object_deinit(UDF_INIT*);
DllExport my_bool bbin_object_nonull_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bbin_object_nonull(UDF_EXEC_ARGS);
DllExport void bbin_object_nonull_deinit(UDF_INIT*);
DllExport my_bool bbin_object_key_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bbin_object_key(UDF_EXEC_ARGS);
DllExport void bbin_object_key_deinit(UDF_INIT*);
DllExport my_bool bbin_object_add_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bbin_object_add(UDF_EXEC_ARGS);
DllExport void bbin_object_add_deinit(UDF_INIT*);
DllExport my_bool bbin_object_delete_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bbin_object_delete(UDF_EXEC_ARGS);
DllExport void bbin_object_delete_deinit(UDF_INIT*);
DllExport my_bool bbin_object_list_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bbin_object_list(UDF_EXEC_ARGS);
DllExport void bbin_object_list_deinit(UDF_INIT*);
DllExport my_bool bbin_object_values_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bbin_object_values(UDF_EXEC_ARGS);
DllExport void bbin_object_values_deinit(UDF_INIT*);
DllExport my_bool bbin_get_item_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bbin_get_item(UDF_EXEC_ARGS);
DllExport void bbin_get_item_deinit(UDF_INIT*);
DllExport my_bool bbin_set_item_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bbin_set_item(UDF_EXEC_ARGS);
DllExport void bbin_set_item_deinit(UDF_INIT*);
DllExport my_bool bbin_insert_item_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bbin_insert_item(UDF_EXEC_ARGS);
DllExport void bbin_insert_item_deinit(UDF_INIT*);
DllExport my_bool bbin_update_item_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bbin_update_item(UDF_EXEC_ARGS);
DllExport void bbin_update_item_deinit(UDF_INIT*);
DllExport my_bool bbin_delete_item_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bbin_delete_item(UDF_EXEC_ARGS);
DllExport void bbin_delete_item_deinit(UDF_INIT*);
DllExport my_bool bbin_locate_all_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bbin_locate_all(UDF_EXEC_ARGS);
DllExport void bbin_locate_all_deinit(UDF_INIT*);
DllExport my_bool bbin_file_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bbin_file(UDF_EXEC_ARGS);
DllExport void bbin_file_deinit(UDF_INIT*);
} // extern "C"
......@@ -185,7 +185,7 @@ typedef struct _global { /* Global structure */
size_t Sarea_Size; /* Work area size */
PACTIVITY Activityp;
char Message[MAX_STR]; /* Message (result, error, trace) */
ulong More; /* Used by jsonudf */
size_t More; /* Used by jsonudf */
size_t Saved_Size; /* Saved work area to_free */
bool Createas; /* To pass multi to ext tables */
void *Xchk; /* indexes in create/alter */
......
......@@ -333,25 +333,30 @@ bool JOUTSTR::WriteChr(const char c) {
/***********************************************************************/
/* Escape and Concatenate a string to the Serialize string. */
/***********************************************************************/
bool JOUTSTR::Escape(const char* s) {
WriteChr('"');
bool JOUTSTR::Escape(const char* s)
{
if (s) {
WriteChr('"');
for (unsigned int i = 0; s[i]; i++)
switch (s[i]) {
case '"':
case '\\':
case '\t':
case '\n':
case '\r':
case '\b':
case '\f': WriteChr('\\');
// fall through
default:
WriteChr(s[i]);
break;
} // endswitch s[i]
for (unsigned int i = 0; s[i]; i++)
switch (s[i]) {
case '"':
case '\\':
case '\t':
case '\n':
case '\r':
case '\b':
case '\f': WriteChr('\\');
// fall through
default:
WriteChr(s[i]);
break;
} // endswitch s[i]
WriteChr('"');
} else
WriteStr("null");
WriteChr('"');
return false;
} // end of Escape
......@@ -360,7 +365,8 @@ bool JOUTSTR::Escape(const char* s) {
/***********************************************************************/
/* Write a string to the Serialize file. */
/***********************************************************************/
bool JOUTFILE::WriteStr(const char* s) {
bool JOUTFILE::WriteStr(const char* s)
{
// This is temporary
fputs(s, Stream);
return false;
......@@ -369,7 +375,8 @@ bool JOUTFILE::WriteStr(const char* s) {
/***********************************************************************/
/* Write a character to the Serialize file. */
/***********************************************************************/
bool JOUTFILE::WriteChr(const char c) {
bool JOUTFILE::WriteChr(const char c)
{
// This is temporary
fputc(c, Stream);
return false;
......@@ -378,25 +385,30 @@ bool JOUTFILE::WriteChr(const char c) {
/***********************************************************************/
/* Escape and Concatenate a string to the Serialize string. */
/***********************************************************************/
bool JOUTFILE::Escape(const char* s) {
bool JOUTFILE::Escape(const char* s)
{
// This is temporary
fputc('"', Stream);
if (s) {
fputc('"', Stream);
for (unsigned int i = 0; s[i]; i++)
switch (s[i]) {
case '"': fputs("\\\"", Stream); break;
case '\\': fputs("\\\\", Stream); break;
case '\t': fputs("\\t", Stream); break;
case '\n': fputs("\\n", Stream); break;
case '\r': fputs("\\r", Stream); break;
case '\b': fputs("\\b", Stream); break;
case '\f': fputs("\\f", Stream); break;
default:
fputc(s[i], Stream);
break;
} // endswitch s[i]
for (unsigned int i = 0; s[i]; i++)
switch (s[i]) {
case '"': fputs("\\\"", Stream); break;
case '\\': fputs("\\\\", Stream); break;
case '\t': fputs("\\t", Stream); break;
case '\n': fputs("\\n", Stream); break;
case '\r': fputs("\\r", Stream); break;
case '\b': fputs("\\b", Stream); break;
case '\f': fputs("\\f", Stream); break;
default:
fputc(s[i], Stream);
break;
} // endswitch s[i]
fputc('"', Stream);
} else
fputs("null", Stream);
fputc('"', Stream);
return false;
} // end of Escape
......@@ -405,7 +417,8 @@ bool JOUTFILE::Escape(const char* s) {
/***********************************************************************/
/* Write a string to the Serialize pretty file. */
/***********************************************************************/
bool JOUTPRT::WriteStr(const char* s) {
bool JOUTPRT::WriteStr(const char* s)
{
// This is temporary
if (B) {
fputs(EL, Stream);
......@@ -424,7 +437,8 @@ bool JOUTPRT::WriteStr(const char* s) {
/***********************************************************************/
/* Write a character to the Serialize pretty file. */
/***********************************************************************/
bool JOUTPRT::WriteChr(const char c) {
bool JOUTPRT::WriteChr(const char c)
{
switch (c) {
case ':':
fputs(": ", Stream);
......
......@@ -1155,7 +1155,7 @@ PBSON JbinAlloc(PGLOBAL g, UDF_ARGS *args, ulong len, PJSON jsp)
/*********************************************************************************/
/* Set the BSON chain as changed. */
/*********************************************************************************/
static void SetChanged(PBSON bsp)
void SetChanged(PBSON bsp)
{
if (bsp->Bsp)
SetChanged(bsp->Bsp);
......
......@@ -16,9 +16,12 @@ jdbc_postgresql : Variable settings depend on machine configuration
json_mongo_c : Need MongoDB running and its C Driver installed
json_java_2 : Need MongoDB running and its Java Driver installed
json_java_3 : Need MongoDB running and its Java Driver installed
bson_mongo_c : Need MongoDB running and its C Driver installed
bson_java_2 : Need MongoDB running and its Java Driver installed
bson_java_3 : Need MongoDB running and its Java Driver installed
mongo_c : Need MongoDB running and its C Driver installed
mongo_java_2 : Need MongoDB running and its Java Driver installed
mongo_java_3 : Need MongoDB running and its Java Driver installed
tbl_thread : Bug MDEV-9844,10179,14214 03/01/2018 OB Option THREAD removed
bson : Development
#bson : Development
#vcol : Different error code on different versions
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
-- source jdbconn.inc
-- source mongo.inc
--disable_query_log
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo2.jar';
set connect_json_all_path=0;
--enable_query_log
let $DRV= Java;
let $VERS= 2;
let $TYPE= BSON;
let $CONN= CONNECTION='mongodb://localhost:27017' LRECL=4096;
-- source mongo_test.inc
-- source jdbconn_cleanup.inc
-- source jdbconn.inc
-- source mongo.inc
--disable_query_log
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/Mongo3.jar';
set connect_json_all_path=0;
--enable_query_log
let $DRV= Java;
let $VERS= 3;
let $TYPE= BSON;
let $CONN= CONNECTION='mongodb://localhost:27017' LRECL=4096;
-- source mongo_test.inc
-- source jdbconn_cleanup.inc
-- source mongo.inc
let $DRV= C;
let $VERS= 0;
let $PROJ= {"projection":;
let $ENDP= };
let $TYPE= BSON;
let $CONN= CONNECTION='mongodb://localhost:27017' LRECL=1024;
-- source mongo_test.inc
......@@ -126,6 +126,10 @@ IF ($TYPE == JSON)
{
SELECT name, borough, address_street, grades_score AS score FROM t1 WHERE grades_grade = 'B';
}
IF ($TYPE == BSON)
{
SELECT name, borough, address_street, grades_score AS score FROM t1 WHERE grades_grade = 'B';
}
DROP TABLE t1;
--echo #
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment