Date: Friday, December 16, 2005 @ 18:00:37
Author: marc
Path: /cvsroot/carob/carob/test
Modified: ConnectionSetup.cpp (1.1 -> 1.2) ConnectionSetup.hpp (1.1 ->
1.2)
Added dropTableIfExists() util method
---------------------+
ConnectionSetup.cpp | 34 ++++++++++++++++++++++++++++++++++
ConnectionSetup.hpp | 3 +++
2 files changed, 37 insertions(+)
Index: carob/test/ConnectionSetup.cpp
diff -u carob/test/ConnectionSetup.cpp:1.1 carob/test/ConnectionSetup.cpp:1.2
--- carob/test/ConnectionSetup.cpp:1.1 Fri Dec 16 17:41:08 2005
+++ carob/test/ConnectionSetup.cpp Fri Dec 16 18:00:37 2005
@@ -23,6 +23,8 @@
#include "ConnectionParameters.hpp"
#include "ConnectionPool.hpp"
#include "CarobException.hpp"
+#include "Statement.hpp"
+
#include "ConnectionSetup.hpp"
using std::wstring;
@@ -47,3 +49,35 @@
if (connectionPtr)
delete connectionPtr;
}
+
+void dropTableIfExists(Connection *conn_p, std::wstring tableName)
+{
+ std::wstring dropcommand(L"drop table ");
+ dropcommand += tableName;
+
+ Statement* dropstmt = conn_p->createStatement();
+
+ try {
+
+ int updatecount = dropstmt->executeUpdate(dropcommand);
+ CPPUNIT_ASSERT(0 == updatecount);
+
+ } 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;
+ // else ignore
+ }
+}
+
+
+/*
+ * Local Variables:
+ * c-file-style: "bsd"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Index: carob/test/ConnectionSetup.hpp
diff -u carob/test/ConnectionSetup.hpp:1.1 carob/test/ConnectionSetup.hpp:1.2
--- carob/test/ConnectionSetup.hpp:1.1 Fri Dec 16 17:41:08 2005
+++ carob/test/ConnectionSetup.hpp Fri Dec 16 18:00:37 2005
@@ -28,6 +28,7 @@
#include <cppunit/TestSuite.h>
#include <cppunit/TestCaller.h>
+#include "Connection.hpp"
/**
* Test super class for running tests on a valid connection to a local
@@ -51,4 +52,6 @@
CarobNS::Connection* connectionPtr;
};
+void dropTableIfExists(CarobNS::Connection *conn_p, std::wstring tableName);
+
#endif /*TESTONVALIDCONNECTION_H_*/
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits