diff options
author | Bill King <bill.king@nokia.com> | 2009-08-27 00:31:37 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2009-08-27 00:31:37 (GMT) |
commit | 40856f6e2e3b5115e8730ea86c97ed7211d4e5a3 (patch) | |
tree | 19bc8b682eb9d730dde1d91adb220f25e148106c /src/sql/drivers/odbc | |
parent | e201ff0ff3a8223b14a72954c898674e606f147e (diff) | |
download | Qt-40856f6e2e3b5115e8730ea86c97ed7211d4e5a3.zip Qt-40856f6e2e3b5115e8730ea86c97ed7211d4e5a3.tar.gz Qt-40856f6e2e3b5115e8730ea86c97ed7211d4e5a3.tar.bz2 |
Fixes invalid use of statics
Multiple database connections could have differing ideas on the return
value for defaultCase. The cost of the call is so minimal that caching
is unnecessary, and static caching is very very wrong.
Reviewed-by: Justin McPherson
Diffstat (limited to 'src/sql/drivers/odbc')
-rw-r--r-- | src/sql/drivers/odbc/qsql_odbc.cpp | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 6a8609e..06ee3e1 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -743,37 +743,31 @@ void QODBCDriverPrivate::splitTableQualifier(const QString & qualifier, QString QODBCDriverPrivate::DefaultCase QODBCDriverPrivate::defaultCase() const { - static bool isInitialized = false; - static DefaultCase ret; - - if (!isInitialized) { - SQLUSMALLINT casing; - int r = SQLGetInfo(hDbc, - SQL_IDENTIFIER_CASE, - &casing, - sizeof(casing), - NULL); - if ( r != SQL_SUCCESS) - ret = Lower;//arbitrary case if driver cannot be queried - else { - switch (casing) { - case (SQL_IC_UPPER): - ret = Upper; - break; - case (SQL_IC_LOWER): - ret = Lower; - break; - case (SQL_IC_SENSITIVE): - ret = Sensitive; - break; - case (SQL_IC_MIXED): - ret = Mixed; - break; - default: - ret = Upper; - } + DefaultCase ret; + SQLUSMALLINT casing; + int r = SQLGetInfo(hDbc, + SQL_IDENTIFIER_CASE, + &casing, + sizeof(casing), + NULL); + if ( r != SQL_SUCCESS) + ret = Mixed;//arbitrary case if driver cannot be queried + else { + switch (casing) { + case (SQL_IC_UPPER): + ret = Upper; + break; + case (SQL_IC_LOWER): + ret = Lower; + break; + case (SQL_IC_SENSITIVE): + ret = Sensitive; + break; + case (SQL_IC_MIXED): + default: + ret = Mixed; + break; } - isInitialized = true; } return ret; } |