Commit 347bce02 authored by Olivier Bertrand's avatar Olivier Bertrand

- Remove static linkage to cpprestsdk when it is installed

  modified:   storage/connect/CMakeLists.txt

- Continue BSON development
  modified:   storage/connect/bson.cpp
  modified:   storage/connect/bson.h
  modified:   storage/connect/bsonudf.cpp
  modified:   storage/connect/bsonudf.h
  added:      storage/connect/mysql-test/connect/r/bson_udf.result
  added:      storage/connect/mysql-test/connect/t/bson_udf.inc
  added:      storage/connect/mysql-test/connect/t/bson_udf.test
  added:      storage/connect/mysql-test/connect/t/bson_udf2.inc
parent 70cfeb9b
...@@ -334,26 +334,26 @@ IF(CONNECT_WITH_REST) ...@@ -334,26 +334,26 @@ IF(CONNECT_WITH_REST)
# MESSAGE(STATUS "=====> REST support is ON") # MESSAGE(STATUS "=====> REST support is ON")
SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp tabrest.h) SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp tabrest.h)
add_definitions(-DREST_SUPPORT) add_definitions(-DREST_SUPPORT)
FIND_PACKAGE(cpprestsdk QUIET) # FIND_PACKAGE(cpprestsdk QUIET)
IF (cpprestsdk_FOUND) # IF (cpprestsdk_FOUND)
IF(UNIX) # IF(UNIX)
# INCLUDE_DIRECTORIES(${CPPRESTSDK_INCLUDE_DIR}) ## INCLUDE_DIRECTORIES(${CPPRESTSDK_INCLUDE_DIR})
# If needed edit next line to set the path to libcpprest.so ## If needed edit next line to set the path to libcpprest.so
SET(REST_LIBRARY -lcpprest) # SET(REST_LIBRARY -lcpprest)
MESSAGE (STATUS ${REST_LIBRARY}) # MESSAGE (STATUS ${REST_LIBRARY})
ELSE(NOT UNIX) # ELSE(NOT UNIX)
# Next line sets debug compile mode matching cpprest_2_10d.dll ## Next line sets debug compile mode matching cpprest_2_10d.dll
# when it was binary installed (can be change later in Visual Studio) ## when it was binary installed (can be change later in Visual Studio)
# Comment it out if not needed depending on your cpprestsdk installation. ## Comment it out if not needed depending on your cpprestsdk installation.
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd") # SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
ENDIF(UNIX) # ENDIF(UNIX)
# IF(REST_LIBRARY) why this? how about Windows ## IF(REST_LIBRARY) why this? how about Windows
SET(CONNECT_SOURCES ${CONNECT_SOURCES} restget.cpp) # SET(CONNECT_SOURCES ${CONNECT_SOURCES} restget.cpp)
add_definitions(-DREST_SOURCE) # add_definitions(-DREST_SOURCE)
# ENDIF() ## ENDIF()
# ELSE(NOT cpprestsdk_FOUND) ##ELSE(NOT cpprestsdk_FOUND)
# MESSAGE(STATUS "=====> cpprestsdk package not found") ## MESSAGE(STATUS "=====> cpprestsdk package not found")
ENDIF (cpprestsdk_FOUND) # ENDIF (cpprestsdk_FOUND)
ENDIF(CONNECT_WITH_REST) ENDIF(CONNECT_WITH_REST)
# #
......
...@@ -631,7 +631,7 @@ PSZ BDOC::Serialize(PGLOBAL g, PBVAL bvp, char* fn, int pretty) ...@@ -631,7 +631,7 @@ PSZ BDOC::Serialize(PGLOBAL g, PBVAL bvp, char* fn, int pretty)
err = SerializeValue(MVP(bvp->To_Val)); err = SerializeValue(MVP(bvp->To_Val));
break; break;
default: default:
err = SerializeValue(bvp); err = SerializeValue(bvp, true);
} // endswitch Type } // endswitch Type
if (fs) { if (fs) {
...@@ -737,7 +737,7 @@ bool BDOC::SerializeObject(OFFSET obp) ...@@ -737,7 +737,7 @@ bool BDOC::SerializeObject(OFFSET obp)
/***********************************************************************/ /***********************************************************************/
/* Serialize a JSON Value. */ /* Serialize a JSON Value. */
/***********************************************************************/ /***********************************************************************/
bool BDOC::SerializeValue(PBVAL jvp) bool BDOC::SerializeValue(PBVAL jvp, bool b)
{ {
char buf[64]; char buf[64];
...@@ -750,7 +750,11 @@ bool BDOC::SerializeValue(PBVAL jvp) ...@@ -750,7 +750,11 @@ bool BDOC::SerializeValue(PBVAL jvp)
return jp->WriteStr(jvp->B ? "true" : "false"); return jp->WriteStr(jvp->B ? "true" : "false");
case TYPE_STRG: case TYPE_STRG:
case TYPE_DTM: case TYPE_DTM:
if (b) {
return jp->WriteStr(MZP(jvp->To_Val));
} else
return jp->Escape(MZP(jvp->To_Val)); return jp->Escape(MZP(jvp->To_Val));
case TYPE_INTG: case TYPE_INTG:
sprintf(buf, "%d", jvp->N); sprintf(buf, "%d", jvp->N);
return jp->WriteStr(buf); return jp->WriteStr(buf);
...@@ -1505,8 +1509,12 @@ double BJSON::GetDouble(PBVAL vp) ...@@ -1505,8 +1509,12 @@ double BJSON::GetDouble(PBVAL vp)
d = (double)vlp->N; d = (double)vlp->N;
break; break;
case TYPE_FLOAT: case TYPE_FLOAT:
d = (double)vlp->F; { char buf[32];
break; int n = (vlp->Nd) ? vlp->Nd : 5;
sprintf(buf, "%.*f", n, vlp->F);
d = atof(buf);
} break;
case TYPE_DTM: case TYPE_DTM:
case TYPE_STRG: case TYPE_STRG:
d = atof(MZP(vlp->To_Val)); d = atof(MZP(vlp->To_Val));
...@@ -1632,7 +1640,7 @@ PBVAL BJSON::SetValue(PBVAL vlp, PVAL valp) ...@@ -1632,7 +1640,7 @@ PBVAL BJSON::SetValue(PBVAL vlp, PVAL valp)
{ double d = valp->GetFloatValue(); { double d = valp->GetFloatValue();
int nd = (IsTypeNum(valp->GetType())) ? valp->GetValPrec() : 0; int nd = (IsTypeNum(valp->GetType())) ? valp->GetValPrec() : 0;
if (nd <= 6 && d >= FLT_MIN && d <= FLT_MAX) { if (nd > 0 && nd <= 6 && d >= FLT_MIN && d <= FLT_MAX) {
vlp->F = (float)valp->GetFloatValue(); vlp->F = (float)valp->GetFloatValue();
vlp->Type = TYPE_FLOAT; vlp->Type = TYPE_FLOAT;
} else { } else {
......
...@@ -193,7 +193,7 @@ class BDOC : public BJSON { ...@@ -193,7 +193,7 @@ class BDOC : public BJSON {
OFFSET ParseAsArray(int& i); OFFSET ParseAsArray(int& i);
bool SerializeArray(OFFSET arp, bool b); bool SerializeArray(OFFSET arp, bool b);
bool SerializeObject(OFFSET obp); bool SerializeObject(OFFSET obp);
bool SerializeValue(PBVAL vp); bool SerializeValue(PBVAL vp, bool b = false);
// Members used when parsing and serializing // Members used when parsing and serializing
JOUT* jp; // Used with serialize JOUT* jp; // Used with serialize
......
This diff is collapsed.
...@@ -116,7 +116,7 @@ class BJNX : public BDOC { ...@@ -116,7 +116,7 @@ class BJNX : public BDOC {
JTYP type, PBVAL* top = NULL); JTYP type, PBVAL* top = NULL);
PBVAL ParseJsonFile(PGLOBAL g, char* fn, int& pty, size_t& len); PBVAL ParseJsonFile(PGLOBAL g, char* fn, int& pty, size_t& len);
char *MakeResult(UDF_ARGS* args, PBVAL top, uint n = 2); char *MakeResult(UDF_ARGS* args, PBVAL top, uint n = 2);
PBSON MakeBinResult(PGLOBAL g, UDF_ARGS* args, PBVAL top, ulong len, int n = 2); PBSON MakeBinResult(UDF_ARGS* args, PBVAL top, ulong len, int n = 2);
protected: protected:
my_bool SetArrayOptions(PGLOBAL g, char* p, int i, PSZ nm); my_bool SetArrayOptions(PGLOBAL g, char* p, int i, PSZ nm);
...@@ -126,6 +126,11 @@ class BJNX : public BDOC { ...@@ -126,6 +126,11 @@ class BJNX : public BDOC {
PVAL MakeJson(PGLOBAL g, PBVAL bvp); PVAL MakeJson(PGLOBAL g, PBVAL bvp);
void SetJsonValue(PGLOBAL g, PVAL vp, PBVAL vlp); void SetJsonValue(PGLOBAL g, PVAL vp, PBVAL vlp);
PBVAL GetRow(PGLOBAL g); PBVAL GetRow(PGLOBAL g);
PBVAL MoveVal(PBVAL vlp);
PBVAL MoveJson(PBJNX bxp, PBVAL jvp);
PBVAL MoveArray(PBJNX bxp, PBVAL jvp);
PBVAL MoveObject(PBJNX bxp, PBVAL jvp);
PBVAL MoveValue(PBJNX bxp, PBVAL jvp);
my_bool CompareValues(PGLOBAL g, PBVAL v1, PBVAL v2); my_bool CompareValues(PGLOBAL g, PBVAL v1, PBVAL v2);
my_bool LocateArray(PGLOBAL g, PBVAL jarp); my_bool LocateArray(PGLOBAL g, PBVAL jarp);
my_bool LocateObject(PGLOBAL g, PBVAL jobp); my_bool LocateObject(PGLOBAL g, PBVAL jobp);
...@@ -368,6 +373,10 @@ extern "C" { ...@@ -368,6 +373,10 @@ extern "C" {
DllExport char *bbin_get_item(UDF_EXEC_ARGS); DllExport char *bbin_get_item(UDF_EXEC_ARGS);
DllExport void bbin_get_item_deinit(UDF_INIT*); DllExport void bbin_get_item_deinit(UDF_INIT*);
DllExport my_bool bbin_item_merge_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* bbin_item_merge(UDF_EXEC_ARGS);
DllExport void bbin_item_merge_deinit(UDF_INIT*);
DllExport my_bool bbin_set_item_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool bbin_set_item_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *bbin_set_item(UDF_EXEC_ARGS); DllExport char *bbin_set_item(UDF_EXEC_ARGS);
DllExport void bbin_set_item_deinit(UDF_INIT*); DllExport void bbin_set_item_deinit(UDF_INIT*);
......
This diff is collapsed.
--disable_query_log
#
# Check if server has support for loading plugins
#
if (`SELECT @@have_dynamic_loading != 'YES'`) {
--skip UDF requires dynamic loading
}
if (!$HA_CONNECT_SO) {
--skip Needs a dynamically built ha_connect.so
}
--eval CREATE FUNCTION bson_test RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bsonvalue RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_make_array RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_array_add_values RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_array_add RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_array_delete RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_make_object RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_object_nonull RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_object_key RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_object_add RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_object_delete RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_object_list RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_object_values RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bsonset_grp_size RETURNS INTEGER SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bsonget_grp_size RETURNS INTEGER SONAME '$HA_CONNECT_SO';
--eval CREATE AGGREGATE FUNCTION bson_array_grp RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE AGGREGATE FUNCTION bson_object_grp RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bsonlocate RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_locate_all RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_contains RETURNS INTEGER SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bsoncontains_path RETURNS INTEGER SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_item_merge RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_get_item RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_delete_item RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bsonget_string RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bsonget_int RETURNS INTEGER SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bsonget_real RETURNS REAL SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_set_item RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_insert_item RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_update_item RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_file RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bson_serialize RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bfile_make RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bfile_convert RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bfile_bjson RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_make_array RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_array_add RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_array_add_values RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_array_delete RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE AGGREGATE FUNCTION bbin_array_grp RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE AGGREGATE FUNCTION bbin_object_grp RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_make_object RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_object_nonull RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_object_key RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_object_add RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_object_delete RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_object_list RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_object_values RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_get_item RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_item_merge RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_set_item RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_insert_item RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_update_item RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_delete_item RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_locate_all RETURNS STRING SONAME '$HA_CONNECT_SO';
--eval CREATE FUNCTION bbin_file RETURNS STRING SONAME '$HA_CONNECT_SO';
--enable_query_log
This diff is collapsed.
--disable_query_log
DROP FUNCTION bson_test;
DROP FUNCTION bsonvalue;
DROP FUNCTION bson_make_array;
DROP FUNCTION bson_array_add_values;
DROP FUNCTION bson_array_add;
DROP FUNCTION bson_array_delete;
DROP FUNCTION bson_make_object;
DROP FUNCTION bson_object_nonull;
DROP FUNCTION bson_object_key;
DROP FUNCTION bson_object_add;
DROP FUNCTION bson_object_delete;
DROP FUNCTION bson_object_list;
DROP FUNCTION bson_object_values;
DROP FUNCTION bsonset_grp_size;
DROP FUNCTION bsonget_grp_size;
DROP FUNCTION bson_array_grp;
DROP FUNCTION bson_object_grp;
DROP FUNCTION bsonlocate;
DROP FUNCTION bson_locate_all;
DROP FUNCTION bson_contains;
DROP FUNCTION bsoncontains_path;
DROP FUNCTION bson_item_merge;
DROP FUNCTION bson_get_item;
DROP FUNCTION bson_delete_item;
DROP FUNCTION bsonget_string;
DROP FUNCTION bsonget_int;
DROP FUNCTION bsonget_real;
DROP FUNCTION bson_set_item;
DROP FUNCTION bson_insert_item;
DROP FUNCTION bson_update_item;
DROP FUNCTION bson_serialize;
DROP FUNCTION bson_file;
DROP FUNCTION bfile_make;
DROP FUNCTION bfile_convert;
DROP FUNCTION bfile_bjson;
DROP FUNCTION bbin_make_array;
DROP FUNCTION bbin_array_add;
DROP FUNCTION bbin_array_add_values;
DROP FUNCTION bbin_array_delete;
DROP FUNCTION bbin_array_grp;
DROP FUNCTION bbin_object_grp;
DROP FUNCTION bbin_make_object;
DROP FUNCTION bbin_object_nonull;
DROP FUNCTION bbin_object_key;
DROP FUNCTION bbin_object_add;
DROP FUNCTION bbin_object_delete;
DROP FUNCTION bbin_object_list;
DROP FUNCTION bbin_object_values;
DROP FUNCTION bbin_get_item;
DROP FUNCTION bbin_set_item;
DROP FUNCTION bbin_insert_item;
DROP FUNCTION bbin_update_item;
DROP FUNCTION bbin_item_merge;
DROP FUNCTION bbin_delete_item;
DROP FUNCTION bbin_locate_all;
DROP FUNCTION bbin_file;
--enable_query_log
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