[Groonga-mysql-commit] mroonga/mroonga [master] Added information schema plugin for groonga.

Back to archive index

null+****@clear***** null+****@clear*****
2010年 9月 13日 (月) 21:56:17 JST


Yoshinori Matsunobu	2010-09-13 12:56:17 +0000 (Mon, 13 Sep 2010)

  New Revision: 2460e3e69373e57b130720bfcc836d5d0624c75e

  Log:
    Added information schema plugin for groonga.

  Modified files:
    ha_mroonga.cc

  Modified: ha_mroonga.cc (+90 -1)
===================================================================
--- ha_mroonga.cc    2010-09-13 12:21:38 +0000 (01cf6b5)
+++ ha_mroonga.cc    2010-09-13 12:56:17 +0000 (b7ea96a)
@@ -77,6 +77,95 @@ struct st_mysql_sys_var *mrn_system_variables[] =
   NULL
 };
 
+
+/* Groonga information schema */
+int GROONGA_VERSION_SHORT = 0x0001;
+static const char plugin_author[] = "Yoshinori Matsunobu";
+static struct st_mysql_information_schema	i_s_info =
+{
+	MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION
+};
+
+static ST_FIELD_INFO	i_s_groonga_stats_fields_info[] =
+{
+  {
+    "VERSION",
+    40,
+    MYSQL_TYPE_STRING,
+    0,
+    0,
+    "",
+    SKIP_OPEN_TABLE
+  },
+  {
+    "rows_written",
+    MY_INT32_NUM_DECIMAL_DIGITS,
+    MYSQL_TYPE_LONG,
+    0,
+    0,
+    "Rows written to groonga",
+    SKIP_OPEN_TABLE
+  },
+  {
+    "rows_read",
+    MY_INT32_NUM_DECIMAL_DIGITS,
+    MYSQL_TYPE_LONG,
+    0,
+    0,
+    "Rows read from groonga",
+    SKIP_OPEN_TABLE
+  }
+};
+
+static int i_s_groonga_stats_deinit(void* p)
+{
+  DBUG_ENTER("i_s_common_deinit");
+  DBUG_RETURN(0);
+}
+
+static int i_s_groonga_stats_fill(
+  THD* thd, TABLE_LIST* tables, COND* cond)
+{
+  TABLE*	table	= (TABLE *) tables->table;
+  int	status	= 0;
+  DBUG_ENTER("i_s_groonga_fill_low");
+  table->field[0]->store(grn_get_version(), strlen(grn_get_version()),
+     system_charset_info);
+  table->field[0]->set_notnull();
+  table->field[1]->store(1); /* TODO */
+  table->field[2]->store(2); /* TODO */
+  if (schema_table_store_record(thd, table)) {
+    status = 1;
+  }
+  DBUG_RETURN(status);
+}
+
+static int i_s_groonga_stats_init(void* p)
+{
+  DBUG_ENTER("i_s_groonga_stats_init");
+  ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p;
+  schema->fields_info = i_s_groonga_stats_fields_info;
+  schema->fill_table = i_s_groonga_stats_fill;
+  DBUG_RETURN(0);
+}
+
+struct st_mysql_plugin i_s_groonga_stats =
+{
+  MYSQL_INFORMATION_SCHEMA_PLUGIN,
+  &i_s_info,
+  "GROONGA_STATS",
+  plugin_author,
+  "Statistics for Groonga",
+  PLUGIN_LICENSE_GPL,
+  i_s_groonga_stats_init,
+  i_s_groonga_stats_deinit,
+  GROONGA_VERSION_SHORT,
+  NULL,
+  NULL,
+  NULL,
+};
+/* End of groonga information schema implementations */
+
 mysql_declare_plugin(mroonga)
 {
   MYSQL_STORAGE_ENGINE_PLUGIN,
@@ -91,7 +180,7 @@ mysql_declare_plugin(mroonga)
   mrn_status_variables,
   mrn_system_variables,
   NULL
-}
+},i_s_groonga_stats
 mysql_declare_plugin_end;
 
 int mrn_init(void *p)




Groonga-mysql-commit メーリングリストの案内
Back to archive index