[sqlite] How to change journal location?

2007-07-21 Thread Simon Posnjak
Hi all!

Is there a way to change the location of the journal file? We would like
to have journal in some other directory than the database.

Regards Simon

-- 
Simon Posnjak
Četrta pot, d.o.o.
Planina 3
4000 Kranj
Slovenija, EU



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] UPDATE reports SQL logic error or missing database

2006-09-08 Thread Simon Posnjak

Hi again!

I found what the problem is that sqlite returns the wrong error code. 
What happens is next (in version 3.3.7):

-vdbe.c:2593 -> sqlite3BtreeCursor returns code 6 (table locked) => rc = 6
-vdbe.c:2606 -> switch checks rc value
-vdbe.c:2642 -> falls to default which is goto abort_due_to_error (:4975)
-vdbe.c:4980 -> goto vbe_halt (:4947)
-vdbe.c:4948 -> rc > 0 == true
-vdbe.c:4950 -> rc = SQLITE_ERROR <== PROBLEM we forget the correct 
error code

-vdbe.c:4956 -> return rc (value is 1) == WRONG!

I added it as a bug (ticket 1965).

Regards Simon

Simon Posnjak wrote:

Hi all!

When I try to do UPDATE of a record i get: SQL logic error or missing
database (error code 1)? The database is not missing or corrupted
because I can UPDATE stuff in it with sqlite3 and I can INSERT into,
SELECT from it and also DELETE. My application uses two threads. The
first thread does INSERT,UPDATE,DELETE and SELECT in to the db and the
other thread only does SELECT. To speed up things I use precompiled
query's. They are created at application startup and they last
throughout  the whole  running time  of the application. I have read and
followed the instructions
(http://www.sqlite.org/cvstrac/wiki?p=MultiThreading) on how to build
multi threaded applications.

Regards Simon



-
To unsubscribe, send email to [EMAIL PROTECTED]
-

  



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] UPDATE reports SQL logic error or missing database

2006-09-07 Thread Simon Posnjak
Hi all!

When I try to do UPDATE of a record i get: SQL logic error or missing
database (error code 1)? The database is not missing or corrupted
because I can UPDATE stuff in it with sqlite3 and I can INSERT into,
SELECT from it and also DELETE. My application uses two threads. The
first thread does INSERT,UPDATE,DELETE and SELECT in to the db and the
other thread only does SELECT. To speed up things I use precompiled
query's. They are created at application startup and they last
throughout  the whole  running time  of the application. I have read and
followed the instructions
(http://www.sqlite.org/cvstrac/wiki?p=MultiThreading) on how to build
multi threaded applications.

Regards Simon



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] CE locking -- review the code

2006-01-17 Thread Simon Posnjak

Robert Simpson wrote:
- Original Message - From: "Simon Posnjak" 
<[EMAIL PROTECTED]>




Robert Simpson wrote:
I incorporated the locks into the latest CVS version of os_win.c and 
it's available here:

http://sqlite.phxsoftware.com/os_win.c


Would i be possible to post  the whole  src? (Taking the 3.3.1 src 
and your file sadly does not work).


Ticket #1600 contains the latest patch that works against os_win.c and 
adds locking code.  Dr. H did some initial code cleanup and I followed 
that up with additional code cleanup to suit his coding style, but I 
suspect he has been too busy as of late to review it.


For your convenience, I've updated the code at the previous link I 
supplied with the latest os_win.c that I am using against the 3.3.1 
alpha.
Thank you. It works super with my application on WinCE 4.10. (The Lucas 
Nuno port had some issues with locking - it dead locked my app). Will 
this code be in the next official release?


Regards Simon


Re: [sqlite] CE locking -- review the code

2006-01-16 Thread Simon Posnjak

Robert Simpson wrote:
- Original Message - From: "Doug Nebeker" 
<[EMAIL PROTECTED]>




Two comments:

* This should only be used for Windows CE as-is.  On Windows
XP/2000/2003(?)/Terminal Services you should probably add "Global\"
to the front of the mutex name so the lock is truly system wide.
Unforunately, you'd have to query Windows to see whether that prefix
could/should be added, but that is doable.


Correct -- this code path would not be available for non-CE 
platforms.  For testing purposes however, it'll run on any flavor of 
Windows.  The code is designed around SQLite's use of those API calls 
under the NT codepath.



* Although it is unlikely, the complete mutex name could end up
being larger than MAX_PATH in which case the mutex won't be created
at all.  Maybe creating a hash of the path would be safest (ie
"Global\sqlite_X4F12F9AB481727BCD" or something like that).


It is pretty highly unlikely, but I suppose hashing the name is a 
possibility.


I incorporated the locks into the latest CVS version of os_win.c and 
it's available here:

http://sqlite.phxsoftware.com/os_win.c
Would i be possible to post  the whole  src? (Taking the 3.3.1 src and 
your file sadly does not work).


Regards Simon



Re: [sqlite] [PATCH] WinCE compilation

2006-01-16 Thread Simon Posnjak

[EMAIL PROTECTED] wrote:

Simon Posnjak <[EMAIL PROTECTED]> wrote:
  
Would it be possible if [Steve Lhomme's] port [to WinCE] and the sf 
port could be merged together in main line src tree?





I have attempt to do this, but I have no way to test it.  Anybody
who is able to download the latest from CVS, compile for WinCE, and
suggest corrections, please do so.
  

Hm... How do I "preprocess" the CVS source so I can compile it with eVC++?

Regards Simon



Re: [sqlite] [PATCH] WinCE compilation

2006-01-05 Thread Simon Posnjak
Hi,

I do not now if you found it but there is another port of sqlite to
WinCE. You can find it at http://sqlite-wince.sourceforge.net/. 

Would it be possible if your port and the sf port could be merged
together in main line src tree?

Regards Simon

On sre, 2006-01-04 at 10:13 -1000, Steve Lhomme wrote:
> Hi everyone,
> 
> I'm a happy user of SQlite for a project I just started to make a 
> multimedia database (a bit like the DB in iTunes). The idea is to make 
> it as cross-platform as possible and free.
> 
> I tried to make it work under Windows CE but run into a few problems 
> when compiling with Embedded Visual C++ 4. Although WinCE has a very 
> similar API to Windows, it lacks some of the features.
> 
> - only the unicode API is present, so I disabled all the xxxA() API calls
> 
> - localtime() is defined but doesn't exist, so I coded one with the 
> existing API
> 
> - LockFile(Ex) and UnlockFile(Ex) are not supported, only the Ex API is 
> available on WinCE 5 but I need bigger support so I just made the code 
> blank on WinCE. Is there any drawback to that ?
> 
> - FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE are not 
> supported for CreateFile. So I removed the flags for WinCE. But that 
> means I have to delete the auto-deleting files on close. I modified the 
> API to do that when calling sqlite3OsClose(). I realise changing the API 
> is not so good, so calling sqlite3OsDelete() where the close is called 
> could be a better option.
> 
> All of the changes are included in the following patch.
> 
> Steve
> 
> priloga plain text document (WinCE.patch)
> Index: os.h
> ===
> --- os.h  (revision 1)
> +++ os.h  (working copy)
> @@ -182,7 +182,7 @@
>  int sqlite3OsSyncDirectory(const char*);
>  int sqlite3OsTempFileName(char*);
>  int sqlite3OsIsDirWritable(char*);
> -int sqlite3OsClose(OsFile*);
> +int sqlite3OsClose(OsFile*, const char*);
>  int sqlite3OsRead(OsFile*, void*, int amt);
>  int sqlite3OsWrite(OsFile*, const void*, int amt);
>  int sqlite3OsSeek(OsFile*, i64 offset);
> Index: os_unix.c
> ===
> --- os_unix.c (revision 1)
> +++ os_unix.c (working copy)
> @@ -1278,7 +1278,7 @@
>  /*
>  ** Close a file.
>  */
> -int sqlite3OsClose(OsFile *id){
> +int sqlite3OsClose(OsFile *id, const char*){
>if( !id->isOpen ) return SQLITE_OK;
>if( CHECK_THREADID(id) ) return SQLITE_MISUSE;
>sqlite3OsUnlock(id, NO_LOCK);
> Index: os_win.c
> ===
> --- os_win.c  (revision 1)
> +++ os_win.c  (working copy)
> @@ -33,6 +33,64 @@
>  ** Include code that is common to all os_*.c files
>  */
>  #include "os_common.h"
> +
> +#if defined(_WIN32_WCE)
> +#include 
> +struct tm * __cdecl localtime(const time_t *t)
> +{
> +  static struct tm y;
> +  FILETIME uTm, lTm;
> +  SYSTEMTIME pTm;
> +  uTm.dwLowDateTime = *t & 0x;
> +  uTm.dwHighDateTime= *t >> 32;
> +  FileTimeToLocalFileTime(,);
> +  FileTimeToSystemTime(,);
> +  y.tm_year = pTm.wYear - 1900;
> +  y.tm_mon = pTm.wMonth - 1;
> +  y.tm_wday = pTm.wDayOfWeek;
> +  y.tm_mday = pTm.wDay;
> +  y.tm_hour = pTm.wHour;
> +  y.tm_min = pTm.wMinute;
> +  y.tm_sec = pTm.wSecond;
> +  return 
> +}
> +
> +#ifndef LOCKFILE_EXCLUSIVE_LOCK
> +#define LockFileEx(a,b,c,d,e,f) (1)
> +#define UnlockFileEx(a,b,c,d,e) (1)
> +#endif
> +
> +BOOL LockFile(
> +  HANDLE hFile,
> +  DWORD dwFileOffsetLow,
> +  DWORD dwFileOffsetHigh,
> +  DWORD nNumberOfBytesToLockLow,
> +  DWORD nNumberOfBytesToLockHigh
> +)
> +{
> +  OVERLAPPED ovlp;
> +  ovlp.Offset = dwFileOffsetLow;
> +  ovlp.OffsetHigh = dwFileOffsetHigh;
> +  ovlp.hEvent = 0;
> +  return LockFileEx(hFile, 
> LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY, 0, 
> nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, );
> +}
> +
> +
> +BOOL UnlockFile(
> +  HANDLE hFile,
> +  DWORD dwFileOffsetLow,
> +  DWORD dwFileOffsetHigh,
> +  DWORD nNumberOfBytesToUnlockLow,
> +  DWORD nNumberOfBytesToUnlockHigh
> +)
> +{
> +  OVERLAPPED ovlp;
> +  ovlp.Offset = dwFileOffsetLow;
> +  ovlp.OffsetHigh = dwFileOffsetHigh;
> +  ovlp.hEvent = 0;
> +  return UnlockFileEx(hFile, 0, nNumberOfBytesToUnlockLow, 
> nNumberOfBytesToUnlockHigh, );
> +}
> +#endif
>  
>  /*
>  ** Do not include any of the File I/O interface procedures if the
> @@ -66,14 +124,18 @@
>  ** WinNT/2K/XP so that we will know whether or not we can safely call
>  ** the LockFileEx() API.
>  */
> -static int isNT(void){
> +static int isNT(void){
> +#if !defined(_WIN32_WCE)
>if( sqlite3_os_type==0 ){
>  OSVERSIONINFO sInfo;
>  sInfo.dwOSVersionInfoSize = sizeof(sInfo);
>  GetVersionEx();
>  sqlite3_os_type = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT ? 2 : 1;
>}
> -  return sqlite3_os_type==2;
> +  return sqlite3_os_type==2;
> +#else
> +  return 1;
> +#endif
>  }
>  
>  /*
> @@ -131,9 +193,11 @@
>if( zWide ){
>  

[sqlite] uclibc and sqlite

2005-06-01 Thread Simon Posnjak

Hi all,

As someone already reported uclibc and sqlite do not play nice together. 
I did a bt after a segfault and got:


#0  0x00089f8c in sqlite3OsFileSize (id=0xf0434, pSize=0x0) at 
src/os_unix.c:816
#1  0x000bea10 in sqlite3pager_pagecount (pPager=0xf0428) at 
src/pager.c:1750
#2  0x000c0062 in sqlite3pager_get (pPager=0xf0428, pgno=1, 
ppPage=0x9fffa298) at src/pager.c:2498
#3  0x000a1644 in getPage (pBt=0xf02c8, pgno=1, ppPage=0x9fffa2c0) at 
src/btree.c:1115

#4  0x000a1d90 in lockBtree (pBt=0xf02c8) at src/btree.c:1424
#5  0x000a22e6 in sqlite3BtreeBeginTrans (pBt=0xf02c8, wrflag=0) at 
src/btree.c:1611

#6  0x000a2032 in lockBtreeWithRetry (pBt=0xf02c8) at src/btree.c:1491
#7  0x000a3220 in sqlite3BtreeCursor (pBt=0xf02c8, iTable=1, wrFlag=0, 
xCmp=0, pArg=0x0, ppCur=0x9fffa3cc) at src/btree.c:2152
#8  0x00086b64 in sqlite3InitOne (db=0xf0008, iDb=0, 
pzErrMsg=0x9fffa6d6) at src/main.c:204
#9  0x00087030 in sqlite3Init (db=0xf0008, pzErrMsg=0x9fffa6d6) at 
src/main.c:347

#10 0x00087162 in sqlite3ReadSchema (pParse=0x9fffa6ce) at src/main.c:387
#11 0x000ab874 in sqlite3LocateTable (pParse=0x9fffa6ce, zName=0xf3bf0 
"sqlite_master", zDbase=0x0) at src/build.c:195
#12 0x000c96e8 in prepSelectStmt (pParse=0x9fffa6ce, p=0xf3d88) at 
src/select.c:1005
#13 0x000cc4f0 in sqlite3SelectResolve (pParse=0x9fffa6ce, p=0xf3d88, 
pOuterNC=0x0) at src/select.c:2334
#14 0x000cc91a in sqlite3Select (pParse=0x9fffa6ce, p=0xf3d88, eDest=1, 
iParm=0, pParent=0x0, parentTab=0, pParentAgg=0x0, aff=0x0) at 
src/select.c:2548

#15 0x000c3764 in yy_reduce (yypParser=0xf3360, yyruleno=98) at parse.y:329
#16 0x000c55c2 in sqlite3Parser (yyp=0xf3360, yymajor=9, yyminor={z = 
0xdc27b "'table'", dyn = 0, n = 7}, pParse=0x9fffa6ce) at parse.c:3303
#17 0x0008e2d8 in sqlite3RunParser (pParse=0x9fffa6ce, zSql=0xdc234 
"SELECT name, type, sql FROM sqlite_master WHERE sql NOT NULL AND 
type=='table'",

   pzErrMsg=0x9fffa6ca) at src/tokenize.c:399
#18 0x000884be in sqlite3_prepare (db=0xf0008, zSql=0xdc234 "SELECT 
name, type, sql FROM sqlite_master WHERE sql NOT NULL AND 
type=='table'", nBytes=-1,

   ppStmt=0x9fffa7bc, pzTail=0x9fffa7c0) at src/main.c:1061
#19 0x0009e8b2 in sqlite3_exec (db=0xf0008, zSql=0xdc234 "SELECT name, 
type, sql FROM sqlite_master WHERE sql NOT NULL AND type=='table'",
   xCallback=0x83114 , pArg=0x9fffe8f5, pzErrMsg=0x0) at 
src/legacy.c:56
#20 0x000834ba in run_schema_dump_query (p=0x9fffe8f5, zQuery=0xdc234 
"SELECT name, type, sql FROM sqlite_master WHERE sql NOT NULL AND 
type=='table'",

   pzErrMsg=0x0) at src/shell.c:730
#21 0x00083b4a in do_meta_command (zLine=0xf2ca8 ".dump", p=0x9fffe8f5) 
at src/shell.c:906

#22 0x00085a16 in process_input (p=0x9fffe8f5, in=0x0) at src/shell.c:1472
#23 0x00086648 in main (argc=2, argv=0x9eb4) at src/shell.c:1789

If we look at the code of sqlite3pager_pagecount in pager.c we find:

int sqlite3pager_pagecount(Pager *pPager){
 i64 n;
 assert( pPager!=0 );
 if( pPager->dbSize>=0 ){
   return pPager->dbSize;
 }
 if( sqlite3OsFileSize(>fd, )!=SQLITE_OK ){
   pPager->errMask |= PAGER_ERR_DISK;
   return 0;
 }
 n /= pPager->pageSize;
 if( !MEMDB && n==PENDING_BYTE/pPager->pageSize ){
   n++;
 }
 if( pPager->state!=PAGER_UNLOCK ){
   pPager->dbSize = n;
 }
 return n;
}

So we call sqlite3OsFileSize with >fd and  But if you look at 
the bt you will see that the function was called with >fd and 
NULL (pSize=0x0). How is this possible?


Regards Simon