Re: [sqlite] Performance tuning for Insert and select operations

2007-08-30 Thread RaghavendraK 70574

Convert your sql to sql Statements.
run sqliteanalz and see which all columns are to be indexed.

regards
ragha
**
 This email and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!
 
*

- Original Message -
From: venkata ramana <[EMAIL PROTECTED]>
Date: Friday, August 31, 2007 9:34 am
Subject: [sqlite] Performance tuning for Insert and select operations

> Hi,
> 
> I am using SQLite 3_3_17with the default configuration of SQLite.
> Using Windows XP C++ API.
> 50,000 inserts into Table (with primary key and no other index as 
> singletransaction commit) is taking 4.609000 sec.
> 50,000 selects from Table ( having 1,00,000 rec with primary key 
> and no
> other index) , query using primary key is taking 8.751000 sec.
> I have to achieve insertion bench mark of nearly 50,000 insertions 
> in 1.5 to
> 2 sec.
> I have to achieve selection bench mark of nearly 50,000 selections 
> in 1.5 to
> 2 sec.
> Please tell me if it is possible to tune Sqlite to achieve this 
> performance.
> Regards,
> Ramana
> 
> 
>  This e-mail and attachments contain confidential information from 
> HUAWEI,which is intended only for the person or entity whose 
> address is listed
> above. Any use of the information contained herein in any way 
> (including,but not limited to, total or partial disclosure, 
> reproduction, or
> dissemination) by persons other than the intended recipient's) is
> prohibited. If you receive this e-mail in error, please notify the 
> sender by
> phone or email immediately and delete it!
> 
> 
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> 
> -
> 
> 

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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Dan Kennedy
On Thu, 2007-08-30 at 19:13 -0700, Joe Wilson wrote:
> > > > latest CVS:
> > > > 
> > > > #if SQLITE_THREADSAFE
> > > > # include 
> > > > # define SQLITE_UNIX_THREADS 1
> > > > #endif
> > > > 
> > > 
> > > I don't know where you are seeing this.  The latest is
> > > 
> > >
> > > http://www.sqlite.org/cvstrac/filediff?f=sqlite/src/sqliteInt.h=1.592=1.593
> > 
> > Look in sqlite 3.4.2 os_unix.c.
> > 
> >   http://www.sqlite.org/cvstrac/fileview?f=sqlite/src/os_unix.c=1.136
> > 
> > Before 3.5 it was the only sqlite source file where thread-safety was 
> > relevant
> > for UNIX.
> 
> I see what's going on now. I incorrectly assumed that both configure 
> builds and the amalgamation were both threadsafe by default in the 
> 3.4.x sources. 
> 
> It appears that a default ./configure without options for both 3.4.x 
> and the new 3.5 sources will result in a non-threadsafe build. This 
> has always been the case, since configure explicitly defines 
> -DTHREADSAFE=0 in the Makefile.

It's an ongoing problem that the configure script is a bit of
a second-class citizen. It's not convenient to develop with,
so people working on the sqlite code don't use it.

Dan.


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



[sqlite] Performance tuning for Insert and select operations

2007-08-30 Thread venkata ramana
Hi,

I am using SQLite 3_3_17with the default configuration of SQLite.
Using Windows XP C++ API.
50,000 inserts into Table (with primary key and no other index as single
transaction commit) is taking 4.609000 sec.
50,000 selects from Table ( having 1,00,000 rec with primary key and no
other index) , query using primary key is taking 8.751000 sec.
I have to achieve insertion bench mark of nearly 50,000 insertions in 1.5 to
2 sec.
I have to achieve selection bench mark of nearly 50,000 selections in 1.5 to
2 sec.
Please tell me if it is possible to tune Sqlite to achieve this performance.

Regards,
Ramana


 This e-mail and attachments contain confidential information from HUAWEI,
which is intended only for the person or entity whose address is listed
above. Any use of the information contained herein in any way (including,
but not limited to, total or partial disclosure, reproduction, or
dissemination) by persons other than the intended recipient's) is
prohibited. If you receive this e-mail in error, please notify the sender by
phone or email immediately and delete it!



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



Re: [sqlite] Table locked - why?

2007-08-30 Thread Dan Kennedy
On Fri, 2007-08-31 at 00:09 +0200, Yves Goergen wrote:
> On 30.08.2007 22:55 CE(S)T, Ken wrote:
> > BEGIN TRANSACTION;
> > CREATE TEMPORARY TABLE attached_db.temp_table (...);
> > INSERT INTO attached_db.temp_table SELECT * FROM attached_db.table1;
> > 
> > /* Add a comit */
> > COMMIT;  
> 
> Error: cannot commit transaction - SQL statements in progress

That error indicates that there are statements that have been
run (had sqlite3_step() called) but not finalized/reset (had
sqlite3_finalize() or sqlite3_reset() called). You need to 
finalize or reset all statements generated by the database
handle.

> CREATE TEMPORARY TABLE attached_db.temp_table 

I'm not sure where that table is created - in the temporary
namespace or as part of attached_db. Checking...

  SQLite version 3.4.2
  Enter ".help" for instructions
  sqlite> attach 'def' as def;
  sqlite> create temporary table def.t1(a, b, c);
  SQL error: temporary table name must be unqualified

Huh. Maybe that's the root of your problem there.

Dan.


> 
> > DROP TABLE attached_db.table1;  -- Error: Table is locked
> 


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



Re: [sqlite] command

2007-08-30 Thread nishit sharma
using UODATE command its working.
thanks for the help

regards
Nishit


On 8/30/07, Jim Dodgen <[EMAIL PROTECTED]> wrote:
>
> Also I recommend you get a very basic SQL database book.
>
>
> Quoting John Stanton <[EMAIL PROTECTED]>:
>
> > nishit sharma wrote:
> > > i have given some text in a database file as
> > > America|england|   and many more.
> > > now i want to replace some text with new text how
> > > this is possible. Also my database has around 15 rows now
> > > which will be incremented.
> > >
> > > so, plz anyone tell me how to replace a text in a row and
> > > how to delete a particular row.
> > >
> > > waiting for response
> > >
> > > regads
> > > Nishit
> > >
> > How about UPDATE?
> >
> >
> -
> > To unsubscribe, send email to [EMAIL PROTECTED]
> >
> -
> >
> >
>
>
>
>
>
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Joe Wilson
> > > latest CVS:
> > > 
> > > #if SQLITE_THREADSAFE
> > > # include 
> > > # define SQLITE_UNIX_THREADS 1
> > > #endif
> > > 
> > 
> > I don't know where you are seeing this.  The latest is
> > 
> >
> > http://www.sqlite.org/cvstrac/filediff?f=sqlite/src/sqliteInt.h=1.592=1.593
> 
> Look in sqlite 3.4.2 os_unix.c.
> 
>   http://www.sqlite.org/cvstrac/fileview?f=sqlite/src/os_unix.c=1.136
> 
> Before 3.5 it was the only sqlite source file where thread-safety was relevant
> for UNIX.

I see what's going on now. I incorrectly assumed that both configure 
builds and the amalgamation were both threadsafe by default in the 
3.4.x sources. 

It appears that a default ./configure without options for both 3.4.x 
and the new 3.5 sources will result in a non-threadsafe build. This 
has always been the case, since configure explicitly defines 
-DTHREADSAFE=0 in the Makefile.

The sqlite3.c amalgamation, on the other hand, with no compile flags
does result in a threadsafe build for both 3.4.x and 3.5.

So the "threadsafe by default" cvs log comment in os_unix.c has to be
taken in context.



  

Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel 
and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 


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



[sqlite] Sqlite Prepare Statement

2007-08-30 Thread RaghavendraK 70574
Hi,

Do we have tool(similar to Sqlite3) by which Prepare statement can be tested as 
easily as normal sql ?
As most of the time we have use Prepare statement hence we need a RAD tool
to verify it.This will be useful to the Sqlite grp.Share your opinion.

Or if any have an idea how to do it,let me know i will make the changes
and submit to Group owner.

regards
ragha

**
 This email and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!
 
*
Dan Source code is attached. I didn't write this, someone else from the forum 
did their name is not on it, nor coppyrighted.. I thought it was a clean way to 
test threading.

Interestingly if you remove out the shared cache everything runs to completion.



Dan Kennedy <[EMAIL PROTECTED]> wrote: 
Hi Ken,

Probably a bug in the new threading stuff. Can you share
source code for this test or is it part of some large app?

Either way, thanks for the report.

Dan.

On Wed, 2007-08-29 at 22:15 -0700, Ken wrote:
> Also erros out here, sporadically.
> int sqlite3OsWrite(sqlite3_file *id, const void *pBuf, int amt, i64 offset){
>   return id->pMethods->xWrite(id, pBuf, amt, offset);
> }
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1075841376 (LWP 15747)]
> 0x0040c413 in sqlite3OsWrite (id=0x55aaa0, pBuf=0x401ffc30, amt=24, 
> offset=0) at os.c:38
> (gdb) Quit
> (gdb) 
> 
> Ken  wrote: 4 threads, shared_Cache enabled
> LOOP 100 
> BEGIN
>  LOOP 50 times
>   INSERT
>  end LOOP
>  COMMIT
> 
>   SELECT COUNT(*) ...
> end LOOP
> 
> 
> program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1080043872 (LWP 15448)]
> moveToChild (pCur=0x569058, newPgno=) at btree.c:3304
> (gdb) 
> 
> 
> if( rc ) return rc;
>   pNewPage->idxParent = pCur->idx;
>   pOldPage = pCur->pPage;
>   pOldPage->idxShift = 0; < Error Here
>   releasePage(pOldPage);
>   pCur->pPage = pNewPage;
>   pCur->idx = 0;
>   pCur->info.nSize = 0;
> 
> 
> Ken
> 
> 
> 
> 
> Ken  wrote: 4 threads, shared_Cache enabled
> LOOP 100 
> BEGIN
>  LOOP 50 times
>   INSERT
>  end LOOP
>  COMMIT
> 
>   SELECT COUNT(*) ...
> end LOOP
> 
> 
> program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1080043872 (LWP 15448)]
> moveToChild (pCur=0x569058, newPgno=) at btree.c:3304
> (gdb) 
> 
> 
> if( rc ) return rc;
>   pNewPage->idxParent = pCur->idx;
>   pOldPage = pCur->pPage;
>   pOldPage->idxShift = 0; < Error Here
>   releasePage(pOldPage);
>   pCur->pPage = pNewPage;
>   pCur->idx = 0;
>   pCur->info.nSize = 0;
> 
> 
> Ken
> 
> 


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


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

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

Re: [sqlite] sqlite3 Database Pointer multithreading / concurrency

2007-08-30 Thread Ben Mann
>
> What you described about the locking is correct.  The threading isn't
> strictly relevant; locking is done on a per-connection basis, not
> per-thread.
>

Yes, I think this was what was missed in our application's original
implementation; it was not fully appreciated that locking was
per-connection as opposed to per-thread. Explains a lot of interesting
issues!

This certainly gives the green light to go ahead with a fix. Thanks
for the help.

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



RE: [sqlite] Table locked - why?

2007-08-30 Thread Virgilio Alexandre Fornazin
Did you closed the cursor opened at 'select *...' ?
Thats probably the reason you have getting a 'table is locked' error.

-Original Message-
From: RaghavendraK 70574 [mailto:[EMAIL PROTECTED] 
Sent: quinta-feira, 30 de agosto de 2007 19:24
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Table locked - why?


Pls see if u hv an open sqlite3 terminal.sometimes this can also cause a
prob with begin tx and just kept it open.

regrads
ragha

**
 This email and its attachments contain confidential information from
HUAWEI, which is intended only for the person or entity whose address is
listed above. Any use of the information contained herein in any way
(including, but not limited to, total or partial disclosure, reproduction,
or dissemination) by persons other than the intended recipient(s) is
prohibited. If you receive this e-mail in error, please notify the sender by
phone or email immediately and delete it!
 

*

- Original Message -
From: Yves Goergen <[EMAIL PROTECTED]>
Date: Friday, August 31, 2007 3:41 am
Subject: Re: [sqlite] Table locked - why?

> On 30.08.2007 23:00 CE(S)T, [EMAIL PROTECTED] wrote:
> > Probably another thread or process is reading from the database
> > and does not want you to drop the table out from under it.
> 
> Surely not. This database is there for testing and development 
> purposesonly and my application is the only one that opens it. It 
> doesn't use
> multiple threads so there also can't be another thread locking it.
> 
> -- 
> Yves Goergen "LonelyPixel" <[EMAIL PROTECTED]>
> Visit my web laboratory at http://beta.unclassified.de
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> 
> -
> 
> 


-
To unsubscribe, send email to [EMAIL PROTECTED]

-


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



Re: [sqlite] Table locked - why?

2007-08-30 Thread RaghavendraK 70574

Pls see if u hv an open sqlite3 terminal.sometimes this can also cause a  prob 
with begin tx and just kept it open.

regrads
ragha
**
 This email and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!
 
*

- Original Message -
From: Yves Goergen <[EMAIL PROTECTED]>
Date: Friday, August 31, 2007 3:41 am
Subject: Re: [sqlite] Table locked - why?

> On 30.08.2007 23:00 CE(S)T, [EMAIL PROTECTED] wrote:
> > Probably another thread or process is reading from the database
> > and does not want you to drop the table out from under it.
> 
> Surely not. This database is there for testing and development 
> purposesonly and my application is the only one that opens it. It 
> doesn't use
> multiple threads so there also can't be another thread locking it.
> 
> -- 
> Yves Goergen "LonelyPixel" <[EMAIL PROTECTED]>
> Visit my web laboratory at http://beta.unclassified.de
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> 
> -
> 
> 

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



Re: [sqlite] Table locked - why?

2007-08-30 Thread Yves Goergen
On 30.08.2007 23:00 CE(S)T, [EMAIL PROTECTED] wrote:
> Probably another thread or process is reading from the database
> and does not want you to drop the table out from under it.

Surely not. This database is there for testing and development purposes
only and my application is the only one that opens it. It doesn't use
multiple threads so there also can't be another thread locking it.

-- 
Yves Goergen "LonelyPixel" <[EMAIL PROTECTED]>
Visit my web laboratory at http://beta.unclassified.de

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



Re: [sqlite] Table locked - why?

2007-08-30 Thread Yves Goergen
On 30.08.2007 22:55 CE(S)T, Ken wrote:
> BEGIN TRANSACTION;
> CREATE TEMPORARY TABLE attached_db.temp_table (...);
> INSERT INTO attached_db.temp_table SELECT * FROM attached_db.table1;
> 
> /* Add a comit */
> COMMIT;  

Error: cannot commit transaction - SQL statements in progress

> DROP TABLE attached_db.table1;  -- Error: Table is locked

-- 
Yves Goergen "LonelyPixel" <[EMAIL PROTECTED]>
Visit my web laboratory at http://beta.unclassified.de

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



Re: [sqlite] Table locked - why?

2007-08-30 Thread drh
Yves Goergen <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I want to modify the structure of a table, particularly remove a column.
> Since SQLite won't help me with that, I'll need to go the hard way by
> copying all data to a temp table, then re-creating the table with the
> new structure and copying all remaining data back.
> 
> This works fine with a table from a regular database. But it fails when
> doing it with a table from an attached database. After backing up all
> data, when dropping the original table, I get an exception that says
> that the table which I want to drop is locked. Why that? Is there a
> difference when the table is from an attached database?
> 

Probably another thread or process is reading from the database
and does not want you to drop the table out from under it.


> Here's what I did:
> 
> BEGIN TRANSACTION;
> CREATE TEMPORARY TABLE attached_db.temp_table (...);
> INSERT INTO attached_db.temp_table SELECT * FROM attached_db.table1;
> DROP TABLE attached_db.table1;  -- Error: Table is locked
> 
> Using SQLite 3.4.1 with the .NET wrapper in VS2005.
> 
> -- 
> Yves Goergen "LonelyPixel" <[EMAIL PROTECTED]>
> Visit my web laboratory at http://beta.unclassified.de
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
> 
> 
> .



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



Re: [sqlite] Table locked - why?

2007-08-30 Thread Ken
BEGIN TRANSACTION;
CREATE TEMPORARY TABLE attached_db.temp_table (...);
INSERT INTO attached_db.temp_table SELECT * FROM attached_db.table1;

/* Add a comit */
COMMIT;  


DROP TABLE attached_db.table1;  -- Error: Table is locked

Yves Goergen <[EMAIL PROTECTED]> wrote: Hi,

I want to modify the structure of a table, particularly remove a column.
Since SQLite won't help me with that, I'll need to go the hard way by
copying all data to a temp table, then re-creating the table with the
new structure and copying all remaining data back.

This works fine with a table from a regular database. But it fails when
doing it with a table from an attached database. After backing up all
data, when dropping the original table, I get an exception that says
that the table which I want to drop is locked. Why that? Is there a
difference when the table is from an attached database?

Here's what I did:

BEGIN TRANSACTION;
CREATE TEMPORARY TABLE attached_db.temp_table (...);
INSERT INTO attached_db.temp_table SELECT * FROM attached_db.table1;
DROP TABLE attached_db.table1;  -- Error: Table is locked

Using SQLite 3.4.1 with the .NET wrapper in VS2005.

-- 
Yves Goergen "LonelyPixel" 
Visit my web laboratory at http://beta.unclassified.de

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




Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Joe Wilson
--- [EMAIL PROTECTED] wrote:
> This problem will likely come up again.  To try and work
> around it, I have added a new (experimental) API to the
> latest version in CVS.  Call
> 
> sqlite3_threadsafe()
> 
> To get back a boolean to indicate whether or not your
> build is threadsafe.

Could you also make an accompanying SQLite SQL function of the same name?

Many SQLite wrapper users (Java, PHP, whatever) have no knowledge of C
or how their drivers are built and it would be useful for diagnosing 
problems via SQL only.



   

Got a little couch potato? 
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail=summer+activities+for+kids=bz
 

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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Joe Wilson
--- [EMAIL PROTECTED] wrote:
> Ken <[EMAIL PROTECTED]> wrote:
> > Recompiled with:
> > gcc -DSQLITE_THREADSAFE -I. -I../src 
> ^^^
> 
> Should be -DSQLITE_THREADSAFE=1
> 
> The =1 is important in this case.

-DSQLITE_THREADSAFE is equivalent to -DSQLITE_THREADSAFE=1

$ cat t.c
#include 
main() { printf("SQLITE_THREADSAFE = %d\n", SQLITE_THREADSAFE); }

$ gcc -DSQLITE_THREADSAFE t.c
$ ./a.out
SQLITE_THREADSAFE = 1

$ gcc -DSQLITE_THREADSAFE=0 t.c
$ ./a.out
SQLITE_THREADSAFE = 0



   

Be a better Globetrotter. Get better travel answers from someone who knows. 
Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list=396545469

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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread drh
[EMAIL PROTECTED] wrote:
> Ken <[EMAIL PROTECTED]> wrote:
> > Recompiled with:
> > gcc -DSQLITE_THREADSAFE -I. -I../src 
> ^^^
> 
> Should be -DSQLITE_THREADSAFE=1
> 
> The =1 is important in this case.
> 

This problem will likely come up again.  To try and work
around it, I have added a new (experimental) API to the
latest version in CVS.  Call

sqlite3_threadsafe()

To get back a boolean to indicate whether or not your
build is threadsafe.

May I suggest adding a call to this routine at the
beginning of sqlitetest_thrd35.c and printing and error
message and aborting if the library is not threadsafe?

--
D. Richard Hipp <[EMAIL PROTECTED]>


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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread drh
Ken <[EMAIL PROTECTED]> wrote:
> Recompiled with:
> gcc -DSQLITE_THREADSAFE -I. -I../src 
^^^

Should be -DSQLITE_THREADSAFE=1

The =1 is important in this case.

--
D. Richard Hipp <[EMAIL PROTECTED]>


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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Ken
And the sqliteInt.h file is id as:

** @(#) $Id: sqliteInt.h,v 1.605 2007/08/29 12:31:28 danielk1977 Exp $

Let me know if you need anything else..

Thanks,
Ken


[EMAIL PROTECTED] wrote: Joe Wilson  wrote:
> 
> latest CVS:
> 
> #if SQLITE_THREADSAFE
> # include 

> # define SQLITE_UNIX_THREADS 1
> #endif
> 

I don't know where you are seeing this.  The latest is

   
http://www.sqlite.org/cvstrac/filediff?f=sqlite/src/sqliteInt.h=1.592=1.593

--
D. Richard Hipp 


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






[EMAIL PROTECTED] wrote: Joe Wilson  wrote:
> 
> latest CVS:
> 
> #if SQLITE_THREADSAFE
> # include 

> # define SQLITE_UNIX_THREADS 1
> #endif
> 

I don't know where you are seeing this.  The latest is

   
http://www.sqlite.org/cvstrac/filediff?f=sqlite/src/sqliteInt.h=1.592=1.593

--
D. Richard Hipp 


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




[EMAIL PROTECTED] wrote: Joe Wilson  wrote:
> 
> latest CVS:
> 
> #if SQLITE_THREADSAFE
> # include 

> # define SQLITE_UNIX_THREADS 1
> #endif
> 

I don't know where you are seeing this.  The latest is

   
http://www.sqlite.org/cvstrac/filediff?f=sqlite/src/sqliteInt.h=1.592=1.593

--
D. Richard Hipp 


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





Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Ken
Recompiled with:
gcc -DSQLITE_THREADSAFE -I. -I../src -DSQLITE_DEBUG=1   -DTHREADSAFE=1 
-DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1  
-DHAVE_READLINE=1 

Ran code (hardware is a dual core x86_64 amd cpu).

sqlitetest_thrd35: ../src/btree.c:1816: sqlite3BtreeBeginTrans: Assertion 
`p->pBt->inTransaction>=p->inTrans' failed.
Aborted

Btree.c id: $Id: btree.c,v 1.420 2007/08/30 01:19:59 drh Exp $





[EMAIL PROTECTED] wrote: Joe Wilson  wrote:
> Compiled without -DSQLITE_DEBUG=1 which presumably changes the timing.
> 
> cvs up -A
> make distclean
> # thrd35.c = http://marc.info/?l=sqlite-users=118848741522192=2
> cp thrd35.c src/shell.c
> ../configure --disable-shared && make LIBPTHREAD=-lpthread sqlite3
> ../sqlite3
> valgrind -v ./sqlite3 2>&1 | tee v.log
> 

I can reproduce this problem only when I compile
with -DSQLITE_THREADSAFE=0.  In other words, if I
disable the mutexes completely, so that no mutex
is ever called (the mutexing routines are all no-ops)
then I can reproduce the problem.

Amazingly enough, the test program works OK most of
the time even with mutexes all disabled.  But every 
now and then I get the segfault.

It's a weak thread-test that works OK must of the
time with mutexes disabled.  :-)   Or perhaps it is
a very robust database engine  ;-)

Please recompile with -DSQLITE_THREADSAFE=1 and let me
know if you are still having problems.  I thought that
SQLITE_THREADSAFE=1 was the default, but I could be
mistaken.  Are you using the configure script?

--
D. Richard Hipp 



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




[EMAIL PROTECTED] wrote: Joe Wilson  wrote:
> Compiled without -DSQLITE_DEBUG=1 which presumably changes the timing.
> 
> cvs up -A
> make distclean
> # thrd35.c = http://marc.info/?l=sqlite-users=118848741522192=2
> cp thrd35.c src/shell.c
> ../configure --disable-shared && make LIBPTHREAD=-lpthread sqlite3
> ../sqlite3
> valgrind -v ./sqlite3 2>&1 | tee v.log
> 

I can reproduce this problem only when I compile
with -DSQLITE_THREADSAFE=0.  In other words, if I
disable the mutexes completely, so that no mutex
is ever called (the mutexing routines are all no-ops)
then I can reproduce the problem.

Amazingly enough, the test program works OK most of
the time even with mutexes all disabled.  But every 
now and then I get the segfault.

It's a weak thread-test that works OK must of the
time with mutexes disabled.  :-)   Or perhaps it is
a very robust database engine  ;-)

Please recompile with -DSQLITE_THREADSAFE=1 and let me
know if you are still having problems.  I thought that
SQLITE_THREADSAFE=1 was the default, but I could be
mistaken.  Are you using the configure script?

--
D. Richard Hipp 



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




Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Ken

** $Id: btree.c,v 1.420 2007/08/30 01:19:59 drh Exp $

Compilation:
../configure --enable-threadsafe  --disable-tcl --enable-tempstore 
make 
 gcc -g -O2 -I. -I../src -DNDEBUG -DTHREADSAFE=1 
-DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -c 
../src/alter.c -o alter.o >/dev/null 2>&1


--So this is a  configure or makefile issue? Since DTHREADSAFE should be 
SQLITE_THREADSAFE ... 

I'll set the CFLAGS to set up SQLITE_THREADSAFE




[EMAIL PROTECTED] wrote: Joe Wilson  wrote:
> I also see random crashes with sources from CVS as of 
> Thu Aug 30 12:20:43 EDT 2007 using Ken's program below.
> 
>   http://marc.info/?l=sqlite-users=118848741522192=2
> 
> It's timing dependent.
> On a single core Pentium4 machine it crashes once in 10 runs.
> 

Compiled with or without -DSQLITE_DEBUG=1?  We have a bazillion
assert()s in place that are suppose to catch this kind of thing.
I'm wondering if the problem slipped through, or if you have
the assert()s turned off.  (Assert()s in SQLite are off by default.
You have to turn them on explicitly using -DSQLITE_DEBUG=1.)

--
D. Richard Hipp 


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




[EMAIL PROTECTED] wrote: Joe Wilson  wrote:
> I also see random crashes with sources from CVS as of 
> Thu Aug 30 12:20:43 EDT 2007 using Ken's program below.
> 
>   http://marc.info/?l=sqlite-users=118848741522192=2
> 
> It's timing dependent.
> On a single core Pentium4 machine it crashes once in 10 runs.
> 

Compiled with or without -DSQLITE_DEBUG=1?  We have a bazillion
assert()s in place that are suppose to catch this kind of thing.
I'm wondering if the problem slipped through, or if you have
the assert()s turned off.  (Assert()s in SQLite are off by default.
You have to turn them on explicitly using -DSQLITE_DEBUG=1.)

--
D. Richard Hipp 


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




Re: [sqlite] How to generate Unique ID?

2007-08-30 Thread Gerhard Haering





On Thu, 30 Aug 2007 13:06:38 +0100, "Simon Davies" <[EMAIL PROTECTED]> wrote:

> On 30/08/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote:

>> Simon,

>>Yeah you can term the problem like that. Can't I use the

>> function which is assigning a unique id for INTEGER PRIMARY KEY column

>> inside sql? If yes, how to use it?

>>

>> Regards,

>> Phani

>>

> 

> Phani,

> 

> With the whole of the sqlite codebase available you are free to use

> any of it as you wish ;-)

> But what you are suggesting above is not an approach that I would

> choose to get involved with. (I don't know how sqlite assigns its

> unique ids for INTEGER PRIMARY KEY columns, but I would be surprised

> if it caters for specific subranges).



I recently produced sample code that gets id ranges. I once did something 
similar with Oracle SEQUENCEs, and my sample code emulates sequences as good as 
it can. It's a rough sketch, and could most probably be improved upon:



http://initd.org/tracker/pysqlite/wiki/IdRange



import sqlite3 as sqlite

import os



def init_tables(con):

for row in con.execute("select name from sqlite_master where type='table' 
and name not like 'sqlite%'"):

column = None

for r in con.execute("pragma table_info (%s)" % row[0]):

if r[-1] == 0:

column = r[1]

break

con.execute("insert into %s(%s) values ('xx')" % (row[0], column))

con.execute("delete from %s" % row[0])



def get_id_range(con, table, n):

isolation_level = con.isolation_level

start, end = None, None

try:

con.isolation_level = None

con.execute("BEGIN EXCLUSIVE")

start = con.execute("SELECT SEQ FROM SQLITE_SEQUENCE WHERE NAME=?", 
(table,)).fetchone()[0]

end = start + n - 1

con.execute("UPDATE SQLITE_SEQUENCE SET SEQ=? WHERE NAME=?", (end, 
table))

con.execute("COMMIT")

finally:

con.isolation_level = isolation_level

return start, end



con = sqlite.connect(":memory:")

con.execute("create table test(id integer primary key autoincrement, name 
text)")

init_tables(con)

print get_id_range(con, "test", 1000)

print get_id_range(con, "test", 1000)

print get_id_range(con, "test", 1000)

con.execute("insert into test(name) values ('foo')")

con.execute("insert into test(name) values ('foo')")

con.execute("insert into test(name) values ('foo')")

print con.execute("select * from test").fetchall()



-- Gerhard


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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Joe Wilson
--- [EMAIL PROTECTED] wrote:
> Amazingly enough, the test program works OK most of
> the time even with mutexes all disabled.  But every 
> now and then I get the segfault.
> 
> It's a weak thread-test that works OK must of the
> time with mutexes disabled.  :-)   Or perhaps it is
> a very robust database engine  ;-)

Uniprocessors, like the machine I was using, are notoriously bad 
test platforms for multi-threaded code. You really need SMP machines 
to thoroughly exercise multi-threaded logic. The more cores the
better.



   

Be a better Heartthrob. Get better relationship answers from someone who knows. 
Yahoo! Answers - Check it out. 
http://answers.yahoo.com/dir/?link=list=396545433

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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Joe Wilson
--- [EMAIL PROTECTED] wrote:
> Joe Wilson <[EMAIL PROTECTED]> wrote:
> > 
> > latest CVS:
> > 
> > #if SQLITE_THREADSAFE
> > # include 
> > # define SQLITE_UNIX_THREADS 1
> > #endif
> > 
> 
> I don't know where you are seeing this.  The latest is
> 
>
> http://www.sqlite.org/cvstrac/filediff?f=sqlite/src/sqliteInt.h=1.592=1.593

Look in sqlite 3.4.2 os_unix.c.

  http://www.sqlite.org/cvstrac/fileview?f=sqlite/src/os_unix.c=1.136

Before 3.5 it was the only sqlite source file where thread-safety was relevant
for UNIX.

sqlite-3.4.1$ grep -nl THREADS src/*.c
src/os_os2.c
src/os_unix.c
src/os_win.c
src/test1.c
src/test4.c
src/test7.c
src/test_async.c
src/test_config.c
src/test_server.c



   

Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for 
today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow  

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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread drh
Joe Wilson <[EMAIL PROTECTED]> wrote:
> 
> latest CVS:
> 
> #if SQLITE_THREADSAFE
> # include 
> # define SQLITE_UNIX_THREADS 1
> #endif
> 

I don't know where you are seeing this.  The latest is

   
http://www.sqlite.org/cvstrac/filediff?f=sqlite/src/sqliteInt.h=1.592=1.593

--
D. Richard Hipp <[EMAIL PROTECTED]>


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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Joe Wilson
--- Joe Wilson <[EMAIL PROTECTED]> wrote:
> I thought there was a checkin a few months ago that made sqlite3 
> threadsafe by default.
> 
>   os_unix.c
>   revision 1.128
>   date: 2007/04/01 18:46:19;  author: drh;  state: Exp;  lines: +4 -1
>   Make unix builds threadsafe by default.
> 
> I guess this is no longer the case?

Okay, it appears that this is new to 3.5. 
THREADSAFE is no longer the default since thread safety is no longer
confined to just os_unix.c.

sqlite 3.4.1:

#ifndef THREADSAFE
# define THREADSAFE 1
#endif
#if THREADSAFE
# include 
# define SQLITE_UNIX_THREADS 1
#endif


latest CVS:

#if SQLITE_THREADSAFE
# include 
# define SQLITE_UNIX_THREADS 1
#endif



   

Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, 
photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC

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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Joe Wilson
--- Dan Kennedy <[EMAIL PROTECTED]> wrote:
> On Thu, 2007-08-30 at 10:13 -0700, Joe Wilson wrote:
> > Compiled without -DSQLITE_DEBUG=1 which presumably changes the timing.
> > 
> > cvs up -A
> > make distclean
> > # thrd35.c = http://marc.info/?l=sqlite-users=118848741522192=2
> > cp thrd35.c src/shell.c
> > ./configure --disable-shared && make LIBPTHREAD=-lpthread sqlite3
> > ./sqlite3
> > valgrind -v ./sqlite3 2>&1 | tee v.log
> 
> Try adding --enable-threadsafe to the configure command. Does the
> valgrind log look any better after doing so?

That explains it. I'm surprised I missed that.

I thought there was a checkin a few months ago that made sqlite3 
threadsafe by default.

  os_unix.c
  revision 1.128
  date: 2007/04/01 18:46:19;  author: drh;  state: Exp;  lines: +4 -1
  Make unix builds threadsafe by default.

I guess this is no longer the case?


   

Be a better Globetrotter. Get better travel answers from someone who knows. 
Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list=396545469

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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread drh
Joe Wilson <[EMAIL PROTECTED]> wrote:
> Compiled without -DSQLITE_DEBUG=1 which presumably changes the timing.
> 
> cvs up -A
> make distclean
> # thrd35.c = http://marc.info/?l=sqlite-users=118848741522192=2
> cp thrd35.c src/shell.c
> ../configure --disable-shared && make LIBPTHREAD=-lpthread sqlite3
> ../sqlite3
> valgrind -v ./sqlite3 2>&1 | tee v.log
> 

I can reproduce this problem only when I compile
with -DSQLITE_THREADSAFE=0.  In other words, if I
disable the mutexes completely, so that no mutex
is ever called (the mutexing routines are all no-ops)
then I can reproduce the problem.

Amazingly enough, the test program works OK most of
the time even with mutexes all disabled.  But every 
now and then I get the segfault.

It's a weak thread-test that works OK must of the
time with mutexes disabled.  :-)   Or perhaps it is
a very robust database engine  ;-)

Please recompile with -DSQLITE_THREADSAFE=1 and let me
know if you are still having problems.  I thought that
SQLITE_THREADSAFE=1 was the default, but I could be
mistaken.  Are you using the configure script?

--
D. Richard Hipp <[EMAIL PROTECTED]>



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



[sqlite] rowid versus docid for fts3.

2007-08-30 Thread Scott Hess
ext/fts3.c in the current code fixes the fts2-vs-vacuum problem by
adding "docid INTEGER PRIMARY KEY" to the %_content table.  This
becomes an alias for rowid, and thus causes vacuum to not renumber
rowids.  It is safe to add that column because the other columns in
%_content are constructed such that even the following:

CREATE VIRTUAL TABLE t USING fts3(docid);

will work fine.

I'm considering whether I should take it one step further, and make
docid a reserved column name for fts3 tables.  My rational is that
fts3 rowids are not quite the same as the rowids of regular tables -
in fact, some use-cases would encourage users of fts3 to use rowids in
exactly the way that fts2 was inappropriately using them!

docid would be a hidden column, like rowid.  That means that you'll
only see the column in SELECT and INSERT statements if you explicitly
reference it.  It would operate WRT rowid exactly as an INTEGER
PRIMARY KEY column would.

Opinions?

-scott

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



Re: [sqlite] multithreaded testfixture?

2007-08-30 Thread drh
Joe Wilson <[EMAIL PROTECTED]> wrote:
> Is it feasible to change testfixture in such a way to run the same tests
> in N seperate threads at the same time? This could potentially expose
> a lot of thread-related bugs.

No, this is not really feasible.

> 
> Among other things, you'd have to change some low level sqlite open() 
> calls to use a different directory for databases for each thread to avoid 
> conflict, I imagine.

Yes.  That is what you would have to do.

> 
> Is Tcl threadsafe?
> 

It can be, depending on compile-time options.

We already have some threading tests in the test suite.
We are working on adding many more.

--
D. Richard Hipp <[EMAIL PROTECTED]>


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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Dan Kennedy
On Thu, 2007-08-30 at 10:13 -0700, Joe Wilson wrote:
> Compiled without -DSQLITE_DEBUG=1 which presumably changes the timing.
> 
> cvs up -A
> make distclean
> # thrd35.c = http://marc.info/?l=sqlite-users=118848741522192=2
> cp thrd35.c src/shell.c
> ./configure --disable-shared && make LIBPTHREAD=-lpthread sqlite3
> ./sqlite3
> valgrind -v ./sqlite3 2>&1 | tee v.log

Try adding --enable-threadsafe to the configure command. Does the
valgrind log look any better after doing so?

Dan.



> 
> --- [EMAIL PROTECTED] wrote:
> > Compiled with or without -DSQLITE_DEBUG=1?  We have a bazillion
> > assert()s in place that are suppose to catch this kind of thing.
> 
> 
> 
> 
>   
> 
> Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel 
> and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
> 


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



Re: [sqlite] multithreaded testfixture?

2007-08-30 Thread Joe Wilson
Upon further thought, such a scheme would not exercise concurrent access
to the same database files, so it would not exercise the shared cache code.

--- Joe Wilson <[EMAIL PROTECTED]> wrote:
> Is it feasible to change testfixture in such a way to run the same tests
> in N seperate threads at the same time? This could potentially expose
> a lot of thread-related bugs.



  

Shape Yahoo! in your own image.  Join our Network Research Panel today!   
http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 



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



[sqlite] multithreaded testfixture?

2007-08-30 Thread Joe Wilson
Is it feasible to change testfixture in such a way to run the same tests
in N seperate threads at the same time? This could potentially expose
a lot of thread-related bugs.

Among other things, you'd have to change some low level sqlite open() 
calls to use a different directory for databases for each thread to avoid 
conflict, I imagine.

Is Tcl threadsafe?


   

Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC

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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Joe Wilson
Compiled without -DSQLITE_DEBUG=1 which presumably changes the timing.

cvs up -A
make distclean
# thrd35.c = http://marc.info/?l=sqlite-users=118848741522192=2
cp thrd35.c src/shell.c
./configure --disable-shared && make LIBPTHREAD=-lpthread sqlite3
./sqlite3
valgrind -v ./sqlite3 2>&1 | tee v.log

--- [EMAIL PROTECTED] wrote:
> Compiled with or without -DSQLITE_DEBUG=1?  We have a bazillion
> assert()s in place that are suppose to catch this kind of thing.




  

Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel 
and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 


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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread drh
Joe Wilson <[EMAIL PROTECTED]> wrote:
> I also see random crashes with sources from CVS as of 
> Thu Aug 30 12:20:43 EDT 2007 using Ken's program below.
> 
>   http://marc.info/?l=sqlite-users=118848741522192=2
> 
> It's timing dependent.
> On a single core Pentium4 machine it crashes once in 10 runs.
> 

Compiled with or without -DSQLITE_DEBUG=1?  We have a bazillion
assert()s in place that are suppose to catch this kind of thing.
I'm wondering if the problem slipped through, or if you have
the assert()s turned off.  (Assert()s in SQLite are off by default.
You have to turn them on explicitly using -DSQLITE_DEBUG=1.)

--
D. Richard Hipp <[EMAIL PROTECTED]>


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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Joe Wilson
Another unique valgrind stack trace.

http://marc.info/?l=sqlite-users=118848741522192=2

==14918== Thread 2:
==14918== Invalid read of size 4
==14918==at 0x80534F9: sqlite3OsWrite (os.c:38)
==14918==by 0x8056C06: syncJournal (pager.c:2765)
==14918==by 0x80581A8: sqlite3PagerCommitPhaseOne (pager.c:4461)
==14918==by 0x8050731: sqlite3BtreeCommitPhaseOne (btree.c:2315)
==14918==by 0x805DBC2: sqlite3VdbeHalt (vdbeaux.c:1131)
==14918==by 0x80815E6: sqlite3VdbeExec (vdbe.c:2465)
==14918==by 0x805C209: sqlite3_step (vdbeapi.c:328)
==14918==by 0x8060951: sqlite3_exec (legacy.c:77)
==14918==by 0x8048FD9: sqlite3_execute (thrd35.c:122)
==14918==by 0x80495DD: testthread (thrd35.c:261)
==14918==by 0x403A561: start_thread (in /lib/i686/libpthread-2.4.so)
==14918==by 0x418D4DD: clone (in /lib/i686/libc-2.4.so)
==14918==  Address 0xC is not stack'd, malloc'd or (recently) free'd
==14918==
==14918== Process terminating with default action of signal 11 (SIGSEGV)
==14918==  Access not within mapped region at address 0xC
==14918==at 0x80534F9: sqlite3OsWrite (os.c:38)
==14918==by 0x8056C06: syncJournal (pager.c:2765)
==14918==by 0x80581A8: sqlite3PagerCommitPhaseOne (pager.c:4461)
==14918==by 0x8050731: sqlite3BtreeCommitPhaseOne (btree.c:2315)
==14918==by 0x805DBC2: sqlite3VdbeHalt (vdbeaux.c:1131)
==14918==by 0x80815E6: sqlite3VdbeExec (vdbe.c:2465)
==14918==by 0x805C209: sqlite3_step (vdbeapi.c:328)
==14918==by 0x8060951: sqlite3_exec (legacy.c:77)
==14918==by 0x8048FD9: sqlite3_execute (thrd35.c:122)
==14918==by 0x80495DD: testthread (thrd35.c:261)
==14918==by 0x403A561: start_thread (in /lib/i686/libpthread-2.4.so)
==14918==by 0x418D4DD: clone (in /lib/i686/libc-2.4.so)
t count(*) from test_Table



   

Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.com/

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



RE: [sqlite] _sqlite3StrCmp not found

2007-08-30 Thread James Dennett
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 30, 2007 6:11 AM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] _sqlite3StrCmp not found
> 
> Bharath Booshan L <[EMAIL PROTECTED]> wrote:
> > Hello All,
> >
> >  I am using sqlite 3.1.3 version which is provided in Mac OS 10.4 OS
for
> my
> > application. We are upgrading our application to support Leapord.
> Leapord
> > includes sqlite 3.4.0 version and while loading dynamic library
> > "libsqlite3.dylib" it returns me following error
> >
> > Symbol not found : _sqlite3StrCmp
> > Referenced from: /usr/lib/sqlite/libtclsqlite3.dylib
> > Expected in: dynamic lookup
> >
> > I am using the following API's in my App.
> >
> > sqlite3_get_table()
> > sqlite3_prepare()
> > sqlite3_mprintf()
> > sqlite3_step()
> > sqlite3_free()
> >
> > What am I supposed to do to upgrade to 3.4.0 from 3.1.3.
> >
> 
> sqlite3StrCmp is not an API and never has been.  That was
> an internal routine used by some older versions of SQLite
> and was never meant for public consumption.
> 
> SQLite APIs all begin with "sqlite3_".  If there is not an
> underscore after the "3" then it is not an API and may change
> or be removed from one point release to the next.
> 
> The other interfaces you are using are APIs (notice the
> underscore after the 3) and are hence guaranteed to be
> supported into the future.

To maybe be more explicit: it appears that you're using an
older version of libtclsqlite3.dylib, and need to have/use
a version compatible with your current SQLite version.

-- James


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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Joe Wilson
Also:

==14673== Invalid read of size 4
==14673==at 0x80534F9: sqlite3OsWrite (os.c:38)
==14673==by 0x8050A17: sqlite3BtreeBeginTrans (btree.c:1850)
==14673==by 0x807E068: sqlite3VdbeExec (vdbe.c:2519)
==14673==by 0x805C209: sqlite3_step (vdbeapi.c:328)
==14673==by 0x8060951: sqlite3_exec (legacy.c:77)
==14673==by 0x8048FD9: sqlite3_execute (thrd35.c:122)
==14673==by 0x8049566: testthread (thrd35.c:240)
==14673==by 0x403A561: start_thread (in /lib/i686/libpthread-2.4.so)
==14673==by 0x418D4DD: clone (in /lib/i686/libc-2.4.so)
==14673==  Address 0xC is not stack'd, malloc'd or (recently) free'd
==14673==
==14673== Process terminating with default action of signal 11 (SIGSEGV)
==14673==  Access not within mapped region at address 0xC
==14673==at 0x80534F9: sqlite3OsWrite (os.c:38)
==14673==by 0x8050A17: sqlite3BtreeBeginTrans (btree.c:1850)
==14673==by 0x807E068: sqlite3VdbeExec (vdbe.c:2519)
==14673==by 0x805C209: sqlite3_step (vdbeapi.c:328)
==14673==by 0x8060951: sqlite3_exec (legacy.c:77)
==14673==by 0x8048FD9: sqlite3_execute (thrd35.c:122)
==14673==by 0x8049566: testthread (thrd35.c:240)
==14673==by 0x403A561: start_thread (in /lib/i686/libpthread-2.4.so)
==14673==by 0x418D4DD: clone (in /lib/i686/libc-2.4.so)
==14673==by 0xA: ???
==14673==by 0x38134192: (within /usr/lib/valgrind/x86-linux/memcheck)
==14673==by 0x2: ???

--- Joe Wilson <[EMAIL PROTECTED]> wrote:

> I also see random crashes with sources from CVS as of 
> Thu Aug 30 12:20:43 EDT 2007 using Ken's program below.
> 
>   http://marc.info/?l=sqlite-users=118848741522192=2
> 
> It's timing dependent.
> On a single core Pentium4 machine it crashes once in 10 runs.
> 
> Sometimes it produces this valgrind error:
> 
> ==14637== Thread 4:
> ==14637== Invalid read of size 4
> ==14637==at 0x804D951: balance_nonroot (btree.c:4774)
> ==14637==by 0x804E840: balance (btree.c:5469)
> ==14637==by 0x805013B: sqlite3BtreeInsert (btree.c:5601)
> ==14637==by 0x807EAC1: sqlite3VdbeExec (vdbe.c:3506)
> ==14637==by 0x805C209: sqlite3_step (vdbeapi.c:328)
> ==14637==by 0x8060951: sqlite3_exec (legacy.c:77)
> ==14637==by 0x8048FD9: sqlite3_execute (thrd35.c:122)
> ==14637==by 0x80495B7: testthread (thrd35.c:251)
> ==14637==by 0x403A561: start_thread (in /lib/i686/libpthread-2.4.so)
> ==14637==by 0x418D4DD: clone (in /lib/i686/libc-2.4.so)
> ==14637==  Address 0x4C is not stack'd, malloc'd or (recently) free'd
> ==14637==
> ==14637== Process terminating with default action of signal 11 (SIGSEGV)
> ==14637==  Access not within mapped region at address 0x4C
> ==14637==at 0x804D951: balance_nonroot (btree.c:4774)
> ==14637==by 0x804E840: balance (btree.c:5469)
> ==14637==by 0x805013B: sqlite3BtreeInsert (btree.c:5601)
> ==14637==by 0x807EAC1: sqlite3VdbeExec (vdbe.c:3506)
> ==14637==by 0x805C209: sqlite3_step (vdbeapi.c:328)
> ==14637==by 0x8060951: sqlite3_exec (legacy.c:77)
> ==14637==by 0x8048FD9: sqlite3_execute (thrd35.c:122)
> ==14637==by 0x80495B7: testthread (thrd35.c:251)
> ==14637==by 0x403A561: start_thread (in /lib/i686/libpthread-2.4.so)
> ==14637==by 0x418D4DD: clone (in /lib/i686/libc-2.4.so)
> ==14637==by 0x38134192: (within /usr/lib/valgrind/x86-linux/memcheck)
> ==14637==by 0x3: ???



   

Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.com/

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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Joe Wilson
I also see random crashes with sources from CVS as of 
Thu Aug 30 12:20:43 EDT 2007 using Ken's program below.

  http://marc.info/?l=sqlite-users=118848741522192=2

It's timing dependent.
On a single core Pentium4 machine it crashes once in 10 runs.

Sometimes it produces this valgrind error:

==14637== Thread 4:
==14637== Invalid read of size 4
==14637==at 0x804D951: balance_nonroot (btree.c:4774)
==14637==by 0x804E840: balance (btree.c:5469)
==14637==by 0x805013B: sqlite3BtreeInsert (btree.c:5601)
==14637==by 0x807EAC1: sqlite3VdbeExec (vdbe.c:3506)
==14637==by 0x805C209: sqlite3_step (vdbeapi.c:328)
==14637==by 0x8060951: sqlite3_exec (legacy.c:77)
==14637==by 0x8048FD9: sqlite3_execute (thrd35.c:122)
==14637==by 0x80495B7: testthread (thrd35.c:251)
==14637==by 0x403A561: start_thread (in /lib/i686/libpthread-2.4.so)
==14637==by 0x418D4DD: clone (in /lib/i686/libc-2.4.so)
==14637==  Address 0x4C is not stack'd, malloc'd or (recently) free'd
==14637==
==14637== Process terminating with default action of signal 11 (SIGSEGV)
==14637==  Access not within mapped region at address 0x4C
==14637==at 0x804D951: balance_nonroot (btree.c:4774)
==14637==by 0x804E840: balance (btree.c:5469)
==14637==by 0x805013B: sqlite3BtreeInsert (btree.c:5601)
==14637==by 0x807EAC1: sqlite3VdbeExec (vdbe.c:3506)
==14637==by 0x805C209: sqlite3_step (vdbeapi.c:328)
==14637==by 0x8060951: sqlite3_exec (legacy.c:77)
==14637==by 0x8048FD9: sqlite3_execute (thrd35.c:122)
==14637==by 0x80495B7: testthread (thrd35.c:251)
==14637==by 0x403A561: start_thread (in /lib/i686/libpthread-2.4.so)
==14637==by 0x418D4DD: clone (in /lib/i686/libc-2.4.so)
==14637==by 0x38134192: (within /usr/lib/valgrind/x86-linux/memcheck)
==14637==by 0x3: ???

--- [EMAIL PROTECTED] wrote:

> Ken <[EMAIL PROTECTED]> wrote:
> > program received signal SIGSEGV, Segmentation fault.
> > [Switching to Thread 1080043872 (LWP 15448)]
> > moveToChild (pCur=0x569058, newPgno=) at btree.c:3304
> > (gdb) 
> > 
> > 
> > if( rc ) return rc;
> >   pNewPage->idxParent = pCur->idx;
> >   pOldPage = pCur->pPage;
> >   pOldPage->idxShift = 0; < Error Here
> >   releasePage(pOldPage);
> >   pCur->pPage = pNewPage;
> >   pCur->idx = 0;
> >   pCur->info.nSize = 0;
> > 
> 
> When did you check-out the sources?  There have been a lot
> of changes lately.  What is the RCS version number on your
> btree.c source file (in the header comment at the top)?



   

Got a little couch potato? 
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail=summer+activities+for+kids=bz
 

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



Re: [sqlite] Storing monetary values and calculations

2007-08-30 Thread John Stanton
This is not available as publicly distributed, but there is some code in 
http://www.viacognis.com/declib which you are free to use.


RohitPatel wrote:

Hi John

If sourcecode for that type (DECIMAL) is available for public, please let us
know the link and we can explore it for SQLite.

Thanks


John Stanton wrote:

That is an interesting way to store money.  We developed a fixed point 
arithmetic library of arbitrary precision using the algorithms described 
by Knuth in his semi-numerical algorithms volume and using standard 
DECIMAL(n,m) definition.  Rounding is precise using an algorithm which 
does not drift and intermediate.  Finally the numbers are stored in 
display format, right justified and with leading spaces and signs so 
that they can be displayed in HTML pages or printed output without 
reformating.

...
...
...







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



Re: [sqlite] command

2007-08-30 Thread Jim Dodgen
Also I recommend you get a very basic SQL database book.


Quoting John Stanton <[EMAIL PROTECTED]>:

> nishit sharma wrote:
> > i have given some text in a database file as
> > America|england|   and many more.
> > now i want to replace some text with new text how
> > this is possible. Also my database has around 15 rows now
> > which will be incremented.
> > 
> > so, plz anyone tell me how to replace a text in a row and
> > how to delete a particular row.
> > 
> > waiting for response
> > 
> > regads
> > Nishit
> > 
> How about UPDATE?
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
> 
> 






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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread drh
Ken <[EMAIL PROTECTED]> wrote:
> program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1080043872 (LWP 15448)]
> moveToChild (pCur=0x569058, newPgno=) at btree.c:3304
> (gdb) 
> 
> 
> if( rc ) return rc;
>   pNewPage->idxParent = pCur->idx;
>   pOldPage = pCur->pPage;
>   pOldPage->idxShift = 0; < Error Here
>   releasePage(pOldPage);
>   pCur->pPage = pNewPage;
>   pCur->idx = 0;
>   pCur->info.nSize = 0;
> 

When did you check-out the sources?  There have been a lot
of changes lately.  What is the RCS version number on your
btree.c source file (in the header comment at the top)?

--
D. Richard Hipp <[EMAIL PROTECTED]>


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



Re: [sqlite] How to generate Unique ID?

2007-08-30 Thread John Stanton

I just need the answer for my original question.

Regards,
Phanisekhar


Maybe you "need" an answer, but others do not "need" to give it to you. 
 If you want others to do your thinking and reading for you, don't 
demand, ask politely.


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



Re: [sqlite] command

2007-08-30 Thread John Stanton

nishit sharma wrote:

i have given some text in a database file as
America|england|   and many more.
now i want to replace some text with new text how
this is possible. Also my database has around 15 rows now
which will be incremented.

so, plz anyone tell me how to replace a text in a row and
how to delete a particular row.

waiting for response

regads
Nishit


How about UPDATE?

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



Re: [sqlite] sqlite3 Database Pointer multithreading / concurrency

2007-08-30 Thread Ken
http://www.sqlite.org/lockingv3.html

where A3 means the processes 3rd connection.


A1  - Shared   (select)
B2  - Pending  (insert)
A3  - Shared   (select)

Looks like a deadlock at A3.  B2 has a pending Lock and can not make further 
progress until A1 completes. But A3 is now waiting on B2.

Either finish the A1 transaction before calling foo() or run foo() using the 
same connection as A1. Not really sure why within the same thread you ever need 
more than 1 connection.




Ben Mann <[EMAIL PROTECTED]> wrote: I have a multithreaded application which is 
exhibiting some unexpected
behaviour in the form of SQLITE_BUSY api return codes. I've traced
this back to a fairly simple way to model the problem, but I can't
seem to find any documentation which explicitly describes this issue.
I'll summarise the problem below, and I also have provided a short
console program which can be used to demonstrate the issue.

To my understanding, the behaviour is:

I have two threads, A and B.
1. A opens the database, and gets an sqlite3*
2. A runs a SELECT, which puts the database in a SHARED lock state
3. The OS interrupts A and allows B to run
4. B opens the database, gets an sqlite3*
5. B attempts an INSERT, but is blocked by the SHARED lock state.
6. B puts the database in a PENDING lock state.
7. The OS interrupts B and allows A to continue
8. A calls some function foo()
9. foo() opens the database, and gets an sqlite3*
10. foo() runs a SELECT, which blocks because the database is in a
PENDING lock state.
11. Because foo() is part of thread A, the system is deadlocked.

In my example code, disabling foo() and replacing it with
bar(sqlite3*), which has a pointer to A's sqlite3* will allow the
application to run normally.

So my questions are:
Is this a known feature?
Should functions called by a thread, which has its own DB handle, be
forbidden from opening a new DB handle?

Any answers much appreciated! This is also my first post here so
scathing criticisms and allegations of being a newbie are also welcome
>.<

Example code follows (beware, it's quick and dirty!); this version
will compile as a windows console app (remember to set OS_WIN and
THREADSAFE in compile options):
__
#include 
#include 
#include 
#include 
#include 
#include "sqlite/sqlite3.h"

#define ALONGTIME 1000

void dotdotdot() { //simulate 'other' stuff
volatile int stupid = 0;
while(stupid < 1) stupid++;
}

//use an open connection and select
void bar(sqlite3 *pdb) {
char sql[] = "SELECT * FROM B";
sqlite3_stmt* pstmt;
const char* szTail=0;
int ret;

printf("B");
assert(SQLITE_OK == (ret = sqlite3_prepare(pdb, sql, -1, , )));
ret = sqlite3_step(pstmt);
assert(ret == SQLITE_DONE || ret == SQLITE_ROW);

sqlite3_finalize(pstmt);
}

//open a new connection and select
void foo() {
sqlite3 *pdb;
int ret;
assert(SQLITE_OK == (ret = sqlite3_open("testdb",)));
sqlite3_busy_timeout(pdb,ALONGTIME);

bar(pdb);

sqlite3_close(pdb);
}

//open a connection and select
DWORD WINAPI ThreadA(LPVOID) {
while(1) {
Sleep(7);

sqlite3 *pdb = 0;
char sql[] = "SELECT * FROM A";
sqlite3_stmt* pstmt;
const char* szTail=0;
int ret;

printf("A");
assert(SQLITE_OK == (ret = sqlite3_open("testdb",)));
sqlite3_busy_timeout(pdb,ALONGTIME);
assert(SQLITE_OK == (ret = sqlite3_prepare(pdb, sql, -1,
, )));
ret = sqlite3_step(pstmt);
assert(ret == SQLITE_DONE || ret == SQLITE_ROW);
dotdotdot(); //simulate 'other code' that occurs here and may
use the query

foo();  //call a function that may query the db
//bar(pdb);

dotdotdot(); //simulate 'other code' that occurs here and may
use the query
sqlite3_finalize(pstmt);
sqlite3_close(pdb);
}
}

void TouchDB() {
static int counter = 0;
sqlite3 *pdb = 0;
char *sql;
char *err = 0;
int ret;

assert(SQLITE_OK == (ret = sqlite3_open("testdb",)));
sqlite3_busy_timeout(pdb,ALONGTIME);
printf("C(%d)", counter);
sql = sqlite3_mprintf("INSERT INTO C VALUES(%d);", counter++);
assert(SQLITE_OK == (ret = sqlite3_exec(pdb,sql,0,0,)));
sqlite3_close(pdb);
}

DWORD ThreadB(LPVOID) {
while(!kbhit()) {
Sleep(3);
TouchDB(); //touch the db
}
return 0;
}

void MakeDB()
{
sqlite3 *pdb = 0;
char sql[] ="DROP TABLE IF EXISTS A;"
"DROP TABLE IF EXISTS B;"
"DROP TABLE IF EXISTS C;"
"CREATE TABLE A(ID INTEGER PRIMARY KEY);"
"CREATE TABLE B(ID INTEGER PRIMARY KEY);"
"CREATE TABLE C(ID INTEGER PRIMARY KEY);"
"INSERT INTO A VALUES(1);"
"INSERT INTO B VALUES(2);";
char *err = 0;
int ret;

if (SQLITE_OK == (ret = sqlite3_open("testdb",))) {
sqlite3_busy_timeout(pdb,ALONGTIME);

Re: [sqlite] How to generate Unique ID?

2007-08-30 Thread John Stanton
Why do you have a unique primary key as an integer to hold your other 
unique integer?  Why not just use the unique integer as a primary key?


If you want to have a limit on the maximum unique ID you can store your 
next to allocate and next to replace keys in another table.


B V, Phanisekhar wrote:

Assume I have a table:

Create table YYY (id Interger PRIMARY KEY, puid Unique integer)

Id is the primary key.

Puid is an unsque interger, whose values needs to be assigned by the
user.

 


Currently my approach is get the maximum value of puid stored in the
table; add 1 to it and uses this value as puid for any new row that
needs to be added. The problem occurs when I reach the max value.
Meanwhile, some rows might have been deleted. In case, when I reach the
maximum value I want to reuse the puids of the deleted rows for new rows
that are to be added. Currently SQLite uses some algorithm to generate a
unique rowid (even when it reaches the limit). I want to use the same
algorithm here also. I tried to understand the algorithm but couldn't. I
need a simple way by which I can generate a unique puid without writing
the algorithm.

 

 


Regards,

Phani

 

 






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



Re: [sqlite] sqlite3 Database Pointer multithreading / concurrency

2007-08-30 Thread Trevor Talbot
On 8/29/07, Ben Mann <[EMAIL PROTECTED]> wrote:

>  The problem is that connection A is calling a function which is attempting
> to open a new SHARED connection. Since it can't (B's PENDING prevents this,
> because of A's earlier SHARED connection), A blocks.
>
> If instead, A does not open a new connection, but uses what it already has
> open, it all works like a charm.
>
> I'm beginning to think this is expected behaviour.

What you described about the locking is correct.  The threading isn't
strictly relevant; locking is done on a per-connection basis, not
per-thread.

Note that the only reason it blocks is because you're using
sqlite_busy_timeout().  If you don't use that, you can detect and
handle the (immediate) SQLITE_BUSY return.

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



Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Ken
Dan Source code is attached. I didn't write this, someone else from the forum 
did their name is not on it, nor coppyrighted.. I thought it was a clean way to 
test threading.

Interestingly if you remove out the shared cache everything runs to completion.



Dan Kennedy <[EMAIL PROTECTED]> wrote: 
Hi Ken,

Probably a bug in the new threading stuff. Can you share
source code for this test or is it part of some large app?

Either way, thanks for the report.

Dan.

On Wed, 2007-08-29 at 22:15 -0700, Ken wrote:
> Also erros out here, sporadically.
> int sqlite3OsWrite(sqlite3_file *id, const void *pBuf, int amt, i64 offset){
>   return id->pMethods->xWrite(id, pBuf, amt, offset);
> }
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1075841376 (LWP 15747)]
> 0x0040c413 in sqlite3OsWrite (id=0x55aaa0, pBuf=0x401ffc30, amt=24, 
> offset=0) at os.c:38
> (gdb) Quit
> (gdb) 
> 
> Ken  wrote: 4 threads, shared_Cache enabled
> LOOP 100 
> BEGIN
>  LOOP 50 times
>   INSERT
>  end LOOP
>  COMMIT
> 
>   SELECT COUNT(*) ...
> end LOOP
> 
> 
> program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1080043872 (LWP 15448)]
> moveToChild (pCur=0x569058, newPgno=) at btree.c:3304
> (gdb) 
> 
> 
> if( rc ) return rc;
>   pNewPage->idxParent = pCur->idx;
>   pOldPage = pCur->pPage;
>   pOldPage->idxShift = 0; < Error Here
>   releasePage(pOldPage);
>   pCur->pPage = pNewPage;
>   pCur->idx = 0;
>   pCur->info.nSize = 0;
> 
> 
> Ken
> 
> 
> 
> 
> Ken  wrote: 4 threads, shared_Cache enabled
> LOOP 100 
> BEGIN
>  LOOP 50 times
>   INSERT
>  end LOOP
>  COMMIT
> 
>   SELECT COUNT(*) ...
> end LOOP
> 
> 
> program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1080043872 (LWP 15448)]
> moveToChild (pCur=0x569058, newPgno=) at btree.c:3304
> (gdb) 
> 
> 
> if( rc ) return rc;
>   pNewPage->idxParent = pCur->idx;
>   pOldPage = pCur->pPage;
>   pOldPage->idxShift = 0; < Error Here
>   releasePage(pOldPage);
>   pCur->pPage = pNewPage;
>   pCur->idx = 0;
>   pCur->info.nSize = 0;
> 
> 
> Ken
> 
> 


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


#include 
#include 
#include 
#include 
#include 
#include 

#ifdef __Linux__
#  define _XOPEN_SOURCE 500
#endif
#include 

#define SQLITEDB "test.db"
#define NUM_THREADS 4
#define MAX_BUSY 25
#define NUM_LOOPS   200
#define NUM_INSERTS 10

#define SHARED_CACHE 1

#ifndef RETRY_BUSY
#define RETRY_BUSY 1
#endif

static void sync_thread(int thnum);

typedef struct sql_result {
	int alloc_rows;
	int rows;
	int cols;
	char ***data;
} sql_result;

typedef struct th_st {
	int th_num;
	/* 0 = not started, 1 = started, 2 = done, 3 = error */
	int state;
} th_st;

th_st *th_data = NULL;

pthread_mutex_t global_mutex;
int on_thread = 0;

#define SQLITE_ALLOC_ROWS 1024
static int sqlite3_rowcallback(void *myresult, int argc, char **argv, char **colName)
{
	sql_result *result = myresult;
	int i;
	(void)colName;
	if (result == NULL)
		return (SQLITE_ERROR);
	if (result->cols == 0)
		result->cols=argc;
	else if (result->cols != argc)
		return (SQLITE_ERROR);

	if (result->rows >= result->alloc_rows) {
		result->data=(char ***)realloc(result->data, (result->alloc_rows+SQLITE_ALLOC_ROWS)*sizeof(char **));
		result->alloc_rows += SQLITE_ALLOC_ROWS;
	}

	result->data[result->rows] = (char **)malloc((result->cols)*sizeof(char *));
	for (i=0; icols; i++) {
		if (argv[i] == NULL)
			result->data[result->rows][i] = NULL;
		else
			result->data[result->rows][i] = strdup(argv[i]);
	}
	result->rows++;
	return(SQLITE_OK);
}

static void sqlite3_printresult(sql_result *result)
{
	int i, j;
	if (!result->rows) return;

	printf("Query Results:\n");
	for (i=0; irows; i++) {
		for (j=0; jcols; j++) {
			if (j != 0)
printf(",");
			printf("%s", result->data[i][j]);
		}
		printf("\n");
	}
	printf("\n");
}

static void sqlite3_freeresult(sql_result *result)
{
	int i, j;
	if (!result->rows) return;
	for (i=0; irows; i++) {
		for (j=0; jcols; j++) {
			free(result->data[i][j]);
		}
		free(result->data[i]);
	}
	free(result->data);
}

/** sqlite3_execute
 *  Description: Execute SQL statment, loop on busy
 *  Return : 1 on success, 0 on failure, -1 on rollback/concurrency issue
 */
static int sqlite3_execute(sqlite3 *db_conn, const char *statement,  int thnum)
{
	int rc, retval;
	sql_result result;
	char *errmsg = NULL;
#if RETRY_BUSY
	int busy_cnt = 0;
#endif

	memset(, 0, sizeof(result));

	do {
		errmsg = NULL;
		printf("%d => Executing: %s\n", thnum, statement);
		rc = sqlite3_exec(db_conn, statement, sqlite3_rowcallback, , );
		switch (rc) {
			case SQLITE_OK:
retval = 1;
break;
			case SQLITE_BUSY:
#if RETRY_BUSY
busy_cnt++;
break;
#endif
			case SQLITE_LOCKED:
/* Issue a 

Re: [sqlite] _sqlite3StrCmp not found

2007-08-30 Thread drh
Bharath Booshan L <[EMAIL PROTECTED]> wrote:
> Hello All,
> 
>  I am using sqlite 3.1.3 version which is provided in Mac OS 10.4 OS for my
> application. We are upgrading our application to support Leapord. Leapord
> includes sqlite 3.4.0 version and while loading dynamic library
> "libsqlite3.dylib" it returns me following error
> 
> Symbol not found : _sqlite3StrCmp
> Referenced from: /usr/lib/sqlite/libtclsqlite3.dylib
> Expected in: dynamic lookup
> 
> I am using the following API's in my App.
> 
> sqlite3_get_table()
> sqlite3_prepare()
> sqlite3_mprintf()
> sqlite3_step()
> sqlite3_free()
> 
> What am I supposed to do to upgrade to 3.4.0 from 3.1.3.
> 

sqlite3StrCmp is not an API and never has been.  That was
an internal routine used by some older versions of SQLite
and was never meant for public consumption.

SQLite APIs all begin with "sqlite3_".  If there is not an
underscore after the "3" then it is not an API and may change
or be removed from one point release to the next.

The other interfaces you are using are APIs (notice the
underscore after the 3) and are hence guaranteed to be
supported into the future.

--
D. Richard Hipp <[EMAIL PROTECTED]>


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



Re: [sqlite] How to generate Unique ID?

2007-08-30 Thread Kees Nuyt

Hi Phani,

On Thu, 30 Aug 2007 16:51:27 +0530, you wrote:

>Simon,
>   Yeah you can term the problem like that. Can't I use the
>function which is assigning a unique id for INTEGER PRIMARY KEY column
>inside sql? If yes, how to use it?
>
>Regards,
>Phani

SQLite will do the job for you, it's all in the documentation.

http://www.sqlite.org/lang_createtable.html :
Specifying a PRIMARY KEY normally just creates a UNIQUE index on
the corresponding columns. [snip] Additional detail on automatic
B-Tree key generation is available separately. ->

http://www.sqlite.org/autoinc.html :
When a new row is inserted into an SQLite table, the ROWID can
either be specified as part of the INSERT statement or it can be
assigned automatically by the database engine. To specify a
ROWID manually [snip]

If no ROWID is specified on the insert, an appropriate ROWID is
created [snip]

Note: this solution is not standard SQL and not portable.
For more or less protable solution you would have to use smart
trigger code. 

Regards,
-- 
  (  Kees Nuyt
  )
c[_]

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



RE: [sqlite] Client/Server approach

2007-08-30 Thread Sreedhar.a
Hi,

Yes, The server and clients are in Network.

Best Regards,
Sreedhar.

-Original Message-
From: John Stanton [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 24, 2007 6:17 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Client/Server approach

You do not need a server to manage 5 clients on the same machine, only if
they are on a network.

Sreedhar.a wrote:
>  
> Hi,
> 
> I am working in sqlite 3.3.6.
> I want 5 clients to browse at the same time with good performance.
> I enabled threadsafe and defined SQLITE_ENABLE_MEMORY_MANAGEMENT .
> I think by using test_server.c  we can do 5 clients browsing with 
> single server.
> Can any one please help me by providing some patch for implementing this.
> 
> My doubts are:
> 1.Do I need  to create a thread for each client.If so it has to be 
> created before Sqlite3_server_start().
> 
> (Or)
> Some thing like below has to be followed.
> 
> Main()
> {
> 
>sqlite3_client_open()
>sqlite3_client_prepare()
>sqlite3_client_step()
>sqlite3_client_reset()
>sqlite3_client_finalize()
>sqlite3_client_close()
> 
> Sqlite3_server_start(); For starting the server.
> 
> sqlite3_server_stop();For closing the server.
> 
> 
> 
> }
> 
> Kindly help me to solve this.
> Thanks in advance
> 
> Best Regards,
> A.Sreedhar.
>  
> 
> 
> 
> --
> --- To unsubscribe, send email to 
> [EMAIL PROTECTED]
> --
> ---
> 



-
To unsubscribe, send email to [EMAIL PROTECTED]

-




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



Re: [sqlite] How to generate Unique ID?

2007-08-30 Thread Simon Davies
On 30/08/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote:
> Simon,
>Yeah you can term the problem like that. Can't I use the
> function which is assigning a unique id for INTEGER PRIMARY KEY column
> inside sql? If yes, how to use it?
>
> Regards,
> Phani
>

Phani,

With the whole of the sqlite codebase available you are free to use
any of it as you wish ;-)
But what you are suggesting above is not an approach that I would
choose to get involved with. (I don't know how sqlite assigns its
unique ids for INTEGER PRIMARY KEY columns, but I would be surprised
if it caters for specific subranges).

Rgds,
Simon

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



RE: [sqlite] command

2007-08-30 Thread kirrthana M
Update can be used to replace a text with some new text.
To delete a particular row use 'where' command along with 
'delete'.

-Original Message-
From: nishit sharma [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 30, 2007 4:04 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] command


i have given some text in a database file as
America|england|   and many more.
now i want to replace some text with new text how
this is possible. Also my database has around 15 rows now
which will be incremented.

so, plz anyone tell me how to replace a text in a row and
how to delete a particular row.

waiting for response

regads
Nishit


This message (including any attachment) is confidential and may be legally 
privileged.  Access to this message by anyone other than the intended 
recipient(s) listed above is unauthorized.  If you are not the intended 
recipient you are hereby notified that any disclosure, copying, or distribution 
of the message, or any action taken or omission of action by you in reliance 
upon it, is prohibited and may be unlawful.  Please immediately notify the 
sender by reply e-mail and permanently delete all copies of the message if you 
have received this message in error.

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



RE: [sqlite] How to generate Unique ID?

2007-08-30 Thread B V, Phanisekhar
Simon,
Yeah you can term the problem like that. Can't I use the
function which is assigning a unique id for INTEGER PRIMARY KEY column
inside sql? If yes, how to use it?

Regards,
Phani



-Original Message-
From: Simon Davies [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 30, 2007 4:35 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] How to generate Unique ID?

On 30/08/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote:
> Simon,
>
> > Without knowing your design, it looks like you wish to be able to
> > determine type from the id. This is creating a problem. Can you not
> > store the type separately from the id?
>
> Why is this creating a problem?
> No it's not possible to store the type separately.
>
> I just need the answer for my original question.
>
> Regards,
> Phanisekhar
>

Phani,

Without the requirement to have unique ids within fixed ranges
dependant on type, you could just declare a column as 'INTEGER PRIMARY
KEY' and let sqlite take care of assigning your ids. As it is you have
to come up with a way to generate these unique ids yourself, hence
your question. This is what I have termed a problem.

Rgds,
Simon


-
To unsubscribe, send email to [EMAIL PROTECTED]

-


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



Re: [sqlite] How to generate Unique ID?

2007-08-30 Thread Simon Davies
On 30/08/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote:
> Simon,
>
> > Without knowing your design, it looks like you wish to be able to
> > determine type from the id. This is creating a problem. Can you not
> > store the type separately from the id?
>
> Why is this creating a problem?
> No it's not possible to store the type separately.
>
> I just need the answer for my original question.
>
> Regards,
> Phanisekhar
>

Phani,

Without the requirement to have unique ids within fixed ranges
dependant on type, you could just declare a column as 'INTEGER PRIMARY
KEY' and let sqlite take care of assigning your ids. As it is you have
to come up with a way to generate these unique ids yourself, hence
your question. This is what I have termed a problem.

Rgds,
Simon

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



RE: [sqlite] How to generate Unique ID?

2007-08-30 Thread B V, Phanisekhar
Simon,

> Without knowing your design, it looks like you wish to be able to
> determine type from the id. This is creating a problem. Can you not
> store the type separately from the id?

Why is this creating a problem?
No it's not possible to store the type separately.

I just need the answer for my original question.

Regards,
Phanisekhar




-Original Message-
From: Simon Davies [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 30, 2007 4:13 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] How to generate Unique ID?

On 30/08/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote:
> Hi Simon,
>The problem is I have rowid which is the PRIMARY Key, and
> another column puid which should be unique. Now when I do vacuum rowid
> changes, but puid doesn't change and I don't want puid to change. Now
it
> is possible to make puid itself as PRIMARY KEY, but the problem is I
> assign the puid's to the objects (row entries) based upon their type.
> For some type of objects I need values from x to x + 1000, for other x
+
> 1000 to x + 2000 and likewise. Hence I need a generator which can
> generate a number from the given range (x, x + 1000) which is not
> assigned.
>
> Regards,
> Phani
>

Hi Phani,

Implicit rowid's might be modified by VACUUM, but values in a column
declared 'INTGER PRIMARY KEY' will not.

Without knowing your design, it looks like you wish to be able to
determine type from the id. This is creating a problem. Can you not
store the type separately from the id?

Rgds,
Simon


-
To unsubscribe, send email to [EMAIL PROTECTED]

-


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



Re: [sqlite] How to generate Unique ID?

2007-08-30 Thread Simon Davies
On 30/08/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote:
> Hi Simon,
>The problem is I have rowid which is the PRIMARY Key, and
> another column puid which should be unique. Now when I do vacuum rowid
> changes, but puid doesn't change and I don't want puid to change. Now it
> is possible to make puid itself as PRIMARY KEY, but the problem is I
> assign the puid's to the objects (row entries) based upon their type.
> For some type of objects I need values from x to x + 1000, for other x +
> 1000 to x + 2000 and likewise. Hence I need a generator which can
> generate a number from the given range (x, x + 1000) which is not
> assigned.
>
> Regards,
> Phani
>

Hi Phani,

Implicit rowid's might be modified by VACUUM, but values in a column
declared 'INTGER PRIMARY KEY' will not.

Without knowing your design, it looks like you wish to be able to
determine type from the id. This is creating a problem. Can you not
store the type separately from the id?

Rgds,
Simon

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



[sqlite] command

2007-08-30 Thread nishit sharma
i have given some text in a database file as
America|england|   and many more.
now i want to replace some text with new text how
this is possible. Also my database has around 15 rows now
which will be incremented.

so, plz anyone tell me how to replace a text in a row and
how to delete a particular row.

waiting for response

regads
Nishit


RE: [sqlite] How to generate Unique ID?

2007-08-30 Thread B V, Phanisekhar
Hi Simon,
The problem is I have rowid which is the PRIMARY Key, and
another column puid which should be unique. Now when I do vacuum rowid
changes, but puid doesn't change and I don't want puid to change. Now it
is possible to make puid itself as PRIMARY KEY, but the problem is I
assign the puid's to the objects (row entries) based upon their type.
For some type of objects I need values from x to x + 1000, for other x +
1000 to x + 2000 and likewise. Hence I need a generator which can
generate a number from the given range (x, x + 1000) which is not
assigned.

Regards,
Phani



-Original Message-
From: Simon Davies [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 30, 2007 3:21 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] How to generate Unique ID?

Hi Phani,

What is the point of generating a unique integer separate from the
(unique) integer primary key?

If you use the primary key as your unique identifier, sqlite will take
care of locating unused (deleted) ids when the maximum value is
reached (according to the documentation; I have not tried it)

Rgds,
Simon

On 30/08/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote:
> Sreedhar,
>
> I think u didn't read my mail properly. I want to generate unique id
for
> puid not for id (which is the PRIMARY KEY). Anyone knows how to
generate
> a undique ID for a column which is not PRIMARY KEY? Also, whenever I
> reach the limit (max value), I should be able to use the values of
> deleted rows.
>
> Regards,
> Phani
>
> -Original Message-
> From: Sreedhar.a [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 30, 2007 2:22 PM
> To: sqlite-users@sqlite.org
> Subject: RE: [sqlite] How to generate Unique ID?
>
> Phani,
>
> Read the "auto increment" in Sqlite FAQ s it is the first one in the
> list,
> it will solve your problem.
>
>
> Best Regards,
> A.Sreedhar.
>
> -Original Message-
> From: B V, Phanisekhar [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 30, 2007 2:11 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] How to generate Unique ID?
>
> Assume I have a table:
>
> Create table YYY (id Interger PRIMARY KEY, puid Unique integer)
>
> Id is the primary key.
>
> Puid is an unsque interger, whose values needs to be assigned by the
> user.
>
>
>
> Currently my approach is get the maximum value of puid stored in the
> table;
> add 1 to it and uses this value as puid for any new row that needs to
be
> added. The problem occurs when I reach the max value.
> Meanwhile, some rows might have been deleted. In case, when I reach
the
> maximum value I want to reuse the puids of the deleted rows for new
rows
> that are to be added. Currently SQLite uses some algorithm to generate
a
> unique rowid (even when it reaches the limit). I want to use the same
> algorithm here also. I tried to understand the algorithm but couldn't.
I
> need a simple way by which I can generate a unique puid without
writing
> the
> algorithm.
>
>
>
>
>
> Regards,
>
> Phani
>
>
>
>
>
>
>
>
>

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

> -
>
>
>

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

-
>
>


-
To unsubscribe, send email to [EMAIL PROTECTED]

-


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



Re: [sqlite] How to generate Unique ID?

2007-08-30 Thread Simon Davies
Hi Phani,

What is the point of generating a unique integer separate from the
(unique) integer primary key?

If you use the primary key as your unique identifier, sqlite will take
care of locating unused (deleted) ids when the maximum value is
reached (according to the documentation; I have not tried it)

Rgds,
Simon

On 30/08/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote:
> Sreedhar,
>
> I think u didn't read my mail properly. I want to generate unique id for
> puid not for id (which is the PRIMARY KEY). Anyone knows how to generate
> a undique ID for a column which is not PRIMARY KEY? Also, whenever I
> reach the limit (max value), I should be able to use the values of
> deleted rows.
>
> Regards,
> Phani
>
> -Original Message-
> From: Sreedhar.a [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 30, 2007 2:22 PM
> To: sqlite-users@sqlite.org
> Subject: RE: [sqlite] How to generate Unique ID?
>
> Phani,
>
> Read the "auto increment" in Sqlite FAQ s it is the first one in the
> list,
> it will solve your problem.
>
>
> Best Regards,
> A.Sreedhar.
>
> -Original Message-
> From: B V, Phanisekhar [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 30, 2007 2:11 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] How to generate Unique ID?
>
> Assume I have a table:
>
> Create table YYY (id Interger PRIMARY KEY, puid Unique integer)
>
> Id is the primary key.
>
> Puid is an unsque interger, whose values needs to be assigned by the
> user.
>
>
>
> Currently my approach is get the maximum value of puid stored in the
> table;
> add 1 to it and uses this value as puid for any new row that needs to be
> added. The problem occurs when I reach the max value.
> Meanwhile, some rows might have been deleted. In case, when I reach the
> maximum value I want to reuse the puids of the deleted rows for new rows
> that are to be added. Currently SQLite uses some algorithm to generate a
> unique rowid (even when it reaches the limit). I want to use the same
> algorithm here also. I tried to understand the algorithm but couldn't. I
> need a simple way by which I can generate a unique puid without writing
> the
> algorithm.
>
>
>
>
>
> Regards,
>
> Phani
>
>
>
>
>
>
>
>
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> 
> -
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
>
>

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



RE: [sqlite] How to generate Unique ID?

2007-08-30 Thread B V, Phanisekhar
Sreedhar,

I think u didn't read my mail properly. I want to generate unique id for
puid not for id (which is the PRIMARY KEY). Anyone knows how to generate
a undique ID for a column which is not PRIMARY KEY? Also, whenever I
reach the limit (max value), I should be able to use the values of
deleted rows.

Regards,
Phani

-Original Message-
From: Sreedhar.a [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 30, 2007 2:22 PM
To: sqlite-users@sqlite.org
Subject: RE: [sqlite] How to generate Unique ID?

Phani,

Read the "auto increment" in Sqlite FAQ s it is the first one in the
list,
it will solve your problem.


Best Regards,
A.Sreedhar.
 
-Original Message-
From: B V, Phanisekhar [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 30, 2007 2:11 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] How to generate Unique ID?

Assume I have a table:

Create table YYY (id Interger PRIMARY KEY, puid Unique integer)

Id is the primary key.

Puid is an unsque interger, whose values needs to be assigned by the
user.

 

Currently my approach is get the maximum value of puid stored in the
table;
add 1 to it and uses this value as puid for any new row that needs to be
added. The problem occurs when I reach the max value.
Meanwhile, some rows might have been deleted. In case, when I reach the
maximum value I want to reuse the puids of the deleted rows for new rows
that are to be added. Currently SQLite uses some algorithm to generate a
unique rowid (even when it reaches the limit). I want to use the same
algorithm here also. I tried to understand the algorithm but couldn't. I
need a simple way by which I can generate a unique puid without writing
the
algorithm.

 

 

Regards,

Phani

 

 





-
To unsubscribe, send email to [EMAIL PROTECTED]

-


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



Re: [sqlite] Towards SQLite version 3.5.0

2007-08-30 Thread Daniel Önnerby

Klemens Friedl wrote:

2007/8/29, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
  

I think you will be much much better off to put every
thread it is own private address space.  In other words,
turn each thread into a separate process.  Threads are
an invention of the devil.  Stay as far away from these
fiendish abominations as you can get.



In Unix processes are rather cheap ("fork", etc.), and as threads got
added late (mid 90ies) to the unix (posix) standard, several
concurrent threading implementation are spreading around, and pthread
is just one of them. Famous book "Advanced Programming in Unix
Environment" by Stevens (1992) doesn't cover threads at all, but
processes. Butenhof's "Programming with POSIX Threads" (1997) is one
of the first and best book that explains the new standard unix
threads.

In Win32, process are more expensive (more management overhead), and
threads, "fibers" or even "I/O complettion ports" are the prefered way
to go.

  


Well, I'm already using boost::thread for this application on win32. 
Since the application will not be finished before sqlite 3.5 I just 
though I could develop using 3.5 and help finding sqlites 
multithread-bugs at the same time. This is why I originally asked the 
question about the best practice when going multithread on SQLite 3.5.



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

  




RE: [sqlite] How to generate Unique ID?

2007-08-30 Thread Sreedhar.a
Phani,

Read the "auto increment" in Sqlite FAQ s it is the first one in the list,
it will solve your problem.


Best Regards,
A.Sreedhar.
 
-Original Message-
From: B V, Phanisekhar [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 30, 2007 2:11 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] How to generate Unique ID?

Assume I have a table:

Create table YYY (id Interger PRIMARY KEY, puid Unique integer)

Id is the primary key.

Puid is an unsque interger, whose values needs to be assigned by the user.

 

Currently my approach is get the maximum value of puid stored in the table;
add 1 to it and uses this value as puid for any new row that needs to be
added. The problem occurs when I reach the max value.
Meanwhile, some rows might have been deleted. In case, when I reach the
maximum value I want to reuse the puids of the deleted rows for new rows
that are to be added. Currently SQLite uses some algorithm to generate a
unique rowid (even when it reaches the limit). I want to use the same
algorithm here also. I tried to understand the algorithm but couldn't. I
need a simple way by which I can generate a unique puid without writing the
algorithm.

 

 

Regards,

Phani

 

 




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



[sqlite] How to generate Unique ID?

2007-08-30 Thread B V, Phanisekhar
Assume I have a table:

Create table YYY (id Interger PRIMARY KEY, puid Unique integer)

Id is the primary key.

Puid is an unsque interger, whose values needs to be assigned by the
user.

 

Currently my approach is get the maximum value of puid stored in the
table; add 1 to it and uses this value as puid for any new row that
needs to be added. The problem occurs when I reach the max value.
Meanwhile, some rows might have been deleted. In case, when I reach the
maximum value I want to reuse the puids of the deleted rows for new rows
that are to be added. Currently SQLite uses some algorithm to generate a
unique rowid (even when it reaches the limit). I want to use the same
algorithm here also. I tried to understand the algorithm but couldn't. I
need a simple way by which I can generate a unique puid without writing
the algorithm.

 

 

Regards,

Phani

 

 



Re: [sqlite] Towards SQLite version 3.5.0

2007-08-30 Thread Klemens Friedl
2007/8/29, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> I think you will be much much better off to put every
> thread it is own private address space.  In other words,
> turn each thread into a separate process.  Threads are
> an invention of the devil.  Stay as far away from these
> fiendish abominations as you can get.

In Unix processes are rather cheap ("fork", etc.), and as threads got
added late (mid 90ies) to the unix (posix) standard, several
concurrent threading implementation are spreading around, and pthread
is just one of them. Famous book "Advanced Programming in Unix
Environment" by Stevens (1992) doesn't cover threads at all, but
processes. Butenhof's "Programming with POSIX Threads" (1997) is one
of the first and best book that explains the new standard unix
threads.

In Win32, process are more expensive (more management overhead), and
threads, "fibers" or even "I/O complettion ports" are the prefered way
to go.

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



Re: [sqlite] Storing monetary values and calculations

2007-08-30 Thread RohitPatel9999

Hi John

If sourcecode for that type (DECIMAL) is available for public, please let us
know the link and we can explore it for SQLite.

Thanks


John Stanton wrote:
> 
> That is an interesting way to store money.  We developed a fixed point 
> arithmetic library of arbitrary precision using the algorithms described 
> by Knuth in his semi-numerical algorithms volume and using standard 
> DECIMAL(n,m) definition.  Rounding is precise using an algorithm which 
> does not drift and intermediate.  Finally the numbers are stored in 
> display format, right justified and with leading spaces and signs so 
> that they can be displayed in HTML pages or printed output without 
> reformating.
> ...
> ...
> ...
> 

-- 
View this message in context: 
http://www.nabble.com/Storing-monetary-values-and-calculations-tf4264034.html#a12401463
Sent from the SQLite mailing list archive at Nabble.com.


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



[sqlite] _sqlite3StrCmp not found

2007-08-30 Thread Bharath Booshan L
Hello All,

 I am using sqlite 3.1.3 version which is provided in Mac OS 10.4 OS for my
application. We are upgrading our application to support Leapord. Leapord
includes sqlite 3.4.0 version and while loading dynamic library
"libsqlite3.dylib" it returns me following error

Symbol not found : _sqlite3StrCmp
Referenced from: /usr/lib/sqlite/libtclsqlite3.dylib
Expected in: dynamic lookup

I am using the following API's in my App.

sqlite3_get_table()
sqlite3_prepare()
sqlite3_mprintf()
sqlite3_step()
sqlite3_free()

What am I supposed to do to upgrade to 3.4.0 from 3.1.3.

Regards,

Bharath Booshan L

PS: It works fine in sqlite 3.3.1.




---
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an 
intended recipient, please notify the sender and delete all copies. Emails to 
and from our network may be logged and monitored. This email and its 
attachments are scanned for virus by our scanners and are believed to be safe. 
However, no warranty is given that this email is free of malicious content or 
virus.



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



Re: [sqlite] sqlite3 Database Pointer multithreading / concurrency

2007-08-30 Thread Ben Mann
Thanks Dan,

 The problem is that connection A is calling a function which is attempting
to open a new SHARED connection. Since it can't (B's PENDING prevents this,
because of A's earlier SHARED connection), A blocks.

If instead, A does not open a new connection, but uses what it already has
open, it all works like a charm.

I'm beginning to think this is expected behaviour.



>
> Continually returns SQLITE_BUSY, right? Doesn't actually block?
>
> Was the INSERT attempted by B inside a transaction? I'm guessing
> so.
>
> This isn't really a threading problem. Once connection B has the
> PENDING lock, no new connections will be able to get the SHARED
> lock required to read the database. The connection held by thread
> A already has it's shared lock, so it can continue to read. Once
> B commits or rolls it's transaction back, the PENDING lock will
> be dropped and other connections, including new connections, will
> be able to obtain new SHARED locks.
>
> If I've understood things right...
>
> Dan.


Re: [sqlite] beginner

2007-08-30 Thread nishit sharma
thanks for telling the link.

regards


On 8/30/07, Pavan <[EMAIL PROTECTED]> wrote:
>
> Hi Nishit,
>
> http://www.sqlite.org/quickstart.html
>
> This is a good link to start with.
>
> Thanks,
> Pavan.
>
>
> On 8/30/07, nishit sharma <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> > i m beginner to sqlite
> > can anybody send me a link which can help me
> > in building and maintining databse
> >
>
>
>
> --
> '
> Always finish stronger than you start
> *
>


Re: [sqlite] version 3.5.0 - Segv

2007-08-30 Thread Dan Kennedy

Hi Ken,

Probably a bug in the new threading stuff. Can you share
source code for this test or is it part of some large app?

Either way, thanks for the report.

Dan.

On Wed, 2007-08-29 at 22:15 -0700, Ken wrote:
> Also erros out here, sporadically.
> int sqlite3OsWrite(sqlite3_file *id, const void *pBuf, int amt, i64 offset){
>   return id->pMethods->xWrite(id, pBuf, amt, offset);
> }
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1075841376 (LWP 15747)]
> 0x0040c413 in sqlite3OsWrite (id=0x55aaa0, pBuf=0x401ffc30, amt=24, 
> offset=0) at os.c:38
> (gdb) Quit
> (gdb) 
> 
> Ken <[EMAIL PROTECTED]> wrote: 4 threads, shared_Cache enabled
> LOOP 100 
> BEGIN
>  LOOP 50 times
>   INSERT
>  end LOOP
>  COMMIT
> 
>   SELECT COUNT(*) ...
> end LOOP
> 
> 
> program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1080043872 (LWP 15448)]
> moveToChild (pCur=0x569058, newPgno=) at btree.c:3304
> (gdb) 
> 
> 
> if( rc ) return rc;
>   pNewPage->idxParent = pCur->idx;
>   pOldPage = pCur->pPage;
>   pOldPage->idxShift = 0; < Error Here
>   releasePage(pOldPage);
>   pCur->pPage = pNewPage;
>   pCur->idx = 0;
>   pCur->info.nSize = 0;
> 
> 
> Ken
> 
> 
> 
> 
> Ken <[EMAIL PROTECTED]> wrote: 4 threads, shared_Cache enabled
> LOOP 100 
> BEGIN
>  LOOP 50 times
>   INSERT
>  end LOOP
>  COMMIT
> 
>   SELECT COUNT(*) ...
> end LOOP
> 
> 
> program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1080043872 (LWP 15448)]
> moveToChild (pCur=0x569058, newPgno=) at btree.c:3304
> (gdb) 
> 
> 
> if( rc ) return rc;
>   pNewPage->idxParent = pCur->idx;
>   pOldPage = pCur->pPage;
>   pOldPage->idxShift = 0; < Error Here
>   releasePage(pOldPage);
>   pCur->pPage = pNewPage;
>   pCur->idx = 0;
>   pCur->info.nSize = 0;
> 
> 
> Ken
> 
> 


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



Re: [sqlite] sqlite3 Database Pointer multithreading / concurrency

2007-08-30 Thread Dan Kennedy
On Thu, 2007-08-30 at 13:25 +0800, Ben Mann wrote:
> I have a multithreaded application which is exhibiting some unexpected
> behaviour in the form of SQLITE_BUSY api return codes. I've traced
> this back to a fairly simple way to model the problem, but I can't
> seem to find any documentation which explicitly describes this issue.
> I'll summarise the problem below, and I also have provided a short
> console program which can be used to demonstrate the issue.
> 
> To my understanding, the behaviour is:
> 
> I have two threads, A and B.
> 1. A opens the database, and gets an sqlite3*
> 2. A runs a SELECT, which puts the database in a SHARED lock state
> 3. The OS interrupts A and allows B to run
> 4. B opens the database, gets an sqlite3*
> 5. B attempts an INSERT, but is blocked by the SHARED lock state.
> 6. B puts the database in a PENDING lock state.
> 7. The OS interrupts B and allows A to continue
> 8. A calls some function foo()
> 9. foo() opens the database, and gets an sqlite3*
> 10. foo() runs a SELECT, which blocks because the database is in a
> PENDING lock state.

Continually returns SQLITE_BUSY, right? Doesn't actually block?

Was the INSERT attempted by B inside a transaction? I'm guessing
so.

This isn't really a threading problem. Once connection B has the 
PENDING lock, no new connections will be able to get the SHARED
lock required to read the database. The connection held by thread
A already has it's shared lock, so it can continue to read. Once
B commits or rolls it's transaction back, the PENDING lock will
be dropped and other connections, including new connections, will
be able to obtain new SHARED locks.

If I've understood things right...

Dan.


> 11. Because foo() is part of thread A, the system is deadlocked.
> 
> In my example code, disabling foo() and replacing it with
> bar(sqlite3*), which has a pointer to A's sqlite3* will allow the
> application to run normally.
> 
> So my questions are:
> Is this a known feature?
> Should functions called by a thread, which has its own DB handle, be
> forbidden from opening a new DB handle?
> 
> Any answers much appreciated! This is also my first post here so
> scathing criticisms and allegations of being a newbie are also welcome
> >.<
> 
> Example code follows (beware, it's quick and dirty!); this version
> will compile as a windows console app (remember to set OS_WIN and
> THREADSAFE in compile options):
> __
> #include 
> #include 
> #include 
> #include 
> #include 
> #include "sqlite/sqlite3.h"
> 
> #define ALONGTIME 1000
> 
> void dotdotdot() { //simulate 'other' stuff
> volatile int stupid = 0;
> while(stupid < 1) stupid++;
> }
> 
> //use an open connection and select
> void bar(sqlite3 *pdb) {
> char sql[] = "SELECT * FROM B";
> sqlite3_stmt* pstmt;
> const char* szTail=0;
> int ret;
> 
> printf("B");
> assert(SQLITE_OK == (ret = sqlite3_prepare(pdb, sql, -1, , 
> )));
> ret = sqlite3_step(pstmt);
> assert(ret == SQLITE_DONE || ret == SQLITE_ROW);
> 
> sqlite3_finalize(pstmt);
> }
> 
> //open a new connection and select
> void foo() {
> sqlite3 *pdb;
> int ret;
> assert(SQLITE_OK == (ret = sqlite3_open("testdb",)));
> sqlite3_busy_timeout(pdb,ALONGTIME);
> 
> bar(pdb);
> 
> sqlite3_close(pdb);
> }
> 
> //open a connection and select
> DWORD WINAPI ThreadA(LPVOID) {
> while(1) {
> Sleep(7);
> 
> sqlite3 *pdb = 0;
> char sql[] = "SELECT * FROM A";
> sqlite3_stmt* pstmt;
> const char* szTail=0;
> int ret;
> 
> printf("A");
> assert(SQLITE_OK == (ret = sqlite3_open("testdb",)));
> sqlite3_busy_timeout(pdb,ALONGTIME);
> assert(SQLITE_OK == (ret = sqlite3_prepare(pdb, sql, -1,
> , )));
> ret = sqlite3_step(pstmt);
> assert(ret == SQLITE_DONE || ret == SQLITE_ROW);
> dotdotdot(); //simulate 'other code' that occurs here and may
> use the query
> 
> foo();  //call a function that may query the db
> //bar(pdb);
> 
> dotdotdot(); //simulate 'other code' that occurs here and may
> use the query
> sqlite3_finalize(pstmt);
> sqlite3_close(pdb);
> }
> }
> 
> void TouchDB() {
> static int counter = 0;
> sqlite3 *pdb = 0;
> char *sql;
> char *err = 0;
> int ret;
> 
> assert(SQLITE_OK == (ret = sqlite3_open("testdb",)));
> sqlite3_busy_timeout(pdb,ALONGTIME);
> printf("C(%d)", counter);
> sql = sqlite3_mprintf("INSERT INTO C VALUES(%d);", counter++);
> assert(SQLITE_OK == (ret = sqlite3_exec(pdb,sql,0,0,)));
> sqlite3_close(pdb);
> }
> 
> DWORD ThreadB(LPVOID) {
> while(!kbhit()) {
> Sleep(3);
> TouchDB(); //touch the db
> }
> return 0;
> }
> 
> void MakeDB()
> {
> sqlite3 *pdb = 0;
> char sql[] ="DROP TABLE IF EXISTS A;"
> "DROP TABLE IF EXISTS B;"
> "DROP TABLE 

Re: [sqlite] beginner

2007-08-30 Thread Pavan
Hi Nishit,

http://www.sqlite.org/quickstart.html

This is a good link to start with.

Thanks,
Pavan.


On 8/30/07, nishit sharma <[EMAIL PROTECTED]> wrote:
>
> Hi,
> i m beginner to sqlite
> can anybody send me a link which can help me
> in building and maintining databse
>



-- 
'
Always finish stronger than you start
*


[sqlite] beginner

2007-08-30 Thread nishit sharma
Hi,
i m beginner to sqlite
can anybody send me a link which can help me
in building and maintining databse