Skip to content

Commit

Permalink
- Remove static linkage to cpprestsdk when it is installed
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
Buggynours committed Jan 12, 2021
1 parent 70cfeb9 commit 347bce0
Show file tree
Hide file tree
Showing 9 changed files with 1,327 additions and 72 deletions.
40 changes: 20 additions & 20 deletions storage/connect/CMakeLists.txt
Expand Up @@ -334,26 +334,26 @@ IF(CONNECT_WITH_REST)
# MESSAGE(STATUS "=====> REST support is ON")
SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp tabrest.h)
add_definitions(-DREST_SUPPORT)
FIND_PACKAGE(cpprestsdk QUIET)
IF (cpprestsdk_FOUND)
IF(UNIX)
# INCLUDE_DIRECTORIES(${CPPRESTSDK_INCLUDE_DIR})
# If needed edit next line to set the path to libcpprest.so
SET(REST_LIBRARY -lcpprest)
MESSAGE (STATUS ${REST_LIBRARY})
ELSE(NOT UNIX)
# Next line sets debug compile mode matching cpprest_2_10d.dll
# when it was binary installed (can be change later in Visual Studio)
# Comment it out if not needed depending on your cpprestsdk installation.
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
ENDIF(UNIX)
# IF(REST_LIBRARY) why this? how about Windows
SET(CONNECT_SOURCES ${CONNECT_SOURCES} restget.cpp)
add_definitions(-DREST_SOURCE)
# ENDIF()
# ELSE(NOT cpprestsdk_FOUND)
# MESSAGE(STATUS "=====> cpprestsdk package not found")
ENDIF (cpprestsdk_FOUND)
# FIND_PACKAGE(cpprestsdk QUIET)
# IF (cpprestsdk_FOUND)
# IF(UNIX)
## INCLUDE_DIRECTORIES(${CPPRESTSDK_INCLUDE_DIR})
## If needed edit next line to set the path to libcpprest.so
# SET(REST_LIBRARY -lcpprest)
# MESSAGE (STATUS ${REST_LIBRARY})
# ELSE(NOT UNIX)
## Next line sets debug compile mode matching cpprest_2_10d.dll
## when it was binary installed (can be change later in Visual Studio)
## Comment it out if not needed depending on your cpprestsdk installation.
# SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
# ENDIF(UNIX)
## IF(REST_LIBRARY) why this? how about Windows
# SET(CONNECT_SOURCES ${CONNECT_SOURCES} restget.cpp)
# add_definitions(-DREST_SOURCE)
## ENDIF()
##ELSE(NOT cpprestsdk_FOUND)
## MESSAGE(STATUS "=====> cpprestsdk package not found")
# ENDIF (cpprestsdk_FOUND)
ENDIF(CONNECT_WITH_REST)

#
Expand Down
20 changes: 14 additions & 6 deletions storage/connect/bson.cpp
Expand Up @@ -631,7 +631,7 @@ PSZ BDOC::Serialize(PGLOBAL g, PBVAL bvp, char* fn, int pretty)
err = SerializeValue(MVP(bvp->To_Val));
break;
default:
err = SerializeValue(bvp);
err = SerializeValue(bvp, true);
} // endswitch Type

if (fs) {
Expand Down Expand Up @@ -737,7 +737,7 @@ bool BDOC::SerializeObject(OFFSET obp)
/***********************************************************************/
/* Serialize a JSON Value. */
/***********************************************************************/
bool BDOC::SerializeValue(PBVAL jvp)
bool BDOC::SerializeValue(PBVAL jvp, bool b)
{
char buf[64];

Expand All @@ -750,7 +750,11 @@ bool BDOC::SerializeValue(PBVAL jvp)
return jp->WriteStr(jvp->B ? "true" : "false");
case TYPE_STRG:
case TYPE_DTM:
return jp->Escape(MZP(jvp->To_Val));
if (b) {
return jp->WriteStr(MZP(jvp->To_Val));
} else
return jp->Escape(MZP(jvp->To_Val));

case TYPE_INTG:
sprintf(buf, "%d", jvp->N);
return jp->WriteStr(buf);
Expand Down Expand Up @@ -1505,8 +1509,12 @@ double BJSON::GetDouble(PBVAL vp)
d = (double)vlp->N;
break;
case TYPE_FLOAT:
d = (double)vlp->F;
break;
{ char buf[32];
int n = (vlp->Nd) ? vlp->Nd : 5;

sprintf(buf, "%.*f", n, vlp->F);
d = atof(buf);
} break;
case TYPE_DTM:
case TYPE_STRG:
d = atof(MZP(vlp->To_Val));
Expand Down Expand Up @@ -1632,7 +1640,7 @@ PBVAL BJSON::SetValue(PBVAL vlp, PVAL valp)
{ double d = valp->GetFloatValue();
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->Type = TYPE_FLOAT;
} else {
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/bson.h
Expand Up @@ -193,7 +193,7 @@ class BDOC : public BJSON {
OFFSET ParseAsArray(int& i);
bool SerializeArray(OFFSET arp, bool b);
bool SerializeObject(OFFSET obp);
bool SerializeValue(PBVAL vp);
bool SerializeValue(PBVAL vp, bool b = false);

// Members used when parsing and serializing
JOUT* jp; // Used with serialize
Expand Down

0 comments on commit 347bce0

Please sign in to comment.