summaryrefslogtreecommitdiff
path: root/storage/example
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2010-03-03 15:44:14 +0100
committerSergei Golubchik <sergii@pisem.net>2010-03-03 15:44:14 +0100
commit2ceaffc4672c62a772890da7761d11f13d3f5ee4 (patch)
treea88f704359d35209d76f0dbb52fe18f7b259e175 /storage/example
parentabb87914ecb4caa1becce4fc4d30c110a6b2c041 (diff)
downloadmariadb-git-2ceaffc4672c62a772890da7761d11f13d3f5ee4.tar.gz
mwl:98 - libservices
Diffstat (limited to 'storage/example')
-rw-r--r--storage/example/Makefile.am2
-rw-r--r--storage/example/ha_example.cc22
2 files changed, 21 insertions, 3 deletions
diff --git a/storage/example/Makefile.am b/storage/example/Makefile.am
index 4b2f165377c..10163e307b1 100644
--- a/storage/example/Makefile.am
+++ b/storage/example/Makefile.am
@@ -34,7 +34,7 @@ noinst_HEADERS = ha_example.h
EXTRA_LTLIBRARIES = ha_example.la
pkgplugin_LTLIBRARIES = @plugin_example_shared_target@
-ha_example_la_LDFLAGS = -module -rpath $(pkgplugindir)
+ha_example_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices
ha_example_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_example_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_example_la_SOURCES = ha_example.cc
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc
index 604722c3c8c..b98466635cc 100644
--- a/storage/example/ha_example.cc
+++ b/storage/example/ha_example.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 MySQL AB
+/* Copyright (C) 2003 MySQL AB, 2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -890,6 +890,24 @@ static struct st_mysql_sys_var* example_system_variables[]= {
NULL
};
+// this is an example of SHOW_FUNC and of my_snprintf() service
+static int show_func_example(MYSQL_THD thd, struct st_mysql_show_var *var,
+ char *buf)
+{
+ var->type= SHOW_CHAR;
+ var->value= buf; // it's of SHOW_VAR_FUNC_BUFF_SIZE bytes
+ my_snprintf(buf, SHOW_VAR_FUNC_BUFF_SIZE,
+ "enum_var is %u, ulong_var is %lu, %.6b", // %b is MySQL extension
+ srv_enum_var, srv_ulong_var, "really");
+ return 0;
+}
+
+static struct st_mysql_show_var func_status[]=
+{
+ {"example_func_example", (char *)show_func_example, SHOW_FUNC},
+ {0,0,SHOW_UNDEF}
+};
+
mysql_declare_plugin(example)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
@@ -901,7 +919,7 @@ mysql_declare_plugin(example)
example_init_func, /* Plugin Init */
example_done_func, /* Plugin Deinit */
0x0001 /* 0.1 */,
- NULL, /* status variables */
+ func_status, /* status variables */
example_system_variables, /* system variables */
NULL /* config options */
}