Date: Friday, December 16, 2005 @ 18:20:01
  Author: marc
    Path: /cvsroot/carob/carob/test

Modified: ConnectionSetup.cpp (1.2 -> 1.3) ConnectionSetup.hpp (1.2 ->
          1.3)

Added createOrReplaceTable(). Minor fixes on dropTableIfExists().


---------------------+
 ConnectionSetup.cpp |   24 +++++++++++++++++++++---
 ConnectionSetup.hpp |    3 ++-
 2 files changed, 23 insertions(+), 4 deletions(-)


Index: carob/test/ConnectionSetup.cpp
diff -u carob/test/ConnectionSetup.cpp:1.2 carob/test/ConnectionSetup.cpp:1.3
--- carob/test/ConnectionSetup.cpp:1.2  Fri Dec 16 18:00:37 2005
+++ carob/test/ConnectionSetup.cpp      Fri Dec 16 18:20:01 2005
@@ -50,7 +50,7 @@
     delete connectionPtr;
 }
 
-void dropTableIfExists(Connection *conn_p, std::wstring tableName)
+void dropTableIfExists(Connection *conn_p, const std::wstring& tableName)
 {
     std::wstring dropcommand(L"drop table ");
     dropcommand += tableName;
@@ -62,15 +62,33 @@
         int updatecount = dropstmt->executeUpdate(dropcommand);
         CPPUNIT_ASSERT(0 == updatecount);
 
-    } catch (const BackendException be)
+    } catch (const BackendException& be)
     {
         // rethrow if different from UNDEFINED TABLE
         // TODO: ignore case here. Problem: "case" concept is locale sensitive?
         if (0 != be.getSQLState().compare(L"42P01") // postgres
             && 0 != be.getSQLState().compare(L"S0002")) // hypersonic
-            throw be;
+            throw be; // and leak. Who cares?
         // else ignore
     }
+
+    delete dropstmt;
+}
+
+void createOrReplaceTable(Connection *conn_p, const std::wstring& tableName, 
const std::wstring& tableType)
+{
+    dropTableIfExists(conn_p, tableName);
+
+    std::wstring createcommand(L"create table ");
+    createcommand += tableName + L" ";
+    createcommand += tableType;
+    
+    Statement* createstmt = conn_p->createStatement();
+
+    int updatecount = createstmt->executeUpdate(createcommand);
+    CPPUNIT_ASSERT(0 == updatecount);
+
+    delete createstmt;
 }
 
 
Index: carob/test/ConnectionSetup.hpp
diff -u carob/test/ConnectionSetup.hpp:1.2 carob/test/ConnectionSetup.hpp:1.3
--- carob/test/ConnectionSetup.hpp:1.2  Fri Dec 16 18:00:37 2005
+++ carob/test/ConnectionSetup.hpp      Fri Dec 16 18:20:01 2005
@@ -52,6 +52,7 @@
   CarobNS::Connection*       connectionPtr;
 };
 
-void dropTableIfExists(CarobNS::Connection *conn_p, std::wstring tableName);
+void dropTableIfExists(CarobNS::Connection *conn_p, const std::wstring& 
tableName);
+void createOrReplaceTable(CarobNS::Connection *conn_p, const std::wstring& 
tableName, const std::wstring& tableType);
 
 #endif /*TESTONVALIDCONNECTION_H_*/

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to