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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
0bfb5bee
Commit
0bfb5bee
authored
Jan 25, 2016
by
Olivier Bertrand
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ob-10.0' into 10.0
parents
7cd94c68
62a5e56c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
82 additions
and
17 deletions
+82
-17
storage/connect/ha_connect.cc
storage/connect/ha_connect.cc
+12
-9
storage/connect/jsonudf.cpp
storage/connect/jsonudf.cpp
+53
-4
storage/connect/jsonudf.h
storage/connect/jsonudf.h
+6
-0
storage/connect/mysql-test/connect/r/json_udf.result
storage/connect/mysql-test/connect/r/json_udf.result
+3
-1
storage/connect/mysql-test/connect/t/json_udf.inc
storage/connect/mysql-test/connect/t/json_udf.inc
+2
-0
storage/connect/mysql-test/connect/t/json_udf.test
storage/connect/mysql-test/connect/t/json_udf.test
+2
-1
storage/connect/mysql-test/connect/t/json_udf2.inc
storage/connect/mysql-test/connect/t/json_udf2.inc
+2
-0
storage/connect/odbconn.cpp
storage/connect/odbconn.cpp
+2
-2
No files found.
storage/connect/ha_connect.cc
View file @
0bfb5bee
/* Copyright (C) Olivier Bertrand 2004 - 201
5
/* Copyright (C) Olivier Bertrand 2004 - 201
6
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -169,7 +169,7 @@
#define JSONMAX 10 // JSON Default max grp size
extern
"C"
{
char
version
[]
=
"Version 1.04.0005
December 11, 2015
"
;
char
version
[]
=
"Version 1.04.0005
January 24, 2016
"
;
#if defined(__WIN__)
char
compver
[]
=
"Version 1.04.0005 "
__DATE__
" "
__TIME__
;
char
slash
=
'\\'
;
...
...
@@ -339,15 +339,22 @@ static MYSQL_THDVAR_ENUM(
&
language_typelib
);
// typelib
#endif // XMSG || NEWMSG
/***********************************************************************/
/* The CONNECT handlerton object. */
/***********************************************************************/
handlerton
*
connect_hton
=
NULL
;
/***********************************************************************/
/* Function to export session variable values to other source files. */
/***********************************************************************/
extern
"C"
int
GetTraceValue
(
void
)
{
return
THDVAR
(
current_thd
,
xtrace
);}
extern
"C"
int
GetTraceValue
(
void
)
{
return
connect_hton
?
THDVAR
(
current_thd
,
xtrace
)
:
0
;}
bool
ExactInfo
(
void
)
{
return
THDVAR
(
current_thd
,
exact_info
);}
USETEMP
UseTemp
(
void
)
{
return
(
USETEMP
)
THDVAR
(
current_thd
,
use_tempfile
);}
int
GetConvSize
(
void
)
{
return
THDVAR
(
current_thd
,
conv_size
);}
TYPCONV
GetTypeConv
(
void
)
{
return
(
TYPCONV
)
THDVAR
(
current_thd
,
type_conv
);}
uint
GetJsonGrpSize
(
void
)
{
return
THDVAR
(
current_thd
,
json_grp_size
);}
uint
GetJsonGrpSize
(
void
)
{
return
connect_hton
?
THDVAR
(
current_thd
,
json_grp_size
)
:
10
;}
uint
GetWorkSize
(
void
)
{
return
THDVAR
(
current_thd
,
work_size
);}
void
SetWorkSize
(
uint
)
{
...
...
@@ -442,11 +449,6 @@ static int check_msg_path (MYSQL_THD thd, struct st_mysql_sys_var *var,
} // end of check_msg_path
#endif // 0
/***********************************************************************/
/* The CONNECT handlerton object. */
/***********************************************************************/
handlerton
*
connect_hton
;
/**
CREATE TABLE option list (table options)
...
...
@@ -687,6 +689,7 @@ static int connect_done_func(void *)
delete
pc
;
}
// endfor pc
connect_hton
=
NULL
;
DBUG_RETURN
(
error
);
}
// end of connect_done_func
...
...
storage/connect/jsonudf.cpp
View file @
0bfb5bee
...
...
@@ -31,6 +31,8 @@ uint GetJsonGrpSize(void);
static
int
IsJson
(
UDF_ARGS
*
args
,
uint
i
);
static
PSZ
MakePSZ
(
PGLOBAL
g
,
UDF_ARGS
*
args
,
int
i
);
static
uint
JsonGrpSize
=
10
;
/* ----------------------------------- JSNX ------------------------------------ */
/*********************************************************************************/
...
...
@@ -1039,6 +1041,14 @@ static void SetChanged(PBSON bsp)
bsp
->
Changed
=
true
;
}
/* end of SetChanged */
/*********************************************************************************/
/* Replaces GetJsonGrpSize not usable when CONNECT is not installed. */
/*********************************************************************************/
static
uint
GetJsonGroupSize
(
void
)
{
return
(
JsonGrpSize
)
?
JsonGrpSize
:
GetJsonGrpSize
();
}
// end of GetJsonGroupSize
/*********************************************************************************/
/* Program for SubSet re-initialization of the memory pool. */
/*********************************************************************************/
...
...
@@ -2393,12 +2403,51 @@ void json_object_list_deinit(UDF_INIT* initid)
JsonFreeMem
((
PGLOBAL
)
initid
->
ptr
);
}
// end of json_object_list_deinit
/*********************************************************************************/
/* Set the value of JsonGrpSize. */
/*********************************************************************************/
my_bool
jsonset_grp_size_init
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
message
)
{
if
(
args
->
arg_count
!=
1
||
args
->
arg_type
[
0
]
!=
INT_RESULT
)
{
strcpy
(
message
,
"This function must have 1 integer argument"
);
return
true
;
}
else
return
false
;
}
// end of jsonset_grp_size_init
long
long
jsonset_grp_size
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
,
char
*
)
{
long
long
n
=
*
(
long
long
*
)
args
->
args
[
0
];
JsonGrpSize
=
(
uint
)
n
;
return
(
long
long
)
GetJsonGroupSize
();
}
// end of jsonset_grp_size
/*********************************************************************************/
/* Get the value of JsonGrpSize. */
/*********************************************************************************/
my_bool
jsonget_grp_size_init
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
message
)
{
if
(
args
->
arg_count
!=
0
)
{
strcpy
(
message
,
"This function must have no arguments"
);
return
true
;
}
else
return
false
;
}
// end of jsonget_grp_size_init
long
long
jsonget_grp_size
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
,
char
*
)
{
return
(
long
long
)
GetJsonGroupSize
();
}
// end of jsonget_grp_size
/*********************************************************************************/
/* Make a Json array from values coming from rows. */
/*********************************************************************************/
my_bool
json_array_grp_init
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
message
)
{
unsigned
long
reslen
,
memlen
,
n
=
GetJsonGrpSize
();
unsigned
long
reslen
,
memlen
,
n
=
GetJsonGr
ou
pSize
();
if
(
args
->
arg_count
!=
1
)
{
strcpy
(
message
,
"This function can only accept 1 argument"
);
...
...
@@ -2458,7 +2507,7 @@ void json_array_grp_clear(UDF_INIT *initid, char*, char*)
PlugSubSet
(
g
,
g
->
Sarea
,
g
->
Sarea_Size
);
g
->
Activityp
=
(
PACTIVITY
)
new
(
g
)
JARRAY
;
g
->
N
=
GetJsonGrpSize
();
g
->
N
=
GetJsonGr
ou
pSize
();
}
// end of json_array_grp_clear
void
json_array_grp_deinit
(
UDF_INIT
*
initid
)
...
...
@@ -2471,7 +2520,7 @@ void json_array_grp_deinit(UDF_INIT* initid)
/*********************************************************************************/
my_bool
json_object_grp_init
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
message
)
{
unsigned
long
reslen
,
memlen
,
n
=
GetJsonGrpSize
();
unsigned
long
reslen
,
memlen
,
n
=
GetJsonGr
ou
pSize
();
if
(
args
->
arg_count
!=
2
)
{
strcpy
(
message
,
"This function requires 2 arguments (key, value)"
);
...
...
@@ -2529,7 +2578,7 @@ void json_object_grp_clear(UDF_INIT *initid, char*, char*)
PlugSubSet
(
g
,
g
->
Sarea
,
g
->
Sarea_Size
);
g
->
Activityp
=
(
PACTIVITY
)
new
(
g
)
JOBJECT
;
g
->
N
=
GetJsonGrpSize
();
g
->
N
=
GetJsonGr
ou
pSize
();
}
// end of json_object_grp_clear
void
json_object_grp_deinit
(
UDF_INIT
*
initid
)
...
...
storage/connect/jsonudf.h
View file @
0bfb5bee
...
...
@@ -77,6 +77,12 @@ extern "C" {
DllExport
char
*
json_object_list
(
UDF_EXEC_ARGS
);
DllExport
void
json_object_list_deinit
(
UDF_INIT
*
);
DllExport
my_bool
jsonset_grp_size_init
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
);
DllExport
long
long
jsonset_grp_size
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
,
char
*
);
DllExport
my_bool
jsonget_grp_size_init
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
);
DllExport
long
long
jsonget_grp_size
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
,
char
*
);
DllExport
my_bool
json_array_grp_init
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
);
DllExport
void
json_array_grp_add
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
,
char
*
);
DllExport
char
*
json_array_grp
(
UDF_EXEC_ARGS
);
...
...
storage/connect/mysql-test/connect/r/json_udf.result
View file @
0bfb5bee
...
...
@@ -217,7 +217,9 @@ DEPARTMENT Json_Array_Grp(NAME)
2452 ["BIGHEAD","ORELLY","BIGHORN","SMITH","CHERRY"]
Warnings:
Warning 1105 Result truncated to json_grp_size values
SET connect_json_grp_size=30;
SELECT JsonSet_Grp_Size(30);
JsonSet_Grp_Size(30)
30
SELECT Json_Object(title, Json_Array_Grp(name) `json_names`) from t3 GROUP BY title;
Json_Object(title, Json_Array_Grp(name) `json_names`)
{"title":"ADMINISTRATOR","names":["GOOSEPEN","FUNNIGUY","SHRINKY"]}
...
...
storage/connect/mysql-test/connect/t/json_udf.inc
View file @
0bfb5bee
...
...
@@ -20,6 +20,8 @@ if (!$HA_CONNECT_SO) {
--
eval
CREATE
FUNCTION
json_object_delete
RETURNS
STRING
SONAME
'$HA_CONNECT_SO'
;
--
eval
CREATE
FUNCTION
json_object_list
RETURNS
STRING
SONAME
'$HA_CONNECT_SO'
;
--
eval
CREATE
FUNCTION
jsonvalue
RETURNS
STRING
SONAME
'$HA_CONNECT_SO'
;
--
eval
CREATE
FUNCTION
jsonset_grp_size
RETURNS
INTEGER
SONAME
'$HA_CONNECT_SO'
;
--
eval
CREATE
FUNCTION
jsonget_grp_size
RETURNS
INTEGER
SONAME
'$HA_CONNECT_SO'
;
--
eval
CREATE
AGGREGATE
FUNCTION
json_array_grp
RETURNS
STRING
SONAME
'$HA_CONNECT_SO'
;
--
eval
CREATE
AGGREGATE
FUNCTION
json_object_grp
RETURNS
STRING
SONAME
'$HA_CONNECT_SO'
;
--
eval
CREATE
FUNCTION
jsonget_string
RETURNS
STRING
SONAME
'$HA_CONNECT_SO'
;
...
...
storage/connect/mysql-test/connect/t/json_udf.test
View file @
0bfb5bee
...
...
@@ -108,7 +108,8 @@ CREATE TABLE t3 (
SELECT
Json_Object
(
SERIALNO
,
NAME
,
TITLE
,
SALARY
)
FROM
t3
WHERE
NAME
=
'MERCHANT'
;
SELECT
DEPARTMENT
,
Json_Array_Grp
(
NAME
)
FROM
t3
GROUP
BY
DEPARTMENT
;
SET
connect_json_grp_size
=
30
;
#SET connect_json_grp_size=30; Deprecated
SELECT
JsonSet_Grp_Size
(
30
);
SELECT
Json_Object
(
title
,
Json_Array_Grp
(
name
)
`json_names`
)
from
t3
GROUP
BY
title
;
SELECT
Json_Array
(
DEPARTMENT
,
Json_Array_Grp
(
NAME
))
FROM
t3
GROUP
BY
DEPARTMENT
;
SELECT
Json_Object
(
DEPARTMENT
,
Json_Array_Grp
(
NAME
)
json_NAMES
)
FROM
t3
GROUP
BY
DEPARTMENT
;
...
...
storage/connect/mysql-test/connect/t/json_udf2.inc
View file @
0bfb5bee
...
...
@@ -11,6 +11,8 @@ DROP FUNCTION json_object_add;
DROP
FUNCTION
json_object_delete
;
DROP
FUNCTION
json_object_list
;
DROP
FUNCTION
jsonvalue
;
DROP
FUNCTION
jsonset_grp_size
;
DROP
FUNCTION
jsonget_grp_size
;
DROP
FUNCTION
json_array_grp
;
DROP
FUNCTION
json_object_grp
;
DROP
FUNCTION
jsonget_string
;
...
...
storage/connect/odbconn.cpp
View file @
0bfb5bee
...
...
@@ -2249,7 +2249,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
rc
=
SQLTables
(
hstmt
,
name
.
ptr
(
2
),
name
.
length
(
2
),
name
.
ptr
(
1
),
name
.
length
(
1
),
name
.
ptr
(
0
),
name
.
length
(
0
),
cap
->
Pat
,
SQL_NTS
);
cap
->
Pat
,
cap
->
Pat
?
SQL_NTS
:
0
);
break
;
case
CAT_COL
:
// rc = SQLSetStmtAttr(hstmt, SQL_ATTR_METADATA_ID,
...
...
@@ -2258,7 +2258,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
rc
=
SQLColumns
(
hstmt
,
name
.
ptr
(
2
),
name
.
length
(
2
),
name
.
ptr
(
1
),
name
.
length
(
1
),
name
.
ptr
(
0
),
name
.
length
(
0
),
cap
->
Pat
,
SQL_NTS
);
cap
->
Pat
,
cap
->
Pat
?
SQL_NTS
:
0
);
break
;
case
CAT_KEY
:
fnc
=
"SQLPrimaryKeys"
;
...
...
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