On 02/26/2012 09:13 PM, Simon Slavin wrote:
> 
> On 26 Feb 2012, at 7:29pm, Patrik Nilsson <nipatriknils...@gmail.com> wrote:
> 
>> I have a table called page (defined below) and have noticed that the
>> data-variable (blob) sometimes get corrupted. How do I set up a log to
>> debug what is happening. What I want is a log file saved with my file,
>> so I can backtrace the error.
> 
> There are various callbacks you can use to make SQLite call your own logging 
> routines, but I don't think anything will help with this sort of thing.
> 
>> This is also to be able to send in a good bug report to the developers
>> of SQLite.
>>
>> I don't know the exact steps to reproduce the error, but the following
>> might give someone a clue:
>>
>> 1) Add rows (one by one) with data.
>> 2) Update sortorder for the whole table with begin/commit
> 
> Can you explain that ?  Tables don't have a sortorder.  You would normally 
> put begin/commit around commands changing the data in a table, e.g. the 
> INSERT commands in your step (1).

sortorder is defined as an integer in the table and is the way I use to
know which order the rows is to be displayed.

create table if not exists page ( id integer primary key autoincrement,
type integer, sortorder integer, width integer, height integer, size
integer, deleted integer default 0, zoom integer default 0, modified
datetime default (datetime('now','localtime')), comment text, data blob )

> 
>> 3) After these and maybe some other steps (i.e. updating a row's data
>> with new data), I discover that a random row of the table has a
>> corrupted data-blob.
> 
> Are you using any PRAGMAs ?

The only pragma I use is "PRAGMA table_info(table)" and it is when I
analyze if the table is correct or an update is needed.

Also the defines I use when compiling are:
SQLITE_ENABLE_FTS3_PARENTHESIS
SQLITE_ENABLE_COLUMN_METADATA
SQLITE_ENABLE_MEMORY_MANAGEMENT

The last define is so I can use "sqlite3_release_memory()".

> Is the database file on the hard disk of the computer doing the operations, 
> or are you accessing it across a network ?

It is a local file using Debian Linux. I compile the source code
directly into my executable.

> Are you doing any kind of multi-thread/multi-process/multi-user thing ?

Yes. My program starts two thread, the main one and a worker. There are
mutexes so only one at a time can the sqlite interface.

> 
> There are a whole bunch of things that will corrupt your file so I'll point 
> you at the page, but answering the above questions will help you faster.
> 
> <http://www.sqlite.org/howtocorrupt.html>
> 
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to