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
a3542482
Commit
a3542482
authored
Dec 26, 2020
by
Olivier Bertrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Continue BSON implementation + fix create modified ha_connect.cc
parent
2113cab7
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
132 additions
and
125 deletions
+132
-125
storage/connect/bson.cpp
storage/connect/bson.cpp
+90
-84
storage/connect/bson.h
storage/connect/bson.h
+15
-13
storage/connect/bsonudf.cpp
storage/connect/bsonudf.cpp
+4
-4
storage/connect/ha_connect.cc
storage/connect/ha_connect.cc
+4
-4
storage/connect/tabbson.cpp
storage/connect/tabbson.cpp
+19
-20
No files found.
storage/connect/bson.cpp
View file @
a3542482
This diff is collapsed.
Click to expand it.
storage/connect/bson.h
View file @
a3542482
...
...
@@ -37,7 +37,8 @@ typedef struct _jvalue {
bool
B
;
// A boolean value True or false (0)
};
short
Nd
;
// Number of decimals
short
Type
;
// The value type
char
Type
;
// The value type
char
Ktp
;
// The key type
OFFSET
Next
;
// Offset to the next value in array
}
BVAL
,
*
PBVAL
;
// end of struct BVALUE
...
...
@@ -46,13 +47,12 @@ typedef struct _jvalue {
/***********************************************************************/
typedef
struct
_jpair
{
OFFSET
Key
;
// Offset to this pair key name
OFFSET
Vlp
;
// To the value of the pair
OFFSET
Next
;
// Offset to the next pair in object
BVAL
Vlp
;
// The value of the pair
}
BPAIR
,
*
PBPR
;
// end of struct BPAIR
char
*
NextChr
(
PSZ
s
,
char
sep
);
char
*
GetJsonNull
(
void
);
const
char
*
GetFmt
(
int
type
,
bool
un
);
const
char
*
GetFmt
(
int
type
,
bool
un
);
DllExport
bool
IsNum
(
PSZ
s
);
...
...
@@ -81,9 +81,9 @@ class BJSON : public BLOCK {
// SubAlloc functions
void
*
BsonSubAlloc
(
size_t
size
);
PBPR
SubAllocPair
(
OFFSET
key
,
OFFSET
val
=
0
);
OFFSET
NewPair
(
PSZ
key
,
OFFSET
val
=
0
)
{
return
MOF
(
SubAllocPair
(
DupStr
(
key
),
val
));}
PBPR
NewPair
(
OFFSET
key
,
int
type
=
TYPE_NULL
);
OFFSET
NewPair
(
PSZ
key
,
int
type
=
TYPE_NULL
)
{
return
MOF
(
NewPair
(
DupStr
(
key
),
type
));}
PBVAL
NewVal
(
int
type
=
TYPE_NULL
);
PBVAL
NewVal
(
PVAL
valp
);
PBVAL
SubAllocVal
(
OFFSET
toval
,
int
type
=
TYPE_NULL
,
short
nd
=
0
);
...
...
@@ -110,13 +110,15 @@ class BJSON : public BLOCK {
// Object functions
inline
PBPR
GetObject
(
PBVAL
bop
)
{
return
MPP
(
bop
->
To_Val
);}
inline
PBPR
GetNext
(
PBPR
brp
)
{
return
MPP
(
brp
->
Next
);
}
inline
PBPR
GetNext
(
PBPR
brp
)
{
return
MPP
(
brp
->
Vlp
.
Next
);
}
void
SetPairValue
(
PBPR
brp
,
PBVAL
bvp
);
int
GetObjectSize
(
PBVAL
bop
,
bool
b
=
false
);
PSZ
GetObjectText
(
PGLOBAL
g
,
PBVAL
bop
,
PSTRG
text
);
PBVAL
MergeObject
(
PBVAL
bop1
,
PBVAL
bop2
);
void
AddPair
(
PBVAL
bop
,
PSZ
key
,
OFFSET
val
=
0
);
PSZ
GetKey
(
PBPR
prp
)
{
return
MZP
(
prp
->
Key
);}
PBVAL
GetVal
(
PBPR
prp
)
{
return
MVP
(
prp
->
Vlp
);}
PBVAL
AddPair
(
PBVAL
bop
,
PSZ
key
,
int
type
=
TYPE_NULL
);
PSZ
GetKey
(
PBPR
prp
)
{
return
prp
?
MZP
(
prp
->
Key
)
:
NULL
;}
PBVAL
GetTo_Val
(
PBPR
prp
)
{
return
prp
?
MVP
(
prp
->
Vlp
.
To_Val
)
:
NULL
;}
PBVAL
GetVlp
(
PBPR
prp
)
{
return
prp
?
(
PBVAL
)
&
prp
->
Vlp
:
NULL
;}
PBVAL
GetKeyValue
(
PBVAL
bop
,
PSZ
key
);
PBVAL
GetKeyList
(
PBVAL
bop
);
PBVAL
GetObjectValList
(
PBVAL
bop
);
...
...
@@ -131,7 +133,7 @@ class BJSON : public BLOCK {
PBVAL
GetNext
(
PBVAL
vlp
)
{
return
MVP
(
vlp
->
Next
);}
//PJSON GetJsp(void) { return (DataType == TYPE_JSON ? Jsp : NULL); }
PSZ
GetValueText
(
PGLOBAL
g
,
PBVAL
vlp
,
PSTRG
text
);
inline
PBVAL
GetBson
(
PBVAL
bvp
)
{
return
IsJson
(
bvp
)
?
MVP
(
bvp
->
To_Val
)
:
bvp
;
}
PBVAL
GetBson
(
PBVAL
bvp
);
PSZ
GetString
(
PBVAL
vp
,
char
*
buff
=
NULL
);
int
GetInteger
(
PBVAL
vp
);
long
long
GetBigint
(
PBVAL
vp
);
...
...
@@ -178,7 +180,7 @@ class BDOC : public BJSON {
protected:
OFFSET
ParseArray
(
int
&
i
);
OFFSET
ParseObject
(
int
&
i
);
PBVAL
ParseValue
(
int
&
i
);
PBVAL
ParseValue
(
int
&
i
,
PBVAL
bvp
);
OFFSET
ParseString
(
int
&
i
);
void
ParseNumeric
(
int
&
i
,
PBVAL
bvp
);
OFFSET
ParseAsArray
(
int
&
i
);
...
...
storage/connect/bsonudf.cpp
View file @
a3542482
...
...
@@ -856,7 +856,7 @@ my_bool BJNX::LocateObject(PGLOBAL g, PBVAL jobp)
if
(
Jp
->
WriteStr
(
MZP
(
pair
->
Key
)))
return
true
;
if
(
LocateValue
(
g
,
MVP
(
pair
->
Vlp
)))
if
(
LocateValue
(
g
,
GetVlp
(
pair
)))
return
true
;
}
// endfor i
...
...
@@ -976,7 +976,7 @@ my_bool BJNX::LocateObjectAll(PGLOBAL g, PBVAL jobp)
for
(
PBPR
pair
=
GetObject
(
jobp
);
pair
;
pair
=
GetNext
(
pair
))
{
Jpnp
[
I
].
Key
=
MZP
(
pair
->
Key
);
if
(
LocateValueAll
(
g
,
MVP
(
pair
->
Vlp
)))
if
(
LocateValueAll
(
g
,
GetVlp
(
pair
)))
return
true
;
}
// endfor i
...
...
@@ -1020,8 +1020,8 @@ my_bool BJNX::CompareTree(PGLOBAL g, PBVAL jp1, PBVAL jp2)
PBPR
p1
=
GetObject
(
jp1
),
p2
=
GetObject
(
jp2
);
// Keys can be differently ordered
for
(;
found
&&
p1
&&
p2
;
p1
=
MPP
(
p1
->
Next
))
found
=
CompareValues
(
g
,
MVP
(
p1
->
Vlp
),
GetKeyValue
(
jp2
,
MZP
(
p1
->
Key
)));
for
(;
found
&&
p1
&&
p2
;
p1
=
GetNext
(
p1
))
found
=
CompareValues
(
g
,
GetVlp
(
p1
),
GetKeyValue
(
jp2
,
GetKey
(
p1
)));
}
else
if
(
jp1
->
Type
==
TYPE_JVAL
)
{
found
=
CompareTree
(
g
,
MVP
(
jp1
->
To_Val
),
(
MVP
(
jp2
->
To_Val
)));
...
...
storage/connect/ha_connect.cc
View file @
a3542482
...
...
@@ -170,7 +170,7 @@
#define JSONMAX 10 // JSON Default max grp size
extern
"C"
{
char
version
[]
=
"Version 1.07.0002 December
19
, 2020"
;
char
version
[]
=
"Version 1.07.0002 December
25
, 2020"
;
#if defined(__WIN__)
char
compver
[]
=
"Version 1.07.0002 "
__DATE__
" "
__TIME__
;
char
slash
=
'\\'
;
...
...
@@ -6440,9 +6440,9 @@ int ha_connect::create(const char *name, TABLE *table_arg,
// Check table type
if
(
type
==
TAB_UNDEF
)
{
options
->
type
=
(
options
->
srcdef
)
?
"MYSQL"
:
#if defined(
BSON
_SUPPORT)
#if defined(
REST
_SUPPORT)
(
options
->
http
)
?
"JSON"
:
#endif //
BSON
_SUPPORT
#endif //
REST
_SUPPORT
(
options
->
tabname
)
?
"PROXY"
:
"DOS"
;
type
=
GetTypeID
(
options
->
type
);
sprintf
(
g
->
Message
,
"No table_type. Will be set to %s"
,
options
->
type
);
...
...
@@ -6460,7 +6460,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
DBUG_RETURN
(
HA_ERR_INTERNAL_ERROR
);
inward
=
IsFileType
(
type
)
&&
!
options
->
filename
&&
(
type
!=
TAB_JSON
||
!
cnc
.
length
);
(
(
type
!=
TAB_JSON
&&
type
!=
TAB_BSON
)
||
!
cnc
.
length
);
if
(
options
->
data_charset
)
{
const
CHARSET_INFO
*
data_charset
;
...
...
storage/connect/tabbson.cpp
View file @
a3542482
...
...
@@ -342,7 +342,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
strncpy
(
colname
,
bp
->
GetKey
(
jpp
),
64
);
fmt
[
bf
]
=
0
;
if
(
Find
(
g
,
bp
->
GetV
al
(
jpp
),
colname
,
MY_MIN
(
lvl
,
0
)))
if
(
Find
(
g
,
bp
->
GetV
lp
(
jpp
),
colname
,
MY_MIN
(
lvl
,
0
)))
goto
err
;
}
// endfor jpp
...
...
@@ -444,7 +444,7 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j)
strncat
(
strncat
(
colname
,
"_"
,
n
),
k
,
n
-
1
);
}
// endif Key
if
(
Find
(
g
,
bp
->
GetV
al
(
jrp
),
k
,
j
+
1
))
if
(
Find
(
g
,
bp
->
GetV
lp
(
jrp
),
k
,
j
+
1
))
return
true
;
*
p
=
*
pc
=
0
;
...
...
@@ -691,7 +691,7 @@ PBVAL BTUTIL::MakeTopTree(PGLOBAL g, int type)
}
// endif Val
Tp
->
Row
=
val
;
Tp
->
Row
->
Type
=
type
;
if
(
Tp
->
Row
)
Tp
->
Row
->
Type
=
type
;
}
else
top
=
Tp
->
Row
=
NewVal
(
type
);
...
...
@@ -1052,18 +1052,20 @@ PBVAL BCUTIL::GetRow(PGLOBAL g)
}
else
{
// Construct missing objects
for
(
i
++
;
row
&&
i
<
nod
;
i
++
)
{
int
type
;
if
(
nodes
[
i
].
Op
==
OP_XX
)
break
;
else
if
(
!
nodes
[
i
].
Key
)
// Construct intermediate array
nwr
=
NewVal
(
TYPE_JAR
)
;
type
=
TYPE_JAR
;
else
nwr
=
NewVal
(
TYPE_JOB
)
;
type
=
TYPE_JOB
;
if
(
row
->
Type
==
TYPE_JOB
)
{
SetKeyValue
(
row
,
MOF
(
nwr
),
nodes
[
i
-
1
].
Key
);
nwr
=
AddPair
(
row
,
nodes
[
i
-
1
].
Key
,
type
);
}
else
if
(
row
->
Type
==
TYPE_JAR
)
{
AddArrayValue
(
row
,
nwr
);
AddArrayValue
(
row
,
(
nwr
=
NewVal
(
type
))
);
}
else
{
strcpy
(
g
->
Message
,
"Wrong type when writing new row"
);
nwr
=
NULL
;
...
...
@@ -2258,19 +2260,16 @@ int TDBBSON::MakeDocument(PGLOBAL g)
Docp
=
jsp
;
else
{
// The table is void or is just one object or one value
Docp
=
Bp
->
NewVal
(
TYPE_JAR
);
if
(
val
)
Bp
->
AddArrayValue
(
Docp
,
val
);
else
if
(
jsp
)
Bp
->
AddArrayValue
(
Docp
,
Bp
->
DupVal
(
jsp
));
if
(
objp
)
Bp
->
SetKeyValue
(
objp
,
Bp
->
DupVal
(
Docp
),
key
);
else
if
(
arp
)
Bp
->
SetArrayValue
(
arp
,
Bp
->
DupVal
(
Docp
),
i
);
else
Top
=
Docp
;
if
(
objp
)
{
Docp
=
Bp
->
GetKeyValue
(
objp
,
key
);
Docp
->
To_Val
=
Bp
->
MOF
(
Bp
->
DupVal
(
Docp
));
Docp
->
Type
=
TYPE_JAR
;
}
else
if
(
arp
)
{
Docp
=
Bp
->
NewVal
(
TYPE_JAR
);
Bp
->
AddArrayValue
(
Docp
,
jsp
);
Bp
->
SetArrayValue
(
arp
,
Docp
,
i
);
}
else
Top
=
Docp
=
Bp
->
NewVal
(
TYPE_JAR
);
}
// endif jsp
...
...
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