On Mon, Jan 21, 2002 at 05:57:51PM -0800, Jonathan Leffler wrote:
> On Mon, 21 Jan 2002, Tim Bunce wrote:
> 
> >> Since DBI won't allow the application to tell us that it wants to use
> >> quoted identifiers, we're stuck in a lose-lose situation.
> >
> >To tell if the driver is going to quote identifiers from tables()
> >an application can do:
> >
> >    if ($dbh->quoted_indentifier('foo') eq '"foo"') { ... }
> >
> >and DBD::Informix is free to add it's own private attributes and/or
> >versions of quoted_indentifier etc. to define whatever semantics it likes.
> 
> We have a horses and carts problem -- and I'm not sure which is the
> horse and which is the cart, but you've got them the other way around
> from me.
> 
> I was expecting the application to tell the driver whether it wants to
> do quoting of identifiers

That was the "and DBD::Informix is free to add ..." part.

> It may be the difference between an application and a utility.  Unto
> some sort of first approximation, a utility has to deal with whatever
> database exists, but an application controls what is in the database it
> deals with.

Yes, exactly.

> >> It is all a bit academic; I don't really have time to do anything
> >> significant to DBD::Informix anyway -- it will limp along as it has
> >> for the last two years.
> >
> >Any feel for how many applications may be using tables() with
> >DELIMIDENT not set? (Yes, I know it's an impossible question :)
> 
> 100% - essentially no-one ever uses DELIMIDENT, primarily because they
> are sane.  No-one who is sane uses DELIMIDENT.  That's both 100% of the
> applications written using DBD::Informix and 100% of those using the
> tables function.  However, the subset using the tables function is
> probably a small subset of those using DBD::Informix.  Based on what I
> see in comp.databases.informix, I would be surprised if there are any
> people using DELIMIDENT at all who have not been forced into it by some
> application or application generator that insists on using delimited
> identifiers.  And there are not many people suffering from that, and
> most of those seem to be running on Win32.
> 
> >I could grandfather in a hack to quoted_identifier so that, for
> >DBD::Informix, it makes tables() behave like it does now for.
> 
> Is tables() provided by DBI or by DBD?  I've forgotten...

It's a method. The DBI provides a default but drivers can override it.

> On average, I
> prefer not to make DBI hack things, especially as at some point it would
> have to be changed again if DBD::Informix caught up.

If DBD::Informix caught up and provided it's own quote_identifier
then the DBI's one would not longer be called by DBD::Informix handles.


> >> >If there's a problem with the (recently added) $dbh->begin_work method
> >> >then please feel free to start up a new thread.
> >>
> >> Informix has extensions to BEGIN WORK, such as BEGIN WORK WITHOUT
> >> REPLICATION, which I abhor but which DBD::Informix needs to be able
> >> to support.
> >
> >  $dbh->begin_work( { ix_foo => 'bar' } );
> 
> OK, probably.  When does fetch get an attribute argument so we can
> support scroll cursors?

That'll be a new fetch_scroll() method. And won't be very soon
unless someone offers to help out with the implementation. I've a pile
of DBD::Oracle, Oracle::OCI and extproc_perl stuff to get to first.


> >> AutoCommit screws me up all ways, and this is particularly painful.  And
> >> it is particularly bad since we don't have database-dependent connection
> >> attributes AFAICT -- stuff such as:
> >>
> >>    DBI->connect($dbid,$user,$pass,{db_attribute=>1})
> >
> >Er, I'm not sure what you're asking here, but for years the DBI->connect
> >has basically done
> >     $dbh->{$_} = $attr->{$_} foreach keys %$attr;
> >In other words all connect method attributes become handle attributes.
> >Also the $attr is passed to the drivers connect method so that the
> >attributes are available to the code that's making the connection.
> 
> OK.  Is that information available in the login function of the driver?
> IIRC, when I tried to get the information (back in 1996 or thereabouts),
> it was not available when I made the connection to the database, but it
> could be that I didn't understand how that bit of code was meant to be
> written or how that bit of code should be used.

No, I think I added it more recently than that. Maybe 1999. My apologies
if I didn't advertise it (I've tended not to put internals stuff into the
Changes file and more than once that's meant that driver authors haven't
known what's available).

> I'm quite willing to
> believe that the DBD::Informix connection startup code needs a complete
> revamp -- it is amazing that it works.  I didn't (and still don't)
> understand which bits of magic are really necessary, and what does which
> bit of it -- especially this far away from when I first did it.  And, as
> so often, once you kludge your way around something so it more or less
> works, what you've got is adequate, and other things need fixing more,
> so it doesn't get retrofixed.  I know I sweated blood'n'tears over it
> for the DBD::Informix 0.25 release, and could not make head or tail of
> what the heck was going on and when anything useful was passed to me.  I
> still don't understand what the DBISTATE stuff does.  I last spent a few
> hours on this back in Aug 2001; prior to that, it was probably 1998 or
> 1999.  Time has passed, and memories have faded.

I know that feeling.

> If the hash is still not available to the login function, then please can
> you work out what it would take to allow it to become available -- having
> that information *before* making the database connection is *crucial* to
> making it work sensibly -- at least for DBD::Informix.

The DBI->connect basically calls $drh->connect($dsn, $user, $pass, $attr).
Your connect probably does something like DBD::Informix::db::_login(...)
and so you need to pass $attr through there.  Assuming you're using
Driver.xst then you already have this code in there:

    _login(dbh, dbname, username, password, attribs=Nullsv)
        ...
    #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
        ...

So you just need to define a macro like
    #define dbd_db_login6  ix_db_login6
and have your own ix_db_login6 function handle the extra attribs param.
(For compatibility with old DBI's I'd recommend still having a dbd_db_login
macro mapping to a ix_db_login function that then simply calls ix_db_login6
with a NULL for the atribs parameter.)o
The DBD_ATTRIB_GET_IV and DBD_ATTRIB_GET_SVP macros defined by DBIXS.h
are also handy. See DBD::Oracle for examples of all the above.


> >> With support for those, I could (and would) allow informed users of
> >> DBD::Informix to override the DBI defaults that make life hell for
> >> everyone using Informix databases.
> >
> >You have them.
> >
> >> The innocent application writer who
> >> is given an Informix database would still get DBI-compliant behaviour,
> >> but those needing native behaviour would be able to get it.
> >
> >Which has always been a core philosophy of the DBI.
> 
> Well, it has not always seemed like it to me -- AutoCommit being the
> biggest bugaboo.  But I'm willing to believe that it can be done and I
> simply haven't had the energy to work out how the hell it can be done.
> I certainly have never had the inclination to work out what the DBI
> code actually does.

The DBI doesn't actually do anything for AutoCommit. It just defines
some semantics. At the end of the day DBD::Informix need only care
about the detail of those semantics to the degree that it wants to
allow portable code.

The begin_work code is only 7 lines of perl and a few lines of C
(look for DBIcf_BegunWork in DBI.xs).  Though it works better if
drivers implement the functionality in their own commit/rollback.


> >> Since I've had no success converting people to my viewpoint starting
> >> from the days when AutoCommit was first mooted, despite extensive
> >> kilobytes of discussion, I have no intention whatsoever of reopening the
> >> discussion.  My previous comments all still apply.  IMNSHO, the idea of
> >> DBI imposing AutoCommit is, and always was, misguided.  DBI should
> >> provide a mechanism that allows the DBD to describe the native semantics
> >> of the database (no transactions, implicit transactions, explicit
> >> transactions, whatever; these days, we should be reviewing whether
> >> savepoint and rollback to savepoint are supported),
> >
> >The latest release of the DBI has a $dbh->get_info method to return
> >that kind of info (as per the ODBC GetInfo function).
> 
> Mentioning that acronym is not designed to make me look kindly on
> anything.

:-)

> However, I can probably get over that, too.  And
> DBD::Informix certainly hasn't been updated to deal with that -- it was
> last released in March 2000, before the DBD book was released, and it
> probably wasn't fully up to date with DBI even then.

It would be great if you could find the time, or find someone else
who has the time, to work on an update. It's probably not as big
as you may think.

Tim.

Reply via email to