From 1dcc640c490a6619eeba19a6bdb93c4ac8d5a6fc Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Mon, 6 Sep 2010 10:53:02 +0200 Subject: more cleanup in exceptions, added a database_locked exception, now we must fix the code to throw this exception all the time and not do funny sleeps in the middle of the sqlitexx layer! --- tests/test9.cpp | 62 ++++++--------------------------------------------------- 1 file changed, 6 insertions(+), 56 deletions(-) (limited to 'tests') diff --git a/tests/test9.cpp b/tests/test9.cpp index 7c217cf..cf61508 100644 --- a/tests/test9.cpp +++ b/tests/test9.cpp @@ -33,8 +33,8 @@ using namespace sqlite3xx; using namespace std; -const int NOF_PRODUCERS = 10; -const int NOF_CONSUMERS = 10; +const int NOF_PRODUCERS = 1; +const int NOF_CONSUMERS = 1; const int NOF_PRODUCER_TRANSACTIONS = 100; const int NOF_PRODUCER_OPS = 100; const int NOF_CONSUMER_TRANSACTIONS = 100; @@ -45,6 +45,7 @@ const int NOF_CONSUMER_OPS = 100; static MUTEX_TYPE cout_mutex; static bool verbose = false; +static bool tracing = true; static THREAD_FUNC_DECL produce( void *thread_data ) { @@ -52,6 +53,7 @@ static THREAD_FUNC_DECL produce( void *thread_data ) try { connection c( "test9.db" ); + if( tracing ) c.trace( true ); c.prepare( "ins", "insert into x values( ? )" )( "integer", prepare::treat_direct ); for( int i = 0; i < NOF_PRODUCER_TRANSACTIONS; i++ ) { @@ -86,6 +88,7 @@ static THREAD_FUNC_DECL consume( void *thread_data ) try { connection c( "test9.db" ); c.prepare( "sel", "select * from x" ); + if( tracing ) c.trace( true ); for( int i = 0; i < NOF_CONSUMER_TRANSACTIONS; i++ ) { work t( c, "sel" ); @@ -127,6 +130,7 @@ int main( ) { try { cout << "creating DB.." << endl; connection c( "test9.db" ); + if( tracing ) c.trace( true ); cout << "connection object is " << c << endl; cout << "create table.." << endl; @@ -161,57 +165,3 @@ int main( ) { cerr << e.what( ) << ": " << e.query( ) << endl; } } - -/* - try { - - work wi( c, "insert" ); - cout << "insert some data.." << endl; - c.prepare( "ins", "insert into a( i, d, s, t ) values( NULL, NULL, NULL, ? )" ) - ( "text", sqlite3xx::prepare::treat_direct ); - result r = wi.prepared( "ins" )( "bla" ).exec( ); - cout << "inserted " << r.affected_rows( ) << " rows." << endl; - r = wi.prepared( "ins" )( "blu" ).exec( ); - cout << "inserted " << r.affected_rows( ) << " rows." << endl; - r = wi.prepared( "ins" )( "bli" ).exec( ); - cout << "inserted " << r.affected_rows( ) << " rows." << endl; - wi.commit( ); - - work wq( c, "query" ); - cout << "querying.." << endl; - c.prepare( "qry", "select * from a" ); - - r = wq.prepared( "qry" ).exec( ); - cout << "found " << r.size( ) << " records.." << endl; - cout << "found " << r.columns( ) << " columns.." << endl; - for( result::size_type i = 0; i < r.columns( ); i++ ) { - cout << "column " << i << ": " << r.column_type( i ) << endl; - } - assert( r.size( ) == 2 ); - - for( result::size_type i = 0; i < r.size( ); i++ ) { - cout << "i: " << i << endl; - - // by field number - cout << "(by col number) i: " << r[i][0] << " d: " << r[i][1] << " s: " << r[i][2] << " t: " << r[i][3] << endl; - - // associative array - cout << "(by col name) i: " << r[i]["i"] << " d: " << r[i]["d"] << " s: " << r[i]["s"] << " t: " << r[i]["t"] << endl; - - // map to variables of a given type - int value_i; - double value_d; - string value_s; - string value_t; - r[i]["i"].to( value_i ); - r[i]["d"].to( value_d ); - r[i]["s"].to( value_s ); - r[i]["t"].to( value_t ); - cout << "(mapping) i: " << value_i << " d: " << value_d << " s: " << value_s << " t: " << value_t << endl; - } - assert( r.size( ) == 3 ); - wq.commit( ); - - cout << "end." << endl; -} -*/ -- cgit v1.2.3-54-g00ecf