DBIx::MyParse
DBIx::MyParse is a Perl module for parsing SQL queries. It works by calling the native MySQL parser from libmysqld and making the parse tree available in Perl.
Contents |
[edit] Example
use DBIx::MyParse;
use Data::Dumper;
my $parser = DBIx::MyParse->new();
my $query = $parser->parse("SELECT 1");
print Dumper $query->getWhere();
print $query->toString();
[edit] Installation
1. Download and unpack the latest MySQL 5.0 source from here
2. Download and unpack DBIx::MyParse from here
3. Patch the MySQL source:
$ cd /path/to/mysql-source $ cat /path/to/dbix-myparse-source/mysql.patch | patch -P1
4. Configure and compile the MySQL source:
$ cd /path/to/mysql-source $ ./configure --with-embedded-server $ make && make test
(you do NOT need to do "make install" to install the patched MySQL server)
5. Configure and compile DBIx::MyParse:
$ cd /path/to/dbix-myparse-source $ perl Makefile.PL $ make $ make test $ sudo make install
DBIx::MyParse can not be installed automatically using CPAN.
[edit] Query Rewriting
DBIx::MyParse can be used for on-the-fly query rewriting. In conjunction with DBIx::MyServer, a MySQL proxy can be built which intercepts, rewrites and responds to queries.