Re: [sqlite] UPDATE during SELECT

2010-11-23 Thread Simon Slavin
On 24 Nov 2010, at 3:08am, Pavel Ivanov wrote: > Probably SQLite's implementation allows some other types of behavior, > but in any case behavior would be "erroneous" and unpredictable, so > you better avoid changing table that is currently being selected, or > at very least avoid changing indexe

Re: [sqlite] UPDATE during SELECT

2010-11-23 Thread Pavel Ivanov
> Could there be any other > consequences like unpredictable behavior and such? Yes, it will be unpredictable and undefined behavior. I can't say exactly how SQLite will behave in such situation. What I know is it doesn't execute all select at once, it fetches row by row on each sqlite3_step call

Re: [sqlite] UPDATE during SELECT

2010-11-23 Thread cricketfan
Pavel, What will happen if you had an index on the other_column for the select/update you mentioned below? Is it just that your tree will be unbalanced every time you change the other_column? Could there be any other consequences like unpredictable behavior and such? Thanks > Exactly t

Re: [sqlite] UPDATE during SELECT

2010-11-19 Thread Igor Tandetnik
Nikolaus Rath wrote: > "Igor Tandetnik" writes: >> Nikolaus Rath wrote: >>> I understand that running INSERT or DELETE during an active SELECT query >>> can get me into trouble. But is it safe to run (in pseudocode): >>> >>> for value in "SELECT main_column IN mytable": >>> >>> UPDATE mytabl

Re: [sqlite] UPDATE during SELECT

2010-11-19 Thread Pavel Ivanov
> for value in "SELECT main_column IN mytable": >   UPDATE mytable SET other_column='foobar' WHERE main_column=value Exactly this sequence is safe. Things can go nuts in case if you have index on other_column and you do something like this: for value in "SELECT main_column IN mytable WHERE other_

Re: [sqlite] UPDATE during SELECT

2010-11-19 Thread Nikolaus Rath
"Igor Tandetnik" writes: > Nikolaus Rath wrote: >> I understand that running INSERT or DELETE during an active SELECT query >> can get me into trouble. But is it safe to run (in pseudocode): >> >> for value in "SELECT main_column IN mytable": >> >> UPDATE mytable SET other_column='foobar' WHE

Re: [sqlite] UPDATE during SELECT

2010-11-18 Thread Igor Tandetnik
Nikolaus Rath wrote: > I understand that running INSERT or DELETE during an active SELECT query > can get me into trouble. But is it safe to run (in pseudocode): > > for value in "SELECT main_column IN mytable": > > UPDATE mytable SET other_column='foobar' WHERE main_column=value It should be

[sqlite] UPDATE during SELECT

2010-11-18 Thread Nikolaus Rath
Hello, I understand that running INSERT or DELETE during an active SELECT query can get me into trouble. But is it safe to run (in pseudocode): for value in "SELECT main_column IN mytable": UPDATE mytable SET other_column='foobar' WHERE main_column=value ? Thanks, -Nikolaus -- »Time

Re: [sqlite] UPDATE during SELECT

2007-07-18 Thread Richard Klein
[EMAIL PROTECTED] wrote: John Stanton <[EMAIL PROTECTED]> wrote: Yes, each connection has a cache. A lot of concurrent connections means a lot of memory allocated to cache and potentially a lot of duplicated cached items. See shared cache mode for relief. Yes. But remember that shared

Re: [sqlite] UPDATE during SELECT

2007-07-18 Thread drh
John Stanton <[EMAIL PROTECTED]> wrote: > > Yes, each connection has a cache. A lot of concurrent connections means > a lot of memory allocated to cache and potentially a lot of duplicated > cached items. See shared cache mode for relief. > Yes. But remember that shared cache mode has limit

Re: [sqlite] UPDATE during SELECT

2007-07-18 Thread John Stanton
[EMAIL PROTECTED] wrote: > A single connection can only be used by a single thread at > a time. If you have multiple threads running at the same > time, they each need to have their own connection. > > If you are not running on a Linux 2.4 kernel, then you can > pass connections from one thread

Re: [sqlite] UPDATE during SELECT

2007-07-18 Thread John Stanton
[EMAIL PROTECTED] wrote: Joe Wilson <[EMAIL PROTECTED]> wrote: --- John Stanton <[EMAIL PROTECTED]> wrote: Using a single Sqlite connection for each database and holding the connection open means that maximum effect is obtained from Sqlite's cache. As far as we can ascertain avoiding fcntl

Re: [sqlite] UPDATE during SELECT

2007-07-18 Thread Joe Wilson
--- [EMAIL PROTECTED] wrote: > A single connection can only be used by a single thread at > a time. If you have multiple threads running at the same > time, they each need to have their own connection. > > If you are not running on a Linux 2.4 kernel, then you can > pass connections from one thre

Re: [sqlite] UPDATE during SELECT

2007-07-18 Thread drh
Joe Wilson <[EMAIL PROTECTED]> wrote: > --- John Stanton <[EMAIL PROTECTED]> wrote: > > Using a single Sqlite connection for each database and holding the > > connection open means that maximum effect is obtained from Sqlite's > > cache. As far as we can ascertain avoiding fcntl removes any issu

[sqlite] UPDATE during SELECT

2007-07-16 Thread Larry Lewis
If I am stepping through the results of a SELECT and want to UPDATE values in the currently selected row prior to completion of the SELECT query, will this work? What if there is already a pending writer lock on the database from a different thread? Thanks. Larry ---