summaryrefslogtreecommitdiffstats
path: root/src/sql/drivers/odbc
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql/drivers/odbc')
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp152
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.h8
2 files changed, 5 insertions, 155 deletions
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index ee500a0..e0aa9b5 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
+** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -34,7 +34,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
+** contact the sales department at http://www.qtsoftware.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -86,12 +86,10 @@ static const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL
class QODBCDriverPrivate
{
public:
- enum DefaultCase{Lower, Mixed, Upper, Sensitive};
QODBCDriverPrivate()
: hEnv(0), hDbc(0), useSchema(false), disconnectCount(0), isMySqlServer(false),
isMSSqlServer(false), hasSQLFetchScroll(true), hasMultiResultSets(false)
{
- sql_char_type = sql_varchar_type = sql_longvarchar_type = QVariant::ByteArray;
unicode = false;
}
@@ -100,9 +98,6 @@ public:
uint unicode :1;
uint useSchema :1;
- QVariant::Type sql_char_type;
- QVariant::Type sql_varchar_type;
- QVariant::Type sql_longvarchar_type;
int disconnectCount;
bool isMySqlServer;
bool isMSSqlServer;
@@ -118,9 +113,6 @@ public:
bool setConnectionOptions(const QString& connOpts);
void splitTableQualifier(const QString &qualifier, QString &catalog,
QString &schema, QString &table);
- DefaultCase defaultCase() const;
- QString adjustCase(const QString&) const;
- QChar quoteChar() const;
};
class QODBCPrivate
@@ -129,7 +121,6 @@ public:
QODBCPrivate()
: hEnv(0), hDbc(0), hStmt(0), useSchema(false), hasSQLFetchScroll(true), precisionPolicy(QSql::HighPrecision)
{
- sql_char_type = sql_varchar_type = sql_longvarchar_type = QVariant::ByteArray;
unicode = false;
}
@@ -142,9 +133,6 @@ public:
uint unicode :1;
uint useSchema :1;
- QVariant::Type sql_char_type;
- QVariant::Type sql_varchar_type;
- QVariant::Type sql_longvarchar_type;
QSqlRecord rInf;
QVector<QVariant> fieldCache;
@@ -295,14 +283,10 @@ static QVariant::Type qDecodeODBCType(SQLSMALLINT sqltype, const T* p, bool isSi
break;
#endif
case SQL_CHAR:
- type = p->sql_char_type;
- break;
case SQL_VARCHAR:
case SQL_GUID:
- type = p->sql_varchar_type;
- break;
case SQL_LONGVARCHAR:
- type = p->sql_longvarchar_type;
+ type = QVariant::String;
break;
default:
type = QVariant::ByteArray;
@@ -557,28 +541,6 @@ static int qGetODBCVersion(const QString &connOpts)
return SQL_OV_ODBC2;
}
-QChar QODBCDriverPrivate::quoteChar() const
-{
- static bool isQuoteInitialized = false;
- static QChar quote = QChar::fromLatin1('"');
- if (!isQuoteInitialized) {
- char driverResponse[4];
- SQLSMALLINT length;
- int r = SQLGetInfo(hDbc,
- SQL_IDENTIFIER_QUOTE_CHAR,
- &driverResponse,
- sizeof(driverResponse),
- &length);
- if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
- quote = QChar::fromLatin1(driverResponse[0]);
- } else {
- quote = QChar::fromLatin1('"');
- }
- isQuoteInitialized = true;
- }
- return quote;
-}
-
bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts)
{
// Set any connection attributes
@@ -729,65 +691,6 @@ 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;
- }
- }
- isInitialized = true;
- }
- return ret;
-}
-
-/*
- Adjust the casing of an identifier to match what the
- database engine would have done to it.
-*/
-QString QODBCDriverPrivate::adjustCase(const QString &identifier) const
-{
- QString ret = identifier;
- switch(defaultCase()) {
- case (Lower):
- ret = identifier.toLower();
- break;
- case (Upper):
- ret = identifier.toUpper();
- break;
- case(Mixed):
- case(Sensitive):
- default:
- ret = identifier;
- }
- return ret;
-}
-
////////////////////////////////////////////////////////////////////////////
QODBCResult::QODBCResult(const QODBCDriver * db, QODBCDriverPrivate* p)
@@ -798,9 +701,6 @@ QODBCResult::QODBCResult(const QODBCDriver * db, QODBCDriverPrivate* p)
d->hDbc = p->hDbc;
d->unicode = p->unicode;
d->useSchema = p->useSchema;
- d->sql_char_type = p->sql_char_type;
- d->sql_varchar_type = p->sql_varchar_type;
- d->sql_longvarchar_type = p->sql_longvarchar_type;
d->disconnectCount = p->disconnectCount;
d->hasSQLFetchScroll = p->hasSQLFetchScroll;
}
@@ -1867,7 +1767,6 @@ void QODBCDriverPrivate::checkUnicode()
sizeof(fFunc),
NULL);
if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WCHAR)) {
- sql_char_type = QVariant::String;
unicode = true;
}
@@ -1877,7 +1776,6 @@ void QODBCDriverPrivate::checkUnicode()
sizeof(fFunc),
NULL);
if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WVARCHAR)) {
- sql_varchar_type = QVariant::String;
unicode = true;
}
@@ -1887,7 +1785,6 @@ void QODBCDriverPrivate::checkUnicode()
sizeof(fFunc),
NULL);
if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WLONGVARCHAR)) {
- sql_longvarchar_type = QVariant::String;
unicode = true;
}
}
@@ -2171,22 +2068,6 @@ QSqlIndex QODBCDriver::primaryIndex(const QString& tablename) const
}
QString catalog, schema, table;
d->splitTableQualifier(tablename, catalog, schema, table);
-
- if (isIdentifierEscaped(catalog, QSqlDriver::TableName))
- catalog = stripDelimiters(catalog, QSqlDriver::TableName);
- else
- catalog = d->adjustCase(catalog);
-
- if (isIdentifierEscaped(schema, QSqlDriver::TableName))
- schema = stripDelimiters(schema, QSqlDriver::TableName);
- else
- schema = d->adjustCase(schema);
-
- if (isIdentifierEscaped(table, QSqlDriver::TableName))
- table = stripDelimiters(table, QSqlDriver::TableName);
- else
- table = d->adjustCase(table);
-
r = SQLSetStmtAttr(hStmt,
SQL_ATTR_CURSOR_TYPE,
(SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
@@ -2289,22 +2170,6 @@ QSqlRecord QODBCDriver::record(const QString& tablename) const
SQLHANDLE hStmt;
QString catalog, schema, table;
d->splitTableQualifier(tablename, catalog, schema, table);
-
- if (isIdentifierEscaped(catalog, QSqlDriver::TableName))
- catalog = stripDelimiters(catalog, QSqlDriver::TableName);
- else
- catalog = d->adjustCase(catalog);
-
- if (isIdentifierEscaped(schema, QSqlDriver::TableName))
- schema = stripDelimiters(schema, QSqlDriver::TableName);
- else
- schema = d->adjustCase(schema);
-
- if (isIdentifierEscaped(table, QSqlDriver::TableName))
- table = stripDelimiters(table, QSqlDriver::TableName);
- else
- table = d->adjustCase(table);
-
SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT,
d->hDbc,
&hStmt);
@@ -2428,15 +2293,4 @@ QString QODBCDriver::escapeIdentifier(const QString &identifier, IdentifierType)
return res;
}
-bool QODBCDriver::isIdentifierEscapedImplementation(const QString &identifier, IdentifierType) const
-{
- QString quote = d->quoteChar();
- bool isLeftDelimited = identifier.left(1) == quote;
- bool isRightDelimited = identifier.right(1) == quote;
- if( identifier.size() > 2 && isLeftDelimited && isRightDelimited )
- return true;
- else
- return false;
-}
-
QT_END_NAMESPACE
diff --git a/src/sql/drivers/odbc/qsql_odbc.h b/src/sql/drivers/odbc/qsql_odbc.h
index 51f53ea..936164e 100644
--- a/src/sql/drivers/odbc/qsql_odbc.h
+++ b/src/sql/drivers/odbc/qsql_odbc.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
+** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtSql module of the Qt Toolkit.
**
@@ -34,7 +34,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
+** contact the sales department at http://www.qtsoftware.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -145,14 +145,10 @@ public:
QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
-protected Q_SLOTS:
- bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const;
-
protected:
bool beginTransaction();
bool commitTransaction();
bool rollbackTransaction();
-
private:
void init();
bool endTrans();