[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/predicate/Predicate/drivers/sqlite
From:       Jarosław Staniek <staniek () kde ! org>
Date:       2010-01-31 22:25:04
Message-ID: 1264976704.667322.30263.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1083257 by staniek:

KexiDB
*kexisql updated to 3.6.22
**we're still embedding sqlite in Kexi because of many options that are not set in \
distros, e.g. SECURE DELETE should be on by default \
                http://sqlite.org/compile.html#secure_delete
**moved to amalgamation version for efficiency http://sqlite.org/amalgamation.html - \
                makes it run faster
**moved directly to sqlite driver - even more efficiency

port of KexiDB's r1083030



 A             3rdparty (directory)   \
trunk/koffice/kexi/kexidb/drivers/sqlite/3rdparty#1083030  M  +29 -2     \
CMakeLists.txt    M  +31 -19    SqliteConnection.cpp  
 M  +3 -0      SqliteConnection.h  


--- branches/work/predicate/Predicate/drivers/sqlite/CMakeLists.txt #1083256:1083257
@@ -1,5 +1,30 @@
+
+# definitins used for the sqlite driver and the shell
+ADD_DEFINITIONS(
+    # sqlite compile-time options, http://sqlite.org/compile.html
+    -DSQLITE_SECURE_DELETE
+    -DSQLITE_ENABLE_COLUMN_METADATA # Some additional APIs that provide convenient \
access to meta-data +                                    # about tables and queries
+    -DSQLITE_ENABLE_FTS3 # Version 3 of the full-text search engine
+    -DSQLITE_ENABLE_FTS3_PARENTHESIS # Modifies the query pattern parser in FTS3 \
such that it supports +                                     # operators AND and NOT \
(in addition to the usual OR and NEAR) +                                     # and \
also allows query expressions to contain nested parenthesesis. +    \
-DSQLITE_ENABLE_MEMORY_MANAGEMENT # Extra logic to SQLite that allows it to release \
unused memory upon request +    -DSQLITE_ENABLE_RTREE # Support for the R*Tree index \
extension +    -DSQLITE_ENABLE_STAT2 # Additional logic to the ANALYZE command and to \
the query planner that can help SQLite +                          # to chose a better \
query plan under certain situations +    -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT # \
Optional ORDER BY and LIMIT clause on UPDATE and DELETE statements +    \
-DSQLITE_ENABLE_UNLOCK_NOTIFY # Enables the sqlite3_unlock_notify() interface and its \
associated functionality +                                  # \
(http://sqlite.org/unlock_notify.html) +    -DSQLITE_SOUNDEX # Enables the soundex() \
SQL function (http://sqlite.org/lang_corefunc.html#soundex) +
+# todo -DSQLITE_OMIT_DEPRECATED
+)
+
+add_subdirectory( 3rdparty/sqlite3 )
+
 include_directories(
-  ${SQLITE_INCLUDE_DIR}
+  3rdparty/sqlite3
   ${CMAKE_SOURCE_DIR}
   ${QT_INCLUDES}
 )
@@ -29,6 +54,8 @@
    SqliteAdmin.cpp
 #todo   SqliteVacuum.cpp
    SqliteAlter.cpp
+
+   3rdparty/sqlite3/sqlite3.c
 )
 
 set(predicate_sqlite3_MOC_SRCS
@@ -41,7 +68,7 @@
 
 add_library(predicate_sqlite3 SHARED ${predicate_sqlite3_SRCS})
 
-target_link_libraries(predicate_sqlite3 ${SQLITE_LIBRARIES} predicate )
+target_link_libraries(predicate_sqlite3 ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS} \
predicate )  
 install(TARGETS predicate_sqlite3 DESTINATION ${PLUGIN_INSTALL_DIR})
 
--- branches/work/predicate/Predicate/drivers/sqlite/SqliteConnection.cpp \
#1083256:1083257 @@ -1,5 +1,5 @@
 /* This file is part of the KDE project
-   Copyright (C) 2003-2006 Jarosław Staniek <staniek@kde.org>
+   Copyright (C) 2003-2010 Jarosław Staniek <staniek@kde.org>
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
@@ -19,10 +19,9 @@
 
 #include "SqliteConnection.h"
 #include "SqliteConnection_p.h"
-#include "sqliteCursor.h"
+#include "SqliteCursor.h"
 #include "SqlitePreparedStatement.h"
 
-//#include "kexisql.h" //for isReadOnly()
 #include <sqlite3.h>
 
 #include <Predicate/Driver.h>
@@ -147,38 +146,51 @@
 
 bool SQLiteConnection::drv_createDatabase(const QString &dbName)
 {
-    // SQLite creates a new db is it does not exist
-    return drv_useDatabase(dbName);
-#if 0
-    d->data = sqlite_open(QFile::encodeName(data()->fileName()), 0/*mode: unused*/,
-                          &d->errmsg_p);
-    d->storeResult();
-    return d->data != 0;
-#endif
+    Q_UNUSED(dbName);
+    return drv_useDatabaseInternal(0, 0, true/*create if missing*/);
 }
 
 bool SQLiteConnection::drv_useDatabase(const QString &dbName, bool *cancelled,
                                        MessageHandler* msgHandler)
 {
     Q_UNUSED(dbName);
-// PreDrvDbg << "drv_useDatabase(): " << data()->fileName();
-    //TODO: perhaps allow to use sqlite3_open16() as well for SQLite ~ 3.3 ?
+    return drv_useDatabaseInternal(cancelled, msgHandler, false/*do not create if \
missing*/); +}
+
+bool SQLiteConnection::drv_useDatabaseInternal(bool *cancelled,
+                                               MessageHandler* msgHandler, bool \
createIfMissing) +{
 //! @todo add option (command line or in kexirc?)
-    int flags = Connection::isReadOnly() ? SQLITE_OPEN_READONLY : \
SQLITE_OPEN_READWRITE; +//! @todo   int exclusiveFlag = Connection::isReadOnly() ? \
SQLITE_OPEN_READONLY : SQLITE_OPEN_WRITE_LOCKED; // <-- shared read + (if !r/o): \
exclusive write +    int openFlags = 0;
+    if (isReadOnly()) {
+        openFlags |= SQLITE_OPEN_READONLY;
+    }
+    else {
+        openFlags |= SQLITE_OPEN_READWRITE;
+        if (createIfMissing) {
+            openFlags |= SQLITE_OPEN_CREATE;
+        }
+    }
+
 //! @todo add option
-//removed in predicate    int allowReadonly = 1;
-//removed in predicate    const bool wasReadOnly = Connection::isReadOnly();
+//    int allowReadonly = 1;
+//    const bool wasReadOnly = Connection::isReadOnly();
 
     d->res = sqlite3_open_v2(
+                 //QFile::encodeName( data()->fileName() ),
                  data()->fileName().toUtf8().constData(), /* unicode expected since \
SQLite 3.1 */  &d->data,
-                 flags,
-//removed in predicate                 allowReadonly /* If 1 and locking fails, try \
opening in read-only mode */ +                 openFlags, /*exclusiveFlag,
+                 allowReadonly *//* If 1 and locking fails, try opening in read-only \
mode */  0
              );
     d->storeResult();
 
-// @todo removed in predicate - reenable?
+//! @todo check exclusive status
+    Q_UNUSED(cancelled);
+    Q_UNUSED(msgHandler);
+//! @todo removed in predicate - reenable?
 /*
     if (d->res == SQLITE_OK && cancelled && !wasReadOnly && allowReadonly && \
isReadOnly()) {  //opened as read only, ask
--- branches/work/predicate/Predicate/drivers/sqlite/SqliteConnection.h \
#1083256:1083257 @@ -101,6 +101,9 @@
 
     SQLiteConnectionInternal* d;
 
+private:
+    bool drv_useDatabaseInternal(bool *cancelled, MessageHandler* msgHandler, bool \
createIfMissing); +
     friend class SQLiteDriver;
     friend class SQLiteCursor;
 };


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic