RE: [sqlite] FW: Help with Porting Problem

2004-04-26 Thread Juan Romano
Christian,
Thanks for your reply.  I have been side-tracked for a few days. But
thanks for your suggestions.

You are correct. My changes are confined to os.c:
1.- Use file descriptors instead of inodes in file lock hash keys (We're
using DOS).
2.- access() function changed to either a nop or stat. (Use stat when
access() is being used to ascertain the existence of a file).
3.- fsync():  Use ioctl (FIOSYNC).
4.- unlink(): I have tried 2 approaches:
a) use remove on sqliteOsDelete() and nop the rest.
b) keep track of unlink calls and remove the files on close() if
they've been unlinked and their link count is 1 or less.
Both of these seem to work. I see no related errors and the temporary
files seem to be created and deleted correctly (Of course my
understanding on what files should be deleted and when may be totally
off).

Thanks again,

Juan//


-Original Message-
From: Christian Smith [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 23, 2004 4:04 AM
To: Juan Romano
Cc: [EMAIL PROTECTED]
Subject: Re: [sqlite] FW: Help with Porting Problem

On Tue, 20 Apr 2004, Juan Romano wrote:

>Hi, I am porting sqlite to vxworks.  I use the shell to issue some
>simple SQL commands.   I can create a table and then I can issue insert
>SQL statements, but when I try to display the data I inserted (by using
>select) I always get the first record and only the first record I
>inserted.  I can create a second table and try the same thing and the
>same thing happens. It seems that all inserts after the first one are
>getting lost.
>
>I have had to change a number of things because of the file systems
>differences. It took some work to get the files management working
>(???), but obviously there is still some work there.

Try compiling your changes on a regular UNIX machine, and see if you get
the same results.

I thought VxWorks would be UNIX like enough to work simply with the
existing UNIX code. Is that not the case?

>
>
>
>I am sure it is my doing but I am looking for some pointers as to what
>area of the code I should be looking at.  I have a bunch of debug
>statements but I don't see any error or anything suspicious. It appears
>that the data is being written to the files, but somehow it gets lost.
>May be it is the record retrieval where the problem is.

The only code you should need to update is os.c, as the other code
should
be sufficiently platform independant not to require updates.

Maybe if you posted your changes, someone else could try them.

Christian

-- 
/"\
\ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
 X   - AGAINST MS ATTACHMENTS
/ \



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [sqlite] Help with "SQL error: database is locked"

2004-04-16 Thread Juan Romano
Hi, I am in the process of porting sqlite (version 2.8.13) to vxworks. I
am running into some problems.
It seems to work when I invoke the shell with no database (:memory:). I
can then create tables, insert records, etc. In general I can submit SQL
queries at will.  However, when I invoke the shell with a database
filename, whether the file exists or not, I get the error:
SQL error: database is locked
It seems that the database is write-locked to start the transaction and
then an attempt to get a read lock fails. There is only one task
(thread) running which is running the shell application.
I should mention that I have made a number of changes, some temporary to
get it running.
1.- Shortened temporary file names.
2.- unlink does not do anything (I think this results in temporary files
being persistent).
3.- __DJGPP__ is defined so that fcntl is a nop (no file locking).
4.- The shell only takes one argument, the database name.

After I exit the shell, there are 3 files created: mydatabase,
mydatabase-journal, and the temporary file (normally sqlite_xy..).

A side question I have is: Can you disable transactions ? If so, how ?

Any help would be much appreciated.

Thanks.

Juan//

What follows is a trace from a bunch of debug statements I have added in
the process of debugging my port. I hope it helps:

>sqlite_shell_main("/tffs0/mydatabase")

sqlite> create table autos(year smallint, make varchar(32), model
varchar(32), id smallint);

sqlite_open: Enter
sqlite_open: Call sqliteBtreeFactory
sqliteBtreeFactory: Enter
sqliteBtreeFactory: Call sqliteBtreeOpen
sqliteBtreeOpen: Enter
sqlitepager_open: Enter (filename = /tffs0/mydatabase)
sqliteOsOpenReadWrite: Enter (filename = /tffs0/mydatabase)
sqliteOsOpenReadWrite: opened file /tffs0/mydatabase
sqliteOsOpenReadWrite: id = 0x1ed63e0
findLockInfo: nRef = 1
findLockInfo: cnt = 0
sqliteOsOpenReadWrite: SQLITE_OK
sqlitepager_open: sqliteOsOpenReadWrite returned 0
sqlitepager_open: SQLITE_OK
sqliteBtreeOpen: SQLITE_OK
sqliteInit: Enter
sqliteInitOne: Enter
sqliteStartTable: Call sqliteBtreeFactory
sqliteBtreeFactory: Enter
sqliteBtreeOpen: Enter
sqlitepager_open: Enter (filename = (null))
sqlitepager_opentemp: Enter
sqliteOsTempFileName: zBuf = /sql_
sqliteOsOpenExclusive: Enter (filename = /tffs0/sql_B3j)
sqliteOsOpenExclusive: opened /tffs0/sql_B3j (fd = 47).
findLockInfo: found pLock (nRef = 2)
sqliteOsOpenExclusive: delFlag. unlink file /tffs0/sql_B3j
sqliteOsOpenExclusive: SQLITE_OK
sqlitepager_opentemp: rc = 0
sqlitepager_open: sqlitepager_opentemp returned 0
sqlitepager_open: SQLITE_OK
sqliteBtreeOpen: SQLITE_OK
fileBtreeCursor: Enter
lockBtree: Enter
lockBtree: Calling sqlitepager_get
sqlitepager_get: Enter
sqlitepager_get: First page. Get a read lock !
sqliteOsReadLock: Enter
sqliteOsReadLock: id->pLock->cnt = 0
sqliteOsReadLock: id->locked = 0
sqliteOsReadLock: s = 0
sqliteOsReadLock: increment nLock
sqliteOsReadLock: pLock->cnt (0x1ecc65c) set to 1
sqliteOsReadLock: id->pLock->cnt = 1
sqliteOsReadLock: id->locked = 1
sqliteOsReadLock: returns Something
sqlitepager_pagecount: Enter (file = /tffs0/mydatabase)
sqlitepager_get: SQLITE_OK
sqlitepager_pagecount: Enter (file = /tffs0/mydatabase)
lockBtree: return 0
fileBtreeCursor: Calling sqlitepager_get
sqlitepager_get: Enter
sqlitepager_get: SQLITE_OK
fileBtreeCursor: SQLITE_OK
fileBtreeGetMeta: Calling sqlitepager_get
sqlitepager_get: Enter
sqlitepager_get: SQLITE_OK
fileBtreeGetMeta: SQLITE_OK
fileBtreeCursor: Enter
lockBtree: Enter
lockBtree: Calling sqlitepager_get
sqlitepager_get: Enter
sqlitepager_get: First page. Get a read lock !
sqliteOsReadLock: Enter
sqliteOsReadLock: id->pLock->cnt = 1
sqliteOsReadLock: id->locked = 0
sqliteOsReadLock: pLock->cnt (0x1ecc65c) incremented to 2
sqliteOsReadLock: id->pLock->cnt = 2
sqliteOsReadLock: id->locked = 1
sqliteOsReadLock: returns Something
sqlitepager_pagecount: Enter (file = /tffs0/sql_B3j)
sqlitepager_get: SQLITE_OK
sqlitepager_pagecount: Enter (file = /tffs0/sql_B3j)
lockBtree: return 0
fileBtreeCursor: Calling sqlitepager_get
sqlitepager_get: Enter
sqlitepager_get: SQLITE_OK
fileBtreeCursor: SQLITE_OK
moveToRoot: Calling sqlitepager_get
sqlitepager_get: Enter
sqlitepager_get: SQLITE_OK
sqliteOsUnlock: pLock->cnt (0x1ecc65c) decremented to 1
sqliteOsUnlock: return Something
fileBtreeCursor: Enter
fileBtreeCursor: Calling sqlitepager_get
sqlitepager_get: Enter
sqlitepager_get: SQLITE_OK
fileBtreeCursor: SQLITE_OK
fileBtreeGetMeta: Calling sqlitepager_get
sqlitepager_get: Enter
sqlitepager_get: SQLITE_OK
fileBtreeGetMeta: SQLITE_OK
moveToRoot: Calling sqlitepager_get
sqlitepager_get: Enter
sqlitepager_get: SQLITE_OK
sqliteOsUnlock: pLock->cnt (0x1ecc65c) set to 0
sqliteOsUnlock: return Something
sqliteInitOne: Final returns 0
sqliteInit: sqliteInitOne returned 0
sqliteInit: returns 0
sqlite_open: sqliteInit returned 0
sqlite_open: return db = 0x1ecc424
fileBtreeBeginTrans: Enter
lockBtree: Enter
lockBtree: Calling sqlitepager_get
sqlitepager_get: