[sqlite] UPDATE silently failing

2015-09-21 Thread James K. Lowden
On Mon, 21 Sep 2015 17:44:13 -0400 Hugues Bruant wrote: > UPDATE cv SET cv_t=? where cv_s=? and cv_o=?; > > Most of the time the row is updated as expected but in some rare cases > we've seen this statement fail silently, as in: > - the row exists > - the row it is not updated > - step

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread James K. Lowden
On Mon, 21 Sep 2015 11:19:16 +0200 "R.Smith" wrote: > On 2015-09-21 01:53 AM, Nicolas J?ger wrote: > > hi, > > > > > > Scott Robison wrote: > > > >> 3. Some time passes and some external process may alter the schema. > >> > > is it really possible ? if the answer is yes (I thought when a > >

[sqlite] UPDATE silently failing

2015-09-21 Thread Richard Hipp
On 9/21/15, Hugues Bruant wrote: > On Mon, Sep 21, 2015 at 8:43 PM, Richard Hipp wrote: > >> On 9/21/15, Hugues Bruant wrote: >> > >> > I would be happy to build and test a patched sqlite with extra logging, >> > some sort of vdbe execution tracing >> >> Compile with -DSQLITE_DEBUG and then use

[sqlite] UPDATE silently failing

2015-09-21 Thread Hugues Bruant
On Mon, Sep 21, 2015 at 8:43 PM, Richard Hipp wrote: > On 9/21/15, Hugues Bruant wrote: > > > > I would be happy to build and test a patched sqlite with extra logging, > > some sort of vdbe execution tracing > > Compile with -DSQLITE_DEBUG and then use "PRAGMA vdbe_debug=ON;" > before the

[sqlite] UPDATE silently failing

2015-09-21 Thread Richard Hipp
On 9/21/15, Hugues Bruant wrote: > > I would be happy to build and test a patched sqlite with extra logging, > some sort of vdbe execution tracing Compile with -DSQLITE_DEBUG and then use "PRAGMA vdbe_debug=ON;" before the offending UPDATE and turn if off afterwards. -- D. Richard Hipp drh at

[sqlite] UPDATE silently failing

2015-09-21 Thread Hugues Bruant
On Mon, Sep 21, 2015 at 8:23 PM, Richard Hipp wrote: > On 9/21/15, Hugues Bruant wrote: > > On Mon, Sep 21, 2015 at 6:49 PM, Richard Hipp wrote: > > > >> On 9/21/15, Hugues Bruant wrote: > >> > Table schema: > >> > > >> > CREATE TABLE cv (cv_s integer not null, cv_o blob not null, cv_t > >> >

[sqlite] UPDATE silently failing

2015-09-21 Thread Richard Hipp
On 9/21/15, Hugues Bruant wrote: > On Mon, Sep 21, 2015 at 6:49 PM, Richard Hipp wrote: > >> On 9/21/15, Hugues Bruant wrote: >> > Table schema: >> > >> > CREATE TABLE cv (cv_s integer not null, cv_o blob not null, cv_t >> > integer >> > not null, primary key(cv_s, cv_o)); >> > >> > Prepared

[sqlite] UPDATE silently failing

2015-09-21 Thread Hugues Bruant
On Mon, Sep 21, 2015 at 6:49 PM, Richard Hipp wrote: > On 9/21/15, Hugues Bruant wrote: > > Table schema: > > > > CREATE TABLE cv (cv_s integer not null, cv_o blob not null, cv_t integer > > not null, primary key(cv_s, cv_o)); > > > > Prepared statement: > > > > UPDATE cv SET cv_t=? where

[sqlite] CSV export CR+LF not working properly on Windows

2015-09-21 Thread Big Stone
hi all, I've been hit by this bug: http://sqlite.1065341.n5.nabble.com/new-line-now-r-n-regardless-the-OS-td77371.html I confirm that some basic export writes now to windows 7 with LF only, instead of CR+LF. I'm not against this feature, but I need also the previous behaviour. ==> could it be

[sqlite] UPDATE silently failing

2015-09-21 Thread Richard Hipp
On 9/21/15, Hugues Bruant wrote: > Table schema: > > CREATE TABLE cv (cv_s integer not null, cv_o blob not null, cv_t integer > not null, primary key(cv_s, cv_o)); > > Prepared statement: > > UPDATE cv SET cv_t=? where cv_s=? and cv_o=?; My guess is that the WHERE clause matches no rows. So it

[sqlite] UPDATE silently failing

2015-09-21 Thread Hugues Bruant
> > Ideally, open the database which exhibits the problem and first execute > > PRAGMA integrity_check; > Integrity check does not report any issue. > If this fails to show any problems run your UPDATE command, repeatedly if > necessary, and see if you can make the shell tool do anything that

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread gwenn
Thank you all for your replies. As suggested, I am going to call sqlite3_column_count each time (after the first sqlite3_step). On Mon, Sep 21, 2015 at 5:57 PM, Scott Robison wrote: > On Mon, Sep 21, 2015 at 5:48 AM, Richard Hipp wrote: > >> On 9/21/15, Dominique Devienne wrote: >> > On Sun,

[sqlite] UPDATE silently failing

2015-09-21 Thread Hugues Bruant
Table schema: CREATE TABLE cv (cv_s integer not null, cv_o blob not null, cv_t integer not null, primary key(cv_s, cv_o)); Prepared statement: UPDATE cv SET cv_t=? where cv_s=? and cv_o=?; Most of the time the row is updated as expected but in some rare cases we've seen this statement fail

[sqlite] Outdated section of docs?

2015-09-21 Thread Jonathan Moules
Hi, I was reading this page (http://sqlite.org/lang_datefunc.html), and at the very bottom it says: / / /"Non-Vista Windows platforms only support one set of DST rules. Vista only supports two. Therefore, on these platforms, historical DST calculations will be incorrect. For example,

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread Rowan Worth
On 21 September 2015 at 16:36, Simon Slavin wrote: > > On 21 Sep 2015, at 8:29am, Rowan Worth wrote: > > > 1) Statement is prepared > > 2) Statement is stepped > > 3) Statement is reset > > 4) ... time passes ... > > 5) Statement is stepped > > 6) Statement is reset > > 7) ... time passes ... >

[sqlite] Parser Grammar for MAX,MIN,SUM,COUNT,AVG functions

2015-09-21 Thread Prakash Premkumar
Thanks a lot Clemens ! Thanks a lot :) On Mon, Sep 21, 2015 at 2:58 PM, Clemens Ladisch wrote: > Prakash Premkumar wrote: > > Can you please tell me which grammar rule in parse.y file parses > aggregate > > function ? > > As you already were told, there are rules that parse _all_ functions: > >

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread Clemens Ladisch
gwenn wrote: > If there is no way to know that the statement has been recompiled, I > guess that the column count should not be cached... SQLite already caches it for you (and properly changes it when recompiling): SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt){ Vdbe

[sqlite] vdbeUnbind return occasionally Error

2015-09-21 Thread Kees Nuyt
On Mon, 21 Sep 2015 14:26:54 +0200, Shuhrat Rahimov wrote: > [...] I think I have found the problem. I do the > following: call sqlite3_bind_text() and then if successful I call > sqlite3_step() on the prepared statement and then call sqlite3_reset(). > This sequence is called 20 times as one

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread Rowan Worth
On 21 September 2015 at 14:38, Simon Slavin wrote: > As expected, ALTER TABLE acts like INSERT: it's a change which requires an > exclusive lock. So just as the documentation says, in a normal journal > mode you can't make a change while the database is locked (which it is > during a SELECT),

[sqlite] Parser Grammar for MAX,MIN,SUM,COUNT,AVG functions

2015-09-21 Thread Prakash Premkumar
Thanks a lot for your reply Ambrus. Can you please tell me which grammar rule in parse.y file parses aggregate function ? Thanks a lot for your time Prakash On Mon, Sep 21, 2015 at 2:07 PM, Zsb?n Ambrus wrote: > On Mon, Sep 21, 2015 at 9:11 AM, Prakash Premkumar > wrote: > > I'm reading the

[sqlite] vdbeUnbind return occasionally Error

2015-09-21 Thread Shuhrat Rahimov
Hello Richard, thanks for your reply. I think I have found the problem. I do the following: call sqlite3_bind_text() and then if successful I call sqlite3_step() on the prepared statement and then call sqlite3_reset(). This sequence is called 20 times as one SQL transaction. I have noticed that

[sqlite] using mprint as a global variable inside a query

2015-09-21 Thread Dominique Devienne
On Sun, Sep 20, 2015 at 6:16 PM, E.Pasma wrote: > Based on that I created function mprint() as limited version of mprintf. > It accepts no format, only a value parameter. Furthermore, if called with > no parameter at all, it returns the last printed value. > The problem with such a function is

[sqlite] Remove by name from email list

2015-09-21 Thread Simon Slavin
On 21 Sep 2015, at 1:33pm, Robert G Grieger wrote: > ___ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users To have your name removed please see the link

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread Dominique Devienne
On Sun, Sep 20, 2015 at 4:10 PM, Igor Tandetnik wrote: > On 9/20/2015 9:55 AM, gwenn wrote: > >> If there is no way to know that the statement has been recompiled, I >> guess that the column count should not be cached... >> > > You could use sqlite3_prepare (no _v2), then you'd get an error on

[sqlite] Parser Grammar for MAX,MIN,SUM,COUNT,AVG functions

2015-09-21 Thread Prakash Premkumar
Hi, I'm reading the sqlite parser grammar. I could not find the grammar rules which parses aggregate functions like MAX,MIN,SUM,COUNT,TOTAL. Can you please tell me how the aggregate functions are parsed (the grammar rule that parses them) Thanks a lot for your time Prakash

[sqlite] FTS5 returns "corrupt" plus trailing zero

2015-09-21 Thread Ralf Junker
My implementation of http://www.sqlite.org/src/artifact/400384798349d658?ln=94-96 returns "corrupt" plus a trailing zero, that is 8 characters in total. Maybe this line http://www.sqlite.org/src/artifact/4fdbc0a321e3a1d7?ln=5364 should be corrected to sqlite3Fts5BufferSet(, , 7,

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread R.Smith
On 2015-09-21 11:18 AM, Rowan Worth wrote: > On 21 September 2015 at 16:36, Simon Slavin wrote: > >> On 21 Sep 2015, at 8:29am, Rowan Worth wrote: >> >>> 1) Statement is prepared >>> 2) Statement is stepped >>> 3) Statement is reset >>> 4) ... time passes ... >>> 5) Statement is stepped >>> 6)

[sqlite] Parser Grammar for MAX,MIN,SUM,COUNT,AVG functions

2015-09-21 Thread Clemens Ladisch
Prakash Premkumar wrote: > Can you please tell me which grammar rule in parse.y file parses aggregate > function ? As you already were told, there are rules that parse _all_ functions: expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP(E). expr(A) ::= id(X) LP STAR RP(E). Due to the sharing of

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread R.Smith
On 2015-09-21 01:53 AM, Nicolas J?ger wrote: > hi, > > > Scott Robison wrote: > >> 3. Some time passes and some external process may alter the schema. >> > is it really possible ? if the answer is yes (I thought when a process open a > communication with > the DB, other processes can't alter

[sqlite] Parser Grammar for MAX,MIN,SUM,COUNT,AVG functions

2015-09-21 Thread Zsbán Ambrus
On Mon, Sep 21, 2015 at 9:11 AM, Prakash Premkumar wrote: > I'm reading the sqlite parser grammar. > > I could not find the grammar rules which parses aggregate functions like > MAX,MIN,SUM,COUNT,TOTAL. > > Can you please tell me how the aggregate functions are parsed (the grammar > rule that

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread Scott Robison
On Mon, Sep 21, 2015 at 5:48 AM, Richard Hipp wrote: > On 9/21/15, Dominique Devienne wrote: > > On Sun, Sep 20, 2015 at 4:10 PM, Igor Tandetnik > wrote: > > > >> On 9/20/2015 9:55 AM, gwenn wrote: > >> > >>> If there is no way to know that the statement has been recompiled, I > >>> guess that

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread Simon Slavin
On 21 Sep 2015, at 8:29am, Rowan Worth wrote: > 1) Statement is prepared > 2) Statement is stepped > 3) Statement is reset > 4) ... time passes ... > 5) Statement is stepped > 6) Statement is reset > 7) ... time passes ... > etc. etc. > > The assertion seems to be that if the return value of

[sqlite] vdbeUnbind return occasionally Error

2015-09-21 Thread Richard Hipp
On 9/21/15, Shuhrat Rahimov wrote: > What could I do here in order to free > memory after sqlite3_step() for further operations. https://www.sqlite.org/c3ref/db_release_memory.html -- D. Richard Hipp drh at sqlite.org

[sqlite] vdbeUnbind return occasionally Error

2015-09-21 Thread Shuhrat Rahimov
Hi all, I have ported SQLite to an embedded ARM Cortex M4 based processor. a bare metal firmware is using SQLite, no OS. It seems to work but occasionaly bindText function fails. So, I am doing 20 inserts as a one transaction, but occasionally after 400-460 inserts bindText returns Error 21. I

[sqlite] vdbeUnbind return occasionally Error

2015-09-21 Thread Richard Hipp
On 9/21/15, Shuhrat Rahimov wrote: > Hi all, > I have ported SQLite to an embedded ARM Cortex M4 based processor. a bare > metal firmware is using SQLite, no OS. It seems to work but occasionaly > bindText function fails. So, I am doing 20 inserts as a one transaction, > but occasionally after

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread Richard Hipp
On 9/21/15, Dominique Devienne wrote: > On Sun, Sep 20, 2015 at 4:10 PM, Igor Tandetnik wrote: > >> On 9/20/2015 9:55 AM, gwenn wrote: >> >>> If there is no way to know that the statement has been recompiled, I >>> guess that the column count should not be cached... >>> >> >> You could use

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread Simon Slavin
I did the experiment. I used two Terminal windows accessing the same database. It's not quite the right experiment because I can't figure out how to make the shell tool stop in the middle of a SELECT. So instead I used a transaction to keep the database locked between two SELECT commands.

[sqlite] Remove by name from email list

2015-09-21 Thread Robert G Grieger

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread Simon Slavin
On 21 Sep 2015, at 12:32am, Scott Robison wrote: > 4. Step through the prepared statement from #1 again after doing any > necessary reset. No finalize / re-prepare step. I believe that if you have done the first _step() then the SELECT will not notice any schema change until you have received

[sqlite] disable update's & delete's via triggers?

2015-09-21 Thread Simon Slavin
On 21 Sep 2015, at 12:21am, James Hartley wrote: > I am assuming that dropping the trigger > will re-enable any action which had been disabled by creating the trigger. > > Is this incorrect? Nope. That's one way to do it. Another is to set "PRAGMA recursive_triggers = OFF" then have a

[sqlite] disable update's & delete's via triggers?

2015-09-21 Thread Simon Slavin
On 21 Sep 2015, at 12:20am, Scott Robison wrote: > Then just go with something like ((rowid - rowid) <> 0). The basic premise > still holds that it should be easy to come up with a condition that is > always false. Hmm. That tells me what I should have used in the first place: WHERE 0 = 1.

[sqlite] disable update's & delete's via triggers?

2015-09-21 Thread Simon Slavin
On 20 Sep 2015, at 11:59pm, Keith Medcalf wrote: > The RowID is an integer. It is perfectly possible to have RowID's with a > value less than 0. > > sqlite> create table x(x); > sqlite> insert into x (rowid, x) values (-1, -1); > sqlite> select rowid, x from x; > -1|-1 Yep. But it's

[sqlite] Handling the whole select query from an index

2015-09-21 Thread Simon Slavin
On 20 Sep 2015, at 11:18pm, James K. Lowden wrote: > Rob Willett wrote: > >> Thanks. We?ve got 100 requests a second which may be enough. We?ll >> keep looking though for any time. > > I suppose you know that 100/sec is about 0.1% of what the machine is > capable of. SQLite is really a

[sqlite] disable update's & delete's via triggers?

2015-09-21 Thread Simon Slavin
On 20 Sep 2015, at 11:13pm, James Hartley wrote: > As I look at the flowchart for triggers at the following: > > https://www.sqlite.org/lang_createtrigger.html > > It appears that the body of a trigger must specify some kind of statement. > > I ask because I am wanting to log all activity on

[sqlite] disable update's & delete's via triggers?

2015-09-21 Thread Igor Tandetnik
On 9/20/2015 6:13 PM, James Hartley wrote: > I ask because I am wanting to log all activity on another table. I can > successfully do this with triggers. What I am curious to do is disable > UPDATE's & DELETE's on the log tables themselves. Something along these lines, perhaps: create trigger