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
723be516
Commit
723be516
authored
Feb 24, 2015
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
8799f870
a736e63f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
131 additions
and
23 deletions
+131
-23
storage/connect/global.h
storage/connect/global.h
+1
-1
storage/connect/ha_connect.cc
storage/connect/ha_connect.cc
+13
-3
storage/connect/json.cpp
storage/connect/json.cpp
+6
-0
storage/connect/jsonudf.cpp
storage/connect/jsonudf.cpp
+100
-12
storage/connect/plgdbutl.cpp
storage/connect/plgdbutl.cpp
+1
-1
storage/connect/plugutil.c
storage/connect/plugutil.c
+1
-1
storage/connect/tabjson.cpp
storage/connect/tabjson.cpp
+5
-1
storage/connect/tabodbc.cpp
storage/connect/tabodbc.cpp
+4
-4
No files found.
storage/connect/global.h
View file @
723be516
...
@@ -235,7 +235,7 @@ typedef struct _global { /* Global structure */
...
@@ -235,7 +235,7 @@ typedef struct _global { /* Global structure */
void
*
Xchk
;
/* indexes in create/alter */
void
*
Xchk
;
/* indexes in create/alter */
short
Alchecked
;
/* Checked for ALTER */
short
Alchecked
;
/* Checked for ALTER */
short
Mrr
;
/* True when doing mrr */
short
Mrr
;
/* True when doing mrr */
short
Trace
;
int
N
;
/* Utility */
int
jump_level
;
int
jump_level
;
jmp_buf
jumper
[
MAX_JUMP
+
2
];
jmp_buf
jumper
[
MAX_JUMP
+
2
];
}
GLOBAL
;
}
GLOBAL
;
...
...
storage/connect/ha_connect.cc
View file @
723be516
...
@@ -168,6 +168,7 @@
...
@@ -168,6 +168,7 @@
#define SZCONV 8192
#define SZCONV 8192
#define SZWORK 67108864 // Default work area size 64M
#define SZWORK 67108864 // Default work area size 64M
#define SZWMIN 4194304 // Minimum work area size 4M
#define SZWMIN 4194304 // Minimum work area size 4M
#define JSONMAX 10 // JSON Default max grp size
extern
"C"
{
extern
"C"
{
char
version
[]
=
"Version 1.03.0006 February 06, 2015"
;
char
version
[]
=
"Version 1.03.0006 February 06, 2015"
;
...
@@ -217,6 +218,7 @@ bool ExactInfo(void);
...
@@ -217,6 +218,7 @@ bool ExactInfo(void);
USETEMP
UseTemp
(
void
);
USETEMP
UseTemp
(
void
);
int
GetConvSize
(
void
);
int
GetConvSize
(
void
);
TYPCONV
GetTypeConv
(
void
);
TYPCONV
GetTypeConv
(
void
);
uint
GetJsonGrpSize
(
void
);
uint
GetWorkSize
(
void
);
uint
GetWorkSize
(
void
);
void
SetWorkSize
(
uint
);
void
SetWorkSize
(
uint
);
extern
"C"
const
char
*
msglang
(
void
);
extern
"C"
const
char
*
msglang
(
void
);
...
@@ -323,6 +325,12 @@ static MYSQL_THDVAR_ENUM(
...
@@ -323,6 +325,12 @@ static MYSQL_THDVAR_ENUM(
0
,
// def (no)
0
,
// def (no)
&
xconv_typelib
);
// typelib
&
xconv_typelib
);
// typelib
// Estimate max number of rows for JSON aggregate functions
static
MYSQL_THDVAR_UINT
(
json_grp_size
,
PLUGIN_VAR_RQCMDARG
,
// opt
"max number of rows for JSON aggregate functions."
,
NULL
,
NULL
,
JSONMAX
,
1
,
INT_MAX
,
1
);
#if defined(XMSG) || defined(NEWMSG)
#if defined(XMSG) || defined(NEWMSG)
const
char
*
language_names
[]
=
const
char
*
language_names
[]
=
{
{
...
@@ -353,6 +361,7 @@ bool ExactInfo(void) {return THDVAR(current_thd, exact_info);}
...
@@ -353,6 +361,7 @@ bool ExactInfo(void) {return THDVAR(current_thd, exact_info);}
USETEMP
UseTemp
(
void
)
{
return
(
USETEMP
)
THDVAR
(
current_thd
,
use_tempfile
);}
USETEMP
UseTemp
(
void
)
{
return
(
USETEMP
)
THDVAR
(
current_thd
,
use_tempfile
);}
int
GetConvSize
(
void
)
{
return
THDVAR
(
current_thd
,
conv_size
);}
int
GetConvSize
(
void
)
{
return
THDVAR
(
current_thd
,
conv_size
);}
TYPCONV
GetTypeConv
(
void
)
{
return
(
TYPCONV
)
THDVAR
(
current_thd
,
type_conv
);}
TYPCONV
GetTypeConv
(
void
)
{
return
(
TYPCONV
)
THDVAR
(
current_thd
,
type_conv
);}
uint
GetJsonGrpSize
(
void
)
{
return
THDVAR
(
current_thd
,
json_grp_size
);}
uint
GetWorkSize
(
void
)
{
return
THDVAR
(
current_thd
,
work_size
);}
uint
GetWorkSize
(
void
)
{
return
THDVAR
(
current_thd
,
work_size
);}
void
SetWorkSize
(
uint
n
)
void
SetWorkSize
(
uint
n
)
{
{
...
@@ -6516,6 +6525,7 @@ static struct st_mysql_sys_var* connect_system_variables[]= {
...
@@ -6516,6 +6525,7 @@ static struct st_mysql_sys_var* connect_system_variables[]= {
#if defined(XMSG)
#if defined(XMSG)
MYSQL_SYSVAR
(
errmsg_dir_path
),
MYSQL_SYSVAR
(
errmsg_dir_path
),
#endif // XMSG
#endif // XMSG
MYSQL_SYSVAR
(
json_grp_size
),
NULL
NULL
};
};
...
...
storage/connect/json.cpp
View file @
723be516
...
@@ -74,6 +74,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int pretty, bool *comma)
...
@@ -74,6 +74,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int pretty, bool *comma)
goto
err
;
goto
err
;
}
else
if
(
!
(
jsp
=
ParseObject
(
g
,
++
i
,
src
)))
}
else
if
(
!
(
jsp
=
ParseObject
(
g
,
++
i
,
src
)))
goto
err
;
goto
err
;
break
;
break
;
case
' '
:
case
' '
:
case
'\t'
:
case
'\t'
:
...
@@ -90,6 +91,11 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int pretty, bool *comma)
...
@@ -90,6 +91,11 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int pretty, bool *comma)
sprintf
(
g
->
Message
,
"Unexpected ',' (pretty=%d)"
,
pretty
);
sprintf
(
g
->
Message
,
"Unexpected ',' (pretty=%d)"
,
pretty
);
goto
err
;
goto
err
;
case
'"'
:
if
(
!
(
jsp
=
ParseValue
(
g
,
i
,
src
)))
goto
err
;
break
;
case
'('
:
case
'('
:
b
=
true
;
b
=
true
;
break
;
break
;
...
...
storage/connect/jsonudf.cpp
View file @
723be516
...
@@ -8,12 +8,18 @@
...
@@ -8,12 +8,18 @@
/* Include relevant sections of the MariaDB header file. */
/* Include relevant sections of the MariaDB header file. */
/***********************************************************************/
/***********************************************************************/
#include <my_global.h>
#include <my_global.h>
#include <mysqld.h>
#include <mysql.h>
#include <mysql.h>
#include <sql_error.h>
#include "global.h"
#include "global.h"
#include "plgdbsem.h"
#include "plgdbsem.h"
#include "json.h"
#include "json.h"
#define MEMFIX 512
uint
GetJsonGrpSize
(
void
);
extern
"C"
{
extern
"C"
{
DllExport
my_bool
Json_Value_init
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
);
DllExport
my_bool
Json_Value_init
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
);
DllExport
char
*
Json_Value
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
,
DllExport
char
*
Json_Value
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
,
...
@@ -23,6 +29,10 @@ DllExport my_bool Json_Array_init(UDF_INIT*, UDF_ARGS*, char*);
...
@@ -23,6 +29,10 @@ DllExport my_bool Json_Array_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport
char
*
Json_Array
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
,
DllExport
char
*
Json_Array
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
,
unsigned
long
*
,
char
*
,
char
*
);
unsigned
long
*
,
char
*
,
char
*
);
DllExport
void
Json_Array_deinit
(
UDF_INIT
*
);
DllExport
void
Json_Array_deinit
(
UDF_INIT
*
);
DllExport
my_bool
Json_Array_Add_init
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
);
DllExport
char
*
Json_Array_Add
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
,
unsigned
long
*
,
char
*
,
char
*
);
DllExport
void
Json_Array_Add_deinit
(
UDF_INIT
*
);
DllExport
my_bool
Json_Object_init
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
);
DllExport
my_bool
Json_Object_init
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
);
DllExport
char
*
Json_Object
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
,
DllExport
char
*
Json_Object
(
UDF_INIT
*
,
UDF_ARGS
*
,
char
*
,
unsigned
long
*
,
char
*
,
char
*
);
unsigned
long
*
,
char
*
,
char
*
);
...
@@ -44,8 +54,8 @@ DllExport void Json_Object_Grp_deinit(UDF_INIT*);
...
@@ -44,8 +54,8 @@ DllExport void Json_Object_Grp_deinit(UDF_INIT*);
/***********************************************************************/
/***********************************************************************/
/* Allocate and initialise the memory area. */
/* Allocate and initialise the memory area. */
/***********************************************************************/
/***********************************************************************/
static
my_bool
JsonInit
(
UDF_INIT
*
initid
,
char
*
message
,
unsigned
long
reslen
,
static
my_bool
JsonInit
(
UDF_INIT
*
initid
,
char
*
message
,
unsigned
long
memlen
)
unsigned
long
reslen
,
unsigned
long
memlen
)
{
{
PGLOBAL
g
=
PlugInit
(
NULL
,
memlen
);
PGLOBAL
g
=
PlugInit
(
NULL
,
memlen
);
...
@@ -119,7 +129,7 @@ static my_bool CalcLen(UDF_ARGS *args, my_bool obj,
...
@@ -119,7 +129,7 @@ static my_bool CalcLen(UDF_ARGS *args, my_bool obj,
}
// endfor i
}
// endfor i
// Calculate the amount of memory needed
// Calculate the amount of memory needed
memlen
=
1024
+
sizeof
(
JOUTSTR
)
+
reslen
;
memlen
=
MEMFIX
+
sizeof
(
JOUTSTR
)
+
reslen
;
for
(
i
=
0
;
i
<
args
->
arg_count
;
i
++
)
{
for
(
i
=
0
;
i
<
args
->
arg_count
;
i
++
)
{
memlen
+=
(
args
->
lengths
[
i
]
+
sizeof
(
JVALUE
));
memlen
+=
(
args
->
lengths
[
i
]
+
sizeof
(
JVALUE
));
...
@@ -219,14 +229,23 @@ static PSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
...
@@ -219,14 +229,23 @@ static PSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
static
PJVAL
MakeValue
(
PGLOBAL
g
,
UDF_ARGS
*
args
,
int
i
)
static
PJVAL
MakeValue
(
PGLOBAL
g
,
UDF_ARGS
*
args
,
int
i
)
{
{
char
*
sap
=
args
->
args
[
i
];
char
*
sap
=
args
->
args
[
i
];
PJSON
jsp
;
PJVAL
jvp
=
new
(
g
)
JVALUE
;
PJVAL
jvp
=
new
(
g
)
JVALUE
;
if
(
sap
)
switch
(
args
->
arg_type
[
i
])
{
if
(
sap
)
switch
(
args
->
arg_type
[
i
])
{
case
STRING_RESULT
:
case
STRING_RESULT
:
if
(
args
->
lengths
[
i
])
{
if
(
args
->
lengths
[
i
])
{
if
(
IsJson
(
args
,
i
))
if
(
IsJson
(
args
,
i
))
{
jvp
->
SetValue
(
ParseJson
(
g
,
sap
,
args
->
lengths
[
i
],
0
));
if
(
!
(
jsp
=
ParseJson
(
g
,
sap
,
args
->
lengths
[
i
],
0
)))
push_warning
(
current_thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
0
,
g
->
Message
);
if
(
jsp
&&
jsp
->
GetType
()
==
TYPE_JVAL
)
jvp
=
(
PJVAL
)
jsp
;
else
else
jvp
->
SetValue
(
jsp
);
}
else
jvp
->
SetString
(
g
,
MakePSZ
(
g
,
args
,
i
));
jvp
->
SetString
(
g
,
MakePSZ
(
g
,
args
,
i
));
}
// endif str
}
// endif str
...
@@ -328,6 +347,59 @@ void Json_Array_deinit(UDF_INIT* initid)
...
@@ -328,6 +347,59 @@ void Json_Array_deinit(UDF_INIT* initid)
PlugExit
((
PGLOBAL
)
initid
->
ptr
);
PlugExit
((
PGLOBAL
)
initid
->
ptr
);
}
// end of Json_Array_deinit
}
// end of Json_Array_deinit
/***********************************************************************/
/* Add values to a Json array. */
/***********************************************************************/
my_bool
Json_Array_Add_init
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
message
)
{
unsigned
long
reslen
,
memlen
;
if
(
args
->
arg_count
<
2
)
{
strcpy
(
message
,
"Json_Value_Add must have at least 2 arguments"
);
return
true
;
}
else
if
(
!
IsJson
(
args
,
0
))
{
strcpy
(
message
,
"Json_Value_Add first argument must be a json array"
);
return
true
;
}
else
CalcLen
(
args
,
false
,
reslen
,
memlen
);
return
JsonInit
(
initid
,
message
,
reslen
,
memlen
);
}
// end of Json_Array_Add_init
char
*
Json_Array_Add
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
result
,
unsigned
long
*
res_length
,
char
*
is_null
,
char
*
error
)
{
char
*
str
;
PJVAL
jvp
;
PJAR
arp
;
PGLOBAL
g
=
(
PGLOBAL
)
initid
->
ptr
;
PlugSubSet
(
g
,
g
->
Sarea
,
g
->
Sarea_Size
);
jvp
=
MakeValue
(
g
,
args
,
0
);
if
(
jvp
->
GetValType
()
!=
TYPE_JAR
)
{
arp
=
new
(
g
)
JARRAY
;
arp
->
AddValue
(
g
,
jvp
);
}
else
arp
=
jvp
->
GetArray
();
for
(
uint
i
=
1
;
i
<
args
->
arg_count
;
i
++
)
arp
->
AddValue
(
g
,
MakeValue
(
g
,
args
,
i
));
arp
->
InitArray
(
g
);
if
(
!
(
str
=
Serialize
(
g
,
arp
,
NULL
,
0
)))
str
=
strcpy
(
result
,
g
->
Message
);
*
res_length
=
strlen
(
str
);
return
str
;
}
// end of Json_Array_Add
void
Json_Array_Add_deinit
(
UDF_INIT
*
initid
)
{
PlugExit
((
PGLOBAL
)
initid
->
ptr
);
}
// end of Json_Array_Add_deinit
/***********************************************************************/
/***********************************************************************/
/* Make a Json Oject containing all the parameters. */
/* Make a Json Oject containing all the parameters. */
/***********************************************************************/
/***********************************************************************/
...
@@ -370,7 +442,7 @@ void Json_Object_deinit(UDF_INIT* initid)
...
@@ -370,7 +442,7 @@ void Json_Object_deinit(UDF_INIT* initid)
/***********************************************************************/
/***********************************************************************/
my_bool
Json_Array_Grp_init
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
message
)
my_bool
Json_Array_Grp_init
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
message
)
{
{
unsigned
long
reslen
,
memlen
,
n
=
10
;
unsigned
long
reslen
,
memlen
,
n
=
GetJsonGrpSize
()
;
if
(
args
->
arg_count
!=
1
)
{
if
(
args
->
arg_count
!=
1
)
{
strcpy
(
message
,
"Json_Array_Grp can only accept 1 argument"
);
strcpy
(
message
,
"Json_Array_Grp can only accept 1 argument"
);
...
@@ -379,7 +451,7 @@ my_bool Json_Array_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
...
@@ -379,7 +451,7 @@ my_bool Json_Array_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
CalcLen
(
args
,
false
,
reslen
,
memlen
);
CalcLen
(
args
,
false
,
reslen
,
memlen
);
reslen
*=
n
;
reslen
*=
n
;
memlen
*=
n
;
memlen
+=
((
memlen
-
MEMFIX
)
*
(
n
-
1
))
;
if
(
JsonInit
(
initid
,
message
,
reslen
,
memlen
))
if
(
JsonInit
(
initid
,
message
,
reslen
,
memlen
))
return
true
;
return
true
;
...
@@ -388,6 +460,7 @@ my_bool Json_Array_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
...
@@ -388,6 +460,7 @@ my_bool Json_Array_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
PlugSubSet
(
g
,
g
->
Sarea
,
g
->
Sarea_Size
);
PlugSubSet
(
g
,
g
->
Sarea
,
g
->
Sarea_Size
);
g
->
Activityp
=
(
PACTIVITY
)
new
(
g
)
JARRAY
;
g
->
Activityp
=
(
PACTIVITY
)
new
(
g
)
JARRAY
;
g
->
N
=
(
int
)
n
;
return
false
;
return
false
;
}
// end of Json_Array_Grp_init
}
// end of Json_Array_Grp_init
...
@@ -397,7 +470,9 @@ void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args,
...
@@ -397,7 +470,9 @@ void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args,
PGLOBAL
g
=
(
PGLOBAL
)
initid
->
ptr
;
PGLOBAL
g
=
(
PGLOBAL
)
initid
->
ptr
;
PJAR
arp
=
(
PJAR
)
g
->
Activityp
;
PJAR
arp
=
(
PJAR
)
g
->
Activityp
;
if
(
g
->
N
--
>
0
)
arp
->
AddValue
(
g
,
MakeValue
(
g
,
args
,
0
));
arp
->
AddValue
(
g
,
MakeValue
(
g
,
args
,
0
));
}
// end of Json_Array_Grp_add
}
// end of Json_Array_Grp_add
char
*
Json_Array_Grp
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
result
,
char
*
Json_Array_Grp
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
result
,
...
@@ -407,6 +482,10 @@ char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result,
...
@@ -407,6 +482,10 @@ char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result,
PGLOBAL
g
=
(
PGLOBAL
)
initid
->
ptr
;
PGLOBAL
g
=
(
PGLOBAL
)
initid
->
ptr
;
PJAR
arp
=
(
PJAR
)
g
->
Activityp
;
PJAR
arp
=
(
PJAR
)
g
->
Activityp
;
if
(
g
->
N
<
0
)
push_warning
(
current_thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
0
,
"Result truncated to json_grp_size values"
);
arp
->
InitArray
(
g
);
arp
->
InitArray
(
g
);
if
(
!
(
str
=
Serialize
(
g
,
arp
,
NULL
,
0
)))
if
(
!
(
str
=
Serialize
(
g
,
arp
,
NULL
,
0
)))
...
@@ -422,6 +501,7 @@ void Json_Array_Grp_clear(UDF_INIT *initid, char *is_null, char *error)
...
@@ -422,6 +501,7 @@ void Json_Array_Grp_clear(UDF_INIT *initid, char *is_null, char *error)
PlugSubSet
(
g
,
g
->
Sarea
,
g
->
Sarea_Size
);
PlugSubSet
(
g
,
g
->
Sarea
,
g
->
Sarea_Size
);
g
->
Activityp
=
(
PACTIVITY
)
new
(
g
)
JARRAY
;
g
->
Activityp
=
(
PACTIVITY
)
new
(
g
)
JARRAY
;
g
->
N
=
GetJsonGrpSize
();
}
// end of Json_Array_Grp_clear
}
// end of Json_Array_Grp_clear
void
Json_Array_Grp_deinit
(
UDF_INIT
*
initid
)
void
Json_Array_Grp_deinit
(
UDF_INIT
*
initid
)
...
@@ -434,7 +514,7 @@ void Json_Array_Grp_deinit(UDF_INIT* initid)
...
@@ -434,7 +514,7 @@ void Json_Array_Grp_deinit(UDF_INIT* initid)
/***********************************************************************/
/***********************************************************************/
my_bool
Json_Object_Grp_init
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
message
)
my_bool
Json_Object_Grp_init
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
message
)
{
{
unsigned
long
reslen
,
memlen
,
n
=
10
;
unsigned
long
reslen
,
memlen
,
n
=
GetJsonGrpSize
()
;
if
(
args
->
arg_count
!=
2
)
{
if
(
args
->
arg_count
!=
2
)
{
strcpy
(
message
,
"Json_Array_Grp can only accept 2 argument"
);
strcpy
(
message
,
"Json_Array_Grp can only accept 2 argument"
);
...
@@ -443,7 +523,7 @@ my_bool Json_Object_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
...
@@ -443,7 +523,7 @@ my_bool Json_Object_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
CalcLen
(
args
,
true
,
reslen
,
memlen
);
CalcLen
(
args
,
true
,
reslen
,
memlen
);
reslen
*=
n
;
reslen
*=
n
;
memlen
*=
n
;
memlen
+=
((
memlen
-
MEMFIX
)
*
(
n
-
1
))
;
if
(
JsonInit
(
initid
,
message
,
reslen
,
memlen
))
if
(
JsonInit
(
initid
,
message
,
reslen
,
memlen
))
return
true
;
return
true
;
...
@@ -452,6 +532,7 @@ my_bool Json_Object_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
...
@@ -452,6 +532,7 @@ my_bool Json_Object_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
PlugSubSet
(
g
,
g
->
Sarea
,
g
->
Sarea_Size
);
PlugSubSet
(
g
,
g
->
Sarea
,
g
->
Sarea_Size
);
g
->
Activityp
=
(
PACTIVITY
)
new
(
g
)
JOBJECT
;
g
->
Activityp
=
(
PACTIVITY
)
new
(
g
)
JOBJECT
;
g
->
N
=
(
int
)
n
;
return
false
;
return
false
;
}
// end of Json_Object_Grp_init
}
// end of Json_Object_Grp_init
...
@@ -461,7 +542,9 @@ void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args,
...
@@ -461,7 +542,9 @@ void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args,
PGLOBAL
g
=
(
PGLOBAL
)
initid
->
ptr
;
PGLOBAL
g
=
(
PGLOBAL
)
initid
->
ptr
;
PJOB
objp
=
(
PJOB
)
g
->
Activityp
;
PJOB
objp
=
(
PJOB
)
g
->
Activityp
;
if
(
g
->
N
--
>
0
)
objp
->
SetValue
(
g
,
MakeValue
(
g
,
args
,
0
),
MakePSZ
(
g
,
args
,
1
));
objp
->
SetValue
(
g
,
MakeValue
(
g
,
args
,
0
),
MakePSZ
(
g
,
args
,
1
));
}
// end of Json_Object_Grp_add
}
// end of Json_Object_Grp_add
char
*
Json_Object_Grp
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
result
,
char
*
Json_Object_Grp
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
result
,
...
@@ -471,6 +554,10 @@ char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result,
...
@@ -471,6 +554,10 @@ char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *args, char *result,
PGLOBAL
g
=
(
PGLOBAL
)
initid
->
ptr
;
PGLOBAL
g
=
(
PGLOBAL
)
initid
->
ptr
;
PJOB
objp
=
(
PJOB
)
g
->
Activityp
;
PJOB
objp
=
(
PJOB
)
g
->
Activityp
;
if
(
g
->
N
<
0
)
push_warning
(
current_thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
0
,
"Result truncated to json_grp_size values"
);
if
(
!
(
str
=
Serialize
(
g
,
objp
,
NULL
,
0
)))
if
(
!
(
str
=
Serialize
(
g
,
objp
,
NULL
,
0
)))
str
=
strcpy
(
result
,
g
->
Message
);
str
=
strcpy
(
result
,
g
->
Message
);
...
@@ -484,6 +571,7 @@ void Json_Object_Grp_clear(UDF_INIT *initid, char *is_null, char *error)
...
@@ -484,6 +571,7 @@ void Json_Object_Grp_clear(UDF_INIT *initid, char *is_null, char *error)
PlugSubSet
(
g
,
g
->
Sarea
,
g
->
Sarea_Size
);
PlugSubSet
(
g
,
g
->
Sarea
,
g
->
Sarea_Size
);
g
->
Activityp
=
(
PACTIVITY
)
new
(
g
)
JOBJECT
;
g
->
Activityp
=
(
PACTIVITY
)
new
(
g
)
JOBJECT
;
g
->
N
=
GetJsonGrpSize
();
}
// end of Json_Object_Grp_clear
}
// end of Json_Object_Grp_clear
void
Json_Object_Grp_deinit
(
UDF_INIT
*
initid
)
void
Json_Object_Grp_deinit
(
UDF_INIT
*
initid
)
...
...
storage/connect/plgdbutl.cpp
View file @
723be516
...
@@ -311,7 +311,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
...
@@ -311,7 +311,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
else
else
crp
->
Kdata
=
NULL
;
crp
->
Kdata
=
NULL
;
if
(
g
->
T
race
)
if
(
t
race
)
htrc
(
"Column(%d) %s type=%d len=%d value=%p
\n
"
,
htrc
(
"Column(%d) %s type=%d len=%d value=%p
\n
"
,
crp
->
Ncol
,
crp
->
Name
,
crp
->
Type
,
crp
->
Length
,
crp
->
Kdata
);
crp
->
Ncol
,
crp
->
Name
,
crp
->
Type
,
crp
->
Length
,
crp
->
Kdata
);
...
...
storage/connect/plugutil.c
View file @
723be516
...
@@ -144,12 +144,12 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
...
@@ -144,12 +144,12 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
return
NULL
;
return
NULL
;
}
else
{
}
else
{
g
->
Sarea_Size
=
worksize
;
g
->
Sarea_Size
=
worksize
;
g
->
Trace
=
0
;
g
->
Createas
=
0
;
g
->
Createas
=
0
;
g
->
Alchecked
=
0
;
g
->
Alchecked
=
0
;
g
->
Mrr
=
0
;
g
->
Mrr
=
0
;
g
->
Activityp
=
g
->
ActivityStart
=
NULL
;
g
->
Activityp
=
g
->
ActivityStart
=
NULL
;
g
->
Xchk
=
NULL
;
g
->
Xchk
=
NULL
;
g
->
N
=
0
;
strcpy
(
g
->
Message
,
""
);
strcpy
(
g
->
Message
,
""
);
/*******************************************************************/
/*******************************************************************/
...
...
storage/connect/tabjson.cpp
View file @
723be516
...
@@ -931,7 +931,11 @@ void JSONCOL::WriteColumn(PGLOBAL g)
...
@@ -931,7 +931,11 @@ void JSONCOL::WriteColumn(PGLOBAL g)
case
TYPE_STRING
:
case
TYPE_STRING
:
if
(
Nodes
[
Nod
-
1
].
Op
==
OP_XX
)
{
if
(
Nodes
[
Nod
-
1
].
Op
==
OP_XX
)
{
s
=
Value
->
GetCharValue
();
s
=
Value
->
GetCharValue
();
jsp
=
ParseJson
(
g
,
s
,
(
int
)
strlen
(
s
),
0
);
if
(
!
(
jsp
=
ParseJson
(
g
,
s
,
(
int
)
strlen
(
s
),
0
)))
{
strcpy
(
g
->
Message
,
s
);
longjmp
(
g
->
jumper
[
g
->
jump_level
],
666
);
}
// endif jsp
if
(
arp
)
{
if
(
arp
)
{
if
(
Nod
>
1
&&
Nodes
[
Nod
-
2
].
Rank
)
if
(
Nod
>
1
&&
Nodes
[
Nod
-
2
].
Rank
)
...
...
storage/connect/tabodbc.cpp
View file @
723be516
...
@@ -787,7 +787,7 @@ bool TDBODBC::OpenDB(PGLOBAL g)
...
@@ -787,7 +787,7 @@ bool TDBODBC::OpenDB(PGLOBAL g)
{
{
bool
rc
=
true
;
bool
rc
=
true
;
if
(
g
->
T
race
)
if
(
t
race
)
htrc
(
"ODBC OpenDB: tdbp=%p tdb=R%d use=%dmode=%d
\n
"
,
htrc
(
"ODBC OpenDB: tdbp=%p tdb=R%d use=%dmode=%d
\n
"
,
this
,
Tdb_No
,
Use
,
Mode
);
this
,
Tdb_No
,
Use
,
Mode
);
...
@@ -1185,12 +1185,12 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
...
@@ -1185,12 +1185,12 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
}
// endif Buf_Type
}
// endif Buf_Type
if
(
g
->
T
race
)
{
if
(
t
race
)
{
char
buf
[
64
];
char
buf
[
64
];
htrc
(
"ODBC Column %s: rows=%d buf=%p type=%d value=%s
\n
"
,
htrc
(
"ODBC Column %s: rows=%d buf=%p type=%d value=%s
\n
"
,
Name
,
tdbp
->
Rows
,
Bufp
,
Buf_Type
,
Value
->
GetCharString
(
buf
));
Name
,
tdbp
->
Rows
,
Bufp
,
Buf_Type
,
Value
->
GetCharString
(
buf
));
}
// endif
T
race
}
// endif
t
race
put:
put:
if
(
tdbp
->
Memory
!=
2
)
if
(
tdbp
->
Memory
!=
2
)
...
@@ -1424,7 +1424,7 @@ bool TDBXDBC::OpenDB(PGLOBAL g)
...
@@ -1424,7 +1424,7 @@ bool TDBXDBC::OpenDB(PGLOBAL g)
{
{
bool
rc
=
false
;
bool
rc
=
false
;
if
(
g
->
T
race
)
if
(
t
race
)
htrc
(
"ODBC OpenDB: tdbp=%p tdb=R%d use=%dmode=%d
\n
"
,
htrc
(
"ODBC OpenDB: tdbp=%p tdb=R%d use=%dmode=%d
\n
"
,
this
,
Tdb_No
,
Use
,
Mode
);
this
,
Tdb_No
,
Use
,
Mode
);
...
...
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