[sqlite] Infinity

2009-10-16 Thread Dan Bishop
I've noticed that I can use IEEE Infinity values in SQLite by writing any literal too big for a double. sqlite> CREATE TABLE foo (x REAL); sqlite> INSERT INTO foo VALUES (9e999); -- +Inf sqlite> INSERT INTO foo VALUES (-9e999); -- -Inf sqlite> INSERT INTO foo VALUES (9e999 / 9e999); -- NaN: gets

Re: [sqlite] sparse matrix in scientific computing with sqlite

2009-10-16 Thread Dan Bishop
Michael Chen wrote: > --this is my first version for the purpose of storing sparse numerical > matrix in sql > --please let me know how to fix the bug at the end of the file, and how to > tune the performance > --or any better reference, thanks! > > .explain-- return

Re: [sqlite] DIVIDE (was Re: INTERSECT?)

2009-10-16 Thread Jay A. Kreibich
On Fri, Oct 16, 2009 at 05:34:02PM -0700, Darren Duncan scratched on the wall: > I believe what you are looking for is the relational operator called DIVIDE, Yes, this is a text-book example of a Relational "divide." If you have a table with a key column and an attribute column, and you want

Re: [sqlite] INTERSECT?

2009-10-16 Thread Dan Bishop
P Kishor wrote: > I don't even know how to title this post, and it just might be > something very obvious. Either way, I apologize in advance. Consider > the following -- > > sqlite> SELECT * FROM foo; > a b > -- -- > 1 6 > 2 6 > 2 3 > 3

[sqlite] DIVIDE (was Re: INTERSECT?)

2009-10-16 Thread Darren Duncan
I believe what you are looking for is the relational operator called DIVIDE, which is one of the original ones that E. F. Codd defined (along with (natural inner) JOIN, UNION, MINUS, PROJECT, RESTRICT, etc) but that very few if any SQL DBMSs actually implement directly, which is a crying shame.

Re: [sqlite] INTERSECT?

2009-10-16 Thread Igor Tandetnik
P Kishor wrote: > I want the values of ‘a’ for which ‘b’ = 3 AND ‘b’ = 4 (This is just > an example. In reality, b could be any set of numbers, not just two > numbers). To illustrate -- > sqlite> SELECT * FROM foo WHERE b = 3; > a b > -- -- > 2 3 > 3

[sqlite] INTERSECT?

2009-10-16 Thread P Kishor
I don't even know how to title this post, and it just might be something very obvious. Either way, I apologize in advance. Consider the following -- sqlite> SELECT * FROM foo; a b -- -- 1 6 2 6 2 3 3 3 3 4 3 5 4

Re: [sqlite] sparse matrix in scientific computing with sqlite

2009-10-16 Thread Michael Chen
yes, that's what I am thinking of too. This big table is in charge of store all matrix, keep track of all index changes, and rollback when needed. I will only extract a tiny part from this big table in format like a sparse matrix, and put it in C array, then the available numerical routines, such a

Re: [sqlite] sparse matrix in scientific computing with sqlite

2009-10-16 Thread Stephan Wehner
On Fri, Oct 16, 2009 at 1:41 PM, Michael Chen wrote: > rdbms is indeed not a place for store a single sparse matrix like this. > However I have hundreds of them, and I need to break them and recombine them > frequently; furthermore, I need to drop a few rows or columns successively, > and need to

Re: [sqlite] sparse matrix in scientific computing with sqlite

2009-10-16 Thread Michael Chen
rdbms is indeed not a place for store a single sparse matrix like this. However I have hundreds of them, and I need to break them and recombine them frequently; furthermore, I need to drop a few rows or columns successively, and need to be able to trace back what's a row's original index. I think s

Re: [sqlite] sparse matrix in scientific computing with sqlite

2009-10-16 Thread Michael Chen
thanks Pavel ! On Fri, Oct 16, 2009 at 1:24 PM, Pavel Ivanov wrote: > > -- IA = [ 1 3 5 7 ] // IA(i) = Index of the first nonzero element > of > > row i in A > > Why 4th element if A has only 3 rows? > > > create temp view rowwiseC as > > select a1.rowid, sum(a2.ct) +1 as JA > > from rowwi

Re: [sqlite] Why FTS3 has the limitations it does

2009-10-16 Thread P Kishor
On Fri, Oct 16, 2009 at 3:12 PM, Scott Hess wrote: > On Wed, Oct 14, 2009 at 11:35 PM, John Crenshaw > wrote: >> The severe limitations on FTS3 seemed odd to me, but I figured I could >> live with them. Then I starting finding that various queries were giving >> strange "out of context" errors wi

Re: [sqlite] suggestions for avoiding "database locked" on ajax

2009-10-16 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 P Kishor wrote: > So, what suggestion might you all have for getting around this? Why not set a busy timeout? Roger -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAR

Re: [sqlite] suggestions for avoiding "database locked" on ajax

2009-10-16 Thread P Kishor
On Fri, Oct 16, 2009 at 3:09 PM, Stephan Wehner wrote: > On Fri, Oct 16, 2009 at 12:58 PM, Simon Slavin > wrote: >> >> On 16 Oct 2009, at 8:53pm, P Kishor wrote: >> >>> If neither the username nor the email exist in the db, then the >>> application creates a record and informs the user of success

Re: [sqlite] Why FTS3 has the limitations it does

2009-10-16 Thread Scott Hess
On Wed, Oct 14, 2009 at 11:35 PM, John Crenshaw wrote: > The severe limitations on FTS3 seemed odd to me, but I figured I could > live with them. Then I starting finding that various queries were giving > strange "out of context" errors with the MATCH operator, even though I > was following all th

Re: [sqlite] suggestions for avoiding "database locked" on ajax

2009-10-16 Thread Stephan Wehner
On Fri, Oct 16, 2009 at 12:58 PM, Simon Slavin wrote: > > On 16 Oct 2009, at 8:53pm, P Kishor wrote: > >> If neither the username nor the email exist in the db, then the >> application creates a record and informs the user of success. Except, >> the previous ajax request (I am assuming it is the p

Re: [sqlite] suggestions for avoiding "database locked" on ajax

2009-10-16 Thread Simon Slavin
On 16 Oct 2009, at 8:53pm, P Kishor wrote: > If neither the username nor the email exist in the db, then the > application creates a record and informs the user of success. Except, > the previous ajax request (I am assuming it is the previous ajax > request from onblur event from the email field)

[sqlite] suggestions for avoiding "database locked" on ajax

2009-10-16 Thread P Kishor
Yes, I know, if it "hurts when I press here," then I shouldn't "press here," but, so it goes... I have an account creation form -- users enter their email and their desired username, and the form -- onblur from the username field, sends off an ajax request to see if the desired username already e

Re: [sqlite] sparse matrix in scientific computing with sqlite

2009-10-16 Thread Pavel Ivanov
> -- IA = [ 1 3 5 7 ] // IA(i) = Index of the first nonzero element of > row i in A Why 4th element if A has only 3 rows? > create temp view rowwiseC as > select a1.rowid, sum(a2.ct) +1 as JA > from rowwiseB a1, rowwiseB a2 > where a2.rowid < a1.rowid > group by a1.rowid > ; > --this is not

Re: [sqlite] sparse matrix in scientific computing with sqlite

2009-10-16 Thread P Kishor
This is not the answer you are looking for, and there are SQL geniuses on this list who will help you better, but really, is an rdbms really a good place to store a matrix the way you are trying to do? So convoluted. My approach, if I really was determined to store it in sqlite, would be to flatte

[sqlite] sparse matrix in scientific computing with sqlite

2009-10-16 Thread Michael Chen
--this is my first version for the purpose of storing sparse numerical matrix in sql --please let me know how to fix the bug at the end of the file, and how to tune the performance --or any better reference, thanks! .explain-- return result in more readable format .

Re: [sqlite] Fwd: Best Query And Index Structure

2009-10-16 Thread Brad Phelan
On Fri, Oct 16, 2009 at 3:07 PM, Pavel Ivanov wrote: > Yes, that's right. > Ta for the help. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] Fwd: Best Query And Index Structure

2009-10-16 Thread Pavel Ivanov
Yes, that's right. Pavel On Fri, Oct 16, 2009 at 9:05 AM, Brad Phelan wrote: > On Fri, Oct 16, 2009 at 2:48 PM, Pavel Ivanov wrote: >> Yes, pretty interesting results. I didn't expect that. :) >> Query plan seems to suggest that SQLite executes query not in the way >> you said but first takes t

Re: [sqlite] Fwd: Best Query And Index Structure

2009-10-16 Thread Brad Phelan
On Fri, Oct 16, 2009 at 2:48 PM, Pavel Ivanov wrote: > Yes, pretty interesting results. I didn't expect that. :) > Query plan seems to suggest that SQLite executes query not in the way > you said but first takes tit table, joins epgdata to it and then joins > tit1 and tit2 to it. So it should be e

Re: [sqlite] Fwd: Best Query And Index Structure

2009-10-16 Thread Pavel Ivanov
Yes, pretty interesting results. I didn't expect that. :) Query plan seems to suggest that SQLite executes query not in the way you said but first takes tit table, joins epgdata to it and then joins tit1 and tit2 to it. So it should be executed faster than you thought... I've played with your quer

Re: [sqlite] Fwd: Best Query And Index Structure

2009-10-16 Thread Brad Phelan
On Fri, Oct 16, 2009 at 2:08 PM, Brad Phelan wrote: > On Fri, Oct 16, 2009 at 1:39 PM, Pavel Ivanov wrote: >>> So if >>> x has a very large range and a small probability of a match then >>> we still have to do a full scan of 10,000 rows of A. >>> >>> Is there a better way to construct the query a

Re: [sqlite] Fwd: Best Query And Index Structure

2009-10-16 Thread Brad Phelan
>> So if >> x has a very large range and a small probability of a match then >> we still have to do a full scan of 10,000 rows of A. >> >> Is there a better way to construct the query and or indexes so >> the result is faster. > > If your x has a small selectivity in B disregarding of A, i.e. for >

Re: [sqlite] Fwd: Best Query And Index Structure

2009-10-16 Thread Brad Phelan
On Fri, Oct 16, 2009 at 1:39 PM, Pavel Ivanov wrote: >> So if >> x has a very large range and a small probability of a match then >> we still have to do a full scan of 10,000 rows of A. >> >> Is there a better way to construct the query and or indexes so >> the result is faster. > > If your x has

Re: [sqlite] Fwd: Best Query And Index Structure

2009-10-16 Thread Pavel Ivanov
> So if > x has a very large range and a small probability of a match then > we still have to do a full scan of 10,000 rows of A. > > Is there a better way to construct the query and or indexes so > the result is faster. If your x has a small selectivity in B disregarding of A, i.e. for each x you

Re: [sqlite] keyword BEGIN in trigger statement

2009-10-16 Thread Pavel Ivanov
> Does the BEGIN start a transaction? No. Triggers work inside transactions that called them. Pavel On Fri, Oct 16, 2009 at 5:22 AM, Wenton Thomas wrote: > For example, > > > CREATE TRIGGER update_customer_address UPDATE OF address ON customers >  BEGIN >    UPDATE orders SET address = new.add

Re: [sqlite] Exception writing to database from multiple processes

2009-10-16 Thread Pavel Ivanov
> Therefore, SQLite > returns SQLITE_BUSY for the first process, hoping that this will > induce the first process to release its read lock and allow the > second process to proceed. [snip] > In short, you can poke at a SQLITE_BUSY state for a bit, but fairly > soon you should give

Re: [sqlite] sqlite-3.6.18: Segmentation fault on SQL INSERT.

2009-10-16 Thread Dan Kennedy
On Oct 16, 2009, at 2:53 PM, Vladimir Looze wrote: > Sqlite causes Segmentation fault on SQL insert. > > Steps to reproduce: > 1. create database with following schema (table/column names dosen't > matter) > > - BEGIN OF SQL LISTING > create table tname ( id integer not null primary key asc

Re: [sqlite] Help-using Case in query

2009-10-16 Thread dave lilley
how about this select * from TestName where History > 399 and History < 501 the above SQL is saying (in laymans terms) >From the table TestName gather all the column data and display ONLY those rows where data in History column is greater than 399 and is below 501. _OR_ Select ONLY those r

[sqlite] Fwd: Best Query And Index Structure

2009-10-16 Thread Brad Phelan
Hi all, I am curious on how to design a schema and indexes to best fit the following pattern. My data is tree like and stored normalized in the database. CREATE TABLE A    ( id INTEGER PRIMARY    ) CREATE TABLE B    ( id INTEGER PRIMARY    , A_ID  INTEGER       # Foreign key to A    , x     INTE

[sqlite] keyword BEGIN in trigger statement

2009-10-16 Thread Wenton Thomas
For example, CREATE TRIGGER update_customer_address UPDATE OF address ON customers BEGIN UPDATE orders SET address = new.address WHERE customer_name = old.name; END; when updating address ON customers, then follow a BEGIN ...END statement. Does the BEGIN start a transaction?

[sqlite] sqlite-3.6.18: Segmentation fault on SQL INSERT.

2009-10-16 Thread Vladimir Looze
Sqlite causes Segmentation fault on SQL insert. Steps to reproduce: 1. create database with following schema (table/column names dosen't matter) - BEGIN OF SQL LISTING create table tname ( id integer not null primary key asc autoincrement, cname string ); create table surname ( id inte

Re: [sqlite] Exception writing to database from multiple processes

2009-10-16 Thread David Carter
Thanks everyone for your suggestions. The locking was caused by not resetting / finalizing the statements in my transactions. Thanks again, David -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of John Crenshaw Sent: Friday,

Re: [sqlite] length() behaviors on Mac osx

2009-10-16 Thread Michael Chen
yes, you are right. I'd better to go to sleep now -:) On Fri, Oct 16, 2009 at 2:23 AM, P Kishor wrote: > On Fri, Oct 16, 2009 at 1:42 AM, Michael Chen > wrote: > > select *, (length(path) - length( replace(path, '/','' )) +1 ) > > sqlite> SELECT length('/1/2/5/'); > 7 > sqlite> SELECT replace(

Re: [sqlite] length() behaviors on Mac osx

2009-10-16 Thread P Kishor
On Fri, Oct 16, 2009 at 1:42 AM, Michael Chen wrote: > select *, (length(path) - length( replace(path, '/','' )) +1 ) sqlite> SELECT length('/1/2/5/'); 7 sqlite> SELECT replace('/1/2/5/', '/', ''); 125 sqlite> SELECT length('125'); 3 7 - 3 = 4 4 + 1 = 5 sqlite> SELECT (length('/1/2/5/') - leng