Skip to content

Commit 0bfb5be

Browse files
committed
Merge branch 'ob-10.0' into 10.0
2 parents 7cd94c6 + 62a5e56 commit 0bfb5be

File tree

8 files changed

+82
-17
lines changed

8 files changed

+82
-17
lines changed

storage/connect/ha_connect.cc

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) Olivier Bertrand 2004 - 2015
1+
/* Copyright (C) Olivier Bertrand 2004 - 2016
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -169,7 +169,7 @@
169169
#define JSONMAX 10 // JSON Default max grp size
170170

171171
extern "C" {
172-
char version[]= "Version 1.04.0005 December 11, 2015";
172+
char version[]= "Version 1.04.0005 January 24, 2016";
173173
#if defined(__WIN__)
174174
char compver[]= "Version 1.04.0005 " __DATE__ " " __TIME__;
175175
char slash= '\\';
@@ -339,15 +339,22 @@ static MYSQL_THDVAR_ENUM(
339339
&language_typelib); // typelib
340340
#endif // XMSG || NEWMSG
341341

342+
/***********************************************************************/
343+
/* The CONNECT handlerton object. */
344+
/***********************************************************************/
345+
handlerton *connect_hton= NULL;
346+
342347
/***********************************************************************/
343348
/* Function to export session variable values to other source files. */
344349
/***********************************************************************/
345-
extern "C" int GetTraceValue(void) {return THDVAR(current_thd, xtrace);}
350+
extern "C" int GetTraceValue(void)
351+
{return connect_hton ? THDVAR(current_thd, xtrace) : 0;}
346352
bool ExactInfo(void) {return THDVAR(current_thd, exact_info);}
347353
USETEMP UseTemp(void) {return (USETEMP)THDVAR(current_thd, use_tempfile);}
348354
int GetConvSize(void) {return THDVAR(current_thd, conv_size);}
349355
TYPCONV GetTypeConv(void) {return (TYPCONV)THDVAR(current_thd, type_conv);}
350-
uint GetJsonGrpSize(void) {return THDVAR(current_thd, json_grp_size);}
356+
uint GetJsonGrpSize(void)
357+
{return connect_hton ? THDVAR(current_thd, json_grp_size) : 10;}
351358
uint GetWorkSize(void) {return THDVAR(current_thd, work_size);}
352359
void SetWorkSize(uint)
353360
{
@@ -442,11 +449,6 @@ static int check_msg_path (MYSQL_THD thd, struct st_mysql_sys_var *var,
442449
} // end of check_msg_path
443450
#endif // 0
444451

445-
/***********************************************************************/
446-
/* The CONNECT handlerton object. */
447-
/***********************************************************************/
448-
handlerton *connect_hton;
449-
450452
/**
451453
CREATE TABLE option list (table options)
452454
@@ -687,6 +689,7 @@ static int connect_done_func(void *)
687689
delete pc;
688690
} // endfor pc
689691

692+
connect_hton= NULL;
690693
DBUG_RETURN(error);
691694
} // end of connect_done_func
692695

storage/connect/jsonudf.cpp

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ uint GetJsonGrpSize(void);
3131
static int IsJson(UDF_ARGS *args, uint i);
3232
static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i);
3333

34+
static uint JsonGrpSize = 10;
35+
3436
/* ----------------------------------- JSNX ------------------------------------ */
3537

3638
/*********************************************************************************/
@@ -1039,6 +1041,14 @@ static void SetChanged(PBSON bsp)
10391041
bsp->Changed = true;
10401042
} /* end of SetChanged */
10411043

1044+
/*********************************************************************************/
1045+
/* Replaces GetJsonGrpSize not usable when CONNECT is not installed. */
1046+
/*********************************************************************************/
1047+
static uint GetJsonGroupSize(void)
1048+
{
1049+
return (JsonGrpSize) ? JsonGrpSize : GetJsonGrpSize();
1050+
} // end of GetJsonGroupSize
1051+
10421052
/*********************************************************************************/
10431053
/* Program for SubSet re-initialization of the memory pool. */
10441054
/*********************************************************************************/
@@ -2393,12 +2403,51 @@ void json_object_list_deinit(UDF_INIT* initid)
23932403
JsonFreeMem((PGLOBAL)initid->ptr);
23942404
} // end of json_object_list_deinit
23952405

2406+
/*********************************************************************************/
2407+
/* Set the value of JsonGrpSize. */
2408+
/*********************************************************************************/
2409+
my_bool jsonset_grp_size_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
2410+
{
2411+
if (args->arg_count != 1 || args->arg_type[0] != INT_RESULT) {
2412+
strcpy(message, "This function must have 1 integer argument");
2413+
return true;
2414+
} else
2415+
return false;
2416+
2417+
} // end of jsonset_grp_size_init
2418+
2419+
long long jsonset_grp_size(UDF_INIT *initid, UDF_ARGS *args, char *, char *)
2420+
{
2421+
long long n = *(long long*)args->args[0];
2422+
2423+
JsonGrpSize = (uint)n;
2424+
return (long long)GetJsonGroupSize();
2425+
} // end of jsonset_grp_size
2426+
2427+
/*********************************************************************************/
2428+
/* Get the value of JsonGrpSize. */
2429+
/*********************************************************************************/
2430+
my_bool jsonget_grp_size_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
2431+
{
2432+
if (args->arg_count != 0) {
2433+
strcpy(message, "This function must have no arguments");
2434+
return true;
2435+
} else
2436+
return false;
2437+
2438+
} // end of jsonget_grp_size_init
2439+
2440+
long long jsonget_grp_size(UDF_INIT *initid, UDF_ARGS *args, char *, char *)
2441+
{
2442+
return (long long)GetJsonGroupSize();
2443+
} // end of jsonget_grp_size
2444+
23962445
/*********************************************************************************/
23972446
/* Make a Json array from values coming from rows. */
23982447
/*********************************************************************************/
23992448
my_bool json_array_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
24002449
{
2401-
unsigned long reslen, memlen, n = GetJsonGrpSize();
2450+
unsigned long reslen, memlen, n = GetJsonGroupSize();
24022451

24032452
if (args->arg_count != 1) {
24042453
strcpy(message, "This function can only accept 1 argument");
@@ -2458,7 +2507,7 @@ void json_array_grp_clear(UDF_INIT *initid, char*, char*)
24582507

24592508
PlugSubSet(g, g->Sarea, g->Sarea_Size);
24602509
g->Activityp = (PACTIVITY)new(g) JARRAY;
2461-
g->N = GetJsonGrpSize();
2510+
g->N = GetJsonGroupSize();
24622511
} // end of json_array_grp_clear
24632512

24642513
void json_array_grp_deinit(UDF_INIT* initid)
@@ -2471,7 +2520,7 @@ void json_array_grp_deinit(UDF_INIT* initid)
24712520
/*********************************************************************************/
24722521
my_bool json_object_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
24732522
{
2474-
unsigned long reslen, memlen, n = GetJsonGrpSize();
2523+
unsigned long reslen, memlen, n = GetJsonGroupSize();
24752524

24762525
if (args->arg_count != 2) {
24772526
strcpy(message, "This function requires 2 arguments (key, value)");
@@ -2529,7 +2578,7 @@ void json_object_grp_clear(UDF_INIT *initid, char*, char*)
25292578

25302579
PlugSubSet(g, g->Sarea, g->Sarea_Size);
25312580
g->Activityp = (PACTIVITY)new(g) JOBJECT;
2532-
g->N = GetJsonGrpSize();
2581+
g->N = GetJsonGroupSize();
25332582
} // end of json_object_grp_clear
25342583

25352584
void json_object_grp_deinit(UDF_INIT* initid)

storage/connect/jsonudf.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ extern "C" {
7777
DllExport char *json_object_list(UDF_EXEC_ARGS);
7878
DllExport void json_object_list_deinit(UDF_INIT*);
7979

80+
DllExport my_bool jsonset_grp_size_init(UDF_INIT*, UDF_ARGS*, char*);
81+
DllExport long long jsonset_grp_size(UDF_INIT*, UDF_ARGS*, char*, char*);
82+
83+
DllExport my_bool jsonget_grp_size_init(UDF_INIT*, UDF_ARGS*, char*);
84+
DllExport long long jsonget_grp_size(UDF_INIT*, UDF_ARGS*, char*, char*);
85+
8086
DllExport my_bool json_array_grp_init(UDF_INIT*, UDF_ARGS*, char*);
8187
DllExport void json_array_grp_add(UDF_INIT *, UDF_ARGS *, char *, char *);
8288
DllExport char *json_array_grp(UDF_EXEC_ARGS);

storage/connect/mysql-test/connect/r/json_udf.result

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ DEPARTMENT Json_Array_Grp(NAME)
217217
2452 ["BIGHEAD","ORELLY","BIGHORN","SMITH","CHERRY"]
218218
Warnings:
219219
Warning 1105 Result truncated to json_grp_size values
220-
SET connect_json_grp_size=30;
220+
SELECT JsonSet_Grp_Size(30);
221+
JsonSet_Grp_Size(30)
222+
30
221223
SELECT Json_Object(title, Json_Array_Grp(name) `json_names`) from t3 GROUP BY title;
222224
Json_Object(title, Json_Array_Grp(name) `json_names`)
223225
{"title":"ADMINISTRATOR","names":["GOOSEPEN","FUNNIGUY","SHRINKY"]}

storage/connect/mysql-test/connect/t/json_udf.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ if (!$HA_CONNECT_SO) {
2020
--eval CREATE FUNCTION json_object_delete RETURNS STRING SONAME '$HA_CONNECT_SO';
2121
--eval CREATE FUNCTION json_object_list RETURNS STRING SONAME '$HA_CONNECT_SO';
2222
--eval CREATE FUNCTION jsonvalue RETURNS STRING SONAME '$HA_CONNECT_SO';
23+
--eval CREATE FUNCTION jsonset_grp_size RETURNS INTEGER SONAME '$HA_CONNECT_SO';
24+
--eval CREATE FUNCTION jsonget_grp_size RETURNS INTEGER SONAME '$HA_CONNECT_SO';
2325
--eval CREATE AGGREGATE FUNCTION json_array_grp RETURNS STRING SONAME '$HA_CONNECT_SO';
2426
--eval CREATE AGGREGATE FUNCTION json_object_grp RETURNS STRING SONAME '$HA_CONNECT_SO';
2527
--eval CREATE FUNCTION jsonget_string RETURNS STRING SONAME '$HA_CONNECT_SO';

storage/connect/mysql-test/connect/t/json_udf.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ CREATE TABLE t3 (
108108

109109
SELECT Json_Object(SERIALNO, NAME, TITLE, SALARY) FROM t3 WHERE NAME = 'MERCHANT';
110110
SELECT DEPARTMENT, Json_Array_Grp(NAME) FROM t3 GROUP BY DEPARTMENT;
111-
SET connect_json_grp_size=30;
111+
#SET connect_json_grp_size=30; Deprecated
112+
SELECT JsonSet_Grp_Size(30);
112113
SELECT Json_Object(title, Json_Array_Grp(name) `json_names`) from t3 GROUP BY title;
113114
SELECT Json_Array(DEPARTMENT, Json_Array_Grp(NAME)) FROM t3 GROUP BY DEPARTMENT;
114115
SELECT Json_Object(DEPARTMENT, Json_Array_Grp(NAME) json_NAMES) FROM t3 GROUP BY DEPARTMENT;

storage/connect/mysql-test/connect/t/json_udf2.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ DROP FUNCTION json_object_add;
1111
DROP FUNCTION json_object_delete;
1212
DROP FUNCTION json_object_list;
1313
DROP FUNCTION jsonvalue;
14+
DROP FUNCTION jsonset_grp_size;
15+
DROP FUNCTION jsonget_grp_size;
1416
DROP FUNCTION json_array_grp;
1517
DROP FUNCTION json_object_grp;
1618
DROP FUNCTION jsonget_string;

storage/connect/odbconn.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
22492249
rc = SQLTables(hstmt, name.ptr(2), name.length(2),
22502250
name.ptr(1), name.length(1),
22512251
name.ptr(0), name.length(0),
2252-
cap->Pat, SQL_NTS);
2252+
cap->Pat, cap->Pat ? SQL_NTS : 0);
22532253
break;
22542254
case CAT_COL:
22552255
// rc = SQLSetStmtAttr(hstmt, SQL_ATTR_METADATA_ID,
@@ -2258,7 +2258,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
22582258
rc = SQLColumns(hstmt, name.ptr(2), name.length(2),
22592259
name.ptr(1), name.length(1),
22602260
name.ptr(0), name.length(0),
2261-
cap->Pat, SQL_NTS);
2261+
cap->Pat, cap->Pat ? SQL_NTS : 0);
22622262
break;
22632263
case CAT_KEY:
22642264
fnc = "SQLPrimaryKeys";

0 commit comments

Comments
 (0)