Skip to content

Instantly share code, notes, and snippets.

@yoku0825
Created December 17, 2022 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoku0825/4227b4f35ac566e2db277e65bdfde283 to your computer and use it in GitHub Desktop.
Save yoku0825/4227b4f35ac566e2db277e65bdfde283 to your computer and use it in GitHub Desktop.
pidを取るi_sプラグイン
MYSQL_ADD_PLUGIN(i_s_pid
i_s_pid.cc
MODULE_ONLY
MODULE_OUTPUT_NAME "i_s_pid"
)
#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