[Dbix-class] Strange statistically significant failure for DBIC with Sybase

Peter Rabbitson rabbit+dbic at rabbit.us
Tue Feb 4 17:30:34 GMT 2014


On Tue, Feb 04, 2014 at 12:19:48PM -0500, Phillip Moore wrote:
> OK, that must have gone right over my head, 'cause I did read it, but I
> don't see why that means I should expect there to be no trace output.
> 
> How do you trace the SQL that is generated when the create() method is
> called then? 

Several ways:

You either preclude DBIC from using an extra connection (by wrapping 
your create in a transaction, which will have little effect over Sybase, 
but will offer a clue to DBIC to do something else, see second code I 
linked)

Or you reach into the storage that holds the secondary connection (deep 
internals, do not use in production): 
$schema->storage->_writer_storage->_dbh->...

> Obviously, I'm just turning on tracing on the connection
> associated with my $dbh, but if that secondary connection isn't exposed to
> me somehow, are you saying my only recourse is to trace the ENTIRE
> application execution, and then wade through the mountain of data?

That's the last option yes, but the above is easier.

> 
> Oh, BTW, I tried switching to using NoBindVars, and was immediately
> reminded of why that failed for me last year:
> 
> DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::Sybase::st
> execute failed: Server message number=257 severity=16 state=1 line=1 \
> server=NYTIBV6T228 text=Implicit conversion from datatype 'VARCHAR' to
> 'NUMERIC' is not allowed.  Use the CONVERT function to run this query.
>  Server message number=257 severity=16 state=1 line=1 server=NYTIBV6T228
> text=Implicit conversion from datatype 'VARCHAR' to 'NUMERIC' is not a\
> llowed.  Use the CONVERT function to run this query.
>   [for Statement "INSERT INTO [ENGN_afsvolume] ( [name], [target],
> [toplevel], [type]) VALUES ( 'canon.root', '9', '1', 'cn' )
> SELECT @@IDENTITY"] at ./util/vms_bootstrap_database line 253
> 
> That '9', and '1' are both foreign keys which are numerics, and the
> dataserver doesn't like them to be quoted.
> 

You do not have sufficient metadata on the 'target' and 'toplevel' 
columns. If you add data_type => $whateverthetypeis_likely_int to your 
add_columns hashref - DBIC will stop quoting:
https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.08270/lib/DBIx/Class/Storage/DBI/Sybase/ASE/NoBindVars.pm#L28

Cheers




More information about the DBIx-Class mailing list