summaryrefslogtreecommitdiff
path: root/libodbcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libodbcpp')
-rw-r--r--libodbcpp/connection.cpp26
-rw-r--r--libodbcpp/connection.h5
2 files changed, 31 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
{
diff --git a/libodbcpp/connection.h b/libodbcpp/connection.h
index d37b679..4fc52ca 100644
--- a/libodbcpp/connection.h
+++ b/libodbcpp/connection.h
@@ -25,11 +25,16 @@ namespace ODBC {
void ping() const;
std::string getAttrStr(SQLINTEGER) const;
SQLINTEGER getAttrInt(SQLINTEGER) const;
+ DB::BulkDeleteStyle bulkDeleteStyle() const;
+ DB::BulkUpdateStyle bulkUpdateStyle() const;
DB::SelectCommand * newSelectCommand(const std::string & sql) const;
DB::ModifyCommand * newModifyCommand(const std::string & sql) const;
private:
+ DB::BulkDeleteStyle thinkDelStyle;
+ DB::BulkUpdateStyle thinkUpdStyle;
+
void connectPre();
void connectPost();
mutable unsigned int txDepth;