Re: [sqlite] Transaction triggers?

2011-05-06 Thread Nico Williams
It took just a few minutes to start on that approach. I have the necessary parse.y changes done and know what to do for the rest. Time to subscribe to sqlite-dev... ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mai

Re: [sqlite] Transaction triggers?

2011-05-06 Thread Nico Williams
BTW, I might implement and contribute something like this. I'm free to contribute any changes to SQLite3 that I make. I'd need some guidance though. And what I cannot contribute is the high degree of testing that SQLite3 is known for. The parsing aspect of database triggers is simple enough. B

Re: [sqlite] Transaction triggers?

2011-05-06 Thread Nico Williams
On Fri, May 6, 2011 at 4:30 PM, Simon Slavin wrote: > On 6 May 2011, at 10:14pm, Nico Williams wrote: >> Here's what I need: >> >> - at transaction time I need a way to record somewhere that the >> transaction did start.  This would mostly be an insert into a tabl

[sqlite] Transaction triggers?

2011-05-06 Thread Nico Williams
I really, really need transaction, not row, triggers. There's been discussion of those here in the past (IIRC D.R. Hipp had a proposal once). Here's what I need: - at transaction time I need a way to record somewhere that the transaction did start. This would mostly be an insert into a table w

Re: [sqlite] ADV: "Using SQLite" ebook, 50% off today

2011-05-03 Thread Nico Williams
On Tue, May 3, 2011 at 11:20 AM, Simon Slavin wrote: > On 3 May 2011, at 5:09pm, Jay A. Kreibich wrote: > >>  "Using SQLite" is today's "Ebook Deal of the Day" over at O'Reilly >>  Media.  Today only (Tuesday, May 3rd) the ebook is 50% off, at >>  $15.99. > > Well I don't know, Jay.  Have you read

Re: [sqlite] sha256sum function

2011-04-30 Thread Nico Williams
On Sat, Apr 30, 2011 at 3:19 PM, Mike Power wrote: > Does this exist in sqlite, my searching seems to indicate no.  Sqlite Right, SQLite3 doesn't ship with such a function. > has the ability to import functions has someone already done the work to > import a sha256sum function?  How is that done

Re: [sqlite] Clarification of ON CONFLICT in trigger bodies?

2011-04-30 Thread Nico Williams
A quick test shows that, indeed, an INSERT OR IGNORE inside a trigger that fails will not be ignored if the top-level statement has an OR ABORT (or rollback, or fail) clause. I can't imagine why one would ever want such behavior, but since I can live with it (as shown below), I'll just conclude th

[sqlite] Clarification of ON CONFLICT in trigger bodies?

2011-04-29 Thread Nico Williams
Long ago I noticed that the lang_createtrigger page says: "An ON CONFLICT clause may be specified as part of an UPDATE or INSERT action within the body of the trigger. However if an ON CONFLICT clause is specified as part of the statement causing the trigger to fire, then conflict handling policy

Re: [sqlite] vacuum and rowids

2011-04-29 Thread Nico Williams
On Thu, Apr 28, 2011 at 5:20 PM, Dave Hayden wrote: > On Apr 28, 2011, at 12:41 PM, Pavel Ivanov wrote: >>> After more poking, it appears that rowids might not be changed by a vacuum >>> if I have an index on the table. Is this true? If so, is it something I can >>> rely on going forward? >> >>

Re: [sqlite] group_concat(... ORDER BY ...)

2011-04-25 Thread Nico Williams
On Mon, Apr 25, 2011 at 8:35 AM, Petite Abeille wrote: > On Apr 25, 2011, at 7:57 AM, Nico Williams wrote: >> For group_concat(), however, this undefined order is >> obnoxious. > > Seconded. As it stands, group_concat nondeterministic nature renders it > useless for mos

[sqlite] group_concat(... ORDER BY ...)

2011-04-24 Thread Nico Williams
As you might know, SQLite3 does not define the order in which aggregate functions are applied to the values to be aggregated. For traditional aggregation functions (min(), max(), ...) this makes perfect sense. For group_concat(), however, this undefined order is obnoxious. Apparently MySQL has s

Re: [sqlite] Persistently setting certain PRAGMAs (foreign_keys, recursive_triggers)

2011-04-17 Thread Nico Williams
On Sun, Apr 17, 2011 at 11:44 AM, Petite Abeille wrote: > On Apr 17, 2011, at 6:33 PM, Nico Williams wrote: >> Now, it's true that that's expected, but if all the application >> "business" logic can be encoded in table constraints, indexes and >> triggers

Re: [sqlite] Persistently setting certain PRAGMAs (foreign_keys, recursive_triggers)

2011-04-17 Thread Nico Williams
On Sun, Apr 17, 2011 at 3:36 AM, Kees Nuyt wrote: >> Is there any way to persistently set certain PRAGMAs, so that they >> need not be set every time a DB handle is opened? > > Many PRAGMA default valuess can be influenced using compiler flags > SQLITE_DEFAULT_* . I was mildly aware of those, but

[sqlite] Persistently setting certain PRAGMAs (foreign_keys, recursive_triggers)

2011-04-16 Thread Nico Williams
Is there any way to persistently set certain PRAGMAs, so that they need not be set every time a DB handle is opened? Thanks, Nico -- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] Pretty schema ?

2011-04-13 Thread Nico Williams
I've found pretty printers online and what not, but there seem to be as many styles of pretty printing SQL as there are RDBMSes, and most are awful to my eyes. What might be nice is an external pretty-printer that you could pipe the schema (and dump) to. Nico -- __

Re: [sqlite] IF-THEN-ELSE sqlite

2011-04-04 Thread Nico Williams
On Mon, Apr 4, 2011 at 12:26 PM, Simon Slavin wrote: > But he's combining two INSERTs into one.  What I think he needs is first an > INSERT OR FAIL to possibly add a new person, and then an INSERT ... SELECT > which looks up that person's ID. I didn't see that in the original post. Did I miss

Re: [sqlite] IF-THEN-ELSE sqlite

2011-04-04 Thread Nico Williams
On Mon, Apr 4, 2011 at 11:25 AM, Simon Slavin wrote: > Probably not.  Don't try to turn SQL into a procedural language.  Do the > SELECT that tells you whether the record exists and gives you the information > you need if it does, then do whatever INSERTs you need to do. I agree with the first

Re: [sqlite] FTS4 bug in last_insert_rowid()

2011-04-04 Thread Nico Williams
On Mon, Apr 4, 2011 at 9:10 AM, Enrico Thierbach wrote: > I might have an exceptionally dumb day, but this sequence (from this post > http://www.mail-archive.com/sqlite-users@sqlite.org/msg34082.html ) looks > totally fine: You're missing something: FTS4 is a virtual table and it re-enters SQLi

Re: [sqlite] FTS4 bug in last_insert_rowid()

2011-04-04 Thread Nico Williams
On Mon, Apr 4, 2011 at 6:43 AM, Enrico Thierbach wrote: > Is this really a bug? I at least wouldn't expect last_insert_rowid to be > constant if the database gets modified. If you read the post that Simon referenced you'll see that the caller typically wants to know the row ID of the last row ex

Re: [sqlite] IF-THEN-ELSE sqlite

2011-04-03 Thread Nico Williams
On Sun, Apr 3, 2011 at 3:49 AM, Marcelo S Zanetti wrote: > IF 1==SELECT COUNT(*) from table > WHERE item==new THEN SELECT itemID from tabel WHERE item==new ELSE > INSERT INTO table (item) VALUES (new) INSERT INTO t (item) SELECT :new WHERE NOT EXISTS (SELECT item FROM t WHERE item = :new); Here

Re: [sqlite] WAL checkpoints not working

2011-03-31 Thread Nico Williams
On Thu, Mar 31, 2011 at 3:48 PM, Richard Hipp wrote: > On Thu, Mar 31, 2011 at 4:44 PM, Dave White wrote: >> Any ideas why this would happen? > > You have a read transaction being held open.  The checkpoint cannot run to > completion when there is a read transaction open.  (It does as much as it >

Re: [sqlite] What foolproof strategies for database file non-corruption are there, as regards app and OS crashes (not hardware) when in WAL mode?

2011-03-30 Thread Nico Williams
On Wed, Mar 30, 2011 at 8:53 AM, Simon Slavin wrote: > On 30 Mar 2011, at 1:46pm, Mikael wrote: >> If yes, we have the solution needed already now - app/OS crashes won't crash >> the database, and rsync backups will create working backups even if made >> during checkpoints. > > But killing the pow

Re: [sqlite] Update trigger

2011-03-29 Thread Nico Williams
On Tue, Mar 29, 2011 at 11:32 AM, Simon Slavin wrote: > On 29 Mar 2011, at 4:12pm, Sutter, Doug wrote: >> I know how to create a unique trigger for each column where I hard-code >> the column's name as shown below.  But I would like to create a trigger >> that would fire when any column is updated

Re: [sqlite] Lack of "decimal" support

2011-03-28 Thread Nico Williams
On Mar 27, 2011 10:20 PM, "Darren Duncan" wrote: > > Nico Williams wrote: > > User defined types. There are two types in particular that I'd like > > to see added: > > > > - Bit strings. Bit strings are like character strings, but the > > ele

Re: [sqlite] Lack of "decimal" support

2011-03-27 Thread Nico Williams
On Sun, Mar 27, 2011 at 10:20 PM, Darren Duncan wrote: > Nico Williams wrote: >> User defined types.  There are two types in particular that I'd like >> to see added: >> >>  - Bit strings.  Bit strings are like character strings, but the >> elements can onl

Re: [sqlite] SQLite & NHibernate

2011-03-27 Thread Nico Williams
On Sat, Mar 26, 2011 at 8:56 PM, Patrick Earl wrote: > 1.  Support for a base-10 numeric data type. Looking at the wikipedia page for NHibernate it seems that you don't export a SQL interface -- all SQL is generated. So, given that, you should be able to generate SQLite3 statements that use user

Re: [sqlite] Lack of "decimal" support

2011-03-27 Thread Nico Williams
On Sun, Mar 27, 2011 at 11:33 AM, jeff archer wrote: >>From: Patrick Earl >>Subject: Re: [sqlite] Lack of "decimal" support >> >>If SQLite can't decide on a base-10 format itself, perhaps the answer >>lies in enhancing the API to allow for custom type storage and >>operators. > > So, like a virtu

Re: [sqlite] storing big numbers into NUMERIC, DECIMAL columns

2011-03-23 Thread Nico Williams
On Wed, Mar 23, 2011 at 1:30 PM, Igor Tandetnik wrote: > On 3/23/2011 1:46 PM, TR Shaw wrote: >> Current US national debt is 16 digits. > > A 64-bit unsigned integer can represent about $18 trillion, in > millionths of a dollar. This should have both range and accuracy to > spare, for most applica

Re: [sqlite] adding/dropping foreign key to existing table

2011-03-23 Thread Nico Williams
Also, just to be clear, making the schema writable and then making any updates to sqlite_master is completely unsupported, and should be. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] adding/dropping foreign key to existing table

2011-03-23 Thread Nico Williams
I do think that SQLite3 will eventually need to grow ALTER support for altering constraints. This whole copy-the-table thing is not really a scalable solution. Without such ALTER functionality users will often have to implement all constraints as triggers and/or unique indexes instead of using co

Re: [sqlite] storing big numbers into NUMERIC, DECIMAL columns

2011-03-22 Thread Nico Williams
You can store any big-number representation you like as TEXT or BLOB values. The main issue is that you'll lose syntactic sugar: SQLite3 won't be able to treat those as numeric values, therefore it won't be able to compare numerically nor use arithmetic with such values. You can get some of that

Re: [sqlite] sqlite-users Digest, Vol 39, Issue 13

2011-03-13 Thread Nico Williams
On Sun, Mar 13, 2011 at 10:31 AM, Igor Tandetnik wrote: > Garry Watkins wrote: >> Not sure why you are using a subselect with a union all. >> >> SELECT * >>  FROM multiturnTable >> WHERE (player1 ='?' OR player2 ='?') > > Because OR prevents SQLite from using an index on either player1 or player2

Re: [sqlite] Implementing sequence nextval in sqlite

2011-03-08 Thread Nico Williams
On Tue, Mar 8, 2011 at 9:36 AM, Simon Slavin wrote: > Yes.  Is there any reason why you don't use your own sequences instead of > relying on SQLite's functions ?  You could simply use something like > max(id)+1 . Without speaking for the OP, sequences are state that changes when read, thus your

Re: [sqlite] Implementing sequence nextval in sqlite

2011-03-08 Thread Nico Williams
On Tue, Mar 8, 2011 at 8:25 AM, Jay A. Kreibich wrote: > On Tue, Mar 08, 2011 at 12:01:03AM -0800, Roger Binns scratched on the wall: >> On 03/07/2011 09:53 PM, RAKESH HEMRAJANI wrote: >> > Probleme statement is : >> > I want to implement nextval keyword in sqlite >> >> There are two separate issu

Re: [sqlite] Implementing sequence nextval in sqlite

2011-03-08 Thread Nico Williams
On Mon, Mar 7, 2011 at 11:53 PM, RAKESH HEMRAJANI wrote: > I am newbie to sqlite, have started understanding the code, at the moment m > stuck and not able to understand how to generate byte code Depending on how strongly wedded you are to syntax, you might be able to avoid VDBE code generation.

Re: [sqlite] Adjusting strategy for ROWIDs

2011-03-04 Thread Nico Williams
On Fri, Mar 4, 2011 at 7:18 PM, Enrico Thierbach wrote: > On 04.03.2011, at 22:21, Drake Wilson wrote: >> Why do you want to do this?  In particular, why would it not work to >> randomize the values from the application side during inserts? > I am trying to build a solution where two or more data

Re: [sqlite] "select disctict" calles tcl functions twice?

2011-02-28 Thread Nico Williams
On Mon, Feb 28, 2011 at 6:23 PM, John wrote: > Reading a little more about how the vdbe works and a little of the source > code, I then examined the output of explain.  Explain shows that the > statement: > >        select distinct x, abs(x) from T ; > > First loops over my T table and builds an

Re: [sqlite] COUNT() extremely slow first time!

2011-02-27 Thread Nico Williams
On Sun, Feb 27, 2011 at 3:11 PM, Max Vlasov wrote: > Hmm, yesterday something struck me I can do similar tests on an Asus T91MT > having SSD as the storage. I got similar timings to Greg's. So it seems like > page size is a very sensitive parameter for solid state drives. Looks like > having the p

Re: [sqlite] How to use sqlite and pthread together?

2011-02-23 Thread Nico Williams
On Sun, Feb 20, 2011 at 6:36 PM, Samuel Adam wrote: > On Sun, 20 Feb 2011 14:46:06 -0500, Nico Williams > wrote: > I appreciate your extensive (if wildly offtopic) analysis as quoted > below.  You thoroughly misunderstood what I said, though.  Again, my > fork()/exec() comment

Re: [sqlite] SQLite and SIGFPE

2011-02-20 Thread Nico Williams
On Sun, Feb 20, 2011 at 6:24 AM, Samuel Adam wrote: > I’m not writing anything multithreaded right now.  But next month or next > year, the humble little SQL user functions I now make could grow up and > get plugged into something bigger.  And before I longjmp(), I like to know > with certainty wh

Re: [sqlite] How to use sqlite and pthread together?

2011-02-20 Thread Nico Williams
On Sun, Feb 20, 2011 at 6:28 AM, Samuel Adam wrote: > On Sat, 19 Feb 2011 17:12:31 -0500, Pavel Ivanov > wrote: > >> [snip] On >> Windows it’s different - process is much more heavy-weight object than >> thread and involves much bigger system load to support it. There’s an >> official general adv

Re: [sqlite] How to use sqlite and pthread together?

2011-02-19 Thread Nico Williams
Pavel, I am fully aware of clone(2). But clone() is not standard, and the modern Linux pthreads implementation is faithful to the pthreads specification. POSIX threads are schedulable threads of execution that share a process' address space. I will grant that my advice regarding vfork() is based

Re: [sqlite] SQLite and SIGFPE

2011-02-18 Thread Nico Williams
On Fri, Feb 18, 2011 at 9:32 PM, Roger Binns wrote: > On 02/18/2011 07:03 PM, Nico Williams wrote: >> BUT, because SIGFPE is a synchronous >> signal so you are on much firmer ground: you can't block it, > > Incidentally you can block it sometimes but the mechanism

Re: [sqlite] SQLite and SIGFPE

2011-02-18 Thread Nico Williams
If you know what you are doing, threads are fine. As you know, async signal handling and threading don't mix well, BUT, because SIGFPE is a synchronous signal so you are on much firmer ground: you can't block it, but since it is synchronous you can lexically determine where it might be generated a

Re: [sqlite] How to use sqlite and pthread together?

2011-02-18 Thread Nico Williams
On Feb 18, 2011 6:16 PM, "Samuel Adam" wrote: > FYI, Windows NT is documented to have light threads and heavy processes. Windows and Unix processes and threads have similar semantics, and thus roughly comparable performance envelopes. > To my knowledge, it just was not designed with the goal of

Re: [sqlite] Bi-directional unique

2011-02-09 Thread Nico Williams
On Wed, Feb 9, 2011 at 2:00 PM, Nico Williams wrote: > This way an insert into t requires one lookup and update in t_idx and > one lookup and update in the table's implied rowid index.  I.e., twice > the work of an insert without this additional index and trigger. Also, you get

Re: [sqlite] Bi-directional unique

2011-02-09 Thread Nico Williams
sqlite> create table t(n integer not null check (typeof(n) = 'integer'), m integer not null check (typeof(m) = 'integer')); sqlite> create index t_idx on t (n, m); sqlite> explain query plan select count(*) != 0 from t t2 where t2.n = ? and t2.m = ?; 0|0|TABLE t AS t2 WITH INDEX t_idx sqlite> creat

Re: [sqlite] Surprising profiling results

2011-02-08 Thread Nico Williams
On Tue, Feb 8, 2011 at 9:12 AM, Ian Hardingham wrote: > Wow - changing to that in combination with indexes on player1 and > player2 has dropped the time to 25 and 10 - an incredible improvement. > > I'll need to get my head around using combinations of queries which each > only use indexed columns

<    1   2   3   4   5