Drizzle Storage Engine Alias!
Admittedly I’m a lazy guy. Due to this nature I’m a little behind on the updates made to the Drizzle Storage Engine API. From lurking through the source code in the Drizzle trunk, I’ve noticed these changes.
- Engines can now have an alias
- handler class is replaced by the Cursor class
- Engine handler is now a subclass of Cursor
- Table definitions are handled/stored by the storage engine
- doCreateTable(), doDropTable(), doGetTableNames(), doGetTableDefinition()
Currently I’m trying to catch up with the updated Drizzle Storage API and take this opportunity to rewrite most of BlitzDB. The reason is that the more I understand TC internal, the more mistakes I realized that I’ve made. I’ll blog more about this soon. Instead, I’m going to introduce something small but nice today.
A while back I poked folks like Monty Taylor and Stewart Smith that it would be cool if engines could have an alias. I mentioned this because InnoDB was allowed to use both “innodb” and “innobase” in the system whereas other engines could only have one name. Another reason I was interested in this issue was that I couldn’t understand how InnoDB could use two names since there was no way to do this in the old interface. Turns out InnoDB was treated specially in the core, which is obviously not desirable in a microkernel philosophy.
In the current Drizzle Storage Engine API, there is a function called addAlias(). By calling this function inside the storage engine constructor, you can allow your engine to have multiple aliases. For experiment purposes I wrote this to BlitzDB:
BlitzEngine(const string &name_arg) : drizzled::plugin::StorageEngine(name_arg, HTON_CAN_RECREATE) { table_definition_ext = drizzled::plugin::DEFAULT_DEFINITION_FILE_EXT; addAlias("BLITZ"); addAlias("TCDB"); }
Here, I added aliases BLITZ and TCDB. TCDB is my way of showing respect to Mikio and Tokyo Cabinet. So given the above, we should now be able to create tables with three names.
drizzle> CREATE TABLE t1 (foo int) engine=blitzdb; Query OK, 0 rows affected (0 sec) drizzle> CREATE TABLE t2 (foo int) engine=blitz; Query OK, 0 rows affected (0 sec) drizzle> CREATE TABLE t3 (foo int) engine=tcdb; Query OK, 0 rows affected (0.01 sec)
Success! Yep, this is something so trivial that I think most people wouldn’t care about but I was happy to see this update in the trunk :)
