Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
9a07f30b
Commit
9a07f30b
authored
Jan 20, 2021
by
Olivier Bertrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some Json and Bson bugs
parent
1d627ce4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
6 deletions
+29
-6
storage/connect/tabbson.cpp
storage/connect/tabbson.cpp
+14
-2
storage/connect/tabbson.h
storage/connect/tabbson.h
+1
-0
storage/connect/tabjson.cpp
storage/connect/tabjson.cpp
+10
-2
storage/connect/tabjson.h
storage/connect/tabjson.h
+4
-2
No files found.
storage/connect/tabbson.cpp
View file @
9a07f30b
...
@@ -784,6 +784,12 @@ PVAL BCUTIL::MakeBson(PGLOBAL g, PBVAL jsp)
...
@@ -784,6 +784,12 @@ PVAL BCUTIL::MakeBson(PGLOBAL g, PBVAL jsp)
{
{
if
(
Cp
->
Value
->
IsTypeNum
())
{
if
(
Cp
->
Value
->
IsTypeNum
())
{
strcpy
(
g
->
Message
,
"Cannot make Json for a numeric column"
);
strcpy
(
g
->
Message
,
"Cannot make Json for a numeric column"
);
if
(
!
Cp
->
Warned
)
{
PushWarning
(
g
,
Tp
);
Cp
->
Warned
=
true
;
}
// endif Warned
Cp
->
Value
->
Reset
();
Cp
->
Value
->
Reset
();
#if 0
#if 0
} else if (Value->GetType() == TYPE_BIN) {
} else if (Value->GetType() == TYPE_BIN) {
...
@@ -1635,6 +1641,7 @@ BSONCOL::BSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
...
@@ -1635,6 +1641,7 @@ BSONCOL::BSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
Xnod
=
-
1
;
Xnod
=
-
1
;
Xpd
=
false
;
Xpd
=
false
;
Parsed
=
false
;
Parsed
=
false
;
Warned
=
false
;
}
// end of BSONCOL constructor
}
// end of BSONCOL constructor
/***********************************************************************/
/***********************************************************************/
...
@@ -1653,6 +1660,7 @@ BSONCOL::BSONCOL(BSONCOL* col1, PTDB tdbp) : DOSCOL(col1, tdbp)
...
@@ -1653,6 +1660,7 @@ BSONCOL::BSONCOL(BSONCOL* col1, PTDB tdbp) : DOSCOL(col1, tdbp)
Xnod
=
col1
->
Xnod
;
Xnod
=
col1
->
Xnod
;
Xpd
=
col1
->
Xpd
;
Xpd
=
col1
->
Xpd
;
Parsed
=
col1
->
Parsed
;
Parsed
=
col1
->
Parsed
;
Warned
=
col1
->
Warned
;
}
// end of BSONCOL copy constructor
}
// end of BSONCOL copy constructor
/***********************************************************************/
/***********************************************************************/
...
@@ -1986,8 +1994,10 @@ void BSONCOL::ReadColumn(PGLOBAL g)
...
@@ -1986,8 +1994,10 @@ void BSONCOL::ReadColumn(PGLOBAL g)
if
(
!
Tbp
->
SameRow
||
Xnod
>=
Tbp
->
SameRow
)
if
(
!
Tbp
->
SameRow
||
Xnod
>=
Tbp
->
SameRow
)
Value
->
SetValue_pval
(
Cp
->
GetColumnValue
(
g
,
Tbp
->
Row
,
0
));
Value
->
SetValue_pval
(
Cp
->
GetColumnValue
(
g
,
Tbp
->
Row
,
0
));
#if defined(DEVELOPMENT)
if
(
Xpd
&&
Value
->
IsNull
()
&&
!
((
PBDEF
)
Tbp
->
To_Def
)
->
Accept
)
if
(
Xpd
&&
Value
->
IsNull
()
&&
!
((
PBDEF
)
Tbp
->
To_Def
)
->
Accept
)
throw
(
"Null expandable JSON value"
);
htrc
(
"Null expandable JSON value for column %s
\n
"
,
Name
);
#endif // DEVELOPMENT
// Set null when applicable
// Set null when applicable
if
(
!
Nullable
)
if
(
!
Nullable
)
...
@@ -2274,8 +2284,10 @@ int TDBBSON::MakeDocument(PGLOBAL g)
...
@@ -2274,8 +2284,10 @@ int TDBBSON::MakeDocument(PGLOBAL g)
Docp
=
Bp
->
NewVal
(
TYPE_JAR
);
Docp
=
Bp
->
NewVal
(
TYPE_JAR
);
Bp
->
AddArrayValue
(
Docp
,
jsp
);
Bp
->
AddArrayValue
(
Docp
,
jsp
);
Bp
->
SetArrayValue
(
arp
,
Docp
,
i
);
Bp
->
SetArrayValue
(
arp
,
Docp
,
i
);
}
else
}
else
{
Top
=
Docp
=
Bp
->
NewVal
(
TYPE_JAR
);
Top
=
Docp
=
Bp
->
NewVal
(
TYPE_JAR
);
Bp
->
AddArrayValue
(
Docp
,
jsp
);
}
// endif's
}
// endif jsp
}
// endif jsp
...
...
storage/connect/tabbson.h
View file @
9a07f30b
...
@@ -265,6 +265,7 @@ class DllExport BSONCOL : public DOSCOL {
...
@@ -265,6 +265,7 @@ class DllExport BSONCOL : public DOSCOL {
char
Sep
;
// The Jpath separator
char
Sep
;
// The Jpath separator
bool
Xpd
;
// True for expandable column
bool
Xpd
;
// True for expandable column
bool
Parsed
;
// True when parsed
bool
Parsed
;
// True when parsed
bool
Warned
;
// True when warning issued
};
// end of class BSONCOL
};
// end of class BSONCOL
/* -------------------------- TDBBSON class -------------------------- */
/* -------------------------- TDBBSON class -------------------------- */
...
...
storage/connect/tabjson.cpp
View file @
9a07f30b
...
@@ -1255,6 +1255,7 @@ JSONCOL::JSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
...
@@ -1255,6 +1255,7 @@ JSONCOL::JSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
Xnod
=
-
1
;
Xnod
=
-
1
;
Xpd
=
false
;
Xpd
=
false
;
Parsed
=
false
;
Parsed
=
false
;
Warned
=
false
;
}
// end of JSONCOL constructor
}
// end of JSONCOL constructor
/***********************************************************************/
/***********************************************************************/
...
@@ -1273,6 +1274,7 @@ JSONCOL::JSONCOL(JSONCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
...
@@ -1273,6 +1274,7 @@ JSONCOL::JSONCOL(JSONCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
Xnod
=
col1
->
Xnod
;
Xnod
=
col1
->
Xnod
;
Xpd
=
col1
->
Xpd
;
Xpd
=
col1
->
Xpd
;
Parsed
=
col1
->
Parsed
;
Parsed
=
col1
->
Parsed
;
Warned
=
col1
->
Warned
;
}
// end of JSONCOL copy constructor
}
// end of JSONCOL copy constructor
/***********************************************************************/
/***********************************************************************/
...
@@ -1606,6 +1608,12 @@ PVAL JSONCOL::MakeJson(PGLOBAL g, PJSON jsp)
...
@@ -1606,6 +1608,12 @@ PVAL JSONCOL::MakeJson(PGLOBAL g, PJSON jsp)
{
{
if
(
Value
->
IsTypeNum
())
{
if
(
Value
->
IsTypeNum
())
{
strcpy
(
g
->
Message
,
"Cannot make Json for a numeric column"
);
strcpy
(
g
->
Message
,
"Cannot make Json for a numeric column"
);
if
(
!
Warned
)
{
PushWarning
(
g
,
Tjp
);
Warned
=
true
;
}
// endif Warned
Value
->
Reset
();
Value
->
Reset
();
#if 0
#if 0
} else if (Value->GetType() == TYPE_BIN) {
} else if (Value->GetType() == TYPE_BIN) {
...
@@ -1703,8 +1711,8 @@ void JSONCOL::ReadColumn(PGLOBAL g)
...
@@ -1703,8 +1711,8 @@ void JSONCOL::ReadColumn(PGLOBAL g)
if
(
!
Tjp
->
SameRow
||
Xnod
>=
Tjp
->
SameRow
)
if
(
!
Tjp
->
SameRow
||
Xnod
>=
Tjp
->
SameRow
)
Value
->
SetValue_pval
(
GetColumnValue
(
g
,
Tjp
->
Row
,
0
));
Value
->
SetValue_pval
(
GetColumnValue
(
g
,
Tjp
->
Row
,
0
));
if
(
Xpd
&&
Value
->
IsNull
()
&&
!
((
PJDEF
)
Tjp
->
To_Def
)
->
Accept
)
//
if (Xpd && Value->IsNull() && !((PJDEF)Tjp->To_Def)->Accept)
throw
(
"Null expandable JSON value"
);
//
throw("Null expandable JSON value");
// Set null when applicable
// Set null when applicable
if
(
!
Nullable
)
if
(
!
Nullable
)
...
...
storage/connect/tabjson.h
View file @
9a07f30b
...
@@ -192,7 +192,8 @@ class DllExport TDBJSN : public TDBDOS {
...
@@ -192,7 +192,8 @@ class DllExport TDBJSN : public TDBDOS {
char
Sep
;
// The Jpath separator
char
Sep
;
// The Jpath separator
bool
Strict
;
// Strict syntax checking
bool
Strict
;
// Strict syntax checking
bool
Comma
;
// Row has final comma
bool
Comma
;
// Row has final comma
};
// end of class TDBJSN
bool
Xpdable
;
// False: expandable columns are NULL
};
// end of class TDBJSN
/* -------------------------- JSONCOL class -------------------------- */
/* -------------------------- JSONCOL class -------------------------- */
...
@@ -247,7 +248,8 @@ class DllExport JSONCOL : public DOSCOL {
...
@@ -247,7 +248,8 @@ class DllExport JSONCOL : public DOSCOL {
char
Sep
;
// The Jpath separator
char
Sep
;
// The Jpath separator
bool
Xpd
;
// True for expandable column
bool
Xpd
;
// True for expandable column
bool
Parsed
;
// True when parsed
bool
Parsed
;
// True when parsed
};
// end of class JSONCOL
bool
Warned
;
// True when warning issued
};
// end of class JSONCOL
/* -------------------------- TDBJSON class -------------------------- */
/* -------------------------- TDBJSON class -------------------------- */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment