Subject: | DBD::mysql::column_info fails on column type "BIT" |
When DBD::mysql::column_info is called on a column of type "BIT" the
following exception is thrown:
column_info: unrecognized column type 'bit' of `table_name`.column_name
(where table_name and column_name
In DBD::mysql::column_info there is a chained if/elsif/.../else switch
based on $basetype - there is currently (as of the latest version on
CPAN) no matching case for 'bit'.
I suspect this may have become a problem since MySQL version 5.0.3 - as
per the MySQL docs:
"As of MySQL 5.0.3, a BIT data type is available for storing bit-field
values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)"
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
I've not tested this but I'm guessing that prior to this change a column
created as type BIT was described by column_info as TINYINT(1), which
would have worked.
The patch seems quite simple - this seems to work (though I've not
tested it extensively):
--- mysql.pm.orig 2010-07-18 21:42:56.000000000 +1000
+++ mysql.pm 2011-05-23 00:03:59.000000000 +1000
@@ -511,7 +511,7 @@
}
$info->{"mysql_values"} = \@type_params;
}
- elsif ($basetype =~ /int/)
+ elsif ($basetype =~ /int/ || $basetype eq 'bit' )
{
# big/medium/small/tiny etc + unsigned?
$info->{DATA_TYPE} = SQL_INTEGER();