diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2008-07-11 18:33:03 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2008-07-11 18:33:03 +0200 |
commit | 59cda05cd517f3191abab0b551733d72105e6450 (patch) | |
tree | f85d91f70aa9fdebd128ed6477fb907eb21b6a12 /tests/psql | |
parent | ea2560808d3665c51b294a5f91d1daa6e5030f26 (diff) | |
download | crawler-59cda05cd517f3191abab0b551733d72105e6450.tar.gz crawler-59cda05cd517f3191abab0b551733d72105e6450.tar.bz2 |
added a second test for prepared statements
Diffstat (limited to 'tests/psql')
-rw-r--r-- | tests/psql/GNUmakefile | 3 | ||||
-rw-r--r-- | tests/psql/README | 1 | ||||
-rw-r--r-- | tests/psql/test2.cpp | 42 |
3 files changed, 45 insertions, 1 deletions
diff --git a/tests/psql/GNUmakefile b/tests/psql/GNUmakefile index 754895f..8ba71a0 100644 --- a/tests/psql/GNUmakefile +++ b/tests/psql/GNUmakefile @@ -11,7 +11,8 @@ LIBS_DIR = \ -lpqxx -lpq CPP_BINS = \ - test1$(EXE) + test1$(EXE) \ + test2$(EXE) OBJS = diff --git a/tests/psql/README b/tests/psql/README index 51987a7..b0af0d1 100644 --- a/tests/psql/README +++ b/tests/psql/README @@ -1 +1,2 @@ test1 - using the newest libpqxx +test2 - using libpqxx and prepared statements diff --git a/tests/psql/test2.cpp b/tests/psql/test2.cpp new file mode 100644 index 0000000..5d4e06f --- /dev/null +++ b/tests/psql/test2.cpp @@ -0,0 +1,42 @@ +#include <iostream> +#include <sstream> +#include <stdio.h> + +#include "pqxx" + +using namespace pqxx; +using namespace PGSTD; +using namespace std; + +int main( ) { + connection c( "dbname=test" ); + + //c.trace( stdout ); + + cout << "Conntected to database." << endl + << "Backend protocol version: " << c.server_version( ) << endl + << "Protocol version: " << c.protocol_version( ) << endl + << "Server PID: " << c.backendpid( ) << endl + << "Prepared Statements: " << c.supports( c.cap_prepared_statements ) << endl; + + work t( c, "test transaction" ); + + t.exec( "create table test( a integer, b integer)" ); + for( unsigned int i = 0; i < 1000; i++ ) { + ostringstream sql; + sql << "insert into test values( '" << i << "', '" << i << "' )"; + t.exec( sql.str( ) ); + } + + result r( t.exec( "select * from test" ) ); + cout << "a\tb" << endl; + for( result::size_type i = 0; i < r.size( ); i++ ) { + cout << r[i]["a"] << "\t" << r[i]["b"] << endl; + } + + t.exec( "drop table test" ); + + t.commit( ); + + return 0; +} |