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
b969a690
Commit
b969a690
authored
Aug 31, 2014
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: simplify sys_var::val* methods, introduce val_str_nolock()
parent
a4e7d339
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
30 deletions
+38
-30
sql/set_var.cc
sql/set_var.cc
+34
-27
sql/set_var.h
sql/set_var.h
+4
-3
No files found.
sql/set_var.cc
View file @
b969a690
...
...
@@ -261,12 +261,10 @@ bool sys_var::set_default(THD *thd, set_var* var)
}
#define do_num_val(T,CMD) \
do { \
mysql_mutex_lock(&LOCK_global_system_variables); \
T val= *(T*) value_ptr(thd, type, base); \
mysql_mutex_unlock(&LOCK_global_system_variables); \
CMD; \
#define do_num_val(T,CMD) \
do { \
T val= *(T*) value; \
CMD; \
} while (0)
#define case_for_integers(CMD) \
...
...
@@ -280,30 +278,30 @@ do { \
case SHOW_BOOL: do_num_val (bool,CMD); \
case SHOW_MY_BOOL: do_num_val (my_bool,CMD)
#define case_for_double(CMD)
\
#define case_for_double(CMD) \
case SHOW_DOUBLE: do_num_val (double,CMD)
#define case_get_string_as_lex_string \
case SHOW_CHAR: \
mysql_mutex_lock(&LOCK_global_system_variables); \
sval.str= (char*) value_ptr(thd, type, base); \
sval.length= sval.str ? strlen(sval.str) : 0; \
break; \
case SHOW_CHAR_PTR: \
mysql_mutex_lock(&LOCK_global_system_variables); \
sval.str= *(char**) value_ptr(thd, type, base); \
sval.length= sval.str ? strlen(sval.str) : 0; \
break; \
case SHOW_LEX_STRING: \
mysql_mutex_lock(&LOCK_global_system_variables); \
sval= *(LEX_STRING *) value_ptr(thd, type, base); \
#define case_get_string_as_lex_string \
case SHOW_CHAR: \
sval.str= (char*) value; \
sval.length= sval.str ? strlen(sval.str) : 0; \
break; \
case SHOW_CHAR_PTR: \
sval.str= *(char**) value; \
sval.length= sval.str ? strlen(sval.str) : 0; \
break; \
case SHOW_LEX_STRING: \
sval= *(LEX_STRING *) value; \
break
longlong
sys_var
::
val_int
(
bool
*
is_null
,
THD
*
thd
,
enum_var_type
type
,
LEX_STRING
*
base
)
THD
*
thd
,
enum_var_type
type
,
const
LEX_STRING
*
base
)
{
LEX_STRING
sval
;
AutoWLock
lock
(
&
PLock_global_system_variables
);
const
uchar
*
value
=
value_ptr
(
thd
,
type
,
base
);
*
is_null
=
false
;
switch
(
show_type
())
{
case_get_string_as_lex_string
;
...
...
@@ -318,13 +316,11 @@ longlong sys_var::val_int(bool *is_null,
if
(
!
(
*
is_null
=
!
sval
.
str
))
ret
=
longlong_from_string_with_check
(
system_charset_info
,
sval
.
str
,
sval
.
str
+
sval
.
length
);
mysql_mutex_unlock
(
&
LOCK_global_system_variables
);
return
ret
;
}
String
*
sys_var
::
val_str
(
String
*
str
,
THD
*
thd
,
enum_var_type
type
,
LEX_STRING
*
base
)
String
*
sys_var
::
val_str_nolock
(
String
*
str
,
THD
*
thd
,
const
uchar
*
value
)
{
LEX_STRING
sval
;
switch
(
show_type
())
...
...
@@ -339,16 +335,27 @@ String *sys_var::val_str(String *str,
if
(
!
sval
.
str
||
str
->
copy
(
sval
.
str
,
sval
.
length
,
system_charset_info
))
str
=
NULL
;
mysql_mutex_unlock
(
&
LOCK_global_system_variables
);
return
str
;
}
String
*
sys_var
::
val_str
(
String
*
str
,
THD
*
thd
,
enum_var_type
type
,
const
LEX_STRING
*
base
)
{
AutoWLock
lock
(
&
PLock_global_system_variables
);
const
uchar
*
value
=
value_ptr
(
thd
,
type
,
base
);
return
val_str_nolock
(
str
,
thd
,
value
);
}
double
sys_var
::
val_real
(
bool
*
is_null
,
THD
*
thd
,
enum_var_type
type
,
LEX_STRING
*
base
)
THD
*
thd
,
enum_var_type
type
,
const
LEX_STRING
*
base
)
{
LEX_STRING
sval
;
AutoWLock
lock
(
&
PLock_global_system_variables
);
const
uchar
*
value
=
value_ptr
(
thd
,
type
,
base
);
*
is_null
=
false
;
switch
(
show_type
())
{
case_get_string_as_lex_string
;
...
...
sql/set_var.h
View file @
b969a690
...
...
@@ -117,9 +117,10 @@ public:
bool
set_default
(
THD
*
thd
,
set_var
*
var
);
bool
update
(
THD
*
thd
,
set_var
*
var
);
longlong
val_int
(
bool
*
is_null
,
THD
*
thd
,
enum_var_type
type
,
LEX_STRING
*
base
);
String
*
val_str
(
String
*
str
,
THD
*
thd
,
enum_var_type
type
,
LEX_STRING
*
base
);
double
val_real
(
bool
*
is_null
,
THD
*
thd
,
enum_var_type
type
,
LEX_STRING
*
base
);
String
*
val_str_nolock
(
String
*
str
,
THD
*
thd
,
const
uchar
*
value
);
longlong
val_int
(
bool
*
is_null
,
THD
*
thd
,
enum_var_type
type
,
const
LEX_STRING
*
base
);
String
*
val_str
(
String
*
str
,
THD
*
thd
,
enum_var_type
type
,
const
LEX_STRING
*
base
);
double
val_real
(
bool
*
is_null
,
THD
*
thd
,
enum_var_type
type
,
const
LEX_STRING
*
base
);
SHOW_TYPE
show_type
()
{
return
show_val_type
;
}
int
scope
()
const
{
return
flags
&
SCOPE_MASK
;
}
...
...
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