How to compare the structure of MySQL databases

I've created a set of SQL queries that can be run on the information_schema of a MySQL 5.x+ server to compare the structure of two databases and create the SQL commands needed to convert the structure of one database to the structure of the other. Use them at your own risk. They worked for me, but they might not cover all aspects of MySQL database comparison. I've tested them on an 5.0.51 MySQL server running on Debian 5.x.

P.S.: for some reason these queries seem to be extremely slow (at least in my case they were). Either the queries are heavily suboptimal or the information_schema is not indexed ... or there's something else wrong with the implementation of these meta tables that I do not know of.
P.S.2: I've found the culprit. The problem is with the implementation of information_schema and the respective bugreport is more than 3 years old. Sad They say that in v5.1.23 there're several optimizations that should either improve or solve the issue, but a number of followup comments prove this to be false.

AttachmentSize
mysql_database_diff.sql6.45 KB