Branchify patch from LP bug #702206 for rel_2_0. collab/dyrcona/lp702206_2_0
authorMike Rylander <mrylander@gmail.com>
Tue, 9 Aug 2011 18:17:00 +0000 (14:17 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Tue, 9 Aug 2011 20:19:53 +0000 (16:19 -0400)
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/c-apps/oils_sql.c

index 852c45f..e45b10c 100644 (file)
@@ -330,6 +330,17 @@ int oilsExtendIDL( dbi_conn handle ) {
        growing_buffer* query_buf = buffer_init( 64 );
        int results_found = 0;   // boolean
 
+    // Set a statement timeout of 1 second
+       dbi_result result = dbi_conn_query( handle, "SET statement_timeout TO 5000;" );
+       if( result ) {
+               dbi_result_free( result  );
+    } else {
+               const char* msg;
+               int errnum = dbi_conn_error( handle, &msg );
+               osrfLogError( OSRF_LOG_MARK, "Could not set session timeout! %s",
+                        msg ? msg : "(No description available)" );
+    }
+
        // For each class in the IDL...
        while( (class = osrfHashIteratorNext( class_itr ) ) ) {
                const char* classname = osrfHashIteratorKey( class_itr );
@@ -353,7 +364,7 @@ int oilsExtendIDL( dbi_conn handle ) {
                osrfLogDebug( OSRF_LOG_MARK, "%s Investigatory SQL = %s",
                                modulename, OSRF_BUFFER_C_STR( query_buf ) );
 
-               dbi_result result = dbi_conn_query( handle, OSRF_BUFFER_C_STR( query_buf ) );
+               result = dbi_conn_query( handle, OSRF_BUFFER_C_STR( query_buf ) );
                if( result ) {
 
                        results_found = 1;
@@ -440,6 +451,17 @@ int oilsExtendIDL( dbi_conn handle ) {
        osrfHashIteratorFree( class_itr );
        child_initialized = 1;
 
+    // Unset a statement timeout of 1 second
+       result = dbi_conn_query( handle, "SET statement_timeout TO DEFAULT;" );
+       if( result ) {
+               dbi_result_free( result  );
+    } else {
+               const char* msg;
+               int errnum = dbi_conn_error( handle, &msg );
+               osrfLogError( OSRF_LOG_MARK, "Could not set session timeout! %s",
+                        msg ? msg : "(No description available)" );
+    }
+
        if( !results_found ) {
                osrfLogError( OSRF_LOG_MARK,
                        "No results found for any class -- bad database connection?" );