summaryrefslogtreecommitdiff
authoreilers <eilers>2004-10-27 14:28:16 (UTC)
committer eilers <eilers>2004-10-27 14:28:16 (UTC)
commit03adfc8b698fbed4b6f31c8320f510eb6da0d51d (patch) (unidiff)
treecb2faa9af5eedab6c816ca81433f457e8930cfc2
parente44d35ca3fd26ef7a3184b07516f6535d8844a83 (diff)
downloadopie-03adfc8b698fbed4b6f31c8320f510eb6da0d51d.zip
opie-03adfc8b698fbed4b6f31c8320f510eb6da0d51d.tar.gz
opie-03adfc8b698fbed4b6f31c8320f510eb6da0d51d.tar.bz2
Switching to sqlite3
Please read the following page for upgrade your old sqlite V2 database: http://opie.handhelds.org/cgi-bin/moin.cgi/SqlBackends
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--Rules.make2
-rw-r--r--dependencies.in2
-rw-r--r--development/pim/dbpaper/intro.tex4
-rw-r--r--libopie2/opiedb/config.in2
-rw-r--r--libopie2/opiedb/libopiedb2.control4
-rw-r--r--libopie2/opiedb/opiedb.pro2
-rw-r--r--libopie2/opiedb/osqlitedriver.cpp42
-rw-r--r--libopie2/opiedb/osqlitedriver.h4
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h7
-rw-r--r--libopie2/opiepim/core/opimcontactfields.h2
-rw-r--r--libopie2/opiepim/core/opimtemplatebase.h6
11 files changed, 34 insertions, 43 deletions
diff --git a/Rules.make b/Rules.make
index 2f32c04..c025d72 100644
--- a/Rules.make
+++ b/Rules.make
@@ -311,3 +311,3 @@ endef
311define makefilegen 311define makefilegen
312 cd $(if $(1),$(dir $(1))); $(TOPDIR)/qmake/qmake $(3) -o $(if $(1),$(notdir $(1))) $(word 3,$(shell grep -m 1 "[[:space:]]$(patsubst %/Makefile,%,$(1))[[:space:]]" $(OPIEDIR)/packages)) 312 cd $(if $(1),$(dir $(1))); $(TOPDIR)/qmake/qmake $(3) -o $(if $(1),$(notdir $(1))) $(word 3,$(shell grep "[[:space:]]$(patsubst %/Makefile,%,$(1))[[:space:]]" $(OPIEDIR)/packages))
313endef 313endef
diff --git a/dependencies.in b/dependencies.in
index 55b44e6..ce1ac96 100644
--- a/dependencies.in
+++ b/dependencies.in
@@ -25,3 +25,3 @@
25 config LIBSQLITE_DEP 25 config LIBSQLITE_DEP
26 boolean "Have sqlite >= 2.8.6" 26 boolean "Have sqlite >= 3.0.7"
27 default n 27 default n
diff --git a/development/pim/dbpaper/intro.tex b/development/pim/dbpaper/intro.tex
index c456333..fd790d7 100644
--- a/development/pim/dbpaper/intro.tex
+++ b/development/pim/dbpaper/intro.tex
@@ -14,3 +14,3 @@ Design goal is a fast and extendable layout on a sql database to support cross r
14Copyright notice 14Copyright notice
15\copyright 2002, Maximilian Rei{\ss} \& Stefan Eilers \& Holger Freyther 15\copyright 2002-2004, Maximilian Rei{\ss} \& Stefan Eilers \& Holger Freyther
16 16
@@ -24,3 +24,3 @@ Some of the tables are just using 5 attributes:
24rows, seperated by ID. 24rows, seperated by ID.
25\item ID: This defines a number to seperate the rows of an entry. UID + ID must be unique for every entry. 25\item ID: This defines a number to seperate the rows of an entry. UID + ID must be unique for every entry (primary key).
26\item Type: Describes the type of this entry. 26\item Type: Describes the type of this entry.
diff --git a/libopie2/opiedb/config.in b/libopie2/opiedb/config.in
index 4d85609..0d74887 100644
--- a/libopie2/opiedb/config.in
+++ b/libopie2/opiedb/config.in
@@ -4,3 +4,3 @@
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBSQLITE_DEP 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBSQLITE_DEP
5 comment "libopie2db needs a libqpe, sqlite and libopie2core" 5 comment "libopie2db needs a libqpe, libsqlite3 and libopie2core"
6 depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBSQLITE_DEP) 6 depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBSQLITE_DEP)
diff --git a/libopie2/opiedb/libopiedb2.control b/libopie2/opiedb/libopiedb2.control
index 4859c46..29fae78 100644
--- a/libopie2/opiedb/libopiedb2.control
+++ b/libopie2/opiedb/libopiedb2.control
@@ -7,4 +7,4 @@ Architecture: arm
7Version: 1.8.2-$SUB_VERSION.2 7Version: 1.8.2-$SUB_VERSION.2
8Depends: libqpe1, libopiecore2 (1.8.2), libsqlite0 | sqlite 8Depends: libqpe1, libopiecore2 (1.8.2), libsqlite3 | sqlite3
9Provides: libopiedb2 9Provides: libopiedb2
10Description: Opie library 2.0 DB 10Description: Opie library 2.1 DB
diff --git a/libopie2/opiedb/opiedb.pro b/libopie2/opiedb/opiedb.pro
index 8432674..f727995 100644
--- a/libopie2/opiedb/opiedb.pro
+++ b/libopie2/opiedb/opiedb.pro
@@ -27,3 +27,3 @@ INCLUDEPATH = $(OPIEDIR)/include
27DEPENDPATH = $(OPIEDIR)/include 27DEPENDPATH = $(OPIEDIR)/include
28LIBS += -lopiecore2 -lqpe -lsqlite 28LIBS += -lopiecore2 -lqpe -lsqlite3
29 29
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp
index c8b560f..816223e 100644
--- a/libopie2/opiedb/osqlitedriver.cpp
+++ b/libopie2/opiedb/osqlitedriver.cpp
@@ -105,10 +105,12 @@ int sqliteRlikeCompare(const char *zPattern, const char *zString, sqregex *reg){
105 105
106void rlikeFunc(sqlite_func *context, int arg, const char **argv){ 106void rlikeFunc( sqlite3_context* context, int count, sqlite3_value** values ){
107 if( arg < 2 || argv[0]==0 || argv[1]==0 ){ 107 const unsigned char* argv0 = sqlite3_value_text( values[0] );
108 printf("One of arguments Null!!\n"); 108 const unsigned char* argv1 = sqlite3_value_text( values[1] );
109 if( count < 2 || argv0 == 0 || argv1 == 0 ){
110 qWarning( "One of arguments Null!!\n" );
109 return; 111 return;
110 } 112 }
111 sqlite_set_result_int(context, 113 sqlite3_result_int(context, sqliteRlikeCompare((const char*)argv0,
112 sqliteRlikeCompare((const char*)argv[0], 114 (const char*)argv1,
113 (const char*)argv[1], (sqregex *)sqlite_user_data(context) )); 115 (sqregex *) sqlite3_user_data( context ) ));
114} 116}
@@ -120,21 +122,21 @@ void rlikeFunc(sqlite_func *context, int arg, const char **argv){
120bool OSQLiteDriver::open() { 122bool OSQLiteDriver::open() {
121 char *error;
122
123 odebug << "OSQLiteDriver::open: about to open" << oendl; 123 odebug << "OSQLiteDriver::open: about to open" << oendl;
124 m_sqlite = sqlite_open(m_url.local8Bit(), 124
125 0, 125 int error = sqlite3_open( m_url.utf8(),
126 &error ); 126 &m_sqlite );
127 127
128 /* failed to open */ 128 /* failed to open */
129 if (m_sqlite == 0l ) { 129 if ( error != SQLITE_OK ) {
130 // FIXME set the last error 130 // FIXME set the last error
131 owarn << "OSQLiteDriver::open: " << error << "" << oendl; 131 owarn << "OSQLiteDriver::open: " << error << "" << oendl;
132 free( error ); 132 sqlite3_close( m_sqlite );
133 return false; 133 return false;
134 } 134 }
135 if (sqlite_create_function(m_sqlite,"rlike",2,rlikeFunc,&sqreg) != 0) 135 if ( sqlite3_create_function( m_sqlite, "rlike", 2, SQLITE_UTF8, &sqreg, rlikeFunc, NULL, NULL ) != SQLITE_OK ){
136 odebug << "Unable to create user defined function!" << oendl; 136 odebug << "Unable to create user defined function!" << oendl;
137 if (sqlite_function_type(m_sqlite,"rlike",SQLITE_NUMERIC) != 0) 137 return false;
138 odebug << "Unable to set rlike function result type!" << oendl; 138 }
139
139 sqreg.regex_raw = NULL; 140 sqreg.regex_raw = NULL;
141
140 return true; 142 return true;
@@ -148,4 +150,6 @@ bool OSQLiteDriver::open() {
148bool OSQLiteDriver::close() { 150bool OSQLiteDriver::close() {
149 if (m_sqlite ) 151 if ( m_sqlite ){
150 sqlite_close( m_sqlite ), m_sqlite=0l; 152 sqlite3_close( m_sqlite );
153 m_sqlite=0l;
154 }
151 if (sqreg.regex_raw != NULL){ 155 if (sqreg.regex_raw != NULL){
@@ -171,3 +175,3 @@ OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
171 /* SQLITE_OK 0 if return code > 0 == failure */ 175 /* SQLITE_OK 0 if return code > 0 == failure */
172 if ( sqlite_exec(m_sqlite, qu->query().utf8(),&call_back, &query, &err) > 0 ) { 176 if ( sqlite3_exec( m_sqlite, qu->query().utf8(), &call_back, &query, &err ) > SQLITE_OK ) {
173 owarn << "OSQLiteDriver::query: Error while executing " << err << "" << oendl; 177 owarn << "OSQLiteDriver::query: Error while executing " << err << "" << oendl;
diff --git a/libopie2/opiedb/osqlitedriver.h b/libopie2/opiedb/osqlitedriver.h
index e38fd52..4990a11 100644
--- a/libopie2/opiedb/osqlitedriver.h
+++ b/libopie2/opiedb/osqlitedriver.h
@@ -3,3 +3,3 @@
3 3
4#include <sqlite.h> 4#include <sqlite3.h>
5#include <sys/types.h> 5#include <sys/types.h>
@@ -43,3 +43,3 @@ private:
43 QString m_url; 43 QString m_url;
44 sqlite *m_sqlite; 44 sqlite3 *m_sqlite;
45 sqregex sqreg; 45 sqregex sqreg;
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 7ab1ea5..f936d4e 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -180,3 +180,2 @@ public:
180 */ 180 */
181 virtual T cacheFind( int uid )const;
182 void cache( const T& )const; 181 void cache( const T& )const;
@@ -268,8 +267,2 @@ T OPimAccessTemplate<T>::find( int uid ) const{
268template <class T> 267template <class T>
269T OPimAccessTemplate<T>::cacheFind( int uid ) const
270{
271 return m_cache.find( uid );
272}
273
274template <class T>
275T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, 268T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
diff --git a/libopie2/opiepim/core/opimcontactfields.h b/libopie2/opiepim/core/opimcontactfields.h
index 3aa3894..2e42951 100644
--- a/libopie2/opiepim/core/opimcontactfields.h
+++ b/libopie2/opiepim/core/opimcontactfields.h
@@ -2,3 +2,3 @@
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) Stefan Eielrs <eilers.stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
diff --git a/libopie2/opiepim/core/opimtemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h
index ec9a94e..787486c 100644
--- a/libopie2/opiepim/core/opimtemplatebase.h
+++ b/libopie2/opiepim/core/opimtemplatebase.h
@@ -95,8 +95,2 @@ public:
95 /** 95 /**
96 * Find in Cache..
97 * Returns empty object if nothing found.
98 */
99 virtual T cacheFind( int uid )const = 0;
100
101 /**
102 * Put element into Cache 96 * Put element into Cache