On Thu, Nov 21, 2002 at 02:19:03PM -0800, Jonathan Leffler wrote:
> Dear Tim,
>
> I'm looking at the code in Driver.xst and there are three conditionally
> used functions, controlled by:
>
> #ifdef dbd_db_finish3
> #ifdef dbd_st_rows
> #ifdef dbd_db_login6
In theory *all* the functions in Driver.xst should be controlled
by the dbd_* macro that they use - because without that there no
easy way for the driver to just use the method inherited from the DBI.
I plan to clean that up one day - but meanwhile driver authors
should note that they should have a #define for each dbd_* function
they implement. Like this:
#define dbd_db_do ora_db_do
#define dbd_db_commit ora_db_commit
#define dbd_db_rollback ora_db_rollback
#define dbd_db_cancel ora_db_cancel
#define dbd_db_disconnect ora_db_disconnect
...
These macros serve two purposes, a: to inform Driver.xst which
functions are implemented, and b: to rename the function to aunique
name per driver so that multiple drivers can be statically linked
into the same executable.
> Of these, there is only a mention of the dbd_db_login6 method in
> DBI/DBD.pm (which could do with some elucidation, but it is there).
Originally there was dbd_db_login but when I wanted to add an extra
parameter to that function I couldn't do that without breaking
existing code, so I added dbd_db_login6 defined to take the extra
parameter (the 6 refers to the number of parameters). Thus:
#ifdef dbd_db_login6
ST(0) = dbd_db_login6(dbh, imp_dbh, dbname, u, p, attribs) ? &sv_yes : &sv_no;
#else
ST(0) = dbd_db_login( dbh, imp_dbh, dbname, u, p) ? &sv_yes : &sv_no;
#endif
> What is the significance of the dbd_st_rows and dbd_db_finish3 methods?
>
> When should a driver use dbd_db_finish3 in preference to dbd_db_finish?
> What is the significance of the third parameter - which seems to be 0 or
> 1 depending on whether this is global destruction, I think?
It is 1 is the finish is being called from DESTROY. If your database
API supports a finish-like function then it's generally not worth
calling it (which'll cost a round-trip to the server) if the statement
handle is about to be destroyed/closed. So the flag lets the driver
code ignore those finish calls if it wants to.
> What should the dbd_st_rows method do?
Implements $sth->rows (and $DBI::rows which calls $DBI::lasth->rows).
> What happens if it is not provided?
The method call will reach the rows method provided by the DBI
(which uses a count kept by the get_fbav function so is usually
accurate).
I hope this helps [and someone turns it into a DBI::DBD patch ;-]
Tim.