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
22a64047
Commit
22a64047
authored
Aug 11, 2014
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-6274 Collation usage statistics
Adding collation usage statistics into the feedback plugin I_S table.
parent
4105cbf4
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
99 additions
and
2 deletions
+99
-2
include/my_sys.h
include/my_sys.h
+5
-0
mysql-test/suite/plugins/r/feedback_plugin_load.result
mysql-test/suite/plugins/r/feedback_plugin_load.result
+9
-0
mysql-test/suite/plugins/t/feedback_plugin_load.test
mysql-test/suite/plugins/t/feedback_plugin_load.test
+13
-0
mysys/charset.c
mysys/charset.c
+50
-1
plugin/feedback/feedback.cc
plugin/feedback/feedback.cc
+2
-1
plugin/feedback/feedback.h
plugin/feedback/feedback.h
+1
-0
plugin/feedback/utils.cc
plugin/feedback/utils.cc
+19
-0
No files found.
include/my_sys.h
View file @
22a64047
...
...
@@ -242,6 +242,11 @@ extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *default_charset_info;
extern
MYSQL_PLUGIN_IMPORT
CHARSET_INFO
*
all_charsets
[
MY_ALL_CHARSETS_SIZE
];
extern
struct
charset_info_st
compiled_charsets
[];
/* Collation properties and use statistics */
extern
my_bool
my_collation_is_known_id
(
uint
id
);
extern
ulonglong
my_collation_statistics_get_use_count
(
uint
id
);
extern
const
char
*
my_collation_get_tailoring
(
uint
id
);
/* statistics */
extern
ulong
my_file_opened
,
my_stream_opened
,
my_tmp_file_created
;
extern
ulong
my_file_total_opened
;
...
...
mysql-test/suite/plugins/r/feedback_plugin_load.result
View file @
22a64047
...
...
@@ -10,3 +10,12 @@ FEEDBACK_SEND_RETRY_WAIT 60
FEEDBACK_SEND_TIMEOUT 60
FEEDBACK_URL http://mariadb.org/feedback_plugin/post
FEEDBACK_USER_INFO mysql-test
SELECT VARIABLE_VALUE>0, VARIABLE_NAME FROM INFORMATION_SCHEMA.FEEDBACK
WHERE VARIABLE_NAME LIKE 'Collation used %'
ORDER BY VARIABLE_NAME;
VARIABLE_VALUE>0 VARIABLE_NAME
1 Collation used binary
1 Collation used latin1_bin
1 Collation used latin1_swedish_ci
1 Collation used utf8_bin
1 Collation used utf8_general_ci
mysql-test/suite/plugins/t/feedback_plugin_load.test
View file @
22a64047
...
...
@@ -8,3 +8,16 @@ select plugin_status from information_schema.plugins where plugin_name='feedback
--
sorted_result
select
*
from
information_schema
.
feedback
where
variable_name
like
'feed%'
and
variable_name
not
like
'%_uid'
;
# Embedded server does not use the table mysqld.user and thus
# does not automatically use latin1_bin on startup. Use it manually.
--
disable_query_log
if
(
`SELECT VERSION() LIKE '%embedded%'`
)
{
DO
_latin1
'test'
COLLATE
latin1_bin
;
}
--
enable_query_log
SELECT
VARIABLE_VALUE
>
0
,
VARIABLE_NAME
FROM
INFORMATION_SCHEMA
.
FEEDBACK
WHERE
VARIABLE_NAME
LIKE
'Collation used %'
ORDER
BY
VARIABLE_NAME
;
mysys/charset.c
View file @
22a64047
...
...
@@ -483,6 +483,50 @@ void add_compiled_collation(struct charset_info_st *cs)
static
my_pthread_once_t
charsets_initialized
=
MY_PTHREAD_ONCE_INIT
;
static
my_pthread_once_t
charsets_template
=
MY_PTHREAD_ONCE_INIT
;
typedef
struct
{
ulonglong
use_count
;
}
MY_COLLATION_STATISTICS
;
static
MY_COLLATION_STATISTICS
my_collation_statistics
[
MY_ALL_CHARSETS_SIZE
];
my_bool
my_collation_is_known_id
(
uint
id
)
{
return
id
>
0
&&
id
<
array_elements
(
all_charsets
)
&&
all_charsets
[
id
]
?
TRUE
:
FALSE
;
}
/*
Collation use statistics functions do not lock
counters to avoid mutex contention. This can lose
some counter increments with high thread concurrency.
But this should be Ok, as we don't need exact numbers.
*/
static
inline
void
my_collation_statistics_inc_use_count
(
uint
id
)
{
DBUG_ASSERT
(
my_collation_is_known_id
(
id
));
my_collation_statistics
[
id
].
use_count
++
;
}
ulonglong
my_collation_statistics_get_use_count
(
uint
id
)
{
DBUG_ASSERT
(
my_collation_is_known_id
(
id
));
return
my_collation_statistics
[
id
].
use_count
;
}
const
char
*
my_collation_get_tailoring
(
uint
id
)
{
/* all_charsets[id]->tailoring is never changed after server startup. */
DBUG_ASSERT
(
my_collation_is_known_id
(
id
));
return
all_charsets
[
id
]
->
tailoring
;
}
static
void
init_available_charsets
(
void
)
{
char
fname
[
FN_REFLEN
+
sizeof
(
MY_CHARSET_INDEX
)];
...
...
@@ -490,6 +534,7 @@ static void init_available_charsets(void)
MY_CHARSET_LOADER
loader
;
bzero
((
char
*
)
&
all_charsets
,
sizeof
(
all_charsets
));
bzero
((
char
*
)
&
my_collation_statistics
,
sizeof
(
my_collation_statistics
));
init_compiled_charsets
(
MYF
(
0
));
/* Copy compiled charsets */
...
...
@@ -608,7 +653,10 @@ get_internal_charset(MY_CHARSET_LOADER *loader, uint cs_number, myf flags)
if
((
cs
=
(
struct
charset_info_st
*
)
all_charsets
[
cs_number
]))
{
if
(
cs
->
state
&
MY_CS_READY
)
/* if CS is already initialized */
{
my_collation_statistics_inc_use_count
(
cs_number
);
return
cs
;
}
/*
To make things thread safe we are not allowing other threads to interfere
...
...
@@ -636,6 +684,7 @@ get_internal_charset(MY_CHARSET_LOADER *loader, uint cs_number, myf flags)
else
cs
->
state
|=
MY_CS_READY
;
}
my_collation_statistics_inc_use_count
(
cs_number
);
}
else
cs
=
NULL
;
...
...
plugin/feedback/feedback.cc
View file @
22a64047
...
...
@@ -217,7 +217,8 @@ int fill_feedback(THD *thd, TABLE_LIST *tables, COND *unused)
tables
->
schema_table
=
i_s_feedback
;
res
=
res
||
fill_plugin_version
(
thd
,
tables
)
||
fill_misc_data
(
thd
,
tables
)
||
fill_linux_info
(
thd
,
tables
);
||
fill_linux_info
(
thd
,
tables
)
||
fill_collation_statistics
(
thd
,
tables
);
return
res
;
}
...
...
plugin/feedback/feedback.h
View file @
22a64047
...
...
@@ -22,6 +22,7 @@ int fill_feedback(THD *thd, TABLE_LIST *tables, COND *cond);
int
fill_plugin_version
(
THD
*
thd
,
TABLE_LIST
*
tables
);
int
fill_misc_data
(
THD
*
thd
,
TABLE_LIST
*
tables
);
int
fill_linux_info
(
THD
*
thd
,
TABLE_LIST
*
tables
);
int
fill_collation_statistics
(
THD
*
thd
,
TABLE_LIST
*
tables
);
static
const
int
SERVER_UID_SIZE
=
29
;
extern
char
server_uid_buf
[
SERVER_UID_SIZE
+
1
],
*
user_info
;
...
...
plugin/feedback/utils.cc
View file @
22a64047
...
...
@@ -383,6 +383,25 @@ int fill_misc_data(THD *thd, TABLE_LIST *tables)
return
0
;
}
int
fill_collation_statistics
(
THD
*
thd
,
TABLE_LIST
*
tables
)
{
TABLE
*
table
=
tables
->
table
;
for
(
uint
id
=
1
;
id
<
MY_ALL_CHARSETS_SIZE
;
id
++
)
{
ulonglong
count
;
if
(
my_collation_is_known_id
(
id
)
&&
(
count
=
my_collation_statistics_get_use_count
(
id
)))
{
char
name
[
MY_CS_NAME_SIZE
+
32
];
size_t
namelen
=
my_snprintf
(
name
,
sizeof
(
name
),
"Collation used %s"
,
get_charset_name
(
id
));
INSERT2
(
name
,
namelen
,
(
count
,
UNSIGNED
));
}
}
return
0
;
};
/**
calculates the server unique identifier
...
...
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