|
|
Choosing A Webhost: |
CVS update of odbsequoia/src (env.cpp env.hpp): msg#00181db.carob.cvs
Date: Thursday, March 30, 2006 @ 18:42:58 Author: marc Path: /cvsroot/carob/odbsequoia/src Modified: env.cpp (1.8 -> 1.9) env.hpp (1.4 -> 1.5) (incomplete, but working) fix for ODBSEQ-20. Extracted set_env_attr() method from SQLSetEnvAttr() ---------+ env.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++----------- env.hpp | 6 ++++- 2 files changed, 64 insertions(+), 13 deletions(-) Index: odbsequoia/src/env.cpp diff -u odbsequoia/src/env.cpp:1.8 odbsequoia/src/env.cpp:1.9 --- odbsequoia/src/env.cpp:1.8 Thu Mar 23 00:10:59 2006 +++ odbsequoia/src/env.cpp Thu Mar 30 18:42:58 2006 @@ -22,39 +22,86 @@ #include "env.hpp" #include "connect.hpp" +#include "odbc_exception.hpp" + +#include "Common.hpp" // for the logger #include <sql.h> #include <sqlucode.h> +#include <string> + using namespace ODBSeqNS; -using namespace CarobNS; +namespace { + const std::wstring SETENVATTR_FUNC = L"env.cpp:SQLSetEnvAttr"; +} /* Is there a SQLGetEnvAttrW()? Does not look like. */ SQLRETURN SQLSetEnvAttr(SQLHENV env_handle, SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER str_len) { - static_cast<ODBCEnv *>(env_handle)->clear_diags(); + ODBCEnv * self_p = static_cast<ODBCEnv *>(env_handle); + self_p->clear_diags(); - SQLRETURN ret = SQL_ERROR; + _PROTECT_SQLRETURN(self_p, set_env_attr(attribute, value, str_len)); +} + +SQLRETURN +ODBCEnv::set_env_attr(SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER str_len) +{ - switch (attribute) - { - case SQL_ATTR_ODBC_VERSION: - if (SQL_OV_ODBC2 == (int) value) - exit(200); // we have to be so violent else unixODBC DM will - // happily go on if we just return an error - if (SQL_OV_ODBC3 == (int) value) - ret = SQL_SUCCESS; + SQLRETURN ret = SQL_SUCCESS; // else throw + + switch (attribute) + { + // Warning: the logic of the unixODBC v2.2 code calling us + // here (in SQLConnect.c:__connect_part_one() is not + // understandable. It's something like: "do whatever but + // fail"... + + case SQL_ATTR_ODBC_VERSION: + + // version 2 asked + if (SQL_OV_ODBC2 == (int) value) { + + std::wstring func_witharg(SETENVATTR_FUNC + L"(ODBC_VERSION, 2, )"); + + // TODO: move this constant to odbc.ini + bool fake_version2 = true; + + if (!fake_version2) { + std::wstring msg(L"faking ODBC version 2 is disabled"); + CarobNS::logFatal(func_witharg, msg); + // this failure will be ignored by unixODBC 2.2 + throw ODBSeqException(L"01S02", func_witharg + msg); + } + + ret = SQL_SUCCESS_WITH_INFO; + std::wstring msg(L"now faking ODBC version 2"); + CarobNS::logWarn(func_witharg, msg); + push_diag_chain(ODBSeqException(L"HYC00", func_witharg + msg)); break; } - return ret; + // version 3 asked + if (SQL_OV_ODBC3 == (int) value) + break; + + default: + throw ODBSeqException(L"HYC00", + SETENVATTR_FUNC + L", unsupported attribute"); + + } + + return ret; } + + SQLRETURN ODBCEnv::AllocConnect(SQLHANDLE * OutputHandle) { Index: odbsequoia/src/env.hpp diff -u odbsequoia/src/env.hpp:1.4 odbsequoia/src/env.hpp:1.5 --- odbsequoia/src/env.hpp:1.4 Wed Jan 11 17:13:00 2006 +++ odbsequoia/src/env.hpp Thu Mar 30 18:42:58 2006 @@ -36,7 +36,11 @@ { public: ODBCEnv() : ODBCItem(*this) { }; // I have no father - SQLRETURN ODBCEnv::AllocConnect(SQLHANDLE * OutputHandle); + SQLRETURN + ODBCEnv::AllocConnect(SQLHANDLE * OutputHandle); + + SQLRETURN + ODBCEnv::set_env_attr(SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER str_len); }; }
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of odbsequoia (odbc.ini), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of odbsequoia/src (4 files), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of odbsequoia/src (abstract_item.hpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of odbsequoia/src (4 files), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|