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

2015-09-20 Thread James Hartley
I appreciate the discussion thus far. I tried the following syntax: CREATE TRIGGER update_history_table_trigger INSTEAD OF UPDATE ON history_table BEGIN UPDATE history_table SET new_value = 1 WHERE 0 = 1; END ; CREATE TRIGGER delete_history_table_trigger INSTEAD OF DELETE ON history_table BEGIN

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

2015-09-20 Thread Nicolas Jäger
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 the DB), for me that would mean that the design(s) of the

[sqlite] I don't understand how to use NOT EXISTS

2015-09-20 Thread Simon Slavin
On 20 Sep 2015, at 7:15pm, James K. Lowden wrote: > Simon Slavin wrote: > >> Constructions like this >> >>> INSERT INTO _TAG_EXISTS_RESULT_ ( NAME, BOOL ) >>> SELECT 'evil little sister' >> >> should be rewritten so that you are not trying to do a SELECT in the >> middle of your INSERT. >

[sqlite] I don't understand how to use NOT EXISTS

2015-09-20 Thread James K. Lowden
On Sun, 20 Sep 2015 19:33:35 +0100 Simon Slavin wrote: > On 20 Sep 2015, at 7:15pm, James K. Lowden > wrote: > > > Simon Slavin wrote: > > > >> Constructions like this > >> > >>> INSERT INTO _TAG_EXISTS_RESULT_ ( NAME, BOOL ) > >>> SELECT 'evil little sister' > >> > >> should be rewritten

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

2015-09-20 Thread James Hartley
On Sun, Sep 20, 2015 at 5:20 PM, Simon Slavin wrote: > > Then your next concern is over how to zero-out the log if you really > needed to do that. > > That is a valid concern, however, I am assuming that dropping the trigger will re-enable any action which had been disabled by creating the

[sqlite] Handling the whole select query from an index

2015-09-20 Thread James K. Lowden
On Sat, 19 Sep 2015 14:24:24 +0100 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. You spoke of read-only data that changes

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

2015-09-20 Thread E.Pasma
Here is still a follow up of last weeks discussion "Worked in 3.8.9 but no longer in .." which is about the following case: a large table includes a datetime field. From the points in time one wants to report time intervals (from - to). The datetime field is indexed. The fastest solution that

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

2015-09-20 Thread Scott Robison
On Sun, Sep 20, 2015 at 5:53 PM, 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

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

2015-09-20 Thread Scott Robison
On Sun, Sep 20, 2015 at 5:47 PM, Simon Slavin wrote: > > 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

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

2015-09-20 Thread Keith Medcalf
Not really. Normal increment of the rowid increments by 1: sqlite> create table x(x); sqlite> insert into x (rowid, x) values (-100, 1); sqlite> insert into x values (2); sqlite> insert into x values (3); sqlite> insert into x values (4); sqlite> select rowid, x from x; -100|1 -99|2

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

2015-09-20 Thread Scott Robison
On Sun, Sep 20, 2015 at 8:11 AM, Simon Slavin wrote: > > On 20 Sep 2015, at 2:55pm, gwenn wrote: > > > But if a column is added to one table in your database, your statement > > is successfully/transparently recompiled (when calling sqlite3_step) > > and the column count may be changed. > >

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

2015-09-20 Thread Scott Robison
On Sun, Sep 20, 2015 at 5:18 PM, Simon Slavin wrote: > > 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] disable update's & delete's via triggers?

2015-09-20 Thread James Hartley
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 another table. I can successfully do this with triggers. What I

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

2015-09-20 Thread Keith Medcalf
> You can create TRIGGERs which operate BEFORE, AFTER or INSTEAD OF. So > perhaps just create an INSTEAD OF trigger which does nothing. Perhaps a > SELECT command or a DELETE command with a WHERE clause which is never > satisfied (e.g. rowid < 0). The RowID is an integer. It is perfectly

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

2015-09-20 Thread gwenn
Sorry for my bad description. Imagine that you have a cache of statements (like in tclsqlite.c) created using sqlite3_prepare_v2. And you want to avoid calling sqlite3_column_count/sqlite3_column_name each time you reuse (sqlite3_step) the same statement (with Java (JNI) or Go (cgo), a native call

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

2015-09-20 Thread Simon Slavin
On 20 Sep 2015, at 2:55pm, gwenn wrote: > But if a column is added to one table in your database, your statement > is successfully/transparently recompiled (when calling sqlite3_step) > and the column count may be changed. Let's assume that you have not used any PRAGMAs to defeat the

[sqlite] I don't understand how to use NOT EXISTS

2015-09-20 Thread James K. Lowden
On Wed, 16 Sep 2015 08:23:04 +1000 Barry Smith wrote: > As for your original query: think about just the select clause (you > can run it independently). This will return ('magnetohydrodynamics', > 1) for each row in the table. It took me a bit to understand what you meant. I also think

[sqlite] I don't understand how to use NOT EXISTS

2015-09-20 Thread James K. Lowden
On Wed, 16 Sep 2015 19:40:23 +0100 Simon Slavin wrote: > Constructions like this > > > INSERT INTO _TAG_EXISTS_RESULT_ ( NAME, BOOL ) > > SELECT 'evil little sister' > > should be rewritten so that you are not trying to do a SELECT in the > middle of your INSERT. Why in the world would you

[sqlite] Fwd: OT: Oracle functions for SQlite

2015-09-20 Thread John G
On 13 September 2015 at 10:06, Domingo Alvarez Duarte < sqlite-mail at dev.dadbiz.es> wrote: > Hello ! > > Due the way sqlite manages it's source code (with fossil-scm) I propose to > anyone that has any extension/custom sqlite code fork this project on > github: > > >

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

2015-09-20 Thread Igor Tandetnik
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 schema change. You would then re-prepare the statement and update