diff options
author | Bruce Momjian <bruce@momjian.us> | 2002-07-02 16:32:19 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2002-07-02 16:32:19 +0000 |
commit | a4485ea894ddd622daa81009d1556c95cd357781 (patch) | |
tree | 40b5d89b6807e7e2088300eb5b113bf9604b47c8 /src/interfaces/libpq++/examples/testlibpq6.cc | |
parent | c9a734521712797b1cd6a77bf9cabfe4c503e186 (diff) |
Indent libpq++ as mentioned in email. Format was terrible, and this
will make fixing things easier.
Diffstat (limited to 'src/interfaces/libpq++/examples/testlibpq6.cc')
-rw-r--r-- | src/interfaces/libpq++/examples/testlibpq6.cc | 104 |
1 files changed, 56 insertions, 48 deletions
diff --git a/src/interfaces/libpq++/examples/testlibpq6.cc b/src/interfaces/libpq++/examples/testlibpq6.cc index 2a6dc92ed5c..29b84c0cbe2 100644 --- a/src/interfaces/libpq++/examples/testlibpq6.cc +++ b/src/interfaces/libpq++/examples/testlibpq6.cc @@ -1,60 +1,68 @@ /* - * testlibpq4.cc - * Test the C++ version of LIBPQ, the POSTGRES frontend library. - * tests the copy in features - * - */ +* testlibpq4.cc +* Test the C++ version of LIBPQ, the POSTGRES frontend library. +* tests the copy in features +* +*/ #include <iostream.h> #include "libpq++.h" #include <stdlib.h> int main() { - // Begin, by connecting to the backend using hardwired constants - // and a test database created by the user prior to the invokation - // of this test program. Connect using transaction interface. - const char* dbName = "dbname=template1"; - PgTransaction data(dbName); + // Begin, by connecting to the backend using hardwired constants + // and a test database created by the user prior to the invokation + // of this test program. Connect using transaction interface. + const char* dbName = "dbname=template1"; + PgTransaction data(dbName); - // check to see that the backend connection was successfully made - if ( data.ConnectionBad() ) { - cerr << "Connection to database '" << dbName << "' failed." << endl - << data.ErrorMessage(); - exit(1); - } - else cout << "Connected to database '" << dbName << "'..." << endl; + // check to see that the backend connection was successfully made + if ( data.ConnectionBad() ) + { + cerr << "Connection to database '" << dbName << "' failed." << endl + << data.ErrorMessage(); + exit(1); + } + else + cout << "Connected to database '" << dbName << "'..." << endl; - // Create a new table - if ( !data.ExecCommandOk("CREATE TABLE foo (a int4, b char(16), d float8)") ) { - cerr << "CREATE TABLE foo command failed" << endl; - exit(1); - } - else cout << "CREATEd TABLE foo successfully.." << endl; + // Create a new table + if ( !data.ExecCommandOk("CREATE TABLE foo (a int4, b char(16), d float8)") ) + { + cerr << "CREATE TABLE foo command failed" << endl; + exit(1); + } + else + cout << "CREATEd TABLE foo successfully.." << endl; - // Initiate Copy command - if ( data.ExecCommandOk("COPY foo FROM STDIN") ) { - cerr << "COPY foo FROM STDIN" << endl; - exit(1); - } - else cout << "COPY foo FROM STDIN was successful.." << endl; + // Initiate Copy command + if ( data.ExecCommandOk("COPY foo FROM STDIN") ) + { + cerr << "COPY foo FROM STDIN" << endl; + exit(1); + } + else + cout << "COPY foo FROM STDIN was successful.." << endl; - // Put some test data into the table - data.PutLine("3\thello world\t4.5\n"); - cout << "Line: \"3\thello world\t4.5\" copied..." << endl; - data.PutLine("4\tgoodbye word\t7.11\n"); - cout << "Line: \"4\tgoodbye word\t7.11\" copied..." << endl; - data.PutLine("\\.\n"); - cout << "Line: \"\\.\" copied..." << endl; - if ( !data.EndCopy() ) - cout << "Ended COPY succesfully..." << endl; - else cerr << "End Copy failed..." << endl; - - // Print the data that was inserted into the table - if ( data.ExecTuplesOk("SELECT * FROM foo") ) - data.PrintTuples(); - else cerr << "SELECT * FROM foo failed..." << endl; - - // Drop the test table - data.Exec("DROP TABLE foo"); - return 0; + // Put some test data into the table + data.PutLine("3\thello world\t4.5\n"); + cout << "Line: \"3\thello world\t4.5\" copied..." << endl; + data.PutLine("4\tgoodbye word\t7.11\n"); + cout << "Line: \"4\tgoodbye word\t7.11\" copied..." << endl; + data.PutLine("\\.\n"); + cout << "Line: \"\\.\" copied..." << endl; + if ( !data.EndCopy() ) + cout << "Ended COPY succesfully..." << endl; + else + cerr << "End Copy failed..." << endl; + + // Print the data that was inserted into the table + if ( data.ExecTuplesOk("SELECT * FROM foo") ) + data.PrintTuples(); + else + cerr << "SELECT * FROM foo failed..." << endl; + + // Drop the test table + data.Exec("DROP TABLE foo"); + return 0; } |