*** Changes for DBI v2 ***

--- Changes that may impact applications:

Turning AutoCommit on should trigger rollback not commit.
(ODBC does a commit) This will break code that assumes a commit.

Always taint check the $sql for do() and prepare()
if perl is in taint mode (can't be disabled).
Default TaintIn=>1 in perl taint mode?
Default TaintOut=>1 in perl taint mode but exclude placeholders?

Remove support for "old-style" connect syntax
(where the driver name is the 4th parameter).

Remove undocumented DBI->err and DBI->errstr methods.

Remove old informix fudge in tables() (would only impact people
using very old DBD::Informix versions as it now has it's own).

Increase size of com struct (requires driver rebuild)
and improve size sanity checks.


--- Additions and other changes visible to applications:

Make ShowErrorStatement=>1 the default

Define expected uft8 behaviour. Basically drivers need to set the
uft8 flag on returned strings themselves when appropriate.
The DBI I<may> define a way for an application to indicate that
a particular column should be flagged as uft8 to help drivers
that are not able to determine that themselves.
The DBI won't support automatic character set conversions.

Define "topic bits" for TraceLevel.
%DBI::TraceTopics & %DBD::Foo::TraceTopics
"Lint" topic for extra checking, eg warn on $sth DESTROY if still Active
"Verbose" topic adds verbosity to any other enabled topics
Change macro to get debug level to only return last 4 bits.
Add macro framework for 'topic' bits.
Use one bit for logging just the SQL statement executed
(with no extra text) ideally in a way that lets the text
file be parsed again later. Perhaps append ";\n\n\n" to each.
Add parameter values and row count as comments afterwards?

Ability to remove a handle from the parents cache:
	$sth->uncache;
and	$dbh->uncache; for connect_cached

Add discard_pending_rows() as an alias
for finish() - which will be deprecated.

$sth->{ParamTypes} eg { "1" => SQL_VARCHAR, "2" => { TYPE=>SQL_VARCHAR, ora_type=>99 }};

$h->{KidsHandles} = ref to cache (array or hash?)
of weakrefs to child handles.

DBI::Profile: some way to get count of 'executions' only, not all method calls.
So avg time is totaltime/executions not totaltime/methodcalls.

Document DbTypeSubclass (ala DBIx::AnyDBD)
Polish up and document _dbtype_names with an external interface and using get_info.

Count do()'s and execute()s (that aren't called by do()s) in imp_dbh.
Make available as an ExecuteCount attribute.
Reset count in commit/rollback.
Add InTransaction attribute that defaults to: !AutoCommit && ExecuteCount>0
Drivers are expected to implement InTransaction if they can.
In $dbh->DESTROY if !AutoCommit don't rollback&warning
unless InTransaction is true.

FetchHashReuse attrib (=1 or ={}) copy from dbh to sth
and use to optimise fetchrow_hash

--- Changes that may affect driver authors

Add PERL_NO_GET_CONTEXT for multiplicity/threads?
force it for drivers?
And enable xsbypass in dispatch if possible.
Remove PERL_POLLUTE

Require a CLONE method.

Add function pointer for setting fetched field values into DBIS.
Drivers would use this instead of calling sv_setpv (etc) themselves.

Add bind_col($n, $foo, { OnFetch => sub { ... } });

Add way to specify default bind_col attributes for each TYPE
e.g.	$dbh->{BindColumnTypes} = {
	  SQL_DATE => SQL_DATE,
	  SQL_DATETIME => { TYPE => SQL_DATETIME, OnFetch => \&foo },
	}

Add a handle flag to say that the driver has a hash that maps error
codes into SQLSTATE values. The error event mechanism could check for
the flag and lookup the SQLSTATE value for the error from the hash.
Allow code hook as well. Maybe $dbh->{SQLSTATE_map} = code or hash ref

Add minimum subset of ODBC3 SQLSTATE values that should be supported
(and corresponding ODBC2 values?)

Add more macro hooks to Driver.xst: ping, quote etc.

Add dbh active checks to some more sth methods where reasonable.

Rework handle creation to use methods.
Maybe $h->new_child(\%override_attr)
    dr::connect =>
	$dbh = $drh->new_child(\%attr);
	$dbh->reset(...)	- revert to 'virgin' state
	$dbh->connect(...)
&   db::prepare =>
	$sth = $dbh->new_child(\%attr);
	$sth->reset(...)	- revert to 'virgin' state
	$sth->prepare($statement)	# once only?
	$sth->close(???)		# to 'reset' before a different prepare()?
need to think through prepare_cached and connect_cached
and relationship to preparse().

Fixup @DBD::Foo::ISA and ?->setup_driver issues

Sort out DBIcDBISTATE() and DBIS mess. dDBIS?
Make it cheap to get h from imp_xxh so only imp_xxh needs
to be passed around?

Define consise DBI<>DBD interface with view towards parrot.
	note that parrot will use more method calls instead of
	'sideways' hooks into DBIS and the driver C code.
DBI::DBD::Base module?
Update DBI::DBD with overview and (at least) recommend Driver.xst strongly.
Find XS drivers that don't use it and talk to authors.

Review drivers for handling of multiple result sets
to define common api for all.
$sth->more_results, maybe via $sth->become($sth2) later (or transplant/swap)
Also standard way to 'reset/reconfigure' a statement handle.

#define a large negative number to mean 'error' from st_execute and
change *.xst to treat either that or -2 as an error. (The -2 is
a transition for old drivers.)

--- Other changes

Change t/zz_*_pp.t to be t/zXX_*.t where XX is a combination of:
 - 'pp' (for DBI_PUREPERL=2)
 - 'mx' (for DBI_AUTOPROXY=dbi:Multiplex:)
 - 'pr' (for DBI_AUTOPROXY=dbi:Proxy:)
mx and pr wouldn't both apply to the same test

Add data structure describing attributes
Use the data structure to replace similar data in Proxy and PurePerl code

Remove _not_impl. Alias debug to trace in DBI::(dr/db/st) ad remove
debug() method from internals.

Mechanism to 'unset' the keep_error flag for the current call, which
could then be used by FETCH when appropriate. Or, better:
New ima flags: CLEAR_ERR (on entry), CHECK_ERR (on exit), CHECK_NEW_ERR
(check if error count has been incremented by set_err).
Then FETCH would have just CHECK_NEW_ERR.

Macro to get new statement handle for XS code

Trace to tied file handle.

Hooks for method entry and exit.

$dbh->{Statement} can be wrong because fetch doesn't update value
maybe imp_dbh holds imp_sth (or inner handle) of last sth method
called (if not DESTROY) and sth outer DESTROY clears it (to reduce ref count)
Then $dbh->{LastSth} would work (returning outer handle if valid).
Then $dbh->{Statement} would be the same as $dbh->{LastSth}->{Statement}
Also $dbh->{ParamValues} would be the same as $dbh->{LastSth}->{ParamValues}.

Remove dummy 'Switch' driver.

Add %time to per-node DBI::Profile dump

Sponge behave_like - generalize into new_child()
	copy RaiseError, PrintError, HandleError etc from the specified handle
	but which attributes? LongReadLen, LongTruncOk etc? Presumably all
	as we're acting as a proxy behind the scenes.
	Should behave_like handle be dbh or sth or either or same as parent?

Add per-handle debug file pointer:
	NULL default => h->dbis->tracefp
	if not NULL then dup() via PerlIO for child handles
	close(h->tracefp) at end of DESTROY
	macro to do (h->tracefp || h->dbis->tracefp)

Move TIEHASH etc to XS (and to PurePerl)

Change CachedKids to be a simple attribute cached in the handle hash
to remove FETCH method call overhead in prepare_cached().

--- Other things to consider

Study alternate DBI's:
	ruby
	python
	php
	others?
	ADO object model
identify any features we could usefully support and any incompatibilities etc

Consider closer mapping to SQL3 CLI API for driver API.

Phalanx?

=cut

*** Small/quick/simple changes/checks ***

fetchall_hashref for multiple keys - pending


*** Assorted to-do items and random thoughts *** IN NO PARTICULAR ORDER ***

DBIx::DWIW

make lasth return outer handle?

document dbi_fetchall_arrayref_attr attr of selectall_arrayref().

ODBC 3.5 date and intervals types and subtypes (from unixODBC?)
http://www.vpservices.com/jeff/programs/SQL/docs/odbc-getinfo-msdn.html

Proxy: allow config to specify SQL to allow/deny via regexen
Docs for connect_cached and test with proxy.

Attribute to prepare() to prefer lazy-prepare,
e.g., don't talk to server till first execute
or a statement handle attribute is accessed.

How to report error from attribute FETCH as fetch method is marked
keep_error? Perhaps some way to make the current keep_error value
in the dispatch code available to change (via pointer in DBIS?) so
a method can change the value of keep_error that's used when the
method returns.

BINDING:

Add to docs & tutorial re wrong bind type on a param may cause
index to not be used! (Find real examples first)
check using EXPLAIN SELECT * WHERE int_indexed_col='42' vs =42.
also WHERE int_column = '01' relies on db to convert '01' to an int
rather than convert int_colum values to strings (which wouldn't match).

> And note that if you are using bind_param_inout as 'bind_param_by_ref',
> then the $maxlen parameter is redundant.  I suspect all drivers could
> implement bind_param_by_ref; most drivers, and specifically the Informix
> driver, has no need for bind_param_inout as a mechanism for getting data
> back from the database as there are no methods in the database which
> work like that.  With Informix, values are passed to the database for
> placeholders, and values are returned through a cursor, and that's all.
Okay. I'll take that as a vote for bind_param_by_ref as an alias for
bind_param_inout. >>todo.

------

OTHERS:

Change bind_column to save the info for get_fbav to use when
first called. Thus making bind before execute work for all drivers.

ODBC attribute defining if transactions are supported
http://www.vpservices.com/jeff/programs/SQL/docs/odbc-getinfo-msdn.html

Informix inspired changes?

Add hook to DBI::DBD to write a myconfig.txt file into the
source directory containing key driver and config info.

test suite
http://www.mipt.sw.ru/en/products/ots/

Add $h->swap_internal_handle($other_h)

dbish - state AutoCommit status clearly at connect time.
(And try to set AutoCommit off in eval?)
test shell "/connect user pass" etc

check out http://tegan.deltanet.com/~phlip/DBUIframe.html

Check DBD::Proxy connect&fetch latency (e.g. CGI use).

****** Less urgent changes ******

$dbh->ping($skip_seconds) - skip the ping if ping'd less than $skip_seconds ago
and $h->err is false
Change connect_cached() to use ping($skip_seconds || 1);


$dbh->get_inner_handle / set_inner_handle
		use to make $dbh->connect return same handle
Hook to call code ref on each fetch, pass fbav ref
datarow_array(), datarow_arrayref(), datarow_hashref()
remove sth from prepare_cached cache.


Give handles names: $h->{Id} ?
Useful for reporting, Multiplex, DBD::AnyData etc etc
May become useful for weakrefs etc

--- Fetch scroll and row set

fetch_scroll() handling via get_fbav.
Also add:
	row_array(offset)
	row_arrayref(offset)
	row_hashref(offset)
get_fbav has three modes:
	single row - return cached RV to same cached AV
	alternate rows - return RV to AV[row % 2]
	row set - return RV to AV[++row]

Bless row into DBI::Row ?
Bless row set into DBI::Rowset ?
Give get/set access to entire rowset via method calls?
	want to be able to plug in pre-loaded data row cache to new sth
	so it'll return the same data.

Add 'break handling' when field values change?
Use two fbav's so 'previous record' is available.
Define break fields and handlers.
Call them via an alternate fetch_with_break method.
Jan 2002: Also now see DBIx::FetchLoop (Brendan Fagan)
Alternatively, and perferably, add sufficient hooks for this to be
done efficiently externally.


DBI::Profile: add simple way to normalise the sql (convert constants
to placeholders) so profiling is more effective for drivers/applications
which don't use placeholders. Requires preparse()?


Devel::Leak

DBI::Profile: Add calc of approx XS method call and timing overhead
by calling perl_call("DBI::dbi_time") x100 at boot time for profile,
and add 1/100 (x2) to each sample. Beware Win32 where resolution
is too small and overhead will be 0 normally but may be eg 100ms
if overhead probe is on cusp of time unit.

Add a C call to return boolean for is a number' for a given SV.
Needs to do the right thing for a non-numeric string SV that's been
tested in a numeric context (eg $a='S23'; foo() if $a==-1; $sth->execute($a))
So if SvNVOK is true but the value is 0 then should also do looks_like_number()
to be sure. [Does perl's looks_like_number() do this already, if not what code do
callers of looks_like_number() use?]

Record attrib STOREs so can be replayed (or use subclass?)

