ibase: Fix the compilation and include it again so it can be detected

Change-Id: I38721155f090173862da8beab8cb04b2e015dcff
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
Andy Shaw 2021-01-13 07:48:15 +01:00
parent fe7cbf8fe6
commit feb20459bd
5 changed files with 87 additions and 19 deletions

51
cmake/FindInterbase.cmake Normal file
View File

@ -0,0 +1,51 @@
#.rst:
# FindInterbase
# ---------
#
# Try to locate the Interbase client library.
# If found, this will define the following variables:
#
# ``Interbase_FOUND``
# True if the Interbase library is available
# ``Interbase_INCLUDE_DIR``
# The Interbase include directories
# ``Interbase_LIBRARY``
# The Interbase libraries for linking
#
# If ``Interbase_FOUND`` is TRUE, it will also define the following
# imported target:
#
# ``Interbase::Interbase``
# The Interbase client library
find_path(Interbase_INCLUDE_DIR
NAMES ibase.h
HINTS ${Interbase_INCLUDEDIR}
)
find_library(Interbase_LIBRARY
NAMES firebase_ms fbclient gds
HINTS ${Interbase_LIBDIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Interbase DEFAULT_MSG Interbase_LIBRARY Interbase_INCLUDE_DIR)
if(Interbase_FOUND)
set(Interbase_INCLUDE_DIRS "${Interbase_INCLUDE_DIR}")
set(Interbase_LIBRARIES "${Interbase_LIBRARY}")
if(NOT TARGET Interbase::Interbase)
add_library(Interbase::Interbase UNKNOWN IMPORTED)
set_target_properties(Interbase::Interbase PROPERTIES
IMPORTED_LOCATION "${Interbase_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${Interbase_INCLUDE_DIRS};")
endif()
endif()
mark_as_advanced(Interbase_INCLUDE_DIR Interbase_LIBRARY)
include(FeatureSummary)
set_package_properties(Interbase PROPERTIES
URL "https://www.embarcadero.com/products/interbase"
DESCRIPTION "Interbase client library")

View File

@ -72,7 +72,7 @@ if(QT_FEATURE_sql_sqlite2)
endif() endif()
if(QT_FEATURE_sql_ibase) if(QT_FEATURE_sql_ibase)
# TODO add_subdirectory(ibase) add_subdirectory(ibase)
endif() endif()
if(NOT CMAKE_PROJECT_NAME STREQUAL "QtBase" AND NOT CMAKE_PROJECT_NAME STREQUAL "Qt") if(NOT CMAKE_PROJECT_NAME STREQUAL "QtBase" AND NOT CMAKE_PROJECT_NAME STREQUAL "Qt")

View File

@ -16,6 +16,7 @@ qt_find_package(PostgreSQL PROVIDED_TARGETS PostgreSQL::PostgreSQL MODULE_NAME s
qt_find_package(Oracle PROVIDED_TARGETS Oracle::OCI MODULE_NAME sqldrivers QMAKE_LIB oci) qt_find_package(Oracle PROVIDED_TARGETS Oracle::OCI MODULE_NAME sqldrivers QMAKE_LIB oci)
qt_find_package(ODBC PROVIDED_TARGETS ODBC::ODBC MODULE_NAME sqldrivers QMAKE_LIB odbc) qt_find_package(ODBC PROVIDED_TARGETS ODBC::ODBC MODULE_NAME sqldrivers QMAKE_LIB odbc)
qt_find_package(SQLite3 PROVIDED_TARGETS SQLite::SQLite3 MODULE_NAME sqldrivers QMAKE_LIB sqlite3) qt_find_package(SQLite3 PROVIDED_TARGETS SQLite::SQLite3 MODULE_NAME sqldrivers QMAKE_LIB sqlite3)
qt_find_package(Interbase PROVIDED_TARGETS Interbase::Interbase MODULE_NAME sqldrivers QMAKE_LIB ibase)
if(NOT WIN32 AND QT_FEATURE_system_zlib) if(NOT WIN32 AND QT_FEATURE_system_zlib)
qt_add_qmake_lib_dependency(sqlite3 zlib) qt_add_qmake_lib_dependency(sqlite3 zlib)
endif() endif()
@ -33,7 +34,7 @@ qt_feature("sql-db2" PRIVATE
) )
qt_feature("sql-ibase" PRIVATE qt_feature("sql-ibase" PRIVATE
LABEL "InterBase" LABEL "InterBase"
CONDITION libs.ibase OR FIXME CONDITION Interbase_FOUND
) )
qt_feature("sql-mysql" PRIVATE qt_feature("sql-mysql" PRIVATE
LABEL "MySql" LABEL "MySql"

View File

@ -0,0 +1,14 @@
qt_internal_add_plugin(QIBaseDriverPlugin
OUTPUT_NAME qsqlibase
TYPE sqldrivers
SOURCES
main.cpp
qsql_ibase.cpp qsql_ibase_p.h
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_CAST_TO_ASCII
PUBLIC_LIBRARIES
Interbase::Interbase
Qt::Core
Qt::CorePrivate
Qt::SqlPrivate)

View File

@ -158,7 +158,7 @@ static void delDA(XSQLDA *&sqlda)
sqlda = 0; sqlda = 0;
} }
static int qIBaseTypeName(int iType, bool hasScale) static QMetaType::Type qIBaseTypeName(int iType, bool hasScale)
{ {
switch (iType) { switch (iType) {
case blr_varying: case blr_varying:
@ -192,7 +192,7 @@ static int qIBaseTypeName(int iType, bool hasScale)
return QMetaType::UnknownType; return QMetaType::UnknownType;
} }
static int qIBaseTypeName2(int iType, bool hasScale) static QMetaType::Type qIBaseTypeName2(int iType, bool hasScale)
{ {
switch(iType & ~1) { switch(iType & ~1) {
case SQL_VARYING: case SQL_VARYING:
@ -674,7 +674,7 @@ static char* qFillBufferWithString(char *buffer, const QString& string,
} }
static char* createArrayBuffer(char *buffer, const QList<QVariant> &list, static char* createArrayBuffer(char *buffer, const QList<QVariant> &list,
int type, short curDim, ISC_ARRAY_DESC *arrayDesc, QMetaType::Type type, short curDim, ISC_ARRAY_DESC *arrayDesc,
QString& error) QString& error)
{ {
int i; int i;
@ -971,8 +971,9 @@ bool QIBaseResult::exec()
QList<QVariant>& values = boundValues(); QList<QVariant>& values = boundValues();
int i; int i;
if (values.count() > d->inda->sqld) { if (values.count() > d->inda->sqld) {
qWarning("QIBaseResult::exec: Parameter mismatch, expected %d, got %d parameters", qWarning() << QLatin1String("QIBaseResult::exec: Parameter mismatch, expected") <<
d->inda->sqld, values.count()); d->inda->sqld << QLatin1String(", got") << values.count() <<
QLatin1String("parameters");
return false; return false;
} }
int para = 0; int para = 0;
@ -1137,17 +1138,18 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx)
if ((d->sqlda->sqlvar[i].sqltype & 1) && *d->sqlda->sqlvar[i].sqlind) { if ((d->sqlda->sqlvar[i].sqltype & 1) && *d->sqlda->sqlvar[i].sqlind) {
// null value // null value
QVariant v; QVariant v;
v.convert(qIBaseTypeName2(d->sqlda->sqlvar[i].sqltype, d->sqlda->sqlvar[i].sqlscale < 0)); v.convert(QMetaType(qIBaseTypeName2(d->sqlda->sqlvar[i].sqltype,
d->sqlda->sqlvar[i].sqlscale < 0)));
if (v.userType() == QMetaType::Double) { if (v.userType() == QMetaType::Double) {
switch(numericalPrecisionPolicy()) { switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32: case QSql::LowPrecisionInt32:
v.convert(QMetaType::Int); v.convert(QMetaType(QMetaType::Int));
break; break;
case QSql::LowPrecisionInt64: case QSql::LowPrecisionInt64:
v.convert(QMetaType::LongLong); v.convert(QMetaType(QMetaType::LongLong));
break; break;
case QSql::HighPrecision: case QSql::HighPrecision:
v.convert(QMetaType::QString); v.convert(QMetaType(QMetaType::QString));
break; break;
case QSql::LowPrecisionDouble: case QSql::LowPrecisionDouble:
// no conversion // no conversion
@ -1220,19 +1222,19 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx)
QVariant v = row[idx]; QVariant v = row[idx];
switch(numericalPrecisionPolicy()) { switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32: case QSql::LowPrecisionInt32:
if (v.convert(QMetaType::Int)) if (v.convert(QMetaType(QMetaType::Int)))
row[idx]=v; row[idx]=v;
break; break;
case QSql::LowPrecisionInt64: case QSql::LowPrecisionInt64:
if (v.convert(QMetaType::LongLong)) if (v.convert(QMetaType(QMetaType::LongLong)))
row[idx]=v; row[idx]=v;
break; break;
case QSql::LowPrecisionDouble: case QSql::LowPrecisionDouble:
if (v.convert(QMetaType::Double)) if (v.convert(QMetaType(QMetaType::Double)))
row[idx]=v; row[idx]=v;
break; break;
case QSql::HighPrecision: case QSql::HighPrecision:
if (v.convert(QMetaType::QString)) if (v.convert(QMetaType(QMetaType::QString)))
row[idx]=v; row[idx]=v;
break; break;
} }
@ -1359,7 +1361,7 @@ QSqlRecord QIBaseResult::record() const
for (int i = 0; i < d->sqlda->sqld; ++i) { for (int i = 0; i < d->sqlda->sqld; ++i) {
v = d->sqlda->sqlvar[i]; v = d->sqlda->sqlvar[i];
QSqlField f(QString::fromLatin1(v.aliasname, v.aliasname_length).simplified(), QSqlField f(QString::fromLatin1(v.aliasname, v.aliasname_length).simplified(),
qIBaseTypeName2(v.sqltype, v.sqlscale < 0), QMetaType(qIBaseTypeName2(v.sqltype, v.sqlscale < 0)),
QString::fromLatin1(v.relname, v.relname_length)); QString::fromLatin1(v.relname, v.relname_length));
f.setLength(v.sqllen); f.setLength(v.sqllen);
f.setPrecision(qAbs(v.sqlscale)); f.setPrecision(qAbs(v.sqlscale));
@ -1647,7 +1649,7 @@ QSqlRecord QIBaseDriver::record(const QString& tablename) const
while (q.next()) { while (q.next()) {
int type = q.value(1).toInt(); int type = q.value(1).toInt();
bool hasScale = q.value(3).toInt() < 0; bool hasScale = q.value(3).toInt() < 0;
QSqlField f(q.value(0).toString().simplified(), qIBaseTypeName(type, hasScale), tablename); QSqlField f(q.value(0).toString().simplified(), QMetaType(qIBaseTypeName(type, hasScale)), tablename);
if (hasScale) { if (hasScale) {
f.setLength(q.value(4).toInt()); f.setLength(q.value(4).toInt());
f.setPrecision(qAbs(q.value(3).toInt())); f.setPrecision(qAbs(q.value(3).toInt()));
@ -1689,7 +1691,7 @@ QSqlIndex QIBaseDriver::primaryIndex(const QString &table) const
while (q.next()) { while (q.next()) {
QSqlField field(q.value(1).toString().simplified(), QSqlField field(q.value(1).toString().simplified(),
qIBaseTypeName(q.value(2).toInt(), q.value(3).toInt() < 0), QMetaType(qIBaseTypeName(q.value(2).toInt(), q.value(3).toInt() < 0)),
tablename); tablename);
index.append(field); //TODO: asc? desc? index.append(field); //TODO: asc? desc?
index.setName(q.value(0).toString()); index.setName(q.value(0).toString());
@ -1700,7 +1702,7 @@ QSqlIndex QIBaseDriver::primaryIndex(const QString &table) const
QString QIBaseDriver::formatValue(const QSqlField &field, bool trimStrings) const QString QIBaseDriver::formatValue(const QSqlField &field, bool trimStrings) const
{ {
switch (field.type()) { switch (field.metaType().id()) {
case QMetaType::QDateTime: { case QMetaType::QDateTime: {
QDateTime datetime = field.value().toDateTime(); QDateTime datetime = field.value().toDateTime();
if (datetime.isValid()) if (datetime.isValid())