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