summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Baumann <Andreas.Baumann@eurospider.com>2010-09-06 10:53:02 +0200
committerAndreas Baumann <Andreas.Baumann@eurospider.com>2010-09-06 10:53:02 +0200
commit1dcc640c490a6619eeba19a6bdb93c4ac8d5a6fc (patch)
treefa6db7059152ef1f34ed925b39c92d068812cb75 /tests
parent73a0556dca6ff98da2a77a34e75c5eec5969cd87 (diff)
downloadsqlitexx-1dcc640c490a6619eeba19a6bdb93c4ac8d5a6fc.tar.gz
sqlitexx-1dcc640c490a6619eeba19a6bdb93c4ac8d5a6fc.tar.bz2
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!
Diffstat (limited to 'tests')
-rw-r--r--tests/test9.cpp62
1 files changed, 6 insertions, 56 deletions
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;
-}
-*/