summaryrefslogtreecommitdiff
path: root/libodbcpp/connection.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-02-11 14:55:07 +0000
committerrandomdan <randomdan@localhost>2011-02-11 14:55:07 +0000
commit7001e0ccd9f6f93f2e38572221c223f8adaf0eaf (patch)
tree284fd4a5717fea1b380602f26f80c744e2c279d7 /libodbcpp/connection.cpp
parentFix the build system to do dependencies properly (diff)
downloadlibdbpp-odbc-7001e0ccd9f6f93f2e38572221c223f8adaf0eaf.tar.bz2
libdbpp-odbc-7001e0ccd9f6f93f2e38572221c223f8adaf0eaf.tar.xz
libdbpp-odbc-7001e0ccd9f6f93f2e38572221c223f8adaf0eaf.zip
Support for table patching in different ways according to what the connector says
Introduce two proper methods of bulk update Tested against PG 8.4, MySQL 5.1 with single and multiple column keys
Diffstat (limited to 'libodbcpp/connection.cpp')
-rw-r--r--libodbcpp/connection.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/libodbcpp/connection.cpp b/libodbcpp/connection.cpp
index 0c2dcc8..087fc69 100644
--- a/libodbcpp/connection.cpp
+++ b/libodbcpp/connection.cpp
@@ -10,6 +10,8 @@
ODBC::Connection::Connection(const DSN& d) :
env(0),
conn(0),
+ thinkDelStyle(DB::BulkDeleteUsingUsing),
+ thinkUpdStyle(DB::BulkUpdateUsingFromSrc),
txDepth(0),
txAborted(false)
{
@@ -53,11 +55,23 @@ ODBC::Connection::connectPost()
if (!SQL_SUCCEEDED(dberr)) {
throw ConnectionError(dberr, SQL_HANDLE_DBC, conn, "Set default auto commit");
}
+ char info[1024];
+ dberr = SQLGetInfo(conn, SQL_DRIVER_NAME, (SQLCHAR*)info, sizeof(info), NULL);
+ if (!SQL_SUCCEEDED(dberr)) {
+ throw ConnectionError(dberr, SQL_HANDLE_DBC, conn, "Get info");
+ }
+ // Apply known DB specific tweaks
+ if (strstr(info, "myodbc") != NULL) {
+ thinkDelStyle = DB::BulkDeleteUsingUsingAlias;
+ thinkUpdStyle = DB::BulkUpdateUsingJoin;
+ }
}
ODBC::Connection::Connection(const std::string & s) :
env(0),
conn(0),
+ thinkDelStyle(DB::BulkDeleteUsingUsing),
+ thinkUpdStyle(DB::BulkUpdateUsingFromSrc),
txDepth(0),
txAborted(false)
{
@@ -162,6 +176,18 @@ ODBC::Connection::inTx() const
return (txDepth > 0);
}
+DB::BulkDeleteStyle
+ODBC::Connection::bulkDeleteStyle() const
+{
+ return thinkDelStyle;
+}
+
+DB::BulkUpdateStyle
+ODBC::Connection::bulkUpdateStyle() const
+{
+ return thinkUpdStyle;
+}
+
DB::SelectCommand *
ODBC::Connection::newSelectCommand(const std::string & sql) const
{