Path: | lib/active_record/vendor/mysql411.rb |
Last Update: | Wed Oct 12 12:38:04 UTC 2005 |
mysq411.rb - 0.1 - Matt Mower <self@mattmower.com>
The native Ruby MySQL client (mysql.rb) by Tomita Masahiro does not (yet) handle the new MySQL protocol introduced in MySQL 4.1.1. This protocol introduces a new authentication scheme as well as modifications to the client/server exchanges themselves.
mysql411.rb modifies the Mysql class to add MySQL 4.1.x support. It modifies the connection algorithm to detect a 4.1.1 server and respond with the new authentication scheme, otherwise using the original one. Similarly for the changes to packet structures and field definitions, etc…
It redefines serveral methods which behave differently depending upon the server context. The way I have implemented this is to alias the old method, create a new alternative method, and redefine the original method as a selector which calls the appropriate method based upon the server version. There may have been a neater way to do this.
In general I’ve tried not to change the original code any more than necessary, i.e. even where I redefine a method I have made the smallest number of changes possible, rather than rewriting from scratch.
*Caveat Lector* This code passes all current ActiveRecord unit tests however this is no guarantee that full & correct MySQL 4.1 support has been achieved.