WARNING! This code is VERY preliminary. It is certainly unsafe. Please do not use in production. If it breaks, you keep both parts. Based on the very helpful skeleton example plugin from Brian Aker. To install, grab a copy of the mysql source code and run this: sh config/bootstrap ./configure --with-mysql=/home/brian/mysql-5.1/ --libdir=/usr/local/lib/mysql/ make install And then inside of MySQL: mysql> INSTALL PLUGIN filesystem SONAME 'libfilesystem_engine.so'; mysql> CREATE TABLE LoadAverage ( load1 DECIMAL(3, 2), load5 DECIMAL(3, 2), load15 DECIMAL(3, 2), active_processes VARCHAR(12), lastpid INTEGER) ENGINE=FILESYSTEM connection="file:///proc/loadavg"; Query OK, 0 rows affected (0.00 sec) mysql> select * from LoadAverage; +-------+-------+--------+------------------+---------+ | load1 | load5 | load15 | active_processes | lastpid | +-------+-------+--------+------------------+---------+ | 0.00 | 0.00 | 0.00 | 1/97 | 6061 | +-------+-------+--------+------------------+---------+ 1 row in set (0.00 sec) mysql> CREATE TABLE passwd ( -> user varchar(32), -> password varchar(32), -> uid integer, -> gid integer, -> comment varchar(64), -> homedir varchar(256), -> shell varchar(64)) ENGINE=FILESYSTEM CONNECTION="file:///etc/passwd;separator=:"; Query OK, 0 rows affected (0.00 sec) mysql> select * from passwd where user = 'chip'; +------+----------+------+------+----------------+-----------------------+-----------+ | user | password | uid | gid | comment | homedir | shell | +------+----------+------+------+----------------+-----------------------+-----------+ | chip | x | 1000 | 1000 | Chip Turner,,, | /export/homedirs/chip | /bin/bash | +------+----------+------+------+----------------+-----------------------+-----------+ 1 row in set (0.00 sec) This is currently supported only on linux (patches welcome!)
Nathaniel-Han/mysql-filesystem-engine
Automatically exported from code.google.com/p/mysql-filesystem-engine
ShellGPL-2.0