On Mon, Jul 19, 2004 at 10:19:47AM +0100, Tony Bowden wrote: > On Mon, Jul 19, 2004 at 03:22:05AM -0400, Michael G Schwern wrote: > > > The two "best" ideas we've had so far are to either run the SQL in the > > > code against a temporary database, and then compare both SHOW CREATE > > > TABLE outputs, or to use something like SQL::Translator to convert both > > > lots of SQL to a common format. Both seem much too cumbersome, however. > > > Anyone have any brighter ideas? > > Don't use a temporary database, just a temporary table. > > Surely that's more work?
Doesn't really matter how much code it is as long as you throw it into a function. Its certainly less permissions to worry about (don't need perms to create a whole new database). sub _ck_schema { my $schema = shift; (my $temp_schema = $schema) =~ s/CREATE TABLE (\w+)/CREATE TEMPORARY TABLE _chk_$1/; my $table = $1; my $temp_table = "_chk_$table"; $dbh->do($temp_schema); my $temp_layout = $dbh->selectrow_array("SHOW CREATE TABLE $temp_table"); my $orig_layout = $dbh->selectrow_array('SHOW CREATE TABLE $table'); $orig_layout =~ s/CREATE TABLE $table/CREATE TEMPORARY TABLE $temp_table/; return is( $temp_layout, $orig_layout ); } Something like that. You don't drop the temp table at the end because MySQL doesn't make a distinction, permissions-wise, between dropping a temp table and a real table until 4.1. Closing the connection will clean up the table. -- Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern/ Any sufficiently encapsulated hack is no longer a hack.