Why do you need to clear cached kids in your driver code?
You probably don't.

For the next release I'll be adding a DBI_REVISION macro that drivers
can use to control conditional compilation.

Meanwhile, if you really do need to clear cached kids yourself, you can
get your Makefile.PL to pass macro definition into the compiler via a -D
option. (See how the DBI's Makefile.PL sets DBI_NO_THREADS that way.)

Tim.


On Tue, May 22, 2007 at 04:21:54PM -0500, Swetha Patel wrote:
>    Hi Mr. Bunce,
> 
>    Thanks for you help last time.
> 
>    The fix is working for DBIv1.55. Now, I am trying to make my code backward 
> compatible with DBIv1.53.
> 
>    In DBIv1.53 the if statement does not evaluate to true (like it does in 
> DBIv1.55):
> 
>    SV **svp = hv_fetch((HV*)SvRV(dbh), "CachedKids", 10, 0);
>    if (svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVHV) {
>      hv_clear((HV*)SvRV(dbh));
>    }
> 
>    Is there an equivalent for the above code in DBIv1.53?
> 
>    Since, I cannot include the following code (because of compile error when 
> using with DBIv1.55 - and I
>    need it to work with both DBIv1.55 and DBIv1.53):
> 
>    if (DBIc_CACHED_KIDS(imp_dbh)) {
>      SvREFCNT_dec(DBIc_CACHED_KIDS(imp_dbh));
>      DBIc_CACHED_KIDS(imp_dbh) = Nullhv;
>    }
> 
>    I have also tried the following:
> 
>    if (DBIc_CACHED_KIDS(imp_dbh)) {
>      hv_undef( DBIc_CACHED_KIDS(imp_dbh) );
>    }
> 
>    But this does not seem to work. Using DBIv1.53 dbh->{CachedKids} does not 
> evaluate to  undef after
>    disconnect.
> 
>    You do not seem to be using any macros which I can use to distinguish the 
> two cases.
> 
>    Any information on this is greatly appreciated.
> 
>    Thank you,
>    Swetha
> 
>    [1]Inactive hide details for Tim Bunce <[EMAIL PROTECTED]>Tim Bunce 
> <[EMAIL PROTECTED]>
> 
>               Tim Bunce                    To Swetha Patel/Lenexa/[EMAIL 
> PROTECTED]
>               <[EMAIL PROTECTED]>        cc [EMAIL PROTECTED], Kellen F 
> Bombardier/Lenexa/[EMAIL PROTECTED],
>                                               Manas Dadarkar/Lenexa/[EMAIL 
> PROTECTED], dbi-dev@perl.org
>               05/15/2007 03:32 PM     Subject Re: Updating to DBI 1.55 breaks 
> DBD::DB2 due to change in
>                                               DBIc_CACHED_KIDS
> 
> 
>    Umm, okay. The key problem here is that DBD::DB2 isn't using the
>    Driver.xst 'driver template' file that the DBI provides.
> 
>    This means that, apart from duplicating a bunch of code, you're also
>    missing out on a bunch of optimizations.
> 
>    The Driver.xst file and related info is discussed in
>    [2]http://search.cpan.org/~timb/DBI/lib/DBI/DBD.pm
> 
>    Take a look at others drivers, like DBD::Sybase and/or DBD::Oracle, for 
> more examples.
> 
>    If you're desparate for a quick fix you can use this code instead:
> 
>           SV **svp = hv_fetch((HV*)SvRV(h), "CachedKids", 10, 0);
>           if (svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVHV) {
>               hv_clear((HV*)SvRV(*svp));
>           }
> 
>    but you're likely to bump into similar issues in later versions.
> 
>    Driver.xst is the way to go.
> 
>    Tim.
> 
>    On Tue, May 15, 2007 at 10:56:13AM -0500, Swetha Patel wrote:
>    >    Hi Mr. Bunce,
>    >
>    >    I work for IBM, and was trying to update the DBD::DB2, so that it 
> works with DBI 1.55. In doing so
>    I
>    >    came accross a compile error
>    >    "DB2.xs", line 115.9: 1506-025 (S) Operand must be a modifiable 
> lvalue.
>    >    Line 115 is: DBIc_CACHED_KIDS(imp_dbh) = Nullhv.
>    >
>    >    In our code it has effectd these three lines (in DB2.xs):
>    >
>    >    if (DBIc_CACHED_KIDS(imp_dbh)) {
>    >    SvREFCNT_dec(DBIc_CACHED_KIDS(imp_dbh));
>    >    DBIc_CACHED_KIDS(imp_dbh) = Nullhv;
>    >    }
>    >
>    >    I noticed that DBIc_CACHED_KIDS in DBI 1.53 was a macro for 
> _imp2com(imp, cached_kids).
>    >    And _imp2com(p,f) is a macro for ((p)->com.f).
>    >
>    >    So in effect DBIc_CACHED_KIDS(imp_dbh) became imp->com.cached_kids in 
> DBI 1.53.
>    >
>    >    But in DBI 1.55
>    >    #define DBIc_CACHED_KIDS(imp) Nullhv
>    >    And in effect in DBI 1.55 it becomes
>    >    Nullhv = Nullhv;
>    >    And hence the compile error.
>    >    I am not sure what imp->com.cached_kids is used for.
>    >    I have also done a diff on the two versions of DBI.xs, and noticed 
> that these three lines where
>    deleted
>    >    in the new DBI.xs, although there were some other things added.
>    >    Any information on this change and information regarding the 
> replacement for this change is greatly
>    >    appreciated.
>    >
>    >    Thanks,
>    >    Swetha Patel
>    >    [EMAIL PROTECTED]
> 
> References
> 
>    Visible links
>    2. http://search.cpan.org/~timb/DBI/lib/DBI/DBD.pm




Reply via email to