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