Skip to content

Commit 0ec8929

Browse files
committed
Remove warning on Linux
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
1 parent 8a860fd commit 0ec8929

File tree

13 files changed

+1285
-288
lines changed

13 files changed

+1285
-288
lines changed

storage/connect/filamzip.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1404,8 +1404,13 @@ void ZLBFAM::Rewind(void)
14041404
// We must be positioned after the header block
14051405
if (CurBlk >= 0) { // Nothing to do if no block read yet
14061406
if (!Optimized) { // If optimized, fseek will be done in ReadBuffer
1407+
size_t st;
1408+
14071409
rewind(Stream);
1408-
(void) fread(Zlenp, sizeof(int), 1, Stream);
1410+
1411+
if (!(st = fread(Zlenp, sizeof(int), 1, Stream)) && trace)
1412+
htrc("fread error %d in Rewind", errno);
1413+
14091414
fseek(Stream, *Zlenp + sizeof(int), SEEK_SET);
14101415
OldBlk = -1;
14111416
} // endif Optimized

storage/connect/json.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,10 +1096,12 @@ PJVAL JARRAY::AddValue(PGLOBAL g, PJVAL jvp, int *x)
10961096
Last = jvp;
10971097

10981098
} else {
1099-
if (Last)
1100-
Last->Next = jvp;
1101-
else
1099+
if (!First)
11021100
First = jvp;
1101+
else if (Last == First)
1102+
First->Next = Last = jvp;
1103+
else
1104+
Last->Next = jvp;
11031105

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

12851287
void JVALUE::SetValue(PJSON jsp)
12861288
{
1287-
if (jsp->GetType() == TYPE_JVAL) {
1289+
if (jsp && jsp->GetType() == TYPE_JVAL) {
12881290
Jsp = jsp->GetJsp();
12891291
Value = jsp->GetValue();
12901292
} else {

storage/connect/json.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class JSON : public BLOCK {
149149
virtual JTYP GetType(void) {return TYPE_JSON;}
150150
virtual JTYP GetValType(void) {X return TYPE_JSON;}
151151
virtual void InitArray(PGLOBAL g) {X}
152-
virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;}
152+
//virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;}
153153
virtual PJPR AddPair(PGLOBAL g, PSZ key) {X return NULL;}
154154
virtual PJAR GetKeyList(PGLOBAL g) {X return NULL;}
155155
virtual PJVAL GetValue(const char *key) {X return NULL;}
@@ -223,7 +223,7 @@ class JARRAY : public JSON {
223223
virtual void Clear(void) {First = Last = NULL; Size = 0;}
224224
virtual JTYP GetType(void) {return TYPE_JAR;}
225225
virtual PJAR GetArray(void) {return this;}
226-
virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL);
226+
PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL);
227227
virtual void InitArray(PGLOBAL g);
228228
virtual PJVAL GetValue(int i);
229229
virtual bool Merge(PGLOBAL g, PJSON jsp);

0 commit comments

Comments
 (0)