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
3182938d
Commit
3182938d
authored
Aug 25, 2014
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move userstat tables to a plugin
parent
db8af318
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
413 additions
and
388 deletions
+413
-388
mysql-test/r/information_schema.result
mysql-test/r/information_schema.result
+15
-15
mysql-test/t/information_schema.test
mysql-test/t/information_schema.test
+6
-0
mysql-test/t/information_schema_db.test
mysql-test/t/information_schema_db.test
+1
-0
plugin/userstat/CMakeLists.txt
plugin/userstat/CMakeLists.txt
+4
-0
plugin/userstat/client_stats.cc
plugin/userstat/client_stats.cc
+97
-0
plugin/userstat/index_stats.cc
plugin/userstat/index_stats.cc
+72
-0
plugin/userstat/table_stats.cc
plugin/userstat/table_stats.cc
+73
-0
plugin/userstat/user_stats.cc
plugin/userstat/user_stats.cc
+55
-0
plugin/userstat/userstat.cc
plugin/userstat/userstat.cc
+81
-0
sql/handler.h
sql/handler.h
+0
-4
sql/innodb_priv.h
sql/innodb_priv.h
+0
-1
sql/sql_acl.cc
sql/sql_acl.cc
+5
-0
sql/sql_acl.h
sql/sql_acl.h
+4
-4
sql/sql_parse.cc
sql/sql_parse.cc
+0
-4
sql/sql_parse.h
sql/sql_parse.h
+0
-13
sql/sql_show.cc
sql/sql_show.cc
+0
-347
No files found.
mysql-test/r/information_schema.result
View file @
3182938d
...
@@ -129,6 +129,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
...
@@ -129,6 +129,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_STATISTICS TABLE_STATISTICS
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
TRIGGERS TRIGGERS
t1 t1
t2 t2
t3 t3
t4 t4
t5 t5
table_stats table_stats
table_stats table_stats
tables_priv tables_priv
tables_priv tables_priv
time_zone time_zone
time_zone time_zone
...
@@ -136,11 +141,6 @@ time_zone_leap_second time_zone_leap_second
...
@@ -136,11 +141,6 @@ time_zone_leap_second time_zone_leap_second
time_zone_name time_zone_name
time_zone_name time_zone_name
time_zone_transition time_zone_transition
time_zone_transition time_zone_transition
time_zone_transition_type time_zone_transition_type
time_zone_transition_type time_zone_transition_type
t1 t1
t4 t4
t2 t2
t3 t3
t5 t5
select c,table_name from v1
select c,table_name from v1
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
where v1.c like "t%";
...
@@ -151,6 +151,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
...
@@ -151,6 +151,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_STATISTICS TABLE_STATISTICS
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
TRIGGERS TRIGGERS
t1 t1
t2 t2
t3 t3
t4 t4
t5 t5
table_stats table_stats
table_stats table_stats
tables_priv tables_priv
tables_priv tables_priv
time_zone time_zone
time_zone time_zone
...
@@ -158,11 +163,6 @@ time_zone_leap_second time_zone_leap_second
...
@@ -158,11 +163,6 @@ time_zone_leap_second time_zone_leap_second
time_zone_name time_zone_name
time_zone_name time_zone_name
time_zone_transition time_zone_transition
time_zone_transition time_zone_transition
time_zone_transition_type time_zone_transition_type
time_zone_transition_type time_zone_transition_type
t1 t1
t4 t4
t2 t2
t3 t3
t5 t5
select c, v2.table_name from v1
select c, v2.table_name from v1
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
where v1.c like "t%";
...
@@ -173,6 +173,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
...
@@ -173,6 +173,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_STATISTICS TABLE_STATISTICS
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
TRIGGERS TRIGGERS
t1 t1
t2 t2
t3 t3
t4 t4
t5 t5
table_stats table_stats
table_stats table_stats
tables_priv tables_priv
tables_priv tables_priv
time_zone time_zone
time_zone time_zone
...
@@ -180,11 +185,6 @@ time_zone_leap_second time_zone_leap_second
...
@@ -180,11 +185,6 @@ time_zone_leap_second time_zone_leap_second
time_zone_name time_zone_name
time_zone_name time_zone_name
time_zone_transition time_zone_transition
time_zone_transition time_zone_transition
time_zone_transition_type time_zone_transition_type
time_zone_transition_type time_zone_transition_type
t1 t1
t4 t4
t2 t2
t3 t3
t5 t5
select table_name from information_schema.TABLES
select table_name from information_schema.TABLES
where table_schema = "mysqltest" and table_name like "t%";
where table_schema = "mysqltest" and table_name like "t%";
table_name
table_name
...
...
mysql-test/t/information_schema.test
View file @
3182938d
...
@@ -55,14 +55,17 @@ create view v1 (c) as
...
@@ -55,14 +55,17 @@ create view v1 (c) as
--
sorted_result
--
sorted_result
select
*
from
v1
;
select
*
from
v1
;
--
sorted_result
select
c
,
table_name
from
v1
select
c
,
table_name
from
v1
inner
join
information_schema
.
TABLES
v2
on
(
v1
.
c
=
v2
.
table_name
)
inner
join
information_schema
.
TABLES
v2
on
(
v1
.
c
=
v2
.
table_name
)
where
v1
.
c
like
"t%"
;
where
v1
.
c
like
"t%"
;
--
sorted_result
select
c
,
table_name
from
v1
select
c
,
table_name
from
v1
left
join
information_schema
.
TABLES
v2
on
(
v1
.
c
=
v2
.
table_name
)
left
join
information_schema
.
TABLES
v2
on
(
v1
.
c
=
v2
.
table_name
)
where
v1
.
c
like
"t%"
;
where
v1
.
c
like
"t%"
;
--
sorted_result
select
c
,
v2
.
table_name
from
v1
select
c
,
v2
.
table_name
from
v1
right
join
information_schema
.
TABLES
v2
on
(
v1
.
c
=
v2
.
table_name
)
right
join
information_schema
.
TABLES
v2
on
(
v1
.
c
=
v2
.
table_name
)
where
v1
.
c
like
"t%"
;
where
v1
.
c
like
"t%"
;
...
@@ -368,17 +371,20 @@ drop view vo;
...
@@ -368,17 +371,20 @@ drop view vo;
select
TABLE_NAME
,
TABLE_TYPE
,
ENGINE
select
TABLE_NAME
,
TABLE_TYPE
,
ENGINE
from
information_schema
.
tables
from
information_schema
.
tables
where
table_schema
=
'information_schema'
limit
2
;
where
table_schema
=
'information_schema'
limit
2
;
--
sorted_result
show
tables
from
information_schema
like
"T%"
;
show
tables
from
information_schema
like
"T%"
;
--
error
ER_DBACCESS_DENIED_ERROR
--
error
ER_DBACCESS_DENIED_ERROR
create
database
information_schema
;
create
database
information_schema
;
use
information_schema
;
use
information_schema
;
--
sorted_result
show
full
tables
like
"T%"
;
show
full
tables
like
"T%"
;
--
error
ER_DBACCESS_DENIED_ERROR
--
error
ER_DBACCESS_DENIED_ERROR
create
table
t1
(
a
int
);
create
table
t1
(
a
int
);
use
test
;
use
test
;
show
tables
;
show
tables
;
use
information_schema
;
use
information_schema
;
--
sorted_result
show
tables
like
"T%"
;
show
tables
like
"T%"
;
#
#
...
...
mysql-test/t/information_schema_db.test
View file @
3182938d
...
@@ -15,6 +15,7 @@ drop function if exists f2;
...
@@ -15,6 +15,7 @@ drop function if exists f2;
--
enable_warnings
--
enable_warnings
--
replace_result
'Tables_in_INFORMATION_SCHEMA (T%)'
'Tables_in_information_schema (T%)'
--
replace_result
'Tables_in_INFORMATION_SCHEMA (T%)'
'Tables_in_information_schema (T%)'
--
sorted_result
show
tables
from
INFORMATION_SCHEMA
like
'T%'
;
show
tables
from
INFORMATION_SCHEMA
like
'T%'
;
create
database
`inf%`
;
create
database
`inf%`
;
create
database
mbase
;
create
database
mbase
;
...
...
plugin/userstat/CMakeLists.txt
0 → 100644
View file @
3182938d
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/sql
)
MYSQL_ADD_PLUGIN
(
USERSTAT userstat.cc MANDATORY
)
plugin/userstat/client_stats.cc
0 → 100644
View file @
3182938d
static
ST_FIELD_INFO
client_stats_fields
[]
=
{
{
"CLIENT"
,
LIST_PROCESS_HOST_LEN
,
MYSQL_TYPE_STRING
,
0
,
0
,
"Client"
,
0
},
{
"TOTAL_CONNECTIONS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Total_connections"
,
0
},
{
"CONCURRENT_CONNECTIONS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Concurrent_connections"
,
0
},
{
"CONNECTED_TIME"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Connected_time"
,
0
},
{
"BUSY_TIME"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_DOUBLE
,
0
,
0
,
"Busy_time"
,
0
},
{
"CPU_TIME"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_DOUBLE
,
0
,
0
,
"Cpu_time"
,
0
},
{
"BYTES_RECEIVED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Bytes_received"
,
0
},
{
"BYTES_SENT"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Bytes_sent"
,
0
},
{
"BINLOG_BYTES_WRITTEN"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Binlog_bytes_written"
,
0
},
{
"ROWS_READ"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_read"
,
0
},
{
"ROWS_SENT"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_sent"
,
0
},
{
"ROWS_DELETED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_deleted"
,
0
},
{
"ROWS_INSERTED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_inserted"
,
0
},
{
"ROWS_UPDATED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_updated"
,
0
},
{
"SELECT_COMMANDS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Select_commands"
,
0
},
{
"UPDATE_COMMANDS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Update_commands"
,
0
},
{
"OTHER_COMMANDS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Other_commands"
,
0
},
{
"COMMIT_TRANSACTIONS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Commit_transactions"
,
0
},
{
"ROLLBACK_TRANSACTIONS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rollback_transactions"
,
0
},
{
"DENIED_CONNECTIONS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Denied_connections"
,
0
},
{
"LOST_CONNECTIONS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Lost_connections"
,
0
},
{
"ACCESS_DENIED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Access_denied"
,
0
},
{
"EMPTY_QUERIES"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Empty_queries"
,
0
},
{
"MAX_STATEMENT_TIME_EXCEEDED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Max_statement_time_exceeded"
,
SKIP_OPEN_TABLE
},
{
0
,
0
,
MYSQL_TYPE_STRING
,
0
,
0
,
0
,
0
}
};
static
int
send_user_stats
(
THD
*
thd
,
HASH
*
all_user_stats
,
TABLE
*
table
)
{
mysql_mutex_lock
(
&
LOCK_global_user_client_stats
);
for
(
uint
i
=
0
;
i
<
all_user_stats
->
records
;
i
++
)
{
uint
j
=
0
;
USER_STATS
*
user_stats
=
(
USER_STATS
*
)
my_hash_element
(
all_user_stats
,
i
);
table
->
field
[
j
++
]
->
store
(
user_stats
->
user
,
user_stats
->
user_name_length
,
system_charset_info
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
total_connections
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
concurrent_connections
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
connected_time
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
double
)
user_stats
->
busy_time
);
table
->
field
[
j
++
]
->
store
((
double
)
user_stats
->
cpu_time
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
bytes_received
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
bytes_sent
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
binlog_bytes_written
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
rows_read
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
rows_sent
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
rows_deleted
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
rows_inserted
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
rows_updated
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
select_commands
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
update_commands
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
other_commands
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
commit_trans
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
rollback_trans
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
denied_connections
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
lost_connections
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
access_denied_errors
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
empty_queries
,
TRUE
);
table
->
field
[
j
++
]
->
store
((
longlong
)
user_stats
->
max_statement_time_exceeded
,
TRUE
);
if
(
schema_table_store_record
(
thd
,
table
))
{
mysql_mutex_unlock
(
&
LOCK_global_user_client_stats
);
return
1
;
}
}
mysql_mutex_unlock
(
&
LOCK_global_user_client_stats
);
return
0
;
}
static
int
client_stats_fill
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
{
if
(
check_global_access
(
thd
,
SUPER_ACL
|
PROCESS_ACL
,
true
))
return
0
;
return
send_user_stats
(
thd
,
&
global_client_stats
,
tables
->
table
);
}
static
int
client_stats_reset
()
{
mysql_mutex_lock
(
&
LOCK_global_user_client_stats
);
free_global_client_stats
();
init_global_client_stats
();
mysql_mutex_unlock
(
&
LOCK_global_user_client_stats
);
return
0
;
}
static
int
client_stats_init
(
void
*
p
)
{
ST_SCHEMA_TABLE
*
schema
=
(
ST_SCHEMA_TABLE
*
)
p
;
schema
->
fields_info
=
client_stats_fields
;
schema
->
fill_table
=
client_stats_fill
;
schema
->
reset_table
=
client_stats_reset
;
return
0
;
}
plugin/userstat/index_stats.cc
0 → 100644
View file @
3182938d
static
ST_FIELD_INFO
index_stats_fields
[]
=
{
{
"TABLE_SCHEMA"
,
NAME_LEN
,
MYSQL_TYPE_STRING
,
0
,
0
,
"Table_schema"
,
SKIP_OPEN_TABLE
},
{
"TABLE_NAME"
,
NAME_LEN
,
MYSQL_TYPE_STRING
,
0
,
0
,
"Table_name"
,
SKIP_OPEN_TABLE
},
{
"INDEX_NAME"
,
NAME_LEN
,
MYSQL_TYPE_STRING
,
0
,
0
,
"Index_name"
,
SKIP_OPEN_TABLE
},
{
"ROWS_READ"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_read"
,
SKIP_OPEN_TABLE
},
{
0
,
0
,
MYSQL_TYPE_STRING
,
0
,
0
,
0
,
0
}
};
static
int
index_stats_fill
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
{
TABLE
*
table
=
tables
->
table
;
mysql_mutex_lock
(
&
LOCK_global_index_stats
);
for
(
uint
i
=
0
;
i
<
global_index_stats
.
records
;
i
++
)
{
INDEX_STATS
*
index_stats
=
(
INDEX_STATS
*
)
my_hash_element
(
&
global_index_stats
,
i
);
TABLE_LIST
tmp_table
;
char
*
index_name
;
size_t
schema_name_length
,
table_name_length
,
index_name_length
;
bzero
((
char
*
)
&
tmp_table
,
sizeof
(
tmp_table
));
tmp_table
.
db
=
index_stats
->
index
;
tmp_table
.
table_name
=
strend
(
index_stats
->
index
)
+
1
;
tmp_table
.
grant
.
privilege
=
0
;
if
(
check_access
(
thd
,
SELECT_ACL
,
tmp_table
.
db
,
&
tmp_table
.
grant
.
privilege
,
NULL
,
0
,
1
)
||
check_grant
(
thd
,
SELECT_ACL
,
&
tmp_table
,
1
,
UINT_MAX
,
1
))
continue
;
index_name
=
strend
(
tmp_table
.
table_name
)
+
1
;
schema_name_length
=
(
tmp_table
.
table_name
-
index_stats
->
index
)
-
1
;
table_name_length
=
(
index_name
-
tmp_table
.
table_name
)
-
1
;
index_name_length
=
(
index_stats
->
index_name_length
-
schema_name_length
-
table_name_length
-
3
);
table
->
field
[
0
]
->
store
(
tmp_table
.
db
,
schema_name_length
,
system_charset_info
);
table
->
field
[
1
]
->
store
(
tmp_table
.
table_name
,
table_name_length
,
system_charset_info
);
table
->
field
[
2
]
->
store
(
index_name
,
index_name_length
,
system_charset_info
);
table
->
field
[
3
]
->
store
((
longlong
)
index_stats
->
rows_read
,
TRUE
);
if
(
schema_table_store_record
(
thd
,
table
))
{
mysql_mutex_unlock
(
&
LOCK_global_index_stats
);
return
1
;
}
}
mysql_mutex_unlock
(
&
LOCK_global_index_stats
);
return
0
;
}
static
int
index_stats_reset
()
{
mysql_mutex_lock
(
&
LOCK_global_index_stats
);
free_global_index_stats
();
init_global_index_stats
();
mysql_mutex_unlock
(
&
LOCK_global_index_stats
);
return
0
;
}
static
int
index_stats_init
(
void
*
p
)
{
ST_SCHEMA_TABLE
*
schema
=
(
ST_SCHEMA_TABLE
*
)
p
;
schema
->
fields_info
=
index_stats_fields
;
schema
->
fill_table
=
index_stats_fill
;
schema
->
reset_table
=
index_stats_reset
;
return
0
;
}
plugin/userstat/table_stats.cc
0 → 100644
View file @
3182938d
static
ST_FIELD_INFO
table_stats_fields
[]
=
{
{
"TABLE_SCHEMA"
,
NAME_LEN
,
MYSQL_TYPE_STRING
,
0
,
0
,
"Table_schema"
,
SKIP_OPEN_TABLE
},
{
"TABLE_NAME"
,
NAME_LEN
,
MYSQL_TYPE_STRING
,
0
,
0
,
"Table_name"
,
SKIP_OPEN_TABLE
},
{
"ROWS_READ"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_read"
,
SKIP_OPEN_TABLE
},
{
"ROWS_CHANGED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_changed"
,
SKIP_OPEN_TABLE
},
{
"ROWS_CHANGED_X_INDEXES"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_changed_x_#indexes"
,
SKIP_OPEN_TABLE
},
{
0
,
0
,
MYSQL_TYPE_STRING
,
0
,
0
,
0
,
0
}
};
static
int
table_stats_fill
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
{
TABLE
*
table
=
tables
->
table
;
mysql_mutex_lock
(
&
LOCK_global_table_stats
);
for
(
uint
i
=
0
;
i
<
global_table_stats
.
records
;
i
++
)
{
char
*
end_of_schema
;
TABLE_STATS
*
table_stats
=
(
TABLE_STATS
*
)
my_hash_element
(
&
global_table_stats
,
i
);
TABLE_LIST
tmp_table
;
size_t
schema_length
,
table_name_length
;
end_of_schema
=
strend
(
table_stats
->
table
);
schema_length
=
(
size_t
)
(
end_of_schema
-
table_stats
->
table
);
table_name_length
=
strlen
(
table_stats
->
table
+
schema_length
+
1
);
bzero
((
char
*
)
&
tmp_table
,
sizeof
(
tmp_table
));
tmp_table
.
db
=
table_stats
->
table
;
tmp_table
.
table_name
=
end_of_schema
+
1
;
tmp_table
.
grant
.
privilege
=
0
;
if
(
check_access
(
thd
,
SELECT_ACL
,
tmp_table
.
db
,
&
tmp_table
.
grant
.
privilege
,
NULL
,
0
,
1
)
||
check_grant
(
thd
,
SELECT_ACL
,
&
tmp_table
,
1
,
UINT_MAX
,
1
))
continue
;
table
->
field
[
0
]
->
store
(
table_stats
->
table
,
schema_length
,
system_charset_info
);
table
->
field
[
1
]
->
store
(
table_stats
->
table
+
schema_length
+
1
,
table_name_length
,
system_charset_info
);
table
->
field
[
2
]
->
store
((
longlong
)
table_stats
->
rows_read
,
TRUE
);
table
->
field
[
3
]
->
store
((
longlong
)
table_stats
->
rows_changed
,
TRUE
);
table
->
field
[
4
]
->
store
((
longlong
)
table_stats
->
rows_changed_x_indexes
,
TRUE
);
if
(
schema_table_store_record
(
thd
,
table
))
{
mysql_mutex_unlock
(
&
LOCK_global_table_stats
);
return
1
;
}
}
mysql_mutex_unlock
(
&
LOCK_global_table_stats
);
return
0
;
}
static
int
table_stats_reset
()
{
mysql_mutex_lock
(
&
LOCK_global_table_stats
);
free_global_table_stats
();
init_global_table_stats
();
mysql_mutex_unlock
(
&
LOCK_global_table_stats
);
return
0
;
}
static
int
table_stats_init
(
void
*
p
)
{
ST_SCHEMA_TABLE
*
schema
=
(
ST_SCHEMA_TABLE
*
)
p
;
schema
->
fields_info
=
table_stats_fields
;
schema
->
fill_table
=
table_stats_fill
;
schema
->
reset_table
=
table_stats_reset
;
return
0
;
}
plugin/userstat/user_stats.cc
0 → 100644
View file @
3182938d
static
ST_FIELD_INFO
user_stats_fields
[]
=
{
{
"USER"
,
USERNAME_CHAR_LENGTH
,
MYSQL_TYPE_STRING
,
0
,
0
,
"User"
,
0
},
{
"TOTAL_CONNECTIONS"
,
MY_INT32_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONG
,
0
,
0
,
"Total_connections"
,
0
},
{
"CONCURRENT_CONNECTIONS"
,
MY_INT32_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONG
,
0
,
0
,
"Concurrent_connections"
,
0
},
{
"CONNECTED_TIME"
,
MY_INT32_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONG
,
0
,
0
,
"Connected_time"
,
0
},
{
"BUSY_TIME"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_DOUBLE
,
0
,
0
,
"Busy_time"
,
0
},
{
"CPU_TIME"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_DOUBLE
,
0
,
0
,
"Cpu_time"
,
0
},
{
"BYTES_RECEIVED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Bytes_received"
,
0
},
{
"BYTES_SENT"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Bytes_sent"
,
0
},
{
"BINLOG_BYTES_WRITTEN"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Binlog_bytes_written"
,
0
},
{
"ROWS_READ"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_read"
,
0
},
{
"ROWS_SENT"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_sent"
,
0
},
{
"ROWS_DELETED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_deleted"
,
0
},
{
"ROWS_INSERTED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_inserted"
,
0
},
{
"ROWS_UPDATED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rows_updated"
,
0
},
{
"SELECT_COMMANDS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Select_commands"
,
0
},
{
"UPDATE_COMMANDS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Update_commands"
,
0
},
{
"OTHER_COMMANDS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Other_commands"
,
0
},
{
"COMMIT_TRANSACTIONS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Commit_transactions"
,
0
},
{
"ROLLBACK_TRANSACTIONS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Rollback_transactions"
,
0
},
{
"DENIED_CONNECTIONS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Denied_connections"
,
0
},
{
"LOST_CONNECTIONS"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Lost_connections"
,
0
},
{
"ACCESS_DENIED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Access_denied"
,
0
},
{
"EMPTY_QUERIES"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Empty_queries"
,
0
},
{
"MAX_STATEMENT_TIME_EXCEEDED"
,
MY_INT64_NUM_DECIMAL_DIGITS
,
MYSQL_TYPE_LONGLONG
,
0
,
0
,
"Max_statement_time_exceeded"
,
SKIP_OPEN_TABLE
},
{
0
,
0
,
MYSQL_TYPE_STRING
,
0
,
0
,
0
,
0
}
};
static
int
user_stats_fill
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
{
if
(
check_global_access
(
thd
,
SUPER_ACL
|
PROCESS_ACL
,
true
))
return
0
;
return
send_user_stats
(
thd
,
&
global_user_stats
,
tables
->
table
);
}
static
int
user_stats_reset
()
{
mysql_mutex_lock
(
&
LOCK_global_user_client_stats
);
free_global_user_stats
();
init_global_user_stats
();
mysql_mutex_unlock
(
&
LOCK_global_user_client_stats
);
return
0
;
}
static
int
user_stats_init
(
void
*
p
)
{
ST_SCHEMA_TABLE
*
schema
=
(
ST_SCHEMA_TABLE
*
)
p
;
schema
->
fields_info
=
user_stats_fields
;
schema
->
fill_table
=
user_stats_fill
;
schema
->
reset_table
=
user_stats_reset
;
return
0
;
}
plugin/userstat/userstat.cc
0 → 100644
View file @
3182938d
#include <mysql/plugin.h>
#include <mysql_version.h>
#include "table.h"
#include "sql_connect.h"
#include "field.h"
#include "sql_const.h"
#include "sql_acl.h"
bool
schema_table_store_record
(
THD
*
thd
,
TABLE
*
table
);
#include "client_stats.cc"
#include "index_stats.cc"
#include "table_stats.cc"
#include "user_stats.cc"
static
struct
st_mysql_information_schema
userstat_info
=
{
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION
};
maria_declare_plugin
(
userstat
)
{
MYSQL_INFORMATION_SCHEMA_PLUGIN
,
&
userstat_info
,
"CLIENT_STATISTICS"
,
"Percona and Sergei Golubchik"
,
"Client Statistics"
,
PLUGIN_LICENSE_GPL
,
client_stats_init
,
0
,
0x0200
,
NULL
,
NULL
,
"2.0"
,
MariaDB_PLUGIN_MATURITY_GAMMA
},
{
MYSQL_INFORMATION_SCHEMA_PLUGIN
,
&
userstat_info
,
"INDEX_STATISTICS"
,
"Percona and Sergei Golubchik"
,
"Index Statistics"
,
PLUGIN_LICENSE_GPL
,
index_stats_init
,
0
,
0x0200
,
NULL
,
NULL
,
"2.0"
,
MariaDB_PLUGIN_MATURITY_GAMMA
},
{
MYSQL_INFORMATION_SCHEMA_PLUGIN
,
&
userstat_info
,
"TABLE_STATISTICS"
,
"Percona and Sergei Golubchik"
,
"Table Statistics"
,
PLUGIN_LICENSE_GPL
,
table_stats_init
,
0
,
0x0200
,
NULL
,
NULL
,
"2.0"
,
MariaDB_PLUGIN_MATURITY_GAMMA
},
{
MYSQL_INFORMATION_SCHEMA_PLUGIN
,
&
userstat_info
,
"USER_STATISTICS"
,
"Percona and Sergei Golubchik"
,
"User Statistics"
,
PLUGIN_LICENSE_GPL
,
user_stats_init
,
0
,
0x0200
,
NULL
,
NULL
,
"2.0"
,
MariaDB_PLUGIN_MATURITY_GAMMA
}
maria_declare_plugin_end
;
sql/handler.h
View file @
3182938d
...
@@ -720,7 +720,6 @@ enum enum_schema_tables
...
@@ -720,7 +720,6 @@ enum enum_schema_tables
SCH_ALL_PLUGINS
,
SCH_ALL_PLUGINS
,
SCH_APPLICABLE_ROLES
,
SCH_APPLICABLE_ROLES
,
SCH_CHARSETS
,
SCH_CHARSETS
,
SCH_CLIENT_STATS
,
SCH_COLLATIONS
,
SCH_COLLATIONS
,
SCH_COLLATION_CHARACTER_SET_APPLICABILITY
,
SCH_COLLATION_CHARACTER_SET_APPLICABILITY
,
SCH_COLUMNS
,
SCH_COLUMNS
,
...
@@ -732,7 +731,6 @@ enum enum_schema_tables
...
@@ -732,7 +731,6 @@ enum enum_schema_tables
SCH_FILES
,
SCH_FILES
,
SCH_GLOBAL_STATUS
,
SCH_GLOBAL_STATUS
,
SCH_GLOBAL_VARIABLES
,
SCH_GLOBAL_VARIABLES
,
SCH_INDEX_STATS
,
SCH_KEY_CACHES
,
SCH_KEY_CACHES
,
SCH_KEY_COLUMN_USAGE
,
SCH_KEY_COLUMN_USAGE
,
SCH_OPEN_TABLES
,
SCH_OPEN_TABLES
,
...
@@ -754,10 +752,8 @@ enum enum_schema_tables
...
@@ -754,10 +752,8 @@ enum enum_schema_tables
SCH_TABLE_CONSTRAINTS
,
SCH_TABLE_CONSTRAINTS
,
SCH_TABLE_NAMES
,
SCH_TABLE_NAMES
,
SCH_TABLE_PRIVILEGES
,
SCH_TABLE_PRIVILEGES
,
SCH_TABLE_STATS
,
SCH_TRIGGERS
,
SCH_TRIGGERS
,
SCH_USER_PRIVILEGES
,
SCH_USER_PRIVILEGES
,
SCH_USER_STATS
,
SCH_VIEWS
SCH_VIEWS
};
};
...
...
sql/innodb_priv.h
View file @
3182938d
...
@@ -25,7 +25,6 @@ class THD;
...
@@ -25,7 +25,6 @@ class THD;
int
get_quote_char_for_identifier
(
THD
*
thd
,
const
char
*
name
,
uint
length
);
int
get_quote_char_for_identifier
(
THD
*
thd
,
const
char
*
name
,
uint
length
);
bool
schema_table_store_record
(
THD
*
thd
,
TABLE
*
table
);
bool
schema_table_store_record
(
THD
*
thd
,
TABLE
*
table
);
void
localtime_to_TIME
(
MYSQL_TIME
*
to
,
struct
tm
*
from
);
void
localtime_to_TIME
(
MYSQL_TIME
*
to
,
struct
tm
*
from
);
bool
check_global_access
(
THD
*
thd
,
ulong
want_access
,
bool
no_errors
=
false
);
uint
strconvert
(
CHARSET_INFO
*
from_cs
,
const
char
*
from
,
uint
from_length
,
uint
strconvert
(
CHARSET_INFO
*
from_cs
,
const
char
*
from
,
uint
from_length
,
CHARSET_INFO
*
to_cs
,
char
*
to
,
uint
to_length
,
CHARSET_INFO
*
to_cs
,
char
*
to
,
uint
to_length
,
uint
*
errors
);
uint
*
errors
);
...
...
sql/sql_acl.cc
View file @
3182938d
...
@@ -10206,6 +10206,11 @@ applicable_roles_insert(ACL_USER_BASE *grantee, ACL_ROLE *role, void *ptr)
...
@@ -10206,6 +10206,11 @@ applicable_roles_insert(ACL_USER_BASE *grantee, ACL_ROLE *role, void *ptr)
return
0
;
return
0
;
}
}
#else
bool
check_grant
(
THD
*
,
ulong
,
TABLE_LIST
*
,
bool
,
uint
,
bool
)
{
return
0
;
}
#endif
/*NO_EMBEDDED_ACCESS_CHECKS */
#endif
/*NO_EMBEDDED_ACCESS_CHECKS */
int
fill_schema_enabled_roles
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
int
fill_schema_enabled_roles
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
...
...
sql/sql_acl.h
View file @
3182938d
...
@@ -235,6 +235,10 @@ bool check_grant_all_columns(THD *thd, ulong want_access,
...
@@ -235,6 +235,10 @@ bool check_grant_all_columns(THD *thd, ulong want_access,
bool
check_grant_routine
(
THD
*
thd
,
ulong
want_access
,
bool
check_grant_routine
(
THD
*
thd
,
ulong
want_access
,
TABLE_LIST
*
procs
,
bool
is_proc
,
bool
no_error
);
TABLE_LIST
*
procs
,
bool
is_proc
,
bool
no_error
);
bool
check_grant_db
(
THD
*
thd
,
const
char
*
db
);
bool
check_grant_db
(
THD
*
thd
,
const
char
*
db
);
bool
check_global_access
(
THD
*
thd
,
ulong
want_access
,
bool
no_errors
=
false
);
bool
check_access
(
THD
*
thd
,
ulong
want_access
,
const
char
*
db
,
ulong
*
save_priv
,
GRANT_INTERNAL_INFO
*
grant_internal_info
,
bool
dont_check_global_grants
,
bool
no_errors
);
ulong
get_table_grant
(
THD
*
thd
,
TABLE_LIST
*
table
);
ulong
get_table_grant
(
THD
*
thd
,
TABLE_LIST
*
table
);
ulong
get_column_grant
(
THD
*
thd
,
GRANT_INFO
*
grant
,
ulong
get_column_grant
(
THD
*
thd
,
GRANT_INFO
*
grant
,
const
char
*
db_name
,
const
char
*
table_name
,
const
char
*
db_name
,
const
char
*
table_name
,
...
@@ -263,10 +267,6 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
...
@@ -263,10 +267,6 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
int
fill_schema_column_privileges
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
);
int
fill_schema_column_privileges
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
);
int
wild_case_compare
(
CHARSET_INFO
*
cs
,
const
char
*
str
,
const
char
*
wildstr
);
int
wild_case_compare
(
CHARSET_INFO
*
cs
,
const
char
*
str
,
const
char
*
wildstr
);
int
check_password_policy
(
String
*
password
);
int
check_password_policy
(
String
*
password
);
#ifdef NO_EMBEDDED_ACCESS_CHECKS
#define check_grant(A,B,C,D,E,F) 0
#define check_grant_db(A,B) 0
#endif
/**
/**
Result of an access check for an internal schema or table.
Result of an access check for an internal schema or table.
...
...
sql/sql_parse.cc
View file @
3182938d
...
@@ -2115,10 +2115,6 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
...
@@ -2115,10 +2115,6 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
thd
->
profiling
.
discard_current_query
();
thd
->
profiling
.
discard_current_query
();
#endif
#endif
break
;
break
;
case
SCH_USER_STATS
:
case
SCH_CLIENT_STATS
:
if
(
check_global_access
(
thd
,
SUPER_ACL
|
PROCESS_ACL
,
true
))
DBUG_RETURN
(
1
);
default:
default:
break
;
break
;
}
}
...
...
sql/sql_parse.h
View file @
3182938d
...
@@ -148,15 +148,6 @@ inline bool check_identifier_name(LEX_STRING *str)
...
@@ -148,15 +148,6 @@ inline bool check_identifier_name(LEX_STRING *str)
return
check_identifier_name
(
str
,
NAME_CHAR_LEN
,
0
,
""
);
return
check_identifier_name
(
str
,
NAME_CHAR_LEN
,
0
,
""
);
}
}
/*
check_access() is needed for the connect engine.
It cannot be inlined - it must be exported.
*/
bool
check_access
(
THD
*
thd
,
ulong
want_access
,
const
char
*
db
,
ulong
*
save_priv
,
GRANT_INTERNAL_INFO
*
grant_internal_info
,
bool
dont_check_global_grants
,
bool
no_errors
);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
bool
check_one_table_access
(
THD
*
thd
,
ulong
privilege
,
TABLE_LIST
*
tables
);
bool
check_one_table_access
(
THD
*
thd
,
ulong
privilege
,
TABLE_LIST
*
tables
);
bool
check_single_table_access
(
THD
*
thd
,
ulong
privilege
,
bool
check_single_table_access
(
THD
*
thd
,
ulong
privilege
,
...
@@ -194,8 +185,4 @@ check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables,
...
@@ -194,8 +185,4 @@ check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables,
{
return
false
;
}
{
return
false
;
}
#endif
/*NO_EMBEDDED_ACCESS_CHECKS*/
#endif
/*NO_EMBEDDED_ACCESS_CHECKS*/
/* These were under the INNODB_COMPATIBILITY_HOOKS */
bool
check_global_access
(
THD
*
thd
,
ulong
want_access
,
bool
no_errors
=
false
);
#endif
/* SQL_PARSE_INCLUDED */
#endif
/* SQL_PARSE_INCLUDED */
sql/sql_show.cc
View file @
3182938d
This diff is collapsed.
Click to expand it.
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