Re: [sqlite] Locking in sqlite

2009-05-02 Thread Pavel Ivanov
> On Sat, May 2, 2009 at 3:48 PM, Pavel Ivanov wrote: > [...] >> update main.t set x = 1 >> update B.t set x = 1 >> update C.t set x = 1 >> >> My question is will these statements be able to execute in connections >> in parallel simultaneously because t

Re: [sqlite] trigger on update bug in 3.6.20?

2009-11-25 Thread Pavel Ivanov
version. Pavel On Tue, Nov 24, 2009 at 8:27 PM, Vasu Nori wrote: > On Tue, Nov 24, 2009 at 12:28 PM, Pavel Ivanov wrote: > >> > I am not what you mean by Oracle's Before triggers have different >> concept? >> > care to explain? >> >> Sure. Whe

Re: [sqlite] Recursive TRIGGERs: depth-first or width-first

2009-11-25 Thread Pavel Ivanov
Does this answers question? sqlite> create table log (t); sqlite> create table t1 (a); sqlite> create table t2 (a); sqlite> create trigger tt1 after update on t1 begin ...> insert into t2 values (new.a); ...> insert into log values ("update of t1, a="||new.a); ...> end; sqlite> create tri

Re: [sqlite] Recursive TRIGGERs: depth-first or width-first

2009-11-25 Thread Pavel Ivanov
hem to fire is considered successful. Otherwise all triggers checking some constraints and prohibiting incorrect data (and thus raise(...) function) are useless. Pavel On Wed, Nov 25, 2009 at 8:59 AM, Simon Slavin wrote: > > On 25 Nov 2009, at 1:38pm, Pavel Ivanov wrote: > >> Does

Re: [sqlite] Recursive TRIGGERs: depth-first or width-first

2009-11-25 Thread Pavel Ivanov
;re deferred foreign keys too. See section 4.2 here: http://www.sqlite.org/foreignkeys.html. Pavel On Wed, Nov 25, 2009 at 9:13 AM, Simon Slavin wrote: > > On 25 Nov 2009, at 2:06pm, Pavel Ivanov wrote: > >>> I couldn't find the answer documented anywhere, so I will have

Re: [sqlite] Foreign Key constraint as column constraint?

2009-11-25 Thread Pavel Ivanov
According to http://www.sqlite.org/lang_createtable.html you can mention foreign-key-clause (starting with REFERENCES) as column-constraint. Why it doesn't work for you? Pavel On Wed, Nov 25, 2009 at 10:33 AM, Jan wrote: > Hi, > > I am testing the new fk support in my db. Currently I have *colum

Re: [sqlite] sqlite-users Digest, Vol 23, Issue 26

2009-11-27 Thread Pavel Ivanov
> reasons. Can primary key values available because of deletes get re- > used at some point? I guess you're talking about rowids not about general primary keys. For rowids reuse is possible only if rows with maximum values of rowids are deleted and only if your INTEGER PRIMARY KEY column doesn't

Re: [sqlite] sqlite3 is blocked by transaction when wanting to close the sqlite3 *

2009-11-30 Thread Pavel Ivanov
> Because there are several process who use the database. I have another > question:Could I close the database of other process in main process? Just use your favorite IPC mechanism and write your application so that main process sends message to other process and when other process receives it th

Re: [sqlite] Convert Access sql to SQLite sql

2009-12-02 Thread Pavel Ivanov
Your Access query doesn't have good equivalent in SQLite. Your options are: 1. Execute SELECT separately and then for each row in the result issue an UPDATE with necessary values (UPDATE can be prepared and you can just bind all values). 2. Insert results of SELECT into some temporary table and the

Re: [sqlite] Multiples natural left joins problem

2009-12-03 Thread Pavel Ivanov
If using "natural left join" is not a requirement for you then this works as you expect it: select movies.id, title, rating, tag from movies left join user on movies.id = user.id left join tag on movies.id = tag.id; Pavel On Thu, Dec 3, 2009 at 9:49 AM, Yuzem wrote: > > Lets say I have

Re: [sqlite] Multiples natural left joins problem

2009-12-03 Thread Pavel Ivanov
ating and tag value. After that you won't have to deal with left joins and with simple "natural join" you won't have such problem... Pavel On Thu, Dec 3, 2009 at 12:30 PM, Yuzem wrote: > > Thanks both for the replies. > > Pavel Ivanov-2 wrote: >> >> If us

Re: [sqlite] Selecting unique entries from one table with multiple columns forming a unique key

2009-12-03 Thread Pavel Ivanov
Maybe select distinct bar.* from foo, bar where foo.col2 = bar.col2 and foo.col3 = bar.col3 It's not clear from your requirements written below whether you need 'distinct' here or not but I've added it just in case... Pavel On Thu, Dec 3, 2009 at 4:34 PM, Rich Rattanni wrote: > Suppose I have

Re: [sqlite] Selecting unique entries from one table with multiple columns forming a unique key

2009-12-03 Thread Pavel Ivanov
in each table is VERY > LARGE (lets say 50,000) would my solution maybe outperform the first > (on the surface seems like n^2 vs n*S where S is concat string length > (which will always be < 50)). > > On Thu, Dec 3, 2009 at 4:39 PM, Pavel Ivanov wrote: >> Maybe >> &

Re: [sqlite] sqlite3 is blocked by transaction when wanting to close the sqlite3 *

2009-12-04 Thread Pavel Ivanov
> { >    ... >    signal (SIGUSR2, (void*)sig_handler); >     > } > > void sig_handler(int sig) > { >    ... >    switch(sig) >    { >        case SIGUSR2: >            ... >            sqlite3_interrupt (db); >            ret = sqlite3_close (db);  // is blocked here >

Re: [sqlite] sqlite help requested to support this requirement

2009-12-04 Thread Pavel Ivanov
> SQLite is an implementation of SQL. SQL is used to store information in a > way that allows you to look things up more quickly than searching a flat > file. If you can search for data your flat files fast enough to make your > software work acceptably, you do not need SQL and your project wi

Re: [sqlite] sqlite help requested to support this requirement

2009-12-04 Thread Pavel Ivanov
read more about concepts of relational databases. Pavel On Fri, Dec 4, 2009 at 8:01 AM, Pronab Ganguly wrote: > Thanks a lot for all help suggestion.Let me know if you have any experience > on file parsing using sqlite. > -P > > On Fri, Dec 4, 2009 at 6:15 PM, Pavel Ivanov wrote:

Re: [sqlite] Generic indexes on FTS3 table

2009-12-04 Thread Pavel Ivanov
> (2) Is there a way to create FTS virtual table that only holds the > fulltext index and not the data itself? (This way I'd able to solve > the problem by creating a separate FTS3 table and hooking triggers on > r/w queries). Can you exclude text fields from your table, put it into separate FTS t

Re: [sqlite] sqlite3_exec() returns SQLITE_OK but Database showsdifferent result

2009-12-07 Thread Pavel Ivanov
> 1) You are opening a different file than the one you think you are opening. > E.g. you are using a relative path to the file, and the workding directory is > not what you expect it to be. > > 2) You are starting an explicit transaction (see BEGIN) and forgetting to > commit it. 3) You are sta

Re: [sqlite] char,ascii function in sqlite

2009-12-07 Thread Pavel Ivanov
As Simon said use substr() to get first character and use cast(X'FF' as text) to convert some hexadecimal character code to symbol (in my example the code is FF = 255). But there's no way to convert character into its code, so you cannot do any arithmetics with it though you probably don't need it

Re: [sqlite] Cache size tuning

2009-12-07 Thread Pavel Ivanov
Maybe 'pragma cache_size'? Pavel On Fri, Dec 4, 2009 at 10:05 PM, Richard Klein wrote: > Does SQLite provide any tools to help the > developer tune the database cache size? > > Thanks, > - Richard Klein > ___ > sqlite-users mailing list > sqlite-users@

Re: [sqlite] Where is CASE documented ?

2009-12-08 Thread Pavel Ivanov
Apparently document writer assumed that it's pretty obvious how CASE works because it works the same way in all DBMSes. :) You can read any documentation Google gives, e.g. this: http://msdn.microsoft.com/en-us/library/ms181765.aspx. In brief, when you give optional expression then CASE works like

Re: [sqlite] BUG: the rowid column in view is automatically named as id

2009-12-09 Thread Pavel Ivanov
It's been said in this list not once already: unless you're using "as ..." to name the column it's not guaranteed to have any particular name you expect it to. So it's not a bug. Also: sqlite> create table test (id INTEGER PRIMARY KEY, a text); sqlite> insert into test (a) values (1); sqlite> .h

Re: [sqlite] [sqlite-dev] query on sqlite3_open16

2009-12-09 Thread Pavel Ivanov
According to documentation on CreateFile() function: "In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path." SQLite is already calling CreateFileW()

Re: [sqlite] SQL question

2009-12-11 Thread Pavel Ivanov
> So for a set of measurements identified by everything but their name > select the latest rows as defined by the timestamp. > > Can I do that in SQL in one query? Maybe this is what you want: select Name, Value, CreateTS from TableName where Oper = 'op' and Category = 'cat' and Product = 'produc

Re: [sqlite] Bug when uUsing Parameters with views

2009-12-15 Thread Pavel Ivanov
Apparently result of count() and probably all other aggregate functions (as well as result of any function at all) has no affinity. So when you compare it to anything having no affinity too you have no type transformation during comparison. And thus values have to be exactly the same including thei

Re: [sqlite] EPC Based Search

2009-12-15 Thread Pavel Ivanov
> Why not just make epc column "unique on conflict ignore"? > i.e. > CREATE TABLE readmode( epc text unique on conflict ignore, col2 text... ); > >> one EPC ( say:'e2003411b802010994095761' i.e. 24char ) out of 5000 records. >> and select query take 2-3 sec. to give result output. >> >> By any mean

Re: [sqlite] Bug when uUsing Parameters with views

2009-12-15 Thread Pavel Ivanov
ty > of the value, no ? AH, GOT IT. values do NOT have affinity. so I would > either need to cast the expression OR the value. > > is this correct ? > > >> -Original Message- >> From: sqlite-users-boun...@sqlite.org >> [mailto:sqlite-users-boun...@sqlite.or

Re: [sqlite] pragma database_list

2009-12-15 Thread Pavel Ivanov
pragma database_list returns record set as any select statement. So you can capture this record set from C code as you do with any other select statement and based on that make your checking as you need. Pavel On Tue, Dec 15, 2009 at 12:58 PM, Angelo wrote: > Hi to everybody, > > I'm using sqlit

Re: [sqlite] EPC Based Search

2009-12-16 Thread Pavel Ivanov
tions of millisecond that only very rare critical applications are able to feel it... Pavel On Wed, Dec 16, 2009 at 7:48 AM, Ram Mandavkar wrote: > > readmode table gets updated on frequently basis so i can not create index on > it. > > Is there any way out except create index on it. >

Re: [sqlite] Compiling SQLite as .lib increases project size and build time?

2009-12-17 Thread Pavel Ivanov
> 1>LINK : fatal error LNK1181: cannot open input file > '..\release\sqlite.lib' Is this filename something that you wrote yourself in configuration of your project? If you compile something as dll you don't need to mention its library as additional linking source in dependent projects. Pavel On

Re: [sqlite] Compiling SQLite as .lib increases project size andbuild time?

2009-12-17 Thread Pavel Ivanov
> If I remove the dependency on sqlite from HouseKeeper, it gives linker > errors with unresolved symbols for sqlite3_* functions. Adding sqlite as > a dependency to HouseKeeper causes it to look for the sqlite.lib file. Make sure that .def file is included in you Sqlite project. When compiling pr

Re: [sqlite] Error in retreiving DATETIME('NOW')

2009-12-17 Thread Pavel Ivanov
> pls tell me, why  DATETIME() function gives wrong time? http://www.sqlite.org/lang_datefunc.html "Format 11, the string 'now', is converted into the current date and time as obtained from the xCurrentTime method of the sqlite3_vfs object in use. Universal Coordinated Time (UTC) is used." Use da

Re: [sqlite] Compiling SQLite as .lib increases projectsizeandbuild time?

2009-12-17 Thread Pavel Ivanov
gor Tandetnik > > -- > It is set to generate a .lib according to that setting, but from what Pavel > said, it never does because the .def file is missing from the project. I've > never heard of .def files before so this is a new issue for me. This is all > quite exciti

Re: [sqlite] Error in retreiving DATETIME('NOW')

2009-12-17 Thread Pavel Ivanov
> but i want to use my localtime as default time in sqlite(without giving > 'localtime'). is it possible? No. And documentation clearly says about that. Pavel On Thu, Dec 17, 2009 at 11:08 AM, greensparker wrote: > > SELECT DATETIME('NOW','localtime');  is WORKED > but i want to use my localti

Re: [sqlite] usage of indexes - query performance

2009-12-18 Thread Pavel Ivanov
As you said because of your LEFT JOIN SQLite (or any other DBMS in its place) is forced to use t2 as a base table. You have no conditions on t2, so SQLite will make full scan on it and for each row it will need to pick up a corresponding rows from t1 which it does using primary index. And FYI, by

Re: [sqlite] ambiguous column name

2009-12-23 Thread Pavel Ivanov
> You have three distinct columns here - t1.a, t2.a and t3.a. With left joins, > it's possible for some but not all of them to be null, so it matters which > one you select. > > Even with inner joins, it may matter which column you pick. E.g., in SQLite > it's possible that a=b but typeof(a) !=

Re: [sqlite] Problem with cast(xx as YY)

2009-12-24 Thread Pavel Ivanov
>     The behavior of cast(XX as YY) is not the same as the old version, such > as 3.3.4, and also different to SQL Server or  MYSQL. Don't complain that SQLite's cast works the other way than SQL Server or MySQL. SQLite behaves in a very unique way when the type-related matters are a concern. And

Re: [sqlite] Help with Insert using select

2009-12-24 Thread Pavel Ivanov
Why this doesn't work? insert into table (creationdate, modifieddate, mytext, title) select date('now'), date('now'), "show text", "show title"; Pavel On Wed, Dec 23, 2009 at 11:24 AM, Christopher Doss wrote: > Hello, I have a table that I'd like to create that needs calculated data in > multi

Re: [sqlite] Problem with cast(xx as YY)

2009-12-24 Thread Pavel Ivanov
esults became the same. Pavel On Thu, Dec 24, 2009 at 12:40 PM, Simon Slavin wrote: > > On 24 Dec 2009, at 1:17pm, Pavel Ivanov wrote: > >> But this behavior is definitely a bug: > > You might change the behaviour by defining the type of the column: > > create table t

Re: [sqlite] Using incremental BLOB I/O when processing result set

2009-12-28 Thread Pavel Ivanov
> The implementation for the SQLite ODBC driver does not use incremental > BLOB I/O, it reads a BLOB into memory for each row > fetched. Not much use if the size of each image in the SQLite database > is 3gb and you only have 2gb memory. I'm looking for a solution that > will work on BLOBs larger t

Re: [sqlite] SQLitedb problem

2009-12-28 Thread Pavel Ivanov
What's the problem with the answers already given? Pavel On Mon, Dec 28, 2009 at 6:13 AM, Othman Guessous wrote: > Hello, > > I wait for your help. Please can you answer to me ASAP. > > Thanks, > Othman. > > On Mon, Dec 21, 2009 at 12:35 AM, Othman Guessous > wrote: > >> Hello, >> >> I have a pr

Re: [sqlite] SQLitedb problem

2009-12-28 Thread Pavel Ivanov
re not removed. > > I think that these data are ignored. So how data can be ignored on a > sqlitedn file? How can i fix this problem so i can view them on my iphone or > SQLite Database Browser. > > I thank you in advance for your return. > > Othman. > > On Mon,

Re: [sqlite] SQLitedb problem

2009-12-28 Thread Pavel Ivanov
nbox answers from the mailing list. > > Is there any answers? > > Othman. > > On Mon, Dec 28, 2009 at 6:05 PM, Pavel Ivanov wrote: >> >> 1. Don't reply directly to me. If you write your question to the >> mailing list all further discussion should take plac

Re: [sqlite] Which is faster raw file I/O or sqlite BLOB

2009-12-29 Thread Pavel Ivanov
It depends on numerous facts. I'd say if size of all your files is measured in megabytes and you're not dealing with thousands of files in the same directory then raw file I/O will be faster. If size of files is measured mostly in tens or hundreds of bytes and you need thousands and millions of the

Re: [sqlite] Using incremental BLOB I/O when processing result set

2009-12-29 Thread Pavel Ivanov
> Its a shame that a BLOB handle is not returned as a result of a query > rather than the BLOB itself. Let me correct you. It's not a shame, it's database specifics and it has its good points. For me personally I'd hate if SQLite returned me some abstract handle if I requested blob value. Note: i

Re: [sqlite] selective result columns

2009-12-30 Thread Pavel Ivanov
> I don't have access to that level of software, so that's the problem. You mean your experience with SQLite is based on using sqlite3 command line utility only? If so you can just redirect its output to sed which will do something like s/|\+/|/g. If your experience with SQLite is based on using s

Re: [sqlite] Requirements for index-aware INSERT SELECT

2009-12-30 Thread Pavel Ivanov
> INSERT OR IGNORE INTO Table (Field) SELECT SomeOtherField FROM OtherTable > ORDER BY SomeOtherField > > produced significant reduce in data flow. (Field Is indexed in Table). I > don't think the difference is related to some caching since the variant > without ORDER BY shows 50 MB data transfer f

Re: [sqlite] Confusing FAQ(26) wording

2009-12-30 Thread Pavel Ivanov
To be honest I'm a bit confused about the wording of these two bullets too. But here're my comments and clarifications: >>     Perhaps you are referring to the following statement from SQL92: >> >>         A unique constraint is satisfied if and only if no two rows in >>         a table have the s

Re: [sqlite] selective result columns

2009-12-31 Thread Pavel Ivanov
tion.  The application > allows me to run an SQL query, then it renders the output into HTML.  I want > to avoid showing empty colums in the HTML output, so I wanted the > include/exclude column logic in my actual SQL statement. > > > > > Pavel Ivanov-2 wrote: >> >&

Re: [sqlite] Is there a way to "predict" autoincrement rowid range

2010-01-07 Thread Pavel Ivanov
max(rowid) + 1 before the insert is a good approximation for the left bound. But if you want to know the exact value you can remember max(rowid) + 1 before insert and execute this after insert: select min(rowid) from table_name where rowid >= remembered_value It will be guaranteed to give you exa

Re: [sqlite] Is there a way to "predict" autoincrement rowid range

2010-01-07 Thread Pavel Ivanov
>  At the very least, do the initial INSERT and get-last in a >  single transaction. Not necessarily. You can do INSERT and get-last without starting transaction because get-last is per-connection, not per-database. So the only thing that should be taken care of is no inserts are executed on the c

Re: [sqlite] Creation of a sqlite database in VC++

2010-01-07 Thread Pavel Ivanov
Use an API to open a database. If database file does not exist at the time of opening then it will be automatically created (unless you try to open it for read-only access). Pavel On Thu, Jan 7, 2010 at 3:43 PM, gary clark wrote: > Hi, > > I'm looking for an API in sqlite3 that allows me to crea

Re: [sqlite] [sqlite-dev] Why I always got error SQLITE_MISUSE 21 /* Library used incorrectly */

2010-01-08 Thread Pavel Ivanov
Oh, and one more thing: sqlite-dev list is for questions related to developing SQLite itself. For problems with using SQLite you should write to sqlite-users list (put in CC). Pavel On Fri, Jan 8, 2010 at 7:50 AM, Pavel Ivanov wrote: > As you're new to SQLite you could easily m

Re: [sqlite] Associating items of a column with one item of another column

2010-01-08 Thread Pavel Ivanov
Probably these commands would help: CREATE TABLE temp_forms (form TEXT, root TEXT); .separator "|" .import forms.txt forms CREATE TABLE roots(id INTEGER PRIMARY KEY, root TEXT); INSERT INTO roots (root) SELECT DISTINCT root FROM temp_forms; CREATE TABLE forms (form TEXT, root INTEGER); INSERT INTO

Re: [sqlite] [sqlite-dev] Why I always got error SQLITE_MISUSE 21 /* Library used incorrectly */

2010-01-11 Thread Pavel Ivanov
t; compile with this option? > > The second question is when i met SQLITE_MISUSE error, can i reset or reopen > the database to avoid this error? > > Regards, > Tim > > > Pavel Ivanov-2 wrote: >> >> Oh, and one more thing: sqlite-dev list is for questions related to

Re: [sqlite] [sqlite-dev] Why I always got error SQLITE_MISUSE 21 /* Library used incorrectly */

2010-01-11 Thread Pavel Ivanov
ersion. :-). So for a temp solution, I will open the database again if the > application detect there is a SQLITE_MISUSE, is this solution safe enough? > > Thanks, > Tim > > > > Pavel Ivanov-2 wrote: >> >>> I am now using SQLite version 3.3.5, and i cannot f

Re: [sqlite] Limitation on Column count

2010-01-12 Thread Pavel Ivanov
> so normalization would lead to a doubling > of the storage space (add a measurement_id to each measurement). My strong belief is that when you try this normalization you'll see that such doubling of storage is a good enough trade-off for the speed you'll achieve. I don't think that speed of quer

Re: [sqlite] Limitation on Column count

2010-01-12 Thread Pavel Ivanov
ompare. > But that will be tomorrow I guess... > When doing so: Any idea of what would be the worst case column select > strategy on the huge table to compare with? > > Stefan > > > Pavel Ivanov-2 wrote: >> >>> so normalization would lead to a doubling >>>

Re: [sqlite] How to find Rank in SQLite3?

2010-01-13 Thread Pavel Ivanov
> I have used following query but it takes more than one hour even after > indexing, Shouldn't be - query is not so hard if a proper index used. What index did you create? >  mysql->select a.DEPTNO, a.EMPNO, a.LASTNAME, a.FIRSTNAME, a.SAL, >        ... >        -> order by x.DEPTNO, x.RANK; Inte

Re: [sqlite] How to find Rank in SQLite3?

2010-01-14 Thread Pavel Ivanov
> Is there is any other possible way to find out rank? As I said you can do it in your application, it will be a whole lot faster than doing it with sql. Just select all your data with 'order by deptno, sal desc'. Then during iteration over result set assign rank 1 to the person when you first see

Re: [sqlite] Limitation on Column count

2010-01-19 Thread Pavel Ivanov
This is from your last e-mail: > So, I can't see the advantage of normalization here. (Note that I do not > plan to join or index > on measurement columns!) This is from your first e-mail: > Queries on this big table will be rather straight-forward: either on the > table alone (SELECT * FROM tab

Re: [sqlite] fasted way to get the min/max

2010-01-20 Thread Pavel Ivanov
Create an index on the field which you're getting min/max of. Then getting min/max will take some milliseconds. Pavel On Wed, Jan 20, 2010 at 7:54 AM, hi wrote: > Hi, > > For my application I am storing about "1770" rows into sqlite table, and > when taking 'min' or 'max' it takes about ~7 t

Re: [sqlite] Attached database

2010-01-20 Thread Pavel Ivanov
I wouldn't say anything about views - from my POV there's no much harm in supporting cross-database views other than possible user confusion (personally I don't know why it was decided to not support this). But concerning foreign keys: how do you think SQLite is supposed to enforce foreign key when

Re: [sqlite] Attached database

2010-01-20 Thread Pavel Ivanov
allow to detach > database when foreign key constraints exist on it. > > Sylvain > > -Original Message- > From: sqlite-users-boun...@sqlite.org > [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Pavel Ivanov > Sent: Wednesday, January 20, 2010 4:40 PM > To: Gen

Re: [sqlite] Attached database

2010-01-20 Thread Pavel Ivanov
> Is it possible? If I attach database B to database A and database A to > database B. As these statements are committed into A and B, they stay > attached even if I close and reopen. So If another process opens A (or B), > it has B (or A) attached to A (or B). I don't have to repeat the ATTACH > s

Re: [sqlite] fastest way to get the min/max

2010-01-20 Thread Pavel Ivanov
> Why the difference in search time between searching individually and > searching together? Apparently SQLite is not smart enough to optimize the search for both min and max to make double entrance to the index - first from the beginning, then from the end. It does search through the full index i

Re: [sqlite] SQL Crash with sqlite 3.6.22 commandline

2010-01-21 Thread Pavel Ivanov
> I am unable to reproduce this problem.  Using the script below, with > RMNOCASE changed to just NOCASE Probably that's exactly the point of crash in the OP's test case. He created table when RMNOCASE collation existed but then tries to execute query when that collation is not registered and unkn

Re: [sqlite] Variable type and/or number of data in a row?

2010-01-22 Thread Pavel Ivanov
> So my question is : how to create a table in which rows (keywords) > could contain variable type and number of data ? You cannot create table containing variable number of data values - it contradicts relational data model. You can either create 2 tables - one containing keywords, another all va

Re: [sqlite] lock database

2010-01-22 Thread Pavel Ivanov
SQLite cannot lock/unlock tables. But by executing "BEGIN IMMEDIATE TRANSACTION"/"BEGIN EXCLUSIVE TRANSACTION" and "COMMIT"/"ROLLBACK" you can lock/unlock the database. Pavel On Fri, Jan 22, 2010 at 12:06 AM, Qianqian Fang wrote: > hi > > I wanna ask a naive question: are there commands to > lo

Re: [sqlite] famous "constraint failed" error

2010-01-22 Thread Pavel Ivanov
> Does any sqlite MVP know what could be beyond this strange > error message. Exactly what message says: you tried to insert data that is not allowed by constraints in the table. "Read"/"write" threads construct doesn't have anything to do with that - everything can be reproduced in one "write" th

Re: [sqlite] famous "constraint failed" error

2010-01-22 Thread Pavel Ivanov
SY error. Are you sure you don't mess with your data from some other process? Pavel On Fri, Jan 22, 2010 at 2:28 PM, Jan Bilek wrote: > But why it only happens when any concurrent select query is in progress? > Thanks for any response. > > Jan > > > > Pavel Ivanov wrot

Re: [sqlite] Append data to a BLOB field

2010-01-26 Thread Pavel Ivanov
No, it's not possible. You can try something like this: update table_name set blob_value = blob_value||appendix where ... But here SQLite will still need to read original data, concatenate and write new, although you by yourself won't read and concatenate anything. And I'm not sure whether it wil

Re: [sqlite] Concurrency support for multiple process

2010-01-28 Thread Pavel Ivanov
It's not clear what locks did you want to show with your diagram but in reality locks would be held as following: *Process A*: Begin Transaction - no lock *Process B*: Select DB1 <-- shared lock *Process A*: Insert DB1 <-- if insert is small then only reserved lock *Process B*: Select DB1 <-- sha

Re: [sqlite] sqllite and sub queries

2010-01-28 Thread Pavel Ivanov
Your query looks perfectly correct. You say that it returns 0 in count(*) sub-selects and you think that it's not correct? Could you show as your schema creation statements? And check that your StatusId really contains integers, not text. Also check that BlogPostId in BlogComment and BlogPost has t

Re: [sqlite] SQLite Question: What is the best way to "buffer" the database in memory while still being able to save the database to disk when needed (programmatically)?

2010-01-28 Thread Pavel Ivanov
I can't see all your requirements for this database but I believe you'd better not use temporary or in-memory databases. You'd better use regular database but use all kinds of tricks to speed up work with it (like "pragma synchronous off", "pragma journal_mode off", in some cases some tricks can be

Re: [sqlite] what are the limitations for IN() lists?

2010-01-28 Thread Pavel Ivanov
SQLite doesn't have this type of optimization. Internally IN-list will be converted by SQLite parser to sequence of equality checks that will be performed on each row. So generally the more the IN-list the worse the performance of the query. So with IN-list growing to 100 or more elements I'd say t

Re: [sqlite] SQLite Question: Is there a SQLite function that can "copy" one database to another (programmatically)?

2010-01-28 Thread Pavel Ivanov
What's wrong with the link already given you in another thread? http://www.sqlite.org/backup.html Also see http://www.sqlite.org/c3ref/backup_finish.html. Pavel On Thu, Jan 28, 2010 at 9:43 AM, Trapper Schuler wrote: > Hello, > > Is there a SQLite function that can "copy" one database to anothe

Re: [sqlite] SQLite Question: Is there a SQLite function that can "copy" one database to another (programmatically)?

2010-01-28 Thread Pavel Ivanov
list. Pavel On Thu, Jan 28, 2010 at 12:44 PM, Trapper Schuler wrote: > Hi, > > I do not understand the question. > > I appreciate the information that you have provided. > > Thank you. > > Pavel Ivanov wrote: >> >> What's wrong with the link already g

Re: [sqlite] Getting an error "table insert failed for eventLog" any idea what is the reason

2010-02-01 Thread Pavel Ivanov
No, we don't. We can help sometimes when script contains about 5 short lines of code, but not with some big complicated scripts. For help with those scripts you should go to script authors. This group is for problems with using SQLite - when you see that SQLite behaves not in a way you expect or r

Re: [sqlite] Update/Delete problem

2010-02-01 Thread Pavel Ivanov
Are you sure that Spiceworks or SQLLite Database Browser commit your changes? What happens if you close those applications and restart it - will they see their own changes? If they will and they still won't see other application's changes then you can be sure that you're looking at different databa

Re: [sqlite] Update/Delete problem

2010-02-02 Thread Pavel Ivanov
ndelig meddelelse- > Fra: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] > På vegne af Pavel Ivanov > Sendt: 1. februar 2010 19:01 > Til: General Discussion of SQLite Database > Emne: Re: [sqlite] Update/Delete problem > > Are you sure that Spiceworks

Re: [sqlite] journal files

2010-02-02 Thread Pavel Ivanov
What do you want to see in journal files? You can execute 'PRAGMA journal_mode = persist' and all information in journal file except first 4 bytes will be left on disk for you. Is it enough? Pavel On Tue, Feb 2, 2010 at 7:00 AM, rishabh wrote: > > hey, > > I am coding for an application wherein

Re: [sqlite] Shocked by long updates of the text database, 1000 speed improvement after small modification to the code.

2010-02-03 Thread Pavel Ivanov
Just first thought came to my mind: are you sure that 2 versions of code mentioned do the same thing? In particular I'm asserting that second version (under #if 1) doesn't do any actual updating and doesn't change your database because you have wrong parameter indexes. And one more question: why do

Re: [sqlite] Shocked by long updates of the text database, 1000 speed improvement after small modification to the code.

2010-02-03 Thread Pavel Ivanov
ation structure and execute all updates in one transaction as already said by others... Pavel On Wed, Feb 3, 2010 at 11:51 AM, a1rex wrote: >>- Original Message ---- >>From: Pavel Ivanov >>To: General Discussion of SQLite Database >>Sent: Wed, February 3, 2010 11:37:17 AM &

Re: [sqlite] Shocked by long updates of the text database, 1000 speed improvement after small modification to the code.

2010-02-03 Thread Pavel Ivanov
>  Capacity: 120.9 GB >  Speed: 7200 rpm >  Average Read Time:8.5 ms > ... > From this data nothing justifies the 120ms update of the record! Look at 7200 rpm and here http://www.sqlite.org/faq.html#q19. Pavel On Wed, Feb 3, 2010 at 1:18 PM, a1rex wrote: > > Thank you kindly for all your sugges

Re: [sqlite] Having trouble with "Update"

2010-02-03 Thread Pavel Ivanov
String constants should be enclosed in single quotes. Double quotes are for identifiers. So in your case you make perfectly legal no-op action - update field R with value of field R, i.e. leave field R unchanged. Pavel On Wed, Feb 3, 2010 at 4:43 PM, Ron Hudson wrote: > I am using the latest ver

Re: [sqlite] Having trouble with "Update"

2010-02-03 Thread Pavel Ivanov
: > Pavel Ivanov wrote: >> String constants should be enclosed in single quotes. Double quotes >> are for identifiers. So in your case you make perfectly legal no-op >> action - update field R with value of field R, i.e. leave field R >> unchanged. >> >> Pavel &g

Re: [sqlite] When incremental write is committed to the hard drive?

2010-02-04 Thread Pavel Ivanov
All incremental writing is committed (and thus is written to disk) when blob handle is closed. And even when you close the handle transaction is committed only when there's no more blob handles or SELECT statements open at the moment on the same connection. Pavel On Wed, Feb 3, 2010 at 7:41 PM, a

Re: [sqlite] When incremental write is committed to the hard drive?

2010-02-04 Thread Pavel Ivanov
> 1) What else can prevent incremental data to be written to the hard drive? Besides all that I mentioned only explicit BEGIN statement can open transaction and thus prevent anything after that from being written to disk immediately until COMMIT is executed. What you can do now is first of all use

Re: [sqlite] When incremental write is committed to the hard drive?

2010-02-04 Thread Pavel Ivanov
red > and pending. At the same time sqlite3_sql(pStmt) says that that statement is > a NULL statement. > > I just got more confused. > > Best regards, > Samuel > > > - Original Message > From: Pavel Ivanov > To: General Discussion of SQLite Database > Se

Re: [sqlite] Multi-process read_uncommited equivalent?

2010-02-05 Thread Pavel Ivanov
First of all there's no multi-process equivalent of read_uncommitted. There's just no way to implement that. If you want such type of behavior with your current application structure then you should use some other RDBMS. For SQLite though I'd suggest you to use some variation of you 3rd approach:

Re: [sqlite] Nesting Read/Write within Transaction?

2010-02-12 Thread Pavel Ivanov
Besides the fact that I don't understand what you have meant by these lines: >     Select * from table where lookup_key = "ABC" >     append save results to my list. I don't see anything unusual in your algorithm. What do you want us to verify (which you cannot verify yourself) and what do you fi

Re: [sqlite] Nesting Read/Write within Transaction?

2010-02-12 Thread Pavel Ivanov
the long run. > > > > Pavel Ivanov-2 wrote: >> >> Besides the fact that I don't understand what you have meant by these >> lines: >> >>>     Select * from table where lookup_key = "ABC" >>>     append save results to my list. >> >

Re: [sqlite] Database is locked error

2010-02-19 Thread Pavel Ivanov
Apparently the following happens: 13875           Thread2 SAVEPOINT Thread2                       success (shared lock acquired) 13875           Thread1 SAVEPOINT Thread1                       success (shared lock acquired) 13880           Thread2 INSERT INTO TableB              success (reserved

Re: [sqlite] SQLite BUSY error - single-threaded app

2010-02-22 Thread Pavel Ivanov
> All of the archive content on SQLITE_BUSY appears to assume multi-threaded > database access; I have only a primary thread. There's also multi-process access. Is there any chance that there're several instances of your application running at the same time? What is your test case exactly? Is it y

Re: [sqlite] Query plan of MAX (id) versus MAX (id) + 1 in a range

2010-02-22 Thread Pavel Ivanov
> Obvioulsy, SQLite already have a special case optimization for MAX (id), > but optimization breaks with MAX (id) + 1, making it impractical for use in > INSERT SELECT. Even not all kind of MAX(id) queries are optimized: http://www.sqlite.org/optoverview.html#minmax Pavel On Mon, Feb 22, 2010

Re: [sqlite] Order of triggers

2010-02-22 Thread Pavel Ivanov
I cannot find right now details on this in SQLite documentation but AFAIK order of triggers execution is undefined and you cannot rely on any of them. Pavel On Mon, Feb 22, 2010 at 3:15 PM, Jens Frøkjær wrote: > Hi, > > I was wondering in what order triggers are executed. I'm using the after >

Re: [sqlite] Database is locked error

2010-02-22 Thread Pavel Ivanov
> Does that seem correct? Yes. > If so, my options are: > > 1)  rollback/commit one of the transactions > > 2)  use begin exclusive That's correct, but it's better to be 'begin immediate' than 'exclusive'. > I don't think the second one will work, since I need nested transactions > and the save

Re: [sqlite] Query plan of MAX (id) versus MAX (id) + 1 in a range

2010-02-22 Thread Pavel Ivanov
> Did you try something like: > > SELECT  id + 1 FROM foo WHERE id>= 100 AND id<  200 and id = MAX (id); Probably you meant SELECT  id + 1 FROM foo WHERE id>= 100 AND id<  200 ORDER BY id DESC LIMIT 1; Otherwise it's incorrect SQL. Pavel On Mon, Feb 22, 2010 at 5:27 PM, Jim Morris wrote: > D

Re: [sqlite] Unable to recover the DB by vacuum

2010-02-23 Thread Pavel Ivanov
> How can i recover this kind of DB, is it possible? and is there any way > to avoid these > unused pages, will enable auto_vacuum solve the problem ? 'VACUUM' is not designed to recover malformed database. Yes, there are some kinds of problems that can be eliminated during vacuuming, but not all

<    1   2   3   4   5   6   7   8   9   10   >