[sqlite] RE: sqlite testing with Boundschecker

2007-07-01 Thread Damian Slee
Re-submitted cause line color in red didn’t  come thru.  [] around the
reported line

 


Subject: sqlite testing with Boundschecker

 

Hi,

I have done some testing with 3.2 and now 3.4, visual studio2003 and
boundschecker (and XP).  I get a few reported errors when I simply do the
.dump command with no db.  Happens on other times with a db, this is easier.
Line numbers are from the downloaded 3.4.0 source.  I don’t really know how
the vdbe works, so not sure how to start on solving the write overrun one…

 

Thanks,

damian

 

Vdbeaux.c sqlite3VdbeChangeP3 line 534

Memory block at address void* _Src = 0x0012C92C in argument 2 in memcpy is
too small, should be 17, was 16.

if( pKeyInfo ){

  unsigned char *aSortOrder;

  [memcpy(pKeyInfo, zP3, nByte);]

  aSortOrder = pKeyInfo->aSortOrder;

 

 

Write Overrun: Memory write to 0x010D8A88 (2) overruns destination block
0x010D89F8 (60) allocated by HeapAlloc.

Vdbe.c, sqlite3VdbeExec, Line 701.  This occurs when running sqlite3.exe
with no db, then executing .dump, then second breakpoint on the pTos->flags
line invokes this boundschecker error.  

case OP_Integer: {

  pTos++;

  [pTos->flags = MEM_Int;]

  pTos->u.i = pOp->p1;

  break;

}

 

Resource Leak Exiting Program: Handle 0x0014 allocated by TlsAlloc.

Os_win.c line 1730

if( !keyInit ){

sqlite3OsEnterMutex();

if( !keyInit ){

  [key = TlsAlloc();]

  if( key==0x ){

sqlite3OsLeaveMutex();

return 0;

  }

 

 

Dangling Pointer: Pointer 0x010D9250, allocated by HeapAlloc, has already
been freed.

Vdbe.c sqlite3VdbeExec Line 469

if( p->magic!=VDBE_MAGIC_RUN ) return SQLITE_MISUSE;

  assert( db->magic==SQLITE_MAGIC_BUSY );

  [pTos = p->pTos;]

  if( p->rc==SQLITE_NOMEM ){

 

 

 

Pointer Error:  Pointer 0x010DA9F0, used as an argument, is out of range; no
longer within block 0x010DAA30 (204), allocated by malloc.

Vdbeaux.c, sqlite3VdbeMakeReady line 889 

for(n=0; nnMem; n++){

p->aMem[n].flags = MEM_Null;

  }

 

  [p->pTos = >aStack[-1];]

  p->pc = -1;

  p->rc = SQLITE_OK;

 

similar error Cleanup, line 967

static void Cleanup(Vdbe *p){

  int i;

  if( p->aStack ){

releaseMemArray(p->aStack, 1 + (p->pTos - p->aStack));

[p->pTos = >aStack[-1];]

  }

  closeAllCursors(p);

 

 

Similar error  vdbe.c sqlite3VdbeExec, line2681

sqlite3VdbeMemIntegerify(pTos);

  iDb = pTos->u.i;

  assert( (pTos->flags & MEM_Dyn)==0 );

  [pTos--;]

  assert( iDb>=0 && iDbnDb );

 

 

Unrelated Pointer: Comparing two unrelated pointers 0x010D8A30 and
0x010D8A70.  Pointers are not within the same buffer.

Vdbe.c sqlite3VdbeExec line 983

static void Cleanup(Vdbe *p){

  int i;

  if( p->aStack ){

[releaseMemArray(p->aStack, 1 + (p->pTos - p->aStack));]

p->pTos = >aStack[-1];

  }

 

 

Unrelated Pointer: Comparing two unrelated pointers 0x010DAD10 and
0x010DACD0.  Pointers are not within the same buffer.

Vdbe.c sqlite3VdbeExec – line 983

  pFirstColumn = [0-pOp->p1];

  [for(pMem = p->aStack; pMemaStack ){

[releaseMemArray(p->aStack, 1 + (p->pTos - p->aStack));]

p->pTos = >aStack[-1];

  }

 

 

Unrelated Pointer: Comparing two unrelated pointers 0x010DAD10 and
0x010DACD0.  Pointers are not within the same buffer.

Vdbe.c sqlite3VdbeExec line 983

pFirstColumn = [0-pOp->p1];

  [for(pMem = p->aStack; pMem

[sqlite] sqlite testing with Boundschecker

2007-07-01 Thread Damian Slee
Hi,

I have done some testing with 3.2 and now 3.4, visual studio2003 and
boundschecker (and XP).  I get a few reported errors when I simply do the
.dump command with no db.  Happens on other times with a db, this is easier.
Line numbers are from the downloaded 3.4.0 source.  I don’t really know how
the vdbe works, so not sure how to start on solving the write overrun one…

 

Thanks,

damian

 

Vdbeaux.c sqlite3VdbeChangeP3 line 534

Memory block at address void* _Src = 0x0012C92C in argument 2 in memcpy is
too small, should be 17, was 16.

if( pKeyInfo ){

  unsigned char *aSortOrder;

  memcpy(pKeyInfo, zP3, nByte);

  aSortOrder = pKeyInfo->aSortOrder;

 

 

Write Overrun: Memory write to 0x010D8A88 (2) overruns destination block
0x010D89F8 (60) allocated by HeapAlloc.

Vdbe.c, sqlite3VdbeExec, Line 701.  This occurs when running sqlite3.exe
with no db, then executing .dump, then second breakpoint on the pTos->flags
line invokes this boundschecker error.  

case OP_Integer: {

  pTos++;

  pTos->flags = MEM_Int;

  pTos->u.i = pOp->p1;

  break;

}

 

Resource Leak Exiting Program: Handle 0x0014 allocated by TlsAlloc.

Os_win.c line 1730

if( !keyInit ){

sqlite3OsEnterMutex();

if( !keyInit ){

  key = TlsAlloc();

  if( key==0x ){

sqlite3OsLeaveMutex();

return 0;

  }

 

 

Dangling Pointer: Pointer 0x010D9250, allocated by HeapAlloc, has already
been freed.

Vdbe.c sqlite3VdbeExec Line 469

if( p->magic!=VDBE_MAGIC_RUN ) return SQLITE_MISUSE;

  assert( db->magic==SQLITE_MAGIC_BUSY );

  pTos = p->pTos;

  if( p->rc==SQLITE_NOMEM ){

 

 

 

Pointer Error:  Pointer 0x010DA9F0, used as an argument, is out of range; no
longer within block 0x010DAA30 (204), allocated by malloc.

Vdbeaux.c, sqlite3VdbeMakeReady line 889 

for(n=0; nnMem; n++){

p->aMem[n].flags = MEM_Null;

  }

 

  p->pTos = >aStack[-1];

  p->pc = -1;

  p->rc = SQLITE_OK;

 

similar error Cleanup, line 967

static void Cleanup(Vdbe *p){

  int i;

  if( p->aStack ){

releaseMemArray(p->aStack, 1 + (p->pTos - p->aStack));

p->pTos = >aStack[-1];

  }

  closeAllCursors(p);

 

 

Similar error  vdbe.c sqlite3VdbeExec, line2681

sqlite3VdbeMemIntegerify(pTos);

  iDb = pTos->u.i;

  assert( (pTos->flags & MEM_Dyn)==0 );

  pTos--;

  assert( iDb>=0 && iDbnDb );

 

 

Unrelated Pointer: Comparing two unrelated pointers 0x010D8A30 and
0x010D8A70.  Pointers are not within the same buffer.

Vdbe.c sqlite3VdbeExec line 983

static void Cleanup(Vdbe *p){

  int i;

  if( p->aStack ){

releaseMemArray(p->aStack, 1 + (p->pTos - p->aStack));

p->pTos = >aStack[-1];

  }

 

 

Unrelated Pointer: Comparing two unrelated pointers 0x010DAD10 and
0x010DACD0.  Pointers are not within the same buffer.

Vdbe.c sqlite3VdbeExec – line 983

  pFirstColumn = [0-pOp->p1];

  for(pMem = p->aStack; pMemaStack ){

releaseMemArray(p->aStack, 1 + (p->pTos - p->aStack));

p->pTos = >aStack[-1];

  }

 

 

Unrelated Pointer: Comparing two unrelated pointers 0x010DAD10 and
0x010DACD0.  Pointers are not within the same buffer.

Vdbe.c sqlite3VdbeExec line 983

pFirstColumn = [0-pOp->p1];

  for(pMem = p->aStack; pMem

RE: [sqlite] DETACHing database after sqlite3_step, but before sqlite3_finalize causes crash in btree.c

2005-09-04 Thread Damian Slee
Yea, but it should have returned an error code or something, not an access 
violation. 

-Original Message-
From: Jay Sprenkle [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 02, 2005 9:54 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] DETACHing database after sqlite3_step, but before 
sqlite3_finalize causes crash in btree.c

On 9/1/05, Damian Slee <[EMAIL PROTECTED]> wrote:
> 
> 
> Work arounds are to call sqlite3_finalize on the query (to cleanup) 
> before detaching, or only selecting the top N in the first place.
> 
> I don't know the internals well enough to fix it myself..


Sounds like you found your answers already ;)



---
The Castles of Dereth Calendar: a tour of the art and architecture of Asheron's 
Call
http://www.lulu.com/content/77264

--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/86 - Release Date: 31/08/2005
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/86 - Release Date: 31/08/2005
 


[sqlite] DETACHing database after sqlite3_step, but before sqlite3_finalize causes crash in btree.c

2005-09-01 Thread Damian Slee

Hi,
Don't know yet if this is fixed in the latest version, but I thought I would 
bring it up anyway.

We are using 3.2.2 library on windows.

Open a database
If you then attach another database
- sqlite3_exec()

Then step a select query, combining some info from tables from both database
- sqlite3_prepare()
- sqlite3_step()
sqlite3_step()
...
But do not keep going till EOF.  Ie. stop before sqlite3_step() returns 
SQLITE_DONE.  Eg do 3 rows out of 10.

Then detach the database
- sqlite3_exec()

It will crash here in at line 2218 in btree.c:

pCur->pPrev->pNext = pCur->pNext;


Work arounds are to call sqlite3_finalize on the query (to cleanup) before 
detaching, or only selecting the top N in the first place.

I don't know the internals well enough to fix it myself..

Regards,

Damian

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/86 - Release Date: 31/08/2005
 


RE: [sqlite] Re: sqite2.8 performance snag when filesize growsmore than 70MB on a 256MB ram

2005-08-21 Thread Damian Slee
>>In order to implement the ORDER BY clause, SQLite reads the entire result set 
>>into memory and sorts it there.  When your result set gets very large (13000 
>>rows) and each row uses in excess of 1KB or memory,this is apparently causing 
>>your machine to thrash.


If an index exists on the same column that Order By is used, does this still 
result in reading the entire result set?

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.12/75 - Release Date: 17/08/2005
 


RE: [sqlite] round ?

2005-07-28 Thread Damian Slee
I tried it on windows for you.   sqlite3.exe v3.21

sqlite> select round(1-0.5);
1
sqlite> select round(2-0.5);
2
sqlite> select round(3-0.5);
3
sqlite> select round(4-0.5);
4
sqlite> select round(5-0.5);
5
sqlite> select round(6-0.5);
6

Maybe the math libarary on the C compiler you are using?
 

-Original Message-
From: Nicolas Martin [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 28, 2005 2:37 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] round ?

Some strange effect of the round expression :

sqlite> select round(1-0.5);
0
sqlite> select round(2-0.5);
2
sqlite> select round(3-0.5);
2
sqlite> select round(4-0.5);
4
sqlite> select round(5-0.5);
4
sqlite> select round(6-0.5);
6
sqlite>






--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.6/59 - Release Date: 27/07/2005
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.6/59 - Release Date: 27/07/2005
 


RE: [sqlite] SQLite in memory database from SQLite (3.x) file database?

2005-07-06 Thread Damian Slee
You could create a new os_ram.c file, with new versions of these functions, but 
instead of read/writing to disk you are read/writing from a linked list of 
filenames, of which each could contain a ptr to the file data.  You would then 
be responsible for copying it back to disk at some point.  And loading it from 
disk when it starts, into your psuedo ram file system.

I guess this would also allow multithreaded access to an in memory database (if 
the locking is also implemented).  Where as opening the "%memory%" one, is only 
single threaded (in the cache), I think?

But you loose sharing the db across processes.   Which I don't think matters to 
you, if you want to load it all into ram anyway.

sqlite3OsOpenReadWrite
sqlite3OsOpenExclusive
sqlite3OsOpenReadOnly
sqlite3OsClose
sqlite3OsRead
sqlite3OsWrite
...
 

-Original Message-
From: Dirk Theisen [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 07, 2005 7:09 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] SQLite in memory database from SQLite (3.x) file database?

Hello, John!

> It would be nice to have option that just loads the db file into 
> memory or  otherwise caches the contents wholly in memory.  Are there 
> any caching options in sqlite that would mirror this behavior?

You could set the cache size as big as your database file (via pragma). 
This should load all (used) data into memory. This is probably not a good 
solution if your application does not run for a longer time.

Greetings,
   Dirk


--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.10/43 - Release Date: 6/07/2005
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.10/43 - Release Date: 6/07/2005
 


[sqlite] Using pragma user_version

2005-05-26 Thread Damian Slee
Hi,
In the sqlite wiki below it describes the use of pragma user_version, but 
doesn't really say how to use it.  I'm evaluating the latest sqlite.exe.

Say on initial creation of me DB I set user_version to 1.  then product with DB 
schema 1 gets released.

Then at some point in the future I want to insert some data into tables only if 
user_version ==1.  then update user_version to 2.

I don't think the sqlite syntax supports?
IF (pragma.user_version == 1)
BEGIN
INSERT into x 
END


Do I have to query user_version from code instead, through sqlite API?

Thanks,
damian



http://www.sqlite.org/cvstrac/wiki?p=SqliteWikiFaq

Q) On sqlite3_Open(), when the file with given filename doesn't exists, SQLite 
creates new database. But usually, the application needs to do some 
initialization work to be able to use this new database (create tables etc.) 
So, what is the most natural way to determine, that Open() created new database 
instead of opening the existing one?
A) Use some system API funtion like IsFileExists(DB_filename) before calling 
sqlite_open(DB_filename) 
A) or, use the "user_version" pragma. Right after calling open(), do "pragma 
user_version". If it returns "0", then assume that this is a new file -- create 
your tables and do "pragma user_version=1" to mark that you've created your 
tables in this db. The next time you do "pragma user_version", it will return 
1, signifying that you've previously set up this db. 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 266.11.17 - Release Date: 5/25/2005
 


RE: [sqlite] backup open database

2005-04-30 Thread Damian Slee
hi,
i had have a look, i may be able to use this.  this will be in an embedded 
hardware application, so i don't have a command line, only what i code in. 

i was hoping to do a binary copy of the db from a ram file system to flash 
memory for permanent storage.  flash is really slow, so a copy would be a lot 
quicker than a series of .dump Inserts.  which really requires sqlite running 
on a flash file system as well.  a copy is really all i want, but knowing when 
everything is commited, or locking out other threads without them having to 
close the db.

thanks,

damian

 




From: Mrs. Brisby [mailto:[EMAIL PROTECTED]
Sent: Sun 1/05/2005 1:07 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] backup open database



Why is it inappropriate to use:

sqlite originaldb ".dump" | sqlite backupdb


On Sun, 2005-05-01 at 00:28 +0800, Damian Slee wrote:
> hi all,
> i want to make a copy of a sqlite3 database file while it is open.  is there 
> anyway that i can tell programatically that any caches/journals are flushed 
> out? or is there any way to get and exclusive lock i guess, before making a 
> backup copy?
>
> my proposed application would have quite a few threads which may have the 
> same sqlite db open for read or write (rarer), but i dont want to shut down 
> the application to definitely know it is safe to copy.
>
>
> thanks,
>
> damian






[sqlite] backup open database

2005-04-30 Thread Damian Slee
hi all,
i want to make a copy of a sqlite3 database file while it is open.  is there 
anyway that i can tell programatically that any caches/journals are flushed 
out? or is there any way to get and exclusive lock i guess, before making a 
backup copy?
 
my proposed application would have quite a few threads which may have the same 
sqlite db open for read or write (rarer), but i dont want to shut down the 
application to definitely know it is safe to copy.
 
 
thanks,
 
damian