ÿØÿà JFIF ÿÛ „ ( %!1!%*+...983,7(-.-
PK ]{q
Changes.pmnu [ =head1 NAME
DBI::Changes - List of significant changes to the DBI
=encoding ISO8859-1
=cut
=head2 Changes in DBI 1.641 - 19th March 2018
Remove dependency on Storable 2.16 introduced in DBI 1.639
thanks to Ribasushi #60
Avoid compiler warnings in Driver.xst #59
thanks to pali #59
=head2 Changes in DBI 1.640 - 28th January 2018
Fix test t/91_store_warning.t for perl 5.10.0
thanks to pali #57
Add Perl 5.10.0 and 5.8.1 specific versions to Travis testing
thanks to pali #57
Add registration of mariadb_ prefix for new DBD::MariaDB driver
thanks to pali #56
=head2 Changes in DBI 1.639 - 28th December 2017
Fix UTF-8 support for warn/croak calls within DBI internals,
thanks to pali #53
Fix dependency on Storable for perl older than 5.8.9,
thanks to H.Merijn Brand.
Add DBD::Mem driver, a pure-perl in-memory driver using DBI::DBD::SqlEngine,
thanks to Jens Rehsack #42
Corrected missing semicolon in example in documentation,
thanks to pali #55
=head2 Changes in DBI 1.637 - 16th August 2017
Fix use of externally controlled format string (CWE-134) thanks to pali #44
This could cause a crash if, for example, a db error contained a %.
https://cwe.mitre.org/data/definitions/134.html
Fix extension detection for DBD::File related drivers
Fix tests for perl without dot in @INC RT#120443
Fix loss of error message on parent handle, thanks to charsbar #34
Fix disappearing $_ inside callbacks, thanks to robschaber #47
Fix dependency on Storable for perl older than 5.8.9
Allow objects to be used as passwords without throwing an error, thanks to demerphq #40
Allow $sth NAME_* attributes to be set from Perl code, re #45
Added support for DBD::XMLSimple thanks to nigelhorne #38
Documentation updates:
Improve examples using eval to be more correct, thanks to pali #39
Add cautionary note to prepare_cached docs re refs in %attr #46
Small POD changes (Getting Help -> Online) thanks to openstrike #33
Adds links to more module names and fix typo, thanks to oalders #43
Typo fix thanks to bor #37
=head2 Changes in DBI 1.636 - 24th April 2016
Fix compilation for threaded perl <= 5.12 broken in 1.635 RT#113955
Revert change to DBI::PurePerl DESTROY in 1.635
Change t/16destroy.t to avoid race hazard RT#113951
Output perl version and archname in t/01basics.t
Add perl 5.22 and 5.22-extras to travis-ci config
=head2 Changes in DBI 1.635 - 24th April 2016
Fixed RaiseError/PrintError for UTF-8 errors/warnings. RT#102404
Fixed cases where ShowErrorStatement might show incorrect Statement RT#97434
Fixed DBD::Gofer for UTF-8-enabled STDIN/STDOUT
thanks to mauke PR#32
Fixed fetchall_arrayref({}) behavior with no columns
thanks to Dan McGee PR#31
Fixed tied CachedKids ref leak in attribute cache by weakening
thanks to Michael Conrad RT#113852
Fixed "panic: attempt to copy freed scalar" upon commit() or rollback()
thanks to fbriere for detailed bug report RT#102791
Ceased to ignore DESTROY of outer handle in DBI::PurePerl
Treat undef in DBI::Profile Path as string "undef"
thanks to fREW Schmidt RT#113298
Fix SQL::Nano parser to ignore trailing semicolon
thanks to H.Merijn Brand.
Added @ary = $dbh->selectall_array(...) method
thanks to Ed Avis RT#106411
Added appveyor support (Travis like CI for windows)
thanks to mbeijen PR#30
Corrected spelling errors in pod
thanks to Gregor Herrmann RT#107838
Corrected and/or removed broken links to SQL standards
thanks to David Pottage RT#111437
Corrected doc example to use dbi: instead of DBI: in DSN
thanks to Michael R. Davis RT#101181
Removed/updated broken links in docs
thanks to mbeijen PR#29
Clarified docs for DBI::hash($string)
Removed the ancient DBI::FAQ module RT#102714
Fixed t/pod.t to require Test::Pod >= 1.41 RT#101769
This release was developed at the Perl QA Hackathon 2016
L
which was made possible by the generosity of many sponsors:
L FastMail,
L ZipRecruiter,
L ActiveState,
L OpusVL,
L Strato,
L SureVoIP,
L CV-Library,
L Infinity,
L Perl Careers,
L MongoDB,
L thinkproject!,
L Dreamhost,
L Perl 6,
L Perl Services,
L Evozon,
L Booking,
L Eligo,
L Oetiker+Partner,
L CAPSiDE,
L Procura,
L Constructor.io,
L Robbie Bow,
L Ron Savage,
L Charlie Gonzalez,
L Justin Cook.
=head2 Changes in DBI 1.634 - 3rd August 2015
Enabled strictures on all modules (Jose Luis Perez Diez) #22
Note that this might cause new exceptions in existing code.
Please take time for extra testing before deploying to production.
Improved handling of row counts for compiled drivers and enable them to
return larger row counts (IV type) by defining new *_iv macros.
Fixed quote_identifier that was adding a trailing separator when there
was only a catalog (Martin J. Evans)
Removed redundant keys() call in fetchall_arrayref with hash slice (ilmari) #24
Corrected pod xref to Placeholders section (Matthew D. Fuller)
Corrected pod grammar (Nick Tonkin) #25
Added support for tables('', '', '', '%') special case (Martin J. Evans)
Added support for DBD prefixes with numbers (Jens Rehsack) #19
Added extra initializer for DBI::DBD::SqlEngine based DBD's (Jens Rehsack)
Added Memory Leaks section to the DBI docs (Tim)
Added Artistic v1 & GPL v1 LICENSE file (Jose Luis Perez Diez) #21
=head2 Changes in DBI 1.633 - 11th Jan 2015
Fixed selectrow_*ref to return undef on error in list context
instead if an empty list.
Changed t/42prof_data.t more informative
Changed $sth->{TYPE} to be NUMERIC in DBD::File drivers as per the
DBI docs. Note TYPE_NAME is now also available. [H.Merijn Brand]
Fixed compilation error on bleadperl due DEFSV no longer being an lvalue
[Dagfinn Ilmari Mannsker]
Added docs for escaping placeholders using a backslash.
Added docs for get_info(9000) indicating ability to escape placeholders.
Added multi_ prefix for DBD::Multi (Dan Wright) and ad2_ prefix for
DBD::AnyData2
=head2 Changes in DBI 1.632 - 9th Nov 2014
Fixed risk of memory corruption with many arguments to methods
originally reported by OSCHWALD for Callbacks but may apply
to other functionality in DBI method dispatch RT#86744.
Fixed DBD::PurePerl to not set $sth->{Active} true by default
drivers are expected to set it true as needed.
Fixed DBI::DBD::SqlEngine to complain loudly when prerequite
driver_prefix is not fulfilled (RT#93204) [Jens Rehsack]
Fixed redundant sprintf argument warning RT#97062 [Reini Urban]
Fixed security issue where DBD::File drivers would open files
from folders other than specifically passed using the
f_dir attribute RT#99508 [H.Merijn Brand]
Changed delete $h->{$key} to work for keys with 'private_' prefix
per request in RT#83156. local $h->{$key} works as before.
Added security notice to DBD::Proxy and DBI::ProxyServer because they
use Storable which is insecure. Thanks to ppisar@redhat.com RT#90475
Added note to AutoInactiveDestroy docs strongly recommending that it
is enabled in all new code.
=head2 Changes in DBI 1.631 - 20th Jan 2014
NOTE: This release changes the handle passed to Callbacks from being an 'inner'
handle to being an 'outer' handle. If you have code that makes use of Callbacks,
ensure that you understand what this change means and review your callback code.
Fixed err_hash handling of integer err RT#92172 [Dagfinn Ilmari]
Fixed use of \Q vs \E in t/70callbacks.t
Changed the handle passed to Callbacks from being an 'inner'
handle to being an 'outer' handle.
Improved reliability of concurrent testing
PR#8 [Peter Rabbitson]
Changed optional dependencies to "suggest"
PR#9 [Karen Etheridge]
Changed to avoid mg_get in neatsvpv during global destruction
PR#10 [Matt Phillips]
=head2 Changes in DBI 1.630 - 28th Oct 2013
NOTE: This release enables PrintWarn by default regardless of $^W.
Your applications may generate more log messages than before.
Fixed err for new drh to be undef not to 0 [Martin J. Evans]
Fixed RT#83132 - moved DBIstcf* constants to util
export tag [Martin J. Evans]
PrintWarn is now triggered by warnings recorded in methods like STORE
that don't clear err RT#89015 [Tim Bunce]
Changed tracing to no longer show quote and quote_identifier calls
at trace level 1.
Changed DBD::Gofer ping while disconnected set_err from warn to info.
Clarified wording of log message when err is cleared.
Changed bootstrap to use $XS_VERSION RT#89618 [Andreas Koenig]
Added connect_cached.connected Callback PR#3 [David E. Wheeler]
Clarified effect of refs in connect_cached attributes [David E. Wheeler]
Extended ReadOnly attribute docs for when the driver cannot
ensure read only [Martin J. Evans]
Corrected SQL_BIGINT docs to say ODBC value is used PR#5 [ilmari]
There was no DBI 1.629 release.
=head2 Changes in DBI 1.628 - 22nd July 2013
Fixed missing fields on partial insert via DBI::DBD::SqlEngine
engines (DBD::CSV, DBD::DBM etc.) [H.Merijn Brand, Jens Rehsack]
Fixed stack corruption on callbacks RT#85562 RT#84974 [Aaron Schweiger]
Fixed DBI::SQL::Nano_::Statement handling of "0" [Jens Rehsack]
Fixed exit op precedence in test RT#87029 [Reni Urban]
Added support for finding tables in multiple directories
via new DBD::File f_dir_search attribute [H.Merijn Brand]
Enable compiling by C++ RT#84285 [Kurt Jaeger]
Typo fixes in pod and comment [David Steinbrunner]
Change DBI's docs to refer to git not svn [H.Merijn Brand]
Clarify bind_col TYPE attribute is sticky [Martin J. Evans]
Fixed reference to $sth in selectall_arrayref docs RT#84873
Spelling fixes [Ville Skytt]
Changed $VERSIONs to hardcoded strings [H.Merijn Brand]
=head2 Changes in DBI 1.627 - 16th May 2013
Fixed VERSION regression in DBI::SQL::Nano [Tim Bunce]
=head2 Changes in DBI 1.626 - 15th May 2013
Fixed pod text/link was reversed in a few cases RT#85168
[H.Merijn Brand]
Handle aliasing of STORE'd attributes in DBI::DBD::SqlEngine
[Jens Rehsack]
Updated repository URI to git [Jens Rehsack]
Fixed skip() count arg in t/48dbi_dbd_sqlengine.t [Tim Bunce]
=head2 Changes in DBI 1.625 (svn r15595) 28th March 2013
Fixed heap-use-after-free during global destruction RT#75614
thanks to Reini Urban.
Fixed ignoring RootClass attribute during connect() by
DBI::DBD::SqlEngine reported in RT#84260 by Michael Schout
=head2 Changes in DBI 1.624 (svn r15576) 22nd March 2013
Fixed Gofer for hash randomization in perl 5.17.10+ RT#84146
Clarify docs for can() re RT#83207
=head2 Changes in DBI 1.623 (svn r15547) 2nd Jan 2013
Fixed RT#64330 - ping wipes out errstr (Martin J. Evans).
Fixed RT#75868 - DBD::Proxy shouldn't call connected() on the server.
Fixed RT#80474 - segfault in DESTROY with threads.
Fixed RT#81516 - Test failures due to hash randomisation in perl 5.17.6
thanks to Jens Rehsack and H.Merijn Brand and feedback on IRC
Fixed RT#81724 - Handle copy-on-write scalars (sprout)
Fixed unused variable / self-assignment compiler warnings.
Fixed default table_info in DBI::DBD::SqlEngine which passed NAMES
attribute instead of NAME to DBD::Sponge RT72343 (Martin J. Evans)
Corrected a spelling error thanks to Chris Sanders.
Corrected typo in DBI->installed_versions docs RT#78825
thanks to Jan Dubois.
Refactored table meta information management from DBD::File into
DBI::DBD::SqlEngine (H.Merijn Brand, Jens Rehsack)
Prevent undefined f_dir being used in opendir (H.Merijn Brand)
Added logic to force destruction of children before parents
during global destruction. See RT#75614.
Added DBD::File Plugin-Support for table names and data sources
(Jens Rehsack, #dbi Team)
Added new tests to 08keeperr for RT#64330
thanks to Kenichi Ishigaki.
Added extra internal handle type check, RT#79952
thanks to Reini Urban.
Added cubrid_ registered prefix for DBD::cubrid, RT#78453
Removed internal _not_impl method (Martin J. Evans).
NOTE: The "old-style" DBD::DBM attributes 'dbm_ext' and 'dbm_lockfile'
have been deprecated for several years and their use will now generate
a warning.
=head2 Changes in DBI 1.622 (svn r15327) 6th June 2012
Fixed lack of =encoding in non-ASCII pod docs. RT#77588
Corrected typo in DBI::ProfileDumper thanks to Finn Hakansson.
=head2 Changes in DBI 1.621 (svn r15315) 21st May 2012
Fixed segmentation fault when a thread is created from
within another thread RT#77137, thanks to Dave Mitchell.
Updated previous Changes to credit Booking.com for sponsoring
Dave Mitchell's recent DBI optimization work.
=head2 Changes in DBI 1.620 (svn r15300) 25th April 2012
Modified column renaming in fetchall_arrayref, added in 1.619,
to work on column index numbers not names (an incompatible change).
Reworked the fetchall_arrayref documentation.
Hash slices in fetchall_arrayref now detect invalid column names.
=head2 Changes in DBI 1.619 (svn r15294) 23rd April 2012
Fixed the connected method to stop showing the password in
trace file (Martin J. Evans).
Fixed _install_method to set CvFILE correctly
thanks to sprout RT#76296
Fixed SqlEngine "list_tables" thanks to David McMath
and Norbert Gruener. RT#67223 RT#69260
Optimized DBI method dispatch thanks to Dave Mitchell.
Optimized driver access to DBI internal state thanks to Dave Mitchell.
Optimized driver access to handle data thanks to Dave Mitchell.
Dave's work on these optimizations was sponsored by Booking.com.
Optimized fetchall_arrayref with hash slice thanks
to Dagfinn Ilmari Mannsker. RT#76520
Allow renaming columns in fetchall_arrayref hash slices
thanks to Dagfinn Ilmari Mannsker. RT#76572
Reserved snmp_ and tree_ for DBD::SNMP and DBD::TreeData
=head2 Changes in DBI 1.618 (svn r15170) 25rd February 2012
Fixed compiler warnings in Driver_xst.h (Martin J. Evans)
Fixed compiler warning in DBI.xs (H.Merijn Brand)
Fixed Gofer tests failing on Windows RT74975 (Manoj Kumar)
Fixed my_ctx compile errors on Windows (Dave Mitchell)
Significantly optimized method dispatch via cache (Dave Mitchell)
Significantly optimized DBI internals for threads (Dave Mitchell)
Dave's work on these optimizations was sponsored by Booking.com.
Xsub to xsub calling optimization now enabled for threaded perls.
Corrected typo in example in docs (David Precious)
Added note that calling clone() without an arg may warn in future.
Minor changes to the install_method() docs in DBI::DBD.
Updated dbipport.h from Devel::PPPort 3.20
=head2 Changes in DBI 1.617 (svn r15107) 30th January 2012
NOTE: The officially supported minimum perl version will change
from perl 5.8.1 (2003) to perl 5.8.3 (2004) in a future release.
(The last change, from perl 5.6 to 5.8.1, was announced
in July 2008 and implemented in DBI 1.611 in April 2010.)
Fixed ParamTypes example in the pod (Martin J. Evans)
Fixed the definition of ArrayTupleStatus and remove confusion over
rows affected in list context of execute_array (Martin J. Evans)
Fixed sql_type_cast example and typo in errors (Martin J. Evans)
Fixed Gofer error handling for keeperr methods like ping (Tim Bunce)
Fixed $dbh->clone({}) RT73250 (Tim Bunce)
Fixed is_nested_call logic error RT73118 (Reini Urban)
Enhanced performance for threaded perls (Dave Mitchell, Tim Bunce)
Dave's work on this optimization was sponsored by Booking.com.
Enhanced and standardized driver trace level mechanism (Tim Bunce)
Removed old code that was an inneffective attempt to detect
people doing DBI->{Attrib}.
Clear ParamValues on bind_param param count error RT66127 (Tim Bunce)
Changed DBI::ProxyServer to require DBI at compile-time RT62672 (Tim Bunce)
Added pod for default_user to DBI::DBD (Martin J. Evans)
Added CON, ENC and DBD trace flags and extended 09trace.t (Martin J. Evans)
Added TXN trace flags and applied CON and TXN to relevant methods (Tim Bunce)
Added some more fetchall_arrayref(..., $maxrows) tests (Tim Bunce)
Clarified docs for fetchall_arrayref called on an inactive handle.
Clarified docs for clone method (Tim Bunce)
Added note to DBI::Profile about async queries (Marcel Grnauer).
Reserved spatialite_ as a driver prefix for DBD::Spatialite
Reserved mo_ as a driver prefix for DBD::MO
Updated link to the SQL Reunion 95 docs, RT69577 (Ash Daminato)
Changed links for DBI recipes. RT73286 (Martin J. Evans)
=head2 Changes in DBI 1.616 (svn r14616) 30th December 2010
Fixed spurious dbi_profile lines written to the log when
profiling is enabled and a trace flag, like SQL, is used.
Fixed to recognize SQL::Statement errors even if instantiated
with RaiseError=0 (Jens Rehsack)
Fixed RT#61513 by catching attribute assignment to tied table access
interface (Jens Rehsack)
Fixing some misbehavior of DBD::File when running within the Gofer
server.
Fixed compiler warnings RT#62640
Optimized connect() to remove redundant FETCH of \%attrib values.
Improved initialization phases in DBI::DBD::SqlEngine (Jens Rehsack)
Added DBD::Gofer::Transport::corostream. An experimental proof-of-concept
transport that enables asynchronous database calls with few code changes.
It enables asynchronous use of DBI frameworks like DBIx::Class.
Added additional notes on DBDs which avoid creating a statement in
the do() method and the effects on error handlers (Martin J. Evans)
Adding new attribute "sql_dialect" to DBI::DBD::SqlEngine to allow
users control used SQL dialect (ANSI, CSV or AnyData), defaults to
CSV (Jens Rehsack)
Add documentation for DBI::DBD::SqlEngine attributes (Jens Rehsack)
Documented dbd_st_execute return (Martin J. Evans)
Fixed typo in InactiveDestroy thanks to Emmanuel Rodriguez.
=head2 Changes in DBI 1.615 (svn r14438) 21st September 2010
Fixed t/51dbm_file for file/directory names with whitespaces in them
RT#61445 (Jens Rehsack)
Fixed compiler warnings from ignored hv_store result (Martin J. Evans)
Fixed portability to VMS (Craig A. Berry)
=head2 Changes in DBI 1.614 (svn r14408) 17th September 2010
Fixed bind_param () in DBI::DBD::SqlEngine (rt#61281)
Fixed internals to not refer to old perl symbols that
will no longer be visible in perl >5.13.3 (Andreas Koenig)
Many compiled drivers are likely to need updating.
Fixed issue in DBD::File when absolute filename is used as table name
(Jens Rehsack)
Croak manually when file after tie doesn't exists in DBD::DBM
when it have to exists (Jens Rehsack)
Fixed issue in DBD::File when users set individual file name for tables
via f_meta compatibility interface - reported by H.Merijn Brand while
working on RT#61168 (Jens Rehsack)
Changed 50dbm_simple to simplify and fix problems (Martin J. Evans)
Changed 50dbm_simple to skip aggregation tests when not using
SQL::Statement (Jens Rehsack)
Minor speed improvements in DBD::File (Jens Rehsack)
Added $h->{AutoInactiveDestroy} as simpler safer form of
$h->{InactiveDestroy} (David E. Wheeler)
Added ability for parallel testing "prove -j4 ..." (Jens Rehsack)
Added tests for delete in DBM (H.Merijn Brand)
Added test for absolute filename as table to 51dbm_file (Jens Rehsack)
Added two initialization phases to DBI::DBD::SqlEngine (Jens Rehsack)
Added improved developers documentation for DBI::DBD::SqlEngine
(Jens Rehsack)
Added guides how to write DBI drivers using DBI::DBD::SqlEngine
or DBD::File (Jens Rehsack)
Added register_compat_map() and table_meta_attr_changed() to
DBD::File::Table to support clean fix of RT#61168 (Jens Rehsack)
=head2 Changes in DBI 1.613 (svn r14271) 22nd July 2010
Fixed Win32 prerequisite module from PathTools to File::Spec.
Changed attribute headings and fixed references in DBI pod (Martin J. Evans)
Corrected typos in DBI::FAQ and DBI::ProxyServer (Ansgar Burchardt)
=head2 Changes in DBI 1.612 (svn r14254) 16th July 2010
NOTE: This is a minor release for the DBI core but a major release for
DBD::File and drivers that depend on it, like DBD::DBM and DBD::CSV.
This is also the first release where the bulk of the development work
has been done by other people. I'd like to thank (in no particular order)
Jens Rehsack, Martin J. Evans, and H.Merijn Brand for all their contributions.
Fixed DBD::File's {ChopBlank} handling (it stripped \s instead of space
only as documented in DBI) (H.Merijn Brand)
Fixed DBD::DBM breakage with SQL::Statement (Jens Rehsack, fixes RT#56561)
Fixed DBD::File file handle leak (Jens Rehsack)
Fixed problems in 50dbm.t when running tests with multiple
dbms (Martin J. Evans)
Fixed DBD::DBM bugs found during tests (Jens Rehsack)
Fixed DBD::File doesn't find files without extensions under some
circumstances (Jens Rehsack, H.Merijn Brand, fixes RT#59038)
Changed Makefile.PL to modernize with CONFLICTS, recommended dependencies
and resources (Jens Rehsack)
Changed DBI::ProfileDumper to rename any existing profile file by
appending .prev, instead of overwriting it.
Changed DBI::ProfileDumper::Apache to work in more configurations
including vhosts using PerlOptions +Parent.
Add driver_prefix method to DBI (Jens Rehsack)
Added more tests to 50dbm_simple.t to prove optimizations in
DBI::SQL::Nano and SQL::Statement (Jens Rehsack)
Updated tests to cover optional installed SQL::Statement (Jens Rehsack)
Synchronize API between SQL::Statement and DBI::SQL::Nano (Jens Rehsack)
Merged some optimizations from SQL::Statement into DBI::SQL::Nano
(Jens Rehsack)
Added basic test for DBD::File (H.Merijn Brand, Jens Rehsack)
Extract dealing with Perl SQL engines from DBD::File into
DBI::DBD::SqlEngine for better subclassing of 3rd party non-db DBDs
(Jens Rehsack)
Updated and clarified documentation for finish method (Tim Bunce).
Changes to DBD::File for better English and hopefully better
explanation (Martin J. Evans)
Update documentation of DBD::DBM to cover current implementation,
tried to explain some things better and changes most examples to
preferred style of Merijn and myself (Jens Rehsack)
Added developer documentation (including a roadmap of future plans)
for DBD::File
=head2 Changes in DBI 1.611 (svn r13935) 29th April 2010
NOTE: minimum perl version is now 5.8.1 (as announced in DBI 1.607)
Fixed selectcol_arrayref MaxRows attribute to count rows not values
thanks to Vernon Lyon.
Fixed DBI->trace(0, *STDERR); (H.Merijn Brand)
which tried to open a file named "*main::STDERR" in perl-5.10.x
Fixes in DBD::DBM for use under threads (Jens Rehsack)
Changed "Issuing rollback() due to DESTROY without explicit disconnect"
warning to not be issued if ReadOnly set for that dbh.
Added f_lock and f_encoding support to DBD::File (H.Merijn Brand)
Added ChildCallbacks => { ... } to Callbacks as a way to
specify Callbacks for child handles.
With tests added by David E. Wheeler.
Added DBI::sql_type_cast($value, $type, $flags) to cast a string value
to an SQL type. e.g. SQL_INTEGER effectively does $value += 0;
Has other options plus an internal interface for drivers.
Documentation changes:
Small fixes in the documentation of DBD::DBM (H.Merijn Brand)
Documented specification of type casting behaviour for bind_col()
based on DBI::sql_type_cast() and two new bind_col attributes
StrictlyTyped and DiscardString. Thanks to Martin Evans.
Document fetchrow_hashref() behaviour for functions,
aliases and duplicate names (H.Merijn Brand)
Updated DBI::Profile and DBD::File docs to fix pod nits
thanks to Frank Wiegand.
Corrected typos in Gopher documentation reported by Jan Krynicky.
Documented the Callbacks attribute thanks to David E. Wheeler.
Corrected the Timeout examples as per rt 50621 (Martin J. Evans).
Removed some internal broken links in the pod (Martin J. Evans)
Added Note to column_info for drivers which do not
support it (Martin J. Evans)
Updated dbipport.h to Devel::PPPort 3.19 (H.Merijn Brand)
=head2 Changes in DBI 1.609 (svn r12816) 8th June 2009
Fixes to DBD::File (H.Merijn Brand)
added f_schema attribute
table names case sensitive when quoted, insensitive when unquoted
workaround a bug in SQL::Statement (temporary fix) related
to the "You passed x parameters where y required" error
Added ImplementorClass and Name info to the "Issuing rollback() due to
DESTROY without explicit disconnect" warning to identify the handle.
Applies to compiled drivers when they are recompiled.
Added DBI->visit_handles($coderef) method.
Added $h->visit_child_handles($coderef) method.
Added docs for column_info()'s COLUMN_DEF value.
Clarified docs on stickyness of data type via bind_param().
Clarified docs on stickyness of data type via bind_col().
=head2 Changes in DBI 1.608 (svn r12742) 5th May 2009
Fixes to DBD::File (H.Merijn Brand)
bind_param () now honors the attribute argument
added f_ext attribute
File::Spec is always required. (CORE since 5.00405)
Fail and set errstr on parameter count mismatch in execute ()
Fixed two small memory leaks when running in mod_perl
one in DBI->connect and one in DBI::Gofer::Execute.
Both due to "local $ENV{...};" leaking memory.
Fixed DBD_ATTRIB_DELETE macro for driver authors
and updated DBI::DBD docs thanks to Martin J. Evans.
Fixed 64bit issues in trace messages thanks to Charles Jardine.
Fixed FETCH_many() method to work with drivers that incorrectly return
an empty list from $h->FETCH. Affected gofer.
Added 'sqlite_' as registered prefix for DBD::SQLite.
Corrected many typos in DBI docs thanks to Martin J. Evans.
Improved DBI::DBD docs thanks to H.Merijn Brand.
=head2 Changes in DBI 1.607 (svn r11571) 22nd July 2008
NOTE: Perl 5.8.1 is now the minimum supported version.
If you need support for earlier versions send me a patch.
Fixed missing import of carp in DBI::Gofer::Execute.
Added note to docs about effect of execute(@empty_array).
Clarified docs for ReadOnly thanks to Martin Evans.
=head2 Changes in DBI 1.605 (svn r11434) 16th June 2008
Fixed broken DBIS macro with threads on big-endian machines
with 64bit ints but 32bit pointers. Ticket #32309.
Fixed the selectall_arrayref, selectrow_arrayref, and selectrow_array
methods that get embedded into compiled drivers to use the
inner sth handle when passed a $sth instead of an sql string.
Drivers will need to be recompiled to pick up this change.
Fixed leak in neat() for some kinds of values thanks to Rudolf Lippan.
Fixed DBI::PurePerl neat() to behave more like XS neat().
Increased default $DBI::neat_maxlen from 400 to 1000.
Increased timeout on tests to accommodate very slow systems.
Changed behaviour of trace levels 1..4 to show less information
at lower levels.
Changed the format of the key used for $h->{CachedKids}
(which is undocumented so you shouldn't depend on it anyway)
Changed gofer error handling to avoid duplicate error text in errstr.
Clarified docs re ":N" style placeholders.
Improved gofer retry-on-error logic and refactored to aid subclassing.
Improved gofer trace output in assorted ways.
Removed the beeps "\a" from Makefile.PL warnings.
Removed check for PlRPC-modules from Makefile.PL
Added sorting of ParamValues reported by ShowErrorStatement
thanks to to Rudolf Lippan.
Added cache miss trace message to DBD::Gofer transport class.
Added $drh->dbixs_revision method.
Added explicit LICENSE specification (perl) to META.yaml
=head2 Changes in DBI 1.604 (svn rev 10994) 24th March 2008
Fixed fetchall_arrayref with $max_rows argument broken in 1.603,
thanks to Greg Sabino Mullane.
Fixed a few harmless compiler warnings on cygwin.
=head2 Changes in DBI 1.603
Fixed pure-perl fetchall_arrayref with $max_rows argument
to not error when fetching after all rows already fetched.
(Was fixed for compiled drivers back in DBI 1.31.)
Thanks to Mark Overmeer.
Fixed C sprintf formats and casts, fixing compiler warnings.
Changed dbi_profile() to accept a hash of profiles and apply to all.
Changed gofer stream transport to improve error reporting.
Changed gofer test timeout to avoid spurious failures on slow systems.
Added options to t/85gofer.t so it's more useful for manual testing.
=head2 Changes in DBI 1.602 (svn rev 10706) 8th February 2008
Fixed potential coredump if stack reallocated while calling back
into perl from XS code. Thanks to John Gardiner Myers.
Fixed DBI::Util::CacheMemory->new to not clear the cache.
Fixed avg in DBI::Profile as_text() thanks to Abe Ingersoll.
Fixed DBD::DBM bug in push_names thanks to J M Davitt.
Fixed take_imp_data for some platforms thanks to Jeffrey Klein.
Fixed docs tie'ing CacheKids (ie LRU cache) thanks to Peter John Edwards.
Expanded DBI::DBD docs for driver authors thanks to Martin Evans.
Enhanced t/80proxy.t test script.
Enhanced t/85gofer.t test script thanks to Stig.
Enhanced t/10examp.t test script thanks to David Cantrell.
Documented $DBI::stderr as the default value of err for internal errors.
Gofer changes:
track_recent now also keeps track of N most recent errors.
The connect method is now also counted in stats.
=head2 Changes in DBI 1.601 (svn rev 10103), 21st October 2007
Fixed t/05thrclone.t to work with Test::More >= 0.71
thanks to Jerry D. Hedden and Michael G Schwern.
Fixed DBI for VMS thanks to Peter (Stig) Edwards.
Added client-side caching to DBD::Gofer. Can use any cache with
get($k)/set($k,$v) methods, including all the Cache and Cache::Cache
distribution modules plus Cache::Memcached, Cache::FastMmap etc.
Works for all transports. Overridable per handle.
Added DBI::Util::CacheMemory for use with DBD::Gofer caching.
It's a very fast and small strict subset of Cache::Memory.
=head2 Changes in DBI 1.59 (svn rev 9874), 23rd August 2007
Fixed DBI::ProfileData to unescape headers lines read from data file.
Fixed DBI::ProfileData to not clobber $_, thanks to Alexey Tourbin.
Fixed DBI::SQL::Nano to not clobber $_, thanks to Alexey Tourbin.
Fixed DBI::PurePerl to return undef for ChildHandles if weaken not available.
Fixed DBD::Proxy disconnect error thanks to Philip Dye.
Fixed DBD::Gofer::Transport::Base bug (typo) in timeout code.
Fixed DBD::Proxy rows method thanks to Philip Dye.
Fixed dbiprof compile errors, thanks to Alexey Tourbin.
Fixed t/03handle.t to skip some tests if ChildHandles not available.
Added check_response_sub to DBI::Gofer::Execute
=head2 Changes in DBI 1.58 (svn rev 9678), 25th June 2007
Fixed code triggering fatal error in bleadperl, thanks to Steve Hay.
Fixed compiler warning thanks to Jerry D. Hedden.
Fixed t/40profile.t to use int(dbi_time()) for systems like Cygwin where
time() seems to be rounded not truncated from the high resolution time.
Removed dump_results() test from t/80proxy.t.
=head2 Changes in DBI 1.57 (svn rev 9639), 13th June 2007
Note: this release includes a change to the DBI::hash() function which will
now produce different values than before *if* your perl was built with 64-bit
'int' type (i.e. "perl -V:intsize" says intsize='8'). It's relatively rare
for perl to be configured that way, even on 64-bit systems.
Fixed XS versions of select*_*() methods to call execute()
fetch() etc., with inner handle instead of outer.
Fixed execute_for_fetch() to not cache errstr values
thanks to Bart Degryse.
Fixed unused var compiler warning thanks to JDHEDDEN.
Fixed t/86gofer_fail tests to be less likely to fail falsely.
Changed DBI::hash to return 'I32' type instead of 'int' so results are
portable/consistent regardless of size of the int type.
Corrected timeout example in docs thanks to Egmont Koblinger.
Changed t/01basic.t to warn instead of failing when it detects
a problem with Math::BigInt (some recent versions had problems).
Added support for !Time and !Time~N to DBI::Profile Path. See docs.
Added extra trace info to connect_cached thanks to Walery Studennikov.
Added non-random (deterministic) mode to DBI_GOFER_RANDOM mechanism.
Added DBIXS_REVISION macro that drivers can use.
Added more docs for private_attribute_info() method.
DBI::Profile changes:
dbi_profile() now returns ref to relevant leaf node.
Don't profile DESTROY during global destruction.
Added as_node_path_list() and as_text() methods.
DBI::ProfileDumper changes:
Don't write file if there's no profile data.
Uses full natural precision when saving data (was using %.6f)
Optimized flush_to_disk().
Locks the data file while writing.
Enabled filename to be a code ref for dynamic names.
DBI::ProfileDumper::Apache changes:
Added Quiet=>1 to avoid write to STDERR in flush_to_disk().
Added Dir=>... to specify a writable destination directory.
Enabled DBI_PROFILE_APACHE_LOG_DIR for mod_perl 1 as well as 2.
Added parent pid to default data file name.
DBI::ProfileData changes:
Added DeleteFiles option to rename & delete files once read.
Locks the data files while reading.
Added ability to sort by Path elements.
dbiprof changes:
Added --dumpnodes and --delete options.
Added/updated docs for both DBI::ProfileDumper && ::Apache.
=head2 Changes in DBI 1.56 (svn rev 9660), 18th June 2007
Fixed printf arg warnings thanks to JDHEDDEN.
Fixed returning driver-private sth attributes via gofer.
Changed pod docs docs to use =head3 instead of =item
so now in html you get links to individual methods etc.
Changed default gofer retry_limit from 2 to 0.
Changed tests to workaround Math::BigInt broken versions.
Changed dbi_profile_merge() to dbi_profile_merge_nodes()
old name still works as an alias for the new one.
Removed old DBI internal sanity check that's no longer valid
causing "panic: DESTROY (dbih_clearcom)" when tracing enabled
Added DBI_GOFER_RANDOM env var that can be use to trigger random
failures and delays when executing gofer requests. Designed to help
test automatic retry on failures and timeout handling.
Added lots more docs to all the DBD::Gofer and DBI::Gofer classes.
=head2 Changes in DBI 1.55 (svn rev 9504), 4th May 2007
Fixed set_err() so HandleSetErr hook is executed reliably, if set.
Fixed accuracy of profiling when perl configured to use long doubles.
Fixed 42prof_data.t on fast systems with poor timers thanks to Malcolm Nooning.
Fixed potential corruption in selectall_arrayref and selectrow_arrayref
for compiled drivers, thanks to Rob Davies.
Rebuild your compiled drivers after installing DBI.
Changed some handle creation code from perl to C code,
to reduce handle creation cost by ~20%.
Changed internal implementation of the CachedKids attribute
so it's a normal handle attribute (and initially undef).
Changed connect_cached and prepare_cached to avoid a FETCH method call,
and thereby reduced cost by ~5% and ~30% respectively.
Changed _set_fbav to not croak when given a wrongly sized array,
it now warns and adjusts the row buffer to match.
Changed some internals to improve performance with threaded perls.
Changed DBD::NullP to be slightly more useful for testing.
Changed File::Spec prerequisite to not require a minimum version.
Changed tests to work with other DBMs thanks to ZMAN.
Changed ex/perl_dbi_nulls_test.pl to be more descriptive.
Added more functionality to the (undocumented) Callback mechanism.
Callbacks can now elect to provide a value to be returned, in which case
the method won't be called. A callback for "*" is applied to all methods
that don't have their own callback.
Added $h->{ReadOnly} attribute.
Added support for DBI Profile Path to contain refs to scalars
which will be de-ref'd for each profile sample.
Added dbilogstrip utility to edit DBI logs for diff'ing (gets installed)
Added details for SQLite 3.3 to NULL handling docs thanks to Alex Teslik.
Added take_imp_data() to DBI::PurePerl.
Gofer related changes:
Fixed gofer pipeone & stream transports to avoid risk of hanging.
Improved error handling and tracing significantly.
Added way to generate random 1-in-N failures for methods.
Added automatic retry-on-error mechanism to gofer transport base class.
Added tests to show automatic retry mechanism works a treat!
Added go_retry_hook callback hook so apps can fine-tune retry behaviour.
Added header to request and response packets for sanity checking
and to enable version skew between client and server.
Added forced_single_resultset, max_cached_sth_per_dbh and max_cached_dbh_per_drh
to gofer executor config.
Driver-private methods installed with install_method are now proxied.
No longer does a round-trip to the server for methods it knows
have not been overridden by the remote driver.
Most significant aspects of gofer behaviour are controlled by policy mechanism.
Added policy-controlled caching of results for some methods, such as schema metadata.
The connect_cached and prepare_cached methods cache on client and server.
The bind_param_array and execute_array methods are now supported.
Worked around a DBD::Sybase bind_param bug (which is fixed in DBD::Sybase 1.07)
Added goferperf.pl utility (doesn't get installed).
Many other assorted Gofer related bug fixes, enhancements and docs.
The http and mod_perl transports have been remove to their own distribution.
Client and server will need upgrading together for this release.
=head2 Changes in DBI 1.54 (svn rev 9157), 23rd February 2007
NOTE: This release includes the 'next big thing': DBD::Gofer.
Take a look!
WARNING: This version has some subtle changes in DBI internals.
It's possible, though doubtful, that some may affect your code.
I recommend some extra testing before using this release.
Or perhaps I'm just being over cautious...
Fixed type_info when called for multiple dbh thanks to Cosimo Streppone.
Fixed compile warnings in bleadperl on freebsd-6.1-release
and solaris 10g thanks to Philip M. Gollucci.
Fixed to compile for perl built with -DNO_MATHOMS thanks to Jerry D. Hedden.
Fixed to work for bleadperl (r29544) thanks to Nicholas Clark.
Users of Perl >= 5.9.5 will require DBI >= 1.54.
Fixed rare error when profiling access to $DBI::err etc tied variables.
Fixed DBI::ProfileDumper to not be affected by changes to $/ and $,
thanks to Michael Schwern.
Changed t/40profile.t to skip tests for perl < 5.8.0.
Changed setting trace file to no longer write "Trace file set" to new file.
Changed 'handle cleared whilst still active' warning for dbh
to only be given for dbh that have active sth or are not AutoCommit.
Changed take_imp_data to call finish on all Active child sth.
Changed DBI::PurePerl trace() method to be more consistent.
Changed set_err method to effectively not append to errstr if the new errstr
is the same as the current one.
Changed handle factory methods, like connect, prepare, and table_info,
to copy any error/warn/info state of the handle being returned
up into the handle the method was called on.
Changed row buffer handling to not alter NUM_OF_FIELDS if it's
inconsistent with number of elements in row buffer array.
Updated DBI::DBD docs re handling multiple result sets.
Updated DBI::DBD docs for driver authors thanks to Ammon Riley
and Dean Arnold.
Updated column_info docs to note that if a table doesn't exist
you get an sth for an empty result set and not an error.
Added new DBD::Gofer 'stateless proxy' driver and framework,
and the DBI test suite is now also executed via DBD::Gofer,
and DBD::Gofer+DBI::PurePerl, in addition to DBI::PurePerl.
Added ability for trace() to support filehandle argument,
including tracing into a string, thanks to Dean Arnold.
Added ability for drivers to implement func() method
so proxy drivers can proxy the func method itself.
Added SQL_BIGINT type code (resolved to the ODBC/JDBC value (-5))
Added $h->private_attribute_info method.
=head2 Changes in DBI 1.53 (svn rev 7995), 31st October 2006
Fixed checks for weaken to work with early 5.8.x versions
Fixed DBD::Proxy handling of some methods, including commit and rollback.
Fixed t/40profile.t to be more insensitive to long double precision.
Fixed t/40profile.t to be insensitive to small negative shifts in time
thanks to Jamie McCarthy.
Fixed t/40profile.t to skip tests for perl < 5.8.0.
Fixed to work with current 'bleadperl' (~5.9.5) thanks to Steve Peters.
Users of Perl >= 5.9.5 will require DBI >= 1.53.
Fixed to be more robust against drivers not handling multiple result
sets properly, thanks to Gisle Aas.
Added array context support to execute_array and execute_for_fetch
methods which returns executed tuples and rows affected.
Added Tie::Cache::LRU example to docs thanks to Brandon Black.
=head2 Changes in DBI 1.52 (svn rev 6840), 30th July 2006
Fixed memory leak (per handle) thanks to Nicholas Clark and Ephraim Dan.
Fixed memory leak (16 bytes per sth) thanks to Doru Theodor Petrescu.
Fixed execute_for_fetch/execute_array to RaiseError thanks to Martin J. Evans.
Fixed for perl 5.9.4. Users of Perl >= 5.9.4 will require DBI >= 1.52.
Updated DBD::File to 0.35 to match the latest release on CPAN.
Added $dbh->statistics_info specification thanks to Brandon Black.
Many changes and additions to profiling:
Profile Path can now uses sane strings instead of obscure numbers,
can refer to attributes, assorted magical values, and even code refs!
Parsing of non-numeric DBI_PROFILE env var values has changed.
Changed DBI::Profile docs extensively - many new features.
See DBI::Profile docs for more information.
=head2 Changes in DBI 1.51 (svn rev 6475), 6th June 2006
Fixed $dbh->clone method 'signature' thanks to Jeffrey Klein.
Fixed default ping() method to return false if !$dbh->{Active}.
Fixed t/40profile.t to be insensitive to long double precision.
Fixed for perl 5.8.0's more limited weaken() function.
Fixed DBD::Proxy to not alter $@ in disconnect or AUTOLOADd methods.
Fixed bind_columns() to use return set_err(...) instead of die()
to report incorrect number of parameters, thanks to Ben Thul.
Fixed bind_col() to ignore undef as bind location, thanks to David Wheeler.
Fixed for perl 5.9.x for non-threaded builds thanks to Nicholas Clark.
Users of Perl >= 5.9.x will require DBI >= 1.51.
Fixed fetching of rows as hash refs to preserve utf8 on field names
from $sth->{NAME} thanks to Alexey Gaidukov.
Fixed build on Win32 (dbd_postamble) thanks to David Golden.
Improved performance for thread-enabled perls thanks to Gisle Aas.
Drivers can now use PERL_NO_GET_CONTEXT thanks to Gisle Aas.
Driver authors please read the notes in the DBI::DBD docs.
Changed DBI::Profile format to always include a percentage,
if not exiting then uses time between the first and last DBI call.
Changed DBI::ProfileData to be more forgiving of systems with
unstable clocks (where time may go backwards occasionally).
Clarified the 'Subclassing the DBI' docs.
Assorted minor changes to docs from comments on annocpan.org.
Changed Makefile.PL to avoid incompatible options for old gcc.
Added 'fetch array of hash refs' example to selectall_arrayref
docs thanks to Tom Schindl.
Added docs for $sth->{ParamArrays} thanks to Martin J. Evans.
Added reference to $DBI::neat_maxlen in TRACING section of docs.
Added ability for DBI::Profile Path to include attributes
and a summary of where the code was called from.
=head2 Changes in DBI 1.50 (svn rev 2307), 13 December 2005
Fixed Makefile.PL options for gcc bug introduced in 1.49.
Fixed handle magic order to keep DBD::Oracle happy.
Fixed selectrow_array to return empty list on error.
Changed dbi_profile_merge() to be able to recurse and merge
sub-trees of profile data.
Added documentation for dbi_profile_merge(), including how to
measure the time spent inside the DBI for an http request.
=head2 Changes in DBI 1.49 (svn rev 2287), 29th November 2005
Fixed assorted attribute handling bugs in DBD::Proxy.
Fixed croak() in DBD::NullP thanks to Sergey Skvortsov.
Fixed handling of take_imp_data() and dbi_imp_data attribute.
Fixed bugs in DBD::DBM thanks to Jeff Zucker.
Fixed bug in DBI::ProfileDumper thanks to Sam Tregar.
Fixed ping in DBD::Proxy thanks to George Campbell.
Fixed dangling ref in $sth after parent $dbh destroyed
with thanks to il@rol.ru for the bug report #13151
Fixed prerequisites to include Storable thanks to Michael Schwern.
Fixed take_imp_data to be more practical.
Change to require perl 5.6.1 (as advertised in 2003) not 5.6.0.
Changed internals to be more strictly coded thanks to Andy Lester.
Changed warning about multiple copies of Driver.xst found in @INC
to ignore duplicated directories thanks to Ed Avis.
Changed Driver.xst to enable drivers to define an dbd_st_prepare_sv
function where the statement parameter is an SV. That enables
compiled drivers to support SQL strings that are UTF-8.
Changed "use DBI" to only set $DBI::connect_via if not already set.
Changed docs to clarify pre-method clearing of err values.
Added ability for DBI::ProfileData to edit profile path on loading.
This enables aggregation of different SQL statements into the same
profile node - very handy when not using placeholders or when working
multiple separate tables for the same thing (ie logtable_2005_11_28)
Added $sth->{ParamTypes} specification thanks to Dean Arnold.
Added $h->{Callbacks} attribute to enable code hooks to be invoked
when certain methods are called. For example:
$dbh->{Callbacks}->{prepare} = sub { ... };
With thanks to David Wheeler for the kick start.
Added $h->{ChildHandles} (using weakrefs) thanks to Sam Tregar
I've recoded it in C so there's no significant performance impact.
Added $h->{Type} docs (returns 'dr', 'db', or 'st')
Adding trace message in DESTROY if InactiveDestroy enabled.
Added %drhs = DBI->installed_drivers();
Ported DBI::ProfileDumper::Apache to mod_perl2 RC5+
thanks to Philip M. Golluci
=head2 Changes in DBI 1.48 (svn rev 928), 14th March 2005
Fixed DBI::DBD::Metadata generation of type_info_all thanks to Steffen Goeldner
(driver authors who have used it should rerun it).
Updated docs for NULL Value placeholders thanks to Brian Campbell.
Added multi-keyfield nested hash fetching to fetchall_hashref()
thanks to Zhuang (John) Li for polishing up my draft.
Added registered driver prefixes: amzn_ for DBD::Amazon and yaswi_ for DBD::Yaswi.
=head2 Changes in DBI 1.47 (svn rev 854), 2nd February 2005
Fixed DBI::ProxyServer to not create pid files by default.
References: Ubuntu Security Notice USN-70-1, CAN-2005-0077
Thanks to Javier Fernndez-Sanguino Pea from the
Debian Security Audit Project, and Jonathan Leffler.
Fixed some tests to work with older Test::More versions.
Fixed setting $DBI::err/errstr in DBI::PurePerl.
Fixed potential undef warning from connect_cached().
Fixed $DBI::lasth handling for DESTROY so lasth points to
parent even if DESTROY called other methods.
Fixed DBD::Proxy method calls to not alter $@.
Fixed DBD::File problem with encoding pragma thanks to Erik Rijkers.
Changed error handling so undef errstr doesn't cause warning.
Changed DBI::DBD docs to use =head3/=head4 pod thanks to
Jonathan Leffler. This may generate warnings for perl 5.6.
Changed DBI::PurePerl to set autoflush on trace filehandle.
Changed DBD::Proxy to treat Username as a local attribute
so recent DBI version can be used with old DBI::ProxyServer.
Changed driver handle caching in DBD::File.
Added $GetInfoType{SQL_DATABASE_NAME} thanks to Steffen Goeldner.
Updated docs to recommend some common DSN string attributes.
Updated connect_cached() docs with issues and suggestions.
Updated docs for NULL Value placeholders thanks to Brian Campbell.
Updated docs for primary_key_info and primary_keys.
Updated docs to clarify that the default fetchrow_hashref behaviour,
of returning a ref to a new hash for each row, will not change.
Updated err/errstr/state docs for DBD authors thanks to Steffen Goeldner.
Updated handle/attribute docs for DBD authors thanks to Steffen Goeldner.
Corrected and updated LongReadLen docs thanks to Bart Lateur.
Added DBD::JDBC as a registered driver.
=head2 Changes in DBI 1.46 (svn rev 584), 16th November 2004
Fixed parsing bugs in DBI::SQL::Nano thanks to Jeff Zucker.
Fixed a couple of bad links in docs thanks to Graham Barr.
Fixed test.pl Win32 undef warning thanks to H.Merijn Brand & David Repko.
Fixed minor issues in DBI::DBD::Metadata thanks to Steffen Goeldner.
Fixed DBI::PurePerl neat() to use double quotes for utf8.
Changed execute_array() definition, and default implementation,
to not consider scalar values for execute tuple count. See docs.
Changed DBD::File to enable ShowErrorStatement by default,
which affects DBD::File subclasses such as DBD::CSV and DBD::DBM.
Changed use DBI qw(:utils) tag to include $neat_maxlen.
Updated Roadmap and ToDo.
Added data_string_diff() data_string_desc() and data_diff()
utility functions to help diagnose Unicode issues.
All can be imported via the use DBI qw(:utils) tag.
=head2 Changes in DBI 1.45 (svn rev 480), 6th October 2004
Fixed DBI::DBD code for drivers broken in 1.44.
Fixed "Free to wrong pool"/"Attempt to free unreferenced scalar" in FETCH.
=head2 Changes in DBI 1.44 (svn rev 478), 5th October 2004
Fixed build issues on VMS thanks to Jakob Snoer.
Fixed DBD::File finish() method to return 1 thanks to Jan Dubois.
Fixed rare core dump during global destruction thanks to Mark Jason Dominus.
Fixed risk of utf8 flag persisting from one row to the next.
Changed bind_param_array() so it doesn't require all bind arrays
to have the same number of elements.
Changed bind_param_array() to error if placeholder number <= 0.
Changed execute_array() definition, and default implementation,
to effectively NULL-pad shorter bind arrays.
Changed execute_array() to return "0E0" for 0 as per the docs.
Changed execute_for_fetch() definition, and default implementation,
to return "0E0" for 0 like execute() and execute_array().
Changed Test::More prerequisite to Test::Simple (which is also the name
of the distribution both are packaged in) to work around ppm behaviour.
Corrected docs to say that get/set of unknown attribute generates
a warning and is no longer fatal. Thanks to Vadim.
Corrected fetchall_arrayref() docs example thanks to Drew Broadley.
Added $h1->swap_inner_handle($h2) sponsored by BizRate.com
=head2 Changes in DBI 1.43 (svn rev 377), 2nd July 2004
Fixed connect() and connect_cached() RaiseError/PrintError
which would sometimes show "(no error string)" as the error.
Fixed compiler warning thanks to Paul Marquess.
Fixed "trace level set to" trace message thanks to H.Merijn Brand.
Fixed DBD::DBM $dbh->{dbm_tables}->{...} to be keyed by the
table name not the file name thanks to Jeff Zucker.
Fixed last_insert_id(...) thanks to Rudy Lippan.
Fixed propagation of scalar/list context into proxied methods.
Fixed DBI::Profile::DESTROY to not alter $@.
Fixed DBI::ProfileDumper new() docs thanks to Michael Schwern.
Fixed _load_class to propagate $@ thanks to Drew Taylor.
Fixed compile warnings on Win32 thanks to Robert Baron.
Fixed problem building with recent versions of MakeMaker.
Fixed DBD::Sponge not to generate warning with threads.
Fixed DBI_AUTOPROXY to work more than once thanks to Steven Hirsch.
Changed TraceLevel 1 to not show recursive/nested calls.
Changed getting or setting an invalid attribute to no longer be
a fatal error but generate a warning instead.
Changed selectall_arrayref() to call finish() if
$attr->{MaxRows} is defined.
Changed all tests to use Test::More and enhanced the tests thanks
to Stevan Little and Andy Lester. See http://qa.perl.org/phalanx/
Changed Test::More minimum prerequisite version to 0.40 (2001).
Changed DBI::Profile header to include the date and time.
Added DBI->parse_dsn($dsn) method.
Added warning if build directory path contains white space.
Added docs for parse_trace_flags() and parse_trace_flag().
Removed "may change" warnings from the docs for table_info(),
primary_key_info(), and foreign_key_info() methods.
=head2 Changes in DBI 1.42 (svn rev 222), 12th March 2004
Fixed $sth->{NUM_OF_FIELDS} of non-executed statement handle
to be undef as per the docs (it was 0).
Fixed t/41prof_dump.t to work with perl5.9.1.
Fixed DBD_ATTRIB_DELETE macro thanks to Marco Paskamp.
Fixed DBI::PurePerl looks_like_number() and $DBI::rows.
Fixed ref($h)->can("foo") to not croak.
Changed attributes (NAME, TYPE etc) of non-executed statement
handle to be undef instead of triggering an error.
Changed ShowErrorStatement to apply to more $dbh methods.
Changed DBI_TRACE env var so just does this at load time:
DBI->trace(split '=', $ENV{DBI_TRACE}, 2);
Improved "invalid number of parameters" error message.
Added DBI::common as base class for DBI::db, DBD::st etc.
Moved methods common to all handles into DBI::common.
Major tracing enhancement:
Added $h->parse_trace_flags("foo|SQL|7") to map a group of
trace flags into the corresponding trace flag bits.
Added automatic calling of parse_trace_flags() if
setting the trace level to a non-numeric value:
$h->{TraceLevel}="foo|SQL|7"; $h->trace("foo|SQL|7");
DBI->connect("dbi:Driver(TraceLevel=SQL|foo):...", ...);
Currently no trace flags have been defined.
Added to, and reworked, the trace documentation.
Added dbivport.h for driver authors to use.
Major driver additions that Jeff Zucker and I have been working on:
Added DBI::SQL::Nano a 'smaller than micro' SQL parser
with an SQL::Statement compatible API. If SQL::Statement
is installed then DBI::SQL::Nano becomes an empty subclass
of SQL::Statement, unless the DBI_SQL_NANO env var is true.
Added DBD::File, modified to use DBI::SQL::Nano.
Added DBD::DBM, an SQL interface to DBM files using DBD::File.
Documentation changes:
Corrected typos in docs thanks to Steffen Goeldner.
Corrected execute_for_fetch example thanks to Dean Arnold.
=head2 Changes in DBI 1.41 (svn rev 130), 22nd February 2004
Fixed execute_for_array() so tuple_status parameter is optional
as per docs, thanks to Ed Avis.
Fixed execute_for_array() docs to say that it returns undef if
any of the execute() calls fail.
Fixed take_imp_data() test on m68k reported by Christian Hammers.
Fixed write_typeinfo_pm inconsistencies in DBI::DBD::Metadata
thanks to Andy Hassall.
Fixed $h->{TraceLevel} to not return DBI->trace trace level
which it used to if DBI->trace trace level was higher.
Changed set_err() to append to errstr, with a leading "\n" if it's
not empty, so that multiple error/warning messages are recorded.
Changed trace to limit elements dumped when an array reference is
returned from a method to the max(40, $DBI::neat_maxlen/10)
so that fetchall_arrayref(), for example, doesn't flood the trace.
Changed trace level to be a four bit integer (levels 0 thru 15)
and a set of topic flags (no topics have been assigned yet).
Changed column_info() to check argument count.
Extended bind_param() TYPE attribute specification to imply
standard formating of value, eg SQL_DATE implies 'YYYY-MM-DD'.
Added way for drivers to indicate 'success with info' or 'warning'
by setting err to "0" for warning and "" for information.
Both values are false and so don't trigger RaiseError etc.
Thanks to Steffen Goeldner for the original idea.
Added $h->{HandleSetErr} = sub { ... } to be called at the
point that an error, warn, or info state is recorded.
The code can alter the err, errstr, and state values
(e.g., to promote an error to a warning, or the reverse).
Added $h->{PrintWarn} attribute to enable printing of warnings
recorded by the driver. Defaults to same value as $^W (perl -w).
Added $h->{ErrCount} attribute, incremented whenever an error is
recorded by the driver via set_err().
Added $h->{Executed} attribute, set if do()/execute() called.
Added \%attr parameter to foreign_key_info() method.
Added ref count of inner handle to "DESTROY ignored for outer" msg.
Added Win32 build config checks to DBI::DBD thanks to Andy Hassall.
Added bind_col to Driver.xst so drivers can define their own.
Added TYPE attribute to bind_col and specified the expected
driver behaviour.
Major update to signal handling docs thanks to Lincoln Baxter.
Corrected dbiproxy usage doc thanks to Christian Hammers.
Corrected type_info_all index hash docs thanks to Steffen Goeldner.
Corrected type_info COLUMN_SIZE to chars not bytes thanks to Dean Arnold.
Corrected get_info() docs to include details of DBI::Const::GetInfoType.
Clarified that $sth->{PRECISION} is OCTET_LENGTH for char types.
=head2 Changes in DBI 1.40, 7th January 2004
Fixed handling of CachedKids when DESTROYing threaded handles.
Fixed sql_user_name() in DBI::DBD::Metadata (used by write_getinfo_pm)
to use $dbh->{Username}. Driver authors please update your code.
Changed connect_cached() when running under Apache::DBI
to route calls to Apache::DBI::connect().
Added CLONE() to DBD::Sponge and DBD::ExampleP.
Added warning when starting a new thread about any loaded driver
which does not have a CLONE() function.
Added new prepare_cache($sql, \%attr, 3) option to manage Active handles.
Added SCALE and NULLABLE support to DBD::Sponge.
Added missing execute() in fetchall_hashref docs thanks to Iain Truskett.
Added a CONTRIBUTING section to the docs with notes on creating patches.
=head2 Changes in DBI 1.39, 27th November 2003
Fixed STORE to not clear error during nested DBI call, again/better,
thanks to Tony Bowden for the report and helpful test case.
Fixed DBI dispatch to not try to use AUTOLOAD for driver methods unless
the method has been declared (as methods should be when using AUTOLOAD).
This fixes a problem when the Attribute::Handlers module is loaded.
Fixed cwd check code to use $Config{path_sep} thanks to Steve Hay.
Fixed unqualified croak() calls thanks to Steffen Goeldner.
Fixed DBD::ExampleP TYPE and PRECISION attributes thanks to Tom Lowery.
Fixed tracing of methods that only get traced at high trace levels.
The level 1 trace no longer includes nested method calls so it generally
just shows the methods the application explicitly calls.
Added line to trace log (level>=4) when err/errstr is cleared.
Updated docs for InactiveDestroy and point out where and when the
trace includes the process id.
Update DBI::DBD docs thanks to Steffen Goeldner.
Removed docs saying that the DBI->data_sources method could be
passed a $dbh. The $dbh->data_sources method should be used instead.
Added link to 'DBI recipes' thanks to Giuseppe Maxia:
http://gmax.oltrelinux.com/dbirecipes.html (note that this
is not an endorsement that the recipies are 'optimal')
Note: There is a bug in perl 5.8.2 when configured with threads
and debugging enabled (bug #24463) which causes a DBI test to fail.
=head2 Changes in DBI 1.38, 21th August 2003
NOTE: The DBI now requires perl version 5.6.0 or later.
(As per notice in DBI 1.33 released 27th February 2003)
Fixed spurious t/03handles failure on 64bit perls reported by H.Merijn Brand.
Fixed spurious t/15array failure on some perl versions thanks to Ed Avis.
Fixed build using dmake on windows thanks to Steffen Goeldner.
Fixed build on using some shells thanks to Gurusamy Sarathy.
Fixed ParamValues to only be appended to ShowErrorStatement if not empty.
Fixed $dbh->{Statement} not being writable by drivers in some cases.
Fixed occasional undef warnings on connect failures thanks to Ed Avis.
Fixed small memory leak when using $sth->{NAME..._hash}.
Fixed 64bit warnings thanks to Marian Jancar.
Fixed DBD::Proxy::db::DESTROY to not alter $@ thanks to Keith Chapman.
Fixed Makefile.PL status from WriteMakefile() thanks to Leon Brocard.
Changed "Can't set ...->{Foo}: unrecognised attribute" from an error to a
warning when running with DBI::ProxyServer to simplify upgrades.
Changed execute_array() to no longer require ArrayTupleStatus attribute.
Changed DBI->available_drivers to not hide DBD::Sponge.
Updated/moved placeholder docs to a better place thanks to Johan Vromans.
Changed dbd_db_do4 api in Driver.xst to match dbd_st_execute (return int,
not bool), relevant only to driver authors.
Changed neat(), and thus trace(), so strings marked as utf8 are presented
in double quotes instead of single quotes and are not sanitized.
Added $dbh->data_sources method.
Added $dbh->last_insert_id method.
Added $sth->execute_for_fetch($fetch_tuple_sub, \@tuple_status) method.
Added DBI->installed_versions thanks to Jeff Zucker.
Added $DBI::Profile::ON_DESTROY_DUMP variable.
Added docs for DBD::Sponge thanks to Mark Stosberg.
=head2 Changes in DBI 1.37, 15th May 2003
Fixed "Can't get dbh->{Statement}: unrecognised attribute" error in test
caused by change to perl internals in 5.8.0
Fixed to build with latest development perl (5.8.1@19525).
Fixed C code to use all ANSI declarations thanks to Steven Lembark.
=head2 Changes in DBI 1.36, 11th May 2003
Fixed DBI->connect to carp instead of croak on 'old-style' usage.
Fixed connect(,,, { RootClass => $foo }) to not croak if module not found.
Fixed code generated by DBI::DBD::Metadata thanks to DARREN@cpan.org (#2270)
Fixed DBI::PurePerl to not reset $@ during method dispatch.
Fixed VMS build thanks to Michael Schwern.
Fixed Proxy disconnect thanks to Steven Hirsch.
Fixed error in DBI::DBD docs thanks to Andy Hassall.
Changed t/40profile.t to not require Time::HiRes.
Changed DBI::ProxyServer to load DBI only on first request, which
helps threaded server mode, thanks to Bob Showalter.
Changed execute_array() return value from row count to executed
tuple count, and now the ArrayTupleStatus attribute is mandatory.
NOTE: That is an API definition change that may affect your code.
Changed CompatMode attribute to also disable attribute 'quick FETCH'.
Changed attribute FETCH to be slightly faster thanks to Stas Bekman.
Added workaround for perl bug #17575 tied hash nested FETCH
thanks to Silvio Wanka.
Added Username and Password attributes to connect(..., \%attr) and so
also embedded in DSN like "dbi:Driver(Username=user,Password=pass):..."
Username and Password can't contain ")", ",", or "=" characters.
The predence is DSN first, then \%attr, then $user & $pass parameters,
and finally the DBI_USER & DBI_PASS environment variables.
The Username attribute is stored in the $dbh but the Password is not.
Added ProxyServer HOWTO configure restrictions docs thanks to Jochen Wiedmann.
Added MaxRows attribute to selectcol_arrayref prompted by Wojciech Pietron.
Added dump_handle as a method not just a DBI:: utility function.
Added on-demand by-row data feed into execute_array() using code ref,
or statement handle. For example, to insert from a select:
$insert_sth->execute_array( { ArrayTupleFetch => $select_sth, ... } )
Added warning to trace log when $h->{foo}=... is ignored due to
invalid prefix (e.g., not 'private_').
=head2 Changes in DBI 1.35, 7th March 2003
Fixed memory leak in fetchrow_hashref introduced in DBI 1.33.
Fixed various DBD::Proxy errors introduced in DBI 1.33.
Fixed to ANSI C in dbd_dr_data_sources thanks to Jonathan Leffler.
Fixed $h->can($method_name) to return correct code ref.
Removed DBI::Format from distribution as it's now part of the
separate DBI::Shell distribution by Tom Lowery.
Updated DBI::DBD docs with a note about the CLONE method.
Updated DBI::DBD docs thanks to Jonathan Leffler.
Updated DBI::DBD::Metadata for perl 5.5.3 thanks to Jonathan Leffler.
Added note to install_method docs about setup_driver() method.
=head2 Changes in DBI 1.34, 28th February 2003
Fixed DBI::DBD docs to refer to DBI::DBD::Metadata thanks to Jonathan Leffler.
Fixed dbi_time() compile using BorlandC on Windows thanks to Steffen Goeldner.
Fixed profile tests to do enough work to measure on Windows.
Fixed disconnect_all() to not be required by drivers.
Added $okay = $h->can($method_name) to check if a method exists.
Added DBD::*::*->install_method($method_name, \%attr) so driver private
methods can be 'installed' into the DBI dispatcher and no longer
need to be called using $h->func(..., $method_name).
Enhanced $dbh->clone() and documentation.
Enhanced docs to note that dbi_time(), and thus profiling, is limited
to only millisecond (seconds/1000) resolution on Windows.
Removed old DBI::Shell from distribution and added Tom Lowery's improved
version to the Bundle::DBI file.
Updated minimum version numbers for modules in Bundle::DBI.
=head2 Changes in DBI 1.33, 27th February 2003
NOTE: Future versions of the DBI *will not* support perl 5.6.0 or earlier.
: Perl 5.6.1 will be the minimum supported version.
NOTE: The "old-style" connect: DBI->connect($database, $user, $pass, $driver);
: has been deprecated for several years and will now generate a warning.
: It will be removed in a later release. Please change any old connect() calls.
Added $dbh2 = $dbh1->clone to make a new connection to the database
that is identical to the original one. clone() can be called even after
the original handle has been disconnected. See the docs for more details.
Fixed merging of profile data to not sum DBIprof_FIRST_TIME values.
Fixed unescaping of newlines in DBI::ProfileData thanks to Sam Tregar.
Fixed Taint bug with fetchrow_hashref with help from Bradley Baetz.
Fixed $dbh->{Active} for DBD::Proxy, reported by Bob Showalter.
Fixed STORE to not clear error during nested DBI call,
thanks to Tony Bowden for the report and helpful test case.
Fixed DBI::PurePerl error clearing behaviour.
Fixed dbi_time() and thus DBI::Profile on Windows thanks to Smejkal Petr.
Fixed problem that meant ShowErrorStatement could show wrong statement,
thanks to Ron Savage for the report and test case.
Changed Apache::DBI hook to check for $ENV{MOD_PERL} instead of
$ENV{GATEWAY_INTERFACE} thanks to Ask Bjoern Hansen.
No longer tries to dup trace logfp when an interpreter is being cloned.
Database handles no longer inherit shared $h->err/errstr/state storage
from their drivers, so each $dbh has it's own $h->err etc. values
and is no longer affected by calls made on other dbh's.
Now when a dbh is destroyed it's err/errstr/state values are copied
up to the driver so checking $DBI::errstr still works as expected.
Build / portability fixes:
Fixed t/40profile.t to not use Time::HiRes.
Fixed t/06attrs.t to not be locale sensitive, reported by Christian Hammers.
Fixed sgi compiler warnings, reported by Paul Blake.
Fixed build using make -j4, reported by Jonathan Leffler.
Fixed build and tests under VMS thanks to Craig A. Berry.
Documentation changes:
Documented $high_resolution_time = dbi_time() function.
Documented that bind_col() can take an attribute hash.
Clarified documentation for ParamValues attribute hash keys.
Many good DBI documentation tweaks from Jonathan Leffler,
including a major update to the DBI::DBD driver author guide.
Clarified that execute() should itself call finish() if it's
called on a statement handle that's still active.
Clarified $sth->{ParamValues}. Driver authors please note.
Removed "NEW" markers on some methods and attributes and
added text to each giving the DBI version it was added in,
if it was added after DBI 1.21 (Feb 2002).
Changes of note for authors of all drivers:
Added SQL_DATA_TYPE, SQL_DATETIME_SUB, NUM_PREC_RADIX, and
INTERVAL_PRECISION fields to docs for type_info_all. There were
already in type_info(), but type_info_all() didn't specify the
index values. Please check and update your type_info_all() code.
Added DBI::DBD::Metadata module that auto-generates your drivers
get_info and type_info_all data and code, thanks mainly to
Jonathan Leffler and Steffen Goeldner. If you've not implemented
get_info and type_info_all methods and your database has an ODBC
driver available then this will do all the hard work for you!
Drivers should no longer pass Err, Errstr, or State to _new_drh
or _new_dbh functions.
Please check that you support the slightly modified behaviour of
$sth->{ParamValues}, e.g., always return hash with keys if possible.
Changes of note for authors of compiled drivers:
Added dbd_db_login6 & dbd_st_finish3 prototypes thanks to Jonathan Leffler.
All dbd_*_*() functions implemented by drivers must have a
corresponding #define dbd_*_* _*_* otherwise
the driver may not work with a future release of the DBI.
Changes of note for authors of drivers which use Driver.xst:
Some new method hooks have been added are are enabled by
defining corresponding macros:
$drh->data_sources() - dbd_dr_data_sources
$dbh->do() - dbd_db_do4
The following methods won't be compiled into the driver unless
the corresponding macro has been #defined:
$drh->disconnect_all() - dbd_discon_all
=head2 Changes in DBI 1.32, 1st December 2002
Fixed to work with 5.005_03 thanks to Tatsuhiko Miyagawa (I've not tested it).
Reenabled taint tests (accidentally left disabled) spotted by Bradley Baetz.
Improved docs for FetchHashKeyName attribute thanks to Ian Barwick.
Fixed core dump if fetchrow_hashref given bad argument (name of attribute
with a value that wasn't an array reference), spotted by Ian Barwick.
Fixed some compiler warnings thanks to David Wheeler.
Updated Steven Hirsch's enhanced proxy work (seems I left out a bit).
Made t/40profile.t tests more reliable, reported by Randy, who is part of
the excellent CPAN testers team: http://testers.cpan.org/
(Please visit, see the valuable work they do and, ideally, join in!)
=head2 Changes in DBI 1.31, 29th November 2002
The fetchall_arrayref method, when called with a $maxrows parameter,
no longer gives an error if called again after all rows have been
fetched. This simplifies application logic when fetching in batches.
Also added batch-fetch while() loop example to the docs.
The proxy now supports non-lazy (synchronous) prepare, positioned
updates (for selects containing 'for update'), PlRPC config set
via attributes, and accurate propagation of errors, all thanks
to Steven Hirsch (plus a minor fix from Sean McMurray and doc
tweaks from Michael A Chase).
The DBI_AUTOPROXY env var can now hold the full dsn of the proxy driver
plus attributes, like "dbi:Proxy(proxy_foo=>1):host=...".
Added TaintIn & TaintOut attributes to give finer control over
tainting thanks to Bradley Baetz.
The RootClass attribute no longer ignores failure to load a module,
but also doesn't try to load a module if the class already exists,
with thanks to James FitzGibbon.
HandleError attribute works for connect failures thanks to David Wheeler.
The connect() RaiseError/PrintError message now includes the username.
Changed "last handle unknown or destroyed" warning to be a trace message.
Removed undocumented $h->event() method.
Further enhancements to DBD::PurePerl accuracy.
The CursorName attribute now defaults to undef and not an error.
DBI::Profile changes:
New DBI::ProfileDumper, DBI::ProfileDumper::Apache, and
DBI::ProfileData modules (to manage the storage and processing
of profile data), plus dbiprof program for analyzing profile
data - with many thanks to Sam Tregar.
Added $DBI::err (etc) tied variable lookup time to profile.
Added time for DESTROY method into parent handles profile (used to be ignored).
Documentation changes:
Documented $dbh = $sth->{Database} attribute.
Documented $dbh->connected(...) post-connection call when subclassing.
Updated some minor doc issues thanks to H.Merijn Brand.
Updated Makefile.PL example in DBI::DBD thanks to KAWAI,Takanori.
Fixed execute_array() example thanks to Peter van Hardenberg.
Changes for driver authors, not required but strongly recommended:
Change DBIS to DBIc_DBISTATE(imp_xxh) [or imp_dbh, imp_sth etc]
Change DBILOGFP to DBIc_LOGPIO(imp_xxh) [or imp_dbh, imp_sth etc]
Any function from which all instances of DBIS and DBILOGFP are
removed can also have dPERLINTERP removed (a good thing).
All use of the DBIh_EVENT* macros should be removed.
Major update to DBI::DBD docs thanks largely to Jonathan Leffler.
Add these key values: 'Err' => \my $err, 'Errstr' => \my $errstr,
to the hash passed to DBI::_new_dbh() in your driver source code.
That will make each $dbh have it's own $h->err and $h->errstr
values separate from other $dbh belonging to the same driver.
If you have a ::db or ::st DESTROY methods that do nothing
you can now remove them - which speeds up handle destruction.
=head2 Changes in DBI 1.30, 18th July 2002
Fixed problems with selectrow_array, selectrow_arrayref, and
selectall_arrayref introduced in DBI 1.29.
Fixed FETCHing a handle attribute to not clear $DBI::err etc (broken in 1.29).
Fixed core dump at trace level 9 or above.
Fixed compilation with perl 5.6.1 + ithreads (i.e. Windows).
Changed definition of behaviour of selectrow_array when called in a scalar
context to match fetchrow_array.
Corrected selectrow_arrayref docs which showed selectrow_array thanks to Paul DuBois.
=head2 Changes in DBI 1.29, 15th July 2002
NOTE: This release changes the specified behaviour for the
: fetchrow_array method when called in a scalar context:
: The DBI spec used to say that it would return the FIRST field.
: Which field it returns (i.e., the first or the last) is now undefined.
: This does not affect statements that only select one column, which is
: usually the case when fetchrow_array is called in a scalar context.
: FYI, this change was triggered by discovering that the fetchrow_array
: implementation in Driver.xst (used by most compiled drivers)
: didn't match the DBI specification. Rather than change the code
: to match, and risk breaking existing applications, I've changed the
: specification (that part was always of dubious value anyway).
NOTE: Future versions of the DBI may not support for perl 5.5 much longer.
: If you are still using perl 5.005_03 you should be making plans to
: upgrade to at least perl 5.6.1, or 5.8.0. Perl 5.8.0 is due to be
: released in the next week or so. (Although it's a "point 0" release,
: it is the most thoroughly tested release ever.)
Added XS/C implementations of selectrow_array, selectrow_arrayref, and
selectall_arrayref to Driver.xst. See DBI 1.26 Changes for more info.
Removed support for the old (fatally flawed) "5005" threading model.
Added support for new perl 5.8 iThreads thanks to Gerald Richter.
(Threading support and safety should still be regarded as beta
quality until further notice. But it's much better than it was.)
Updated the "Threads and Thread Safety" section of the docs.
The trace output can be sent to STDOUT instead of STDERR by using
"STDOUT" as the name of the file, i.e., $h->trace(..., "STDOUT")
Added pointer to perlreftut, perldsc, perllol, and perlboot manuals
into the intro section of the docs, suggested by Brian McCain.
Fixed DBI::Const::GetInfo::* pod docs thanks to Zack Weinberg.
Some changes to how $dbh method calls are treated by DBI::Profile:
Meta-data methods now clear $dbh->{Statement} on entry.
Some $dbh methods are now profiled as if $dbh->{Statement} was empty
(because thet're unlikely to actually relate to its contents).
Updated dbiport.h to ppport.h from perl 5.8.0.
Tested with perl 5.5.3 (vanilla, Solaris), 5.6.1 (vanilla, Solaris), and
perl 5.8.0 (RC3@17527 with iThreads & Multiplicity on Solaris and FreeBSD).
=head2 Changes in DBI 1.28, 14th June 2002
Added $sth->{ParamValues} to return a hash of the most recent
values bound to placeholders via bind_param() or execute().
Individual drivers need to be updated to support it.
Enhanced ShowErrorStatement to include ParamValues if available:
"DBD::foo::st execute failed: errstr [for statement ``...'' with params: 1='foo']"
Further enhancements to DBD::PurePerl accuracy.
=head2 Changes in DBI 1.27, 13th June 2002
Fixed missing column in C implementation of fetchall_arrayref()
thanks to Philip Molter for the prompt reporting of the problem.
=head2 Changes in DBI 1.26, 13th June 2002
Fixed t/40profile.t to work on Windows thanks to Smejkal Petr.
Fixed $h->{Profile} to return undef, not error, if not set.
Fixed DBI->available_drivers in scalar context thanks to Michael Schwern.
Added C implementations of selectrow_arrayref() and fetchall_arrayref()
in Driver.xst. All compiled drivers using Driver.xst will now be
faster making those calls. Most noticeable with fetchall_arrayref for
many rows or selectrow_arrayref with a fast query. For example, using
DBD::mysql a selectrow_arrayref for a single row using a primary key
is ~20% faster, and fetchall_arrayref for 20000 rows is twice as fast!
Drivers just need to be recompiled and reinstalled to enable it.
The fetchall_arrayref speed up only applies if $slice parameter is not used.
Added $max_rows parameter to fetchall_arrayref() to optionally limit
the number of rows returned. Can now fetch batches of rows.
Added MaxRows attribute to selectall_arrayref()
which then passes it to fetchall_arrayref().
Changed selectrow_array to make use of selectrow_arrayref.
Trace level 1 now shows first two parameters of all methods
(used to only for that for some, like prepare,execute,do etc)
Trace indicator for recursive calls (first char on trace lines)
now starts at 1 not 2.
Documented that $h->func() does not trigger RaiseError etc
so applications must explicitly check for errors.
DBI::Profile with DBI_PROFILE now shows percentage time inside DBI.
HandleError docs updated to show that handler can edit error message.
HandleError subroutine interface is now regarded as stable.
=head2 Changes in DBI 1.25, 5th June 2002
Fixed build problem on Windows and some compiler warnings.
Fixed $dbh->{Driver} and $sth->{Statement} for driver internals
These are 'inner' handles as per behaviour prior to DBI 1.16.
Further minor improvements to DBI::PurePerl accuracy.
=head2 Changes in DBI 1.24, 4th June 2002
Fixed reference loop causing a handle/memory leak
that was introduced in DBI 1.16.
Fixed DBI::Format to work with 'filehandles' from IO::Scalar
and similar modules thanks to report by Jeff Boes.
Fixed $h->func for DBI::PurePerl thanks to Jeff Zucker.
Fixed $dbh->{Name} for DBI::PurePerl thanks to Dean Arnold.
Added DBI method call profiling and benchmarking.
This is a major new addition to the DBI.
See $h->{Profile} attribute and DBI::Profile module.
For a quick trial, set the DBI_PROFILE environment variable and
run your favourite DBI script. Try it with DBI_PROFILE set to 1,
then try 2, 4, 8, 10, and -10. Have fun!
Added execute_array() and bind_param_array() documentation
with thanks to Dean Arnold.
Added notes about the DBI having not yet been tested with iThreads
(testing and patches for SvLOCK etc welcome).
Removed undocumented Handlers attribute (replaced by HandleError).
Tested with 5.5.3 and 5.8.0 RC1.
=head2 Changes in DBI 1.23, 25th May 2002
Greatly improved DBI::PurePerl in performance and accuracy.
Added more detail to DBI::PurePerl docs about what's not supported.
Fixed undef warnings from t/15array.t and DBD::Sponge.
=head2 Changes in DBI 1.22, 22nd May 2002
Added execute_array() and bind_param_array() with special thanks
to Dean Arnold. Not yet documented. See t/15array.t for examples.
All drivers now automatically support these methods.
Added DBI::PurePerl, a transparent DBI emulation for pure-perl drivers
with special thanks to Jeff Zucker. Perldoc DBI::PurePerl for details.
Added DBI::Const::GetInfo* modules thanks to Steffen Goeldner.
Added write_getinfo_pm utility to DBI::DBD thanks to Steffen Goeldner.
Added $allow_active==2 mode for prepare_cached() thanks to Stephen Clouse.
Updated DBI::Format to Revision 11.4 thanks to Tom Lowery.
Use File::Spec in Makefile.PL (helps VMS etc) thanks to Craig Berry.
Extend $h->{Warn} to commit/rollback ineffective warning thanks to Jeff Baker.
Extended t/preparse.t and removed "use Devel::Peek" thanks to Scott Hildreth.
Only copy Changes to blib/lib/Changes.pm once thanks to Jonathan Leffler.
Updated internals for modern perls thanks to Jonathan Leffler and Jeff Urlwin.
Tested with perl 5.7.3 (just using default perl config).
Documentation changes:
Added 'Catalog Methods' section to docs thanks to Steffen Goeldner.
Updated README thanks to Michael Schwern.
Clarified that driver may choose not to start new transaction until
next use of $dbh after commit/rollback.
Clarified docs for finish method.
Clarified potentials problems with prepare_cached() thanks to Stephen Clouse.
=head2 Changes in DBI 1.21, 7th February 2002
The minimum supported perl version is now 5.005_03.
Fixed DBD::Proxy support for AutoCommit thanks to Jochen Wiedmann.
Fixed DBI::ProxyServer bind_param(_inout) handing thanks to Oleg Mechtcheriakov.
Fixed DBI::ProxyServer fetch loop thanks to nobull@mail.com.
Fixed install_driver do-the-right-thing with $@ on error. It, and connect(),
will leave $@ empty on success and holding the error message on error.
Thanks to Jay Lawrence, Gavin Sherlock and others for the bug report.
Fixed fetchrow_hashref to assign columns to the hash left-to-right
so later fields with the same name overwrite earlier ones
as per DBI < 1.15, thanks to Kay Roepke.
Changed tables() to use quote_indentifier() if the driver returns a
true value for $dbh->get_info(29) # SQL_IDENTIFIER_QUOTE_CHAR
Changed ping() so it no longer triggers RaiseError/PrintError.
Changed connect() to not call $class->install_driver unless needed.
Changed DESTROY to catch fatal exceptions and append to $@.
Added ISO SQL/CLI & ODBCv3 data type definitions thanks to Steffen Goeldner.
Removed the definition of SQL_BIGINT data type constant as the value is
inconsistent between standards (ODBC=-5, SQL/CLI=25).
Added $dbh->column_info(...) thanks to Steffen Goeldner.
Added $dbh->foreign_key_info(...) thanks to Steffen Goeldner.
Added $dbh->quote_identifier(...) insipred by Simon Oliver.
Added $dbh->set_err(...) for DBD authors and DBI subclasses
(actually been there for a while, now expanded and documented).
Added $h->{HandleError} = sub { ... } addition and/or alternative
to RaiseError/PrintError. See the docs for more info.
Added $h->{TraceLevel} = N attribute to set/get trace level of handle
thus can set trace level via an (eg externally specified) DSN
using the embedded attribute syntax:
$dsn = 'dbi:DB2(PrintError=1,TraceLevel=2):dbname';
Plus, you can also now do: local($h->{TraceLevel}) = N;
(but that leaks a little memory in some versions of perl).
Added some call tree information to trace output if trace level >= 3
With thanks to Graham Barr for the stack walking code.
Added experimental undocumented $dbh->preparse(), see t/preparse.t
With thanks to Scott T. Hildreth for much of the work.
Added Fowler/Noll/Vo hash type as an option to DBI::hash().
Documentation changes:
Added DBI::Changes so now you can "perldoc DBI::Changes", yeah!
Added selectrow_arrayref & selectrow_hashref docs thanks to Doug Wilson.
Added 'Standards Reference Information' section to docs to gather
together all references to relevant on-line standards.
Added link to poop.sourceforge.net into the docs thanks to Dave Rolsky.
Added link to hyperlinked BNF for SQL92 thanks to Jeff Zucker.
Added 'Subclassing the DBI' docs thanks to Stephen Clouse, and
then changed some of them to reflect the new approach to subclassing.
Added stronger wording to description of $h->{private_*} attributes.
Added docs for DBI::hash.
Driver API changes:
Now a COPY of the DBI->connect() attributes is passed to the driver
connect() method, so it can process and delete any elements it wants.
Deleting elements reduces/avoids the explicit
$dbh->{$_} = $attr->{$_} foreach keys %$attr;
that DBI->connect does after the driver connect() method returns.
=head2 Changes in DBI 1.20, 24th August 2001
WARNING: This release contains two changes that may affect your code.
: Any code using selectall_hashref(), which was added in March 2001, WILL
: need to be changed. Any code using fetchall_arrayref() with a non-empty
: hash slice parameter may, in a few rare cases, need to be changed.
: See the change list below for more information about the changes.
: See the DBI documentation for a description of current behaviour.
Fixed memory leak thanks to Toni Andjelkovic.
Changed fetchall_arrayref({ foo=>1, ...}) specification again (sorry):
The key names of the returned hashes is identical to the letter case of
the names in the parameter hash, regardless of the L
attribute. The letter case is ignored for matching.
Changed fetchall_arrayref([...]) array slice syntax specification to
clarify that the numbers in the array slice are perl index numbers
(which start at 0) and not column numbers (which start at 1).
Added { Columns=>... } and { Slice =>... } attributes to selectall_arrayref()
which is passed to fetchall_arrayref() so it can fetch hashes now.
Added a { Columns => [...] } attribute to selectcol_arrayref() so that
the list it returns can be built from more than one column per row.
Why? Consider my %hash = @{$dbh->selectcol_arrayref($sql,{ Columns=>[1,2]})}
to return id-value pairs which can be used directly to build a hash.
Added $hash_ref = $sth->fetchall_hashref( $key_field )
which returns a ref to a hash with, typically, one element per row.
$key_field is the name of the field to get the key for each row from.
The value of the hash for each row is a hash returned by fetchrow_hashref.
Changed selectall_hashref to return a hash ref (from fetchall_hashref)
and not an array of hashes as it has since DBI 1.15 (end March 2001).
WARNING: THIS CHANGE WILL BREAK ANY CODE USING selectall_hashref()!
Sorry, but I think this is an important regularization of the API.
To get previous selectall_hashref() behaviour (an array of hash refs)
change $ary_ref = $dbh->selectall_hashref( $statement, undef, @bind);
to $ary_ref = $dbh->selectall_arrayref($statement, { Columns=>{} }, @bind);
Added NAME_lc_hash, NAME_uc_hash, NAME_hash statement handle attributes.
which return a ref to a hash of field_name => field_index (0..n-1) pairs.
Fixed select_hash() example thanks to Doug Wilson.
Removed (unbundled) DBD::ADO and DBD::Multiplex from the DBI distribution.
The latest versions of those modules are available from CPAN sites.
Added $dbh->begin_work. This method causes AutoCommit to be turned
off just until the next commit() or rollback().
Driver authors: if the DBIcf_BegunWork flag is set when your commit or
rollback method is called then please turn AutoCommit on and clear the
DBIcf_BegunWork flag. If you don't then the DBI will but it'll be much
less efficient and won't handle error conditions very cleanly.
Retested on perl 5.4.4, but the DBI won't support 5.4.x much longer.
Added text to SUPPORT section of the docs:
For direct DBI and DBD::Oracle support, enhancement, and related work
I am available for consultancy on standard commercial terms.
Added text to ACKNOWLEDGEMENTS section of the docs:
Much of the DBI and DBD::Oracle was developed while I was Technical
Director (CTO) of the Paul Ingram Group (www.ig.co.uk). So I'd
especially like to thank Paul for his generosity and vision in
supporting this work for many years.
=head2 Changes in DBI 1.19, 20th July 2001
Made fetchall_arrayref({ foo=>1, ...}) be more strict to the specification
in relation to wanting hash slice keys to be lowercase names.
WARNING: If you've used fetchall_arrayref({...}) with a hash slice
that contains keys with uppercase letters then your code will break.
(As far as I recall the spec has always said don't do that.)
Fixed $sth->execute() to update $dbh->{Statement} to $sth->{Statement}.
Added row number to trace output for fetch method calls.
Trace level 1 no longer shows fetches with row>1 (to reduce output volume).
Added $h->{FetchHashKeyName} = 'NAME_lc' or 'NAME_uc' to alter
behaviour of fetchrow_hashref() method. See docs.
Added type_info quote caching to quote() method thanks to Dean Kopesky.
Makes using quote() with second data type param much much faster.
Added type_into_all() caching to type_info(), spotted by Dean Kopesky.
Added new API definition for table_info() and tables(),
driver authors please note!
Added primary_key_info() to DBI API thanks to Steffen Goeldner.
Added primary_key() to DBI API as simpler interface to primary_key_info().
Indent and other fixes for DBI::DBD doc thanks to H.Merijn Brand.
Added prepare_cached() insert_hash() example thanks to Doug Wilson.
Removed false docs for fetchall_hashref(), use fetchall_arrayref({}).
=head2 Changes in DBI 1.18, 4th June 2001
Fixed that altering ShowErrorStatement also altered AutoCommit!
Thanks to Jeff Boes for spotting that clanger.
Fixed DBD::Proxy to handle commit() and rollback(). Long overdue, sorry.
Fixed incompatibility with perl 5.004 (but no one's using that right? :)
Fixed connect_cached and prepare_cached to not be affected by the order
of elements in the attribute hash. Spotted by Mitch Helle-Morrissey.
Fixed version number of DBI::Shell
reported by Stuhlpfarrer Gerhard and others.
Defined and documented table_info() attribute semantics (ODBC compatible)
thanks to Olga Voronova, who also implemented then in DBD::Oracle.
Updated Win32::DBIODBC (Win32::ODBC emulation) thanks to Roy Lee.
=head2 Changes in DBI 1.16, 30th May 2001
Reimplemented fetchrow_hashref in C, now fetches about 25% faster!
Changed behaviour if both PrintError and RaiseError are enabled
to simply do both (in that order, obviously :)
Slight reduction in DBI handle creation overhead.
Fixed $dbh->{Driver} & $sth->{Database} to return 'outer' handles.
Fixed execute param count check to honour RaiseError spotted by Belinda Giardie.
Fixed build for perl5.6.1 with PERLIO thanks to H.Merijn Brand.
Fixed client sql restrictions in ProxyServer.pm thanks to Jochen Wiedmann.
Fixed batch mode command parsing in Shell thanks to Christian Lemburg.
Fixed typo in selectcol_arrayref docs thanks to Jonathan Leffler.
Fixed selectrow_hashref to be available to callers thanks to T.J.Mather.
Fixed core dump if statement handle didn't define Statement attribute.
Added bind_param_inout docs to DBI::DBD thanks to Jonathan Leffler.
Added note to data_sources() method docs that some drivers may
require a connected database handle to be supplied as an attribute.
Trace of install_driver method now shows path of driver file loaded.
Changed many '||' to 'or' in the docs thanks to H.Merijn Brand.
Updated DBD::ADO again (improvements in error handling) from Tom Lowery.
Updated Win32::DBIODBC (Win32::ODBC emulation) thanks to Roy Lee.
Updated email and web addresses in DBI::FAQ thanks to Michael A Chase.
=head2 Changes in DBI 1.15, 28th March 2001
Added selectrow_arrayref
Added selectrow_hashref
Added selectall_hashref thanks to Leon Brocard.
Added DBI->connect(..., { dbi_connect_method => 'method' })
Added $dbh->{Statement} aliased to most recent child $sth->{Statement}.
Added $h->{ShowErrorStatement}=1 to cause the appending of the
relevant Statement text to the RaiseError/PrintError text.
Modified type_info to always return hash keys in uppercase and
to not require uppercase 'DATA_TYPE' key from type_info_all.
Thanks to Jennifer Tong and Rob Douglas.
Added \%attr param to tables() and table_info() methods.
Trace method uses warn() if it can't open the new file.
Trace shows source line and filename during global destruction.
Updated packages:
Updated Win32::DBIODBC (Win32::ODBC emulation) thanks to Roy Lee.
Updated DBD::ADO to much improved version 0.4 from Tom Lowery.
Updated DBD::Sponge to include $sth->{PRECISION} thanks to Tom Lowery.
Changed DBD::ExampleP to use lstat() instead of stat().
Documentation:
Documented $DBI::lasth (which has been there since day 1).
Documented SQL_* names.
Clarified and extended docs for $h->state thanks to Masaaki Hirose.
Clarified fetchall_arrayref({}) docs (thanks to, er, someone!).
Clarified type_info_all re lettercase and index values.
Updated DBI::FAQ to 0.38 thanks to Alligator Descartes.
Added cute bind_columns example thanks to H.Merijn Brand.
Extended docs on \%attr arg to data_sources method.
Makefile.PL
Removed obscure potential 'rm -rf /' (thanks to Ulrich Pfeifer).
Removed use of glob and find (thanks to Michael A. Chase).
Proxy:
Removed debug messages from DBD::Proxy AUTOLOAD thanks to Brian McCauley.
Added fix for problem using table_info thanks to Tom Lowery.
Added better determination of where to put the pid file, and...
Added KNOWN ISSUES section to DBD::Proxy docs thanks to Jochen Wiedmann.
Shell:
Updated DBI::Format to include DBI::Format::String thanks to Tom Lowery.
Added describe command thanks to Tom Lowery.
Added columnseparator option thanks to Tom Lowery (I think).
Added 'raw' format thanks to, er, someone, maybe Tom again.
Known issues:
Perl 5.005 and 5.006 both leak memory doing local($handle->{Foo}).
Perl 5.004 doesn't. The leak is not a DBI or driver bug.
=head2 Changes in DBI 1.14, 14th June 2000
NOTE: This version is the one the DBI book is based on.
NOTE: This version requires at least Perl 5.004.
Perl 5.6 ithreads changes with thanks to Doug MacEachern.
Changed trace output to use PerlIO thanks to Paul Moore.
Fixed bug in RaiseError/PrintError handling.
(% chars in the error string could cause a core dump.)
Fixed Win32 PerlEx IIS concurrency bugs thanks to Murray Nesbitt.
Major documentation polishing thanks to Linda Mui at O'Reilly.
Password parameter now shown as **** in trace output.
Added two fields to type_info and type_info_all.
Added $dsn to PrintError/RaiseError message from DBI->connect().
Changed prepare_cached() croak to carp if sth still Active.
Added prepare_cached() example to the docs.
Added further DBD::ADO enhancements from Thomas Lowery.
=head2 Changes in DBI 1.13, 11th July 1999
Fixed Win32 PerlEx IIS concurrency bugs thanks to Murray Nesbitt.
Fixed problems with DBD::ExampleP long_list test mode.
Added SQL_WCHAR SQL_WVARCHAR SQL_WLONGVARCHAR and SQL_BIT
to list of known and exportable SQL types.
Improved data fetch performance of DBD::ADO.
Added GetTypeInfo to DBD::ADO thanks to Thomas Lowery.
Actually documented connect_cached thanks to Michael Schwern.
Fixed user/key/cipher bug in ProxyServer thanks to Joshua Pincus.
=head2 Changes in DBI 1.12, 29th June 1999
Fixed significant DBD::ADO bug (fetch skipped first row).
Fixed ProxyServer bug handling non-select statements.
Fixed VMS problem with t/examp.t thanks to Craig Berry.
Trace only shows calls to trace_msg and _set_fbav at high levels.
Modified t/examp.t to workaround Cygwin buffering bug.
=head2 Changes in DBI 1.11, 17th June 1999
Fixed bind_columns argument checking to allow a single arg.
Fixed problems with internal default_user method.
Fixed broken DBD::ADO.
Made default $DBI::rows more robust for some obscure cases.
=head2 Changes in DBI 1.10, 14th June 1999
Fixed trace_msg.al error when using Apache.
Fixed dbd_st_finish enhancement in Driver.xst (internals).
Enable drivers to define default username and password
and temporarily disabled warning added in 1.09.
Thread safety optimised for single thread case.
=head2 Changes in DBI 1.09, 9th June 1999
Added optional minimum trace level parameter to trace_msg().
Added warning in Makefile.PL that DBI will require 5.004 soon.
Added $dbh->selectcol_arrayref($statement) method.
Fixed fetchall_arrayref hash-slice mode undef NAME problem.
Fixed problem with tainted parameter checking and t/examp.t.
Fixed problem with thread safety code, including 64 bit machines.
Thread safety now enabled by default for threaded perls.
Enhanced code for MULTIPLICITY/PERL_OBJECT from ActiveState.
Enhanced prepare_cached() method.
Minor changes to trace levels (less internal info at level 2).
Trace log now shows "!! ERROR..." before the "<- method" line.
DBI->connect() now warn's if user / password is undefined and
DBI_USER / DBI_PASS environment variables are not defined.
The t/proxy.t test now ignores any /etc/dbiproxy.conf file.
Added portability fixes for MacOS from Chris Nandor.
Updated mailing list address from fugue.com to isc.org.
=head2 Changes in DBI 1.08, 12th May 1999
Much improved DBD::ADO driver thanks to Phlip Plumlee and others.
Connect now allows you to specify attribute settings within the DSN
E.g., "dbi:Driver(RaiseError=>1,Taint=>1,AutoCommit=>0):dbname"
The $h->{Taint} attribute now also enables taint checking of
arguments to almost all DBI methods.
Improved trace output in various ways.
Fixed bug where $sth->{NAME_xx} was undef in some situations.
Fixed code for MULTIPLICITY/PERL_OBJECT thanks to Alex Smishlajev.
Fixed and documented DBI->connect_cached.
Workaround for Cygwin32 build problem with help from Jong-Pork Park.
bind_columns no longer needs undef or hash ref as first parameter.
=head2 Changes in DBI 1.07, 6th May 1999
Trace output now shows contents of array refs returned by DBI.
Changed names of some result columns from type_info, type_info_all,
tables and table_info to match ODBC 3.5 / ISO/IEC standards.
Many fixes for DBD::Proxy and ProxyServer.
Fixed error reporting in install_driver.
Major enhancement to DBI::W32ODBC from Patrick Hollins.
Added $h->{Taint} to taint fetched data if tainting (perl -T).
Added code for MULTIPLICITY/PERL_OBJECT contributed by ActiveState.
Added $sth->more_results (undocumented for now).
=head2 Changes in DBI 1.06, 6th January 1999
Fixed Win32 Makefile.PL problem in 1.04 and 1.05.
Significant DBD::Proxy enhancements and fixes
including support for bind_param_inout (Jochen and I)
Added experimental DBI->connect_cached method.
Added $sth->{NAME_uc} and $sth->{NAME_lc} attributes.
Enhanced fetchrow_hashref to take an attribute name arg.
=head2 Changes in DBI 1.05, 4th January 1999
Improved DBD::ADO connect (thanks to Phlip Plumlee).
Improved thread safety (thanks to Jochen Wiedmann).
[Quick release prompted by truncation of copies on CPAN]
=head2 Changes in DBI 1.04, 3rd January 1999
Fixed error in Driver.xst. DBI build now tests Driver.xst.
Removed unused variable compiler warnings in Driver.xst.
DBI::DBD module now tested during DBI build.
Further clarification in the DBI::DBD driver writers manual.
Added optional name parameter to $sth->fetchrow_hashref.
=head2 Changes in DBI 1.03, 1st January 1999
Now builds with Perl>=5.005_54 (PERL_POLLUTE in DBIXS.h)
DBI trace trims path from "at yourfile.pl line nnn".
Trace level 1 now shows statement passed to prepare.
Assorted improvements to the DBI manual.
Assorted improvements to the DBI::DBD driver writers manual.
Fixed $dbh->quote prototype to include optional $data_type.
Fixed $dbh->prepare_cached problems.
$dbh->selectrow_array behaves better in scalar context.
Added a (very) experimental DBD::ADO driver for Win32 ADO.
Added experimental thread support (perl Makefile.PL -thread).
Updated the DBI::FAQ - thanks to Alligator Descartes.
The following changes were implemented and/or packaged
by Jochen Wiedmann - thanks Jochen:
Added a Bundle for CPAN installation of DBI, the DBI proxy
server and prerequisites (lib/Bundle/DBI.pm).
DBI->available_drivers uses File::Spec, if available.
This makes it work on MacOS. (DBI.pm)
Modified type_info to work with read-only values returned
by type_info_all. (DBI.pm)
Added handling of magic values in $sth->execute,
$sth->bind_param and other methods (Driver.xst)
Added Perl's CORE directory to the linkers path on Win32,
required by recent versions of ActiveState Perl.
Fixed DBD::Sponge to work with empty result sets.
Complete rewrite of DBI::ProxyServer and DBD::Proxy.
=head2 Changes in DBI 1.02, 2nd September 1998
Fixed DBI::Shell including @ARGV and /current.
Added basic DBI::Shell test.
Renamed DBI::Shell /display to /format.
=head2 Changes in DBI 1.01, 2nd September 1998
Many enhancements to Shell (with many contributions from
Jochen Wiedmann, Tom Lowery and Adam Marks).
Assorted fixes to DBD::Proxy and DBI::ProxyServer.
Tidied up trace messages - trace(2) much cleaner now.
Added $dbh->{RowCacheSize} and $sth->{RowsInCache}.
Added experimental DBI::Format (mainly for DBI::Shell).
Fixed fetchall_arrayref($slice_hash).
DBI->connect now honours PrintError=1 if connect fails.
Assorted clarifications to the docs.
=head2 Changes in DBI 1.00, 14th August 1998
The DBI is no longer 'alpha' software!
Added $dbh->tables and $dbh->table_info.
Documented \%attr arg to data_sources method.
Added $sth->{TYPE}, $sth->{PRECISION} and $sth->{SCALE}.
Added $sth->{Statement}.
DBI::Shell now uses neat_list to print results
It also escapes "'" chars and converts newlines to spaces.
=head2 Changes in DBI 0.95, 10th August 1998
WARNING: THIS IS AN EXPERIMENTAL RELEASE!
Fixed 0.94 slip so it will build on pre-5.005 again.
Added DBI_AUTOPROXY environment variable.
Array ref returned from fetch/fetchrow_arrayref now readonly.
Improved connect error reporting by DBD::Proxy.
All trace/debug messages from DBI now go to trace file.
=head2 Changes in DBI 0.94, 9th August 1998
WARNING: THIS IS AN EXPERIMENTAL RELEASE!
Added DBD::Shell and dbish interactive DBI shell. Try it!
Any database attribs can be set via DBI->connect(,,, \%attr).
Added _get_fbav and _set_fbav methods for Perl driver developers
(see ExampleP driver for perl usage). Drivers which don't use
one of these methods (either via XS or Perl) are not compliant.
DBI trace now shows adds " at yourfile.pl line nnn"!
PrintError and RaiseError now prepend driver and method name.
The available_drivers method no longer returns NullP or Sponge.
Added $dbh->{Name}.
Added $dbh->quote($value, $data_type).
Added more hints to install_driver failure message.
Added DBD::Proxy and DBI::ProxyServer (from Jochen Wiedmann).
Added $DBI::neat_maxlen to control truncation of trace output.
Added $dbh->selectall_arrayref and $dbh->selectrow_array methods.
Added $dbh->tables.
Added $dbh->type_info and $dbh->type_info_all.
Added $h->trace_msg($msg) to write to trace log.
Added @bool = DBI::looks_like_number(@ary).
Many assorted improvements to the DBI docs.
=head2 Changes in DBI 0.93, 13th February 1998
Fixed DBI::DBD::dbd_postamble bug causing 'Driver.xsi not found' errors.
Changes to handling of 'magic' values in neatsvpv (used by trace).
execute (in Driver.xst) stops binding after first bind error.
This release requires drivers to be rebuilt.
=head2 Changes in DBI 0.92, 3rd February 1998
Fixed per-handle memory leak (with many thanks to Irving Reid).
Added $dbh->prepare_cached() caching variant of $dbh->prepare.
Added some attributes:
$h->{Active} is the handle 'Active' (vague concept) (boolean)
$h->{Kids} e.g. number of sth's associated with a dbh
$h->{ActiveKids} number of the above which are 'Active'
$dbh->{CachedKids} ref to prepare_cached sth cache
Added support for general-purpose 'private_' attributes.
Added experimental support for subclassing the DBI: see t/subclass.t
Added SQL_ALL_TYPES to exported :sql_types.
Added dbd_dbi_dir() and dbd_dbi_arch_dir() to DBI::DBD module so that
DBD Makefile.PLs can work with the DBI installed in non-standard locations.
Fixed 'Undefined value' warning and &sv_no output from neatsvpv/trace.
Fixed small 'once per interpreter' leak.
Assorted minor documentation fixes.
=head2 Changes in DBI 0.91, 10th December 1997
NOTE: This fix may break some existing scripts:
DBI->connect("dbi:...",$user,$pass) was not setting AutoCommit and PrintError!
DBI->connect(..., { ... }) no longer sets AutoCommit or PrintError twice.
DBI->connect(..., { RaiseError=>1 }) now croaks if connect fails.
Fixed $fh parameter of $sth->dump_results;
Added default statement DESTROY method which carps.
Added default driver DESTROY method to silence AUTOLOAD/__DIE__/CGI::Carp
Added more SQL_* types to %EXPORT_TAGS and @EXPORT_OK.
Assorted documentation updates (mainly clarifications).
Added workaround for perl's 'sticky lvalue' bug.
Added better warning for bind_col(umns) where fields==0.
Fixed to build okay with 5.004_54 with or without USE_THREADS.
Note that the DBI has not been tested for thread safety yet.
=head2 Changes in DBI 0.90, 6th September 1997
Can once again be built with Perl 5.003.
The DBI class can be subclassed more easily now.
InactiveDestroy fixed for drivers using the *.xst template.
Slightly faster handle creation.
Changed prototype for dbd_*_*_attrib() to add extra param.
Note: 0.90, 0.89 and possibly some other recent versions have
a small memory leak. This will be fixed in the next release.
=head2 Changes in DBI 0.89, 25th July 1997
Minor fix to neatsvpv (mainly used for debug trace) to workaround
bug in perl where SvPV removes IOK flag from an SV.
Minor updates to the docs.
=head2 Changes in DBI 0.88, 22nd July 1997
Fixed build for perl5.003 and Win32 with Borland.
Fixed documentation formatting.
Fixed DBI_DSN ignored for old-style connect (with explicit driver).
Fixed AutoCommit in DBD::ExampleP
Fixed $h->trace.
The DBI can now export SQL type values: use DBI ':sql_types';
Modified Driver.xst and renamed DBDI.h to dbd_xsh.h
=head2 Changes in DBI 0.87, 18th July 1997
Fixed minor type clashes.
Added more docs about placeholders and bind values.
=head2 Changes in DBI 0.86, 16th July 1997
Fixed failed connect causing 'unblessed ref' and other errors.
Drivers must handle AutoCommit FETCH and STORE else DBI croaks.
Added $h->{LongReadLen} and $h->{LongTruncOk} attributes for BLOBS.
Added DBI_USER and DBI_PASS env vars. See connect docs for usage.
Added DBI->trace() to set global trace level (like per-handle $h->trace).
PERL_DBI_DEBUG env var renamed DBI_DEBUG (old name still works for now).
Updated docs, including commit, rollback, AutoCommit and Transactions sections.
Added bind_param method and execute(@bind_values) to docs.
Fixed fetchall_arrayref.
Since the DBIS structure has change the internal version numbers have also
changed (DBIXS_VERSION == 9 and DBISTATE_VERSION == 9) so drivers will have
to be recompiled. The test is also now more sensitive and the version
mismatch error message now more clear about what to do. Old drivers are
likely to core dump (this time) until recompiled for this DBI. In future
DBI/DBD version mismatch will always produce a clear error message.
Note that this DBI release contains and documents many new features
that won't appear in drivers for some time. Driver writers might like
to read perldoc DBI::DBD and comment on or apply the information given.
=head2 Changes in DBI 0.85, 25th June 1997
NOTE: New-style connect now defaults to AutoCommit mode unless
{ AutoCommit => 0 } specified in connect attributes. See the docs.
AutoCommit attribute now defined and tracked by DBI core.
Drivers should use/honour this and not implement their own.
Added pod doc changes from Andreas and Jonathan.
New DBI_DSN env var default for connect method. See docs.
Documented the func method.
Fixed "Usage: DBD::_::common::DESTROY" error.
Fixed bug which set some attributes true when there value was fetched.
Added new internal DBIc_set() macro for drivers to use.
=head2 Changes in DBI 0.84, 20th June 1997
Added $h->{PrintError} attribute which, if set true, causes all errors to
trigger a warn().
New-style DBI->connect call now automatically sets PrintError=1 unless
{ PrintError => 0 } specified in the connect attributes. See the docs.
The old-style connect with a separate driver parameter is deprecated.
Fixed fetchrow_hashref.
Renamed $h->debug to $h->trace() and added a trace filename arg.
Assorted other minor tidy-ups.
=head2 Changes in DBI 0.83, 11th June 1997
Added driver specification syntax to DBI->connect data_source
parameter: DBI->connect('dbi:driver:...', $user, $passwd);
The DBI->data_sources method should return data_source
names with the appropriate 'dbi:driver:' prefix.
DBI->connect will warn if \%attr is true but not a hash ref.
Added the new fetchrow methods:
@row_ary = $sth->fetchrow_array;
$ary_ref = $sth->fetchrow_arrayref;
$hash_ref = $sth->fetchrow_hashref;
The old fetch and fetchrow methods still work.
Driver implementors should implement the new names for
fetchrow_array and fetchrow_arrayref ASAP (use the xs ALIAS:
directive to define aliases for fetch and fetchrow).
Fixed occasional problems with t/examp.t test.
Added automatic errstr reporting to the debug trace output.
Added the DBI FAQ from Alligator Descartes in module form for
easy reading via "perldoc DBI::FAQ". Needs reformatting.
Unknown driver specific attribute names no longer croak.
Fixed problem with internal neatsvpv macro.
=head2 Changes in DBI 0.82, 23rd May 1997
Added $h->{RaiseError} attribute which, if set true, causes all errors to
trigger a die(). This makes it much easier to implement robust applications
in terms of higher level eval { ... } blocks and rollbacks.
Added DBI->data_sources($driver) method for implementation by drivers.
The quote method now returns the string NULL (without quotes) for undef.
Added VMS support thanks to Dan Sugalski.
Added a 'quick start guide' to the README.
Added neatsvpv function pointer to DBIS structure to make it available for
use by drivers. A macro defines neatsvpv(sv,len) as (DBIS->neatsvpv(sv,len)).
Old XS macro SV_YES_NO changes to standard boolSV.
Since the DBIS structure has change the internal version numbers have also
changed (DBIXS_VERSION == 8 and DBISTATE_VERSION == 8) so drivers will have
to be recompiled.
=head2 Changes in DBI 0.81, 7th May 1997
Minor fix to let DBI build using less modern perls.
Fixed a suprious typo warning.
=head2 Changes in DBI 0.80, 6th May 1997
Builds with no changes on NT using perl5.003_99 (with thanks to Jeffrey Urlwin).
Automatically supports Apache::DBI (with thanks to Edmund Mergl).
DBI scripts no longer need to be modified to make use of Apache::DBI.
Added a ping method and an experimental connect_test_perf method.
Added a fetchhash and fetch_all methods.
The func method no longer pre-clears err and errstr.
Added ChopBlanks attribute (currently defaults to off, that may change).
Support for the attribute needs to be implemented by individual drivers.
Reworked tests into standard t/*.t form.
Added more pod text. Fixed assorted bugs.
=head2 Changes in DBI 0.79, 7th Apr 1997
Minor release. Tidied up pod text and added some more descriptions
(especially disconnect). Minor changes to DBI.xs to remove compiler
warnings.
=head2 Changes in DBI 0.78, 28th Mar 1997
Greatly extended the pod documentation in DBI.pm, including the under
used bind_columns method. Use 'perldoc DBI' to read after installing.
Fixed $h->err. Fetching an attribute value no longer resets err.
Added $h->{InactiveDestroy}, see documentation for details.
Improved debugging of cached ('quick') attribute fetches.
errstr will return err code value if there is no string value.
Added DBI/W32ODBC to the distribution. This is a pure-perl experimental
DBI emulation layer for Win32::ODBC. Note that it's unsupported, your
mileage will vary, and bug reports without fixes will probably be ignored.
=head2 Changes in DBI 0.77, 21st Feb 1997
Removed erroneous $h->errstate and $h->errmsg methods from DBI.pm.
Added $h->err, $h->errstr and $h->state default methods in DBI.xs.
Updated informal DBI API notes in DBI.pm. Updated README slightly.
DBIXS.h now correctly installed into INST_ARCHAUTODIR.
(DBD authors will need to edit their Makefile.PL's to use
-I$(INSTALLSITEARCH)/auto/DBI -I$(INSTALLSITEARCH)/DBI)
=head2 Changes in DBI 0.76, 3rd Feb 1997
Fixed a compiler type warnings (pedantic IRIX again).
=head2 Changes in DBI 0.75, 27th Jan 1997
Fix problem introduced by a change in Perl5.003_XX.
Updated README and DBI.pm docs.
=head2 Changes in DBI 0.74, 14th Jan 1997
Dispatch now sets dbi_debug to the level of the current handle
(this makes tracing/debugging individual handles much easier).
The '>> DISPATCH' log line now only logged at debug >= 3 (was 2).
The $csr->NUM_OF_FIELDS attribute can be set if not >0 already.
You can log to a file using the env var PERL_DBI_DEBUG=/tmp/dbi.log.
Added a type cast needed by IRIX.
No longer sets perl_destruct_level unless debug set >= 4.
Make compatible with PerlIO and sfio.
=head2 Changes in DBI 0.73, 10th Oct 1996
Fixed some compiler type warnings (IRIX).
Fixed DBI->internal->{DebugLog} = $filename.
Made debug log file unbuffered.
Added experimental bind_param_inout method to interface.
Usage: $dbh->bind_param_inout($param, \$value, $maxlen [, \%attribs ])
(only currently used by DBD::Oracle at this time.)
=head2 Changes in DBI 0.72, 23 Sep 1996
Using an undefined value as a handle now gives a better
error message (mainly useful for emulators like Oraperl).
$dbh->do($sql, @params) now works for binding placeholders.
=head2 Changes in DBI 0.71, 10 July 1996
Removed spurious abort() from invalid handle check.
Added quote method to DBI interface and added test.
=head2 Changes in DBI 0.70, 16 June 1996
Added extra invalid handle check (dbih_getcom)
Fixed broken $dbh->quote method.
Added check for old GCC in Makefile.PL
=head2 Changes in DBI 0.69
Fixed small memory leak.
Clarified the behaviour of DBI->connect.
$dbh->do now returns '0E0' instead of 'OK'.
Fixed "Can't read $DBI::errstr, lost last handle" problem.
=head2 Changes in DBI 0.68, 2 Mar 1996
Changes to suit perl5.002 and site_lib directories.
Detects old versions ahead of new in @INC.
=head2 Changes in DBI 0.67, 15 Feb 1996
Trivial change to test suite to fix a problem shown up by the
Perl5.002gamma release Test::Harness.
=head2 Changes in DBI 0.66, 29 Jan 1996
Minor changes to bring the DBI into line with 5.002 mechanisms,
specifically the xs/pm VERSION checking mechanism.
No functionality changes. One no-last-handle bug fix (rare problem).
Requires 5.002 (beta2 or later).
=head2 Changes in DBI 0.65, 23 Oct 1995
Added $DBI::state to hold SQL CLI / ODBC SQLSTATE value.
SQLSTATE "00000" (success) is returned as "" (false), all else is true.
If a driver does not explicitly initialise it (via $h->{State} or
DBIc_STATE(imp_xxh) then $DBI::state will automatically return "" if
$DBI::err is false otherwise "S1000" (general error).
As always, this is a new feature and liable to change.
The is *no longer* a default error handler!
You can add your own using push(@{$h->{Handlers}}, sub { ... })
but be aware that this interface may change (or go away).
The DBI now automatically clears $DBI::err, errstr and state before
calling most DBI methods. Previously error conditions would persist.
Added DBIh_CLEAR_ERROR(imp_xxh) macro.
DBI now EXPORT_OK's some utility functions, neat($value),
neat_list(@values) and dump_results($sth).
Slightly enhanced t/min.t minimal test script in an effort to help
narrow down the few stray core dumps that some porters still report.
Renamed readblob to blob_read (old name still works but warns).
Added default blob_copy_to_file method.
Added $sth = $dbh->tables method. This returns an $sth for a query
which has these columns: TABLE_CATALOGUE, TABLE_OWNER, TABLE_NAME,
TABLE_TYPE, REMARKS in that order. The TABLE_CATALOGUE column
should be ignored for now.
=head2 Changes in DBI 0.64, 23 Oct 1995
Fixed 'disconnect invalidates 1 associated cursor(s)' problem.
Drivers using DBIc_ACTIVE_on/off() macros should not need any changes
other than to test for DBIc_ACTIVE_KIDS() instead of DBIc_KIDS().
Fixed possible core dump in dbih_clearcom during global destruction.
=head2 Changes in DBI 0.63, 1 Sep 1995
Minor update. Fixed uninitialised memory bug in method
attribute handling and streamlined processing and debugging.
Revised usage definitions for bind_* methods and readblob.
=head2 Changes in DBI 0.62, 26 Aug 1995
Added method redirection method $h->func(..., $method_name).
This is now the official way to call private driver methods
that are not part of the DBI standard. E.g.:
@ary = $sth->func('ora_types');
It can also be used to call existing methods. Has very low cost.
$sth->bind_col columns now start from 1 (not 0) to match SQL.
$sth->bind_columns now takes a leading attribute parameter (or undef),
e.g., $sth->bind_columns($attribs, \$col1 [, \$col2 , ...]);
Added handy DBD_ATTRIBS_CHECK macro to vet attribs in XS.
Added handy DBD_ATTRIB_GET_SVP, DBD_ATTRIB_GET_BOOL and
DBD_ATTRIB_GET_IV macros for handling attributes.
Fixed STORE for NUM_OF_FIELDS and NUM_OF_PARAMS.
Added FETCH for NUM_OF_FIELDS and NUM_OF_PARAMS.
Dispatch no longer bothers to call _untie().
Faster startup via install_method/_add_dispatch changes.
=head2 Changes in DBI 0.61, 22 Aug 1995
Added $sth->bind_col($column, \$var [, \%attribs ]);
This method enables perl variable to be directly and automatically
updated when a row is fetched. It requires no driver support
(if the driver has been written to use DBIS->get_fbav).
Currently \%attribs is unused.
Added $sth->bind_columns(\$var [, \$var , ...]);
This method is a short-cut for bind_col which binds all the
columns of a query in one go (with no attributes). It also
requires no driver support.
Added $sth->bind_param($parameter, $var [, \%attribs ]);
This method enables attributes to be specified when values are
bound to placeholders. It also enables binding to occur away
from the execute method to improve execute efficiency.
The DBI does not provide a default implementation of this.
See the DBD::Oracle module for a detailed example.
The DBI now provides default implementations of both fetch and
fetchrow. Each is written in terms of the other. A driver is
expected to implement at least one of them.
More macro and assorted structure changes in DBDXS.h. Sorry!
The old dbihcom definitions have gone. All fields have macros.
The imp_xxh_t type is now used within the DBI as well as drivers.
Drivers must set DBIc_NUM_FIELDS(imp_sth) and DBIc_NUM_PARAMS(imp_sth).
test.pl includes a trivial test of bind_param and bind_columns.
=head2 Changes in DBI 0.60, 17 Aug 1995
This release has significant code changes but much less
dramatic than the previous release. The new implementors data
handling mechanism has matured significantly (don't be put off
by all the struct typedefs in DBIXS.h, there's just to make it
easier for drivers while keeping things type-safe).
The DBI now includes two new methods:
do $dbh->do($statement)
This method prepares, executes and finishes a statement. It is
designed to be used for executing one-off non-select statements
where there is no benefit in reusing a prepared statement handle.
fetch $array_ref = $sth->fetch;
This method is the new 'lowest-level' row fetching method. The
previous @row = $sth->fetchrow method now defaults to calling
the fetch method and expanding the returned array reference.
The DBI now provides fallback attribute FETCH and STORE functions
which drivers should call if they don't recognise an attribute.
THIS RELEASE IS A GOOD STARTING POINT FOR DRIVER DEVELOPERS!
Study DBIXS.h from the DBI and Oracle.xs etc from DBD::Oracle.
There will be further changes in the interface but nothing
as dramatic as these last two releases! (I hope :-)
=head2 Changes in DBI 0.59 15 Aug 1995
NOTE: THIS IS AN UNSTABLE RELEASE!
Major reworking of internal data management!
Performance improvements and memory leaks fixed.
Added a new NullP (empty) driver and a -m flag
to test.pl to help check for memory leaks.
Study DBD::Oracle version 0.21 for more details.
(Comparing parts of v0.21 with v0.20 may be useful.)
=head2 Changes in DBI 0.58 21 June 1995
Added DBI->internal->{DebugLog} = $filename;
Reworked internal logging.
Added $VERSION.
Made disconnect_all a compulsory method for drivers.
=head1 ANCIENT HISTORY
12th Oct 1994: First public release of the DBI module.
(for Perl 5.000-beta-3h)
19th Sep 1994: DBperl project renamed to DBI.
29th Sep 1992: DBperl project started.
=cut
PK ]E
N N ProfileData.pmnu [ package DBI::ProfileData;
use strict;
=head1 NAME
DBI::ProfileData - manipulate DBI::ProfileDumper data dumps
=head1 SYNOPSIS
The easiest way to use this module is through the dbiprof frontend
(see L for details):
dbiprof --number 15 --sort count
This module can also be used to roll your own profile analysis:
# load data from dbi.prof
$prof = DBI::ProfileData->new(File => "dbi.prof");
# get a count of the records (unique paths) in the data set
$count = $prof->count();
# sort by longest overall time
$prof->sort(field => "longest");
# sort by longest overall time, least to greatest
$prof->sort(field => "longest", reverse => 1);
# exclude records with key2 eq 'disconnect'
$prof->exclude(key2 => 'disconnect');
# exclude records with key1 matching /^UPDATE/i
$prof->exclude(key1 => qr/^UPDATE/i);
# remove all records except those where key1 matches /^SELECT/i
$prof->match(key1 => qr/^SELECT/i);
# produce a formatted report with the given number of items
$report = $prof->report(number => 10);
# clone the profile data set
$clone = $prof->clone();
# get access to hash of header values
$header = $prof->header();
# get access to sorted array of nodes
$nodes = $prof->nodes();
# format a single node in the same style as report()
$text = $prof->format($nodes->[0]);
# get access to Data hash in DBI::Profile format
$Data = $prof->Data();
=head1 DESCRIPTION
This module offers the ability to read, manipulate and format
L profile data.
Conceptually, a profile consists of a series of records, or nodes,
each of each has a set of statistics and set of keys. Each record
must have a unique set of keys, but there is no requirement that every
record have the same number of keys.
=head1 METHODS
The following methods are supported by DBI::ProfileData objects.
=cut
our $VERSION = "2.010008";
use Carp qw(croak);
use Symbol;
use Fcntl qw(:flock);
use DBI::Profile qw(dbi_profile_merge);
# some constants for use with node data arrays
sub COUNT () { 0 };
sub TOTAL () { 1 };
sub FIRST () { 2 };
sub SHORTEST () { 3 };
sub LONGEST () { 4 };
sub FIRST_AT () { 5 };
sub LAST_AT () { 6 };
sub PATH () { 7 };
my $HAS_FLOCK = (defined $ENV{DBI_PROFILE_FLOCK})
? $ENV{DBI_PROFILE_FLOCK}
: do { local $@; eval { flock STDOUT, 0; 1 } };
=head2 $prof = DBI::ProfileData->new(File => "dbi.prof")
=head2 $prof = DBI::ProfileData->new(File => "dbi.prof", Filter => sub { ... })
=head2 $prof = DBI::ProfileData->new(Files => [ "dbi.prof.1", "dbi.prof.2" ])
Creates a new DBI::ProfileData object. Takes either a single file
through the File option or a list of Files in an array ref. If
multiple files are specified then the header data from the first file
is used.
=head3 Files
Reference to an array of file names to read.
=head3 File
Name of file to read. Takes precedence over C.
=head3 DeleteFiles
If true, the files are deleted after being read.
Actually the files are renamed with a C suffix before being read,
and then, after reading all the files, they're all deleted together.
The files are locked while being read which, combined with the rename, makes it
safe to 'consume' files that are still being generated by L.
=head3 Filter
The C parameter can be used to supply a code reference that can
manipulate the profile data as it is being read. This is most useful for
editing SQL statements so that slightly different statements in the raw data
will be merged and aggregated in the loaded data. For example:
Filter => sub {
my ($path_ref, $data_ref) = @_;
s/foo = '.*?'/foo = '...'/ for @$path_ref;
}
Here's an example that performs some normalization on the SQL. It converts all
numbers to C and all quoted strings to C. It can also convert digits to
N within names. Finally, it summarizes long "IN (...)" clauses.
It's aggressive and simplistic, but it's often sufficient, and serves as an
example that you can tailor to suit your own needs:
Filter => sub {
my ($path_ref, $data_ref) = @_;
local $_ = $path_ref->[0]; # whichever element contains the SQL Statement
s/\b\d+\b/N/g; # 42 -> N
s/\b0x[0-9A-Fa-f]+\b/N/g; # 0xFE -> N
s/'.*?'/'S'/g; # single quoted strings (doesn't handle escapes)
s/".*?"/"S"/g; # double quoted strings (doesn't handle escapes)
# convert names like log_20001231 into log_NNNNNNNN, controlled by $opt{n}
s/([a-z_]+)(\d{$opt{n},})/$1.('N' x length($2))/ieg if $opt{n};
# abbreviate massive "in (...)" statements and similar
s!(([NS],){100,})!sprintf("$2,{repeated %d times}",length($1)/2)!eg;
}
It's often better to perform this kinds of normalization in the DBI while the
data is being collected, to avoid too much memory being used by storing profile
data for many different SQL statement. See L.
=cut
sub new {
my $pkg = shift;
my $self = {
Files => [ "dbi.prof" ],
Filter => undef,
DeleteFiles => 0,
LockFile => $HAS_FLOCK,
_header => {},
_nodes => [],
_node_lookup => {},
_sort => 'none',
@_
};
bless $self, $pkg;
# File (singular) overrides Files (plural)
$self->{Files} = [ $self->{File} ] if exists $self->{File};
$self->_read_files();
return $self;
}
# read files into _header and _nodes
sub _read_files {
my $self = shift;
my $files = $self->{Files};
my $read_header = 0;
my @files_to_delete;
my $fh = gensym;
foreach (@$files) {
my $filename = $_;
if ($self->{DeleteFiles}) {
my $newfilename = $filename . ".deleteme";
if ($^O eq 'VMS') {
# VMS default filesystem can only have one period
$newfilename = $filename . 'deleteme';
}
# will clobber an existing $newfilename
rename($filename, $newfilename)
or croak "Can't rename($filename, $newfilename): $!";
# On a versioned filesystem we want old versions to be removed
1 while (unlink $filename);
$filename = $newfilename;
}
open($fh, "<", $filename)
or croak("Unable to read profile file '$filename': $!");
# lock the file in case it's still being written to
# (we'll be forced to wait till the write is complete)
flock($fh, LOCK_SH) if $self->{LockFile};
if (-s $fh) { # not empty
$self->_read_header($fh, $filename, $read_header ? 0 : 1);
$read_header = 1;
$self->_read_body($fh, $filename);
}
close($fh); # and release lock
push @files_to_delete, $filename
if $self->{DeleteFiles};
}
for (@files_to_delete){
# for versioned file systems
1 while (unlink $_);
if(-e $_){
warn "Can't delete '$_': $!";
}
}
# discard node_lookup now that all files are read
delete $self->{_node_lookup};
}
# read the header from the given $fh named $filename. Discards the
# data unless $keep.
sub _read_header {
my ($self, $fh, $filename, $keep) = @_;
# get profiler module id
my $first = <$fh>;
chomp $first;
$self->{_profiler} = $first if $keep;
# collect variables from the header
local $_;
while (<$fh>) {
chomp;
last unless length $_;
/^(\S+)\s*=\s*(.*)/
or croak("Syntax error in header in $filename line $.: $_");
# XXX should compare new with existing (from previous file)
# and warn if they differ (different program or path)
$self->{_header}{$1} = unescape_key($2) if $keep;
}
}
sub unescape_key { # inverse of escape_key() in DBI::ProfileDumper
local $_ = shift;
s/(?{_nodes};
my $lookup = $self->{_node_lookup};
my $filter = $self->{Filter};
# build up node array
my @path = ("");
my (@data, $path_key);
local $_;
while (<$fh>) {
chomp;
if (/^\+\s+(\d+)\s?(.*)/) {
# it's a key
my ($key, $index) = ($2, $1 - 1);
$#path = $index; # truncate path to new length
$path[$index] = unescape_key($key); # place new key at end
}
elsif (s/^=\s+//) {
# it's data - file in the node array with the path in index 0
# (the optional minus is to make it more robust against systems
# with unstable high-res clocks - typically due to poor NTP config
# of kernel SMP behaviour, i.e. min time may be -0.000008))
@data = split / /, $_;
# corrupt data?
croak("Invalid number of fields in $filename line $.: $_")
unless @data == 7;
croak("Invalid leaf node characters $filename line $.: $_")
unless m/^[-+ 0-9eE\.]+$/;
# hook to enable pre-processing of the data - such as mangling SQL
# so that slightly different statements get treated as the same
# and so merged in the results
$filter->(\@path, \@data) if $filter;
# elements of @path can't have NULLs in them, so this
# forms a unique string per @path. If there's some way I
# can get this without arbitrarily stripping out a
# character I'd be happy to hear it!
$path_key = join("\0",@path);
# look for previous entry
if (exists $lookup->{$path_key}) {
# merge in the new data
dbi_profile_merge($nodes->[$lookup->{$path_key}], \@data);
} else {
# insert a new node - nodes are arrays with data in 0-6
# and path data after that
push(@$nodes, [ @data, @path ]);
# record node in %seen
$lookup->{$path_key} = $#$nodes;
}
}
else {
croak("Invalid line type syntax error in $filename line $.: $_");
}
}
}
=head2 $copy = $prof->clone();
Clone a profile data set creating a new object.
=cut
sub clone {
my $self = shift;
# start with a simple copy
my $clone = bless { %$self }, ref($self);
# deep copy nodes
$clone->{_nodes} = [ map { [ @$_ ] } @{$self->{_nodes}} ];
# deep copy header
$clone->{_header} = { %{$self->{_header}} };
return $clone;
}
=head2 $header = $prof->header();
Returns a reference to a hash of header values. These are the key
value pairs included in the header section of the L
data format. For example:
$header = {
Path => [ '!Statement', '!MethodName' ],
Program => 't/42profile_data.t',
};
Note that modifying this hash will modify the header data stored
inside the profile object.
=cut
sub header { shift->{_header} }
=head2 $nodes = $prof->nodes()
Returns a reference the sorted nodes array. Each element in the array
is a single record in the data set. The first seven elements are the
same as the elements provided by L. After that each key is
in a separate element. For example:
$nodes = [
[
2, # 0, count
0.0312958955764771, # 1, total duration
0.000490069389343262, # 2, first duration
0.000176072120666504, # 3, shortest duration
0.00140702724456787, # 4, longest duration
1023115819.83019, # 5, time of first event
1023115819.86576, # 6, time of last event
'SELECT foo FROM bar' # 7, key1
'execute' # 8, key2
# 6+N, keyN
],
# ...
];
Note that modifying this array will modify the node data stored inside
the profile object.
=cut
sub nodes { shift->{_nodes} }
=head2 $count = $prof->count()
Returns the number of items in the profile data set.
=cut
sub count { scalar @{shift->{_nodes}} }
=head2 $prof->sort(field => "field")
=head2 $prof->sort(field => "field", reverse => 1)
Sorts data by the given field. Available fields are:
longest
total
count
shortest
The default sort is greatest to smallest, which is the opposite of the
normal Perl meaning. This, however, matches the expected behavior of
the dbiprof frontend.
=cut
# sorts data by one of the available fields
{
my %FIELDS = (
longest => LONGEST,
total => TOTAL,
count => COUNT,
shortest => SHORTEST,
key1 => PATH+0,
key2 => PATH+1,
key3 => PATH+2,
);
sub sort {
my $self = shift;
my $nodes = $self->{_nodes};
my %opt = @_;
croak("Missing required field option.") unless $opt{field};
my $index = $FIELDS{$opt{field}};
croak("Unrecognized sort field '$opt{field}'.")
unless defined $index;
# sort over index
if ($opt{reverse}) {
@$nodes = sort {
$a->[$index] <=> $b->[$index]
} @$nodes;
} else {
@$nodes = sort {
$b->[$index] <=> $a->[$index]
} @$nodes;
}
# remember how we're sorted
$self->{_sort} = $opt{field};
return $self;
}
}
=head2 $count = $prof->exclude(key2 => "disconnect")
=head2 $count = $prof->exclude(key2 => "disconnect", case_sensitive => 1)
=head2 $count = $prof->exclude(key1 => qr/^SELECT/i)
Removes records from the data set that match the given string or
regular expression. This method modifies the data in a permanent
fashion - use clone() first to maintain the original data after
exclude(). Returns the number of nodes left in the profile data set.
=cut
sub exclude {
my $self = shift;
my $nodes = $self->{_nodes};
my %opt = @_;
# find key index number
my ($index, $val);
foreach (keys %opt) {
if (/^key(\d+)$/) {
$index = PATH + $1 - 1;
$val = $opt{$_};
last;
}
}
croak("Missing required keyN option.") unless $index;
if (UNIVERSAL::isa($val,"Regexp")) {
# regex match
@$nodes = grep {
$#$_ < $index or $_->[$index] !~ /$val/
} @$nodes;
} else {
if ($opt{case_sensitive}) {
@$nodes = grep {
$#$_ < $index or $_->[$index] ne $val;
} @$nodes;
} else {
$val = lc $val;
@$nodes = grep {
$#$_ < $index or lc($_->[$index]) ne $val;
} @$nodes;
}
}
return scalar @$nodes;
}
=head2 $count = $prof->match(key2 => "disconnect")
=head2 $count = $prof->match(key2 => "disconnect", case_sensitive => 1)
=head2 $count = $prof->match(key1 => qr/^SELECT/i)
Removes records from the data set that do not match the given string
or regular expression. This method modifies the data in a permanent
fashion - use clone() first to maintain the original data after
match(). Returns the number of nodes left in the profile data set.
=cut
sub match {
my $self = shift;
my $nodes = $self->{_nodes};
my %opt = @_;
# find key index number
my ($index, $val);
foreach (keys %opt) {
if (/^key(\d+)$/) {
$index = PATH + $1 - 1;
$val = $opt{$_};
last;
}
}
croak("Missing required keyN option.") unless $index;
if (UNIVERSAL::isa($val,"Regexp")) {
# regex match
@$nodes = grep {
$#$_ >= $index and $_->[$index] =~ /$val/
} @$nodes;
} else {
if ($opt{case_sensitive}) {
@$nodes = grep {
$#$_ >= $index and $_->[$index] eq $val;
} @$nodes;
} else {
$val = lc $val;
@$nodes = grep {
$#$_ >= $index and lc($_->[$index]) eq $val;
} @$nodes;
}
}
return scalar @$nodes;
}
=head2 $Data = $prof->Data()
Returns the same Data hash structure as seen in L. This
structure is not sorted. The nodes() structure probably makes more
sense for most analysis.
=cut
sub Data {
my $self = shift;
my (%Data, @data, $ptr);
foreach my $node (@{$self->{_nodes}}) {
# traverse to key location
$ptr = \%Data;
foreach my $key (@{$node}[PATH .. $#$node - 1]) {
$ptr->{$key} = {} unless exists $ptr->{$key};
$ptr = $ptr->{$key};
}
# slice out node data
$ptr->{$node->[-1]} = [ @{$node}[0 .. 6] ];
}
return \%Data;
}
=head2 $text = $prof->format($nodes->[0])
Formats a single node into a human-readable block of text.
=cut
sub format {
my ($self, $node) = @_;
my $format;
# setup keys
my $keys = "";
for (my $i = PATH; $i <= $#$node; $i++) {
my $key = $node->[$i];
# remove leading and trailing space
$key =~ s/^\s+//;
$key =~ s/\s+$//;
# if key has newlines or is long take special precautions
if (length($key) > 72 or $key =~ /\n/) {
$keys .= " Key " . ($i - PATH + 1) . " :\n\n$key\n\n";
} else {
$keys .= " Key " . ($i - PATH + 1) . " : $key\n";
}
}
# nodes with multiple runs get the long entry format, nodes with
# just one run get a single count.
if ($node->[COUNT] > 1) {
$format = <[TOTAL] / $node->[COUNT]) . $keys;
} else {
$format = <report(number => 10)
Produces a report with the given number of items.
=cut
sub report {
my $self = shift;
my $nodes = $self->{_nodes};
my %opt = @_;
croak("Missing required number option") unless exists $opt{number};
$opt{number} = @$nodes if @$nodes < $opt{number};
my $report = $self->_report_header($opt{number});
for (0 .. $opt{number} - 1) {
$report .= sprintf("#" x 5 . "[ %d ]". "#" x 59 . "\n",
$_ + 1);
$report .= $self->format($nodes->[$_]);
$report .= "\n";
}
return $report;
}
# format the header for report()
sub _report_header {
my ($self, $number) = @_;
my $nodes = $self->{_nodes};
my $node_count = @$nodes;
# find total runtime and method count
my ($time, $count) = (0,0);
foreach my $node (@$nodes) {
$time += $node->[TOTAL];
$count += $node->[COUNT];
}
my $header = <{_profiler})
END
# output header fields
while (my ($key, $value) = each %{$self->{_header}}) {
$header .= sprintf(" %-13s : %s\n", $key, $value);
}
# output summary data fields
$header .= sprintf(<{_sort}, $count, $time);
Total Records : %d (showing %d, sorted by %s)
Total Count : %d
Total Runtime : %3.6f seconds
END
return $header;
}
1;
__END__
=head1 AUTHOR
Sam Tregar
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2002 Sam Tregar
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl 5 itself.
=cut
PK ] ProfileSubs.pmnu [ package DBI::ProfileSubs;
our $VERSION = "0.009396";
=head1 NAME
DBI::ProfileSubs - Subroutines for dynamic profile Path
=head1 SYNOPSIS
DBI_PROFILE='&norm_std_n3' prog.pl
This is new and still experimental.
=head1 TO DO
Define come kind of naming convention for the subs.
=cut
use strict;
use warnings;
# would be good to refactor these regex into separate subs and find some
# way to compose them in various combinations into multiple subs.
# Perhaps via AUTOLOAD where \&auto_X_Y_Z creates a sub that does X, Y, and Z.
# The final subs always need to be very fast.
#
sub norm_std_n3 {
# my ($h, $method_name) = @_;
local $_ = $_;
s/\b\d+\b//g; # 42 ->
s/\b0x[0-9A-Fa-f]+\b//g; # 0xFE ->
s/'.*?'/''/g; # single quoted strings (doesn't handle escapes)
s/".*?"/""/g; # double quoted strings (doesn't handle escapes)
# convert names like log20001231 into log
s/([a-z_]+)(\d{3,})\b/${1}/ig;
# abbreviate massive "in (...)" statements and similar
s!((\s*<[NS]>\s*,\s*){100,})!sprintf("$2,",length($1)/2)!eg;
return $_;
}
1;
PK ]h\:5( ( ProfileDumper.pmnu [ package DBI::ProfileDumper;
use strict;
=head1 NAME
DBI::ProfileDumper - profile DBI usage and output data to a file
=head1 SYNOPSIS
To profile an existing program using DBI::ProfileDumper, set the
DBI_PROFILE environment variable and run your program as usual. For
example, using bash:
DBI_PROFILE=2/DBI::ProfileDumper program.pl
Then analyze the generated file (F) with L:
dbiprof
You can also activate DBI::ProfileDumper from within your code:
use DBI;
# profile with default path (2) and output file (dbi.prof)
$dbh->{Profile} = "!Statement/DBI::ProfileDumper";
# same thing, spelled out
$dbh->{Profile} = "!Statement/DBI::ProfileDumper/File:dbi.prof";
# another way to say it
use DBI::ProfileDumper;
$dbh->{Profile} = DBI::ProfileDumper->new(
Path => [ '!Statement' ],
File => 'dbi.prof' );
# using a custom path
$dbh->{Profile} = DBI::ProfileDumper->new(
Path => [ "foo", "bar" ],
File => 'dbi.prof',
);
=head1 DESCRIPTION
DBI::ProfileDumper is a subclass of L which
dumps profile data to disk instead of printing a summary to your
screen. You can then use L to analyze the data in
a number of interesting ways, or you can roll your own analysis using
L.
B For Apache/mod_perl applications, use
L.
=head1 USAGE
One way to use this module is just to enable it in your C<$dbh>:
$dbh->{Profile} = "1/DBI::ProfileDumper";
This will write out profile data by statement into a file called
F. If you want to modify either of these properties, you
can construct the DBI::ProfileDumper object yourself:
use DBI::ProfileDumper;
$dbh->{Profile} = DBI::ProfileDumper->new(
Path => [ '!Statement' ],
File => 'dbi.prof'
);
The C option takes the same values as in
L. The C option gives the name of the
file where results will be collected. If it already exists it will be
overwritten.
You can also activate this module by setting the DBI_PROFILE
environment variable:
$ENV{DBI_PROFILE} = "!Statement/DBI::ProfileDumper";
This will cause all DBI handles to share the same profiling object.
=head1 METHODS
The following methods are available to be called using the profile
object. You can get access to the profile object from the Profile key
in any DBI handle:
my $profile = $dbh->{Profile};
=head2 flush_to_disk
$profile->flush_to_disk()
Flushes all collected profile data to disk and empties the Data hash. Returns
the filename written to. If no profile data has been collected then the file is
not written and flush_to_disk() returns undef.
The file is locked while it's being written. A process 'consuming' the files
while they're being written to, should rename the file first, then lock it,
then read it, then close and delete it. The C option to
L does the right thing.
This method may be called multiple times during a program run.
=head2 empty
$profile->empty()
Clears the Data hash without writing to disk.
=head2 filename
$filename = $profile->filename();
Get or set the filename.
The filename can be specified as a CODE reference, in which case the referenced
code should return the filename to be used. The code will be called with the
profile object as its first argument.
=head1 DATA FORMAT
The data format written by DBI::ProfileDumper starts with a header
containing the version number of the module used to generate it. Then
a block of variable declarations describes the profile. After two
newlines, the profile data forms the body of the file. For example:
DBI::ProfileDumper 2.003762
Path = [ '!Statement', '!MethodName' ]
Program = t/42profile_data.t
+ 1 SELECT name FROM users WHERE id = ?
+ 2 prepare
= 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576
+ 2 execute
1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576
+ 2 fetchrow_hashref
= 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576
+ 1 UPDATE users SET name = ? WHERE id = ?
+ 2 prepare
= 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576
+ 2 execute
= 1 0.0312958955764771 0.000490069389343262 0.000176072120666504 0.00140702724456787 1023115819.83019 1023115819.86576
The lines beginning with C<+> signs signify keys. The number after
the C<+> sign shows the nesting level of the key. Lines beginning
with C<=> are the actual profile data, in the same order as
in DBI::Profile.
Note that the same path may be present multiple times in the data file
since C may be called more than once. When read by
DBI::ProfileData the data points will be merged to produce a single
data set for each distinct path.
The key strings are transformed in three ways. First, all backslashes
are doubled. Then all newlines and carriage-returns are transformed
into C<\n> and C<\r> respectively. Finally, any NULL bytes (C<\0>)
are entirely removed. When DBI::ProfileData reads the file the first
two transformations will be reversed, but NULL bytes will not be
restored.
=head1 AUTHOR
Sam Tregar
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2002 Sam Tregar
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl 5 itself.
=cut
# inherit from DBI::Profile
use DBI::Profile;
our @ISA = ("DBI::Profile");
our $VERSION = "2.015325";
use Carp qw(croak);
use Fcntl qw(:flock);
use Symbol;
my $HAS_FLOCK = (defined $ENV{DBI_PROFILE_FLOCK})
? $ENV{DBI_PROFILE_FLOCK}
: do { local $@; eval { flock STDOUT, 0; 1 } };
my $program_header;
# validate params and setup default
sub new {
my $pkg = shift;
my $self = $pkg->SUPER::new(
LockFile => $HAS_FLOCK,
@_,
);
# provide a default filename
$self->filename("dbi.prof") unless $self->filename;
DBI->trace_msg("$self: @{[ %$self ]}\n",0)
if $self->{Trace} && $self->{Trace} >= 2;
return $self;
}
# get/set filename to use
sub filename {
my $self = shift;
$self->{File} = shift if @_;
my $filename = $self->{File};
$filename = $filename->($self) if ref($filename) eq 'CODE';
return $filename;
}
# flush available data to disk
sub flush_to_disk {
my $self = shift;
my $class = ref $self;
my $filename = $self->filename;
my $data = $self->{Data};
if (1) { # make an option
if (not $data or ref $data eq 'HASH' && !%$data) {
DBI->trace_msg("flush_to_disk skipped for empty profile\n",0) if $self->{Trace};
return undef;
}
}
my $fh = gensym;
if (($self->{_wrote_header}||'') eq $filename) {
# append more data to the file
# XXX assumes that Path hasn't changed
open($fh, ">>", $filename)
or croak("Unable to open '$filename' for $class output: $!");
} else {
# create new file (or overwrite existing)
if (-f $filename) {
my $bak = $filename.'.prev';
unlink($bak);
rename($filename, $bak)
or warn "Error renaming $filename to $bak: $!\n";
}
open($fh, ">", $filename)
or croak("Unable to open '$filename' for $class output: $!");
}
# lock the file (before checking size and writing the header)
flock($fh, LOCK_EX) if $self->{LockFile};
# write header if file is empty - typically because we just opened it
# in '>' mode, or perhaps we used '>>' but the file had been truncated externally.
if (-s $fh == 0) {
DBI->trace_msg("flush_to_disk wrote header to $filename\n",0) if $self->{Trace};
$self->write_header($fh);
$self->{_wrote_header} = $filename;
}
my $lines = $self->write_data($fh, $self->{Data}, 1);
DBI->trace_msg("flush_to_disk wrote $lines lines to $filename\n",0) if $self->{Trace};
close($fh) # unlocks the file
or croak("Error closing '$filename': $!");
$self->empty();
return $filename;
}
# write header to a filehandle
sub write_header {
my ($self, $fh) = @_;
# isolate us against globals which effect print
local($\, $,);
# $self->VERSION can return undef during global destruction
my $version = $self->VERSION || $VERSION;
# module name and version number
print $fh ref($self)." $version\n";
# print out Path (may contain CODE refs etc)
my @path_words = map { escape_key($_) } @{ $self->{Path} || [] };
print $fh "Path = [ ", join(', ', @path_words), " ]\n";
# print out $0 and @ARGV
if (!$program_header) {
# XXX should really quote as well as escape
$program_header = "Program = "
. join(" ", map { escape_key($_) } $0, @ARGV)
. "\n";
}
print $fh $program_header;
# all done
print $fh "\n";
}
# write data in the proscribed format
sub write_data {
my ($self, $fh, $data, $level) = @_;
# XXX it's valid for $data to be an ARRAY ref, i.e., Path is empty.
# produce an empty profile for invalid $data
return 0 unless $data and UNIVERSAL::isa($data,'HASH');
# isolate us against globals which affect print
local ($\, $,);
my $lines = 0;
while (my ($key, $value) = each(%$data)) {
# output a key
print $fh "+ $level ". escape_key($key). "\n";
if (UNIVERSAL::isa($value,'ARRAY')) {
# output a data set for a leaf node
print $fh "= ".join(' ', @$value)."\n";
$lines += 1;
} else {
# recurse through keys - this could be rewritten to use a
# stack for some small performance gain
$lines += $self->write_data($fh, $value, $level + 1);
}
}
return $lines;
}
# escape a key for output
sub escape_key {
my $key = shift;
$key =~ s!\\!\\\\!g;
$key =~ s!\n!\\n!g;
$key =~ s!\r!\\r!g;
$key =~ s!\0!!g;
return $key;
}
# flush data to disk when profile object goes out of scope
sub on_destroy {
shift->flush_to_disk();
}
1;
PK ]~ Const/GetInfoType.pmnu [ # $Id: GetInfoType.pm 8696 2007-01-24 23:12:38Z Tim $
#
# Copyright (c) 2002 Tim Bunce Ireland
#
# Constant data describing info type codes for the DBI getinfo function.
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
package DBI::Const::GetInfoType;
use strict;
use Exporter ();
use vars qw(@ISA @EXPORT @EXPORT_OK %GetInfoType);
@ISA = qw(Exporter);
@EXPORT = qw(%GetInfoType);
my
$VERSION = "2.008697";
=head1 NAME
DBI::Const::GetInfoType - Data describing GetInfo type codes
=head1 SYNOPSIS
use DBI::Const::GetInfoType;
=head1 DESCRIPTION
Imports a %GetInfoType hash which maps names for GetInfo Type Codes
into their corresponding numeric values. For example:
$database_version = $dbh->get_info( $GetInfoType{SQL_DBMS_VER} );
The interface to this module is new and nothing beyond what is
written here is guaranteed.
=cut
use DBI::Const::GetInfo::ANSI (); # liable to change
use DBI::Const::GetInfo::ODBC (); # liable to change
%GetInfoType =
(
%DBI::Const::GetInfo::ANSI::InfoTypes # liable to change
, %DBI::Const::GetInfo::ODBC::InfoTypes # liable to change
);
1;
PK ]] Const/GetInfoReturn.pmnu [ # $Id: GetInfoReturn.pm 8696 2007-01-24 23:12:38Z Tim $
#
# Copyright (c) 2002 Tim Bunce Ireland
#
# Constant data describing return values from the DBI getinfo function.
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
package DBI::Const::GetInfoReturn;
use strict;
use Exporter ();
use vars qw(@ISA @EXPORT @EXPORT_OK %GetInfoReturnTypes %GetInfoReturnValues);
@ISA = qw(Exporter);
@EXPORT = qw(%GetInfoReturnTypes %GetInfoReturnValues);
my
$VERSION = "2.008697";
=head1 NAME
DBI::Const::GetInfoReturn - Data and functions for describing GetInfo results
=head1 SYNOPSIS
The interface to this module is undocumented and liable to change.
=head1 DESCRIPTION
Data and functions for describing GetInfo results
=cut
use DBI::Const::GetInfoType;
use DBI::Const::GetInfo::ANSI ();
use DBI::Const::GetInfo::ODBC ();
%GetInfoReturnTypes =
(
%DBI::Const::GetInfo::ANSI::ReturnTypes
, %DBI::Const::GetInfo::ODBC::ReturnTypes
);
%GetInfoReturnValues = ();
{
my $A = \%DBI::Const::GetInfo::ANSI::ReturnValues;
my $O = \%DBI::Const::GetInfo::ODBC::ReturnValues;
while ( my ($k, $v) = each %$A ) {
my %h = ( exists $O->{$k} ) ? ( %$v, %{$O->{$k}} ) : %$v;
$GetInfoReturnValues{$k} = \%h;
}
while ( my ($k, $v) = each %$O ) {
next if exists $A->{$k};
my %h = %$v;
$GetInfoReturnValues{$k} = \%h;
}
}
# -----------------------------------------------------------------------------
sub Format {
my $InfoType = shift;
my $Value = shift;
return '' unless defined $Value;
my $ReturnType = $GetInfoReturnTypes{$InfoType};
return sprintf '0x%08X', $Value if $ReturnType eq 'SQLUINTEGER bitmask';
return sprintf '0x%08X', $Value if $ReturnType eq 'SQLINTEGER bitmask';
# return '"' . $Value . '"' if $ReturnType eq 'SQLCHAR';
return $Value;
}
sub Explain {
my $InfoType = shift;
my $Value = shift;
return '' unless defined $Value;
return '' unless exists $GetInfoReturnValues{$InfoType};
$Value = int $Value;
my $ReturnType = $GetInfoReturnTypes{$InfoType};
my %h = reverse %{$GetInfoReturnValues{$InfoType}};
if ( $ReturnType eq 'SQLUINTEGER bitmask'|| $ReturnType eq 'SQLINTEGER bitmask') {
my @a = ();
for my $k ( sort { $a <=> $b } keys %h ) {
push @a, $h{$k} if $Value & $k;
}
return wantarray ? @a : join(' ', @a );
}
else {
return $h{$Value} ||'?';
}
}
1;
PK ]ב% % Const/GetInfo/ANSI.pmnu [ # $Id: ANSI.pm 8696 2007-01-24 23:12:38Z Tim $
#
# Copyright (c) 2002 Tim Bunce Ireland
#
# Constant data describing ANSI CLI info types and return values for the
# SQLGetInfo() method of ODBC.
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
use strict;
package DBI::Const::GetInfo::ANSI;
our (%InfoTypes,%ReturnTypes,%ReturnValues,);
=head1 NAME
DBI::Const::GetInfo::ANSI - ISO/IEC SQL/CLI Constants for GetInfo
=head1 SYNOPSIS
The API for this module is private and subject to change.
=head1 DESCRIPTION
Information requested by GetInfo().
See: A.1 C header file SQLCLI.H, Page 316, 317.
The API for this module is private and subject to change.
=head1 REFERENCES
ISO/IEC FCD 9075-3:200x Information technology - Database Languages -
SQL - Part 3: Call-Level Interface (SQL/CLI)
SC32 N00744 = WG3:VIE-005 = H2-2002-007
Date: 2002-01-15
=cut
my
$VERSION = "2.008697";
%InfoTypes =
(
SQL_ALTER_TABLE => 86
, SQL_CATALOG_NAME => 10003
, SQL_COLLATING_SEQUENCE => 10004
, SQL_CURSOR_COMMIT_BEHAVIOR => 23
, SQL_CURSOR_SENSITIVITY => 10001
, SQL_DATA_SOURCE_NAME => 2
, SQL_DATA_SOURCE_READ_ONLY => 25
, SQL_DBMS_NAME => 17
, SQL_DBMS_VERSION => 18
, SQL_DEFAULT_TRANSACTION_ISOLATION => 26
, SQL_DESCRIBE_PARAMETER => 10002
, SQL_FETCH_DIRECTION => 8
, SQL_GETDATA_EXTENSIONS => 81
, SQL_IDENTIFIER_CASE => 28
, SQL_INTEGRITY => 73
, SQL_MAXIMUM_CATALOG_NAME_LENGTH => 34
, SQL_MAXIMUM_COLUMNS_IN_GROUP_BY => 97
, SQL_MAXIMUM_COLUMNS_IN_ORDER_BY => 99
, SQL_MAXIMUM_COLUMNS_IN_SELECT => 100
, SQL_MAXIMUM_COLUMNS_IN_TABLE => 101
, SQL_MAXIMUM_COLUMN_NAME_LENGTH => 30
, SQL_MAXIMUM_CONCURRENT_ACTIVITIES => 1
, SQL_MAXIMUM_CURSOR_NAME_LENGTH => 31
, SQL_MAXIMUM_DRIVER_CONNECTIONS => 0
, SQL_MAXIMUM_IDENTIFIER_LENGTH => 10005
, SQL_MAXIMUM_SCHEMA_NAME_LENGTH => 32
, SQL_MAXIMUM_STMT_OCTETS => 20000
, SQL_MAXIMUM_STMT_OCTETS_DATA => 20001
, SQL_MAXIMUM_STMT_OCTETS_SCHEMA => 20002
, SQL_MAXIMUM_TABLES_IN_SELECT => 106
, SQL_MAXIMUM_TABLE_NAME_LENGTH => 35
, SQL_MAXIMUM_USER_NAME_LENGTH => 107
, SQL_NULL_COLLATION => 85
, SQL_ORDER_BY_COLUMNS_IN_SELECT => 90
, SQL_OUTER_JOIN_CAPABILITIES => 115
, SQL_SCROLL_CONCURRENCY => 43
, SQL_SEARCH_PATTERN_ESCAPE => 14
, SQL_SERVER_NAME => 13
, SQL_SPECIAL_CHARACTERS => 94
, SQL_TRANSACTION_CAPABLE => 46
, SQL_TRANSACTION_ISOLATION_OPTION => 72
, SQL_USER_NAME => 47
);
=head2 %ReturnTypes
See: Codes and data types for implementation information (Table 28), Page 85, 86.
Mapped to ODBC datatype names.
=cut
%ReturnTypes = # maxlen
(
SQL_ALTER_TABLE => 'SQLUINTEGER bitmask' # INTEGER
, SQL_CATALOG_NAME => 'SQLCHAR' # CHARACTER (1)
, SQL_COLLATING_SEQUENCE => 'SQLCHAR' # CHARACTER (254)
, SQL_CURSOR_COMMIT_BEHAVIOR => 'SQLUSMALLINT' # SMALLINT
, SQL_CURSOR_SENSITIVITY => 'SQLUINTEGER' # INTEGER
, SQL_DATA_SOURCE_NAME => 'SQLCHAR' # CHARACTER (128)
, SQL_DATA_SOURCE_READ_ONLY => 'SQLCHAR' # CHARACTER (1)
, SQL_DBMS_NAME => 'SQLCHAR' # CHARACTER (254)
, SQL_DBMS_VERSION => 'SQLCHAR' # CHARACTER (254)
, SQL_DEFAULT_TRANSACTION_ISOLATION => 'SQLUINTEGER' # INTEGER
, SQL_DESCRIBE_PARAMETER => 'SQLCHAR' # CHARACTER (1)
, SQL_FETCH_DIRECTION => 'SQLUINTEGER bitmask' # INTEGER
, SQL_GETDATA_EXTENSIONS => 'SQLUINTEGER bitmask' # INTEGER
, SQL_IDENTIFIER_CASE => 'SQLUSMALLINT' # SMALLINT
, SQL_INTEGRITY => 'SQLCHAR' # CHARACTER (1)
, SQL_MAXIMUM_CATALOG_NAME_LENGTH => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_COLUMNS_IN_GROUP_BY => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_COLUMNS_IN_ORDER_BY => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_COLUMNS_IN_SELECT => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_COLUMNS_IN_TABLE => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_COLUMN_NAME_LENGTH => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_CONCURRENT_ACTIVITIES => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_CURSOR_NAME_LENGTH => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_DRIVER_CONNECTIONS => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_IDENTIFIER_LENGTH => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_SCHEMA_NAME_LENGTH => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_STMT_OCTETS => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_STMT_OCTETS_DATA => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_STMT_OCTETS_SCHEMA => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_TABLES_IN_SELECT => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_TABLE_NAME_LENGTH => 'SQLUSMALLINT' # SMALLINT
, SQL_MAXIMUM_USER_NAME_LENGTH => 'SQLUSMALLINT' # SMALLINT
, SQL_NULL_COLLATION => 'SQLUSMALLINT' # SMALLINT
, SQL_ORDER_BY_COLUMNS_IN_SELECT => 'SQLCHAR' # CHARACTER (1)
, SQL_OUTER_JOIN_CAPABILITIES => 'SQLUINTEGER bitmask' # INTEGER
, SQL_SCROLL_CONCURRENCY => 'SQLUINTEGER bitmask' # INTEGER
, SQL_SEARCH_PATTERN_ESCAPE => 'SQLCHAR' # CHARACTER (1)
, SQL_SERVER_NAME => 'SQLCHAR' # CHARACTER (128)
, SQL_SPECIAL_CHARACTERS => 'SQLCHAR' # CHARACTER (254)
, SQL_TRANSACTION_CAPABLE => 'SQLUSMALLINT' # SMALLINT
, SQL_TRANSACTION_ISOLATION_OPTION => 'SQLUINTEGER bitmask' # INTEGER
, SQL_USER_NAME => 'SQLCHAR' # CHARACTER (128)
);
=head2 %ReturnValues
See: A.1 C header file SQLCLI.H, Page 317, 318.
=cut
$ReturnValues{SQL_ALTER_TABLE} =
{
SQL_AT_ADD_COLUMN => 0x00000001
, SQL_AT_DROP_COLUMN => 0x00000002
, SQL_AT_ALTER_COLUMN => 0x00000004
, SQL_AT_ADD_CONSTRAINT => 0x00000008
, SQL_AT_DROP_CONSTRAINT => 0x00000010
};
$ReturnValues{SQL_CURSOR_COMMIT_BEHAVIOR} =
{
SQL_CB_DELETE => 0
, SQL_CB_CLOSE => 1
, SQL_CB_PRESERVE => 2
};
$ReturnValues{SQL_FETCH_DIRECTION} =
{
SQL_FD_FETCH_NEXT => 0x00000001
, SQL_FD_FETCH_FIRST => 0x00000002
, SQL_FD_FETCH_LAST => 0x00000004
, SQL_FD_FETCH_PRIOR => 0x00000008
, SQL_FD_FETCH_ABSOLUTE => 0x00000010
, SQL_FD_FETCH_RELATIVE => 0x00000020
};
$ReturnValues{SQL_GETDATA_EXTENSIONS} =
{
SQL_GD_ANY_COLUMN => 0x00000001
, SQL_GD_ANY_ORDER => 0x00000002
};
$ReturnValues{SQL_IDENTIFIER_CASE} =
{
SQL_IC_UPPER => 1
, SQL_IC_LOWER => 2
, SQL_IC_SENSITIVE => 3
, SQL_IC_MIXED => 4
};
$ReturnValues{SQL_NULL_COLLATION} =
{
SQL_NC_HIGH => 1
, SQL_NC_LOW => 2
};
$ReturnValues{SQL_OUTER_JOIN_CAPABILITIES} =
{
SQL_OUTER_JOIN_LEFT => 0x00000001
, SQL_OUTER_JOIN_RIGHT => 0x00000002
, SQL_OUTER_JOIN_FULL => 0x00000004
, SQL_OUTER_JOIN_NESTED => 0x00000008
, SQL_OUTER_JOIN_NOT_ORDERED => 0x00000010
, SQL_OUTER_JOIN_INNER => 0x00000020
, SQL_OUTER_JOIN_ALL_COMPARISON_OPS => 0x00000040
};
$ReturnValues{SQL_SCROLL_CONCURRENCY} =
{
SQL_SCCO_READ_ONLY => 0x00000001
, SQL_SCCO_LOCK => 0x00000002
, SQL_SCCO_OPT_ROWVER => 0x00000004
, SQL_SCCO_OPT_VALUES => 0x00000008
};
$ReturnValues{SQL_TRANSACTION_ACCESS_MODE} =
{
SQL_TRANSACTION_READ_ONLY => 0x00000001
, SQL_TRANSACTION_READ_WRITE => 0x00000002
};
$ReturnValues{SQL_TRANSACTION_CAPABLE} =
{
SQL_TC_NONE => 0
, SQL_TC_DML => 1
, SQL_TC_ALL => 2
, SQL_TC_DDL_COMMIT => 3
, SQL_TC_DDL_IGNORE => 4
};
$ReturnValues{SQL_TRANSACTION_ISOLATION} =
{
SQL_TRANSACTION_READ_UNCOMMITTED => 0x00000001
, SQL_TRANSACTION_READ_COMMITTED => 0x00000002
, SQL_TRANSACTION_REPEATABLE_READ => 0x00000004
, SQL_TRANSACTION_SERIALIZABLE => 0x00000008
};
1;
=head1 TODO
Corrections, e.g.:
SQL_TRANSACTION_ISOLATION_OPTION vs. SQL_TRANSACTION_ISOLATION
=cut
PK ]stI I Const/GetInfo/ODBC.pmnu [ # $Id: ODBC.pm 11373 2008-06-02 19:01:33Z Tim $
#
# Copyright (c) 2002 Tim Bunce Ireland
#
# Constant data describing Microsoft ODBC info types and return values
# for the SQLGetInfo() method of ODBC.
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
use strict;
package DBI::Const::GetInfo::ODBC;
our (%InfoTypes,%ReturnTypes,%ReturnValues,);
=head1 NAME
DBI::Const::GetInfo::ODBC - ODBC Constants for GetInfo
=head1 SYNOPSIS
The API for this module is private and subject to change.
=head1 DESCRIPTION
Information requested by GetInfo().
The API for this module is private and subject to change.
=head1 REFERENCES
MDAC SDK 2.6
ODBC version number (0x0351)
sql.h
sqlext.h
=cut
my
$VERSION = "2.011374";
%InfoTypes =
(
SQL_ACCESSIBLE_PROCEDURES => 20
, SQL_ACCESSIBLE_TABLES => 19
, SQL_ACTIVE_CONNECTIONS => 0
, SQL_ACTIVE_ENVIRONMENTS => 116
, SQL_ACTIVE_STATEMENTS => 1
, SQL_AGGREGATE_FUNCTIONS => 169
, SQL_ALTER_DOMAIN => 117
, SQL_ALTER_TABLE => 86
, SQL_ASYNC_MODE => 10021
, SQL_BATCH_ROW_COUNT => 120
, SQL_BATCH_SUPPORT => 121
, SQL_BOOKMARK_PERSISTENCE => 82
, SQL_CATALOG_LOCATION => 114 # SQL_QUALIFIER_LOCATION
, SQL_CATALOG_NAME => 10003
, SQL_CATALOG_NAME_SEPARATOR => 41 # SQL_QUALIFIER_NAME_SEPARATOR
, SQL_CATALOG_TERM => 42 # SQL_QUALIFIER_TERM
, SQL_CATALOG_USAGE => 92 # SQL_QUALIFIER_USAGE
, SQL_COLLATION_SEQ => 10004
, SQL_COLUMN_ALIAS => 87
, SQL_CONCAT_NULL_BEHAVIOR => 22
, SQL_CONVERT_BIGINT => 53
, SQL_CONVERT_BINARY => 54
, SQL_CONVERT_BIT => 55
, SQL_CONVERT_CHAR => 56
, SQL_CONVERT_DATE => 57
, SQL_CONVERT_DECIMAL => 58
, SQL_CONVERT_DOUBLE => 59
, SQL_CONVERT_FLOAT => 60
, SQL_CONVERT_FUNCTIONS => 48
, SQL_CONVERT_GUID => 173
, SQL_CONVERT_INTEGER => 61
, SQL_CONVERT_INTERVAL_DAY_TIME => 123
, SQL_CONVERT_INTERVAL_YEAR_MONTH => 124
, SQL_CONVERT_LONGVARBINARY => 71
, SQL_CONVERT_LONGVARCHAR => 62
, SQL_CONVERT_NUMERIC => 63
, SQL_CONVERT_REAL => 64
, SQL_CONVERT_SMALLINT => 65
, SQL_CONVERT_TIME => 66
, SQL_CONVERT_TIMESTAMP => 67
, SQL_CONVERT_TINYINT => 68
, SQL_CONVERT_VARBINARY => 69
, SQL_CONVERT_VARCHAR => 70
, SQL_CONVERT_WCHAR => 122
, SQL_CONVERT_WLONGVARCHAR => 125
, SQL_CONVERT_WVARCHAR => 126
, SQL_CORRELATION_NAME => 74
, SQL_CREATE_ASSERTION => 127
, SQL_CREATE_CHARACTER_SET => 128
, SQL_CREATE_COLLATION => 129
, SQL_CREATE_DOMAIN => 130
, SQL_CREATE_SCHEMA => 131
, SQL_CREATE_TABLE => 132
, SQL_CREATE_TRANSLATION => 133
, SQL_CREATE_VIEW => 134
, SQL_CURSOR_COMMIT_BEHAVIOR => 23
, SQL_CURSOR_ROLLBACK_BEHAVIOR => 24
, SQL_CURSOR_SENSITIVITY => 10001
, SQL_DATA_SOURCE_NAME => 2
, SQL_DATA_SOURCE_READ_ONLY => 25
, SQL_DATABASE_NAME => 16
, SQL_DATETIME_LITERALS => 119
, SQL_DBMS_NAME => 17
, SQL_DBMS_VER => 18
, SQL_DDL_INDEX => 170
, SQL_DEFAULT_TXN_ISOLATION => 26
, SQL_DESCRIBE_PARAMETER => 10002
, SQL_DM_VER => 171
, SQL_DRIVER_HDBC => 3
, SQL_DRIVER_HDESC => 135
, SQL_DRIVER_HENV => 4
, SQL_DRIVER_HLIB => 76
, SQL_DRIVER_HSTMT => 5
, SQL_DRIVER_NAME => 6
, SQL_DRIVER_ODBC_VER => 77
, SQL_DRIVER_VER => 7
, SQL_DROP_ASSERTION => 136
, SQL_DROP_CHARACTER_SET => 137
, SQL_DROP_COLLATION => 138
, SQL_DROP_DOMAIN => 139
, SQL_DROP_SCHEMA => 140
, SQL_DROP_TABLE => 141
, SQL_DROP_TRANSLATION => 142
, SQL_DROP_VIEW => 143
, SQL_DYNAMIC_CURSOR_ATTRIBUTES1 => 144
, SQL_DYNAMIC_CURSOR_ATTRIBUTES2 => 145
, SQL_EXPRESSIONS_IN_ORDERBY => 27
, SQL_FETCH_DIRECTION => 8
, SQL_FILE_USAGE => 84
, SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 => 146
, SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 => 147
, SQL_GETDATA_EXTENSIONS => 81
, SQL_GROUP_BY => 88
, SQL_IDENTIFIER_CASE => 28
, SQL_IDENTIFIER_QUOTE_CHAR => 29
, SQL_INDEX_KEYWORDS => 148
# SQL_INFO_DRIVER_START => 1000
# SQL_INFO_FIRST => 0
# SQL_INFO_LAST => 114 # SQL_QUALIFIER_LOCATION
, SQL_INFO_SCHEMA_VIEWS => 149
, SQL_INSERT_STATEMENT => 172
, SQL_INTEGRITY => 73
, SQL_KEYSET_CURSOR_ATTRIBUTES1 => 150
, SQL_KEYSET_CURSOR_ATTRIBUTES2 => 151
, SQL_KEYWORDS => 89
, SQL_LIKE_ESCAPE_CLAUSE => 113
, SQL_LOCK_TYPES => 78
, SQL_MAXIMUM_CATALOG_NAME_LENGTH => 34 # SQL_MAX_CATALOG_NAME_LEN
, SQL_MAXIMUM_COLUMNS_IN_GROUP_BY => 97 # SQL_MAX_COLUMNS_IN_GROUP_BY
, SQL_MAXIMUM_COLUMNS_IN_INDEX => 98 # SQL_MAX_COLUMNS_IN_INDEX
, SQL_MAXIMUM_COLUMNS_IN_ORDER_BY => 99 # SQL_MAX_COLUMNS_IN_ORDER_BY
, SQL_MAXIMUM_COLUMNS_IN_SELECT => 100 # SQL_MAX_COLUMNS_IN_SELECT
, SQL_MAXIMUM_COLUMN_NAME_LENGTH => 30 # SQL_MAX_COLUMN_NAME_LEN
, SQL_MAXIMUM_CONCURRENT_ACTIVITIES => 1 # SQL_MAX_CONCURRENT_ACTIVITIES
, SQL_MAXIMUM_CURSOR_NAME_LENGTH => 31 # SQL_MAX_CURSOR_NAME_LEN
, SQL_MAXIMUM_DRIVER_CONNECTIONS => 0 # SQL_MAX_DRIVER_CONNECTIONS
, SQL_MAXIMUM_IDENTIFIER_LENGTH => 10005 # SQL_MAX_IDENTIFIER_LEN
, SQL_MAXIMUM_INDEX_SIZE => 102 # SQL_MAX_INDEX_SIZE
, SQL_MAXIMUM_ROW_SIZE => 104 # SQL_MAX_ROW_SIZE
, SQL_MAXIMUM_SCHEMA_NAME_LENGTH => 32 # SQL_MAX_SCHEMA_NAME_LEN
, SQL_MAXIMUM_STATEMENT_LENGTH => 105 # SQL_MAX_STATEMENT_LEN
, SQL_MAXIMUM_TABLES_IN_SELECT => 106 # SQL_MAX_TABLES_IN_SELECT
, SQL_MAXIMUM_USER_NAME_LENGTH => 107 # SQL_MAX_USER_NAME_LEN
, SQL_MAX_ASYNC_CONCURRENT_STATEMENTS => 10022
, SQL_MAX_BINARY_LITERAL_LEN => 112
, SQL_MAX_CATALOG_NAME_LEN => 34
, SQL_MAX_CHAR_LITERAL_LEN => 108
, SQL_MAX_COLUMNS_IN_GROUP_BY => 97
, SQL_MAX_COLUMNS_IN_INDEX => 98
, SQL_MAX_COLUMNS_IN_ORDER_BY => 99
, SQL_MAX_COLUMNS_IN_SELECT => 100
, SQL_MAX_COLUMNS_IN_TABLE => 101
, SQL_MAX_COLUMN_NAME_LEN => 30
, SQL_MAX_CONCURRENT_ACTIVITIES => 1
, SQL_MAX_CURSOR_NAME_LEN => 31
, SQL_MAX_DRIVER_CONNECTIONS => 0
, SQL_MAX_IDENTIFIER_LEN => 10005
, SQL_MAX_INDEX_SIZE => 102
, SQL_MAX_OWNER_NAME_LEN => 32
, SQL_MAX_PROCEDURE_NAME_LEN => 33
, SQL_MAX_QUALIFIER_NAME_LEN => 34
, SQL_MAX_ROW_SIZE => 104
, SQL_MAX_ROW_SIZE_INCLUDES_LONG => 103
, SQL_MAX_SCHEMA_NAME_LEN => 32
, SQL_MAX_STATEMENT_LEN => 105
, SQL_MAX_TABLES_IN_SELECT => 106
, SQL_MAX_TABLE_NAME_LEN => 35
, SQL_MAX_USER_NAME_LEN => 107
, SQL_MULTIPLE_ACTIVE_TXN => 37
, SQL_MULT_RESULT_SETS => 36
, SQL_NEED_LONG_DATA_LEN => 111
, SQL_NON_NULLABLE_COLUMNS => 75
, SQL_NULL_COLLATION => 85
, SQL_NUMERIC_FUNCTIONS => 49
, SQL_ODBC_API_CONFORMANCE => 9
, SQL_ODBC_INTERFACE_CONFORMANCE => 152
, SQL_ODBC_SAG_CLI_CONFORMANCE => 12
, SQL_ODBC_SQL_CONFORMANCE => 15
, SQL_ODBC_SQL_OPT_IEF => 73
, SQL_ODBC_VER => 10
, SQL_OJ_CAPABILITIES => 115
, SQL_ORDER_BY_COLUMNS_IN_SELECT => 90
, SQL_OUTER_JOINS => 38
, SQL_OUTER_JOIN_CAPABILITIES => 115 # SQL_OJ_CAPABILITIES
, SQL_OWNER_TERM => 39
, SQL_OWNER_USAGE => 91
, SQL_PARAM_ARRAY_ROW_COUNTS => 153
, SQL_PARAM_ARRAY_SELECTS => 154
, SQL_POSITIONED_STATEMENTS => 80
, SQL_POS_OPERATIONS => 79
, SQL_PROCEDURES => 21
, SQL_PROCEDURE_TERM => 40
, SQL_QUALIFIER_LOCATION => 114
, SQL_QUALIFIER_NAME_SEPARATOR => 41
, SQL_QUALIFIER_TERM => 42
, SQL_QUALIFIER_USAGE => 92
, SQL_QUOTED_IDENTIFIER_CASE => 93
, SQL_ROW_UPDATES => 11
, SQL_SCHEMA_TERM => 39 # SQL_OWNER_TERM
, SQL_SCHEMA_USAGE => 91 # SQL_OWNER_USAGE
, SQL_SCROLL_CONCURRENCY => 43
, SQL_SCROLL_OPTIONS => 44
, SQL_SEARCH_PATTERN_ESCAPE => 14
, SQL_SERVER_NAME => 13
, SQL_SPECIAL_CHARACTERS => 94
, SQL_SQL92_DATETIME_FUNCTIONS => 155
, SQL_SQL92_FOREIGN_KEY_DELETE_RULE => 156
, SQL_SQL92_FOREIGN_KEY_UPDATE_RULE => 157
, SQL_SQL92_GRANT => 158
, SQL_SQL92_NUMERIC_VALUE_FUNCTIONS => 159
, SQL_SQL92_PREDICATES => 160
, SQL_SQL92_RELATIONAL_JOIN_OPERATORS => 161
, SQL_SQL92_REVOKE => 162
, SQL_SQL92_ROW_VALUE_CONSTRUCTOR => 163
, SQL_SQL92_STRING_FUNCTIONS => 164
, SQL_SQL92_VALUE_EXPRESSIONS => 165
, SQL_SQL_CONFORMANCE => 118
, SQL_STANDARD_CLI_CONFORMANCE => 166
, SQL_STATIC_CURSOR_ATTRIBUTES1 => 167
, SQL_STATIC_CURSOR_ATTRIBUTES2 => 168
, SQL_STATIC_SENSITIVITY => 83
, SQL_STRING_FUNCTIONS => 50
, SQL_SUBQUERIES => 95
, SQL_SYSTEM_FUNCTIONS => 51
, SQL_TABLE_TERM => 45
, SQL_TIMEDATE_ADD_INTERVALS => 109
, SQL_TIMEDATE_DIFF_INTERVALS => 110
, SQL_TIMEDATE_FUNCTIONS => 52
, SQL_TRANSACTION_CAPABLE => 46 # SQL_TXN_CAPABLE
, SQL_TRANSACTION_ISOLATION_OPTION => 72 # SQL_TXN_ISOLATION_OPTION
, SQL_TXN_CAPABLE => 46
, SQL_TXN_ISOLATION_OPTION => 72
, SQL_UNION => 96
, SQL_UNION_STATEMENT => 96 # SQL_UNION
, SQL_USER_NAME => 47
, SQL_XOPEN_CLI_YEAR => 10000
);
=head2 %ReturnTypes
See: mk:@MSITStore:X:\dm\cli\mdac\sdk26\Docs\odbc.chm::/htm/odbcsqlgetinfo.htm
=> : alias
=> !!! : edited
=cut
%ReturnTypes =
(
SQL_ACCESSIBLE_PROCEDURES => 'SQLCHAR' # 20
, SQL_ACCESSIBLE_TABLES => 'SQLCHAR' # 19
, SQL_ACTIVE_CONNECTIONS => 'SQLUSMALLINT' # 0 =>
, SQL_ACTIVE_ENVIRONMENTS => 'SQLUSMALLINT' # 116
, SQL_ACTIVE_STATEMENTS => 'SQLUSMALLINT' # 1 =>
, SQL_AGGREGATE_FUNCTIONS => 'SQLUINTEGER bitmask' # 169
, SQL_ALTER_DOMAIN => 'SQLUINTEGER bitmask' # 117
, SQL_ALTER_TABLE => 'SQLUINTEGER bitmask' # 86
, SQL_ASYNC_MODE => 'SQLUINTEGER' # 10021
, SQL_BATCH_ROW_COUNT => 'SQLUINTEGER bitmask' # 120
, SQL_BATCH_SUPPORT => 'SQLUINTEGER bitmask' # 121
, SQL_BOOKMARK_PERSISTENCE => 'SQLUINTEGER bitmask' # 82
, SQL_CATALOG_LOCATION => 'SQLUSMALLINT' # 114
, SQL_CATALOG_NAME => 'SQLCHAR' # 10003
, SQL_CATALOG_NAME_SEPARATOR => 'SQLCHAR' # 41
, SQL_CATALOG_TERM => 'SQLCHAR' # 42
, SQL_CATALOG_USAGE => 'SQLUINTEGER bitmask' # 92
, SQL_COLLATION_SEQ => 'SQLCHAR' # 10004
, SQL_COLUMN_ALIAS => 'SQLCHAR' # 87
, SQL_CONCAT_NULL_BEHAVIOR => 'SQLUSMALLINT' # 22
, SQL_CONVERT_BIGINT => 'SQLUINTEGER bitmask' # 53
, SQL_CONVERT_BINARY => 'SQLUINTEGER bitmask' # 54
, SQL_CONVERT_BIT => 'SQLUINTEGER bitmask' # 55
, SQL_CONVERT_CHAR => 'SQLUINTEGER bitmask' # 56
, SQL_CONVERT_DATE => 'SQLUINTEGER bitmask' # 57
, SQL_CONVERT_DECIMAL => 'SQLUINTEGER bitmask' # 58
, SQL_CONVERT_DOUBLE => 'SQLUINTEGER bitmask' # 59
, SQL_CONVERT_FLOAT => 'SQLUINTEGER bitmask' # 60
, SQL_CONVERT_FUNCTIONS => 'SQLUINTEGER bitmask' # 48
, SQL_CONVERT_GUID => 'SQLUINTEGER bitmask' # 173
, SQL_CONVERT_INTEGER => 'SQLUINTEGER bitmask' # 61
, SQL_CONVERT_INTERVAL_DAY_TIME => 'SQLUINTEGER bitmask' # 123
, SQL_CONVERT_INTERVAL_YEAR_MONTH => 'SQLUINTEGER bitmask' # 124
, SQL_CONVERT_LONGVARBINARY => 'SQLUINTEGER bitmask' # 71
, SQL_CONVERT_LONGVARCHAR => 'SQLUINTEGER bitmask' # 62
, SQL_CONVERT_NUMERIC => 'SQLUINTEGER bitmask' # 63
, SQL_CONVERT_REAL => 'SQLUINTEGER bitmask' # 64
, SQL_CONVERT_SMALLINT => 'SQLUINTEGER bitmask' # 65
, SQL_CONVERT_TIME => 'SQLUINTEGER bitmask' # 66
, SQL_CONVERT_TIMESTAMP => 'SQLUINTEGER bitmask' # 67
, SQL_CONVERT_TINYINT => 'SQLUINTEGER bitmask' # 68
, SQL_CONVERT_VARBINARY => 'SQLUINTEGER bitmask' # 69
, SQL_CONVERT_VARCHAR => 'SQLUINTEGER bitmask' # 70
, SQL_CONVERT_WCHAR => 'SQLUINTEGER bitmask' # 122 => !!!
, SQL_CONVERT_WLONGVARCHAR => 'SQLUINTEGER bitmask' # 125 => !!!
, SQL_CONVERT_WVARCHAR => 'SQLUINTEGER bitmask' # 126 => !!!
, SQL_CORRELATION_NAME => 'SQLUSMALLINT' # 74
, SQL_CREATE_ASSERTION => 'SQLUINTEGER bitmask' # 127
, SQL_CREATE_CHARACTER_SET => 'SQLUINTEGER bitmask' # 128
, SQL_CREATE_COLLATION => 'SQLUINTEGER bitmask' # 129
, SQL_CREATE_DOMAIN => 'SQLUINTEGER bitmask' # 130
, SQL_CREATE_SCHEMA => 'SQLUINTEGER bitmask' # 131
, SQL_CREATE_TABLE => 'SQLUINTEGER bitmask' # 132
, SQL_CREATE_TRANSLATION => 'SQLUINTEGER bitmask' # 133
, SQL_CREATE_VIEW => 'SQLUINTEGER bitmask' # 134
, SQL_CURSOR_COMMIT_BEHAVIOR => 'SQLUSMALLINT' # 23
, SQL_CURSOR_ROLLBACK_BEHAVIOR => 'SQLUSMALLINT' # 24
, SQL_CURSOR_SENSITIVITY => 'SQLUINTEGER' # 10001
, SQL_DATA_SOURCE_NAME => 'SQLCHAR' # 2
, SQL_DATA_SOURCE_READ_ONLY => 'SQLCHAR' # 25
, SQL_DATABASE_NAME => 'SQLCHAR' # 16
, SQL_DATETIME_LITERALS => 'SQLUINTEGER bitmask' # 119
, SQL_DBMS_NAME => 'SQLCHAR' # 17
, SQL_DBMS_VER => 'SQLCHAR' # 18
, SQL_DDL_INDEX => 'SQLUINTEGER bitmask' # 170
, SQL_DEFAULT_TXN_ISOLATION => 'SQLUINTEGER' # 26
, SQL_DESCRIBE_PARAMETER => 'SQLCHAR' # 10002
, SQL_DM_VER => 'SQLCHAR' # 171
, SQL_DRIVER_HDBC => 'SQLUINTEGER' # 3
, SQL_DRIVER_HDESC => 'SQLUINTEGER' # 135
, SQL_DRIVER_HENV => 'SQLUINTEGER' # 4
, SQL_DRIVER_HLIB => 'SQLUINTEGER' # 76
, SQL_DRIVER_HSTMT => 'SQLUINTEGER' # 5
, SQL_DRIVER_NAME => 'SQLCHAR' # 6
, SQL_DRIVER_ODBC_VER => 'SQLCHAR' # 77
, SQL_DRIVER_VER => 'SQLCHAR' # 7
, SQL_DROP_ASSERTION => 'SQLUINTEGER bitmask' # 136
, SQL_DROP_CHARACTER_SET => 'SQLUINTEGER bitmask' # 137
, SQL_DROP_COLLATION => 'SQLUINTEGER bitmask' # 138
, SQL_DROP_DOMAIN => 'SQLUINTEGER bitmask' # 139
, SQL_DROP_SCHEMA => 'SQLUINTEGER bitmask' # 140
, SQL_DROP_TABLE => 'SQLUINTEGER bitmask' # 141
, SQL_DROP_TRANSLATION => 'SQLUINTEGER bitmask' # 142
, SQL_DROP_VIEW => 'SQLUINTEGER bitmask' # 143
, SQL_DYNAMIC_CURSOR_ATTRIBUTES1 => 'SQLUINTEGER bitmask' # 144
, SQL_DYNAMIC_CURSOR_ATTRIBUTES2 => 'SQLUINTEGER bitmask' # 145
, SQL_EXPRESSIONS_IN_ORDERBY => 'SQLCHAR' # 27
, SQL_FETCH_DIRECTION => 'SQLUINTEGER bitmask' # 8 => !!!
, SQL_FILE_USAGE => 'SQLUSMALLINT' # 84
, SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 => 'SQLUINTEGER bitmask' # 146
, SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 => 'SQLUINTEGER bitmask' # 147
, SQL_GETDATA_EXTENSIONS => 'SQLUINTEGER bitmask' # 81
, SQL_GROUP_BY => 'SQLUSMALLINT' # 88
, SQL_IDENTIFIER_CASE => 'SQLUSMALLINT' # 28
, SQL_IDENTIFIER_QUOTE_CHAR => 'SQLCHAR' # 29
, SQL_INDEX_KEYWORDS => 'SQLUINTEGER bitmask' # 148
# SQL_INFO_DRIVER_START => '' # 1000 =>
# SQL_INFO_FIRST => 'SQLUSMALLINT' # 0 =>
# SQL_INFO_LAST => 'SQLUSMALLINT' # 114 =>
, SQL_INFO_SCHEMA_VIEWS => 'SQLUINTEGER bitmask' # 149
, SQL_INSERT_STATEMENT => 'SQLUINTEGER bitmask' # 172
, SQL_INTEGRITY => 'SQLCHAR' # 73
, SQL_KEYSET_CURSOR_ATTRIBUTES1 => 'SQLUINTEGER bitmask' # 150
, SQL_KEYSET_CURSOR_ATTRIBUTES2 => 'SQLUINTEGER bitmask' # 151
, SQL_KEYWORDS => 'SQLCHAR' # 89
, SQL_LIKE_ESCAPE_CLAUSE => 'SQLCHAR' # 113
, SQL_LOCK_TYPES => 'SQLUINTEGER bitmask' # 78 => !!!
, SQL_MAXIMUM_CATALOG_NAME_LENGTH => 'SQLUSMALLINT' # 34 =>
, SQL_MAXIMUM_COLUMNS_IN_GROUP_BY => 'SQLUSMALLINT' # 97 =>
, SQL_MAXIMUM_COLUMNS_IN_INDEX => 'SQLUSMALLINT' # 98 =>
, SQL_MAXIMUM_COLUMNS_IN_ORDER_BY => 'SQLUSMALLINT' # 99 =>
, SQL_MAXIMUM_COLUMNS_IN_SELECT => 'SQLUSMALLINT' # 100 =>
, SQL_MAXIMUM_COLUMN_NAME_LENGTH => 'SQLUSMALLINT' # 30 =>
, SQL_MAXIMUM_CONCURRENT_ACTIVITIES => 'SQLUSMALLINT' # 1 =>
, SQL_MAXIMUM_CURSOR_NAME_LENGTH => 'SQLUSMALLINT' # 31 =>
, SQL_MAXIMUM_DRIVER_CONNECTIONS => 'SQLUSMALLINT' # 0 =>
, SQL_MAXIMUM_IDENTIFIER_LENGTH => 'SQLUSMALLINT' # 10005 =>
, SQL_MAXIMUM_INDEX_SIZE => 'SQLUINTEGER' # 102 =>
, SQL_MAXIMUM_ROW_SIZE => 'SQLUINTEGER' # 104 =>
, SQL_MAXIMUM_SCHEMA_NAME_LENGTH => 'SQLUSMALLINT' # 32 =>
, SQL_MAXIMUM_STATEMENT_LENGTH => 'SQLUINTEGER' # 105 =>
, SQL_MAXIMUM_TABLES_IN_SELECT => 'SQLUSMALLINT' # 106 =>
, SQL_MAXIMUM_USER_NAME_LENGTH => 'SQLUSMALLINT' # 107 =>
, SQL_MAX_ASYNC_CONCURRENT_STATEMENTS => 'SQLUINTEGER' # 10022
, SQL_MAX_BINARY_LITERAL_LEN => 'SQLUINTEGER' # 112
, SQL_MAX_CATALOG_NAME_LEN => 'SQLUSMALLINT' # 34
, SQL_MAX_CHAR_LITERAL_LEN => 'SQLUINTEGER' # 108
, SQL_MAX_COLUMNS_IN_GROUP_BY => 'SQLUSMALLINT' # 97
, SQL_MAX_COLUMNS_IN_INDEX => 'SQLUSMALLINT' # 98
, SQL_MAX_COLUMNS_IN_ORDER_BY => 'SQLUSMALLINT' # 99
, SQL_MAX_COLUMNS_IN_SELECT => 'SQLUSMALLINT' # 100
, SQL_MAX_COLUMNS_IN_TABLE => 'SQLUSMALLINT' # 101
, SQL_MAX_COLUMN_NAME_LEN => 'SQLUSMALLINT' # 30
, SQL_MAX_CONCURRENT_ACTIVITIES => 'SQLUSMALLINT' # 1
, SQL_MAX_CURSOR_NAME_LEN => 'SQLUSMALLINT' # 31
, SQL_MAX_DRIVER_CONNECTIONS => 'SQLUSMALLINT' # 0
, SQL_MAX_IDENTIFIER_LEN => 'SQLUSMALLINT' # 10005
, SQL_MAX_INDEX_SIZE => 'SQLUINTEGER' # 102
, SQL_MAX_OWNER_NAME_LEN => 'SQLUSMALLINT' # 32 =>
, SQL_MAX_PROCEDURE_NAME_LEN => 'SQLUSMALLINT' # 33
, SQL_MAX_QUALIFIER_NAME_LEN => 'SQLUSMALLINT' # 34 =>
, SQL_MAX_ROW_SIZE => 'SQLUINTEGER' # 104
, SQL_MAX_ROW_SIZE_INCLUDES_LONG => 'SQLCHAR' # 103
, SQL_MAX_SCHEMA_NAME_LEN => 'SQLUSMALLINT' # 32
, SQL_MAX_STATEMENT_LEN => 'SQLUINTEGER' # 105
, SQL_MAX_TABLES_IN_SELECT => 'SQLUSMALLINT' # 106
, SQL_MAX_TABLE_NAME_LEN => 'SQLUSMALLINT' # 35
, SQL_MAX_USER_NAME_LEN => 'SQLUSMALLINT' # 107
, SQL_MULTIPLE_ACTIVE_TXN => 'SQLCHAR' # 37
, SQL_MULT_RESULT_SETS => 'SQLCHAR' # 36
, SQL_NEED_LONG_DATA_LEN => 'SQLCHAR' # 111
, SQL_NON_NULLABLE_COLUMNS => 'SQLUSMALLINT' # 75
, SQL_NULL_COLLATION => 'SQLUSMALLINT' # 85
, SQL_NUMERIC_FUNCTIONS => 'SQLUINTEGER bitmask' # 49
, SQL_ODBC_API_CONFORMANCE => 'SQLUSMALLINT' # 9 => !!!
, SQL_ODBC_INTERFACE_CONFORMANCE => 'SQLUINTEGER' # 152
, SQL_ODBC_SAG_CLI_CONFORMANCE => 'SQLUSMALLINT' # 12 => !!!
, SQL_ODBC_SQL_CONFORMANCE => 'SQLUSMALLINT' # 15 => !!!
, SQL_ODBC_SQL_OPT_IEF => 'SQLCHAR' # 73 =>
, SQL_ODBC_VER => 'SQLCHAR' # 10
, SQL_OJ_CAPABILITIES => 'SQLUINTEGER bitmask' # 115
, SQL_ORDER_BY_COLUMNS_IN_SELECT => 'SQLCHAR' # 90
, SQL_OUTER_JOINS => 'SQLCHAR' # 38 => !!!
, SQL_OUTER_JOIN_CAPABILITIES => 'SQLUINTEGER bitmask' # 115 =>
, SQL_OWNER_TERM => 'SQLCHAR' # 39 =>
, SQL_OWNER_USAGE => 'SQLUINTEGER bitmask' # 91 =>
, SQL_PARAM_ARRAY_ROW_COUNTS => 'SQLUINTEGER' # 153
, SQL_PARAM_ARRAY_SELECTS => 'SQLUINTEGER' # 154
, SQL_POSITIONED_STATEMENTS => 'SQLUINTEGER bitmask' # 80 => !!!
, SQL_POS_OPERATIONS => 'SQLINTEGER bitmask' # 79
, SQL_PROCEDURES => 'SQLCHAR' # 21
, SQL_PROCEDURE_TERM => 'SQLCHAR' # 40
, SQL_QUALIFIER_LOCATION => 'SQLUSMALLINT' # 114 =>
, SQL_QUALIFIER_NAME_SEPARATOR => 'SQLCHAR' # 41 =>
, SQL_QUALIFIER_TERM => 'SQLCHAR' # 42 =>
, SQL_QUALIFIER_USAGE => 'SQLUINTEGER bitmask' # 92 =>
, SQL_QUOTED_IDENTIFIER_CASE => 'SQLUSMALLINT' # 93
, SQL_ROW_UPDATES => 'SQLCHAR' # 11
, SQL_SCHEMA_TERM => 'SQLCHAR' # 39
, SQL_SCHEMA_USAGE => 'SQLUINTEGER bitmask' # 91
, SQL_SCROLL_CONCURRENCY => 'SQLUINTEGER bitmask' # 43 => !!!
, SQL_SCROLL_OPTIONS => 'SQLUINTEGER bitmask' # 44
, SQL_SEARCH_PATTERN_ESCAPE => 'SQLCHAR' # 14
, SQL_SERVER_NAME => 'SQLCHAR' # 13
, SQL_SPECIAL_CHARACTERS => 'SQLCHAR' # 94
, SQL_SQL92_DATETIME_FUNCTIONS => 'SQLUINTEGER bitmask' # 155
, SQL_SQL92_FOREIGN_KEY_DELETE_RULE => 'SQLUINTEGER bitmask' # 156
, SQL_SQL92_FOREIGN_KEY_UPDATE_RULE => 'SQLUINTEGER bitmask' # 157
, SQL_SQL92_GRANT => 'SQLUINTEGER bitmask' # 158
, SQL_SQL92_NUMERIC_VALUE_FUNCTIONS => 'SQLUINTEGER bitmask' # 159
, SQL_SQL92_PREDICATES => 'SQLUINTEGER bitmask' # 160
, SQL_SQL92_RELATIONAL_JOIN_OPERATORS => 'SQLUINTEGER bitmask' # 161
, SQL_SQL92_REVOKE => 'SQLUINTEGER bitmask' # 162
, SQL_SQL92_ROW_VALUE_CONSTRUCTOR => 'SQLUINTEGER bitmask' # 163
, SQL_SQL92_STRING_FUNCTIONS => 'SQLUINTEGER bitmask' # 164
, SQL_SQL92_VALUE_EXPRESSIONS => 'SQLUINTEGER bitmask' # 165
, SQL_SQL_CONFORMANCE => 'SQLUINTEGER' # 118
, SQL_STANDARD_CLI_CONFORMANCE => 'SQLUINTEGER bitmask' # 166
, SQL_STATIC_CURSOR_ATTRIBUTES1 => 'SQLUINTEGER bitmask' # 167
, SQL_STATIC_CURSOR_ATTRIBUTES2 => 'SQLUINTEGER bitmask' # 168
, SQL_STATIC_SENSITIVITY => 'SQLUINTEGER bitmask' # 83 => !!!
, SQL_STRING_FUNCTIONS => 'SQLUINTEGER bitmask' # 50
, SQL_SUBQUERIES => 'SQLUINTEGER bitmask' # 95
, SQL_SYSTEM_FUNCTIONS => 'SQLUINTEGER bitmask' # 51
, SQL_TABLE_TERM => 'SQLCHAR' # 45
, SQL_TIMEDATE_ADD_INTERVALS => 'SQLUINTEGER bitmask' # 109
, SQL_TIMEDATE_DIFF_INTERVALS => 'SQLUINTEGER bitmask' # 110
, SQL_TIMEDATE_FUNCTIONS => 'SQLUINTEGER bitmask' # 52
, SQL_TRANSACTION_CAPABLE => 'SQLUSMALLINT' # 46 =>
, SQL_TRANSACTION_ISOLATION_OPTION => 'SQLUINTEGER bitmask' # 72 =>
, SQL_TXN_CAPABLE => 'SQLUSMALLINT' # 46
, SQL_TXN_ISOLATION_OPTION => 'SQLUINTEGER bitmask' # 72
, SQL_UNION => 'SQLUINTEGER bitmask' # 96
, SQL_UNION_STATEMENT => 'SQLUINTEGER bitmask' # 96 =>
, SQL_USER_NAME => 'SQLCHAR' # 47
, SQL_XOPEN_CLI_YEAR => 'SQLCHAR' # 10000
);
=head2 %ReturnValues
See: sql.h, sqlext.h
Edited:
SQL_TXN_ISOLATION_OPTION
=cut
$ReturnValues{SQL_AGGREGATE_FUNCTIONS} =
{
SQL_AF_AVG => 0x00000001
, SQL_AF_COUNT => 0x00000002
, SQL_AF_MAX => 0x00000004
, SQL_AF_MIN => 0x00000008
, SQL_AF_SUM => 0x00000010
, SQL_AF_DISTINCT => 0x00000020
, SQL_AF_ALL => 0x00000040
};
$ReturnValues{SQL_ALTER_DOMAIN} =
{
SQL_AD_CONSTRAINT_NAME_DEFINITION => 0x00000001
, SQL_AD_ADD_DOMAIN_CONSTRAINT => 0x00000002
, SQL_AD_DROP_DOMAIN_CONSTRAINT => 0x00000004
, SQL_AD_ADD_DOMAIN_DEFAULT => 0x00000008
, SQL_AD_DROP_DOMAIN_DEFAULT => 0x00000010
, SQL_AD_ADD_CONSTRAINT_INITIALLY_DEFERRED => 0x00000020
, SQL_AD_ADD_CONSTRAINT_INITIALLY_IMMEDIATE => 0x00000040
, SQL_AD_ADD_CONSTRAINT_DEFERRABLE => 0x00000080
, SQL_AD_ADD_CONSTRAINT_NON_DEFERRABLE => 0x00000100
};
$ReturnValues{SQL_ALTER_TABLE} =
{
SQL_AT_ADD_COLUMN => 0x00000001
, SQL_AT_DROP_COLUMN => 0x00000002
, SQL_AT_ADD_CONSTRAINT => 0x00000008
, SQL_AT_ADD_COLUMN_SINGLE => 0x00000020
, SQL_AT_ADD_COLUMN_DEFAULT => 0x00000040
, SQL_AT_ADD_COLUMN_COLLATION => 0x00000080
, SQL_AT_SET_COLUMN_DEFAULT => 0x00000100
, SQL_AT_DROP_COLUMN_DEFAULT => 0x00000200
, SQL_AT_DROP_COLUMN_CASCADE => 0x00000400
, SQL_AT_DROP_COLUMN_RESTRICT => 0x00000800
, SQL_AT_ADD_TABLE_CONSTRAINT => 0x00001000
, SQL_AT_DROP_TABLE_CONSTRAINT_CASCADE => 0x00002000
, SQL_AT_DROP_TABLE_CONSTRAINT_RESTRICT => 0x00004000
, SQL_AT_CONSTRAINT_NAME_DEFINITION => 0x00008000
, SQL_AT_CONSTRAINT_INITIALLY_DEFERRED => 0x00010000
, SQL_AT_CONSTRAINT_INITIALLY_IMMEDIATE => 0x00020000
, SQL_AT_CONSTRAINT_DEFERRABLE => 0x00040000
, SQL_AT_CONSTRAINT_NON_DEFERRABLE => 0x00080000
};
$ReturnValues{SQL_ASYNC_MODE} =
{
SQL_AM_NONE => 0
, SQL_AM_CONNECTION => 1
, SQL_AM_STATEMENT => 2
};
$ReturnValues{SQL_ATTR_MAX_ROWS} =
{
SQL_CA2_MAX_ROWS_SELECT => 0x00000080
, SQL_CA2_MAX_ROWS_INSERT => 0x00000100
, SQL_CA2_MAX_ROWS_DELETE => 0x00000200
, SQL_CA2_MAX_ROWS_UPDATE => 0x00000400
, SQL_CA2_MAX_ROWS_CATALOG => 0x00000800
# SQL_CA2_MAX_ROWS_AFFECTS_ALL =>
};
$ReturnValues{SQL_ATTR_SCROLL_CONCURRENCY} =
{
SQL_CA2_READ_ONLY_CONCURRENCY => 0x00000001
, SQL_CA2_LOCK_CONCURRENCY => 0x00000002
, SQL_CA2_OPT_ROWVER_CONCURRENCY => 0x00000004
, SQL_CA2_OPT_VALUES_CONCURRENCY => 0x00000008
, SQL_CA2_SENSITIVITY_ADDITIONS => 0x00000010
, SQL_CA2_SENSITIVITY_DELETIONS => 0x00000020
, SQL_CA2_SENSITIVITY_UPDATES => 0x00000040
};
$ReturnValues{SQL_BATCH_ROW_COUNT} =
{
SQL_BRC_PROCEDURES => 0x0000001
, SQL_BRC_EXPLICIT => 0x0000002
, SQL_BRC_ROLLED_UP => 0x0000004
};
$ReturnValues{SQL_BATCH_SUPPORT} =
{
SQL_BS_SELECT_EXPLICIT => 0x00000001
, SQL_BS_ROW_COUNT_EXPLICIT => 0x00000002
, SQL_BS_SELECT_PROC => 0x00000004
, SQL_BS_ROW_COUNT_PROC => 0x00000008
};
$ReturnValues{SQL_BOOKMARK_PERSISTENCE} =
{
SQL_BP_CLOSE => 0x00000001
, SQL_BP_DELETE => 0x00000002
, SQL_BP_DROP => 0x00000004
, SQL_BP_TRANSACTION => 0x00000008
, SQL_BP_UPDATE => 0x00000010
, SQL_BP_OTHER_HSTMT => 0x00000020
, SQL_BP_SCROLL => 0x00000040
};
$ReturnValues{SQL_CATALOG_LOCATION} =
{
SQL_CL_START => 0x0001 # SQL_QL_START
, SQL_CL_END => 0x0002 # SQL_QL_END
};
$ReturnValues{SQL_CATALOG_USAGE} =
{
SQL_CU_DML_STATEMENTS => 0x00000001 # SQL_QU_DML_STATEMENTS
, SQL_CU_PROCEDURE_INVOCATION => 0x00000002 # SQL_QU_PROCEDURE_INVOCATION
, SQL_CU_TABLE_DEFINITION => 0x00000004 # SQL_QU_TABLE_DEFINITION
, SQL_CU_INDEX_DEFINITION => 0x00000008 # SQL_QU_INDEX_DEFINITION
, SQL_CU_PRIVILEGE_DEFINITION => 0x00000010 # SQL_QU_PRIVILEGE_DEFINITION
};
$ReturnValues{SQL_CONCAT_NULL_BEHAVIOR} =
{
SQL_CB_NULL => 0x0000
, SQL_CB_NON_NULL => 0x0001
};
$ReturnValues{SQL_CONVERT_} =
{
SQL_CVT_CHAR => 0x00000001
, SQL_CVT_NUMERIC => 0x00000002
, SQL_CVT_DECIMAL => 0x00000004
, SQL_CVT_INTEGER => 0x00000008
, SQL_CVT_SMALLINT => 0x00000010
, SQL_CVT_FLOAT => 0x00000020
, SQL_CVT_REAL => 0x00000040
, SQL_CVT_DOUBLE => 0x00000080
, SQL_CVT_VARCHAR => 0x00000100
, SQL_CVT_LONGVARCHAR => 0x00000200
, SQL_CVT_BINARY => 0x00000400
, SQL_CVT_VARBINARY => 0x00000800
, SQL_CVT_BIT => 0x00001000
, SQL_CVT_TINYINT => 0x00002000
, SQL_CVT_BIGINT => 0x00004000
, SQL_CVT_DATE => 0x00008000
, SQL_CVT_TIME => 0x00010000
, SQL_CVT_TIMESTAMP => 0x00020000
, SQL_CVT_LONGVARBINARY => 0x00040000
, SQL_CVT_INTERVAL_YEAR_MONTH => 0x00080000
, SQL_CVT_INTERVAL_DAY_TIME => 0x00100000
, SQL_CVT_WCHAR => 0x00200000
, SQL_CVT_WLONGVARCHAR => 0x00400000
, SQL_CVT_WVARCHAR => 0x00800000
, SQL_CVT_GUID => 0x01000000
};
$ReturnValues{SQL_CONVERT_BIGINT } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_BINARY } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_BIT } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_CHAR } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_DATE } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_DECIMAL } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_DOUBLE } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_FLOAT } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_GUID } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_INTEGER } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_INTERVAL_DAY_TIME } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_INTERVAL_YEAR_MONTH} = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_LONGVARBINARY } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_LONGVARCHAR } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_NUMERIC } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_REAL } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_SMALLINT } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_TIME } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_TIMESTAMP } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_TINYINT } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_VARBINARY } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_VARCHAR } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_WCHAR } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_WLONGVARCHAR } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_WVARCHAR } = $ReturnValues{SQL_CONVERT_};
$ReturnValues{SQL_CONVERT_FUNCTIONS} =
{
SQL_FN_CVT_CONVERT => 0x00000001
, SQL_FN_CVT_CAST => 0x00000002
};
$ReturnValues{SQL_CORRELATION_NAME} =
{
SQL_CN_NONE => 0x0000
, SQL_CN_DIFFERENT => 0x0001
, SQL_CN_ANY => 0x0002
};
$ReturnValues{SQL_CREATE_ASSERTION} =
{
SQL_CA_CREATE_ASSERTION => 0x00000001
, SQL_CA_CONSTRAINT_INITIALLY_DEFERRED => 0x00000010
, SQL_CA_CONSTRAINT_INITIALLY_IMMEDIATE => 0x00000020
, SQL_CA_CONSTRAINT_DEFERRABLE => 0x00000040
, SQL_CA_CONSTRAINT_NON_DEFERRABLE => 0x00000080
};
$ReturnValues{SQL_CREATE_CHARACTER_SET} =
{
SQL_CCS_CREATE_CHARACTER_SET => 0x00000001
, SQL_CCS_COLLATE_CLAUSE => 0x00000002
, SQL_CCS_LIMITED_COLLATION => 0x00000004
};
$ReturnValues{SQL_CREATE_COLLATION} =
{
SQL_CCOL_CREATE_COLLATION => 0x00000001
};
$ReturnValues{SQL_CREATE_DOMAIN} =
{
SQL_CDO_CREATE_DOMAIN => 0x00000001
, SQL_CDO_DEFAULT => 0x00000002
, SQL_CDO_CONSTRAINT => 0x00000004
, SQL_CDO_COLLATION => 0x00000008
, SQL_CDO_CONSTRAINT_NAME_DEFINITION => 0x00000010
, SQL_CDO_CONSTRAINT_INITIALLY_DEFERRED => 0x00000020
, SQL_CDO_CONSTRAINT_INITIALLY_IMMEDIATE => 0x00000040
, SQL_CDO_CONSTRAINT_DEFERRABLE => 0x00000080
, SQL_CDO_CONSTRAINT_NON_DEFERRABLE => 0x00000100
};
$ReturnValues{SQL_CREATE_SCHEMA} =
{
SQL_CS_CREATE_SCHEMA => 0x00000001
, SQL_CS_AUTHORIZATION => 0x00000002
, SQL_CS_DEFAULT_CHARACTER_SET => 0x00000004
};
$ReturnValues{SQL_CREATE_TABLE} =
{
SQL_CT_CREATE_TABLE => 0x00000001
, SQL_CT_COMMIT_PRESERVE => 0x00000002
, SQL_CT_COMMIT_DELETE => 0x00000004
, SQL_CT_GLOBAL_TEMPORARY => 0x00000008
, SQL_CT_LOCAL_TEMPORARY => 0x00000010
, SQL_CT_CONSTRAINT_INITIALLY_DEFERRED => 0x00000020
, SQL_CT_CONSTRAINT_INITIALLY_IMMEDIATE => 0x00000040
, SQL_CT_CONSTRAINT_DEFERRABLE => 0x00000080
, SQL_CT_CONSTRAINT_NON_DEFERRABLE => 0x00000100
, SQL_CT_COLUMN_CONSTRAINT => 0x00000200
, SQL_CT_COLUMN_DEFAULT => 0x00000400
, SQL_CT_COLUMN_COLLATION => 0x00000800
, SQL_CT_TABLE_CONSTRAINT => 0x00001000
, SQL_CT_CONSTRAINT_NAME_DEFINITION => 0x00002000
};
$ReturnValues{SQL_CREATE_TRANSLATION} =
{
SQL_CTR_CREATE_TRANSLATION => 0x00000001
};
$ReturnValues{SQL_CREATE_VIEW} =
{
SQL_CV_CREATE_VIEW => 0x00000001
, SQL_CV_CHECK_OPTION => 0x00000002
, SQL_CV_CASCADED => 0x00000004
, SQL_CV_LOCAL => 0x00000008
};
$ReturnValues{SQL_CURSOR_COMMIT_BEHAVIOR} =
{
SQL_CB_DELETE => 0
, SQL_CB_CLOSE => 1
, SQL_CB_PRESERVE => 2
};
$ReturnValues{SQL_CURSOR_ROLLBACK_BEHAVIOR} = $ReturnValues{SQL_CURSOR_COMMIT_BEHAVIOR};
$ReturnValues{SQL_CURSOR_SENSITIVITY} =
{
SQL_UNSPECIFIED => 0
, SQL_INSENSITIVE => 1
, SQL_SENSITIVE => 2
};
$ReturnValues{SQL_DATETIME_LITERALS} =
{
SQL_DL_SQL92_DATE => 0x00000001
, SQL_DL_SQL92_TIME => 0x00000002
, SQL_DL_SQL92_TIMESTAMP => 0x00000004
, SQL_DL_SQL92_INTERVAL_YEAR => 0x00000008
, SQL_DL_SQL92_INTERVAL_MONTH => 0x00000010
, SQL_DL_SQL92_INTERVAL_DAY => 0x00000020
, SQL_DL_SQL92_INTERVAL_HOUR => 0x00000040
, SQL_DL_SQL92_INTERVAL_MINUTE => 0x00000080
, SQL_DL_SQL92_INTERVAL_SECOND => 0x00000100
, SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH => 0x00000200
, SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR => 0x00000400
, SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE => 0x00000800
, SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND => 0x00001000
, SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE => 0x00002000
, SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND => 0x00004000
, SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND => 0x00008000
};
$ReturnValues{SQL_DDL_INDEX} =
{
SQL_DI_CREATE_INDEX => 0x00000001
, SQL_DI_DROP_INDEX => 0x00000002
};
$ReturnValues{SQL_DIAG_CURSOR_ROW_COUNT} =
{
SQL_CA2_CRC_EXACT => 0x00001000
, SQL_CA2_CRC_APPROXIMATE => 0x00002000
, SQL_CA2_SIMULATE_NON_UNIQUE => 0x00004000
, SQL_CA2_SIMULATE_TRY_UNIQUE => 0x00008000
, SQL_CA2_SIMULATE_UNIQUE => 0x00010000
};
$ReturnValues{SQL_DROP_ASSERTION} =
{
SQL_DA_DROP_ASSERTION => 0x00000001
};
$ReturnValues{SQL_DROP_CHARACTER_SET} =
{
SQL_DCS_DROP_CHARACTER_SET => 0x00000001
};
$ReturnValues{SQL_DROP_COLLATION} =
{
SQL_DC_DROP_COLLATION => 0x00000001
};
$ReturnValues{SQL_DROP_DOMAIN} =
{
SQL_DD_DROP_DOMAIN => 0x00000001
, SQL_DD_RESTRICT => 0x00000002
, SQL_DD_CASCADE => 0x00000004
};
$ReturnValues{SQL_DROP_SCHEMA} =
{
SQL_DS_DROP_SCHEMA => 0x00000001
, SQL_DS_RESTRICT => 0x00000002
, SQL_DS_CASCADE => 0x00000004
};
$ReturnValues{SQL_DROP_TABLE} =
{
SQL_DT_DROP_TABLE => 0x00000001
, SQL_DT_RESTRICT => 0x00000002
, SQL_DT_CASCADE => 0x00000004
};
$ReturnValues{SQL_DROP_TRANSLATION} =
{
SQL_DTR_DROP_TRANSLATION => 0x00000001
};
$ReturnValues{SQL_DROP_VIEW} =
{
SQL_DV_DROP_VIEW => 0x00000001
, SQL_DV_RESTRICT => 0x00000002
, SQL_DV_CASCADE => 0x00000004
};
$ReturnValues{SQL_CURSOR_ATTRIBUTES1} =
{
SQL_CA1_NEXT => 0x00000001
, SQL_CA1_ABSOLUTE => 0x00000002
, SQL_CA1_RELATIVE => 0x00000004
, SQL_CA1_BOOKMARK => 0x00000008
, SQL_CA1_LOCK_NO_CHANGE => 0x00000040
, SQL_CA1_LOCK_EXCLUSIVE => 0x00000080
, SQL_CA1_LOCK_UNLOCK => 0x00000100
, SQL_CA1_POS_POSITION => 0x00000200
, SQL_CA1_POS_UPDATE => 0x00000400
, SQL_CA1_POS_DELETE => 0x00000800
, SQL_CA1_POS_REFRESH => 0x00001000
, SQL_CA1_POSITIONED_UPDATE => 0x00002000
, SQL_CA1_POSITIONED_DELETE => 0x00004000
, SQL_CA1_SELECT_FOR_UPDATE => 0x00008000
, SQL_CA1_BULK_ADD => 0x00010000
, SQL_CA1_BULK_UPDATE_BY_BOOKMARK => 0x00020000
, SQL_CA1_BULK_DELETE_BY_BOOKMARK => 0x00040000
, SQL_CA1_BULK_FETCH_BY_BOOKMARK => 0x00080000
};
$ReturnValues{ SQL_DYNAMIC_CURSOR_ATTRIBUTES1} = $ReturnValues{SQL_CURSOR_ATTRIBUTES1};
$ReturnValues{SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1} = $ReturnValues{SQL_CURSOR_ATTRIBUTES1};
$ReturnValues{ SQL_KEYSET_CURSOR_ATTRIBUTES1} = $ReturnValues{SQL_CURSOR_ATTRIBUTES1};
$ReturnValues{ SQL_STATIC_CURSOR_ATTRIBUTES1} = $ReturnValues{SQL_CURSOR_ATTRIBUTES1};
$ReturnValues{SQL_CURSOR_ATTRIBUTES2} =
{
SQL_CA2_READ_ONLY_CONCURRENCY => 0x00000001
, SQL_CA2_LOCK_CONCURRENCY => 0x00000002
, SQL_CA2_OPT_ROWVER_CONCURRENCY => 0x00000004
, SQL_CA2_OPT_VALUES_CONCURRENCY => 0x00000008
, SQL_CA2_SENSITIVITY_ADDITIONS => 0x00000010
, SQL_CA2_SENSITIVITY_DELETIONS => 0x00000020
, SQL_CA2_SENSITIVITY_UPDATES => 0x00000040
, SQL_CA2_MAX_ROWS_SELECT => 0x00000080
, SQL_CA2_MAX_ROWS_INSERT => 0x00000100
, SQL_CA2_MAX_ROWS_DELETE => 0x00000200
, SQL_CA2_MAX_ROWS_UPDATE => 0x00000400
, SQL_CA2_MAX_ROWS_CATALOG => 0x00000800
, SQL_CA2_CRC_EXACT => 0x00001000
, SQL_CA2_CRC_APPROXIMATE => 0x00002000
, SQL_CA2_SIMULATE_NON_UNIQUE => 0x00004000
, SQL_CA2_SIMULATE_TRY_UNIQUE => 0x00008000
, SQL_CA2_SIMULATE_UNIQUE => 0x00010000
};
$ReturnValues{ SQL_DYNAMIC_CURSOR_ATTRIBUTES2} = $ReturnValues{SQL_CURSOR_ATTRIBUTES2};
$ReturnValues{SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2} = $ReturnValues{SQL_CURSOR_ATTRIBUTES2};
$ReturnValues{ SQL_KEYSET_CURSOR_ATTRIBUTES2} = $ReturnValues{SQL_CURSOR_ATTRIBUTES2};
$ReturnValues{ SQL_STATIC_CURSOR_ATTRIBUTES2} = $ReturnValues{SQL_CURSOR_ATTRIBUTES2};
$ReturnValues{SQL_FETCH_DIRECTION} =
{
SQL_FD_FETCH_NEXT => 0x00000001
, SQL_FD_FETCH_FIRST => 0x00000002
, SQL_FD_FETCH_LAST => 0x00000004
, SQL_FD_FETCH_PRIOR => 0x00000008
, SQL_FD_FETCH_ABSOLUTE => 0x00000010
, SQL_FD_FETCH_RELATIVE => 0x00000020
, SQL_FD_FETCH_RESUME => 0x00000040
, SQL_FD_FETCH_BOOKMARK => 0x00000080
};
$ReturnValues{SQL_FILE_USAGE} =
{
SQL_FILE_NOT_SUPPORTED => 0x0000
, SQL_FILE_TABLE => 0x0001
, SQL_FILE_QUALIFIER => 0x0002
, SQL_FILE_CATALOG => 0x0002 # SQL_FILE_QUALIFIER
};
$ReturnValues{SQL_GETDATA_EXTENSIONS} =
{
SQL_GD_ANY_COLUMN => 0x00000001
, SQL_GD_ANY_ORDER => 0x00000002
, SQL_GD_BLOCK => 0x00000004
, SQL_GD_BOUND => 0x00000008
};
$ReturnValues{SQL_GROUP_BY} =
{
SQL_GB_NOT_SUPPORTED => 0x0000
, SQL_GB_GROUP_BY_EQUALS_SELECT => 0x0001
, SQL_GB_GROUP_BY_CONTAINS_SELECT => 0x0002
, SQL_GB_NO_RELATION => 0x0003
, SQL_GB_COLLATE => 0x0004
};
$ReturnValues{SQL_IDENTIFIER_CASE} =
{
SQL_IC_UPPER => 1
, SQL_IC_LOWER => 2
, SQL_IC_SENSITIVE => 3
, SQL_IC_MIXED => 4
};
$ReturnValues{SQL_INDEX_KEYWORDS} =
{
SQL_IK_NONE => 0x00000000
, SQL_IK_ASC => 0x00000001
, SQL_IK_DESC => 0x00000002
# SQL_IK_ALL =>
};
$ReturnValues{SQL_INFO_SCHEMA_VIEWS} =
{
SQL_ISV_ASSERTIONS => 0x00000001
, SQL_ISV_CHARACTER_SETS => 0x00000002
, SQL_ISV_CHECK_CONSTRAINTS => 0x00000004
, SQL_ISV_COLLATIONS => 0x00000008
, SQL_ISV_COLUMN_DOMAIN_USAGE => 0x00000010
, SQL_ISV_COLUMN_PRIVILEGES => 0x00000020
, SQL_ISV_COLUMNS => 0x00000040
, SQL_ISV_CONSTRAINT_COLUMN_USAGE => 0x00000080
, SQL_ISV_CONSTRAINT_TABLE_USAGE => 0x00000100
, SQL_ISV_DOMAIN_CONSTRAINTS => 0x00000200
, SQL_ISV_DOMAINS => 0x00000400
, SQL_ISV_KEY_COLUMN_USAGE => 0x00000800
, SQL_ISV_REFERENTIAL_CONSTRAINTS => 0x00001000
, SQL_ISV_SCHEMATA => 0x00002000
, SQL_ISV_SQL_LANGUAGES => 0x00004000
, SQL_ISV_TABLE_CONSTRAINTS => 0x00008000
, SQL_ISV_TABLE_PRIVILEGES => 0x00010000
, SQL_ISV_TABLES => 0x00020000
, SQL_ISV_TRANSLATIONS => 0x00040000
, SQL_ISV_USAGE_PRIVILEGES => 0x00080000
, SQL_ISV_VIEW_COLUMN_USAGE => 0x00100000
, SQL_ISV_VIEW_TABLE_USAGE => 0x00200000
, SQL_ISV_VIEWS => 0x00400000
};
$ReturnValues{SQL_INSERT_STATEMENT} =
{
SQL_IS_INSERT_LITERALS => 0x00000001
, SQL_IS_INSERT_SEARCHED => 0x00000002
, SQL_IS_SELECT_INTO => 0x00000004
};
$ReturnValues{SQL_LOCK_TYPES} =
{
SQL_LCK_NO_CHANGE => 0x00000001
, SQL_LCK_EXCLUSIVE => 0x00000002
, SQL_LCK_UNLOCK => 0x00000004
};
$ReturnValues{SQL_NON_NULLABLE_COLUMNS} =
{
SQL_NNC_NULL => 0x0000
, SQL_NNC_NON_NULL => 0x0001
};
$ReturnValues{SQL_NULL_COLLATION} =
{
SQL_NC_HIGH => 0
, SQL_NC_LOW => 1
, SQL_NC_START => 0x0002
, SQL_NC_END => 0x0004
};
$ReturnValues{SQL_NUMERIC_FUNCTIONS} =
{
SQL_FN_NUM_ABS => 0x00000001
, SQL_FN_NUM_ACOS => 0x00000002
, SQL_FN_NUM_ASIN => 0x00000004
, SQL_FN_NUM_ATAN => 0x00000008
, SQL_FN_NUM_ATAN2 => 0x00000010
, SQL_FN_NUM_CEILING => 0x00000020
, SQL_FN_NUM_COS => 0x00000040
, SQL_FN_NUM_COT => 0x00000080
, SQL_FN_NUM_EXP => 0x00000100
, SQL_FN_NUM_FLOOR => 0x00000200
, SQL_FN_NUM_LOG => 0x00000400
, SQL_FN_NUM_MOD => 0x00000800
, SQL_FN_NUM_SIGN => 0x00001000
, SQL_FN_NUM_SIN => 0x00002000
, SQL_FN_NUM_SQRT => 0x00004000
, SQL_FN_NUM_TAN => 0x00008000
, SQL_FN_NUM_PI => 0x00010000
, SQL_FN_NUM_RAND => 0x00020000
, SQL_FN_NUM_DEGREES => 0x00040000
, SQL_FN_NUM_LOG10 => 0x00080000
, SQL_FN_NUM_POWER => 0x00100000
, SQL_FN_NUM_RADIANS => 0x00200000
, SQL_FN_NUM_ROUND => 0x00400000
, SQL_FN_NUM_TRUNCATE => 0x00800000
};
$ReturnValues{SQL_ODBC_API_CONFORMANCE} =
{
SQL_OAC_NONE => 0x0000
, SQL_OAC_LEVEL1 => 0x0001
, SQL_OAC_LEVEL2 => 0x0002
};
$ReturnValues{SQL_ODBC_INTERFACE_CONFORMANCE} =
{
SQL_OIC_CORE => 1
, SQL_OIC_LEVEL1 => 2
, SQL_OIC_LEVEL2 => 3
};
$ReturnValues{SQL_ODBC_SAG_CLI_CONFORMANCE} =
{
SQL_OSCC_NOT_COMPLIANT => 0x0000
, SQL_OSCC_COMPLIANT => 0x0001
};
$ReturnValues{SQL_ODBC_SQL_CONFORMANCE} =
{
SQL_OSC_MINIMUM => 0x0000
, SQL_OSC_CORE => 0x0001
, SQL_OSC_EXTENDED => 0x0002
};
$ReturnValues{SQL_OJ_CAPABILITIES} =
{
SQL_OJ_LEFT => 0x00000001
, SQL_OJ_RIGHT => 0x00000002
, SQL_OJ_FULL => 0x00000004
, SQL_OJ_NESTED => 0x00000008
, SQL_OJ_NOT_ORDERED => 0x00000010
, SQL_OJ_INNER => 0x00000020
, SQL_OJ_ALL_COMPARISON_OPS => 0x00000040
};
$ReturnValues{SQL_OWNER_USAGE} =
{
SQL_OU_DML_STATEMENTS => 0x00000001
, SQL_OU_PROCEDURE_INVOCATION => 0x00000002
, SQL_OU_TABLE_DEFINITION => 0x00000004
, SQL_OU_INDEX_DEFINITION => 0x00000008
, SQL_OU_PRIVILEGE_DEFINITION => 0x00000010
};
$ReturnValues{SQL_PARAM_ARRAY_ROW_COUNTS} =
{
SQL_PARC_BATCH => 1
, SQL_PARC_NO_BATCH => 2
};
$ReturnValues{SQL_PARAM_ARRAY_SELECTS} =
{
SQL_PAS_BATCH => 1
, SQL_PAS_NO_BATCH => 2
, SQL_PAS_NO_SELECT => 3
};
$ReturnValues{SQL_POSITIONED_STATEMENTS} =
{
SQL_PS_POSITIONED_DELETE => 0x00000001
, SQL_PS_POSITIONED_UPDATE => 0x00000002
, SQL_PS_SELECT_FOR_UPDATE => 0x00000004
};
$ReturnValues{SQL_POS_OPERATIONS} =
{
SQL_POS_POSITION => 0x00000001
, SQL_POS_REFRESH => 0x00000002
, SQL_POS_UPDATE => 0x00000004
, SQL_POS_DELETE => 0x00000008
, SQL_POS_ADD => 0x00000010
};
$ReturnValues{SQL_QUALIFIER_LOCATION} =
{
SQL_QL_START => 0x0001
, SQL_QL_END => 0x0002
};
$ReturnValues{SQL_QUALIFIER_USAGE} =
{
SQL_QU_DML_STATEMENTS => 0x00000001
, SQL_QU_PROCEDURE_INVOCATION => 0x00000002
, SQL_QU_TABLE_DEFINITION => 0x00000004
, SQL_QU_INDEX_DEFINITION => 0x00000008
, SQL_QU_PRIVILEGE_DEFINITION => 0x00000010
};
$ReturnValues{SQL_QUOTED_IDENTIFIER_CASE} = $ReturnValues{SQL_IDENTIFIER_CASE};
$ReturnValues{SQL_SCHEMA_USAGE} =
{
SQL_SU_DML_STATEMENTS => 0x00000001 # SQL_OU_DML_STATEMENTS
, SQL_SU_PROCEDURE_INVOCATION => 0x00000002 # SQL_OU_PROCEDURE_INVOCATION
, SQL_SU_TABLE_DEFINITION => 0x00000004 # SQL_OU_TABLE_DEFINITION
, SQL_SU_INDEX_DEFINITION => 0x00000008 # SQL_OU_INDEX_DEFINITION
, SQL_SU_PRIVILEGE_DEFINITION => 0x00000010 # SQL_OU_PRIVILEGE_DEFINITION
};
$ReturnValues{SQL_SCROLL_CONCURRENCY} =
{
SQL_SCCO_READ_ONLY => 0x00000001
, SQL_SCCO_LOCK => 0x00000002
, SQL_SCCO_OPT_ROWVER => 0x00000004
, SQL_SCCO_OPT_VALUES => 0x00000008
};
$ReturnValues{SQL_SCROLL_OPTIONS} =
{
SQL_SO_FORWARD_ONLY => 0x00000001
, SQL_SO_KEYSET_DRIVEN => 0x00000002
, SQL_SO_DYNAMIC => 0x00000004
, SQL_SO_MIXED => 0x00000008
, SQL_SO_STATIC => 0x00000010
};
$ReturnValues{SQL_SQL92_DATETIME_FUNCTIONS} =
{
SQL_SDF_CURRENT_DATE => 0x00000001
, SQL_SDF_CURRENT_TIME => 0x00000002
, SQL_SDF_CURRENT_TIMESTAMP => 0x00000004
};
$ReturnValues{SQL_SQL92_FOREIGN_KEY_DELETE_RULE} =
{
SQL_SFKD_CASCADE => 0x00000001
, SQL_SFKD_NO_ACTION => 0x00000002
, SQL_SFKD_SET_DEFAULT => 0x00000004
, SQL_SFKD_SET_NULL => 0x00000008
};
$ReturnValues{SQL_SQL92_FOREIGN_KEY_UPDATE_RULE} =
{
SQL_SFKU_CASCADE => 0x00000001
, SQL_SFKU_NO_ACTION => 0x00000002
, SQL_SFKU_SET_DEFAULT => 0x00000004
, SQL_SFKU_SET_NULL => 0x00000008
};
$ReturnValues{SQL_SQL92_GRANT} =
{
SQL_SG_USAGE_ON_DOMAIN => 0x00000001
, SQL_SG_USAGE_ON_CHARACTER_SET => 0x00000002
, SQL_SG_USAGE_ON_COLLATION => 0x00000004
, SQL_SG_USAGE_ON_TRANSLATION => 0x00000008
, SQL_SG_WITH_GRANT_OPTION => 0x00000010
, SQL_SG_DELETE_TABLE => 0x00000020
, SQL_SG_INSERT_TABLE => 0x00000040
, SQL_SG_INSERT_COLUMN => 0x00000080
, SQL_SG_REFERENCES_TABLE => 0x00000100
, SQL_SG_REFERENCES_COLUMN => 0x00000200
, SQL_SG_SELECT_TABLE => 0x00000400
, SQL_SG_UPDATE_TABLE => 0x00000800
, SQL_SG_UPDATE_COLUMN => 0x00001000
};
$ReturnValues{SQL_SQL92_NUMERIC_VALUE_FUNCTIONS} =
{
SQL_SNVF_BIT_LENGTH => 0x00000001
, SQL_SNVF_CHAR_LENGTH => 0x00000002
, SQL_SNVF_CHARACTER_LENGTH => 0x00000004
, SQL_SNVF_EXTRACT => 0x00000008
, SQL_SNVF_OCTET_LENGTH => 0x00000010
, SQL_SNVF_POSITION => 0x00000020
};
$ReturnValues{SQL_SQL92_PREDICATES} =
{
SQL_SP_EXISTS => 0x00000001
, SQL_SP_ISNOTNULL => 0x00000002
, SQL_SP_ISNULL => 0x00000004
, SQL_SP_MATCH_FULL => 0x00000008
, SQL_SP_MATCH_PARTIAL => 0x00000010
, SQL_SP_MATCH_UNIQUE_FULL => 0x00000020
, SQL_SP_MATCH_UNIQUE_PARTIAL => 0x00000040
, SQL_SP_OVERLAPS => 0x00000080
, SQL_SP_UNIQUE => 0x00000100
, SQL_SP_LIKE => 0x00000200
, SQL_SP_IN => 0x00000400
, SQL_SP_BETWEEN => 0x00000800
, SQL_SP_COMPARISON => 0x00001000
, SQL_SP_QUANTIFIED_COMPARISON => 0x00002000
};
$ReturnValues{SQL_SQL92_RELATIONAL_JOIN_OPERATORS} =
{
SQL_SRJO_CORRESPONDING_CLAUSE => 0x00000001
, SQL_SRJO_CROSS_JOIN => 0x00000002
, SQL_SRJO_EXCEPT_JOIN => 0x00000004
, SQL_SRJO_FULL_OUTER_JOIN => 0x00000008
, SQL_SRJO_INNER_JOIN => 0x00000010
, SQL_SRJO_INTERSECT_JOIN => 0x00000020
, SQL_SRJO_LEFT_OUTER_JOIN => 0x00000040
, SQL_SRJO_NATURAL_JOIN => 0x00000080
, SQL_SRJO_RIGHT_OUTER_JOIN => 0x00000100
, SQL_SRJO_UNION_JOIN => 0x00000200
};
$ReturnValues{SQL_SQL92_REVOKE} =
{
SQL_SR_USAGE_ON_DOMAIN => 0x00000001
, SQL_SR_USAGE_ON_CHARACTER_SET => 0x00000002
, SQL_SR_USAGE_ON_COLLATION => 0x00000004
, SQL_SR_USAGE_ON_TRANSLATION => 0x00000008
, SQL_SR_GRANT_OPTION_FOR => 0x00000010
, SQL_SR_CASCADE => 0x00000020
, SQL_SR_RESTRICT => 0x00000040
, SQL_SR_DELETE_TABLE => 0x00000080
, SQL_SR_INSERT_TABLE => 0x00000100
, SQL_SR_INSERT_COLUMN => 0x00000200
, SQL_SR_REFERENCES_TABLE => 0x00000400
, SQL_SR_REFERENCES_COLUMN => 0x00000800
, SQL_SR_SELECT_TABLE => 0x00001000
, SQL_SR_UPDATE_TABLE => 0x00002000
, SQL_SR_UPDATE_COLUMN => 0x00004000
};
$ReturnValues{SQL_SQL92_ROW_VALUE_CONSTRUCTOR} =
{
SQL_SRVC_VALUE_EXPRESSION => 0x00000001
, SQL_SRVC_NULL => 0x00000002
, SQL_SRVC_DEFAULT => 0x00000004
, SQL_SRVC_ROW_SUBQUERY => 0x00000008
};
$ReturnValues{SQL_SQL92_STRING_FUNCTIONS} =
{
SQL_SSF_CONVERT => 0x00000001
, SQL_SSF_LOWER => 0x00000002
, SQL_SSF_UPPER => 0x00000004
, SQL_SSF_SUBSTRING => 0x00000008
, SQL_SSF_TRANSLATE => 0x00000010
, SQL_SSF_TRIM_BOTH => 0x00000020
, SQL_SSF_TRIM_LEADING => 0x00000040
, SQL_SSF_TRIM_TRAILING => 0x00000080
};
$ReturnValues{SQL_SQL92_VALUE_EXPRESSIONS} =
{
SQL_SVE_CASE => 0x00000001
, SQL_SVE_CAST => 0x00000002
, SQL_SVE_COALESCE => 0x00000004
, SQL_SVE_NULLIF => 0x00000008
};
$ReturnValues{SQL_SQL_CONFORMANCE} =
{
SQL_SC_SQL92_ENTRY => 0x00000001
, SQL_SC_FIPS127_2_TRANSITIONAL => 0x00000002
, SQL_SC_SQL92_INTERMEDIATE => 0x00000004
, SQL_SC_SQL92_FULL => 0x00000008
};
$ReturnValues{SQL_STANDARD_CLI_CONFORMANCE} =
{
SQL_SCC_XOPEN_CLI_VERSION1 => 0x00000001
, SQL_SCC_ISO92_CLI => 0x00000002
};
$ReturnValues{SQL_STATIC_SENSITIVITY} =
{
SQL_SS_ADDITIONS => 0x00000001
, SQL_SS_DELETIONS => 0x00000002
, SQL_SS_UPDATES => 0x00000004
};
$ReturnValues{SQL_STRING_FUNCTIONS} =
{
SQL_FN_STR_CONCAT => 0x00000001
, SQL_FN_STR_INSERT => 0x00000002
, SQL_FN_STR_LEFT => 0x00000004
, SQL_FN_STR_LTRIM => 0x00000008
, SQL_FN_STR_LENGTH => 0x00000010
, SQL_FN_STR_LOCATE => 0x00000020
, SQL_FN_STR_LCASE => 0x00000040
, SQL_FN_STR_REPEAT => 0x00000080
, SQL_FN_STR_REPLACE => 0x00000100
, SQL_FN_STR_RIGHT => 0x00000200
, SQL_FN_STR_RTRIM => 0x00000400
, SQL_FN_STR_SUBSTRING => 0x00000800
, SQL_FN_STR_UCASE => 0x00001000
, SQL_FN_STR_ASCII => 0x00002000
, SQL_FN_STR_CHAR => 0x00004000
, SQL_FN_STR_DIFFERENCE => 0x00008000
, SQL_FN_STR_LOCATE_2 => 0x00010000
, SQL_FN_STR_SOUNDEX => 0x00020000
, SQL_FN_STR_SPACE => 0x00040000
, SQL_FN_STR_BIT_LENGTH => 0x00080000
, SQL_FN_STR_CHAR_LENGTH => 0x00100000
, SQL_FN_STR_CHARACTER_LENGTH => 0x00200000
, SQL_FN_STR_OCTET_LENGTH => 0x00400000
, SQL_FN_STR_POSITION => 0x00800000
};
$ReturnValues{SQL_SUBQUERIES} =
{
SQL_SQ_COMPARISON => 0x00000001
, SQL_SQ_EXISTS => 0x00000002
, SQL_SQ_IN => 0x00000004
, SQL_SQ_QUANTIFIED => 0x00000008
, SQL_SQ_CORRELATED_SUBQUERIES => 0x00000010
};
$ReturnValues{SQL_SYSTEM_FUNCTIONS} =
{
SQL_FN_SYS_USERNAME => 0x00000001
, SQL_FN_SYS_DBNAME => 0x00000002
, SQL_FN_SYS_IFNULL => 0x00000004
};
$ReturnValues{SQL_TIMEDATE_ADD_INTERVALS} =
{
SQL_FN_TSI_FRAC_SECOND => 0x00000001
, SQL_FN_TSI_SECOND => 0x00000002
, SQL_FN_TSI_MINUTE => 0x00000004
, SQL_FN_TSI_HOUR => 0x00000008
, SQL_FN_TSI_DAY => 0x00000010
, SQL_FN_TSI_WEEK => 0x00000020
, SQL_FN_TSI_MONTH => 0x00000040
, SQL_FN_TSI_QUARTER => 0x00000080
, SQL_FN_TSI_YEAR => 0x00000100
};
$ReturnValues{SQL_TIMEDATE_FUNCTIONS} =
{
SQL_FN_TD_NOW => 0x00000001
, SQL_FN_TD_CURDATE => 0x00000002
, SQL_FN_TD_DAYOFMONTH => 0x00000004
, SQL_FN_TD_DAYOFWEEK => 0x00000008
, SQL_FN_TD_DAYOFYEAR => 0x00000010
, SQL_FN_TD_MONTH => 0x00000020
, SQL_FN_TD_QUARTER => 0x00000040
, SQL_FN_TD_WEEK => 0x00000080
, SQL_FN_TD_YEAR => 0x00000100
, SQL_FN_TD_CURTIME => 0x00000200
, SQL_FN_TD_HOUR => 0x00000400
, SQL_FN_TD_MINUTE => 0x00000800
, SQL_FN_TD_SECOND => 0x00001000
, SQL_FN_TD_TIMESTAMPADD => 0x00002000
, SQL_FN_TD_TIMESTAMPDIFF => 0x00004000
, SQL_FN_TD_DAYNAME => 0x00008000
, SQL_FN_TD_MONTHNAME => 0x00010000
, SQL_FN_TD_CURRENT_DATE => 0x00020000
, SQL_FN_TD_CURRENT_TIME => 0x00040000
, SQL_FN_TD_CURRENT_TIMESTAMP => 0x00080000
, SQL_FN_TD_EXTRACT => 0x00100000
};
$ReturnValues{SQL_TXN_CAPABLE} =
{
SQL_TC_NONE => 0
, SQL_TC_DML => 1
, SQL_TC_ALL => 2
, SQL_TC_DDL_COMMIT => 3
, SQL_TC_DDL_IGNORE => 4
};
$ReturnValues{SQL_TRANSACTION_ISOLATION_OPTION} =
{
SQL_TRANSACTION_READ_UNCOMMITTED => 0x00000001 # SQL_TXN_READ_UNCOMMITTED
, SQL_TRANSACTION_READ_COMMITTED => 0x00000002 # SQL_TXN_READ_COMMITTED
, SQL_TRANSACTION_REPEATABLE_READ => 0x00000004 # SQL_TXN_REPEATABLE_READ
, SQL_TRANSACTION_SERIALIZABLE => 0x00000008 # SQL_TXN_SERIALIZABLE
};
$ReturnValues{SQL_DEFAULT_TRANSACTION_ISOLATION} = $ReturnValues{SQL_TRANSACTION_ISOLATION_OPTION};
$ReturnValues{SQL_TXN_ISOLATION_OPTION} =
{
SQL_TXN_READ_UNCOMMITTED => 0x00000001
, SQL_TXN_READ_COMMITTED => 0x00000002
, SQL_TXN_REPEATABLE_READ => 0x00000004
, SQL_TXN_SERIALIZABLE => 0x00000008
};
$ReturnValues{SQL_DEFAULT_TXN_ISOLATION} = $ReturnValues{SQL_TXN_ISOLATION_OPTION};
$ReturnValues{SQL_TXN_VERSIONING} =
{
SQL_TXN_VERSIONING => 0x00000010
};
$ReturnValues{SQL_UNION} =
{
SQL_U_UNION => 0x00000001
, SQL_U_UNION_ALL => 0x00000002
};
$ReturnValues{SQL_UNION_STATEMENT} =
{
SQL_US_UNION => 0x00000001 # SQL_U_UNION
, SQL_US_UNION_ALL => 0x00000002 # SQL_U_UNION_ALL
};
1;
=head1 TODO
Corrections?
SQL_NULL_COLLATION: ODBC vs ANSI
Unique values for $ReturnValues{...}?, e.g. SQL_FILE_USAGE
=cut
PK ]^q Util/CacheMemory.pmnu [ package DBI::Util::CacheMemory;
# $Id: CacheMemory.pm 10314 2007-11-26 22:25:33Z Tim $
#
# Copyright (c) 2007, Tim Bunce, Ireland
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
use strict;
use warnings;
=head1 NAME
DBI::Util::CacheMemory - a very fast but very minimal subset of Cache::Memory
=head1 DESCRIPTION
Like Cache::Memory (part of the Cache distribution) but doesn't support any fancy features.
This module aims to be a very fast compatible strict sub-set for simple cases,
such as basic client-side caching for DBD::Gofer.
Like Cache::Memory, and other caches in the Cache and Cache::Cache
distributions, the data will remain in the cache until cleared, it expires,
or the process dies. The cache object simply going out of scope will I
destroy the data.
=head1 METHODS WITH CHANGES
=head2 new
All options except C are ignored.
=head2 set
Doesn't support expiry.
=head2 purge
Same as clear() - deletes everything in the namespace.
=head1 METHODS WITHOUT CHANGES
=over
=item clear
=item count
=item exists
=item remove
=back
=head1 UNSUPPORTED METHODS
If it's not listed above, it's not supported.
=cut
our $VERSION = "0.010315";
my %cache;
sub new {
my ($class, %options ) = @_;
my $namespace = $options{namespace} ||= 'Default';
#$options{_cache} = \%cache; # can be handy for debugging/dumping
my $self = bless \%options => $class;
$cache{ $namespace } ||= {}; # init - ensure it exists
return $self;
}
sub set {
my ($self, $key, $value) = @_;
$cache{ $self->{namespace} }->{$key} = $value;
}
sub get {
my ($self, $key) = @_;
return $cache{ $self->{namespace} }->{$key};
}
sub exists {
my ($self, $key) = @_;
return exists $cache{ $self->{namespace} }->{$key};
}
sub remove {
my ($self, $key) = @_;
return delete $cache{ $self->{namespace} }->{$key};
}
sub purge {
return shift->clear;
}
sub clear {
$cache{ shift->{namespace} } = {};
}
sub count {
return scalar keys %{ $cache{ shift->{namespace} } };
}
sub size {
my $c = $cache{ shift->{namespace} };
my $size = 0;
while ( my ($k,$v) = each %$c ) {
$size += length($k) + length($v);
}
return $size;
}
1;
PK ]!3т Util/_accessor.pmnu [ package DBI::Util::_accessor;
use strict;
use Carp;
our $VERSION = "0.009479";
# inspired by Class::Accessor::Fast
sub new {
my($proto, $fields) = @_;
my($class) = ref $proto || $proto;
$fields ||= {};
my @dubious = grep { !m/^_/ && !$proto->can($_) } keys %$fields;
carp "$class doesn't have accessors for fields: @dubious" if @dubious;
# make a (shallow) copy of $fields.
bless {%$fields}, $class;
}
sub mk_accessors {
my($self, @fields) = @_;
$self->mk_accessors_using('make_accessor', @fields);
}
sub mk_accessors_using {
my($self, $maker, @fields) = @_;
my $class = ref $self || $self;
# So we don't have to do lots of lookups inside the loop.
$maker = $self->can($maker) unless ref $maker;
no strict 'refs';
foreach my $field (@fields) {
my $accessor = $self->$maker($field);
*{$class."\:\:$field"} = $accessor
unless defined &{$class."\:\:$field"};
}
#my $hash_ref = \%{$class."\:\:_accessors_hash};
#$hash_ref->{$_}++ for @fields;
# XXX also copy down _accessors_hash of base class(es)
# so one in this class is complete
return;
}
sub make_accessor {
my($class, $field) = @_;
return sub {
my $self = shift;
return $self->{$field} unless @_;
croak "Too many arguments to $field" if @_ > 1;
return $self->{$field} = shift;
};
}
sub make_accessor_autoviv_hashref {
my($class, $field) = @_;
return sub {
my $self = shift;
return $self->{$field} ||= {} unless @_;
croak "Too many arguments to $field" if @_ > 1;
return $self->{$field} = shift;
};
}
1;
PK ]ma: : DBD/Metadata.pmnu [ package DBI::DBD::Metadata;
# $Id: Metadata.pm 14213 2010-06-30 19:29:18Z Martin $
#
# Copyright (c) 1997-2003 Jonathan Leffler, Jochen Wiedmann,
# Steffen Goeldner and Tim Bunce
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
use strict;
use Exporter ();
use Carp;
use DBI;
use DBI::Const::GetInfoType qw(%GetInfoType);
our @ISA = qw(Exporter);
our @EXPORT = qw(write_getinfo_pm write_typeinfo_pm);
our $VERSION = "2.014214";
=head1 NAME
DBI::DBD::Metadata - Generate the code and data for some DBI metadata methods
=head1 SYNOPSIS
The idea is to extract metadata information from a good quality
ODBC driver and use it to generate code and data to use in your own
DBI driver for the same database.
To generate code to support the get_info method:
perl -MDBI::DBD::Metadata -e "write_getinfo_pm('dbi:ODBC:dsn-name','user','pass','Driver')"
perl -MDBI::DBD::Metadata -e write_getinfo_pm dbi:ODBC:foo_db username password Driver
To generate code to support the type_info method:
perl -MDBI::DBD::Metadata -e "write_typeinfo_pm('dbi:ODBC:dsn-name','user','pass','Driver')"
perl -MDBI::DBD::Metadata -e write_typeinfo_pm dbi:ODBC:dsn-name user pass Driver
Where C is the connection to use to extract the
data, and C is the name of the driver you want the code
generated for (the driver name gets embedded into the output in
numerous places).
=head1 Generating a GetInfo package for a driver
The C in the DBI::DBD::Metadata module generates a
DBD::Driver::GetInfo package on standard output.
This method generates a DBD::Driver::GetInfo package from the data
source you specified in the parameter list or in the environment
variable DBI_DSN.
DBD::Driver::GetInfo should help a DBD author implement the DBI
get_info() method.
Because you are just creating this package, it is very unlikely that
DBD::Driver already provides a good implementation for get_info().
Thus you will probably connect via DBD::ODBC.
Once you are sure that it is producing reasonably sane data, you should
typically redirect the standard output to lib/DBD/Driver/GetInfo.pm, and
then hand edit the result.
Do not forget to update your Makefile.PL and MANIFEST to include this as
an extra PM file that should be installed.
If you connect via DBD::ODBC, you should use version 0.38 or greater;
Please take a critical look at the data returned!
ODBC drivers 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 is very likely that you will 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::Driver::db::get_info() may look like:
sub get_info {
my($dbh, $info_type) = @_;
require DBD::Driver::GetInfo;
my $v = $DBD::Driver::GetInfo::info{int($info_type)};
$v = $v->($dbh) if ref $v eq 'CODE';
return $v;
}
Please replace Driver (or "") with the name of your driver.
Note that this stub function is generated for you by write_getinfo_pm
function, but you must manually transfer the code to Driver.pm.
=cut
sub write_getinfo_pm
{
my ($dsn, $user, $pass, $driver) = @_ ? @_ : @ARGV;
my $dbh = DBI->connect($dsn, $user, $pass, {RaiseError=>1});
$driver = "" unless defined $driver;
print <(\$dbh) if ref \$v eq 'CODE';
return \$v;
}
# Transfer this to lib/DBD/${driver}/GetInfo.pm
# The \%info hash was automatically generated by
# DBI::DBD::Metadata::write_getinfo_pm v$DBI::DBD::Metadata::VERSION.
package DBD::${driver}::GetInfo;
use strict;
use DBD::${driver};
# Beware: not officially documented interfaces...
# use DBI::Const::GetInfoType qw(\%GetInfoType);
# use DBI::Const::GetInfoReturn qw(\%GetInfoReturnTypes \%GetInfoReturnValues);
my \$sql_driver = '${driver}';
my \$sql_ver_fmt = '%02d.%02d.%04d'; # ODBC version string: ##.##.#####
my \$sql_driver_ver = sprintf \$sql_ver_fmt, split (/\\./, \$DBD::${driver}::VERSION);
PERL
my $kw_map = 0;
{
# Informix CLI (ODBC) v3.81.0000 does not return a list of keywords.
local $\ = "\n";
local $, = "\n";
my ($kw) = $dbh->get_info($GetInfoType{SQL_KEYWORDS});
if ($kw)
{
print "\nmy \@Keywords = qw(\n";
print sort split /,/, $kw;
print ");\n\n";
print "sub sql_keywords {\n";
print q% return join ',', @Keywords;%;
print "\n}\n\n";
$kw_map = 1;
}
}
print <<'PERL';
sub sql_data_source_name {
my $dbh = shift;
return "dbi:$sql_driver:" . $dbh->{Name};
}
sub sql_user_name {
my $dbh = shift;
# CURRENT_USER is a non-standard attribute, probably undef
# Username is a standard DBI attribute
return $dbh->{CURRENT_USER} || $dbh->{Username};
}
PERL
print "\nour \%info = (\n";
foreach my $key (sort keys %GetInfoType)
{
my $num = $GetInfoType{$key};
my $val = eval { $dbh->get_info($num); };
if ($key eq 'SQL_DATA_SOURCE_NAME') {
$val = '\&sql_data_source_name';
}
elsif ($key eq 'SQL_KEYWORDS') {
$val = ($kw_map) ? '\&sql_keywords' : 'undef';
}
elsif ($key eq 'SQL_DRIVER_NAME') {
$val = "\$INC{'DBD/$driver.pm'}";
}
elsif ($key eq 'SQL_DRIVER_VER') {
$val = '$sql_driver_ver';
}
elsif ($key eq 'SQL_USER_NAME') {
$val = '\&sql_user_name';
}
elsif (not defined $val) {
$val = 'undef';
}
elsif ($val eq '') {
$val = "''";
}
elsif ($val =~ /\D/) {
$val =~ s/\\/\\\\/g;
$val =~ s/'/\\'/g;
$val = "'$val'";
}
printf "%s %5d => %-30s # %s\n", (($val eq 'undef') ? '#' : ' '), $num, "$val,", $key;
}
print ");\n\n1;\n\n__END__\n";
}
=head1 Generating a TypeInfo package for a driver
The C function in the DBI::DBD::Metadata module generates
on standard output the data needed for a driver's type_info_all method.
It also provides default implementations of the type_info_all
method for inclusion in the driver's main implementation file.
The driver parameter is the name of the driver for which the methods
will be generated; for the sake of examples, this will be "Driver".
Typically, the dsn parameter will be of the form "dbi:ODBC:odbc_dsn",
where the odbc_dsn is a DSN for one of the driver's databases.
The user and pass parameters are the other optional connection
parameters that will be provided to the DBI connect method.
Once you are sure that it is producing reasonably sane data, you should
typically redirect the standard output to lib/DBD/Driver/TypeInfo.pm,
and then hand edit the result if necessary.
Do not forget to update your Makefile.PL and MANIFEST to include this as
an extra PM file that should be installed.
Please take a critical look at the data returned!
ODBC drivers vary dramatically in their quality.
The generator assumes that all the values are static and places these
values directly in the %info hash.
A possible implementation of DBD::Driver::type_info_all() may look like:
sub type_info_all {
my ($dbh) = @_;
require DBD::Driver::TypeInfo;
return [ @$DBD::Driver::TypeInfo::type_info_all ];
}
Please replace Driver (or "") with the name of your driver.
Note that this stub function is generated for you by the write_typeinfo_pm
function, but you must manually transfer the code to Driver.pm.
=cut
# These two are used by fmt_value...
my %dbi_inv;
my %sql_type_inv;
#-DEBUGGING-#
#sub print_hash
#{
# my ($name, %hash) = @_;
# print "Hash: $name\n";
# foreach my $key (keys %hash)
# {
# print "$key => $hash{$key}\n";
# }
#}
#-DEBUGGING-#
sub inverse_hash
{
my (%hash) = @_;
my (%inv);
foreach my $key (keys %hash)
{
my $val = $hash{$key};
die "Double mapping for key value $val ($inv{$val}, $key)!"
if (defined $inv{$val});
$inv{$val} = $key;
}
return %inv;
}
sub fmt_value
{
my ($num, $val) = @_;
if (!defined $val)
{
$val = "undef";
}
elsif ($val !~ m/^[-+]?\d+$/)
{
# All the numbers in type_info_all are integers!
# Anything that isn't an integer is a string.
# Ensure that no double quotes screw things up.
$val =~ s/"/\\"/g if ($val =~ m/"/o);
$val = qq{"$val"};
}
elsif ($dbi_inv{$num} =~ m/^(SQL_)?DATA_TYPE$/)
{
# All numeric...
$val = $sql_type_inv{$val}
if (defined $sql_type_inv{$val});
}
return $val;
}
sub write_typeinfo_pm
{
my ($dsn, $user, $pass, $driver) = @_ ? @_ : @ARGV;
my $dbh = DBI->connect($dsn, $user, $pass, {AutoCommit=>1, RaiseError=>1});
$driver = "" unless defined $driver;
print < 0,
DATA_TYPE => 1,
COLUMN_SIZE => 2,
LITERAL_PREFIX => 3,
LITERAL_SUFFIX => 4,
CREATE_PARAMS => 5,
NULLABLE => 6,
CASE_SENSITIVE => 7,
SEARCHABLE => 8,
UNSIGNED_ATTRIBUTE => 9,
FIXED_PREC_SCALE => 10,
AUTO_UNIQUE_VALUE => 11,
LOCAL_TYPE_NAME => 12,
MINIMUM_SCALE => 13,
MAXIMUM_SCALE => 14,
SQL_DATA_TYPE => 15,
SQL_DATETIME_SUB => 16,
NUM_PREC_RADIX => 17,
INTERVAL_PRECISION => 18,
);
#-DEBUG-# print_hash("dbi_map", %dbi_map);
%dbi_inv = inverse_hash(%dbi_map);
#-DEBUG-# print_hash("dbi_inv", %dbi_inv);
my $maxlen = 0;
foreach my $key (keys %dbi_map)
{
$maxlen = length($key) if length($key) > $maxlen;
}
# Print the name/value mapping entry in the type_info_all array;
my $fmt = " \%-${maxlen}s => \%2d,\n";
my $numkey = 0;
my $maxkey = 0;
print " \$type_info_all = [\n {\n";
foreach my $i (sort { $a <=> $b } keys %dbi_inv)
{
printf($fmt, $dbi_inv{$i}, $i);
$numkey++;
$maxkey = $i;
}
print " },\n";
print STDERR "### WARNING - Non-dense set of keys ($numkey keys, $maxkey max key)\n"
unless $numkey = $maxkey + 1;
my $h = $dbh->type_info_all;
my @tia = @$h;
my %odbc_map = map { uc $_ => $tia[0]->{$_} } keys %{$tia[0]};
shift @tia; # Remove the mapping reference.
my $numtyp = $#tia;
#-DEBUG-# print_hash("odbc_map", %odbc_map);
# In theory, the key/number mapping sequence for %dbi_map
# should be the same as the one from the ODBC driver. However, to
# prevent the possibility of mismatches, and to deal with older
# missing attributes or unexpected new ones, we chase back through
# the %dbi_inv and %odbc_map hashes, generating @dbi_to_odbc
# to map our new key number to the old one.
# Report if @dbi_to_odbc is not an identity mapping.
my @dbi_to_odbc;
foreach my $num (sort { $a <=> $b } keys %dbi_inv)
{
# Find the name in %dbi_inv that matches this index number.
my $dbi_key = $dbi_inv{$num};
#-DEBUG-# print "dbi_key = $dbi_key\n";
#-DEBUG-# print "odbc_key = $odbc_map{$dbi_key}\n";
# Find the index in %odbc_map that has this key.
$dbi_to_odbc[$num] = (defined $odbc_map{$dbi_key}) ? $odbc_map{$dbi_key} : undef;
}
# Determine the length of the longest formatted value in each field
my @len;
for (my $i = 0; $i <= $numtyp; $i++)
{
my @odbc_val = @{$tia[$i]};
for (my $num = 0; $num <= $maxkey; $num++)
{
# Find the value of the entry in the @odbc_val array.
my $val = (defined $dbi_to_odbc[$num]) ? $odbc_val[$dbi_to_odbc[$num]] : undef;
$val = fmt_value($num, $val);
#-DEBUG-# print "val = $val\n";
$val = "$val,";
$len[$num] = length($val) if !defined $len[$num] || length($val) > $len[$num];
}
}
# Generate format strings to left justify each string in maximum field width.
my @fmt;
for (my $i = 0; $i <= $maxkey; $i++)
{
$fmt[$i] = "%-$len[$i]s";
#-DEBUG-# print "fmt[$i] = $fmt[$i]\n";
}
# Format the data from type_info_all
for (my $i = 0; $i <= $numtyp; $i++)
{
my @odbc_val = @{$tia[$i]};
print " [ ";
for (my $num = 0; $num <= $maxkey; $num++)
{
# Find the value of the entry in the @odbc_val array.
my $val = (defined $dbi_to_odbc[$num]) ? $odbc_val[$dbi_to_odbc[$num]] : undef;
$val = fmt_value($num, $val);
printf $fmt[$num], "$val,";
}
print " ],\n";
}
print " ];\n\n 1;\n}\n\n__END__\n";
}
1;
__END__
=head1 AUTHORS
Jonathan Leffler (previously ),
Jochen Wiedmann ,
Steffen Goeldner ,
and Tim Bunce .
=cut
PK ]QG G DBD/SqlEngine.pmnu [ # -*- perl -*-
#
# DBI::DBD::SqlEngine - A base class for implementing DBI drivers that
# have not an own SQL engine
#
# This module is currently maintained by
#
# H.Merijn Brand & Jens Rehsack
#
# The original author is Jochen Wiedmann.
#
# Copyright (C) 2009-2013 by H.Merijn Brand & Jens Rehsack
# Copyright (C) 2004 by Jeff Zucker
# Copyright (C) 1998 by Jochen Wiedmann
#
# All rights reserved.
#
# You may distribute this module under the terms of either the GNU
# General Public License or the Artistic License, as specified in
# the Perl README file.
require 5.008;
use strict;
use DBI ();
require DBI::SQL::Nano;
package DBI::DBD::SqlEngine;
use strict;
use Carp;
use vars qw( @ISA $VERSION $drh %methods_installed);
$VERSION = "0.06";
$drh = undef; # holds driver handle(s) once initialized
DBI->setup_driver("DBI::DBD::SqlEngine"); # only needed once but harmless to repeat
my %accessors = (
versions => "get_driver_versions",
new_meta => "new_sql_engine_meta",
get_meta => "get_sql_engine_meta",
set_meta => "set_sql_engine_meta",
clear_meta => "clear_sql_engine_meta",
);
sub driver ($;$)
{
my ( $class, $attr ) = @_;
# Drivers typically use a singleton object for the $drh
# We use a hash here to have one singleton per subclass.
# (Otherwise DBD::CSV and DBD::DBM, for example, would
# share the same driver object which would cause problems.)
# An alternative would be to not cache the $drh here at all
# and require that subclasses do that. Subclasses should do
# their own caching, so caching here just provides extra safety.
$drh->{$class} and return $drh->{$class};
$attr ||= {};
{
no strict "refs";
unless ( $attr->{Attribution} )
{
$class eq "DBI::DBD::SqlEngine"
and $attr->{Attribution} = "$class by Jens Rehsack";
$attr->{Attribution} ||= ${ $class . "::ATTRIBUTION" }
|| "oops the author of $class forgot to define this";
}
$attr->{Version} ||= ${ $class . "::VERSION" };
$attr->{Name} or ( $attr->{Name} = $class ) =~ s/^DBD\:\://;
}
$drh->{$class} = DBI::_new_drh( $class . "::dr", $attr );
$drh->{$class}->STORE( ShowErrorStatement => 1 );
my $prefix = DBI->driver_prefix($class);
if ($prefix)
{
my $dbclass = $class . "::db";
while ( my ( $accessor, $funcname ) = each %accessors )
{
my $method = $prefix . $accessor;
$dbclass->can($method) and next;
my $inject = sprintf <<'EOI', $dbclass, $method, $dbclass, $funcname;
sub %s::%s
{
my $func = %s->can (q{%s});
goto &$func;
}
EOI
eval $inject;
$dbclass->install_method($method);
}
}
else
{
warn "Using DBI::DBD::SqlEngine with unregistered driver $class.\n"
. "Reading documentation how to prevent is strongly recommended.\n";
}
# XXX inject DBD::XXX::Statement unless exists
my $stclass = $class . "::st";
$stclass->install_method("sql_get_colnames") unless ( $methods_installed{__PACKAGE__}++ );
return $drh->{$class};
} # driver
sub CLONE
{
undef $drh;
} # CLONE
# ====== DRIVER ================================================================
package DBI::DBD::SqlEngine::dr;
use strict;
use warnings;
use vars qw(@ISA $imp_data_size);
use Carp qw/carp/;
$imp_data_size = 0;
sub connect ($$;$$$)
{
my ( $drh, $dbname, $user, $auth, $attr ) = @_;
# create a 'blank' dbh
my $dbh = DBI::_new_dbh(
$drh,
{
Name => $dbname,
USER => $user,
CURRENT_USER => $user,
}
);
if ($dbh)
{
# must be done first, because setting flags implicitly calls $dbdname::db->STORE
$dbh->func( 0, "init_default_attributes" );
my $two_phased_init;
defined $dbh->{sql_init_phase} and $two_phased_init = ++$dbh->{sql_init_phase};
my %second_phase_attrs;
my @func_inits;
# this must be done to allow DBI.pm reblessing got handle after successful connecting
exists $attr->{RootClass} and $second_phase_attrs{RootClass} = delete $attr->{RootClass};
my ( $var, $val );
while ( length $dbname )
{
if ( $dbname =~ s/^((?:[^\\;]|\\.)*?);//s )
{
$var = $1;
}
else
{
$var = $dbname;
$dbname = "";
}
if ( $var =~ m/^(.+?)=(.*)/s )
{
$var = $1;
( $val = $2 ) =~ s/\\(.)/$1/g;
exists $attr->{$var}
and carp("$var is given in DSN *and* \$attr during DBI->connect()")
if ($^W);
exists $attr->{$var} or $attr->{$var} = $val;
}
elsif ( $var =~ m/^(.+?)=>(.*)/s )
{
$var = $1;
( $val = $2 ) =~ s/\\(.)/$1/g;
my $ref = eval $val;
# $dbh->$var($ref);
push( @func_inits, $var, $ref );
}
}
# The attributes need to be sorted in a specific way as the
# assignment is through tied hashes and calls STORE on each
# attribute. Some attributes require to be called prior to
# others
# e.g. f_dir *must* be done before xx_tables in DBD::File
# The dbh attribute sql_init_order is a hash with the order
# as key (low is first, 0 .. 100) and the attributes that
# are set to that oreder as anon-list as value:
# { 0 => [qw( AutoCommit PrintError RaiseError Profile ... )],
# 10 => [ list of attr to be dealt with immediately after first ],
# 50 => [ all fields that are unspecified or default sort order ],
# 90 => [ all fields that are needed after other initialisation ],
# }
my %order = map {
my $order = $_;
map { ( $_ => $order ) } @{ $dbh->{sql_init_order}{$order} };
} sort { $a <=> $b } keys %{ $dbh->{sql_init_order} || {} };
my @ordered_attr =
map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { [ $_, defined $order{$_} ? $order{$_} : 50 ] }
keys %$attr;
# initialize given attributes ... lower weighted before higher weighted
foreach my $a (@ordered_attr)
{
exists $attr->{$a} or next;
$two_phased_init and eval {
$dbh->{$a} = $attr->{$a};
delete $attr->{$a};
};
$@ and $second_phase_attrs{$a} = delete $attr->{$a};
$two_phased_init or $dbh->STORE( $a, delete $attr->{$a} );
}
$two_phased_init and $dbh->func( 1, "init_default_attributes" );
%$attr = %second_phase_attrs;
for ( my $i = 0; $i < scalar(@func_inits); $i += 2 )
{
my $func = $func_inits[$i];
my $arg = $func_inits[ $i + 1 ];
$dbh->$func($arg);
}
$dbh->func("init_done");
$dbh->STORE( Active => 1 );
}
return $dbh;
} # connect
sub data_sources ($;$)
{
my ( $drh, $attr ) = @_;
my $tbl_src;
$attr
and defined $attr->{sql_table_source}
and $attr->{sql_table_source}->isa('DBI::DBD::SqlEngine::TableSource')
and $tbl_src = $attr->{sql_table_source};
!defined($tbl_src)
and $drh->{ImplementorClass}->can('default_table_source')
and $tbl_src = $drh->{ImplementorClass}->default_table_source();
defined($tbl_src) or return;
$tbl_src->data_sources( $drh, $attr );
} # data_sources
sub disconnect_all
{
} # disconnect_all
sub DESTROY
{
undef;
} # DESTROY
# ====== DATABASE ==============================================================
package DBI::DBD::SqlEngine::db;
use strict;
use warnings;
use vars qw(@ISA $imp_data_size);
use Carp;
if ( eval { require Clone; } )
{
Clone->import("clone");
}
else
{
require Storable; # in CORE since 5.7.3
*clone = \&Storable::dclone;
}
$imp_data_size = 0;
sub ping
{
( $_[0]->FETCH("Active") ) ? 1 : 0;
} # ping
sub data_sources
{
my ( $dbh, $attr, @other ) = @_;
my $drh = $dbh->{Driver}; # XXX proxy issues?
ref($attr) eq 'HASH' or $attr = {};
defined( $attr->{sql_table_source} ) or $attr->{sql_table_source} = $dbh->{sql_table_source};
return $drh->data_sources( $attr, @other );
}
sub prepare ($$;@)
{
my ( $dbh, $statement, @attribs ) = @_;
# create a 'blank' sth
my $sth = DBI::_new_sth( $dbh, { Statement => $statement } );
if ($sth)
{
my $class = $sth->FETCH("ImplementorClass");
$class =~ s/::st$/::Statement/;
my $stmt;
# if using SQL::Statement version > 1
# cache the parser object if the DBD supports parser caching
# SQL::Nano and older SQL::Statements don't support this
if ( $class->isa("SQL::Statement") )
{
my $parser = $dbh->{sql_parser_object};
$parser ||= eval { $dbh->func("sql_parser_object") };
if ($@)
{
$stmt = eval { $class->new($statement) };
}
else
{
$stmt = eval { $class->new( $statement, $parser ) };
}
}
else
{
$stmt = eval { $class->new($statement) };
}
if ( $@ || $stmt->{errstr} )
{
$dbh->set_err( $DBI::stderr, $@ || $stmt->{errstr} );
undef $sth;
}
else
{
$sth->STORE( "sql_stmt", $stmt );
$sth->STORE( "sql_params", [] );
$sth->STORE( "NUM_OF_PARAMS", scalar( $stmt->params() ) );
my @colnames = $sth->sql_get_colnames();
$sth->STORE( "NUM_OF_FIELDS", scalar @colnames );
}
}
return $sth;
} # prepare
sub set_versions
{
my $dbh = $_[0];
$dbh->{sql_engine_version} = $DBI::DBD::SqlEngine::VERSION;
for (qw( nano_version statement_version ))
{
defined $DBI::SQL::Nano::versions->{$_} or next;
$dbh->{"sql_$_"} = $DBI::SQL::Nano::versions->{$_};
}
$dbh->{sql_handler} =
$dbh->{sql_statement_version}
? "SQL::Statement"
: "DBI::SQL::Nano";
return $dbh;
} # set_versions
sub init_valid_attributes
{
my $dbh = $_[0];
$dbh->{sql_valid_attrs} = {
sql_engine_version => 1, # DBI::DBD::SqlEngine version
sql_handler => 1, # Nano or S:S
sql_nano_version => 1, # Nano version
sql_statement_version => 1, # S:S version
sql_flags => 1, # flags for SQL::Parser
sql_dialect => 1, # dialect for SQL::Parser
sql_quoted_identifier_case => 1, # case for quoted identifiers
sql_identifier_case => 1, # case for non-quoted identifiers
sql_parser_object => 1, # SQL::Parser instance
sql_sponge_driver => 1, # Sponge driver for table_info ()
sql_valid_attrs => 1, # SQL valid attributes
sql_readonly_attrs => 1, # SQL readonly attributes
sql_init_phase => 1, # Only during initialization
sql_meta => 1, # meta data for tables
sql_meta_map => 1, # mapping table for identifier case
sql_data_source => 1, # reasonable datasource class
};
$dbh->{sql_readonly_attrs} = {
sql_engine_version => 1, # DBI::DBD::SqlEngine version
sql_handler => 1, # Nano or S:S
sql_nano_version => 1, # Nano version
sql_statement_version => 1, # S:S version
sql_quoted_identifier_case => 1, # case for quoted identifiers
sql_parser_object => 1, # SQL::Parser instance
sql_sponge_driver => 1, # Sponge driver for table_info ()
sql_valid_attrs => 1, # SQL valid attributes
sql_readonly_attrs => 1, # SQL readonly attributes
};
return $dbh;
} # init_valid_attributes
sub init_default_attributes
{
my ( $dbh, $phase ) = @_;
my $given_phase = $phase;
unless ( defined($phase) )
{
# we have an "old" driver here
$phase = defined $dbh->{sql_init_phase};
$phase and $phase = $dbh->{sql_init_phase};
}
if ( 0 == $phase )
{
# must be done first, because setting flags implicitly calls $dbdname::db->STORE
$dbh->func("init_valid_attributes");
$dbh->func("set_versions");
$dbh->{sql_identifier_case} = 2; # SQL_IC_LOWER
$dbh->{sql_quoted_identifier_case} = 3; # SQL_IC_SENSITIVE
$dbh->{sql_dialect} = "CSV";
$dbh->{sql_init_phase} = $given_phase;
# complete derived attributes, if required
( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
my $drv_prefix = DBI->driver_prefix($drv_class);
my $valid_attrs = $drv_prefix . "valid_attrs";
my $ro_attrs = $drv_prefix . "readonly_attrs";
# check whether we're running in a Gofer server or not (see
# validate_FETCH_attr for details)
$dbh->{sql_engine_in_gofer} =
( defined $INC{"DBD/Gofer.pm"} && ( caller(5) )[0] eq "DBI::Gofer::Execute" );
$dbh->{sql_meta} = {};
$dbh->{sql_meta_map} = {}; # choose new name because it contains other keys
# init_default_attributes calls inherited routine before derived DBD's
# init their default attributes, so we don't override something here
#
# defining an order of attribute initialization from connect time
# specified ones with a magic baarier (see next statement)
my $drv_pfx_meta = $drv_prefix . "meta";
$dbh->{sql_init_order} = {
0 => [qw( Profile RaiseError PrintError AutoCommit )],
90 => [ "sql_meta", $dbh->{$drv_pfx_meta} ? $dbh->{$drv_pfx_meta} : () ],
};
# ensuring Profile, RaiseError, PrintError, AutoCommit are initialized
# first when initializing attributes from connect time specified
# attributes
# further, initializations to predefined tables are happens after any
# unspecified attribute initialization (that default to order 50)
my @comp_attrs = qw(valid_attrs version readonly_attrs);
if ( exists $dbh->{$drv_pfx_meta} and !$dbh->{sql_engine_in_gofer} )
{
my $attr = $dbh->{$drv_pfx_meta};
defined $attr
and defined $dbh->{$valid_attrs}
and !defined $dbh->{$valid_attrs}{$attr}
and $dbh->{$valid_attrs}{$attr} = 1;
my %h;
tie %h, "DBI::DBD::SqlEngine::TieTables", $dbh;
$dbh->{$attr} = \%h;
push @comp_attrs, "meta";
}
foreach my $comp_attr (@comp_attrs)
{
my $attr = $drv_prefix . $comp_attr;
defined $dbh->{$valid_attrs}
and !defined $dbh->{$valid_attrs}{$attr}
and $dbh->{$valid_attrs}{$attr} = 1;
defined $dbh->{$ro_attrs}
and !defined $dbh->{$ro_attrs}{$attr}
and $dbh->{$ro_attrs}{$attr} = 1;
}
}
return $dbh;
} # init_default_attributes
sub init_done
{
defined $_[0]->{sql_init_phase} and delete $_[0]->{sql_init_phase};
delete $_[0]->{sql_valid_attrs}->{sql_init_phase};
return;
}
sub sql_parser_object
{
my $dbh = $_[0];
my $dialect = $dbh->{sql_dialect} || "CSV";
my $parser = {
RaiseError => $dbh->FETCH("RaiseError"),
PrintError => $dbh->FETCH("PrintError"),
};
my $sql_flags = $dbh->FETCH("sql_flags") || {};
%$parser = ( %$parser, %$sql_flags );
$parser = SQL::Parser->new( $dialect, $parser );
$dbh->{sql_parser_object} = $parser;
return $parser;
} # sql_parser_object
sub sql_sponge_driver
{
my $dbh = $_[0];
my $dbh2 = $dbh->{sql_sponge_driver};
unless ($dbh2)
{
$dbh2 = $dbh->{sql_sponge_driver} = DBI->connect("DBI:Sponge:");
unless ($dbh2)
{
$dbh->set_err( $DBI::stderr, $DBI::errstr );
return;
}
}
}
sub disconnect ($)
{
%{ $_[0]->{sql_meta} } = ();
%{ $_[0]->{sql_meta_map} } = ();
$_[0]->STORE( Active => 0 );
return 1;
} # disconnect
sub validate_FETCH_attr
{
my ( $dbh, $attrib ) = @_;
# If running in a Gofer server, access to our tied compatibility hash
# would force Gofer to serialize the tieing object including it's
# private $dbh reference used to do the driver function calls.
# This will result in nasty exceptions. So return a copy of the
# sql_meta structure instead, which is the source of for the compatibility
# tie-hash. It's not as good as liked, but the best we can do in this
# situation.
if ( $dbh->{sql_engine_in_gofer} )
{
( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
my $drv_prefix = DBI->driver_prefix($drv_class);
exists $dbh->{ $drv_prefix . "meta" } && $attrib eq $dbh->{ $drv_prefix . "meta" }
and $attrib = "sql_meta";
}
return $attrib;
}
sub FETCH ($$)
{
my ( $dbh, $attrib ) = @_;
$attrib eq "AutoCommit"
and return 1;
# Driver private attributes are lower cased
if ( $attrib eq ( lc $attrib ) )
{
# first let the implementation deliver an alias for the attribute to fetch
# after it validates the legitimation of the fetch request
$attrib = $dbh->func( $attrib, "validate_FETCH_attr" ) or return;
my $attr_prefix;
$attrib =~ m/^([a-z]+_)/ and $attr_prefix = $1;
unless ($attr_prefix)
{
( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
$attr_prefix = DBI->driver_prefix($drv_class);
$attrib = $attr_prefix . $attrib;
}
my $valid_attrs = $attr_prefix . "valid_attrs";
my $ro_attrs = $attr_prefix . "readonly_attrs";
exists $dbh->{$valid_attrs}
and ( $dbh->{$valid_attrs}{$attrib}
or return $dbh->set_err( $DBI::stderr, "Invalid attribute '$attrib'" ) );
exists $dbh->{$ro_attrs}
and $dbh->{$ro_attrs}{$attrib}
and defined $dbh->{$attrib}
and refaddr( $dbh->{$attrib} )
and return clone( $dbh->{$attrib} );
return $dbh->{$attrib};
}
# else pass up to DBI to handle
return $dbh->SUPER::FETCH($attrib);
} # FETCH
sub validate_STORE_attr
{
my ( $dbh, $attrib, $value ) = @_;
if ( $attrib eq "sql_identifier_case" || $attrib eq "sql_quoted_identifier_case"
and $value < 1 || $value > 4 )
{
croak "attribute '$attrib' must have a value from 1 .. 4 (SQL_IC_UPPER .. SQL_IC_MIXED)";
# XXX correctly a remap of all entries in sql_meta/sql_meta_map is required here
}
( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
my $drv_prefix = DBI->driver_prefix($drv_class);
exists $dbh->{ $drv_prefix . "meta" }
and $attrib eq $dbh->{ $drv_prefix . "meta" }
and $attrib = "sql_meta";
return ( $attrib, $value );
}
# the ::db::STORE method is what gets called when you set
# a lower-cased database handle attribute such as $dbh->{somekey}=$someval;
#
# STORE should check to make sure that "somekey" is a valid attribute name
# but only if it is really one of our attributes (starts with dbm_ or foo_)
# You can also check for valid values for the attributes if needed
# and/or perform other operations
#
sub STORE ($$$)
{
my ( $dbh, $attrib, $value ) = @_;
if ( $attrib eq "AutoCommit" )
{
$value and return 1; # is already set
croak "Can't disable AutoCommit";
}
if ( $attrib eq lc $attrib )
{
# Driver private attributes are lower cased
( $attrib, $value ) = $dbh->func( $attrib, $value, "validate_STORE_attr" );
$attrib or return;
my $attr_prefix;
$attrib =~ m/^([a-z]+_)/ and $attr_prefix = $1;
unless ($attr_prefix)
{
( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
$attr_prefix = DBI->driver_prefix($drv_class);
$attrib = $attr_prefix . $attrib;
}
my $valid_attrs = $attr_prefix . "valid_attrs";
my $ro_attrs = $attr_prefix . "readonly_attrs";
exists $dbh->{$valid_attrs}
and ( $dbh->{$valid_attrs}{$attrib}
or return $dbh->set_err( $DBI::stderr, "Invalid attribute '$attrib'" ) );
exists $dbh->{$ro_attrs}
and $dbh->{$ro_attrs}{$attrib}
and defined $dbh->{$attrib}
and return $dbh->set_err( $DBI::stderr,
"attribute '$attrib' is readonly and must not be modified" );
if ( $attrib eq "sql_meta" )
{
while ( my ( $k, $v ) = each %$value )
{
$dbh->{$attrib}{$k} = $v;
}
}
else
{
$dbh->{$attrib} = $value;
}
return 1;
}
return $dbh->SUPER::STORE( $attrib, $value );
} # STORE
sub get_driver_versions
{
my ( $dbh, $table ) = @_;
my %vsn = (
OS => "$^O ($Config::Config{osvers})",
Perl => "$] ($Config::Config{archname})",
DBI => $DBI::VERSION,
);
my %vmp;
my $sql_engine_verinfo =
join " ",
$dbh->{sql_engine_version}, "using", $dbh->{sql_handler},
$dbh->{sql_handler} eq "SQL::Statement"
? $dbh->{sql_statement_version}
: $dbh->{sql_nano_version};
my $indent = 0;
my @deriveds = ( $dbh->{ImplementorClass} );
while (@deriveds)
{
my $derived = shift @deriveds;
$derived eq "DBI::DBD::SqlEngine::db" and last;
$derived->isa("DBI::DBD::SqlEngine::db") or next;
#no strict 'refs';
eval "push \@deriveds, \@${derived}::ISA";
#use strict;
( my $drv_class = $derived ) =~ s/::db$//;
my $drv_prefix = DBI->driver_prefix($drv_class);
my $ddgv = $dbh->{ImplementorClass}->can("get_${drv_prefix}versions");
my $drv_version = $ddgv ? &$ddgv( $dbh, $table ) : $dbh->{ $drv_prefix . "version" };
$drv_version ||=
eval { $derived->VERSION() }; # XXX access $drv_class::VERSION via symbol table
$vsn{$drv_class} = $drv_version;
$indent and $vmp{$drv_class} = " " x $indent . $drv_class;
$indent += 2;
}
$vsn{"DBI::DBD::SqlEngine"} = $sql_engine_verinfo;
$indent and $vmp{"DBI::DBD::SqlEngine"} = " " x $indent . "DBI::DBD::SqlEngine";
$DBI::PurePerl and $vsn{"DBI::PurePerl"} = $DBI::PurePerl::VERSION;
$indent += 20;
my @versions = map { sprintf "%-${indent}s %s", $vmp{$_} || $_, $vsn{$_} }
sort {
$a->isa($b) and return -1;
$b->isa($a) and return 1;
$a->isa("DBI::DBD::SqlEngine") and return -1;
$b->isa("DBI::DBD::SqlEngine") and return 1;
return $a cmp $b;
} keys %vsn;
return wantarray ? @versions : join "\n", @versions;
} # get_versions
sub get_single_table_meta
{
my ( $dbh, $table, $attr ) = @_;
my $meta;
$table eq "."
and return $dbh->FETCH($attr);
( my $class = $dbh->{ImplementorClass} ) =~ s/::db$/::Table/;
( undef, $meta ) = $class->get_table_meta( $dbh, $table, 1 );
$meta or croak "No such table '$table'";
# prevent creation of undef attributes
return $class->get_table_meta_attr( $meta, $attr );
} # get_single_table_meta
sub get_sql_engine_meta
{
my ( $dbh, $table, $attr ) = @_;
my $gstm = $dbh->{ImplementorClass}->can("get_single_table_meta");
$table eq "*"
and $table = [ ".", keys %{ $dbh->{sql_meta} } ];
$table eq "+"
and $table = [ grep { m/^[_A-Za-z0-9]+$/ } keys %{ $dbh->{sql_meta} } ];
ref $table eq "Regexp"
and $table = [ grep { $_ =~ $table } keys %{ $dbh->{sql_meta} } ];
ref $table || ref $attr
or return $gstm->( $dbh, $table, $attr );
ref $table or $table = [$table];
ref $attr or $attr = [$attr];
"ARRAY" eq ref $table
or return
$dbh->set_err( $DBI::stderr,
"Invalid argument for \$table - SCALAR, Regexp or ARRAY expected but got " . ref $table );
"ARRAY" eq ref $attr
or return $dbh->set_err(
"Invalid argument for \$attr - SCALAR or ARRAY expected but got " . ref $attr );
my %results;
foreach my $tname ( @{$table} )
{
my %tattrs;
foreach my $aname ( @{$attr} )
{
$tattrs{$aname} = $gstm->( $dbh, $tname, $aname );
}
$results{$tname} = \%tattrs;
}
return \%results;
} # get_sql_engine_meta
sub new_sql_engine_meta
{
my ( $dbh, $table, $values ) = @_;
my $respect_case = 0;
"HASH" eq ref $values
or croak "Invalid argument for \$values - SCALAR or HASH expected but got " . ref $values;
$table =~ s/^\"// and $respect_case = 1; # handle quoted identifiers
$table =~ s/\"$//;
unless ($respect_case)
{
defined $dbh->{sql_meta_map}{$table} and $table = $dbh->{sql_meta_map}{$table};
}
$dbh->{sql_meta}{$table} = { %{$values} };
my $class;
defined $values->{sql_table_class} and $class = $values->{sql_table_class};
defined $class or ( $class = $dbh->{ImplementorClass} ) =~ s/::db$/::Table/;
# XXX we should never hit DBD::File::Table::get_table_meta here ...
my ( undef, $meta ) = $class->get_table_meta( $dbh, $table, $respect_case );
1;
} # new_sql_engine_meta
sub set_single_table_meta
{
my ( $dbh, $table, $attr, $value ) = @_;
my $meta;
$table eq "."
and return $dbh->STORE( $attr, $value );
( my $class = $dbh->{ImplementorClass} ) =~ s/::db$/::Table/;
( undef, $meta ) = $class->get_table_meta( $dbh, $table, 1 ); # 1 means: respect case
$meta or croak "No such table '$table'";
$class->set_table_meta_attr( $meta, $attr, $value );
return $dbh;
} # set_single_table_meta
sub set_sql_engine_meta
{
my ( $dbh, $table, $attr, $value ) = @_;
my $sstm = $dbh->{ImplementorClass}->can("set_single_table_meta");
$table eq "*"
and $table = [ ".", keys %{ $dbh->{sql_meta} } ];
$table eq "+"
and $table = [ grep { m/^[_A-Za-z0-9]+$/ } keys %{ $dbh->{sql_meta} } ];
ref($table) eq "Regexp"
and $table = [ grep { $_ =~ $table } keys %{ $dbh->{sql_meta} } ];
ref $table || ref $attr
or return $sstm->( $dbh, $table, $attr, $value );
ref $table or $table = [$table];
ref $attr or $attr = { $attr => $value };
"ARRAY" eq ref $table
or croak "Invalid argument for \$table - SCALAR, Regexp or ARRAY expected but got "
. ref $table;
"HASH" eq ref $attr
or croak "Invalid argument for \$attr - SCALAR or HASH expected but got " . ref $attr;
foreach my $tname ( @{$table} )
{
while ( my ( $aname, $aval ) = each %$attr )
{
$sstm->( $dbh, $tname, $aname, $aval );
}
}
return $dbh;
} # set_file_meta
sub clear_sql_engine_meta
{
my ( $dbh, $table ) = @_;
( my $class = $dbh->{ImplementorClass} ) =~ s/::db$/::Table/;
my ( undef, $meta ) = $class->get_table_meta( $dbh, $table, 1 );
$meta and %{$meta} = ();
return;
} # clear_file_meta
sub DESTROY ($)
{
my $dbh = shift;
$dbh->SUPER::FETCH("Active") and $dbh->disconnect;
undef $dbh->{sql_parser_object};
} # DESTROY
sub type_info_all ($)
{
[
{
TYPE_NAME => 0,
DATA_TYPE => 1,
PRECISION => 2,
LITERAL_PREFIX => 3,
LITERAL_SUFFIX => 4,
CREATE_PARAMS => 5,
NULLABLE => 6,
CASE_SENSITIVE => 7,
SEARCHABLE => 8,
UNSIGNED_ATTRIBUTE => 9,
MONEY => 10,
AUTO_INCREMENT => 11,
LOCAL_TYPE_NAME => 12,
MINIMUM_SCALE => 13,
MAXIMUM_SCALE => 14,
},
[
"VARCHAR", DBI::SQL_VARCHAR(), undef, "'", "'", undef, 0, 1, 1, 0, 0, 0, undef, 1, 999999,
],
[ "CHAR", DBI::SQL_CHAR(), undef, "'", "'", undef, 0, 1, 1, 0, 0, 0, undef, 1, 999999, ],
[ "INTEGER", DBI::SQL_INTEGER(), undef, "", "", undef, 0, 0, 1, 0, 0, 0, undef, 0, 0, ],
[ "REAL", DBI::SQL_REAL(), undef, "", "", undef, 0, 0, 1, 0, 0, 0, undef, 0, 0, ],
[
"BLOB", DBI::SQL_LONGVARBINARY(), undef, "'", "'", undef, 0, 1, 1, 0, 0, 0, undef, 1,
999999,
],
[
"BLOB", DBI::SQL_LONGVARBINARY(), undef, "'", "'", undef, 0, 1, 1, 0, 0, 0, undef, 1,
999999,
],
[
"TEXT", DBI::SQL_LONGVARCHAR(), undef, "'", "'", undef, 0, 1, 1, 0, 0, 0, undef, 1,
999999,
],
];
} # type_info_all
sub get_avail_tables
{
my $dbh = $_[0];
my @tables = ();
if ( $dbh->{sql_handler} eq "SQL::Statement" and $dbh->{sql_ram_tables} )
{
# XXX map +[ undef, undef, $_, "TABLE", "TEMP" ], keys %{...}
foreach my $table ( keys %{ $dbh->{sql_ram_tables} } )
{
push @tables, [ undef, undef, $table, "TABLE", "TEMP" ];
}
}
my $tbl_src;
defined $dbh->{sql_table_source}
and $dbh->{sql_table_source}->isa('DBI::DBD::SqlEngine::TableSource')
and $tbl_src = $dbh->{sql_table_source};
!defined($tbl_src)
and $dbh->{Driver}->{ImplementorClass}->can('default_table_source')
and $tbl_src = $dbh->{Driver}->{ImplementorClass}->default_table_source();
defined($tbl_src) and push( @tables, $tbl_src->avail_tables($dbh) );
return @tables;
} # get_avail_tables
{
my $names = [qw( TABLE_QUALIFIER TABLE_OWNER TABLE_NAME TABLE_TYPE REMARKS )];
sub table_info ($)
{
my $dbh = shift;
my @tables = $dbh->func("get_avail_tables");
# Temporary kludge: DBD::Sponge dies if @tables is empty. :-(
# this no longer seems to be true @tables or return;
my $dbh2 = $dbh->func("sql_sponge_driver");
my $sth = $dbh2->prepare(
"TABLE_INFO",
{
rows => \@tables,
NAME => $names,
}
);
$sth or return $dbh->set_err( $DBI::stderr, $dbh2->errstr );
$sth->execute or return;
return $sth;
} # table_info
}
sub list_tables ($)
{
my $dbh = shift;
my @table_list;
my @tables = $dbh->func("get_avail_tables") or return;
foreach my $ref (@tables)
{
# rt69260 and rt67223 - the same issue in 2 different queues
push @table_list, $ref->[2];
}
return @table_list;
} # list_tables
sub quote ($$;$)
{
my ( $self, $str, $type ) = @_;
defined $str or return "NULL";
defined $type && ( $type == DBI::SQL_NUMERIC()
|| $type == DBI::SQL_DECIMAL()
|| $type == DBI::SQL_INTEGER()
|| $type == DBI::SQL_SMALLINT()
|| $type == DBI::SQL_FLOAT()
|| $type == DBI::SQL_REAL()
|| $type == DBI::SQL_DOUBLE()
|| $type == DBI::SQL_TINYINT() )
and return $str;
$str =~ s/\\/\\\\/sg;
$str =~ s/\0/\\0/sg;
$str =~ s/\'/\\\'/sg;
$str =~ s/\n/\\n/sg;
$str =~ s/\r/\\r/sg;
return "'$str'";
} # quote
sub commit ($)
{
my $dbh = shift;
$dbh->FETCH("Warn")
and carp "Commit ineffective while AutoCommit is on", -1;
return 1;
} # commit
sub rollback ($)
{
my $dbh = shift;
$dbh->FETCH("Warn")
and carp "Rollback ineffective while AutoCommit is on", -1;
return 0;
} # rollback
# ====== Tie-Meta ==============================================================
package DBI::DBD::SqlEngine::TieMeta;
use Carp qw(croak);
require Tie::Hash;
@DBI::DBD::SqlEngine::TieMeta::ISA = qw(Tie::Hash);
sub TIEHASH
{
my ( $class, $tblClass, $tblMeta ) = @_;
my $self = bless(
{
tblClass => $tblClass,
tblMeta => $tblMeta,
},
$class
);
return $self;
} # new
sub STORE
{
my ( $self, $meta_attr, $meta_val ) = @_;
$self->{tblClass}->set_table_meta_attr( $self->{tblMeta}, $meta_attr, $meta_val );
return;
} # STORE
sub FETCH
{
my ( $self, $meta_attr ) = @_;
return $self->{tblClass}->get_table_meta_attr( $self->{tblMeta}, $meta_attr );
} # FETCH
sub FIRSTKEY
{
my $a = scalar keys %{ $_[0]->{tblMeta} };
each %{ $_[0]->{tblMeta} };
} # FIRSTKEY
sub NEXTKEY
{
each %{ $_[0]->{tblMeta} };
} # NEXTKEY
sub EXISTS
{
exists $_[0]->{tblMeta}{ $_[1] };
} # EXISTS
sub DELETE
{
croak "Can't delete single attributes from table meta structure";
} # DELETE
sub CLEAR
{
%{ $_[0]->{tblMeta} } = ();
} # CLEAR
sub SCALAR
{
scalar %{ $_[0]->{tblMeta} };
} # SCALAR
# ====== Tie-Tables ============================================================
package DBI::DBD::SqlEngine::TieTables;
use Carp qw(croak);
require Tie::Hash;
@DBI::DBD::SqlEngine::TieTables::ISA = qw(Tie::Hash);
sub TIEHASH
{
my ( $class, $dbh ) = @_;
( my $tbl_class = $dbh->{ImplementorClass} ) =~ s/::db$/::Table/;
my $self = bless(
{
dbh => $dbh,
tblClass => $tbl_class,
},
$class
);
return $self;
} # new
sub STORE
{
my ( $self, $table, $tbl_meta ) = @_;
"HASH" eq ref $tbl_meta
or croak "Invalid data for storing as table meta data (must be hash)";
( undef, my $meta ) = $self->{tblClass}->get_table_meta( $self->{dbh}, $table, 1 );
$meta or croak "Invalid table name '$table'";
while ( my ( $meta_attr, $meta_val ) = each %$tbl_meta )
{
$self->{tblClass}->set_table_meta_attr( $meta, $meta_attr, $meta_val );
}
return;
} # STORE
sub FETCH
{
my ( $self, $table ) = @_;
( undef, my $meta ) = $self->{tblClass}->get_table_meta( $self->{dbh}, $table, 1 );
$meta or croak "Invalid table name '$table'";
my %h;
tie %h, "DBI::DBD::SqlEngine::TieMeta", $self->{tblClass}, $meta;
return \%h;
} # FETCH
sub FIRSTKEY
{
my $a = scalar keys %{ $_[0]->{dbh}->{sql_meta} };
each %{ $_[0]->{dbh}->{sql_meta} };
} # FIRSTKEY
sub NEXTKEY
{
each %{ $_[0]->{dbh}->{sql_meta} };
} # NEXTKEY
sub EXISTS
{
exists $_[0]->{dbh}->{sql_meta}->{ $_[1] }
or exists $_[0]->{dbh}->{sql_meta_map}->{ $_[1] };
} # EXISTS
sub DELETE
{
my ( $self, $table ) = @_;
( undef, my $meta ) = $self->{tblClass}->get_table_meta( $self->{dbh}, $table, 1 );
$meta or croak "Invalid table name '$table'";
delete $_[0]->{dbh}->{sql_meta}->{ $meta->{table_name} };
} # DELETE
sub CLEAR
{
%{ $_[0]->{dbh}->{sql_meta} } = ();
%{ $_[0]->{dbh}->{sql_meta_map} } = ();
} # CLEAR
sub SCALAR
{
scalar %{ $_[0]->{dbh}->{sql_meta} };
} # SCALAR
# ====== STATEMENT =============================================================
package DBI::DBD::SqlEngine::st;
use strict;
use warnings;
use vars qw(@ISA $imp_data_size);
$imp_data_size = 0;
sub bind_param ($$$;$)
{
my ( $sth, $pNum, $val, $attr ) = @_;
if ( $attr && defined $val )
{
my $type = ref $attr eq "HASH" ? $attr->{TYPE} : $attr;
if ( $type == DBI::SQL_BIGINT()
|| $type == DBI::SQL_INTEGER()
|| $type == DBI::SQL_SMALLINT()
|| $type == DBI::SQL_TINYINT() )
{
$val += 0;
}
elsif ( $type == DBI::SQL_DECIMAL()
|| $type == DBI::SQL_DOUBLE()
|| $type == DBI::SQL_FLOAT()
|| $type == DBI::SQL_NUMERIC()
|| $type == DBI::SQL_REAL() )
{
$val += 0.;
}
else
{
$val = "$val";
}
}
$sth->{sql_params}[ $pNum - 1 ] = $val;
return 1;
} # bind_param
sub execute
{
my $sth = shift;
my $params = @_ ? ( $sth->{sql_params} = [@_] ) : $sth->{sql_params};
$sth->finish;
my $stmt = $sth->{sql_stmt};
# must not proved when already executed - SQL::Statement modifies
# received params
unless ( $sth->{sql_params_checked}++ )
{
# SQL::Statement and DBI::SQL::Nano will return the list of required params
# when called in list context. Do not look into the several items, they're
# implementation specific and may change without warning
unless ( ( my $req_prm = $stmt->params() ) == ( my $nparm = @$params ) )
{
my $msg = "You passed $nparm parameters where $req_prm required";
return $sth->set_err( $DBI::stderr, $msg );
}
}
my @err;
my $result;
eval {
local $SIG{__WARN__} = sub { push @err, @_ };
$result = $stmt->execute( $sth, $params );
};
unless ( defined $result )
{
$sth->set_err( $DBI::stderr, $@ || $stmt->{errstr} || $err[0] );
return;
}
if ( $stmt->{NUM_OF_FIELDS} )
{ # is a SELECT statement
$sth->STORE( Active => 1 );
$sth->FETCH("NUM_OF_FIELDS")
or $sth->STORE( "NUM_OF_FIELDS", $stmt->{NUM_OF_FIELDS} );
}
return $result;
} # execute
sub finish
{
my $sth = $_[0];
$sth->SUPER::STORE( Active => 0 );
delete $sth->{sql_stmt}{data};
return 1;
} # finish
sub fetch ($)
{
my $sth = $_[0];
my $data = $sth->{sql_stmt}{data};
if ( !$data || ref $data ne "ARRAY" )
{
$sth->set_err(
$DBI::stderr,
"Attempt to fetch row without a preceding execute () call or from a non-SELECT statement"
);
return;
}
my $dav = shift @$data;
unless ($dav)
{
$sth->finish;
return;
}
if ( $sth->FETCH("ChopBlanks") ) # XXX: (TODO) Only chop on CHAR fields,
{ # not on VARCHAR or NUMERIC (see DBI docs)
$_ && $_ =~ s/ +$// for @$dav;
}
return $sth->_set_fbav($dav);
} # fetch
no warnings 'once';
*fetchrow_arrayref = \&fetch;
use warnings;
sub sql_get_colnames
{
my $sth = $_[0];
# Being a bit dirty here, as neither SQL::Statement::Structure nor
# DBI::SQL::Nano::Statement_ does not offer an interface to the
# required data
my @colnames;
if ( $sth->{sql_stmt}->{NAME} and "ARRAY" eq ref( $sth->{sql_stmt}->{NAME} ) )
{
@colnames = @{ $sth->{sql_stmt}->{NAME} };
}
elsif ( $sth->{sql_stmt}->isa('SQL::Statement') )
{
my $stmt = $sth->{sql_stmt} || {};
my @coldefs = @{ $stmt->{column_defs} || [] };
@colnames = map { $_->{name} || $_->{value} } @coldefs;
}
@colnames = $sth->{sql_stmt}->column_names() unless (@colnames);
@colnames = () if ( grep { m/\*/ } @colnames );
return @colnames;
}
sub FETCH ($$)
{
my ( $sth, $attrib ) = @_;
$attrib eq "NAME" and return [ $sth->sql_get_colnames() ];
$attrib eq "TYPE" and return [ ( DBI::SQL_VARCHAR() ) x scalar $sth->sql_get_colnames() ];
$attrib eq "TYPE_NAME" and return [ ("VARCHAR") x scalar $sth->sql_get_colnames() ];
$attrib eq "PRECISION" and return [ (0) x scalar $sth->sql_get_colnames() ];
$attrib eq "NULLABLE" and return [ (1) x scalar $sth->sql_get_colnames() ];
if ( $attrib eq lc $attrib )
{
# Private driver attributes are lower cased
return $sth->{$attrib};
}
# else pass up to DBI to handle
return $sth->SUPER::FETCH($attrib);
} # FETCH
sub STORE ($$$)
{
my ( $sth, $attrib, $value ) = @_;
if ( $attrib eq lc $attrib ) # Private driver attributes are lower cased
{
$sth->{$attrib} = $value;
return 1;
}
return $sth->SUPER::STORE( $attrib, $value );
} # STORE
sub DESTROY ($)
{
my $sth = shift;
$sth->SUPER::FETCH("Active") and $sth->finish;
undef $sth->{sql_stmt};
undef $sth->{sql_params};
} # DESTROY
sub rows ($)
{
return $_[0]->{sql_stmt}{NUM_OF_ROWS};
} # rows
# ====== TableSource ===========================================================
package DBI::DBD::SqlEngine::TableSource;
use strict;
use warnings;
use Carp;
sub data_sources ($;$)
{
my ( $class, $drh, $attrs ) = @_;
croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement data_sources" );
}
sub avail_tables
{
my ( $self, $dbh ) = @_;
croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement avail_tables" );
}
# ====== DataSource ============================================================
package DBI::DBD::SqlEngine::DataSource;
use strict;
use warnings;
use Carp;
sub complete_table_name ($$;$)
{
my ( $self, $meta, $table, $respect_case ) = @_;
croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement complete_table_name" );
}
sub open_data ($)
{
my ( $self, $meta, $attrs, $flags ) = @_;
croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement open_data" );
}
# ====== SQL::STATEMENT ========================================================
package DBI::DBD::SqlEngine::Statement;
use strict;
use warnings;
use Carp;
@DBI::DBD::SqlEngine::Statement::ISA = qw(DBI::SQL::Nano::Statement);
sub open_table ($$$$$)
{
my ( $self, $data, $table, $createMode, $lockMode ) = @_;
my $class = ref $self;
$class =~ s/::Statement/::Table/;
my $flags = {
createMode => $createMode,
lockMode => $lockMode,
};
$self->{command} eq "DROP" and $flags->{dropMode} = 1;
my ( $tblnm, $table_meta ) = $class->get_table_meta( $data->{Database}, $table, 1 )
or croak "Cannot find appropriate meta for table '$table'";
defined $table_meta->{sql_table_class} and $class = $table_meta->{sql_table_class};
# because column name mapping is initialized in constructor ...
# and therefore specific opening operations might be done before
# reaching DBI::DBD::SqlEngine::Table->new(), we need to intercept
# ReadOnly here
my $write_op = $createMode || $lockMode || $flags->{dropMode};
if ($write_op)
{
$table_meta->{readonly}
and croak "Table '$table' is marked readonly - "
. $self->{command}
. ( $lockMode ? " with locking" : "" )
. " command forbidden";
}
return $class->new( $data, { table => $table }, $flags );
} # open_table
# ====== SQL::TABLE ============================================================
package DBI::DBD::SqlEngine::Table;
use strict;
use warnings;
use Carp;
@DBI::DBD::SqlEngine::Table::ISA = qw(DBI::SQL::Nano::Table);
sub bootstrap_table_meta
{
my ( $self, $dbh, $meta, $table ) = @_;
defined $dbh->{ReadOnly}
and !defined( $meta->{readonly} )
and $meta->{readonly} = $dbh->{ReadOnly};
defined $meta->{sql_identifier_case}
or $meta->{sql_identifier_case} = $dbh->{sql_identifier_case};
exists $meta->{sql_data_source} or $meta->{sql_data_source} = $dbh->{sql_data_source};
$meta;
}
sub init_table_meta
{
my ( $self, $dbh, $meta, $table ) = @_ if (0);
return;
} # init_table_meta
sub get_table_meta ($$$;$)
{
my ( $self, $dbh, $table, $respect_case, @other ) = @_;
unless ( defined $respect_case )
{
$respect_case = 0;
$table =~ s/^\"// and $respect_case = 1; # handle quoted identifiers
$table =~ s/\"$//;
}
unless ($respect_case)
{
defined $dbh->{sql_meta_map}{$table} and $table = $dbh->{sql_meta_map}{$table};
}
my $meta = {};
defined $dbh->{sql_meta}{$table} and $meta = $dbh->{sql_meta}{$table};
do_initialize:
unless ( $meta->{initialized} )
{
$self->bootstrap_table_meta( $dbh, $meta, $table, @other );
$meta->{sql_data_source}->complete_table_name( $meta, $table, $respect_case, @other )
or return;
if ( defined $meta->{table_name} and $table ne $meta->{table_name} )
{
$dbh->{sql_meta_map}{$table} = $meta->{table_name};
$table = $meta->{table_name};
}
# now we know a bit more - let's check if user can't use consequent spelling
# XXX add know issue about reset sql_identifier_case here ...
if ( defined $dbh->{sql_meta}{$table} )
{
$meta = delete $dbh->{sql_meta}{$table}; # avoid endless loop
$meta->{initialized}
or goto do_initialize;
#or $meta->{sql_data_source}->complete_table_name( $meta, $table, $respect_case, @other )
#or return;
}
unless ( $dbh->{sql_meta}{$table}{initialized} )
{
$self->init_table_meta( $dbh, $meta, $table );
$meta->{initialized} = 1;
$dbh->{sql_meta}{$table} = $meta;
}
}
return ( $table, $meta );
} # get_table_meta
my %reset_on_modify = ();
my %compat_map = ();
sub register_reset_on_modify
{
my ( $proto, $extra_resets ) = @_;
foreach my $cv ( keys %$extra_resets )
{
#%reset_on_modify = ( %reset_on_modify, %$extra_resets );
push @{ $reset_on_modify{$cv} },
ref $extra_resets->{$cv} ? @{ $extra_resets->{$cv} } : ( $extra_resets->{$cv} );
}
return;
} # register_reset_on_modify
sub register_compat_map
{
my ( $proto, $extra_compat_map ) = @_;
%compat_map = ( %compat_map, %$extra_compat_map );
return;
} # register_compat_map
sub get_table_meta_attr
{
my ( $class, $meta, $attrib ) = @_;
exists $compat_map{$attrib}
and $attrib = $compat_map{$attrib};
exists $meta->{$attrib}
and return $meta->{$attrib};
return;
} # get_table_meta_attr
sub set_table_meta_attr
{
my ( $class, $meta, $attrib, $value ) = @_;
exists $compat_map{$attrib}
and $attrib = $compat_map{$attrib};
$class->table_meta_attr_changed( $meta, $attrib, $value );
$meta->{$attrib} = $value;
} # set_table_meta_attr
sub table_meta_attr_changed
{
my ( $class, $meta, $attrib, $value ) = @_;
defined $reset_on_modify{$attrib}
and delete @$meta{ @{ $reset_on_modify{$attrib} } }
and $meta->{initialized} = 0;
} # table_meta_attr_changed
sub open_data
{
my ( $self, $meta, $attrs, $flags ) = @_;
$meta->{sql_data_source}
or croak "Table " . $meta->{table_name} . " not completely initialized";
$meta->{sql_data_source}->open_data( $meta, $attrs, $flags );
return;
} # open_data
# ====== SQL::Eval API =========================================================
sub new
{
my ( $className, $data, $attrs, $flags ) = @_;
my $dbh = $data->{Database};
my ( $tblnm, $meta ) = $className->get_table_meta( $dbh, $attrs->{table}, 1 )
or croak "Cannot find appropriate table '$attrs->{table}'";
$attrs->{table} = $tblnm;
# Being a bit dirty here, as SQL::Statement::Structure does not offer
# me an interface to the data I want
$flags->{createMode} && $data->{sql_stmt}{table_defs}
and $meta->{table_defs} = $data->{sql_stmt}{table_defs};
# open_file must be called before inherited new is invoked
# because column name mapping is initialized in constructor ...
$className->open_data( $meta, $attrs, $flags );
my $tbl = {
%{$attrs},
meta => $meta,
col_names => $meta->{col_names} || [],
};
return $className->SUPER::new($tbl);
} # new
sub DESTROY
{
my $self = shift;
my $meta = $self->{meta};
$self->{row} and undef $self->{row};
()
}
1;
=pod
=head1 NAME
DBI::DBD::SqlEngine - Base class for DBI drivers without their own SQL engine
=head1 SYNOPSIS
package DBD::myDriver;
use base qw(DBI::DBD::SqlEngine);
sub driver
{
...
my $drh = $proto->SUPER::driver($attr);
...
return $drh->{class};
}
package DBD::myDriver::dr;
@ISA = qw(DBI::DBD::SqlEngine::dr);
sub data_sources { ... }
...
package DBD::myDriver::db;
@ISA = qw(DBI::DBD::SqlEngine::db);
sub init_valid_attributes { ... }
sub init_default_attributes { ... }
sub set_versions { ... }
sub validate_STORE_attr { my ($dbh, $attrib, $value) = @_; ... }
sub validate_FETCH_attr { my ($dbh, $attrib) = @_; ... }
sub get_myd_versions { ... }
sub get_avail_tables { ... }
package DBD::myDriver::st;
@ISA = qw(DBI::DBD::SqlEngine::st);
sub FETCH { ... }
sub STORE { ... }
package DBD::myDriver::Statement;
@ISA = qw(DBI::DBD::SqlEngine::Statement);
sub open_table { ... }
package DBD::myDriver::Table;
@ISA = qw(DBI::DBD::SqlEngine::Table);
sub new { ... }
=head1 DESCRIPTION
DBI::DBD::SqlEngine abstracts the usage of SQL engines from the
DBD. DBD authors can concentrate on the data retrieval they want to
provide.
It is strongly recommended that you read L and
L, because many of the DBD::File API is provided
by DBI::DBD::SqlEngine.
Currently the API of DBI::DBD::SqlEngine is experimental and will
likely change in the near future to provide the table meta data basics
like DBD::File.
DBI::DBD::SqlEngine expects that any driver in inheritance chain has
a L.
=head2 Metadata
The following attributes are handled by DBI itself and not by
DBI::DBD::SqlEngine, thus they all work as expected:
Active
ActiveKids
CachedKids
CompatMode (Not used)
InactiveDestroy
AutoInactiveDestroy
Kids
PrintError
RaiseError
Warn (Not used)
=head3 The following DBI attributes are handled by DBI::DBD::SqlEngine:
=head4 AutoCommit
Always on.
=head4 ChopBlanks
Works.
=head4 NUM_OF_FIELDS
Valid after C<< $sth->execute >>.
=head4 NUM_OF_PARAMS
Valid after C<< $sth->prepare >>.
=head4 NAME
Valid after C<< $sth->execute >>; probably undef for Non-Select statements.
=head4 NULLABLE
Not really working, always returns an array ref of ones, as DBD::CSV
does not verify input data. Valid after C<< $sth->execute >>; undef for
non-select statements.
=head3 The following DBI attributes and methods are not supported:
=over 4
=item bind_param_inout
=item CursorName
=item LongReadLen
=item LongTruncOk
=back
=head3 DBI::DBD::SqlEngine specific attributes
In addition to the DBI attributes, you can use the following dbh
attributes:
=head4 sql_engine_version
Contains the module version of this driver (B)
=head4 sql_nano_version
Contains the module version of DBI::SQL::Nano (B)
=head4 sql_statement_version
Contains the module version of SQL::Statement, if available (B)
=head4 sql_handler
Contains the SQL Statement engine, either DBI::SQL::Nano or SQL::Statement
(B).
=head4 sql_parser_object
Contains an instantiated instance of SQL::Parser (B).
This is filled when used first time (only when used with SQL::Statement).
=head4 sql_sponge_driver
Contains an internally used DBD::Sponge handle (B).
=head4 sql_valid_attrs
Contains the list of valid attributes for each DBI::DBD::SqlEngine based
driver (B).
=head4 sql_readonly_attrs
Contains the list of those attributes which are readonly (B).
=head4 sql_identifier_case
Contains how DBI::DBD::SqlEngine deals with non-quoted SQL identifiers:
* SQL_IC_UPPER (1) means all identifiers are internally converted
into upper-cased pendants
* SQL_IC_LOWER (2) means all identifiers are internally converted
into lower-cased pendants
* SQL_IC_MIXED (4) means all identifiers are taken as they are
These conversions happen if (and only if) no existing identifier matches.
Once existing identifier is used as known.
The SQL statement execution classes doesn't have to care, so don't expect
C affects column names in statements like
SELECT * FROM foo
=head4 sql_quoted_identifier_case
Contains how DBI::DBD::SqlEngine deals with quoted SQL identifiers
(B). It's fixated to SQL_IC_SENSITIVE (3), which is interpreted
as SQL_IC_MIXED.
=head4 sql_flags
Contains additional flags to instantiate an SQL::Parser. Because an
SQL::Parser is instantiated only once, it's recommended to set this flag
before any statement is executed.
=head4 sql_dialect
Controls the dialect understood by SQL::Parser. Possible values (delivery
state of SQL::Statement):
* ANSI
* CSV
* AnyData
Defaults to "CSV". Because an SQL::Parser is instantiated only once and
SQL::Parser doesn't allow one to modify the dialect once instantiated,
it's strongly recommended to set this flag before any statement is
executed (best place is connect attribute hash).
=head4 sql_engine_in_gofer
This value has a true value in case of this driver is operated via
L. The impact of being operated via Gofer is a read-only
driver (not read-only databases!), so you cannot modify any attributes
later - neither any table settings. B you won't get an error in
cases you modify table attributes, so please carefully watch
C.
=head4 sql_meta
Private data area which contains information about the tables this
module handles. Table meta data might not be available until the
table has been accessed for the first time e.g., by issuing a select
on it however it is possible to pre-initialize attributes for each table
you use.
DBI::DBD::SqlEngine recognizes the (public) attributes C,
C, C, C and C.
Be very careful when modifying attributes you do not know, the consequence
might be a destroyed or corrupted table.
While C is a private and readonly attribute (which means, you
cannot modify it's values), derived drivers might provide restricted
write access through another attribute. Well known accessors are
C for L, C for L and
C for L.
=head4 sql_table_source
Controls the class which will be used for fetching available tables.
See L for details.
=head4 sql_data_source
Contains the class name to be used for opening tables.
See L for details.
=head2 Driver private methods
=head3 Default DBI methods
=head4 data_sources
The C method returns a list of subdirectories of the current
directory in the form "dbi:CSV:f_dir=$dirname".
If you want to read the subdirectories of another directory, use
my ($drh) = DBI->install_driver ("CSV");
my (@list) = $drh->data_sources (f_dir => "/usr/local/csv_data");
=head4 list_tables
This method returns a list of file names inside $dbh->{f_dir}.
Example:
my ($dbh) = DBI->connect ("dbi:CSV:f_dir=/usr/local/csv_data");
my (@list) = $dbh->func ("list_tables");
Note that the list includes all files contained in the directory, even
those that have non-valid table names, from the view of SQL.
=head3 Additional methods
The following methods are only available via their documented name when
DBI::DBD::SQlEngine is used directly. Because this is only reasonable for
testing purposes, the real names must be used instead. Those names can be
computed by replacing the C in the method name with the driver prefix.
=head4 sql_versions
Signature:
sub sql_versions (;$) {
my ($table_name) = @_;
$table_name ||= ".";
...
}
Returns the versions of the driver, including the DBI version, the Perl
version, DBI::PurePerl version (if DBI::PurePerl is active) and the version
of the SQL engine in use.
my $dbh = DBI->connect ("dbi:File:");
my $sql_versions = $dbh->func( "sql_versions" );
print "$sql_versions\n";
__END__
# DBI::DBD::SqlEngine 0.05 using SQL::Statement 1.402
# DBI 1.623
# OS netbsd (6.99.12)
# Perl 5.016002 (x86_64-netbsd-thread-multi)
Called in list context, sql_versions will return an array containing each
line as single entry.
Some drivers might use the optional (table name) argument and modify
version information related to the table (e.g. DBD::DBM provides storage
backend information for the requested table, when it has a table name).
=head4 sql_get_meta
Signature:
sub sql_get_meta ($$)
{
my ($table_name, $attrib) = @_;
...
}
Returns the value of a meta attribute set for a specific table, if any.
See L for the possible attributes.
A table name of C<"."> (single dot) is interpreted as the default table.
This will retrieve the appropriate attribute globally from the dbh.
This has the same restrictions as C<< $dbh->{$attrib} >>.
=head4 sql_set_meta
Signature:
sub sql_set_meta ($$$)
{
my ($table_name, $attrib, $value) = @_;
...
}
Sets the value of a meta attribute set for a specific table.
See L for the possible attributes.
A table name of C<"."> (single dot) is interpreted as the default table
which will set the specified attribute globally for the dbh.
This has the same restrictions as C<< $dbh->{$attrib} = $value >>.
=head4 sql_clear_meta
Signature:
sub sql_clear_meta ($)
{
my ($table_name) = @_;
...
}
Clears the table specific meta information in the private storage of the
dbh.
=head2 Extensibility
=head3 DBI::DBD::SqlEngine::TableSource
Provides data sources and table information on database driver and database
handle level.
package DBI::DBD::SqlEngine::TableSource;
sub data_sources ($;$)
{
my ( $class, $drh, $attrs ) = @_;
...
}
sub avail_tables
{
my ( $class, $drh ) = @_;
...
}
The C method is called when the user invokes any of the
following:
@ary = DBI->data_sources($driver);
@ary = DBI->data_sources($driver, \%attr);
@ary = $dbh->data_sources();
@ary = $dbh->data_sources(\%attr);
The C method is called when the user invokes any of the
following:
@names = $dbh->tables( $catalog, $schema, $table, $type );
$sth = $dbh->table_info( $catalog, $schema, $table, $type );
$sth = $dbh->table_info( $catalog, $schema, $table, $type, \%attr );
$dbh->func( "list_tables" );
Every time where an C<\%attr> argument can be specified, this C<\%attr>
object's C attribute is preferred over the C<$dbh>
attribute or the driver default, eg.
@ary = DBI->data_sources("dbi:CSV:", {
f_dir => "/your/csv/tables",
# note: this class doesn't comes with DBI
sql_table_source => "DBD::File::Archive::Tar::TableSource",
# scan tarballs instead of directories
});
When you're going to implement such a DBD::File::Archive::Tar::TableSource
class, remember to add correct attributes (including C
and C) to the returned DSN's.
=head3 DBI::DBD::SqlEngine::DataSource
Provides base functionality for dealing with tables. It is primarily
designed for allowing transparent access to files on disk or already
opened (file-)streams (eg. for DBD::CSV).
Derived classes shall be restricted to similar functionality, too (eg.
opening streams from an archive, transparently compress/uncompress
log files before parsing them,
package DBI::DBD::SqlEngine::DataSource;
sub complete_table_name ($$;$)
{
my ( $self, $meta, $table, $respect_case ) = @_;
...
}
The method C is called when first setting up the
I for a table:
"SELECT user.id, user.name, user.shell FROM user WHERE ..."
results in opening the table C. First step of the table open
process is completing the name. Let's imagine you're having a L
handle with following settings:
$dbh->{sql_identifier_case} = SQL_IC_LOWER;
$dbh->{f_ext} = '.lst';
$dbh->{f_dir} = '/data/web/adrmgr';
Those settings will result in looking for files matching
C<[Uu][Ss][Ee][Rr](\.lst)?$> in C. The scanning of the
directory C and the pattern match check will be done
in C by the C method.
If you intend to provide other sources of data streams than files, in
addition to provide an appropriate C method, a method
to open the resource is required:
package DBI::DBD::SqlEngine::DataSource;
sub open_data ($)
{
my ( $self, $meta, $attrs, $flags ) = @_;
...
}
After the method C has been run successfully, the table's meta
information are in a state which allowes the table's data accessor methods
will be able to fetch/store row information. Implementation details heavily
depends on the table implementation, whereby the most famous is surely
L.
=head1 SQL ENGINES
DBI::DBD::SqlEngine currently supports two SQL engines:
L and
L. DBI::SQL::Nano supports a
I limited subset of SQL statements, but it might be faster for some
very simple tasks. SQL::Statement in contrast supports a much larger subset
of ANSI SQL.
To use SQL::Statement, you need at least version 1.401 of
SQL::Statement and the environment variable C must not
be set to a true value.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc DBI::DBD::SqlEngine
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker
L
L
=item * AnnoCPAN: Annotated CPAN documentation
L
L
=item * CPAN Ratings
L
=item * Search CPAN
L
=back
=head2 Where can I go for more help?
For questions about installation or usage, please ask on the
dbi-dev@perl.org mailing list.
If you have a bug report, patch or suggestion, please open
a new report ticket on CPAN, if there is not already one for
the issue you want to report. Of course, you can mail any of the
module maintainers, but it is less likely to be missed if
it is reported on RT.
Report tickets should contain a detailed description of the bug or
enhancement request you want to report and at least an easy way to
verify/reproduce the issue and any supplied fix. Patches are always
welcome, too.
=head1 ACKNOWLEDGEMENTS
Thanks to Tim Bunce, Martin Evans and H.Merijn Brand for their continued
support while developing DBD::File, DBD::DBM and DBD::AnyData.
Their support, hints and feedback helped to design and implement this
module.
=head1 AUTHOR
This module is currently maintained by
H.Merijn Brand < h.m.brand at xs4all.nl > and
Jens Rehsack < rehsack at googlemail.com >
The original authors are Jochen Wiedmann and Jeff Zucker.
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2009-2013 by H.Merijn Brand & Jens Rehsack
Copyright (C) 2004-2009 by Jeff Zucker
Copyright (C) 1998-2004 by Jochen Wiedmann
All rights reserved.
You may freely distribute and/or modify this module under the terms of
either the GNU General Public License (GPL) or the Artistic License, as
specified in the Perl README file.
=head1 SEE ALSO
L, L, L and L.
=cut
PK ]`yj j DBD/SqlEngine/Developers.podnu [ =head1 NAME
DBI::DBD::SqlEngine::Developers - Developers documentation for DBI::DBD::SqlEngine
=head1 SYNOPSIS
package DBD::myDriver;
use base qw(DBI::DBD::SqlEngine);
sub driver
{
...
my $drh = $proto->SUPER::driver($attr);
...
return $drh->{class};
}
sub CLONE { ... }
package DBD::myDriver::dr;
@ISA = qw(DBI::DBD::SqlEngine::dr);
sub data_sources { ... }
...
package DBD::myDriver::db;
@ISA = qw(DBI::DBD::SqlEngine::db);
sub init_valid_attributes { ... }
sub init_default_attributes { ... }
sub set_versions { ... }
sub validate_STORE_attr { my ($dbh, $attrib, $value) = @_; ... }
sub validate_FETCH_attr { my ($dbh, $attrib) = @_; ... }
sub get_myd_versions { ... }
sub get_avail_tables { ... }
package DBD::myDriver::st;
@ISA = qw(DBI::DBD::SqlEngine::st);
sub FETCH { ... }
sub STORE { ... }
package DBD::myDriver::Statement;
@ISA = qw(DBI::DBD::SqlEngine::Statement);
sub open_table { ... }
package DBD::myDriver::Table;
@ISA = qw(DBI::DBD::SqlEngine::Table);
my %reset_on_modify = (
myd_abc => "myd_foo",
myd_mno => "myd_bar",
);
__PACKAGE__->register_reset_on_modify( \%reset_on_modify );
my %compat_map = (
abc => 'foo_abc',
xyz => 'foo_xyz',
);
__PACKAGE__->register_compat_map( \%compat_map );
sub bootstrap_table_meta { ... }
sub init_table_meta { ... }
sub table_meta_attr_changed { ... }
sub open_data { ... }
sub new { ... }
sub fetch_row { ... }
sub push_row { ... }
sub push_names { ... }
sub seek { ... }
sub truncate { ... }
sub drop { ... }
# optimize the SQL engine by add one or more of
sub update_current_row { ... }
# or
sub update_specific_row { ... }
# or
sub update_one_row { ... }
# or
sub insert_new_row { ... }
# or
sub delete_current_row { ... }
# or
sub delete_one_row { ... }
=head1 DESCRIPTION
This document describes the interface of DBI::DBD::SqlEngine for DBD
developers who write DBI::DBD::SqlEngine based DBI drivers. It supplements
L and L, which you should read first.
=head1 CLASSES
Each DBI driver must provide a package global C<< driver >> method and
three DBI related classes:
=over 4
=item DBI::DBD::SqlEngine::dr
Driver package, contains the methods DBI calls indirectly via DBI
interface:
DBI->connect ('DBI:DBM:', undef, undef, {})
# invokes
package DBD::DBM::dr;
@DBD::DBM::dr::ISA = qw(DBI::DBD::SqlEngine::dr);
sub connect ($$;$$$)
{
...
}
Similar for C and C.
Pure Perl DBI drivers derived from DBI::DBD::SqlEngine usually don't need to
override any of the methods provided through the DBD::XXX::dr package.
However if you need additional initialization not fitting in
C and C of you're ::db
class, the connect method might be the final place to be modified.
=item DBI::DBD::SqlEngine::db
Contains the methods which are called through DBI database handles
(C<< $dbh >>). e.g.,
$sth = $dbh->prepare ("select * from foo");
# returns the f_encoding setting for table foo
$dbh->csv_get_meta ("foo", "f_encoding");
DBI::DBD::SqlEngine provides the typical methods required here. Developers who
write DBI drivers based on DBI::DBD::SqlEngine need to override the methods
C<< set_versions >> and C<< init_valid_attributes >>.
=item DBI::DBD::SqlEngine::TieMeta;
Provides the tie-magic for C<< $dbh->{$drv_pfx . "_meta"} >>. Routes
C through C<< $drv->set_sql_engine_meta() >> and C through
C<< $drv->get_sql_engine_meta() >>. C is not supported, you have
to execute a C statement, where applicable.
=item DBI::DBD::SqlEngine::TieTables;
Provides the tie-magic for tables in C<< $dbh->{$drv_pfx . "_meta"} >>.
Routes C though C<< $tblClass->set_table_meta_attr() >> and C
though C<< $tblClass->get_table_meta_attr() >>. C removes an
attribute from the I retrieved by
C<< $tblClass->get_table_meta() >>.
=item DBI::DBD::SqlEngine::st
Contains the methods to deal with prepared statement handles. e.g.,
$sth->execute () or die $sth->errstr;
=item DBI::DBD::SqlEngine::TableSource;
Base class for 3rd party table sources:
$dbh->{sql_table_source} = "DBD::Foo::TableSource";
=item DBI::DBD::SqlEngine::DataSource;
Base class for 3rd party data sources:
$dbh->{sql_data_source} = "DBD::Foo::DataSource";
=item DBI::DBD::SqlEngine::Statement;
Base class for derived drivers statement engine. Implements C.
=item DBI::DBD::SqlEngine::Table;
Contains tailoring between SQL engine's requirements and
C magic for finding the right tables and storage.
Builds bridges between C handling of C,
table initialization for SQL engines and I's attribute
management for derived drivers.
=back
=head2 DBI::DBD::SqlEngine
This is the main package containing the routines to initialize
DBI::DBD::SqlEngine based DBI drivers. Primarily the
C<< DBI::DBD::SqlEngine::driver >> method is invoked, either directly
from DBI when the driver is initialized or from the derived class.
package DBD::DBM;
use base qw( DBI::DBD::SqlEngine );
sub driver
{
my ( $class, $attr ) = @_;
...
my $drh = $class->SUPER::driver( $attr );
...
return $drh;
}
It is not necessary to implement your own driver method as long as
additional initialization (e.g. installing more private driver
methods) is not required. You do not need to call C<< setup_driver >>
as DBI::DBD::SqlEngine takes care of it.
=head2 DBI::DBD::SqlEngine::dr
The driver package contains the methods DBI calls indirectly via the DBI
interface (see L).
DBI::DBD::SqlEngine based DBI drivers usually do not need to implement anything here,
it is enough to do the basic initialization:
package DBD:XXX::dr;
@DBD::XXX::dr::ISA = qw (DBI::DBD::SqlEngine::dr);
$DBD::XXX::dr::imp_data_size = 0;
$DBD::XXX::dr::data_sources_attr = undef;
$DBD::XXX::ATTRIBUTION = "DBD::XXX $DBD::XXX::VERSION by Hans Mustermann";
=head3 Methods provided by C<< DBI::DBD::SqlEngine::dr >>:
=over 4
=item connect
Supervises the driver bootstrap when calling
DBI->connect( "dbi:Foo", , , { ... } );
First it instantiates a new driver using C. After that,
initial bootstrap of the newly instantiated driver is done by
$dbh->func( 0, "init_default_attributes" );
The first argument (C<0>) signals that this is the very first call to
C. Modern drivers understand that and do early
stage setup here after calling
package DBD::Foo::db;
our @DBD::Foo::db::ISA = qw(DBI::DBD::SqlEngine::db);
sub init_default_attributes
{
my ($dbh, $phase) = @_;
$dbh->SUPER::init_default_attributes($phase);
...; # own setup code, maybe separated by phases
}
When the C<$phase> argument is passed down until
C, C recognizes
a I driver and initializes the attributes from I and I<$attr>
arguments passed via C<< DBI->connect( $dsn, $user, $pass, \%attr ) >>.
At the end of the attribute initialization after I, C
invoked C again for I:
$dbh->func( 1, "init_default_attributes" );
=item data_sources
Returns a list of I's using the C method of the
class specified in C<< $dbh->{sql_table_source} >> or via C<\%attr>:
@ary = DBI->data_sources($driver);
@ary = DBI->data_sources($driver, \%attr);
=item disconnect_all
C doesn't have an overall driver cache, so nothing
happens here at all.
=back
=head2 DBI::DBD::SqlEngine::db
This package defines the database methods, which are called via the DBI
database handle C<< $dbh >>.
=head3 Methods provided by C<< DBI::DBD::SqlEngine::db >>:
=over 4
=item ping
Simply returns the content of the C<< Active >> attribute. Override
when your driver needs more complicated actions here.
=item prepare
Prepares a new SQL statement to execute. Returns a statement handle,
C<< $sth >> - instance of the DBD:XXX::st. It is neither required nor
recommended to override this method.
=item validate_FETCH_attr
Called by C to allow inherited drivers do their own attribute
name validation. Calling convention is similar to C and the
return value is the approved attribute name.
return $validated_attribute_name;
In case of validation fails (e.g. accessing private attribute or similar),
C is permitted to throw an exception.
=item FETCH
Fetches an attribute of a DBI database object. Private handle attributes
must have a prefix (this is mandatory). If a requested attribute is
detected as a private attribute without a valid prefix, the driver prefix
(written as C<$drv_prefix>) is added.
The driver prefix is extracted from the attribute name and verified against
C<< $dbh->{ $drv_prefix . "valid_attrs" } >> (when it exists). If the
requested attribute value is not listed as a valid attribute, this method
croaks. If the attribute is valid and readonly (listed in C<< $dbh->{
$drv_prefix . "readonly_attrs" } >> when it exists), a real copy of the
attribute value is returned. So it's not possible to modify
C from outside of DBI::DBD::SqlEngine::db or a derived class.
=item validate_STORE_attr
Called by C to allow inherited drivers do their own attribute
name validation. Calling convention is similar to C and the
return value is the approved attribute name followed by the approved
new value.
return ($validated_attribute_name, $validated_attribute_value);
In case of validation fails (e.g. accessing private attribute or similar),
C is permitted to throw an exception
(C throws an exception when
someone tries to assign value other than C
to C<< $dbh->{sql_identifier_case} >> or
C<< $dbh->{sql_quoted_identifier_case} >>).
=item STORE
Stores a database private attribute. Private handle attributes must have a
prefix (this is mandatory). If a requested attribute is detected as a private
attribute without a valid prefix, the driver prefix (written as
C<$drv_prefix>) is added. If the database handle has an attribute
C<${drv_prefix}_valid_attrs> - for attribute names which are not listed in
that hash, this method croaks. If the database handle has an attribute
C<${drv_prefix}_readonly_attrs>, only attributes which are not listed there
can be stored (once they are initialized). Trying to overwrite such an
immutable attribute forces this method to croak.
An example of a valid attributes list can be found in
C<< DBI::DBD::SqlEngine::db::init_valid_attributes >>.
=item set_versions
This method sets the attributes C<< f_version >>, C<< sql_nano_version >>,
C<< sql_statement_version >> and (if not prohibited by a restrictive
C<< ${prefix}_valid_attrs >>) C<< ${prefix}_version >>.
This method is called at the end of the C<< connect () >> phase.
When overriding this method, do not forget to invoke the superior one.
=item init_valid_attributes
This method is called after the database handle is instantiated as the
first attribute initialization.
C<< DBI::DBD::SqlEngine::db::init_valid_attributes >> initializes the
attributes C and C.
When overriding this method, do not forget to invoke the superior one,
preferably before doing anything else.
=item init_default_attributes
This method is called after the database handle is instantiated to
initialize the default attributes. It expects one argument: C<$phase>.
If C<$phase> is not given, C of C
expects this is an old-fashioned driver which isn't capable of multi-phased
initialization.
C<< DBI::DBD::SqlEngine::db::init_default_attributes >> initializes the
attributes C, C,
C, C, C, C,
C and C when L
is available.
It sets C to the given C<$phase>.
When the derived implementor class provides the attribute to validate
attributes (e.g. C<< $dbh->{dbm_valid_attrs} = {...}; >>) or the attribute
containing the immutable attributes (e.g. C<< $dbh->{dbm_readonly_attrs}
= {...}; >>), the attributes C, C and
C are added (when available) to the list of valid and
immutable attributes (where C is interpreted as the driver prefix).
=item get_versions
This method is called by the code injected into the instantiated driver to
provide the user callable driver method C<< ${prefix}versions >> (e.g.
C<< dbm_versions >>, C<< csv_versions >>, ...).
The DBI::DBD::SqlEngine implementation returns all version information known by
DBI::DBD::SqlEngine (e.g. DBI version, Perl version, DBI::DBD::SqlEngine version and
the SQL handler version).
C takes the C<$dbh> as the first argument and optionally a
second argument containing a table name. The second argument is not
evaluated in C<< DBI::DBD::SqlEngine::db::get_versions >> itself - but
might be in the future.
If the derived implementor class provides a method named
C, this is invoked and the return value of
it is associated to the derived driver name:
if (my $dgv = $dbh->{ImplementorClass}->can ("get_" . $drv_prefix . "versions") {
(my $derived_driver = $dbh->{ImplementorClass}) =~ s/::db$//;
$versions{$derived_driver} = &$dgv ($dbh, $table);
}
Override it to add more version information about your module, (e.g.
some kind of parser version in case of DBD::CSV, ...), if one line is not
enough room to provide all relevant information.
=item sql_parser_object
Returns a L instance, when C<< sql_handler >> is set to
"SQL::Statement". The parser instance is stored in C<< sql_parser_object >>.
It is not recommended to override this method.
=item disconnect
Disconnects from a database. All local table information is discarded and
the C<< Active >> attribute is set to 0.
=item type_info_all
Returns information about all the types supported by DBI::DBD::SqlEngine.
=item table_info
Returns a statement handle which is prepared to deliver information about
all known tables.
=item list_tables
Returns a list of all known table names.
=item quote
Quotes a string for use in SQL statements.
=item commit
Warns about a useless call (if warnings enabled) and returns.
DBI::DBD::SqlEngine is typically a driver which commits every action
instantly when executed.
=item rollback
Warns about a useless call (if warnings enabled) and returns.
DBI::DBD::SqlEngine is typically a driver which commits every action
instantly when executed.
=back
=head3 Attributes used by C<< DBI::DBD::SqlEngine::db >>:
This section describes attributes which are important to developers of DBI
Database Drivers derived from C.
=over 4
=item sql_init_order
This attribute contains a hash with priorities as key and an array
containing the C<$dbh> attributes to be initialized during before/after
other attributes.
C initializes following attributes:
$dbh->{sql_init_order} = {
0 => [qw( Profile RaiseError PrintError AutoCommit )],
90 => [ "sql_meta", $dbh->{$drv_pfx_meta} ? $dbh->{$drv_pfx_meta} : () ]
}
The default priority of not listed attribute keys is C<50>. It is well
known that a lot of attributes needed to be set before some table settings
are initialized. For example, for L, when using
my $dbh = DBI->connect( "dbi:DBM:", undef, undef, {
f_dir => "/path/to/dbm/databases",
dbm_type => "BerkeleyDB",
dbm_mldbm => "JSON", # use MLDBM::Serializer::JSON
dbm_tables => {
quick => {
dbm_type => "GDBM_File",
dbm_MLDBM => "FreezeThaw"
}
}
});
This defines a known table C which uses the L backend and
L as serializer instead of the overall default L and
L. B all files containing the table data have to be searched in
C<< $dbh->{f_dir} >>, which requires C<< $dbh->{f_dir} >> must be initialized
before C<< $dbh->{sql_meta}->{quick} >> is initialized by
C method of L to get
C<< $dbh->{sql_meta}->{quick}->{f_dir} >> being initialized properly.
=item sql_init_phase
This attribute is only set during the initialization steps of the DBI
Database Driver. It contains the value of the currently run initialization
phase. Currently supported phases are I and I. This
attribute is set in C and removed in C.
=item sql_engine_in_gofer
This value has a true value in case of this driver is operated via
L. The impact of being operated via Gofer is a read-only
driver (not read-only databases!), so you cannot modify any attributes
later - neither any table settings. B you won't get an error in
cases you modify table attributes, so please carefully watch
C.
=item sql_table_source
Names a class which is responsible for delivering I and
I (Database Driver related). I here
refers to L, not C.
See L for details.
=item sql_data_source
Name a class which is responsible for handling table resources open
and completing table names requested via SQL statements.
See L for details.
=item sql_dialect
Controls the dialect understood by SQL::Parser. Possible values (delivery
state of SQL::Statement):
* ANSI
* CSV
* AnyData
Defaults to "CSV". Because an SQL::Parser is instantiated only once and
SQL::Parser doesn't allow one to modify the dialect once instantiated,
it's strongly recommended to set this flag before any statement is
executed (best place is connect attribute hash).
=back
=head2 DBI::DBD::SqlEngine::st
Contains the methods to deal with prepared statement handles:
=over 4
=item bind_param
Common routine to bind placeholders to a statement for execution. It
is dangerous to override this method without detailed knowledge about
the DBI::DBD::SqlEngine internal storage structure.
=item execute
Executes a previously prepared statement (with placeholders, if any).
=item finish
Finishes a statement handle, discards all buffered results. The prepared
statement is not discarded so the statement can be executed again.
=item fetch
Fetches the next row from the result-set. This method may be rewritten
in a later version and if it's overridden in a derived class, the
derived implementation should not rely on the storage details.
=item fetchrow_arrayref
Alias for C<< fetch >>.
=item FETCH
Fetches statement handle attributes. Supported attributes (for full overview
see L) are C, C, C
and C. Each column is returned as C which might be wrong
depending on the derived backend storage. If the statement handle has
private attributes, they can be fetched using this method, too. B that
statement attributes are not associated with any table used in this statement.
This method usually requires extending in a derived implementation.
See L or L for some example.
=item STORE
Allows storing of statement private attributes. No special handling is
currently implemented here.
=item rows
Returns the number of rows affected by the last execute. This method might
return C.
=back
=head2 DBI::DBD::SqlEngine::TableSource
Provides data sources and table information on database driver and database
handle level.
package DBI::DBD::SqlEngine::TableSource;
sub data_sources ($;$)
{
my ( $class, $drh, $attrs ) = @_;
...
}
sub avail_tables
{
my ( $class, $drh ) = @_;
...
}
The C method is called when the user invokes any of the
following:
@ary = DBI->data_sources($driver);
@ary = DBI->data_sources($driver, \%attr);
@ary = $dbh->data_sources();
@ary = $dbh->data_sources(\%attr);
The C method is called when the user invokes any of the
following:
@names = $dbh->tables( $catalog, $schema, $table, $type );
$sth = $dbh->table_info( $catalog, $schema, $table, $type );
$sth = $dbh->table_info( $catalog, $schema, $table, $type, \%attr );
$dbh->func( "list_tables" );
Every time where an C<\%attr> argument can be specified, this C<\%attr>
object's C attribute is preferred over the C<$dbh>
attribute or the driver default.
=head2 DBI::DBD::SqlEngine::DataSource
Provides base functionality for dealing with tables. It is primarily
designed for allowing transparent access to files on disk or already
opened (file-)streams (e.g. for DBD::CSV).
Derived classes shall be restricted to similar functionality, too (e.g.
opening streams from an archive, transparently compress/uncompress
log files before parsing them,
package DBI::DBD::SqlEngine::DataSource;
sub complete_table_name ($$;$)
{
my ( $self, $meta, $table, $respect_case ) = @_;
...
}
The method C is called when first setting up the
I for a table:
"SELECT user.id, user.name, user.shell FROM user WHERE ..."
results in opening the table C. First step of the table open
process is completing the name. Let's imagine you're having a L
handle with following settings:
$dbh->{sql_identifier_case} = SQL_IC_LOWER;
$dbh->{f_ext} = '.lst';
$dbh->{f_dir} = '/data/web/adrmgr';
Those settings will result in looking for files matching
C<[Uu][Ss][Ee][Rr](\.lst)?$> in C. The scanning of the
directory C and the pattern match check will be done
in C by the C method.
If you intend to provide other sources of data streams than files, in
addition to provide an appropriate C method, a method
to open the resource is required:
package DBI::DBD::SqlEngine::DataSource;
sub open_data ($)
{
my ( $self, $meta, $attrs, $flags ) = @_;
...
}
After the method C has been run successfully, the table's meta
information are in a state which allows the table's data accessor methods
will be able to fetch/store row information. Implementation details heavily
depends on the table implementation, whereby the most famous is surely
L.
=head2 DBI::DBD::SqlEngine::Statement
Derives from DBI::SQL::Nano::Statement for unified naming when deriving
new drivers. No additional feature is provided from here.
=head2 DBI::DBD::SqlEngine::Table
Derives from DBI::SQL::Nano::Table for unified naming when deriving
new drivers.
You should consult the documentation of C<< SQL::Eval::Table >> (see
L) to get more information about the abstract methods of the
table's base class you have to override and a description of the table
meta information expected by the SQL engines.
=over 4
=item bootstrap_table_meta
Initializes a table meta structure. Can be safely overridden in a
derived class, as long as the C<< SUPER >> method is called at the end
of the overridden method.
It copies the following attributes from the database into the table meta data
C<< $dbh->{ReadOnly} >> into C<< $meta->{readonly} >>, C
and C and makes them sticky to the table.
This method should be called before you attempt to map between file
name and table name to ensure the correct directory, extension etc. are
used.
=item init_table_meta
Initializes more attributes of the table meta data - usually more
expensive ones (e.g. those which require class instantiations) - when
the file name and the table name could mapped.
=item get_table_meta
Returns the table meta data. If there are none for the required table,
a new one is initialized. When after bootstrapping a new I
and L a
mapping can be established between an existing I and the
new bootstrapped one, the already existing is used and a mapping
shortcut between the recent used table name and the already known
table name is hold in C<< $dbh->{sql_meta_map} >>. When it fails,
nothing is returned. On success, the name of the table and the meta data
structure is returned.
=item get_table_meta_attr
Returns a single attribute from the table meta data. If the attribute
name appears in C<%compat_map>, the attribute name is updated from
there.
=item set_table_meta_attr
Sets a single attribute in the table meta data. If the attribute
name appears in C<%compat_map>, the attribute name is updated from
there.
=item table_meta_attr_changed
Called when an attribute of the meta data is modified.
If the modified attribute requires to reset a calculated attribute, the
calculated attribute is reset (deleted from meta data structure) and
the I flag is removed, too. The decision is made based on
C<%register_reset_on_modify>.
=item register_reset_on_modify
Allows C to reset meta attributes when special
attributes are modified. For DBD::File, modifying one of C, C,
C or C will reset C. DBD::DBM extends the
list for C and C to reset the value of C.
If your DBD has calculated values in the meta data area, then call
C:
my %reset_on_modify = ( "xxx_foo" => "xxx_bar" );
__PACKAGE__->register_reset_on_modify( \%reset_on_modify );
=item register_compat_map
Allows C and C to update the
attribute name to the current favored one:
# from DBD::DBM
my %compat_map = ( "dbm_ext" => "f_ext" );
__PACKAGE__->register_compat_map( \%compat_map );
=item open_data
Called to open the table's data storage. This is silently forwarded
to C<< $meta->{sql_data_source}->open_data() >>.
After this is done, a derived class might add more steps in an overridden
C<< open_file >> method.
=item new
Instantiates the table. This is done in 3 steps:
1. get the table meta data
2. open the data file
3. bless the table data structure using inherited constructor new
It is not recommended to override the constructor of the table class.
Find a reasonable place to add you extensions in one of the above four
methods.
=back
=head1 AUTHOR
The module DBI::DBD::SqlEngine is currently maintained by
H.Merijn Brand < h.m.brand at xs4all.nl > and
Jens Rehsack < rehsack at googlemail.com >
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2010 by H.Merijn Brand & Jens Rehsack
All rights reserved.
You may freely distribute and/or modify this module under the terms of
either the GNU General Public License (GPL) or the Artistic License, as
specified in the Perl README file.
=cut
PK ]SK* K* DBD/SqlEngine/HowTo.podnu [ =head1 NAME
DBI::DBD::SqlEngine::HowTo - Guide to create DBI::DBD::SqlEngine based driver
=head1 SYNOPSIS
perldoc DBI::DBD::SqlEngine::HowTo
perldoc DBI
perldoc DBI::DBD
perldoc DBI::DBD::SqlEngine::Developers
perldoc SQL::Eval
perldoc DBI::DBD::SqlEngine
perldoc DBI::DBD::SqlEngine::HowTo
perldoc SQL::Statement::Embed
=head1 DESCRIPTION
This document provides a step-by-step guide, how to create a new
C based DBD. It expects that you carefully read the
L documentation and that you're familiar with L and had
read and understood L.
This document addresses experienced developers who are really sure that
they need to invest time when writing a new DBI Driver. Writing a DBI
Driver is neither a weekend project nor an easy job for hobby coders
after work. Expect one or two man-month of time for the first start.
Those who are still reading, should be able to sing the rules of
L.
=head1 CREATING DRIVER CLASSES
Do you have an entry in DBI's DBD registry? DBI::DBD::SqlEngine expect
having a unique prefix for every driver class in inheritance chain.
It's easy to get a prefix - just drop the DBI team a note
(L). If you want for some reason hide your work, take
a look at L how to wrap a private prefix method
around existing C.
For this guide, a prefix of C is assumed.
=head2 Sample Skeleton
package DBD::Foo;
use strict;
use warnings;
use vars qw($VERSION);
use base qw(DBI::DBD::SqlEngine);
use DBI ();
$VERSION = "0.001";
package DBD::Foo::dr;
use vars qw(@ISA $imp_data_size);
@ISA = qw(DBI::DBD::SqlEngine::dr);
$imp_data_size = 0;
package DBD::Foo::db;
use vars qw(@ISA $imp_data_size);
@ISA = qw(DBI::DBD::SqlEngine::db);
$imp_data_size = 0;
package DBD::Foo::st;
use vars qw(@ISA $imp_data_size);
@ISA = qw(DBI::DBD::SqlEngine::st);
$imp_data_size = 0;
package DBD::Foo::Statement;
use vars qw(@ISA);
@ISA = qw(DBI::DBD::SqlEngine::Statement);
package DBD::Foo::Table;
use vars qw(@ISA);
@ISA = qw(DBI::DBD::SqlEngine::Table);
1;
Tiny, eh? And all you have now is a DBD named foo which will is able to
deal with temporary tables, as long as you use L. In
L environments, this DBD can do nothing.
=head2 Deal with own attributes
Before we start doing usable stuff with our DBI driver, we need to think
about what we want to do and how we want to do it.
Do we need tunable knobs accessible by users? Do we need status
information? All this is handled in attributes of the database handles (be
careful when your DBD is running "behind" a L proxy).
How come the attributes into the DBD and how are they fetchable by the
user? Good question, but you should know because you've read the L
documentation.
C and C
taking care for you - all they need to know is which attribute names
are valid and mutable or immutable. Tell them by adding
C to your db class:
sub init_valid_attributes
{
my $dbh = $_[0];
$dbh->SUPER::init_valid_attributes ();
$dbh->{foo_valid_attrs} = {
foo_version => 1, # contains version of this driver
foo_valid_attrs => 1, # contains the valid attributes of foo drivers
foo_readonly_attrs => 1, # contains immutable attributes of foo drivers
foo_bar => 1, # contains the bar attribute
foo_baz => 1, # contains the baz attribute
foo_manager => 1, # contains the manager of the driver instance
foo_manager_type => 1, # contains the manager class of the driver instance
};
$dbh->{foo_readonly_attrs} = {
foo_version => 1, # ensure no-one modifies the driver version
foo_valid_attrs => 1, # do not permit one to add more valid attributes ...
foo_readonly_attrs => 1, # ... or make the immutable mutable
foo_manager => 1, # manager is set internally only
};
return $dbh;
}
Woooho - but now the user cannot assign new managers? This is intended,
overwrite C to handle it!
sub STORE ($$$)
{
my ( $dbh, $attrib, $value ) = @_;
$dbh->SUPER::STORE( $attrib, $value );
# we're still alive, so no exception is thrown ...
# by DBI::DBD::SqlEngine::db::STORE
if ( $attrib eq "foo_manager_type" )
{
$dbh->{foo_manager} = $dbh->{foo_manager_type}->new();
# ... probably correct some states based on the new
# foo_manager_type - see DBD::Sys for an example
}
}
But ... my driver runs without a manager until someone first assignes
a C. Well, no - there're two places where you can
initialize defaults:
sub init_default_attributes
{
my ($dbh, $phase) = @_;
$dbh->SUPER::init_default_attributes($phase);
if( 0 == $phase )
{
# init all attributes which have no knowledge about
# user settings from DSN or the attribute hash
$dbh->{foo_manager_type} = "DBD::Foo::Manager";
}
elsif( 1 == $phase )
{
# init phase with more knowledge from DSN or attribute
# hash
$dbh->{foo_manager} = $dbh->{foo_manager_type}->new();
}
return $dbh;
}
So far we can prevent the users to use our database driver as data
storage for anything and everything. We care only about the real important
stuff for peace on earth and alike attributes. But in fact, the driver
still can't do anything. It can do less than nothing - meanwhile it's
not a stupid storage area anymore.
=head2 User comfort
C since C<0.05> consolidates all persistent meta data
of a table into a single structure stored in C<< $dbh->{sql_meta} >>. While
DBI::DBD::SqlEngine provides only readonly access to this structure,
modifications are still allowed.
Primarily DBI::DBD::SqlEngine provides access via the setters
C, C