Remove non-UNICODE code branches from ODBC plugin.
Task-number: QTBUG-39388 Change-Id: If22876454547098dd00e477c0593da7c4be0e803 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
parent
497f0af1f7
commit
dc58c6be47
@ -222,12 +222,7 @@ static QString qWarnODBCHandle(int handleType, SQLHANDLE handle, int *nativeCode
|
||||
if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
|
||||
if (nativeCode)
|
||||
*nativeCode = nativeCode_;
|
||||
QString tmpstore;
|
||||
#ifdef UNICODE
|
||||
tmpstore = fromSQLTCHAR(description_, msgLen);
|
||||
#else
|
||||
tmpstore = QString::fromUtf8((const char*)description_.constData(), msgLen);
|
||||
#endif
|
||||
const QString tmpstore = fromSQLTCHAR(description_, msgLen);
|
||||
if(result != tmpstore) {
|
||||
if(!result.isEmpty())
|
||||
result += QLatin1Char(' ');
|
||||
@ -617,11 +612,7 @@ static QSqlField qMakeFieldInfo(const QODBCPrivate* p, int i )
|
||||
qSqlWarning(QString::fromLatin1("qMakeField: Unable to get column attributes for column %1").arg(i), p);
|
||||
}
|
||||
|
||||
#ifdef UNICODE
|
||||
QString qColName(fromSQLTCHAR(colName, colNameLen));
|
||||
#else
|
||||
QString qColName = QString::fromUtf8((const char *)colName.constData());
|
||||
#endif
|
||||
const QString qColName(fromSQLTCHAR(colName, colNameLen));
|
||||
// nullable can be SQL_NO_NULLS, SQL_NULLABLE or SQL_NULLABLE_UNKNOWN
|
||||
QVariant::Type type = qDecodeODBCType(colType, p, unsignedFlag == SQL_FALSE);
|
||||
QSqlField f(qColName, type);
|
||||
@ -654,11 +645,7 @@ QChar QODBCDriverPrivate::quoteChar()
|
||||
sizeof(driverResponse),
|
||||
&length);
|
||||
if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
|
||||
#ifdef UNICODE
|
||||
quote = QChar(driverResponse[0]);
|
||||
#else
|
||||
quote = QLatin1Char(driverResponse[0]);
|
||||
#endif
|
||||
else
|
||||
quote = QLatin1Char('"');
|
||||
isQuoteInitialized = true;
|
||||
@ -703,11 +690,7 @@ bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts)
|
||||
} else if (opt.toUpper() == QLatin1String("SQL_ATTR_CURRENT_CATALOG")) {
|
||||
val.utf16(); // 0 terminate
|
||||
r = SQLSetConnectAttr(hDbc, SQL_ATTR_CURRENT_CATALOG,
|
||||
#ifdef UNICODE
|
||||
toSQLTCHAR(val).data(),
|
||||
#else
|
||||
(SQLCHAR*) val.toUtf8().data(),
|
||||
#endif
|
||||
val.length()*sizeof(SQLTCHAR));
|
||||
} else if (opt.toUpper() == QLatin1String("SQL_ATTR_METADATA_ID")) {
|
||||
if (val.toUpper() == QLatin1String("SQL_TRUE")) {
|
||||
@ -725,11 +708,7 @@ bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts)
|
||||
} else if (opt.toUpper() == QLatin1String("SQL_ATTR_TRACEFILE")) {
|
||||
val.utf16(); // 0 terminate
|
||||
r = SQLSetConnectAttr(hDbc, SQL_ATTR_TRACEFILE,
|
||||
#ifdef UNICODE
|
||||
toSQLTCHAR(val).data(),
|
||||
#else
|
||||
(SQLCHAR*) val.toUtf8().data(),
|
||||
#endif
|
||||
val.length()*sizeof(SQLTCHAR));
|
||||
} else if (opt.toUpper() == QLatin1String("SQL_ATTR_TRACE")) {
|
||||
if (val.toUpper() == QLatin1String("SQL_OPT_TRACE_OFF")) {
|
||||
@ -934,16 +913,9 @@ bool QODBCResult::reset (const QString& query)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef UNICODE
|
||||
r = SQLExecDirect(d->hStmt,
|
||||
toSQLTCHAR(query).data(),
|
||||
(SQLINTEGER) query.length());
|
||||
#else
|
||||
QByteArray query8 = query.toUtf8();
|
||||
r = SQLExecDirect(d->hStmt,
|
||||
(SQLCHAR*) query8.data(),
|
||||
(SQLINTEGER) query8.length());
|
||||
#endif
|
||||
if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r!= SQL_NO_DATA) {
|
||||
setLastError(qMakeError(QCoreApplication::translate("QODBCResult",
|
||||
"Unable to execute statement"), QSqlError::StatementError, d));
|
||||
@ -1280,16 +1252,9 @@ bool QODBCResult::prepare(const QString& query)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef UNICODE
|
||||
r = SQLPrepare(d->hStmt,
|
||||
toSQLTCHAR(query).data(),
|
||||
(SQLINTEGER) query.length());
|
||||
#else
|
||||
QByteArray query8 = query.toUtf8();
|
||||
r = SQLPrepare(d->hStmt,
|
||||
(SQLCHAR*) query8.data(),
|
||||
(SQLINTEGER) query8.length());
|
||||
#endif
|
||||
|
||||
if (r != SQL_SUCCESS) {
|
||||
setLastError(qMakeError(QCoreApplication::translate("QODBCResult",
|
||||
@ -1879,11 +1844,7 @@ bool QODBCDriver::open(const QString & db,
|
||||
memset(connOut.data(), 0, connOut.size() * sizeof(SQLTCHAR));
|
||||
r = SQLDriverConnect(d->hDbc,
|
||||
NULL,
|
||||
#ifdef UNICODE
|
||||
toSQLTCHAR(connQStr).data(),
|
||||
#else
|
||||
(SQLCHAR*)connQStr.toUtf8().data(),
|
||||
#endif
|
||||
(SQLSMALLINT)connQStr.length(),
|
||||
connOut.data(),
|
||||
1024,
|
||||
@ -2090,12 +2051,7 @@ void QODBCDriverPrivate::checkDBMS()
|
||||
serverString.size() * sizeof(SQLTCHAR),
|
||||
&t);
|
||||
if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
|
||||
QString serverType;
|
||||
#ifdef UNICODE
|
||||
serverType = fromSQLTCHAR(serverString, t/sizeof(SQLTCHAR));
|
||||
#else
|
||||
serverType = QString::fromUtf8((const char *)serverString.constData(), t);
|
||||
#endif
|
||||
const QString serverType = fromSQLTCHAR(serverString, t / sizeof(SQLTCHAR));
|
||||
if (serverType.contains(QLatin1String("PostgreSQL"), Qt::CaseInsensitive))
|
||||
dbmsType = QSqlDriver::PostgreSQL;
|
||||
else if (serverType.contains(QLatin1String("Oracle"), Qt::CaseInsensitive))
|
||||
@ -2113,12 +2069,7 @@ void QODBCDriverPrivate::checkDBMS()
|
||||
serverString.size() * sizeof(SQLTCHAR),
|
||||
&t);
|
||||
if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
|
||||
QString serverType;
|
||||
#ifdef UNICODE
|
||||
serverType = fromSQLTCHAR(serverString, t/sizeof(SQLTCHAR));
|
||||
#else
|
||||
serverType = QString::fromUtf8((const char *)serverString.constData(), t);
|
||||
#endif
|
||||
const QString serverType = fromSQLTCHAR(serverString, t / sizeof(SQLTCHAR));
|
||||
isFreeTDSDriver = serverType.contains(QLatin1String("tdsodbc"), Qt::CaseInsensitive);
|
||||
unicode = unicode && !isFreeTDSDriver;
|
||||
}
|
||||
@ -2144,11 +2095,7 @@ void QODBCDriverPrivate::checkHasMultiResults()
|
||||
driverResponse.size() * sizeof(SQLTCHAR),
|
||||
&length);
|
||||
if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
|
||||
#ifdef UNICODE
|
||||
hasMultiResultSets = fromSQLTCHAR(driverResponse, length/sizeof(SQLTCHAR)).startsWith(QLatin1Char('Y'));
|
||||
#else
|
||||
hasMultiResultSets = QString::fromUtf8((const char *)driverResponse.constData(), length).startsWith(QLatin1Char('Y'));
|
||||
#endif
|
||||
}
|
||||
|
||||
void QODBCDriverPrivate::checkDateTimePrecision()
|
||||
@ -2289,11 +2236,7 @@ QStringList QODBCDriver::tables(QSql::TableType type) const
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
#ifdef UNICODE
|
||||
toSQLTCHAR(joinedTableTypeString).data(),
|
||||
#else
|
||||
(SQLCHAR*)joinedTableTypeString.toUtf8().data(),
|
||||
#endif
|
||||
joinedTableTypeString.length() /* characters, not bytes */);
|
||||
|
||||
if (r != SQL_SUCCESS)
|
||||
@ -2369,23 +2312,11 @@ QSqlIndex QODBCDriver::primaryIndex(const QString& tablename) const
|
||||
(SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
|
||||
SQL_IS_UINTEGER);
|
||||
r = SQLPrimaryKeys(hStmt,
|
||||
#ifdef UNICODE
|
||||
catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).data(),
|
||||
#else
|
||||
catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().data(),
|
||||
#endif
|
||||
catalog.length(),
|
||||
#ifdef UNICODE
|
||||
schema.length() == 0 ? NULL : toSQLTCHAR(schema).data(),
|
||||
#else
|
||||
schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().data(),
|
||||
#endif
|
||||
schema.length(),
|
||||
#ifdef UNICODE
|
||||
toSQLTCHAR(table).data(),
|
||||
#else
|
||||
(SQLCHAR*)table.toUtf8().data(),
|
||||
#endif
|
||||
table.length() /* in characters, not in bytes */);
|
||||
|
||||
// if the SQLPrimaryKeys() call does not succeed (e.g the driver
|
||||
@ -2394,23 +2325,11 @@ QSqlIndex QODBCDriver::primaryIndex(const QString& tablename) const
|
||||
if (r != SQL_SUCCESS) {
|
||||
r = SQLSpecialColumns(hStmt,
|
||||
SQL_BEST_ROWID,
|
||||
#ifdef UNICODE
|
||||
catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).data(),
|
||||
#else
|
||||
catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().data(),
|
||||
#endif
|
||||
catalog.length(),
|
||||
#ifdef UNICODE
|
||||
schema.length() == 0 ? NULL : toSQLTCHAR(schema).data(),
|
||||
#else
|
||||
schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().data(),
|
||||
#endif
|
||||
schema.length(),
|
||||
#ifdef UNICODE
|
||||
toSQLTCHAR(table).data(),
|
||||
#else
|
||||
(SQLCHAR*)table.toUtf8().data(),
|
||||
#endif
|
||||
table.length(),
|
||||
SQL_SCOPE_CURROW,
|
||||
SQL_NULLABLE);
|
||||
@ -2495,23 +2414,11 @@ QSqlRecord QODBCDriver::record(const QString& tablename) const
|
||||
(SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
|
||||
SQL_IS_UINTEGER);
|
||||
r = SQLColumns(hStmt,
|
||||
#ifdef UNICODE
|
||||
catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).data(),
|
||||
#else
|
||||
catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().data(),
|
||||
#endif
|
||||
catalog.length(),
|
||||
#ifdef UNICODE
|
||||
schema.length() == 0 ? NULL : toSQLTCHAR(schema).data(),
|
||||
#else
|
||||
schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().data(),
|
||||
#endif
|
||||
schema.length(),
|
||||
#ifdef UNICODE
|
||||
toSQLTCHAR(table).data(),
|
||||
#else
|
||||
(SQLCHAR*)table.toUtf8().data(),
|
||||
#endif
|
||||
table.length(),
|
||||
NULL,
|
||||
0);
|
||||
|
Loading…
Reference in New Issue
Block a user