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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
d2afcc09
Commit
d2afcc09
authored
Oct 31, 2017
by
Sergey Vojtovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PROC_FDINFO plugin for workshop
parent
6c847192
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
+92
-0
plugin/proc_info/mysql-test/proc_info/fdinfo.test
plugin/proc_info/mysql-test/proc_info/fdinfo.test
+5
-0
plugin/proc_info/proc_info.cc
plugin/proc_info/proc_info.cc
+87
-0
No files found.
plugin/proc_info/mysql-test/proc_info/fdinfo.test
0 → 100644
View file @
d2afcc09
SHOW
CREATE
TABLE
INFORMATION_SCHEMA
.
PROC_FDINFO
;
query_vertical
SELECT
PLUGIN_NAME
,
PLUGIN_VERSION
,
PLUGIN_TYPE
,
PLUGIN_AUTHOR
,
PLUGIN_DESCRIPTION
,
PLUGIN_LICENSE
,
PLUGIN_MATURITY
FROM
INFORMATION_SCHEMA
.
PLUGINS
WHERE
PLUGIN_NAME
=
'proc_fdinfo'
;
SELECT
*
FROM
INFORMATION_SCHEMA
.
PROC_FDINFO
;
FLUSH
TABLES
;
SELECT
*
FROM
INFORMATION_SCHEMA
.
PROC_FDINFO
;
plugin/proc_info/proc_info.cc
View file @
d2afcc09
...
...
@@ -3,6 +3,7 @@
#include <sql_show.h>
#include <sql_class.h>
#include <mysql/plugin.h>
#include <dirent.h>
static
ST_FIELD_INFO
meminfo_fields
[]
=
...
...
@@ -58,6 +59,77 @@ static struct st_mysql_information_schema meminfo_plugin=
{
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION
};
static
ST_FIELD_INFO
fdinfo_fields
[]
=
{
{
"NAME"
,
100
,
MYSQL_TYPE_STRING
,
0
,
0
,
0
,
SKIP_OPEN_TABLE
},
{
"VALUE"
,
FN_REFLEN
,
MYSQL_TYPE_STRING
,
0
,
MY_I_S_MAYBE_NULL
,
0
,
SKIP_OPEN_TABLE
},
{
0
,
0
,
MYSQL_TYPE_STRING
,
0
,
0
,
0
,
0
}
};
static
int
fdinfo_fill
(
MYSQL_THD
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
)
{
TABLE
*
table
=
tables
->
table
;
int
fd
;
DIR
*
dir
;
struct
dirent
dirbuf
,
*
result
;
if
((
fd
=
open
(
"/proc/self/fd"
,
O_DIRECTORY
))
<
0
)
return
1
;
if
(
!
(
dir
=
fdopendir
(
fd
)))
{
close
(
fd
);
return
1
;
}
while
(
readdir_r
(
dir
,
&
dirbuf
,
&
result
)
==
0
&&
result
)
{
char
buf
[
FN_REFLEN
];
ssize_t
len
;
if
(
result
->
d_name
[
0
]
==
'.'
)
continue
;
len
=
readlinkat
(
fd
,
result
->
d_name
,
buf
,
sizeof
(
buf
));
table
->
field
[
0
]
->
store
(
result
->
d_name
,
strlen
(
result
->
d_name
),
system_charset_info
);
if
(
len
<
0
)
table
->
field
[
1
]
->
set_null
();
else
{
table
->
field
[
1
]
->
store
(
buf
,
len
,
system_charset_info
);
table
->
field
[
1
]
->
set_notnull
();
}
if
(
schema_table_store_record
(
thd
,
table
))
{
close
(
fd
);
closedir
(
dir
);
return
1
;
}
}
close
(
fd
);
closedir
(
dir
);
return
0
;
}
static
int
fdinfo_init
(
void
*
p
)
{
ST_SCHEMA_TABLE
*
schema
=
(
ST_SCHEMA_TABLE
*
)
p
;
schema
->
fields_info
=
fdinfo_fields
;
schema
->
fill_table
=
fdinfo_fill
;
return
0
;
}
static
struct
st_mysql_information_schema
fdinfo_plugin
=
{
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION
};
maria_declare_plugin
(
proc_info
)
{
MYSQL_INFORMATION_SCHEMA_PLUGIN
,
/* type */
...
...
@@ -73,5 +145,20 @@ maria_declare_plugin(proc_info)
NULL
,
/* system variables */
"1.0"
,
/* version as a string */
MariaDB_PLUGIN_MATURITY_EXPERIMENTAL
},
{
MYSQL_INFORMATION_SCHEMA_PLUGIN
,
/* type */
&
fdinfo_plugin
,
/* information schema */
"PROC_FDINFO"
,
/* name */
""
,
/* author */
"Useful information from /proc"
,
/* description */
PLUGIN_LICENSE_BSD
,
/* license */
fdinfo_init
,
/* init callback */
0
,
/* deinit callback */
0x0100
,
/* version as hex */
NULL
,
/* status variables */
NULL
,
/* system variables */
"1.0"
,
/* version as a string */
MariaDB_PLUGIN_MATURITY_EXPERIMENTAL
}
maria_declare_plugin_end
;
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