Re: [sqlite] sqlite 3.7.6.2: sqlite3VdeExec says we have a corrupted database

2011-04-28 Thread Simon Slavin

On 28 Apr 2011, at 7:28pm, Frank Chang wrote:

>  Good afternoon, We are using the latest version of sqlite, 3.7.6.2 in 
> Windows XP 32bit ( and Centos Linux 5.5). sqlite3_step, sqlite3_reset and 
> sqlite3VdeExec says we have a corrupted database. We are not using the WAL 
> mode. 
>When I using sqlite3.exe to query the database, the queries return 
> correct values. So I am wondering if our database is really corrupted.



Use sqlite3.exe, or write your own code, to issue the following command:

PRAGMA integrity_check;

(from )

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] sqlite 3.7.6.2: sqlite3VdeExec says we have a corrupted database

2011-04-28 Thread Frank Chang


  Good afternoon, We are using the latest version of sqlite, 3.7.6.2 in Windows 
XP 32bit ( and Centos Linux 5.5). sqlite3_step, sqlite3_reset and 
sqlite3VdeExec says we have a corrupted database. We are not using the WAL 
mode. 
When I using sqlite3.exe to query the database, the queries return 
correct values. So I am wondering if our database is really corrupted.
Using the Windows C++ 2008 Debugger, we can isolate the detection of 
the corrupted sqlite database to the following lines:
lines 64503 - 64513 of sqlite.c(sqlite3VdbeExec) shown below. 
We were wondering how to fix this problem. Is our sqlite database 
really corrupted or are we doing something wrong in our application. Below 
lines  64504 - 64513 we show an excerpt of our application code.   
 
/* If we have read more header data than was contained in the header,
** or if the end of the last field appears to be past the end of the
** record, or if the end of the last field appears to be before the end
** of the record (when all fields present), then we must be dealing
** with a corrupt database.
*/
if( (u.am.zIdx > u.am.zEndHdr) || (u.am.offset > u.am.payloadSize)
|| (u.am.zIdx==u.am.zEndHdr && u.am.offset!=u.am.payloadSize) ){
rc = SQLITE_CORRUPT_BKPT;
goto op_column_out;
}
}
 
 
--APPLICATION CODE---
 strcpy(SelectStatement, "select [Key] from KeyFile order by rowid");
 ReturnValue=sqlite3_prepare(Database,SelectStatement,-1,,0);
 int mm(0);
 while (true){
 
  status =  sqlite3_step(Statement); 
  if (status == SQLITE_ROW) {
   bytes = sqlite3_column_bytes(Statement,0);
   Key = new char[bytes+1];
   memset(Key,0,54);
   memcpy(Key, sqlite3_column_text(Statement, 0),bytes);
  char *filestart = KeyArray->operator [](Offset); //Memory Mapped File
   strcpy([Offset],Key); //Memory Mapped File
   
   Offset += Matchcode->KeySize();
   delete [] Key;
   mm += 1;
  }
  else{
 resetstatus = sqlite3_reset(Statement);
 KeyArray->AddFinalRange(); // Memory Mapped File
break;
  }
 }
 status = sqlite3_finalize(Statement);
  
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users