diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2015-02-24 23:18:04 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2015-02-24 23:18:04 +0100 |
commit | e027f5e8d5d966f11d7f38825a8e316ff9d4dd79 (patch) | |
tree | 281e8cf30fdbf406683eafd6e50369d56de1500d /storage/connect/json.cpp | |
parent | a736e63f7c494b0611a27a8951bf8fe0980cbaad (diff) | |
download | mariadb-git-e027f5e8d5d966f11d7f38825a8e316ff9d4dd79.tar.gz |
- Fix MDEV-7616 by adding SQLCOM_SET_OPTION to the accepted command list.
modified:
storage/connect/ha_connect.cc
- Add new JSON UDF functions and JSON functionalities.
modified:
storage/connect/json.cpp
storage/connect/json.h
storage/connect/jsonudf.cpp
storage/connect/tabjson.cpp
Diffstat (limited to 'storage/connect/json.cpp')
-rw-r--r-- | storage/connect/json.cpp | 82 |
1 files changed, 66 insertions, 16 deletions
diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp index 8031ba51b19..7356a86d53c 100644 --- a/storage/connect/json.cpp +++ b/storage/connect/json.cpp @@ -881,27 +881,26 @@ PJVAL JOBJECT::GetValue(const char* key) /***********************************************************************/ /* Return the text corresponding to all keys (XML like). */ /***********************************************************************/ -PSZ JOBJECT::GetText(PGLOBAL g) +PSZ JOBJECT::GetText(PGLOBAL g, PSZ text) { - char *p, *text = (char*)PlugSubAlloc(g, NULL, 0); - bool b = true; + int n; - if (!First) - return NULL; - else for (PJPR jp = First; jp; jp = jp->Next) { - if (!(p = jp->Val->GetString())) - p = "???"; + if (!text) { + text = (char*)PlugSubAlloc(g, NULL, 0); + text[0] = 0; + n = 1; + } else + n = 0; - if (b) { - strcpy(text, p); - b = false; - } else - strcat(strcat(text, " "), p); + if (!First && n) + return NULL; + else for (PJPR jp = First; jp; jp = jp->Next) + jp->Val->GetText(g, text); - } // endfor jp + if (n) + PlugSubAlloc(g, NULL, strlen(text) + 1); - PlugSubAlloc(g, NULL, strlen(text) + 1); - return text; + return text + n; } // end of GetValue; /***********************************************************************/ @@ -924,6 +923,18 @@ void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PSZ key) } // end of SetValue +/***********************************************************************/ +/* True if void or if all members are nulls. */ +/***********************************************************************/ +bool JOBJECT::IsNull(void) +{ + for (PJPR jp = First; jp; jp = jp->Next) + if (!jp->Val->IsNull()) + return false; + + return true; +} // end of IsNull + /* -------------------------- Class JARRAY --------------------------- */ /***********************************************************************/ @@ -1012,6 +1023,18 @@ bool JARRAY::DeleteValue(int n) } // end of DeleteValue +/***********************************************************************/ +/* True if void or if all members are nulls. */ +/***********************************************************************/ +bool JARRAY::IsNull(void) +{ + for (int i = 0; i < Size; i++) + if (!Mvals[i]->IsNull()) + return false; + + return true; +} // end of IsNull + /* -------------------------- Class JVALUE- -------------------------- */ /***********************************************************************/ @@ -1087,6 +1110,25 @@ PSZ JVALUE::GetString(void) } // end of GetString /***********************************************************************/ +/* Return the Value's String value. */ +/***********************************************************************/ +PSZ JVALUE::GetText(PGLOBAL g, PSZ text) +{ + if (Jsp && Jsp->GetType() == TYPE_JOB) + return Jsp->GetText(g, text); + + char buf[32]; + PSZ s = (Value) ? Value->GetCharString(buf) : NULL; + + if (s) + strcat(strcat(text, " "), s); + else + strcat(text, " ???"); + + return text; +} // end of GetText + +/***********************************************************************/ /* Set the Value's value as the given integer. */ /***********************************************************************/ void JVALUE::SetInteger(PGLOBAL g, int n) @@ -1110,3 +1152,11 @@ void JVALUE::SetString(PGLOBAL g, PSZ s) Value = AllocateValue(g, s, TYPE_STRING); } // end of AddFloat +/***********************************************************************/ +/* True when its JSON or normal value is null. */ +/***********************************************************************/ +bool JVALUE::IsNull(void) +{ + return (Jsp) ? Jsp->IsNull() : (Value) ? Value->IsNull() : true; +} // end of IsNull + |