Re: [sqlite] db crash when creating rows

2007-11-28 Thread Joe Wilson
I compiled your program with MinGW gcc 3.4.2 on Windows with 
sqlite-amalgamation-3_5_3.zip.

  gcc -I. ged.c sqlite3.c -o ged.exe

It runs fine. If another sqlite3 process issues a query like:

  select * from test;

while ged.exe is running, then ged.exe will exit with:

  Creating 10 rows...
  died on row 2595
  SQL error 2: database is locked

So I'm wondering if another process accessed your database 
file while it was running. Or perhaps, are you running antivirus 
software on your PC?

What happens if you retry sqlite3_exec a few times after failure 
instead of exitting?  (throw in Sleep(50) after each failure for 
good measure)


--- Ged Murphy <[EMAIL PROTECTED]> wrote:

> I am doing some programmatic stress / benchmark testing on sqlite in the
> hope it'll be of use to me in my project.
> 
> I'm performing some simple stress tests to gauge read/write speeds, whereby
> I fill a table with a large amount rows
> 
> However,  I hit the following problem on writing:
> 
>   Creating 10 rows...
> 
>   died on row 1075
> 
>   SQL error 2: unable to open database fi
> 
>   Press any key to continue . . .
> 
> I'm using version 3.5.2 and my stress test code (written in C) is attached.
> 
> Does anyone have any ideas as to why it fails?



  

Get easy, one-click access to your favorites. 
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs 

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



RE: [sqlite] db crash when creating rows

2007-11-28 Thread Ged Murphy
Simon Davies wrote:

> Compiled your snippet using VS2005 on XP, sqlite 3.4.2 -
> ran to completion with no errors

Yeah, I had no errors when I ran this using the native exports from the
System.Data.SQLite.dll .NET wrapper from http://sqlite.phxsoftware.com
This also uses the 3.4.2 library.

I can only assume there's a problem with the 3.5.* lib somewhere when bulk
filling in this manner.

> PS Took nrly 2 hrs. Added "BEGIN" and "COMMIT" around insert loop,
> reduced time to 10 seconds

Yeah, it's a long way of filling but I needed to test it in this way as it'd
be filled up by single queries in the real world

Thanks,
Ged.





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



Re: [sqlite] db crash when creating rows

2007-11-28 Thread Simon Davies
Hi Ged,

Compiled your snippet using VS2005 on XP, sqlite 3.4.2 -
ran to completion with no errors

Rgds,
Simon

PS Took nrly 2 hrs. Added "BEGIN" and "COMMIT" around insert loop,
reduced time to 10 seconds

On 27/11/2007, Ged Murphy <[EMAIL PROTECTED]> wrote:
>
>
>
> Hi,
>
>
>
> I am doing some programmatic stress / benchmark testing on sqlite in the
> hope it'll be of use to me in my project.
>
> I'm performing some simple stress tests to gauge read/write speeds, whereby
> I fill a table with a large amount rows
>
> However,  I hit the following problem on writing:
>
>
>
>   Creating 10 rows...
>
>   died on row 1075
>
>   SQL error 2: unable to open database fi
>
>   Press any key to continue . . .
>
>
>
> I'm using version 3.5.2 and my stress test code (written in C) is attached.
>
> Does anyone have any ideas as to why it fails?
>
>
>
> Thanks,
>
> Ged
>
>
>
>
>
>
>
>
>
>
>
>
> -
> To unsubscribe, send email to
> [EMAIL PROTECTED]
> -
>
>

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



[sqlite] db crash when creating rows

2007-11-27 Thread Ged Murphy
Hi,

 

I am doing some programmatic stress / benchmark testing on sqlite in the
hope it'll be of use to me in my project.

I'm performing some simple stress tests to gauge read/write speeds, whereby
I fill a table with a large amount rows

However,  I hit the following problem on writing:

 

  Creating 10 rows...

  died on row 1075

  SQL error 2: unable to open database fi

  Press any key to continue . . .

 

I'm using version 3.5.2 and my stress test code (written in C) is attached.

Does anyone have any ideas as to why it fails?

 

Thanks,

Ged

 

 

 

 

 

 

#include 
#include 
#include 

#define TESTDB "C:\\Users\\Ged\\Desktop\\sqlite stuff\\benchmarking\\testdb"
#define MAX_ROWS 10

static int 
ReadCallback(void *NotUsed,
 int argc,
 char **argv,
 char **azColName)
{
/* do stuff */
return 0;
}


static BOOL
FillDatabase(sqlite3 *db)
{
INT ret, i;
char *zErrMsg = 0;
BOOL bRet = FALSE;

printf("Creating %d rows...\n", MAX_ROWS);

ret = sqlite3_exec(db,
   "CREATE TABLE test (ID integer primary key 
autoincrement, Field1 int, Field2 VARCHAR(50))",
   NULL,
   0,
   &zErrMsg);
if (ret == SQLITE_OK)
{
for (i = 0; i < MAX_ROWS; i++)
{
ret = sqlite3_exec(db,
   "INSERT INTO test(Field1, Field2) VALUES(15, 
'Hello')",
   NULL,
   0,
   &zErrMsg);
if (ret != SQLITE_OK)
{
fprintf(stderr, "died on row %d\n", i);
fprintf(stderr, "SQL error 2: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
return FALSE;
}

//Sleep(5);
}

bRet = TRUE;
}
else
{
fprintf(stderr, "SQL error 1: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}

return bRet;

}


static VOID
ReadDatabase(sqlite3 *db)
{
INT ret;
char *zErrMsg = 0;

printf("Reading %d rows...\n", MAX_ROWS);

ret = sqlite3_exec(db,
   "SELECT * FROM test",
   ReadCallback,
   0,
   &zErrMsg);
if (ret != SQLITE_OK)
{
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
}


static BOOL
OpenDatabase(sqlite3 **db)
{
INT ret;

ret = sqlite3_open(TESTDB, db);
if (ret != SQLITE_OK)
{
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(*db));
}

return (ret == SQLITE_OK);
}


static VOID
CloseDatabase(sqlite3 *db)
{
if (db)
sqlite3_close(db);
}


int main (int argc, char* argv[])
{
sqlite3 *db = NULL;
DWORD startwrite = 0, startread = 0;
DWORD endwrite = 0, endread = 0;

DeleteFileA(TESTDB);

if (OpenDatabase(&db))
{
startwrite = GetTickCount();
if (FillDatabase(db))
{
endwrite = startread = GetTickCount();
ReadDatabase(db);
endread = GetTickCount();
}

CloseDatabase(db);
}

if (endwrite)
{
INT writetime = endwrite - startwrite;

if (writetime > 1000)
{
writetime /= 1000;
if (writetime > 60)
{
int min = writetime / 60;
int sec = writetime % 60;
printf("\ncreate time - %d.%d mins\n", min, sec);
}
else
printf("\ncreate time - %d secs\n", writetime);
}
else
printf("\ncreate time - %d ms\n", writetime);


if (endread)
printf("read time - %d ms\n\n", endread - startread);
}

system("PAUSE");

return 0;
}

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