[sqlite] porting sqlite3 to embeded os-----lock question

2007-05-09 Thread allen . zhang
I am porting sqlite3 to the embeded os,such as threadx,nucleus,ect.. I am writing the file such as os_threadx.c,os_nucleus.c according to the os_win.c,os_unix.c. I have read the os_win.c and find that there is a switcher OS_WINCE in the struct winFile. Is this mean the windows platform don't

[sqlite] A suggestion

2007-05-09 Thread A.J.Millan
As a suggestion, and even in the risk to abuse of Mr Hipp's patience. Would it be possible to include in the command-line program (sqlite3.exe) the ability to edit, an repeat at least the five or six last commands, as in Linux?. Is to say with up-arrow and down-arrow. I believe it would be too

[sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread bash
Hello All, Im using SQLite-3.3.17. My table is: CREATE TABLE town_log ( id integer NOT NULL PRIMARY KEY AUTOINCREMENT, town_id int, stamp_id int, old_player_id int,

[sqlite] Re: perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread bash
Im simplify environment: CREATE TABLE tbl( id integer NOT NULL PRIMARY KEY AUTOINCREMENT, n1 int, n2 int ); CREATE INDEX idx1 on tbl(n1); CREATE INDEX idx2 on tbl(n2); sqlite> select count(*) from tbl; 63026 1 query: SELECT id, n1, n2 FROM tbl WHERE n1 = $I OR n2 = $I

Re: [sqlite] A suggestion

2007-05-09 Thread Peter van Dijk
On 9-mei-2007, at 11:06, A.J.Millan wrote: As a suggestion, and even in the risk to abuse of Mr Hipp's patience. Would it be possible to include in the command-line program (sqlite3.exe) the ability to edit, an repeat at least the five or six last commands, as in Linux?. Is to say with

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread Peter van Dijk
On 9-mei-2007, at 11:28, bash wrote: SELECT type, stamp_id, old_player_id, new_player_id FROM town_log WHERE old_player_id = $ID OR new_player_id = $ID ORDER BY stamp_id DESC; This query works really slowly and i don't know why :/ For example, the same result by another QUERY work much

Re: [sqlite] Re: perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread Tomash Brechko
On Wed, May 09, 2007 at 14:03:54 +0400, bash wrote: > Im simplify environment: > > CREATE TABLE tbl( > id integer NOT NULL PRIMARY KEY AUTOINCREMENT, > n1 int, > n2 int > ); > CREATE INDEX idx1 on tbl(n1); > CREATE INDEX idx2 on tbl(n2); > > sqlite> select count(*) from tbl; >

Re: [sqlite] A suggestion

2007-05-09 Thread Lloyd
In old versions it work... But in new versions (3.* I think) its not working! On Wed, 2007-05-09 at 12:11 +0200, Peter van Dijk wrote: > On 9-mei-2007, at 11:06, A.J.Millan wrote: > > > As a suggestion, and even in the risk to abuse of Mr Hipp's > > patience. Would > > it be possible to

Re: [sqlite] A suggestion

2007-05-09 Thread A.J.Millan
Sorry!! Although there are two other boxes around; one with XP and the other with Vista, for test purposes, actually I still use a third, with my old Windows 98SE and a utility, DOSKEY.COM, who emulates the Linux behavior in the Windows shell (who natively does not do that), but when I use it

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread bash
On Wed, 9 May 2007 12:23:14 +0200 Peter van Dijk <[EMAIL PROTECTED]> wrote: > > On 9-mei-2007, at 11:28, bash wrote: > > > SELECT type, stamp_id, old_player_id, new_player_id > > FROM town_log > > WHERE old_player_id = $ID OR new_player_id = $ID > > ORDER BY stamp_id DESC; > > > > This query

Re: [sqlite] Re: perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread bash
On Wed, 9 May 2007 14:24:27 +0400 Tomash Brechko <[EMAIL PROTECTED]> wrote: > On Wed, May 09, 2007 at 14:03:54 +0400, bash wrote: > > Im simplify environment: > > > > CREATE TABLE tbl( > > id integer NOT NULL PRIMARY KEY AUTOINCREMENT, > > n1 int, > > n2 int > > ); > > CREATE INDEX

[sqlite] Update callback and REPLACE

2007-05-09 Thread Krzysztof Sobolewski
Hi all, I have a question about an update callback. It's supposed to be called for every row that's inserted, updated and deleted and it works fine. Now there's a little thing calles INSERT OR UPDATE (and its friends) which removes conflicting rows before the INSERT. The thing is, the callback

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread Tomash Brechko
On Wed, May 09, 2007 at 16:34:57 +0400, bash wrote: > On Wed, 9 May 2007 14:24:27 +0400 > Tomash Brechko <[EMAIL PROTECTED]> wrote: > > From http://www.sqlite.org/optoverview.html section 6.0: > > > > Each table in the FROM clause of a query can use at most one index... > > > > So the first

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread bash
On Wed, 9 May 2007 17:29:29 +0400 Tomash Brechko <[EMAIL PROTECTED]> wrote: > > On Wed, May 09, 2007 at 16:32:34 +0400, bash wrote: > > SELECT * FROM ex1 WHERE x>'abc' AND y>'abc'; > > In this form only one indexes will be used, why not both? > > One index per table rule. At first glance it

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread drh
Tomash Brechko <[EMAIL PROTECTED]> wrote: > > sqlite> explain query plan > ...> SELECT id, n1, n2 > ...> FROM tbl > ...> WHERE n1 = $I > ...> UNION > ...> SELECT id, n1, n2 > ...> FROM tbl > ...> WHERE n2 = $I > ...> ORDER BY id DESC; >

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread Tomash Brechko
On Wed, May 09, 2007 at 17:45:52 +0400, bash wrote: > > One index per table rule. At first glance it seems like SQLite could > > use at least one index for "x=5 OR y=7" case too, but there is no > > point in that, as the other part of the OR would require full table > > scan anyway. > > Why full

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread bash
On Wed, 9 May 2007 18:13:07 +0400 Tomash Brechko <[EMAIL PROTECTED]> wrote: > On Wed, May 09, 2007 at 17:45:52 +0400, bash wrote: > > > One index per table rule. At first glance it seems like SQLite could > > > use at least one index for "x=5 OR y=7" case too, but there is no > > > point in

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread drh
bash <[EMAIL PROTECTED]> wrote: > > Oh... so this is implementation limitation. > Im currently thinking about this table: > > CREATE TABLE map ( > x int, > y int, > name char > ); > CREATE INDEX map_x ON map(x); > CREATE INDEX map_y ON map(y); > > And query for it will be

RE: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread Samuel R. Neff
I wonder if it would be beneficial to add an additional where clause which can prefilter the data so you only need to perform the full calculation on a subset of records. I haven't done the math, but let's supposed that point_x is 10 and that for any result of your long calculation to be true,

Re: [sqlite] Conditional table select

2007-05-09 Thread Dennis Cote
Vitali Lovich wrote: The solution I came up with is: SELECT coalesce( (SELECT field1 FROM tbl1 WHERE key = $key), (SELECT field1 FROM tbl2 WHERE key = $key), (SELECT field1 FROM tbl3 WHERE key = $key)) , field2 FROM tbl1 WHERE key = $key; However, if coalesce works the way I think it does,

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread Ken
[EMAIL PROTECTED] wrote:Note that some client/server database engines (ex: PostgreSQL and I think also firebird) will automatically rewrite the original query into something logically similar to my second example above. But the query optimizer in SQLite does not attempt to be quite that

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread bash
On Wed, 09 May 2007 14:45:33 + [EMAIL PROTECTED] wrote: > bash <[EMAIL PROTECTED]> wrote: > > > > Oh... so this is implementation limitation. > > Im currently thinking about this table: > > > > CREATE TABLE map ( > > x int, > > y int, > > name char > > ); > > CREATE INDEX map_x

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread bash
On Wed, 9 May 2007 11:08:26 -0400 "Samuel R. Neff" <[EMAIL PROTECTED]> wrote: > > I wonder if it would be beneficial to add an additional where clause which > can prefilter the data so you only need to perform the full calculation on a > subset of records. > > I haven't done the math, but

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread Dennis Cote
bash wrote: Why full table scan? :/ SQLite can takes set (1) of rowid by ex(x) index for "X=5". Then takes another set (2) of rowid by ex(y) for "Y=7". Then SQLite need only to union this two set (1) and (2). Final SQLite should returns rows where rowid in (set1 union set2). I think you

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread drh
Dennis Cote <[EMAIL PROTECTED]> wrote: > > > > Why full table scan? :/ > > SQLite can takes set (1) of rowid by ex(x) index for > > "X=5". Then takes another set (2) of rowid by ex(y) for "Y=7". > > Then SQLite need only to union this two set (1) and (2). > > Final SQLite should returns rows where

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread Tomash Brechko
On Wed, May 09, 2007 at 14:45:33 +, [EMAIL PROTECTED] wrote: > You need an R-Tree index to do something like this. The > public-domain version of SQLite only supports B-Tree indices. > So, no, indices are not going to help you here. Alternatively to R-tree index, you may simply partition the

[sqlite] sql stack using sqlite

2007-05-09 Thread Ken
Id like to get your ideas on implementing a stack using sql tables. table a, contains references to b table b contains refernce to a table c contains delete entries for A (but b must also be purged!) My processing forces me to load all of a,b and c. There may be cases where table C

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread bash
On Wed, 9 May 2007 21:00:46 +0400 Tomash Brechko <[EMAIL PROTECTED]> wrote: > On Wed, May 09, 2007 at 14:45:33 +, [EMAIL PROTECTED] wrote: > > You need an R-Tree index to do something like this. The > > public-domain version of SQLite only supports B-Tree indices. > > So, no, indices are not

Re: [sqlite] perfomance degradation for expr "foo = X or bar =X"

2007-05-09 Thread Dennis Cote
[EMAIL PROTECTED] wrote: INTERSECT would give you x=5 AND y=7. For x=5 OR y=7 you want UNION. Oops, yes of course. I was thinking of the higher level problem with circles where intersection could be used to find a small subset of the table that would then be scanned to locate the

[sqlite] Variable substitution for table names

2007-05-09 Thread Jeff Hamilton
Hi all, I have a complex query that I want to run often and store the results to a temporary table. I'd like to compile a statement that looks something like: CREATE TEMP TABLE ? AS SELECT * FROM data WHERE value = ?; so that I can have multiple threads accessing the results of the query in

[sqlite] Re: Variable substitution for table names

2007-05-09 Thread Igor Tandetnik
Jeff Hamilton <[EMAIL PROTECTED]> wrote: I have a complex query that I want to run often and store the results to a temporary table. I'd like to compile a statement that looks something like: CREATE TEMP TABLE ? AS SELECT * FROM data WHERE value = ?; so that I can have multiple threads

Re: [sqlite] Variable substitution for table names

2007-05-09 Thread drh
"Jeff Hamilton" <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a complex query that I want to run often and store the results > to a temporary table. I'd like to compile a statement that looks > something like: > > CREATE TEMP TABLE ? AS SELECT * FROM data WHERE value = ?; > > so that I can

[sqlite] adding a default ESCAPE character to LIKE

2007-05-09 Thread Jeffrey . H . Mitchell
Sorry if this isn't the proper channel, but I couldn't figure out where to submit a patch. See below for a patch to src/func.c that alters LIKE such that it has a default escape character of '\'. That is, LIKE behaves by default as if ESCAPE '\' were appended. Both MySQL and PostgreSQL

Re: [sqlite] A suggestion

2007-05-09 Thread John Stanton
That program does have the capability, but may not be implemented that way on Windows. Why not make the change yourself? A.J.Millan wrote: As a suggestion, and even in the risk to abuse of Mr Hipp's patience. Would it be possible to include in the command-line program (sqlite3.exe) the

Re: [sqlite] A suggestion

2007-05-09 Thread Rich Shepard
On Wed, 9 May 2007, John Stanton wrote: That program does have the capability, but may not be implemented that way on Windows. Why not make the change yourself? A.J.Millan wrote: As a suggestion, and even in the risk to abuse of Mr Hipp's patience. Would it be possible to include in the

[sqlite] Re: Help wiith SQL - first row of each group

2007-05-09 Thread A. Pagaltzis
* Ed Pasma <[EMAIL PROTECTED]> [2007-05-07 10:28]: > This solution may is tricky but has occasoinaly helped me. It > is written here dedicated for the example data. For real data > the leftpadding should likely be increased to the content of > the sorting key. Also the result may need to be

[sqlite] The need for sqlite3_encode_binary and sqlite3_decode_binary

2007-05-09 Thread Andrew Finkenstadt
It would appear that by using bind variables instead of '%Q' in the SQL string, the need for sqlite3_encode_binary and sqlite3_decode_binary is eliminated. Is that indeed the case? --andy

[sqlite] ATTACH and sqlite3_open()

2007-05-09 Thread Jon Scully
Can one attach multiple database files using C API? The only example I've seen is CLI-based (using ATTACH). The Owens book seems to hint that it's possible to do the same trick using sqlite3_open()... Quote Pgs. 206-207: This is more of a connection handle than a database handle since it is

Re: [sqlite] ATTACH and sqlite3_open()

2007-05-09 Thread Andrew Finkenstadt
From the comments around the attach function, you'd have to execute a SQL statement "attach database x as y KEY z". I assume that 'key Z' is for the encrypting version of SQLite3 distributed by drh. /* ** An SQL user-function registered to do the work of an ATTACH statement. The ** three

Re: [sqlite] ATTACH and sqlite3_open()

2007-05-09 Thread Andrew Finkenstadt
On further inspection of your code fragment, it appears you aren't really using (extra) attached databases, but merely specifying an alternative file to use if the first file is not available. Calling sqlite3_close(...) will do the right thing, by closing the actual database that succeeded in

Re: [sqlite] ATTACH and sqlite3_open()

2007-05-09 Thread Jon Scully
Simpler than that. I merely want to attach to two databases (files). flash.db contains a set of tables that hold non-volatile data; ram.db contains a set of tables that is re-built (volatile) on re-boot -- but offers fast, read-only access. No table-name overlaps, of course. I want to access

AW: [sqlite] ATTACH and sqlite3_open()

2007-05-09 Thread Michael Ruck
Just call sqlite3_exec with the proper ATTACH as you would on the command line. (Of course you could also do a prepare/step/finalize, but for ATTACH sqlite3_exec is enough.) Example: sqlite3 *db = NULL; /* ... */ sqlite3_exec(db, "ATTACH DATABASE 'filename' AS dbname",

[sqlite] Longest "real" SQL statement

2007-05-09 Thread drh
I'm looking for an upper bound on how big legitimate SQL statements handed to SQLite get to be. I'm not interested in contrived examples. I want to see really big SQL statements that are actually used in real programs. "Big" can be defined in several ways: * Number of bytes of text in

[sqlite] Problem with SQLite Pecl extension for PHP4

2007-05-09 Thread Brandon Eley
I've gone through a few tutorials and can't seem to get this right. I've had my web host install the PECL extension and the following is what is in my phpinfo(); sqlite SQLite support enabled PECL Module version 1.0.3 $Id: sqlite.c,v 1.62.2.25 2004/07/10 12:25:33 wez Exp $ SQLite

[sqlite] Re: Longest "real" SQL statement

2007-05-09 Thread Dave Dyer
I've recently been storing images in Sqlite datbases, and for various reasons don't want to use the normal "blob" mechanisms. Consequently, a 10mb JPG image file would be encoded as slightly larger than 10mb sqlite "insert xx" command. The size of the commands required by this method is limited

Re: [sqlite] Longest "real" SQL statement

2007-05-09 Thread drh
Dave Dyer <[EMAIL PROTECTED]> wrote: > I've recently been storing images in Sqlite datbases, and > for various reasons don't want to use the normal "blob" > mechanisms. Consequently, a 10mb JPG image file would be > encoded as slightly larger than 10mb sqlite "insert xx" command. > The use of

Re: [sqlite] A suggestion

2007-05-09 Thread John Stanton
Rich Shepard wrote: On Wed, 9 May 2007, John Stanton wrote: That program does have the capability, but may not be implemented that way on Windows. Why not make the change yourself? A.J.Millan wrote: As a suggestion, and even in the risk to abuse of Mr Hipp's patience. Would it be

Re: [sqlite] ATTACH and sqlite3_open()

2007-05-09 Thread Jon Scully
That worked as hoped. (Used your sqlite3_exec() version.) Thanks. On 5/9/07, Michael Ruck <[EMAIL PROTECTED]> wrote: Just call sqlite3_exec with the proper ATTACH as you would on the command line. (Of course you could also do a prepare/step/finalize, but for ATTACH sqlite3_exec is enough.)

Re: [sqlite] Problem with SQLite Pecl extension for PHP4

2007-05-09 Thread Jon Scully
What user is httpd running as? Enter: ps aux | grep -v grep | grep httpd Does that user (typically 'nobody') have permission to access the file at your: /home/xxx/data/xxx.db ? On 5/9/07, Brandon Eley <[EMAIL PROTECTED]> wrote: I've gone through a few tutorials and can't seem to get this

[sqlite] sqlite3_step error code confusion

2007-05-09 Thread Emerson Clarke
Ive been getting SQLITE_MISUSE errors after calling sqlite3_step one more time than required. Im using sqlite3_prepare_v2 so im expecting detailed error messages, but when i call sqlite3_errmsg all i seem to get is "not an error". So my question is this. What is an error ? It seems a little

Re: [sqlite] Problem with SQLite Pecl extension for PHP4

2007-05-09 Thread Chris Peachment
There was a change of file structure with version 3.x.x and this is described in the documentation under Version 3 Overview. You are attempting to use Sqlite3 on a version 2.8.x database and the formats are not compatible. On Wed, 9 May 2007 19:42:06 -0400, Brandon Eley wrote: >I've gone