Subject: | SQL_ALL_TYPES and SQL_UNKNOWN_TYPE share the same type code number |
Hi All,
These two type constants sharing the same type code leads to incorrect
results when one requests type info:
C:\>perl -MData::Dumper -e "use 5.16.0; use DBI qw(:sql_types); say
'SQL_ALL_TYPES=' . SQL_ALL_TYPES; say 'SQL_UNKNOWN_TYPE=' .
SQL_UNKNOWN_TYPE;"
#SQL_ALL_TYPES=0
#SQL_UNKNOWN_TYPE=0
C:\>perl -MData::Dumper -e "use DBI qw(:sql_types); my $dbh =
DBI->connect('DBI:mysql:database=test;host=localhost;','test','test');
print Dumper( $dbh->type_info( SQL_UNKNOWN_TYPE ) )"
#returns all types
C:\>perl -MData::Dumper -e "use DBI qw(:sql_types); my $dbh =
DBI->connect('DBI:Pg:database=test;host=localhost;','test','test');
print Dumper( $dbh->type_info( SQL_UNKNOWN_TYPE ) )"
#returns all types
SQL_ALL_TYPES does appear in the standard.
SQL_UNKNOWN_TYPE doesn't appear in the standard.
Googling seems to suggest that SQL_UNKNOWN_TYPE is used by a number of
DBMSs, with type code 0.
I can't think of a solution other than to re-code SQL_UNKNOWN_TYPE to
something within the DBI specific permissible range, such as 9000. But
then that would probably break several DBDs.
The DBI docs don't mention SQL_UNKNOWN_TYPE. So maybe the only workable
solution is to add a caveat?
Lyle