Tim Bunce wrote: > > p.s. Steffen, any chance you could produce a chunk of code that'll > connect to a DSN (specified on the command line), query all the > get_info values and dump the results to stdout as a DBD::<foo>::GetInfo > module? Shouldn't be a big modification from the scripts you've > obviously developed already. It would obviously be a big help > to many driver authors.
Here is a first cut; test it, stress it, tell me what you think!
=head1 NAME
Gen_DBD_foo_GetInfo - Generates a DBD::<foo>::GetInfo package.
=head1 SYNOPSIS
set DBI_DSN=dbi:ODBC:...
perl Gen_DBD_foo_GetInfo.pl > GetInfo.pm
=head1 DESCRIPTION
This script generates a DBD::<foo>::GetInfo package from the data source you
specified in the environment variable DBI_DSN.
DBD::<foo>::GetInfo should help a DBD author implementing the DBI get_info()
method.
Because you are just creating this package, it's very unlikly that DBD::<foo>
already provides a good implementation for get_info(). Thus you will probable
connect via DBD::ODBC.
=head1 NOTES
If you connect via DBD::ODBC, you should use version 0.38 or greater;
Please have a critical look at the data returned! ODBC driver vary dramatically
in their quality.
The generator assumes that most values are static and places these values
directly in the %info hash. A few examples show the use of CODE references
and the implementation via subroutines.
It's very likely that you have to write additional subroutines for values
depending on the session state or server version, e.g. SQL_DBMS_VER.
A possible implementation of DBD::<foo>::get_info() may look like:
sub get_info {
my($dbh, $info_type) = @_;
require DBD::<foo>::GetInfo;
my $v = $DBD::<foo>::GetInfo::info{int($info_type)};
$v = $v->($dbh) if ref $v eq 'CODE';
return $v;
}
Please replace <foo> with the name of your driver.
=head1 SEE ALSO
DBI, DBD::ODBC
=head1 COPYRIGHT
Copyright (c) 2002 Steffen Goeldner. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=cut
Steffen
Gen_DBD_foo_GetInfo.tar.gz
Description: GNU Zip compressed data
