Created
December 17, 2022 15:23
-
-
Save yoku0825/4227b4f35ac566e2db277e65bdfde283 to your computer and use it in GitHub Desktop.
pidを取るi_sプラグイン
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MYSQL_ADD_PLUGIN(i_s_pid | |
i_s_pid.cc | |
MODULE_ONLY | |
MODULE_OUTPUT_NAME "i_s_pid" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/types.h> | |
#include <unistd.h> | |
#include <mysql/plugin.h> | |
#include <sql/table.h> | |
#include <sql/sql_show.h> | |
static struct st_mysql_information_schema info= | |
{ | |
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION | |
}; | |
static ST_FIELD_INFO myfields[]= | |
{ | |
{"pid", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, MY_I_S_UNSIGNED, 0, 0}, | |
{0, 0, MYSQL_TYPE_NULL, 0, 0, 0, 0} | |
}; | |
static int fill (THD *thd, TABLE_LIST *tables, Item *cond) | |
{ | |
TABLE *table= tables->table; | |
table->field[0]->store((uint) getpid()); | |
//table->file->ha_write_row(table->record[0]); | |
if (schema_table_store_record(thd, table)) | |
return 1; | |
return 0; | |
} | |
static int init (void *ptr) | |
{ | |
ST_SCHEMA_TABLE *schema_table= (ST_SCHEMA_TABLE*) ptr; | |
schema_table->fields_info= myfields; | |
schema_table->fill_table= fill; | |
return 0; | |
} | |
mysql_declare_plugin (i_s_pid) | |
{ | |
MYSQL_INFORMATION_SCHEMA_PLUGIN, | |
&info, | |
"i_s_pid", | |
"yoku0825", | |
"information_schema plugin example", | |
PLUGIN_LICENSE_GPL, | |
init, | |
NULL, | |
NULL, | |
0x0001, | |
NULL, | |
NULL, | |
NULL, | |
0 | |
} | |
mysql_declare_plugin_end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment