main build file and sql database cruft review

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2017-08-08 16:33:19 +00:00
parent 1944c376f0
commit 58219108e1
7 changed files with 80 additions and 758 deletions

View file

@ -209,7 +209,7 @@ if(KATIE_ALLINONE)
add_definitions(-DQT_ALLINONE)
endif()
# for 3rd party source used in test components
# for 3rd party source used in test component
check_include_file(sys/time.h HAVE_SYS_TIME_H)
if(HAVE_SYS_TIME_H)
add_definitions(-DTIME_WITH_SYS_TIME=1 -DHAVE_SYS_TIME_H)
@ -273,6 +273,14 @@ set_package_properties(PCRE PROPERTIES
TYPE REQUIRED
)
find_package(X11 COMPONENTS ICE SM Xcursor Xext Xfixes XSync XShm XShape Xi Xinerama Xrandr Xrender X11 Xtst Xt)
set_package_properties(X11 PROPERTIES
PURPOSE "Required for X11/X.Org integration support"
DESCRIPTION "Open source implementation of the X Window System"
URL "http://www.x.org"
TYPE REQUIRED
)
find_package(Git)
set_package_properties(Git PROPERTIES
PURPOSE "Git checkout stored for the sake of bug reports"
@ -293,6 +301,23 @@ find_package(NIS)
set_package_properties(NIS PROPERTIES
PURPOSE "Required for Network Information Service support"
DESCRIPTION "Standard C library specific NIS implementation"
URL ""
TYPE RECOMMENDED
)
find_package(Resolv)
set_package_properties(Resolv PROPERTIES
PURPOSE "Required for domain resolving support"
DESCRIPTION "Standard C library specific resolv implementation"
URL ""
TYPE RECOMMENDED
)
find_package(NSL)
set_package_properties(NSL PROPERTIES
PURPOSE "Required for printing information support"
DESCRIPTION "Standard C library specific NSL implementation"
URL ""
TYPE RECOMMENDED
)
@ -377,6 +402,7 @@ set_package_properties(HarfBuzz PROPERTIES
TYPE RECOMMENDED
)
# v2.22.0+ to avoid too many conditionals in sources
find_package(GLib2 2.22.0)
set_package_properties(GLib2 PROPERTIES
PURPOSE "Required for glib mainloop support"
@ -393,12 +419,20 @@ set_package_properties(DBus PROPERTIES
TYPE RECOMMENDED
)
find_package(Sqlite)
set_package_properties(Sqlite PROPERTIES
PURPOSE "Required for SQLite database support"
DESCRIPTION "Software library that implements SQL database engine"
URL "https://www.sqlite.org/"
TYPE RECOMMENDED
)
find_package(ODBC)
set_package_properties(ODBC PROPERTIES
PURPOSE "Required for ODBC database support"
DESCRIPTION "The definitive standard for ODBC on non MS Windows platforms"
URL "http://www.unixodbc.org"
TYPE RECOMMENDED
TYPE OPTIONAL
)
find_package(PostgreSQL)
@ -417,39 +451,6 @@ set_package_properties(MySQL PROPERTIES
TYPE OPTIONAL
)
find_package(Sqlite)
set_package_properties(Sqlite PROPERTIES
PURPOSE "Required for SQLite database support"
DESCRIPTION "Software library that implements SQL database engine"
URL "https://www.sqlite.org/"
TYPE RECOMMENDED
)
find_package(Resolv)
set_package_properties(Resolv PROPERTIES
PURPOSE "Required for domain resolving support"
DESCRIPTION ""
URL ""
TYPE RECOMMENDED
)
find_package(NSL)
set_package_properties(NSL PROPERTIES
PURPOSE "Required for printing information support"
DESCRIPTION ""
URL ""
TYPE RECOMMENDED
)
find_package(X11 COMPONENTS ICE SM Xcursor Xext Xfixes XSync XShm XShape Xi Xinerama Xrandr Xrender X11 Xtst Xt)
set_package_properties(X11 PROPERTIES
PURPOSE "Required for X11/X.Org integration support"
DESCRIPTION "Open source implementation of the X Window System"
URL "http://www.x.org"
TYPE REQUIRED
)
if(PYTHONINTERP_FOUND)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/genmap.py
@ -507,6 +508,14 @@ if(NOT WITH_CUPS OR NOT CUPS_FOUND)
katie_definition(-DQT_NO_CUPS -DQT_NO_LPR)
endif()
if(NOT WITH_RESOLV OR NOT RESOLV_FOUND)
katie_definition(-DQT_NO_RESOLV)
endif()
if(NOT WITH_NSL OR NOT NSL_FOUND)
katie_definition(-DQT_NO_NSL)
endif()
if(NOT WITH_NIS OR NOT NIS_FOUND)
katie_definition(-DQT_NO_NIS)
endif()
@ -527,14 +536,6 @@ if(NOT WITH_TIFF OR NOT TIFF_FOUND)
katie_definition(-DQT_NO_IMAGEFORMAT_TIFF)
endif()
if(NOT WITH_RESOLV OR NOT RESOLV_FOUND)
katie_definition(-DQT_NO_RESOLV)
endif()
if(NOT WITH_NSL OR NOT NSL_FOUND)
katie_definition(-DQT_NO_NSL)
endif()
# conditional features
if(NOT WITH_ACCESSIBILITY)
katie_definition(-DQT_NO_ACCESSIBILITY)

View file

@ -85,7 +85,7 @@
QT_BEGIN_NAMESPACE
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_TEXTCODECPLUGIN)
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, codecsloader,
(QTextCodecFactoryInterface_iid, QLatin1String("/codecs")))
#endif
@ -127,7 +127,7 @@ static bool nameMatch(const QByteArray &name, const QByteArray &test)
static QTextCodec *createForName(const QByteArray &name)
{
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_TEXTCODECPLUGIN)
QFactoryLoader *l = loader();
QFactoryLoader *l = codecsloader();
QStringList keys = l->keys();
for (int i = 0; i < keys.size(); ++i) {
if (nameMatch(name, keys.at(i).toLatin1())) {
@ -149,7 +149,7 @@ static QTextCodec *createForMib(int mib)
#ifndef QT_NO_TEXTCODECPLUGIN
QString name = QLatin1String("MIB: ") + QString::number(mib);
if (QTextCodecFactoryInterface *factory
= qobject_cast<QTextCodecFactoryInterface*>(loader()->instance(name)))
= qobject_cast<QTextCodecFactoryInterface*>(codecsloader()->instance(name)))
return factory->create(name);
#else
Q_UNUSED(mib);
@ -797,7 +797,7 @@ QList<QByteArray> QTextCodec::availableCodecs()
#endif
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_TEXTCODECPLUGIN)
QFactoryLoader *l = loader();
QFactoryLoader *l = codecsloader();
QStringList keys = l->keys();
for (int i = 0; i < keys.size(); ++i) {
if (!keys.at(i).startsWith(QLatin1String("MIB: "))) {
@ -833,7 +833,7 @@ QList<int> QTextCodec::availableMibs()
#endif
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_TEXTCODECPLUGIN)
QFactoryLoader *l = loader();
QFactoryLoader *l = codecsloader();
QStringList keys = l->keys();
for (int i = 0; i < keys.size(); ++i) {
if (keys.at(i).startsWith(QLatin1String("MIB: "))) {

View file

@ -42,11 +42,7 @@
#include "qsqldatabase.h"
#include "qsqlquery.h"
#ifdef Q_OS_WIN32
// Conflicting declarations of LPCBYTE in sqlfront.h and winscard.h
#define _WINSCARD_H_
#endif
// NOTE: if the following are defined then drivers must be built-in
#ifdef QT_SQL_PSQL
#include "../drivers/psql/qsql_psql.h"
#endif
@ -56,35 +52,9 @@
#ifdef QT_SQL_ODBC
#include "../drivers/odbc/qsql_odbc.h"
#endif
#ifdef QT_SQL_OCI
#include "../drivers/oci/qsql_oci.h"
#endif
#ifdef QT_SQL_TDS
// conflicting RETCODE typedef between odbc and freetds
#define RETCODE DBRETCODE
#include "../drivers/tds/qsql_tds.h"
#undef RETCODE
#endif
#ifdef QT_SQL_DB2
#include "../drivers/db2/qsql_db2.h"
#endif
#ifdef QT_SQL_SQLITE
#include "../drivers/sqlite/qsql_sqlite.h"
#endif
#ifdef QT_SQL_SQLITE2
#include "../drivers/sqlite2/qsql_sqlite2.h"
#endif
#ifdef QT_SQL_IBASE
#undef SQL_FLOAT // avoid clash with ODBC
#undef SQL_DOUBLE
#undef SQL_TIMESTAMP
#undef SQL_TYPE_TIME
#undef SQL_TYPE_DATE
#undef SQL_DATE
#define SCHAR IBASE_SCHAR // avoid clash with ODBC (older versions of ibase.h with Firebird)
#include "../drivers/ibase/qsql_ibase.h"
#undef SCHAR
#endif
#include "qdebug.h"
#include "qcoreapplication.h"
@ -102,7 +72,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, sqlloader,
(QSqlDriverFactoryInterface_iid,
QLatin1String("/sqldrivers")))
#endif
@ -555,29 +525,12 @@ QStringList QSqlDatabase::drivers()
list << QLatin1String("QODBC3");
list << QLatin1String("QODBC");
#endif
#ifdef QT_SQL_OCI
list << QLatin1String("QOCI8");
list << QLatin1String("QOCI");
#endif
#ifdef QT_SQL_TDS
list << QLatin1String("QTDS7");
list << QLatin1String("QTDS");
#endif
#ifdef QT_SQL_DB2
list << QLatin1String("QDB2");
#endif
#ifdef QT_SQL_SQLITE
list << QLatin1String("QSQLITE");
#endif
#ifdef QT_SQL_SQLITE2
list << QLatin1String("QSQLITE2");
#endif
#ifdef QT_SQL_IBASE
list << QLatin1String("QIBASE");
#endif
#ifndef QT_NO_LIBRARY
if (QFactoryLoader *fl = loader()) {
if (QFactoryLoader *fl = sqlloader()) {
QStringList keys = fl->keys();
for (QStringList::const_iterator i = keys.constBegin(); i != keys.constEnd(); ++i) {
if (!list.contains(*i))
@ -652,15 +605,10 @@ QStringList QSqlDatabase::connectionNames()
\table
\header \i Driver Type \i Description
\row \i QDB2 \i IBM DB2
\row \i QIBASE \i Borland InterBase Driver
\row \i QMYSQL \i MySQL Driver
\row \i QOCI \i Oracle Call Interface Driver
\row \i QODBC \i ODBC Driver (includes Microsoft SQL Server)
\row \i QPSQL \i PostgreSQL Driver
\row \i QSQLITE \i SQLite version 3 or above
\row \i QSQLITE2 \i SQLite version 2
\row \i QTDS \i Sybase Adaptive Server
\endtable
Additional third party drivers, including your own custom
@ -738,26 +686,10 @@ void QSqlDatabasePrivate::init(const QString &type)
if (type == QLatin1String("QODBC") || type == QLatin1String("QODBC3"))
driver = new QODBCDriver();
#endif
#ifdef QT_SQL_OCI
if (type == QLatin1String("QOCI") || type == QLatin1String("QOCI8"))
driver = new QOCIDriver();
#endif
#ifdef QT_SQL_TDS
if (type == QLatin1String("QTDS") || type == QLatin1String("QTDS7"))
driver = new QTDSDriver();
#endif
#ifdef QT_SQL_DB2
if (type == QLatin1String("QDB2"))
driver = new QDB2Driver();
#endif
#ifdef QT_SQL_SQLITE
if (type == QLatin1String("QSQLITE"))
driver = new QSQLiteDriver();
#endif
#ifdef QT_SQL_SQLITE2
if (type == QLatin1String("QSQLITE2"))
driver = new QSQLite2Driver();
#endif
#ifdef QT_SQL_IBASE
if (type == QLatin1String("QIBASE"))
driver = new QIBaseDriver();
@ -775,8 +707,8 @@ void QSqlDatabasePrivate::init(const QString &type)
}
#ifndef QT_NO_LIBRARY
if (!driver && loader()) {
if (QSqlDriverFactoryInterface *factory = qobject_cast<QSqlDriverFactoryInterface*>(loader()->instance(type)))
if (!driver && sqlloader()) {
if (QSqlDriverFactoryInterface *factory = qobject_cast<QSqlDriverFactoryInterface*>(sqlloader()->instance(type)))
driver = factory->create(type);
}
#endif // QT_NO_LIBRARY

View file

@ -1,3 +1,6 @@
# TODO: fix them warnings
add_definitions(-UQT_ASCII_CAST_WARNINGS)
katie_test(tst_qlocale
${CMAKE_CURRENT_SOURCE_DIR}/tst_qlocale.cpp
)

View file

@ -0,0 +1,9 @@
# TODO: fix them warnings
add_definitions(-UQT_ASCII_CAST_WARNINGS)
katie_test(tst_qsqldatabase
${CMAKE_CURRENT_SOURCE_DIR}/tst_qsqldatabase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tst_databases.h
)
target_link_libraries(tst_qsqldatabase KtSql)

View file

@ -109,11 +109,10 @@ inline static QString qTableName( const QString& prefix, QSqlDriver* driver )
inline static bool testWhiteSpaceNames( const QString &name )
{
/* return name.startsWith( QLatin1String("QPSQL") )
return name.startsWith( QLatin1String("QPSQL") )
|| name.startsWith( QLatin1String("QODBC") )
|| name.startsWith( QLatin1String("QSQLITE") )
|| name.startsWith( QLatin1String("QMYSQL") );*/
return name != QLatin1String("QSQLITE2");
|| name.startsWith( QLatin1String("QMYSQL") );
}
inline static QString toHex( const QString& binary )
@ -240,16 +239,9 @@ public:
void addDbs()
{
// addDb( "QOCI8", "//horsehead.nokia.troll.no:1521/pony.troll.no", "scott", "tiger" ); // Oracle 9i on horsehead
// addDb( "QOCI8", "//horsehead.nokia.troll.no:1521/ustest.troll.no", "scott", "tiger", "" ); // Oracle 9i on horsehead
// addDb( "QOCI8", "//iceblink.nokia.troll.no:1521/ice.troll.no", "scott", "tiger", "" ); // Oracle 8 on iceblink (not currently working)
// addDb( "QOCI", "//silence.nokia.troll.no:1521/testdb", "scott", "tiger" ); // Oracle 10g on silence
// addDb( "QOCI", "//bq-oracle10g.apac.nokia.com:1521/XE", "scott", "tiger" ); // Oracle 10gexpress
// This requires a local ODBC data source to be configured( pointing to a MySql database )
// addDb( "QODBC", "mysqlodbc", "troll", "trond" );
// addDb( "QODBC", "SqlServer", "troll", "trond" );
// addDb( "QTDS7", "testdb", "troll", "trondk", "horsehead" );
// addDb( "QODBC", "silencetestdb", "troll", "trond", "silence" );
// addDb( "QODBC", "horseheadtestdb", "troll", "trondk", "horsehead" );
@ -275,24 +267,9 @@ public:
// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "bq-pgsql84.apac.nokia.com" ); // Version 8.4.1-2.1.i586
// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "bq-pgsql90.apac.nokia.com" ); // Version 9.0.0
// addDb( "QDB2", "testdb", "troll", "trond", "silence.nokia.troll.no" ); // DB2 v9.1 on silence
// addDb( "QDB2", "testdb", "testuser", "Ee4Gabf6_", "bq-db2-972.apac.nokia.com" ); // DB2
// yes - interbase really wants the physical path on the host machine.
// addDb( "QIBASE", "/opt/interbase/qttest.gdb", "SYSDBA", "masterkey", "horsehead.nokia.troll.no" );
// addDb( "QIBASE", "silence.troll.no:c:\\ibase\\testdb", "SYSDBA", "masterkey", "" ); // InterBase 7.5 on silence
// addDb( "QIBASE", "silence.troll.no:c:\\ibase\\testdb_ascii", "SYSDBA", "masterkey", "" ); // InterBase 7.5 on silence
// addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "firebird1-nokia.trolltech.com.au" ); // Firebird 1.5.5
// addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "firebird2-nokia.trolltech.com.au" ); // Firebird 2.1.1
// addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "bq-firebird1.apac.nokia.com" ); // Firebird 1.5.5
// addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "bq-firebird2.apac.nokia.com" ); // Firebird 2.1.1
// use in-memory database to prevent local files
// addDb("QSQLITE", ":memory:");
addDb( QLatin1String("QSQLITE"), QDir::toNativeSeparators(sqLiteFileName()));
// addDb( "QSQLITE2", QDir::toNativeSeparators(QDir::tempPath()+"/foo2.db") );
// addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=iceblink.nokia.troll.no\\ICEBLINK", "troll", "trond", "" );
// addDb( "QODBC3", "DRIVER={SQL Native Client};SERVER=silence.nokia.troll.no\\SQLEXPRESS", "troll", "trond", "" );
@ -302,8 +279,6 @@ public:
// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=silence.nokia.troll.no;DATABASE=testdb;PORT=2392;UID=troll;PWD=trond", "troll", "trond", "" );
// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "", "", "" );
// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2008-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "", "", "" );
// addDb( "QTDS7", "testdb", "testuser", "Ee4Gabf6_", "bq-winserv2003" );
// addDb( "QTDS7", "testdb", "testuser", "Ee4Gabf6_", "bq-winserv2008" );
// addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" );
// addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2008-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" );
// addDb( "QODBC", "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\dbs\\access\\testdb.mdb", "", "", "" );
@ -353,7 +328,7 @@ public:
{
QString res = db.driverName() + QLatin1Char('@');
if ( db.driverName().startsWith( QLatin1String("QODBC") ) || db.driverName().startsWith( QLatin1String("QOCI") ) ) {
if ( db.driverName().startsWith( QLatin1String("QODBC") ) ) {
res += db.databaseName();
} else {
res += db.hostName();
@ -455,19 +430,7 @@ public:
if ( db.driverName().startsWith( QLatin1String("QPSQL") ) )
return QLatin1String( "bytea" );
if ( db.driverName().startsWith( QLatin1String("QTDS") )
|| isSqlServer( db )
|| isMSAccess( db ) )
return QLatin1String( "image" );
if ( db.driverName().startsWith( QLatin1String("QDB2") ) )
return QString( "blob(%1)" ).arg( blobSize );
if ( db.driverName().startsWith( QLatin1String("QIBASE") ) )
return QLatin1String( "blob sub_type 0 segment size 4096" );
if ( db.driverName().startsWith( QLatin1String("QOCI") )
|| db.driverName().startsWith( QLatin1String("QSQLITE") ) )
if ( db.driverName().startsWith( QLatin1String("QSQLITE") ) )
return QLatin1String( "blob" );
qDebug() << "tst_Databases::blobTypeName: Don't know the blob type for" << dbToString( db );
@ -479,12 +442,8 @@ public:
{
if ( db.driverName().startsWith( QLatin1String("QMYSQL") ) )
return QLatin1String( "AUTO_INCREMENT" );
if ( db.driverName().startsWith( QLatin1String("QTDS") ) )
return QLatin1String( "IDENTITY" );
/* if ( db.driverName().startsWith( QLatin1String("QPSQL") ) )
return QLatin1String( "SERIAL" );*/
// if ( db.driverName().startsWith( QLatin1String("QDB2") ) )
// return QLatin1String( "GENERATED BY DEFAULT AS IDENTITY" );
return QString();
}
@ -536,10 +495,6 @@ public:
{
return db.driverName().startsWith(QLatin1String("QMYSQL")) || (db.driverName().startsWith(QLatin1String("QODBC")) && db.databaseName().contains(QLatin1String("MySQL"), Qt::CaseInsensitive) );
}
static bool isDB2( QSqlDatabase db )
{
return db.driverName().startsWith(QLatin1String("QDB2")) || (db.driverName().startsWith(QLatin1String("QODBC")) && db.databaseName().contains(QLatin1String("db2"), Qt::CaseInsensitive) );
}
// -1 on fail, else Oracle version
static int getOraVersion( QSqlDatabase db )

View file

@ -80,8 +80,6 @@ private slots:
void open();
void tables_data() { generic_data(); }
void tables();
void oci_tables_data() { generic_data("QOCI"); }
void oci_tables();
void transaction_data() { generic_data(); }
void transaction();
void eventNotification_data() { generic_data(); }
@ -95,23 +93,13 @@ private slots:
void recordMySQL();
void recordPSQL_data() { generic_data("QPSQL"); }
void recordPSQL();
void recordOCI_data() { generic_data("QOCI"); }
void recordOCI();
void recordTDS_data() { generic_data("QTDS"); }
void recordTDS();
void recordDB2_data() { generic_data("QDB2"); }
void recordDB2();
void recordSQLite_data() { generic_data("QSQLITE"); }
void recordSQLite();
void recordAccess_data() { generic_data("QODBC"); }
void recordAccess();
void recordSQLServer_data() { generic_data("QODBC"); }
void recordSQLServer();
void recordIBase_data() {generic_data("QIBASE"); }
void recordIBase();
void eventNotificationIBase_data() { generic_data("QIBASE"); }
void eventNotificationIBase();
void eventNotificationPSQL_data() { generic_data("QPSQL"); }
void eventNotificationPSQL();
@ -137,9 +125,6 @@ private slots:
void precisionPolicy_data() { generic_data(); }
void precisionPolicy();
void db2_valueCacheUpdate_data() { generic_data("QDB2"); }
void db2_valueCacheUpdate();
void psql_schemas_data() { generic_data("QPSQL"); }
void psql_schemas();
void psql_escapedIdentifiers_data() { generic_data("QPSQL"); }
@ -159,17 +144,6 @@ private slots:
void accessOdbc_strings_data() { generic_data(); }
void accessOdbc_strings();
void ibase_numericFields_data() { generic_data("QIBASE"); }
void ibase_numericFields(); // For task 125053
void ibase_fetchBlobs_data() { generic_data("QIBASE"); }
void ibase_fetchBlobs(); // For task 143471
void ibase_useCustomCharset_data() { generic_data("QIBASE"); }
void ibase_useCustomCharset(); // For task 134608
void ibase_procWithoutReturnValues_data() { generic_data("QIBASE"); } // For task 165423
void ibase_procWithoutReturnValues();
void ibase_procWithReturnValues_data() { generic_data("QIBASE"); } // For task 177530
void ibase_procWithReturnValues();
void odbc_reopenDatabase_data() { generic_data("QODBC"); }
void odbc_reopenDatabase();
void odbc_uniqueidentifier_data() { generic_data("QODBC"); }
@ -181,15 +155,6 @@ private slots:
void odbc_testqGetString_data() { generic_data("QODBC"); }
void odbc_testqGetString();
void oci_serverDetach_data() { generic_data("QOCI"); }
void oci_serverDetach(); // For task 154518
void oci_xmltypeSupport_data() { generic_data("QOCI"); }
void oci_xmltypeSupport();
void oci_fieldLength_data() { generic_data("QOCI"); }
void oci_fieldLength();
void oci_synonymstest_data() { generic_data("QOCI"); }
void oci_synonymstest();
void sqlite_bindAndFetchUInt_data() { generic_data("QSQLITE"); }
void sqlite_bindAndFetchUInt();
@ -259,7 +224,7 @@ static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db)
int i = 0;
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
qs += QString(",\n %1 %2").arg(fieldDefs[ i ].fieldName()).arg(fieldDefs[ i ].typeName);
if ((db.driverName().startsWith("QTDS") || tst_Databases::isSqlServer(db)) && fieldDefs[ i ].nullable) {
if (tst_Databases::isSqlServer(db) && fieldDefs[ i ].nullable) {
qs += " null";
}
}
@ -347,7 +312,6 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
<< qTableName("uint", __FILE__)
<< qTableName("strings", __FILE__)
<< qTableName("numericfields", __FILE__)
<< qTableName("qtest_ibaseblobs", __FILE__)
<< qTableName("qtestBindBool", __FILE__)
<< qTableName("testqGetString", __FILE__)
<< qTableName("qtest_sqlguid", __FILE__)
@ -355,7 +319,7 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
<< qTableName("uint_test", __FILE__)
<< qTableName("bug_249059", __FILE__);
QSqlQuery q(0, db);
QSqlQuery q(QString(), db);
if (db.driverName().startsWith("QPSQL")) {
q.exec("drop schema " + qTableName("qtestschema", __FILE__) + " cascade");
q.exec("drop schema " + qTableName("qtestScHeMa", __FILE__) + " cascade");
@ -365,13 +329,6 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
tableNames << db.driver()->escapeIdentifier(qTableName("qtest", __FILE__) + " test", QSqlDriver::TableName);
tst_Databases::safeDropTables(db, tableNames);
if (db.driverName().startsWith("QOCI")) {
q.exec("drop user "+qTableName("CREATOR", __FILE__)+" cascade");
q.exec("drop user "+qTableName("APPUSER", __FILE__)+" cascade");
q.exec("DROP TABLE system."+qTableName("mypassword", __FILE__));
}
}
void tst_QSqlDatabase::populateTestTables(QSqlDatabase db)
@ -449,8 +406,8 @@ void tst_QSqlDatabase::errorReporting_data()
{
QTest::addColumn<QString>("driver");
QTest::newRow("QTDS") << QString::fromLatin1("QTDS");
QTest::newRow("QTDS7") << QString::fromLatin1("QTDS7");
QTest::newRow("QMYSQL") << QString::fromLatin1("QMYSQL");
QTest::newRow("QPSQL") << QString::fromLatin1("QPSQL");
}
void tst_QSqlDatabase::errorReporting()
@ -573,18 +530,12 @@ void tst_QSqlDatabase::whitespaceInIdentifiers()
QSqlRecord rec = db.record(db.driver()->escapeIdentifier(tableName, QSqlDriver::TableName));
QCOMPARE(rec.count(), 1);
QCOMPARE(rec.fieldName(0), QString("test test"));
if(db.driverName().startsWith("QOCI"))
QCOMPARE(rec.field(0).type(), QVariant::Double);
else
QCOMPARE(rec.field(0).type(), QVariant::Int);
QCOMPARE(rec.field(0).type(), QVariant::Int);
QSqlIndex idx = db.primaryIndex(db.driver()->escapeIdentifier(tableName, QSqlDriver::TableName));
QCOMPARE(idx.count(), 1);
QCOMPARE(idx.fieldName(0), QString("test test"));
if(db.driverName().startsWith("QOCI"))
QCOMPARE(idx.field(0).type(), QVariant::Double);
else
QCOMPARE(idx.field(0).type(), QVariant::Int);
QCOMPARE(idx.field(0).type(), QVariant::Int);
} else {
QSKIP("DBMS does not support whitespaces in identifiers", SkipSingle);
}
@ -625,7 +576,7 @@ void tst_QSqlDatabase::alterTable()
// this is the general test that should work on all databases.
// unfortunately no DBMS supports SQL 92/ 99 so the general
// test is more or less a joke. Please write a test for each
// database plugin (see recordOCI and so on). Use this test
// database plugin (see recordSQLite and so on). Use this test
// as a template.
void tst_QSqlDatabase::record()
{
@ -679,110 +630,6 @@ void tst_QSqlDatabase::commonFieldTest(const FieldDef fieldDefs[], QSqlDatabase
QVERIFY_SQL(q, exec("select * from " + qTableName("qtestfields", __FILE__)));
}
void tst_QSqlDatabase::recordTDS()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
static const FieldDef fieldDefs[] = {
FieldDef("tinyint", QVariant::Int, 255),
FieldDef("smallint", QVariant::Int, 32767),
FieldDef("int", QVariant::Int, 2147483647),
FieldDef("numeric(10,9)", QVariant::Double, 1.23456789),
FieldDef("decimal(10,9)", QVariant::Double, 1.23456789),
FieldDef("float(4)", QVariant::Double, 1.23456789),
FieldDef("double precision", QVariant::Double, 1.23456789),
FieldDef("real", QVariant::Double, 1.23456789),
FieldDef("smallmoney", QVariant::Double, 100.42),
FieldDef("money", QVariant::Double, 200.42),
// accuracy is that of a minute
FieldDef("smalldatetime", QVariant::DateTime, QDateTime(QDate::currentDate(), QTime(1, 2, 0, 0))),
// accuracy is that of a second
FieldDef("datetime", QVariant::DateTime, QDateTime(QDate::currentDate(), QTime(1, 2, 3, 0))),
FieldDef("char(20)", QVariant::String, "blah1"),
FieldDef("varchar(20)", QVariant::String, "blah2"),
FieldDef("nchar(20)", QVariant::String, "blah3"),
FieldDef("nvarchar(20)", QVariant::String, "blah4"),
FieldDef("text", QVariant::String, "blah5"),
FieldDef("bit", QVariant::Int, 1, false),
FieldDef()
};
const int fieldCount = createFieldTable(fieldDefs, db);
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
}
void tst_QSqlDatabase::recordOCI()
{
bool hasTimeStamp = false;
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
// runtime check for Oracle version since V8 doesn't support TIMESTAMPs
if (tst_Databases::getOraVersion(db) >= 9)
hasTimeStamp = true;
FieldDef tsdef;
FieldDef tstzdef;
FieldDef tsltzdef;
FieldDef intytm;
FieldDef intdts;
static const QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0));
if (hasTimeStamp) {
tsdef = FieldDef("timestamp", QVariant::DateTime, dt);
tstzdef = FieldDef("timestamp with time zone", QVariant::DateTime, dt);
tsltzdef = FieldDef("timestamp with local time zone", QVariant::DateTime, dt);
intytm = FieldDef("interval year to month", QVariant::String, QString("+01-01"));
intdts = FieldDef("interval day to second", QVariant::String, QString("+01 00:00:01.000000"));
}
const FieldDef fieldDefs[] = {
FieldDef("char(20)", QVariant::String, QString("blah1")),
FieldDef("varchar(20)", QVariant::String, QString("blah2")),
FieldDef("nchar(20)", QVariant::String, QString("blah3")),
FieldDef("nvarchar2(20)", QVariant::String, QString("blah4")),
FieldDef("number(10,5)", QVariant::Double, 1.1234567),
FieldDef("date", QVariant::DateTime, dt),
FieldDef("long raw", QVariant::ByteArray, QByteArray("blah5")),
FieldDef("raw(2000)", QVariant::ByteArray, QByteArray("blah6"), false),
FieldDef("blob", QVariant::ByteArray, QByteArray("blah7")),
FieldDef("clob", QVariant::String, QString("blah8")),
FieldDef("nclob", QVariant::String, QString("blah9")),
// FieldDef("bfile", QVariant::ByteArray, QByteArray("blah10")),
intytm,
intdts,
tsdef,
tstzdef,
tsltzdef,
FieldDef()
};
const int fieldCount = createFieldTable(fieldDefs, db);
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
// some additional tests
QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__));
QCOMPARE(rec.field("T_NUMBER").length(), 10);
QCOMPARE(rec.field("T_NUMBER").precision(), 5);
QSqlQuery q(db);
QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtestfields", __FILE__)));
rec = q.record();
QCOMPARE(rec.field("T_NUMBER").length(), 10);
QCOMPARE(rec.field("T_NUMBER").precision(), 5);
}
void tst_QSqlDatabase::recordPSQL()
{
QFETCH(QString, dbName);
@ -923,68 +770,6 @@ void tst_QSqlDatabase::recordMySQL()
QCOMPARE(q.value(0).toDateTime().date(), QDate::currentDate().addDays(-2));
}
void tst_QSqlDatabase::recordDB2()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
static const FieldDef fieldDefs[] = {
FieldDef("char(20)", QVariant::String, QString("Blah1")),
FieldDef("varchar(20)", QVariant::String, QString("Blah2")),
FieldDef("long varchar", QVariant::String, QString("Blah3")),
// using BOOLEAN results in "SQL0486N The BOOLEAN data type is currently only supported internally."
//X FieldDef("boolean" , QVariant::Bool, QVariant(true, 1)),
FieldDef("smallint", QVariant::Int, 32767),
FieldDef("integer", QVariant::Int, 2147483647),
FieldDef("bigint", QVariant::LongLong, Q_INT64_C(9223372036854775807)),
FieldDef("real", QVariant::Double, 1.12345),
FieldDef("double", QVariant::Double, 1.23456789),
FieldDef("float", QVariant::Double, 1.23456789),
FieldDef("decimal(10,9)", QVariant::Double, 1.234567891),
FieldDef("numeric(10,9)", QVariant::Double, 1.234567891),
FieldDef("date", QVariant::Date, QDate::currentDate()),
FieldDef("time", QVariant::Time, QTime(1, 2, 3)),
FieldDef("timestamp", QVariant::DateTime, QDateTime::currentDateTime()),
// FieldDef("graphic(20)", QVariant::String, QString("Blah4")),
// FieldDef("vargraphic(20)", QVariant::String, QString("Blah5")),
// FieldDef("long vargraphic", QVariant::String, QString("Blah6")),
//X FieldDef("datalink", QVariant::String, QString("DLVALUE('Blah10')")),
FieldDef()
};
const int fieldCount = createFieldTable(fieldDefs, db);
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
}
void tst_QSqlDatabase::recordIBase()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
static const FieldDef fieldDefs[] = {
FieldDef("char(20)", QVariant::String, QString("Blah1"), false),
FieldDef("varchar(20)", QVariant::String, QString("Blah2")),
FieldDef("smallint", QVariant::Int, 32767),
FieldDef("float", QVariant::Double, 1.2345),
FieldDef("double precision", QVariant::Double, 1.2345678),
FieldDef("timestamp", QVariant::DateTime, QDateTime::currentDateTime()),
FieldDef("time", QVariant::Time, QTime::currentTime()),
FieldDef("decimal(18)", QVariant::LongLong, Q_INT64_C(9223372036854775807)),
FieldDef("numeric(5,2)", QVariant::Double, 123.45),
FieldDef()
};
const int fieldCount = createFieldTable(fieldDefs, db);
QVERIFY(fieldCount > 0);
commonFieldTest(fieldDefs, db, fieldCount);
}
void tst_QSqlDatabase::recordSQLite()
{
QFETCH(QString, dbName);
@ -1136,19 +921,11 @@ void tst_QSqlDatabase::bigIntField()
QSqlQuery q(db);
q.setForwardOnly(true);
if (drvName.startsWith("QOCI"))
q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt64);
if (drvName.startsWith("QMYSQL")) {
QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit bigint, t_u64bit bigint unsigned)"));
} else if (drvName.startsWith("QPSQL")
|| drvName.startsWith("QDB2")
|| tst_Databases::isSqlServer(db)) {
} else if (drvName.startsWith("QPSQL") || tst_Databases::isSqlServer(db)) {
QVERIFY_SQL(q, exec("create table " + qtest_bigint + "(id int, t_s64bit bigint, t_u64bit bigint)"));
} else if (drvName.startsWith("QOCI")) {
QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit int, t_u64bit int)"));
//} else if (drvName.startsWith("QIBASE")) {
// QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit int64, t_u64bit int64)"));
} else {
QSKIP("no 64 bit integer support", SkipAll);
}
@ -1156,7 +933,7 @@ void tst_QSqlDatabase::bigIntField()
qlonglong ll = Q_INT64_C(9223372036854775807);
qulonglong ull = Q_UINT64_C(18446744073709551615);
if (drvName.startsWith("QMYSQL") || drvName.startsWith("QOCI")) {
if (drvName.startsWith("QMYSQL")) {
q.bindValue(0, 0);
q.bindValue(1, ll);
q.bindValue(2, ull);
@ -1180,13 +957,9 @@ void tst_QSqlDatabase::bigIntField()
QVERIFY(q.next());
QCOMPARE(q.value(1).toDouble(), (double)ll);
QCOMPARE(q.value(1).toLongLong(), ll);
if(drvName.startsWith("QOCI"))
QEXPECT_FAIL("", "Oracle driver lacks support for unsigned int64 types", Continue);
QCOMPARE(q.value(2).toULongLong(), ull);
QVERIFY(q.next());
QCOMPARE(q.value(1).toLongLong(), -ll);
if(drvName.startsWith("QOCI"))
QEXPECT_FAIL("", "Oracle driver lacks support for unsigned int64 types", Continue);
QCOMPARE(q.value(2).toULongLong(), ull);
}
@ -1229,8 +1002,6 @@ void tst_QSqlDatabase::noEscapedFieldNamesInRecord()
CHECK_DATABASE(db);
QString fieldname("t_varchar");
if (db.driverName().startsWith("QOCI") || db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QDB2"))
fieldname = fieldname.toUpper();
QSqlQuery q(db);
QString query = "SELECT " + db.driver()->escapeIdentifier(fieldname, QSqlDriver::FieldName) + " FROM " + qTableName("qtest", __FILE__);
@ -1429,8 +1200,6 @@ void tst_QSqlDatabase::precisionPolicy()
q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt32);
QVERIFY_SQL(q, exec(query));
if(db.driverName().startsWith("QOCI"))
QEXPECT_FAIL("", "Oracle fails to move to next when data columns are oversize", Abort);
QVERIFY_SQL(q, next());
if(db.driverName().startsWith("QSQLITE"))
QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue);
@ -1462,7 +1231,6 @@ void tst_QSqlDatabase::precisionPolicy()
QCOMPARE(q.value(0).type(), QVariant::String);
q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt64);
QEXPECT_FAIL("QOCI", "Oracle fails here, to retrieve next", Continue);
QVERIFY_SQL(q, exec(query));
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).type(), QVariant::LongLong);
@ -1546,171 +1314,6 @@ void tst_QSqlDatabase::accessOdbc_strings()
QCOMPARE(q.value(7).toString(), hStr);
}
// For task 125053
void tst_QSqlDatabase::ibase_numericFields()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
QSqlQuery q(db);
const QString tableName(qTableName("numericfields", __FILE__));
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (id int not null, num1 NUMERIC(2,1), "
"num2 NUMERIC(5,2), num3 NUMERIC(10,3), "
"num4 NUMERIC(18,4))").arg(tableName)));
QVERIFY_SQL(q, exec(QString("INSERT INTO %1 VALUES (1, 1.1, 123.45, 1234567.123, 10203040506070.8090)").arg(tableName)));
QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES (?, ?, ?, ?, ?)").arg(tableName)));
double num1 = 1.1;
double num2 = 123.45;
double num3 = 1234567.123;
double num4 = 10203040506070.8090;
q.bindValue(0, 2);
q.bindValue(1, QVariant(num1));
q.bindValue(2, QVariant(num2));
q.bindValue(3, QVariant(num3));
q.bindValue(4, QVariant(num4));
QVERIFY_SQL(q, exec());
QVERIFY_SQL(q, exec(QString("SELECT id, num1, num2, num3, num4 FROM %1").arg(tableName)));
int id = 0;
while (q.next()) {
QCOMPARE(q.value(0).toInt(), ++id);
QCOMPARE(q.value(1).toString(), QString("%1").arg(num1));
QCOMPARE(q.value(2).toString(), QString("%1").arg(num2));
QCOMPARE(QString("%1").arg(q.value(3).toDouble()), QString("%1").arg(num3));
QCOMPARE(QString("%1").arg(q.value(4).toDouble()), QString("%1").arg(num4));
QVERIFY(q.value(0).type() == QVariant::Int);
QVERIFY(q.value(1).type() == QVariant::Double);
QVERIFY(q.value(2).type() == QVariant::Double);
QVERIFY(q.value(3).type() == QVariant::Double);
QVERIFY(q.value(4).type() == QVariant::Double);
QCOMPARE(q.record().field(1).length(), 2);
QCOMPARE(q.record().field(1).precision(), 1);
QCOMPARE(q.record().field(2).length(), 5);
QCOMPARE(q.record().field(2).precision(), 2);
QCOMPARE(q.record().field(3).length(), 10);
QCOMPARE(q.record().field(3).precision(), 3);
QCOMPARE(q.record().field(4).length(), 18);
QCOMPARE(q.record().field(4).precision(), 4);
QVERIFY(q.record().field(0).requiredStatus() == QSqlField::Required);
QVERIFY(q.record().field(1).requiredStatus() == QSqlField::Optional);
}
QSqlRecord r = db.record(tableName);
QVERIFY(r.field(0).type() == QVariant::Int);
QVERIFY(r.field(1).type() == QVariant::Double);
QVERIFY(r.field(2).type() == QVariant::Double);
QVERIFY(r.field(3).type() == QVariant::Double);
QVERIFY(r.field(4).type() == QVariant::Double);
QCOMPARE(r.field(1).length(), 2);
QCOMPARE(r.field(1).precision(), 1);
QCOMPARE(r.field(2).length(), 5);
QCOMPARE(r.field(2).precision(), 2);
QCOMPARE(r.field(3).length(), 10);
QCOMPARE(r.field(3).precision(), 3);
QCOMPARE(r.field(4).length(), 18);
QCOMPARE(r.field(4).precision(), 4);
QVERIFY(r.field(0).requiredStatus() == QSqlField::Required);
QVERIFY(r.field(1).requiredStatus() == QSqlField::Optional);
}
void tst_QSqlDatabase::ibase_fetchBlobs()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
const QString tableName(qTableName("qtest_ibaseblobs", __FILE__));
QSqlQuery q(db);
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (blob1 BLOB segment size 256)").arg(tableName)));
QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES (?)").arg(tableName)));
q.bindValue(0, QByteArray().fill('x', 1024));
QVERIFY_SQL(q, exec());
QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES (?)").arg(tableName)));
q.bindValue(0, QByteArray().fill('x', 16383));
QVERIFY_SQL(q, exec());
QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES (?)").arg(tableName)));
q.bindValue(0, QByteArray().fill('x', 17408));
QVERIFY_SQL(q, exec());
QVERIFY_SQL(q, exec(QString("SELECT * FROM %1").arg(tableName)));
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toByteArray().size(), 1024);
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toByteArray().size(), 16383);
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toByteArray().size(), 17408);
}
void tst_QSqlDatabase::ibase_procWithoutReturnValues()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
QSqlQuery q(db);
const QString procName(qTableName("qtest_proc1", __FILE__));
q.exec(QString("drop procedure %1").arg(procName));
QVERIFY_SQL(q, exec("CREATE PROCEDURE " + procName + " (str VARCHAR(10))\nAS BEGIN\nstr='test';\nEND;"));
QVERIFY_SQL(q, exec(QString("execute procedure %1('qtest')").arg(procName)));
q.exec(QString("drop procedure %1").arg(procName));
}
void tst_QSqlDatabase::ibase_procWithReturnValues()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
if (!db.driverName().startsWith("QIBASE")) {
QSKIP("InterBase specific test", SkipSingle);
return;
}
const QString procName(qTableName("qtest_proc2", __FILE__));
QSqlQuery q(db);
q.exec(QString("drop procedure %1").arg(procName));
QVERIFY_SQL(q, exec("CREATE PROCEDURE " + procName + " ("
"\nABC INTEGER)"
"\nRETURNS ("
"\nRESULT INTEGER)"
"\nAS"
"\nbegin"
"\nRESULT = 10 * ABC;"
"\nsuspend;"
"\nend"));
// Interbase procedures can be executed in two ways: EXECUTE PROCEDURE or SELECT
QVERIFY_SQL(q, exec(QString("execute procedure %1(123)").arg(procName)));
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toInt(), 1230);
QVERIFY_SQL(q, exec(QString("select result from %1(456)").arg(procName)));
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toInt(), 4560);
QVERIFY_SQL(q, prepare(QLatin1String("execute procedure ")+procName+QLatin1String("(?)")));
q.bindValue(0, 123);
QVERIFY_SQL(q, exec());
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toInt(), 1230);
q.bindValue(0, 456);
QVERIFY_SQL(q, exec());
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toInt(), 4560);
q.exec(QString("drop procedure %1").arg(procName));
}
void tst_QSqlDatabase::formatValueTrimStrings()
{
QFETCH(QString, dbName);
@ -1852,122 +1455,6 @@ void tst_QSqlDatabase::mysql_multiselect()
QVERIFY_SQL(q, exec("SELECT * FROM " + qtest));
}
void tst_QSqlDatabase::ibase_useCustomCharset()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
QString nonlatin1string("<EFBFBD><EFBFBD>");
db.close();
db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1");
db.open();
const QString tableName(qTableName("latin1table", __FILE__));
QSqlQuery q(db);
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(text VARCHAR(6) CHARACTER SET Latin1)").arg(tableName)));
QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES(?)").arg(tableName)));
q.addBindValue(nonlatin1string);
QVERIFY_SQL(q, exec());
QVERIFY_SQL(q, exec(QString("SELECT text FROM %1").arg(tableName)));
QVERIFY_SQL(q, next());
QCOMPARE(toHex(q.value(0).toString()), toHex(nonlatin1string));
}
void tst_QSqlDatabase::oci_serverDetach()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
for (int i = 0; i < 2; i++) {
db.close();
if (db.open()) {
QSqlQuery query(db);
query.exec("SELECT 1 FROM DUAL");
db.close();
} else {
QFAIL(tst_Databases::printError(db.lastError(), db));
}
}
if(!db.open())
qFatal(tst_Databases::printError(db.lastError(), db));
}
void tst_QSqlDatabase::oci_xmltypeSupport()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
const QString tableName(qTableName("qtest_xmltype", __FILE__));
QString xml("<?xml version=\"1.0\"?><TABLE_NAME>MY_TABLE</TABLE_NAME>");
QSqlQuery q(db);
// Embedding the XML in the statement
if(!q.exec(QString("CREATE TABLE %1(xmldata xmltype)").arg(tableName)))
QSKIP("This test requries xml type support", SkipSingle);
QVERIFY_SQL(q, exec(QString("INSERT INTO %1 values('%2')").arg(tableName).arg(xml)));
QVERIFY_SQL(q, exec(QString("SELECT a.xmldata.getStringVal() FROM %1 a").arg(tableName)));
QVERIFY_SQL(q, last());
QCOMPARE(q.value(0).toString(), xml);
// Binding the XML with a prepared statement
QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 values(?)").arg(tableName)));
q.addBindValue(xml);
QVERIFY_SQL(q, exec());
QVERIFY_SQL(q, exec(QString("SELECT a.xmldata.getStringVal() FROM %1 a").arg(tableName)));
QVERIFY_SQL(q, last());
QCOMPARE(q.value(0).toString(), xml);
}
void tst_QSqlDatabase::oci_fieldLength()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
const QString tableName(qTableName("qtest", __FILE__));
QSqlQuery q(db);
QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1").arg(tableName)));
QVERIFY_SQL(q, next());
QCOMPARE(q.record().field(0).length(), 40);
QCOMPARE(q.record().field(1).length(), 40);
}
void tst_QSqlDatabase::oci_synonymstest()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
QSqlQuery q(db);
const QString creator(qTableName("CREATOR", __FILE__)), appuser(qTableName("APPUSER", __FILE__)), table1(qTableName("TABLE1", __FILE__));
// QVERIFY_SQL(q, exec("drop public synonym "+table1));
QVERIFY_SQL(q, exec(QString("create user %1 identified by %2 default tablespace users temporary tablespace temp").arg(creator).arg(creator)));
QVERIFY_SQL(q, exec(QString("grant CONNECT to %1").arg(creator)));
QVERIFY_SQL(q, exec(QString("grant RESOURCE to %1").arg(creator)));
QSqlDatabase db2=db.cloneDatabase(db, QLatin1String("oci_synonymstest"));
db2.close();
QVERIFY_SQL(db2, open(creator,creator));
QSqlQuery q2(db2);
QVERIFY_SQL(q2, exec(QString("create table %1(id int primary key)").arg(table1)));
QVERIFY_SQL(q, exec(QString("create user %1 identified by %2 default tablespace users temporary tablespace temp").arg(appuser).arg(appuser)));
QVERIFY_SQL(q, exec(QString("grant CREATE ANY SYNONYM to %1").arg(appuser)));
QVERIFY_SQL(q, exec(QString("grant CONNECT to %1").arg(appuser)));
QVERIFY_SQL(q2, exec(QString("grant select, insert, update, delete on %1 to %2").arg(table1).arg(appuser)));
QSqlDatabase db3=db.cloneDatabase(db, QLatin1String("oci_synonymstest2"));
db3.close();
QVERIFY_SQL(db3, open(appuser,appuser));
QSqlQuery q3(db3);
QVERIFY_SQL(q3, exec("create synonym "+appuser+'.'+qTableName("synonyms", __FILE__)+" for "+creator+'.'+table1));
QVERIFY_SQL(db3, tables().filter(qTableName("synonyms", __FILE__), Qt::CaseInsensitive).count() >= 1);
}
// This test isn't really necessary as SQL_GUID / uniqueidentifier is
// already tested in recordSQLServer().
void tst_QSqlDatabase::odbc_uniqueidentifier()
@ -2081,35 +1568,6 @@ void tst_QSqlDatabase::eventNotification()
db.open();
}
void tst_QSqlDatabase::eventNotificationIBase()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
const QString procedureName(qTableName("posteventProc", __FILE__));
QSqlDriver *driver=db.driver();
QVERIFY_SQL(*driver, subscribeToNotification(procedureName));
QTest::qWait(300); // Interbase needs some time to call the driver callback.
db.transaction(); // InterBase events are posted from within transactions.
QSqlQuery q(db);
q.exec(QString("DROP PROCEDURE %1").arg(procedureName));
q.exec(QString("CREATE PROCEDURE %1\nAS BEGIN\nPOST_EVENT '%1';\nEND;").arg(procedureName));
q.exec(QString("EXECUTE PROCEDURE %1").arg(procedureName));
QSignalSpy spy(driver, SIGNAL(notification(const QString&)));
db.commit(); // No notifications are posted until the transaction is committed.
QTest::qWait(300); // Interbase needs some time to post the notification and call the driver callback.
// This happends from another thread, and we have to process events in order for the
// event handler in the driver to be executed and emit the notification signal.
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
QVERIFY(arguments.at(0).toString() == procedureName);
QVERIFY_SQL(*driver, unsubscribeFromNotification(procedureName));
q.exec(QString("DROP PROCEDURE %1").arg(procedureName));
}
void tst_QSqlDatabase::eventNotificationPSQL()
{
QFETCH(QString, dbName);
@ -2135,10 +1593,6 @@ void tst_QSqlDatabase::sqlite_bindAndFetchUInt()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
if (db.driverName().startsWith("QSQLITE2")) {
QSKIP("SQLite3 specific test", SkipSingle);
return;
}
QSqlQuery q(db);
const QString tableName(qTableName("uint_test", __FILE__));
@ -2155,26 +1609,6 @@ void tst_QSqlDatabase::sqlite_bindAndFetchUInt()
QCOMPARE(q.value(0).toUInt(), 4000000000U);
}
void tst_QSqlDatabase::db2_valueCacheUpdate()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
const QString tableName(qTableName("qtest", __FILE__));
QSqlQuery q(db);
q.exec(QString("SELECT id, t_varchar, t_char, t_numeric FROM %1").arg(tableName));
q.next();
QVariant c4 = q.value(3);
QVariant c3 = q.value(2);
QVariant c2 = q.value(1);
QVariant c1 = q.value(0);
QCOMPARE(c4.toString(), q.value(3).toString());
QCOMPARE(c3.toString(), q.value(2).toString());
QCOMPARE(c2.toString(), q.value(1).toString());
QCOMPARE(c1.toString(), q.value(0).toString());
}
void tst_QSqlDatabase::sqlStatementUseIsNull_189093()
{
// NULL = NULL is unknown, the sqlStatment must use IS NULL
@ -2211,18 +1645,6 @@ void tst_QSqlDatabase::mysql_savepointtest()
QVERIFY_SQL(q, exec("savepoint foo"));
}
void tst_QSqlDatabase::oci_tables()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
QSqlQuery q(db);
const QString systemTableName("system."+qTableName("mypassword", __FILE__));
QVERIFY_SQL(q, exec("CREATE TABLE "+systemTableName+"(name VARCHAR(20))"));
QVERIFY(!db.tables().contains(systemTableName.toUpper()));
QVERIFY(db.tables(QSql::SystemTables).contains(systemTableName.toUpper()));
}
void tst_QSqlDatabase::sqlite_enable_cache_mode()
{
QFETCH(QString, dbName);
@ -2243,4 +1665,4 @@ void tst_QSqlDatabase::sqlite_enable_cache_mode()
}
QTEST_MAIN(tst_QSqlDatabase)
#include "tst_qsqldatabase.moc"
#include "moc_tst_qsqldatabase.cpp"