<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Toru Maesaka &#187; plugin</title>
	<atom:link href="http://torum.net/tag/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://torum.net</link>
	<description>Hackaholic and a Web Addict based in Tokyo</description>
	<lastBuildDate>Tue, 28 Feb 2012 10:52:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Playing with Drizzle&#8217;s new plugin subsystem</title>
		<link>http://torum.net/2009/05/playing-with-drizzles-new-plugin-subsystem/</link>
		<comments>http://torum.net/2009/05/playing-with-drizzles-new-plugin-subsystem/#comments</comments>
		<pubDate>Thu, 07 May 2009 09:21:55 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[autotools]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://torum.net/?p=1507</guid>
		<description><![CDATA[Something notable that has changed in Drizzle this week is the build system for plugins. Previously we were using the old plugin system that was inherited from MySQL but Drizzle now uses a Python based system that allows us to aggregate your plugin build rules to the top level Makefile. This change also gets rid [...]]]></description>
			<content:encoded><![CDATA[<p>Something notable that has changed in <a href="https://launchpad.net/drizzle">Drizzle</a> this week is the build system for plugins.</p>
<p>Previously we were using the old plugin system that was inherited from <a href="http://www.mysql.com">MySQL</a> but Drizzle now uses a Python based system that allows us to aggregate your plugin build rules to the top level Makefile. This change also gets rid of the nasty behavior that was giving people like Monty Taylor and other build system hackers heachaches.</p>
<p>But hey, as a plugin developer you&#8217;re not so interested in how things are handled cleanly inside right? you&#8217;re more interested in how to create or port your plugin over to the new build system! As a developer, you are interested in the following three files:</p>
<ul>
<li>plugin.ini</li>
<li>plugin.ac</li>
<li>plugin.am</li>
</ul>
<p>where the mandatory file is <strong>plugin.ini</strong>. This file is where you write the basic details of the plugin like the name, source files and relevant compiler options. For example this is what plugin.ini looks like for the <a href="http://dev.mysql.com/doc/refman/5.0/en/blackhole-storage-engine.html">Blackhole</a> storage engine:</p>

<div class="wp_syntax"><div class="code"><pre class="null" style="font-family:monospace;">[plugin]
name=blackhole
title=Blackhole Storage Engine
description=Basic Write-only Read-never tables
sources=ha_blackhole.cc
headers=ha_blackhole.h</pre></div></div>

<p>You can also specify the plugin to be loaded by default with this line: &#8220;load_by_default=yes&#8221;. If you don&#8217;t add this line, the plugin is enabled by specifying it with the &#8220;&#8211;plugin_load&#8221; server startup option.</p>
<p>As for the optional plugin.ac and plugin.am files, these are where you can add your own autoconf and automake rules for the plugin. For example you might want to check/search for a library or build an internal library for your plugin.</p>
<h3>Example of Linking an external library</h3>
<p>If you write a plugin, you&#8217;ll most likely want to link a particular library to your program. After all, thats one of the major points of writing a plugin right? to bring the external goodness over to the database server for solving a particular need/requirement in your application.</p>
<p>For those that are interested, I&#8217;ll leave a snippet of how I linked <a href="http://tokyocabinet.sf.net">Tokyo Cabinet</a> to the storage engine I am currently working on. Firstly, you want to search whether Tokyo Cabinet exists in the environment that you&#8217;re building in. Clearly this is what configure is for so I added this to my plugin.ac:</p>

<div class="wp_syntax"><div class="code"><pre class="autoconf" style="font-family:monospace;">AC_LIB_HAVE_LINKFLAGS(tokyocabinet,,
  [#include &lt;tchdb.h&gt;],
  [
     TCHDB hdb;
  ])  
  AS_IF([test &quot;x$ac_cv_libtokyocabinet&quot; = &quot;xno&quot;],
        AC_MSG_WARN([tokyocabinet not found: not building plugin.]))
DRIZZLED_PLUGIN_DEP_LIBS=&quot;${DRIZZLED_PLUGIN_DEP_LIBS} ${LTLIBTOKYOCABINET}&quot;</pre></div></div>

<p>The above will check for Tokyo Cabinet and whether the TCHDB structure exists. If it doesn&#8217;t exist then it will print a warning but if it does exist, it will add the linker option to plugin dependencies. You can now tell the build system to link Tokyo Cabinet, which you do by assigning the LTLIBTOKYOCABINET variable to ldflags in plugin.ini:</p>

<div class="wp_syntax"><div class="code"><pre class="null" style="font-family:monospace;">ldflags=${LTLIBTOKYOCABINET}</pre></div></div>

<p>You could directly write &#8220;ldflags = -ltokyocabinet&#8221; to plugin.ini but you really want to take advantage of configure. configure (more rather autotools) is your friend.</p>
<p>So, this is all I have to cover in this entry and I hope this entry will be helpful to those that are looking into working on a Drizzle plugin. If you would like more information, the <a href="http://drizzle.org/wiki/">Drizzle Wiki</a> should be updated with more detailed explanation soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2009/05/playing-with-drizzles-new-plugin-subsystem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drizzle&#8217;s Storage Engine subsystem</title>
		<link>http://torum.net/2009/04/drizzle-storage-subsystem/</link>
		<comments>http://torum.net/2009/04/drizzle-storage-subsystem/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 13:34:02 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[engine]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[storage]]></category>

		<guid isPermaLink="false">http://torum.net/?p=1403</guid>
		<description><![CDATA[Today I was doing some work on writing a small storage engine for Drizzle that we&#8217;re hoping will perform good enough to replace the MEMORY/HEAP engine inherited from MySQL. For those that are interested, this engine is going to be based on Tokyo Cabinet&#8217;s on-memory b+tree database. I was a little worried that this task [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was doing some work on writing a small storage engine for <a href="https://launchpad.net/drizzle">Drizzle</a> that we&#8217;re hoping will perform good enough to replace the <a href="http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html">MEMORY/HEAP engine</a> inherited from <a href="http://www.mysql.com">MySQL</a>. For those that are interested, this engine is going to be based on Tokyo Cabinet&#8217;s <a href="http://tokyocabinet.sourceforge.net/spex-en.html#tcutilapi_ndbapi">on-memory b+tree</a> database.</p>
<p>I was a little worried that this task is going to be heavy since I&#8217;ve never hacked on a relational database engine before (other than tracing through <a href="http://www.innodb.com">InnoDB</a>) but it turns out it&#8217;s not so bad. I first looked up the engine interface for MySQL then looked at the engines in the Drizzle tree. The interface itself looks very similar but what&#8217;s really cool about Drizzle is how the storage engine is registered to the core server with the new plugin system. Here&#8217;s a snippet of how this looks with the <a href="http://dev.mysql.com/doc/refman/5.0/en/blackhole-storage-engine.html">Blackhole engine</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">blackhole_engine<span style="color: #339933;">=</span> new BlackholeEngine<span style="color: #009900;">&#40;</span>engine_name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
registry.<span style="color: #202020;">add</span><span style="color: #009900;">&#40;</span>blackhole_engine<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>and the de-initialization:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">registry.<span style="color: #202020;">remove</span><span style="color: #009900;">&#40;</span>blackhole_engine<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
delete blackhole_engine<span style="color: #339933;">;</span></pre></div></div>

<p>If you&#8217;re familiar with how a Drizzle plugin is written, you will notice that this is exactly the same; You implement the interface and boom, you register it with the PluginRegistry object. So a storage engine is treated equally just like any other plugin system.</p>
<p>Needless to say, the storage engine declaration is exactly the same as what you would do with any Drizzle plugin:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">drizzle_declare_plugin<span style="color: #009900;">&#40;</span>blackhole<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #ff0000;">&quot;BLACKHOLE&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">&quot;MySQL AB&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #ff0000;">&quot;/dev/null storage engine (anything you write to it disappears)&quot;</span><span style="color: #339933;">,</span>
  PLUGIN_LICENSE_GPL<span style="color: #339933;">,</span>
  blackhole_init<span style="color: #339933;">,</span> <span style="color: #808080; font-style: italic;">/* Plugin Init */</span>
  blackhole_fini<span style="color: #339933;">,</span> <span style="color: #808080; font-style: italic;">/* Plugin Deinit */</span>
  NULL<span style="color: #339933;">,</span>           <span style="color: #808080; font-style: italic;">/* status variables */</span>
  NULL<span style="color: #339933;">,</span>           <span style="color: #808080; font-style: italic;">/* system variables */</span>
  NULL            <span style="color: #808080; font-style: italic;">/* config options */</span>
<span style="color: #009900;">&#125;</span>
drizzle_declare_plugin_end<span style="color: #339933;">;</span></pre></div></div>

<p>This is nice! a storage engine is just a plugin after all and Drizzle treats it as it ought to be. I will have some more time to hack on this after <a href="http://www.mysql.com/news-and-events/web-seminars/display-323.html">my memcached webinar</a> so hopefully I&#8217;ll have more details posted about the progress on this work soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2009/04/drizzle-storage-subsystem/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

