Subject: | Patch for "type_info_all result has 19 keys but 20 fields" errors |
When using type_info with DBD::Sybase/freetds against an MSSQL server, DBI fails with an error
type_info_all result has 19 keys but 20 fields
(If you search on the Web you'll see that this causes DBD::Sybase build failures on various systems.)
The DBD::ODBC documentation has some suggestion about why this happens:
Show quoted text
>Many ODBC drivers now return 20 columns in type_info_all rather
>than the 19 DBI documents. The 20th column is usually called
>"USERTYPE". Recent MS SQL Server ODBC drivers do this.
>Fortunately this should not adversely affect you so long as you
>are using the keys provided at the start of type_info_all.
I suggest that the check in DBI is a bit too fussy, and it should allow *extra* fields in type_info_all (which will then be ignored), and only fail if too few are seen.
Please change the test in line 1811 from != to <, thus:
if @ti && @{$ti[0]} < $idx_fields;
Then if 20 fields are returned by the driver, it still works and the unrecognized twentieth field is just ignored.