"ignored until end of transaction block\n";
const char* msg;
dbi_conn_error( handle, &msg );
- if( strcmp( msg, ok_msg )) {
- osrfLogError( OSRF_LOG_MARK, "Database connection isn't working" );
+ // Newer versions of dbi_conn_error return codes within the error msg.
+ // E.g. 3624914: ERROR: current transaction is aborted, commands ignored until end of transaction block
+ // Substring test should work regardless.
+ const char* substr = strstr(msg, ok_msg);
+ if( substr == NULL ) {
+ osrfLogError( OSRF_LOG_MARK, "Database connection isn't working : %s", msg );
return 0;
} else
return 1; // ignoring SELECT due to previous error; that's okay
--- /dev/null
+#!perl
+
+use Test::More tests => 2;
+
+diag("Tests libdbi transaction error reporting");
+
+use strict; use warnings;
+
+use OpenILS::Utils::TestUtils;
+use OpenILS::Utils::CStoreEditor (':funcs');
+use OpenILS::Utils::Fieldmapper;
+my $script = OpenILS::Utils::TestUtils->new();
+$script->bootstrap;
+
+my $e = new_editor(xact => 1);
+$e->init;
+
+# create a copy status object with ID 1, which will fail.
+my $stat = Fieldmapper::config::copy_status->new;
+$stat->id(1);
+
+# when functioning well, this should happen and fail quickly
+my $start = time;
+$e->create_config_copy_status($stat);
+my $evt = $e->die_event; # this part takes the longest
+my $duration = time - $start;
+
+cmp_ok($duration, '<', '10',
+ 'Confirm cstore reports standard query error in a timely fashion');
+
+if ($evt) {
+ is($evt->{textcode}, 'DATABASE_QUERY_FAILED',
+ 'CStoreEditor returns standard query error');
+} else {
+ fail('CStoreEditor returned no event');
+}
+
+
+