Skip to content

Commit

Permalink
Remove warning on Linux
Browse files Browse the repository at this point in the history
  modified:   storage/connect/filamzip.cpp

Avoid calling the wrong AddValue (Windows compiler error ???)
  modified:   storage/connect/json.h

Fix looping bug in JARRAY::AddValue for arrays having one value.
Fix potential crash in JVALUE::SetValue
  modified:   storage/connect/json.cpp

Many changes to fix bugs, enhance memory handling and modify Jpath.
In JSNX some functions have been re-written or added to handle new Jpath.
BMX was re-defined to avoid a different size between Windows an Linux.
Jbin memory was fixed to use the proper memory when adding values.
Default pretty value is now 0 instead of 2.
Filename is stored in BSON when IsJson == 2.
BSON size is added to memlen in CalcLen when applicable.
The order or parameter was switch in Json_Object_Grp.
File name argument must be a constant (temporary?)
Json_Set_Item now returns file name when applicable.
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/jsonudf.h

Include "mycat.h"
  modified:   storage/connect/mycat.cc

Udf_json test revisited and fixed for Linux
  modified:   storage/connect/mysql-test/connect/r/json_udf.result
  modified:   storage/connect/mysql-test/connect/t/json_udf.inc
  modified:   storage/connect/mysql-test/connect/t/json_udf.test
  modified:   storage/connect/mysql-test/connect/t/json_udf2.inc
  • Loading branch information
Buggynours committed Dec 4, 2015
1 parent 8a860fd commit 0ec8929
Show file tree
Hide file tree
Showing 13 changed files with 1,285 additions and 288 deletions.
7 changes: 6 additions & 1 deletion storage/connect/filamzip.cpp
Expand Up @@ -1404,8 +1404,13 @@ void ZLBFAM::Rewind(void)
// We must be positioned after the header block
if (CurBlk >= 0) { // Nothing to do if no block read yet
if (!Optimized) { // If optimized, fseek will be done in ReadBuffer
size_t st;

rewind(Stream);
(void) fread(Zlenp, sizeof(int), 1, Stream);

if (!(st = fread(Zlenp, sizeof(int), 1, Stream)) && trace)
htrc("fread error %d in Rewind", errno);

fseek(Stream, *Zlenp + sizeof(int), SEEK_SET);
OldBlk = -1;
} // endif Optimized
Expand Down
10 changes: 6 additions & 4 deletions storage/connect/json.cpp
Expand Up @@ -1096,10 +1096,12 @@ PJVAL JARRAY::AddValue(PGLOBAL g, PJVAL jvp, int *x)
Last = jvp;

} else {
if (Last)
Last->Next = jvp;
else
if (!First)
First = jvp;
else if (Last == First)
First->Next = Last = jvp;
else
Last->Next = jvp;

Last = jvp;
} // endif x
Expand Down Expand Up @@ -1284,7 +1286,7 @@ PSZ JVALUE::GetText(PGLOBAL g, PSZ text)

void JVALUE::SetValue(PJSON jsp)
{
if (jsp->GetType() == TYPE_JVAL) {
if (jsp && jsp->GetType() == TYPE_JVAL) {
Jsp = jsp->GetJsp();
Value = jsp->GetValue();
} else {
Expand Down
4 changes: 2 additions & 2 deletions storage/connect/json.h
Expand Up @@ -149,7 +149,7 @@ class JSON : public BLOCK {
virtual JTYP GetType(void) {return TYPE_JSON;}
virtual JTYP GetValType(void) {X return TYPE_JSON;}
virtual void InitArray(PGLOBAL g) {X}
virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;}
//virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;}
virtual PJPR AddPair(PGLOBAL g, PSZ key) {X return NULL;}
virtual PJAR GetKeyList(PGLOBAL g) {X return NULL;}
virtual PJVAL GetValue(const char *key) {X return NULL;}
Expand Down Expand Up @@ -223,7 +223,7 @@ class JARRAY : public JSON {
virtual void Clear(void) {First = Last = NULL; Size = 0;}
virtual JTYP GetType(void) {return TYPE_JAR;}
virtual PJAR GetArray(void) {return this;}
virtual 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 PJVAL GetValue(int i);
virtual bool Merge(PGLOBAL g, PJSON jsp);
Expand Down

0 comments on commit 0ec8929

Please sign in to comment.