summaryrefslogtreecommitdiff
path: root/storage/connect/json.cpp
diff options
context:
space:
mode:
authorNikita Malyavin <nikitamalyavin@gmail.com>2021-05-05 23:17:20 +0300
committerNikita Malyavin <nikitamalyavin@gmail.com>2021-05-05 23:57:11 +0300
commit3f55c569514679d98e09e71286ca28a8ac667a71 (patch)
tree4347fbb2238d1a97e5e1166f9e7b7b7adba165ce /storage/connect/json.cpp
parentca1dc0789b7e724128d1369977e2f70fb9d69bb5 (diff)
parenta4139f8d68bd31e80ff6202c093cd232c194ddfd (diff)
downloadmariadb-git-mariadb-10.5.10.tar.gz
Merge branch bb-10.4-release into bb-10.5-releasemariadb-10.5.10
Diffstat (limited to 'storage/connect/json.cpp')
-rw-r--r--storage/connect/json.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp
index bd9c4fac7a1..e9925ee959a 100644
--- a/storage/connect/json.cpp
+++ b/storage/connect/json.cpp
@@ -54,15 +54,24 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e);
#endif // SE_CATCH
char *GetJsonNull(void);
+int GetDefaultPrec(void);
/***********************************************************************/
/* IsNum: check whether this string is all digits. */
/***********************************************************************/
-bool IsNum(PSZ s) {
- for (char* p = s; *p; p++)
+bool IsNum(PSZ s)
+{
+ char* p = s;
+
+ if (*p == '-')
+ p++;
+
+ if (*p == ']')
+ return false;
+ else for (; *p; p++)
if (*p == ']')
break;
- else if (!isdigit(*p) || *p == '-')
+ else if (!isdigit(*p))
return false;
return true;
@@ -1257,6 +1266,8 @@ PJVAL JARRAY::GetArrayValue(int i)
{
if (Mvals && i >= 0 && i < Size)
return Mvals[i];
+ else if (Mvals && i < 0 && i >= -Size)
+ return Mvals[Size + i];
else
return NULL;
} // end of GetValue
@@ -1752,7 +1763,7 @@ void JVALUE::SetBigint(PGLOBAL g, long long ll)
void JVALUE::SetFloat(PGLOBAL g, double f)
{
F = f;
- Nd = 6;
+ Nd = GetDefaultPrec();
DataType = TYPE_DBL;
} // end of SetFloat