NAME

DBIO::Manual::Troubleshooting - Troubleshooting common DBIO problems

VERSION

version 0.900004

"Can't locate storage blabla"

You're trying to make a query on a non-connected schema. Make sure you got the current resultset from $schema->resultset('Artist') on a schema object you got back from connect().

Tracing SQL

The DBIO_TRACE environment variable controls SQL tracing, so to see what is happening try

export DBIO_TRACE=1

DBIO_TRACE=1 shows the statement. DBIO_TRACE=2 adds the bind values, each one run through the redact_bind_value hook and cut to 32 characters (... marks the cut), undef as NULL:-

export DBIO_TRACE=2

Alternatively use the storage->debug method, which holds the level:-

$schema->storage->debug(1);   # statement
$schema->storage->debug(2);   # statement and binds

To send the output somewhere else set debugfh:-

$schema->storage->debugfh(IO::File->new('./dbio-trace.out', 'w'));

Alternatively you can do this with the environment variable, too:-

export DBIO_TRACE="1=./dbio-trace.out"

N=/path keeps the level N, so 2=./dbio-trace.out writes the binds too.

What an error text contains

The text of a failed statement carries the statement and the number of its bind values ([for Statement "..." with 3 bind values]), never the values. ShowErrorStatement is off on every handle DBIO opens, whatever connect_info says. A value the code writes as a literal into the SQL is part of the statement text. The text the server writes about the error is the driver's business. Exceptions belong in a log; show a client a message of your own, not the exception.

Can't locate method result_source_instance

For some reason the table class in question didn't load fully, so the ResultSource object for it hasn't been created. Debug this class in isolation, then try loading the full schema again.

Can't get last insert ID under Postgres with serial primary keys

A DBI or DBD::Pg that does not handle last_insert_id correctly causes code that uses auto-incrementing primary key columns to fail with a message such as:

Can't get last insert id

Use a current DBI and DBD::Pg.

Can't locate object method "source_name" via package

There's likely a syntax error in the table class referred to elsewhere in this error message. In particular make sure that the package declaration is correct. For example, for a schema MySchema you need to specify a fully qualified namespace: package MySchema::MyTable; .

syntax error at or near "<something>" ...

This can happen if you have a relation whose name is a word reserved by your database, e.g. "user":

package My::Schema::User;
...
__PACKAGE__->table('users');
__PACKAGE__->add_columns(qw/ id name /);
__PACKAGE__->set_primary_key('id');
...
1;

package My::Schema::ACL;
...
__PACKAGE__->table('acl');
__PACKAGE__->add_columns(qw/ user_id /);
__PACKAGE__->belongs_to( 'user' => 'My::Schema::User', 'user_id' );
...
1;

$schema->resultset('ACL')->search(
  {},
  {
    join => [qw/ user /],
    '+select' => [ 'user.name' ]
  }
);

The SQL generated would resemble something like:

SELECT me.user_id, user.name FROM acl me
JOIN users user ON me.user_id = user.id

If, as is likely, your database treats "user" as a reserved word, you'd end up with the following errors:

1) syntax error at or near "." - due to "user.name" in the SELECT clause

2) syntax error at or near "user" - due to "user" in the JOIN clause

The solution is to enable quoting - see "Setting quoting for the generated SQL" in DBIO::Manual::Cookbook for details.

column "foo DESC" does not exist ...

This can happen if you are still using the obsolete order hack, and also happen to turn on SQL-quoting.

$rs->search( {}, { order_by => [ 'name DESC' ] } );

The above should be written as:

$rs->search( {}, { order_by => { -desc => 'name' } } );

For more ways to express order clauses refer to "ORDER BY CLAUSES" in SQL::Abstract

Excessive Memory Allocation with TEXT/BLOB/etc. Columns and Large LongReadLen

It has been observed, using DBD::ODBC, that creating a DBIO::Row object which includes a column of data type TEXT/BLOB/etc. will allocate LongReadLen bytes. This allocation does not leak, but if LongReadLen is large in size, and many such result objects are created, e.g. as the output of a ResultSet query, the memory footprint of the Perl interpreter can grow very large.

The solution is to use the smallest practical value for LongReadLen.

AUTHOR

DBIO & DBIx::Class Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.