Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:belphegor_belbel:KDE3
qt3-extensions
qt3-extensions_sqlite3.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File qt3-extensions_sqlite3.patch of Package qt3-extensions
diff -Naru qt3_orig/plugins/src/sqldrivers/sqlite/sqlite.pro qt3/plugins/src/sqldrivers/sqlite/sqlite.pro --- qt3_orig/plugins/src/sqldrivers/sqlite/sqlite.pro 2019-04-03 12:55:51.566383781 +0900 +++ qt3/plugins/src/sqldrivers/sqlite/sqlite.pro 2019-04-03 15:48:42.021172331 +0900 @@ -11,7 +11,7 @@ unix { OBJECTS_DIR = .obj !contains( LIBS, .*sqlite.* ) { - LIBS *= -lsqlite + LIBS *= -lsqlite3 } } diff -Naru qt3_orig/src/sql/drivers/sqlite/qsql_sqlite.cpp qt3/src/sql/drivers/sqlite/qsql_sqlite.cpp --- qt3_orig/src/sql/drivers/sqlite/qsql_sqlite.cpp 2008-01-16 04:09:13.000000000 +0900 +++ qt3/src/sql/drivers/sqlite/qsql_sqlite.cpp 2019-04-03 17:10:10.307183989 +0900 @@ -29,10 +29,10 @@ # if !defined Q_WS_WIN32 # include <unistd.h> # endif -# include <sqlite.h> +# include <sqlite3.h> #endif -typedef struct sqlite_vm sqlite_vm; +#include <stdlib.h> #define QSQLITE_DRIVER_NAME "QSQLITE" @@ -53,13 +53,13 @@ { public: QSQLiteDriverPrivate(); - sqlite *access; + sqlite3 *access; bool utf8; }; QSQLiteDriverPrivate::QSQLiteDriverPrivate() : access(0) { - utf8 = (qstrcmp(sqlite_encoding, "UTF-8") == 0); + utf8 = -1; // (qstrcmp(sqlite_encoding, "UTF-8") == 0); // not defined for sqlite3, is this right? } class QSQLiteResultPrivate @@ -74,12 +74,12 @@ void finalize(); QSQLiteResult* q; - sqlite *access; + sqlite3 *access; // and we have too keep our own struct for the data (sqlite works via // callback. const char *currentTail; - sqlite_vm *currentMachine; + sqlite3_stmt *currentStatement; uint skippedStatus: 1; // the status of the fetchNext() that's skipped QtSqlCachedResult::RowCache *skipRow; @@ -91,7 +91,7 @@ static const uint initial_cache_size = 128; QSQLiteResultPrivate::QSQLiteResultPrivate(QSQLiteResult* res) : q(res), access(0), currentTail(0), - currentMachine(0), skippedStatus(FALSE), skipRow(0), utf8(FALSE) + currentStatement(0), skippedStatus(FALSE), skipRow(0), utf8(FALSE) { } @@ -100,7 +100,7 @@ finalize(); rInf.clear(); currentTail = 0; - currentMachine = 0; + currentStatement = 0; skippedStatus = FALSE; delete skipRow; skipRow = 0; @@ -111,16 +111,14 @@ void QSQLiteResultPrivate::finalize() { - if (!currentMachine) + if (!currentStatement) return; - char* err = 0; - int res = sqlite_finalize(currentMachine, &err); - if (err) { - q->setLastError(QSqlError("Unable to fetch results", err, QSqlError::Statement, res)); - sqlite_freemem(err); + int res = sqlite3_finalize(currentStatement); + if (res != SQLITE_OK) { + q->setLastError(QSqlError("Unable to fetch results", "", QSqlError::Statement, res)); } - currentMachine = 0; + currentStatement = 0; } // called on first fetch @@ -148,8 +146,8 @@ bool QSQLiteResultPrivate::fetchNext(QtSqlCachedResult::RowCache* row) { // may be caching. - const char **fvals; - const char **cnames; + const char **fvals = 0; + const char **cnames = 0; int colNum; int res; int i; @@ -163,11 +161,11 @@ return skippedStatus; } - if (!currentMachine) + if (!currentStatement) return FALSE; // keep trying while busy, wish I could implement this better. - while ((res = sqlite_step(currentMachine, &colNum, &fvals, &cnames)) == SQLITE_BUSY) { + while ((res = sqlite3_step(currentStatement)) == SQLITE_BUSY) { // sleep instead requesting result again immidiately. #if defined Q_WS_WIN32 Sleep(1000); @@ -176,24 +174,50 @@ #endif } + colNum = sqlite3_column_count(currentStatement); + if (colNum > 0) { + cnames = (const char **) malloc(sizeof(const char *) * colNum * 2); + if (!cnames) return FALSE; + fvals = (const char **) malloc(sizeof(const char *) * colNum); + if (!fvals) { + free(cnames); + return FALSE; + } + + for(i = 0; i< colNum; ++i) { + cnames[i] = sqlite3_column_name(currentStatement, i); + cnames[i + colNum] = sqlite3_column_decltype(currentStatement, i); + fvals[i] = (const char *)sqlite3_column_text(currentStatement, i); + } + } + switch(res) { case SQLITE_ROW: // check to see if should fill out columns if (rInf.isEmpty()) // must be first call. init(cnames, colNum, &row); - if (!fvals) + if (!fvals) { + if (cnames) free(cnames); return FALSE; - if (!row) + } + if (!row) { + if (cnames) free(cnames); + if (fvals) free(fvals); return TRUE; + } for (i = 0; i < colNum; ++i) (*row)[i] = utf8 ? QString::fromUtf8(fvals[i]) : QString(fvals[i]); + if (cnames) free(cnames); + if (fvals) free(fvals); return TRUE; case SQLITE_DONE: if (rInf.isEmpty()) // must be first call. init(cnames, colNum); q->setAt(QSql::AfterLast); + if (cnames) free(cnames); + if (fvals) free(fvals); return FALSE; case SQLITE_ERROR: case SQLITE_MISUSE: @@ -201,8 +225,12 @@ // something wrong, don't get col info, but still return false finalize(); // finalize to get the error message. q->setAt(QSql::AfterLast); + if (cnames) free(cnames); + if (fvals) free(fvals); return FALSE; } + if (cnames) free(cnames); + if (fvals) free(fvals); return FALSE; } @@ -235,18 +263,16 @@ // Um, ok. callback based so.... pass private static function for this. setSelect(FALSE); - char *err = 0; - int res = sqlite_compile(d->access, + int res = sqlite3_prepare(d->access, d->utf8 ? (const char*)query.utf8().data() : query.ascii(), - &(d->currentTail), - &(d->currentMachine), - &err); - if (res != SQLITE_OK || err) { - setLastError(QSqlError("Unable to execute statement", err, QSqlError::Statement, res)); - sqlite_freemem(err); + -1, + &(d->currentStatement), + &(d->currentTail)); + if (res != SQLITE_OK) { + setLastError(QSqlError("Unable to execute statement", "", QSqlError::Statement, res)); } //if (*d->currentTail != '\000' then there is more sql to eval - if (!d->currentMachine) { + if (!d->currentStatement) { setActive(FALSE); return FALSE; } @@ -272,7 +298,7 @@ int QSQLiteResult::numRowsAffected() { - return sqlite_changes(d->access); + return sqlite3_changes(d->access); } ///////////////////////////////////////////////////////// @@ -283,7 +309,7 @@ d = new QSQLiteDriverPrivate(); } -QSQLiteDriver::QSQLiteDriver(sqlite *connection, QObject *parent, const char *name) +QSQLiteDriver::QSQLiteDriver(sqlite3 *connection, QObject *parent, const char *name) : QSqlDriver(parent, name ? name : QSQLITE_DRIVER_NAME) { d = new QSQLiteDriverPrivate(); @@ -325,11 +351,10 @@ if (db.isEmpty()) return FALSE; - char* err = 0; - d->access = sqlite_open(QFile::encodeName(db), 0, &err); - if (err) { - setLastError(QSqlError("Error to open database", err, QSqlError::Connection)); - sqlite_freemem(err); + int err = 0; + err = sqlite3_open(QFile::encodeName(db), &(d->access)); + if (err != SQLITE_OK) { + setLastError(QSqlError("Error to open database", "", QSqlError::Connection)); err = 0; } @@ -345,7 +370,7 @@ void QSQLiteDriver::close() { if (isOpen()) { - sqlite_close(d->access); + sqlite3_close(d->access); d->access = 0; setOpen(FALSE); setOpenError(FALSE); @@ -363,13 +388,13 @@ return FALSE; char* err; - int res = sqlite_exec(d->access, "BEGIN", 0, this, &err); + int res = sqlite3_exec(d->access, "BEGIN", 0, this, &err); if (res == SQLITE_OK) return TRUE; setLastError(QSqlError("Unable to begin transaction", err, QSqlError::Transaction, res)); - sqlite_freemem(err); + sqlite3_free(err); return FALSE; } @@ -379,13 +404,13 @@ return FALSE; char* err; - int res = sqlite_exec(d->access, "COMMIT", 0, this, &err); + int res = sqlite3_exec(d->access, "COMMIT", 0, this, &err); if (res == SQLITE_OK) return TRUE; setLastError(QSqlError("Unable to commit transaction", err, QSqlError::Transaction, res)); - sqlite_freemem(err); + sqlite3_free(err); return FALSE; } @@ -395,13 +420,13 @@ return FALSE; char* err; - int res = sqlite_exec(d->access, "ROLLBACK", 0, this, &err); + int res = sqlite3_exec(d->access, "ROLLBACK", 0, this, &err); if (res == SQLITE_OK) return TRUE; setLastError(QSqlError("Unable to rollback Transaction", err, QSqlError::Transaction, res)); - sqlite_freemem(err); + sqlite3_free(err); return FALSE; } diff -Naru qt3_orig/src/sql/drivers/sqlite/qsql_sqlite.h qt3/src/sql/drivers/sqlite/qsql_sqlite.h --- qt3_orig/src/sql/drivers/sqlite/qsql_sqlite.h 2008-01-16 04:09:13.000000000 +0900 +++ qt3/src/sql/drivers/sqlite/qsql_sqlite.h 2019-04-03 15:35:37.363444448 +0900 @@ -32,7 +32,7 @@ class QSQLiteDriverPrivate; class QSQLiteResultPrivate; class QSQLiteDriver; -struct sqlite; +struct sqlite3; class QSQLiteResult : public QtSqlCachedResult { @@ -57,7 +57,7 @@ friend class QSQLiteResult; public: QSQLiteDriver(QObject *parent = 0, const char *name = 0); - QSQLiteDriver(sqlite *connection, QObject *parent = 0, const char *name = 0); + QSQLiteDriver(sqlite3 *connection, QObject *parent = 0, const char *name = 0); ~QSQLiteDriver(); bool hasFeature(DriverFeature f) const; bool open(const QString & db,
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor