summaryrefslogtreecommitdiff
path: root/libodbcpp/connection.cpp
diff options
context:
space:
mode:
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
{