max_length field of MYSQL_FIELD struct is not populated when using prepared statements. This is because according to http://dev.mysql.com/doc/refman/5.0/en/c-api-datatypes.html in order for this field to be populated, additional parameter should be provided before preparing statement. This patch passes needed parameter.
Created attachment 24335 [details] apr_dbd_mysql_length.patch