Re: [sqlite] How to exit from sqlite shell?

2009-05-04 Thread Pavel Ivanov
In windows shell Control-Z should be equivalent of Control-D on Unix (it sends EOF to stdin). Pavel On Mon, May 4, 2009 at 2:58 PM, Kees Nuyt wrote: > On Mon, 4 May 2009 14:00:45 -0400, "D. Richard Hipp" > wrote: > >> >>On May 4, 2009, at 1:44 PM, Sam Carleton wrote: >> >>> prefix with a period

Re: [sqlite] SQL error: database disk image is malformed

2009-05-05 Thread Pavel Ivanov
Is it just me or somebody else is seeing too that the sql statement "select blobid, fbid from sig group by peerid" is invalid and shouldn't be executed or prepared at all? Pavel On Mon, May 4, 2009 at 2:51 PM, Joanne Pham wrote: > Hi All, > I ran the following sql statement: >     select blobid,

[sqlite] Performance of in-memory database and memory journal

2009-05-06 Thread Pavel Ivanov
Hi, all! Recently I've discovered that my application works faster if it uses journal_mode = PERSIST instead of MEMORY. After running under callgrind I've found that with journal_mode = MEMORY application spends a lot of time inside malloc() which is called from memjrnlWrite(). Is there a way to o

Re: [sqlite] sqlite in shell loop

2009-05-06 Thread Pavel Ivanov
You should do for i in $HANDLER Notice: NO quotes. Though be careful - it will not work if row contains text field with spaces. Pavel On Wed, May 6, 2009 at 5:24 PM, Daniel Wolny wrote: > 2009/5/6 Kees Nuyt : >> On Wed, 6 May 2009 23:01:24 +0200, Daniel Wolny >> wrote: >> It should be possibl

Re: [sqlite] Performance of in-memory database and memory journal

2009-05-06 Thread Pavel Ivanov
one statement, then this insert will be able to rollback harmlessly even without journal? Pavel On Thu, May 7, 2009 at 12:27 AM, Dan wrote: > > On May 7, 2009, at 3:27 AM, Pavel Ivanov wrote: > >> Hi, all! >> >> Recently I've discovered that my application works

Re: [sqlite] Combining .output and .read in a batch file

2009-05-07 Thread Pavel Ivanov
Maybe you want to do sqlite3 test.db ".output o.txt; .read r.sql" Pavel On Thu, May 7, 2009 at 6:44 AM, Leo Freitag wrote: > Hallo, > > I try to get run the following in a batch file > > Open database "test.db" > Set output to "o.txt" > Read sql-statement form "r.sql" > > === r.sql - Start === >

Re: [sqlite] SQLite version 3.6.14 and async vfs

2009-05-07 Thread Pavel Ivanov
Hi! It's great to hear about performance improvements and especially about asynchronous I/O extension. Thank you very much for your work! I have one question though: taking quick look at the sources of async vfs I've noticed that even closing the file is just a task in the async queue and thus af

Re: [sqlite] SQLite version 3.6.14 and async vfs

2009-05-07 Thread Pavel Ivanov
operations complete to meet that needs. >> I think asynchronous VFS should take care of waiting in >> sqlite3_close() >> call. >> >> -Original Message- >> From: sqlite-users-boun...@sqlite.org >> [mailto:sqlite-users-boun...@sqlite.org] >> O

Re: [sqlite] SQLite version 3.6.14 and async vfs

2009-05-07 Thread Pavel Ivanov
. I will think what can I do in this situation. Pavel On Thu, May 7, 2009 at 12:54 PM, Dan wrote: > > On May 7, 2009, at 10:33 PM, Pavel Ivanov wrote: > >> Hi! >> >> It's great to hear about performance improvements and especially about >> asynchronous I/O e

Re: [sqlite] setting a date in a BEFORE INSERT trigger

2009-05-09 Thread Pavel Ivanov
According to the syntax of CREATE TRIGGER statement you can use in the trigger body only insert/update/delete/select statements. There's no support of simple assignments or any other programming language extensions. Pavel On Sat, May 9, 2009 at 11:11 AM, Sam Carleton wrote: > This is my first BE

Re: [sqlite] Multiple counts between two tables

2009-05-10 Thread Pavel Ivanov
Try something like this: SELECT tag_name.id, SUM(CASE WHEN tag_link.app = 't' THEN 1 ELSE 0) AS cntTwt, SUM(CASE WHEN tag_link.app = 'd' THEN 1 ELSE 0) AS cntDel FROM tag_name, tag_link WHERE tag_link.tag_id = tag_name.id GROUP BY tag_name.id Pavel On S

Re: [sqlite] Multiple counts between two tables

2009-05-10 Thread Pavel Ivanov
tag_id = tag_name.id GROUP BY tag_name.id Pavel On Sun, May 10, 2009 at 7:40 PM, Pavel Ivanov wrote: > Try something like this: > > SELECT >       tag_name.id, >       SUM(CASE WHEN tag_link.app = 't' THEN 1 ELSE 0) AS cntTwt, >       SUM(CASE WHEN ta

Re: [sqlite] Prepared statements must be generated inside your transaction

2009-05-12 Thread Pavel Ivanov
I believe, these matters are very specific for each database server (though I can't recall server for which it's true what you say). What specific server is talked about in this book? What's the name of this book? As long as SQLite is a concern, I prepare statements outside of transaction and then

Re: [sqlite] Prepared statements must be generated inside your transaction

2009-05-12 Thread Pavel Ivanov
009 at 12:48 PM, Joanne Pham wrote: > Thanks for quick responde my email > This is sqlite documentation. Below is the link and last paragraph in this > document has stated that. > > http://www.sqlite.org/cvstrac/wiki?p=PerformanceTuning > > > _________

Re: [sqlite] Program is crashed on sqlite3_free

2009-05-12 Thread Pavel Ivanov
Double call to sqlite3_finalize() ? Pavel On Tue, May 12, 2009 at 5:22 PM, Joanne Pham wrote: > Hi all, > I have the application and occasionally it is crashed on sqlite3_free when it > callled sqlite3_finalized and I really didn't know what problem it was. > Below is stack trace. > Do you hav

Re: [sqlite] Bad UPDATE performance

2009-05-12 Thread Pavel Ivanov
Just a couple of questions that can clarify situation: Do you work with pragma synchronous = FULL? Does the behavior of the journal you have described remains if you change pragma journal_mode = PERSIST? Pavel On Tue, May 12, 2009 at 4:15 PM, Ofir Neuman wrote: > Hi, > > Using version 3.6.10.0.

Re: [sqlite] Transaction isolation

2009-05-18 Thread Pavel Ivanov
SQLite doesn't support several simultaneous transactions on the same connection to database. So in fact your select and insert statements execute in the same transaction. And even more: your inserts are not committed until your select is completely finished. So for your task you should use differen

Re: [sqlite] error in documentation of SELECT?

2009-05-18 Thread Pavel Ivanov
I didn't notice it earlier and now I'm a bit surprised. Can I ask a more elaborate example which will include WHERE and/or GROUP BY but not include FROM? Pavel On Mon, May 18, 2009 at 2:32 PM, D. Richard Hipp wrote: > > On May 18, 2009, at 2:18 PM, Mitchell L Model wrote: > >> Is it really possi

Re: [sqlite] error in documentation of SELECT?

2009-05-18 Thread Pavel Ivanov
order by 1 > > Noah > > -Original Message- > From: sqlite-users-boun...@sqlite.org > [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Pavel Ivanov > Sent: Monday, May 18, 2009 11:37 AM > To: General Discussion of SQLite Database > Subject: Re: [sqlite] error in doc

Re: [sqlite] Fw: Question about reading all database data into memory

2009-05-21 Thread Pavel Ivanov
Why do you expect performance improvement in your approach as opposed to implemented now? Pavel On Thu, May 21, 2009 at 1:56 PM, rajyalakshmi bommaraju wrote: > I did not get any reply so adding bit more explanation for what I need. > > In a C program, I am trying to read data from database. I u

Re: [sqlite] Fw: Question about reading all database data into memory

2009-05-21 Thread Pavel Ivanov
ue for that name for x times. instead I get > values into tuple in one call. > > -Raji > > --- On Thu, 5/21/09, Pavel Ivanov wrote: > > From: Pavel Ivanov > Subject: Re: [sqlite] Fw: Question about reading all database data into memory > To: "General Discussion of

Re: [sqlite] a problem with sqlite3_get_table

2009-05-26 Thread Pavel Ivanov
Instead of exe_query(query.str()); try to do this: size_t len = query.pcount(); exe_query(string(query.str(), len).c_str()); Stringstream never puts 0 byte at the end of the string. Pavel On Tue, May 26, 2009 at 12:12 PM, Enrico Piccinini wrote: > Hy to all, I'm very new to database and sqli

[sqlite] Global cache size restriction

2009-05-29 Thread Pavel Ivanov
Hi, all! Is there a way to set global restriction on cache size in SQLite? I like the default cache_size value for each database. But if I open a lot of different databases then total cache size for all of them could be too big for me. So I'd want to set some global_cache_size to limit it. Is it p

Re: [sqlite] 2 columns as primary key?

2009-05-29 Thread Pavel Ivanov
What create table statement did you use? Pavel 2009/5/29 "Andrés G. Aragoneses" : > I just tried to create a primary key with 2 columns and got this error: > > "sqlite error" "table X has more than one primary key" > > > Doesn't SQLite support this?? :o > >        Andres > > -- > > __

Re: [sqlite] GROUPY BY alias backward incompatibility

2009-05-30 Thread Pavel Ivanov
> * The query that works on SQLite all versions fails on Oracle. False conclusion. Did you try to make only one row in t? > * Behaviour is inconsistent between MySQL and Oracle. I believe this conclusion is also false. Did you try several rows in t on MySQL? If it worked I wonder how it showed

Re: [sqlite] Join performance in SQLite

2009-05-30 Thread Pavel Ivanov
> Do other SQL database engines not have this same limitation? Are > MySQL and PostgreSQL and Firebird and MS-SQL and Oracle creating > phantom indices on-the-fly to help them do joins faster, for example? Sort of. There's 2 types of join methods in Oracle for this - Hash joins and Sort merge joi

Re: [sqlite] UPDATE TRIGGER works in all records

2009-06-01 Thread Pavel Ivanov
Your trigger basically does this: UPDATE t SET b = DATETIME('now','localtime') WHERE 1 != 0; So it updates all rows in the table. Try to change it to this: UPDATE t SET b = DATETIME('now','localtime') WHERE rowid = new.rowid; Pavel On Sun, May 31, 2009 at 7:44 AM, Oliver Peters wrote: > Afte

Re: [sqlite] how can we solve IF EXIST in SQLite

2009-06-02 Thread Pavel Ivanov
If you have unique index on stock_tab.prod_batch_code then you can re-write your trigger as this: INSERT OR REPLACE INTO stock_tab (stock_id, prod_batch_code, stock_qty, stock_date) SELECT new.purchase_id+2, new.prod_batch_code, new.purchase_qty + ifnull(b.stock_qty

Re: [sqlite] How to change the default values option when build SQLite 3.6.14

2009-06-03 Thread Pavel Ivanov
You can do during configuration: ../sqlite/configure -DSQLITE_THREADSAFE=2 Pavel On Wed, Jun 3, 2009 at 2:27 PM, Joanne Pham wrote: > Hi All, > I would like to build the SQLite 3.6.14 to following the steps as mentioned > in the document >     tar xzf sqlite.tar.gz ;# Unpack the source tree i

Re: [sqlite] "not an error" error inserting data trough a view on fts3 table

2009-06-05 Thread Pavel Ivanov
"Not an error" is SQLITE_OK. Are you sure that you don't do anything between getting error code from SQLite and obtaining error message? Maybe in another thread? Pavel On Fri, Jun 5, 2009 at 3:50 AM, Vladimir Kharitonov wrote: > I have a problem inserting data through a view. > > This is my DB:

Re: [sqlite] Working with a new DB every 5 minutes

2009-06-08 Thread Pavel Ivanov
I'd create another special file (maybe even database) that will keep information about current file that your program should be working with. So separate process will create new database and then update this file. And program will just read this file and then work with database mentioned in the fil

Re: [sqlite] Working with a new DB every 5 minutes

2009-06-08 Thread Pavel Ivanov
ite code to open databasses with FILE_SHARE_DELETE flag. In this case you will be able to work the same way as on Unix. Pavel On Mon, Jun 8, 2009 at 3:24 PM, Mohit Sindhwani wrote: > Pavel Ivanov wrote: >> I'd create another special file (maybe even database) that will keep >>

Re: [sqlite] Order by term not in result set

2009-06-10 Thread Pavel Ivanov
It mentions "from" and "column_name" where column name in this particular case is "selected". ;-) @Igor: I thought that sql standard in this case doesn't guarantee that outer select will return rows in the same order that were enforced in inner select by "order by", does it? Pavel On Wed, Jun 10

Re: [sqlite] Slow select from a single table when using a view

2009-06-11 Thread Pavel Ivanov
I think you should try to rewrite condition to exclude OR like this: WHERE C >= 1 AND C <= 2. You can even do like this: WHERE C >= 1 AND C <= 3 AND (C = 1 OR C = 3). I think it will be faster than just ORed conditions alone. Pavel On Thu, Jun 11, 2009 at 5:19 AM, Antti Nietosvaara wrote: > On Th

Re: [sqlite] Advice on which to use (SQLite or SQL Server) for the following app.

2009-06-11 Thread Pavel Ivanov
I bet "synchronous"ness will not be your only bottleneck. Opening connection, preparing statement and closing connection will take in total much longer than executing statement itself. So that doing all these operations 500 times per second will not be possible I think. If you keep pool of connecti

Re: [sqlite] UPDATE with inline view/ derived table

2009-06-11 Thread Pavel Ivanov
According to this http://www.sqlite.org/lang_update.html you have invalid syntax. I believe you can achieve the same by this (assuming that id is unique in fud28_thread): UPDATE fud28_read SET user_id=2, last_view=1244710953, msg_id=(SELECT last_post_id FROM fud28_thread

Re: [sqlite] Database inserts gradually slowing down

2009-06-16 Thread Pavel Ivanov
How do you do step 5? Like "delete from table" or "delete from table where ..."? Do you see any degrade in disk space used by database along with slowness? Pavel On Tue, Jun 16, 2009 at 8:06 AM, Jens Páll Hafsteinsson wrote: > Hi > > I've been running some tests against sqlite and have found that

Re: [sqlite] Rather SQL quiestion

2009-06-16 Thread Pavel Ivanov
Try this: select c.* from players a, registrations b, players c where a.device_id = b.device_id and b.mesg_token='123456' and a.table_group_id = c.table_group_id and a.table_id = c.table_id Pavel On Tue, Jun 16, 2009 at 11:25 AM, Boris Ioffe wrote: > > Hello folks, > I am having

Re: [sqlite] Literal replacements in prepared statements

2009-06-19 Thread Pavel Ivanov
You're trying identifier replacement, not literal replacement. It's not allowed. You have to write table name without binding. Pavel On Fri, Jun 19, 2009 at 9:58 AM, Shaun Seckman (Firaxis) wrote: > I'm trying to add some literal replacements in my prepared SQL statement > but I'm currently getti

Re: [sqlite] Literal replacements in prepared statements

2009-06-19 Thread Pavel Ivanov
ure I fully understand what you mean.  Is it not possible to replace the > table name in the prepared statement?  What sort of things can I replace then? > > -Original Message- > From: sqlite-users-boun...@sqlite.org > [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of P

Re: [sqlite] integer primary key autoincrement & sqlite_sequence

2009-06-22 Thread Pavel Ivanov
Hi, Richard! Could you explain why this scenario doesn't cause infinite call cycle of the trigger by itself? Is there some protection in SQLite which breaks such cycles? Pavel On Mon, Jun 22, 2009 at 4:10 PM, D. Richard Hipp wrote: > > On Jun 22, 2009, at 3:33 PM, Oliver Peters wrote: > >> Hello

Re: [sqlite] How can I specify that a column is equal to another?

2009-07-01 Thread Pavel Ivanov
You can do only where movies.id = 'tt0426459' or where user.id = 'tt0426459' What to choose depends on your needs. And you're wrong that these variants are identical and movies.id is always equal to user.id because you're making left join. They will be identical if you will make inner join. But ev

Re: [sqlite] SQLite3: Database is sometimes locked when a reader is attached with open_v2

2009-07-02 Thread Pavel Ivanov
>From http://www.sqlite.org/lockingv3.html: -- Eventually, the writing process will want to update the database file, either because its memory cache has filled up or because it is ready to commit its changes. Before this happens, the writer must make sure no ot

Re: [sqlite] Nested Inner Join Help

2009-07-02 Thread Pavel Ivanov
I believe you need this: SELECT A.ID, A.Column1, A.Column2, B.Column1, C.Column1 FROM A INNER JOIN B ON A.Column3 = B.ID INNER JOIN C ON B.Column2 = C.ID Pavel On Thu, Jul 2, 2009 at 2:53 PM, Ed Hawke wrote: > Hi all, > > I'm having problems getting nested inner joins to work with

Re: [sqlite] there is problem when getting data by sqlite3's c apis in signal-handling func

2009-07-08 Thread Pavel Ivanov
> there is problem when getting data by sqlite3's c apis in signal-handling > func. What problem? And as a hint: are you sure that your SQLite is in correct thread-safety mode and you're not trying to dead-lock your application? Pavel On Mon, Jul 6, 2009 at 9:58 PM, liubin liu<7101...@sina.com>

Re: [sqlite] unable to backup using command line

2009-07-08 Thread Pavel Ivanov
Did you try sqlite3 accounts.db ".backup main a.db" (note the quotes)? Pavel On Tue, Jul 7, 2009 at 2:28 PM, Eric Peterson wrote: > > > > C:\InWork\rsm\weekly_status>sqlite3 accounts.db .database > seq  name             file > ---  ---  --- >

Re: [sqlite] SQLITE_OMIT_AUTOVACUUM seems to need small change in btree.c

2009-07-08 Thread Pavel Ivanov
Is this related to your problem? http://www.sqlite.org/cvstrac/tktview?tn=3940 Pavel On Wed, Jul 8, 2009 at 4:06 AM, Yan Bertrand wrote: >                Hello, > > > > I am compiling SQLite with options to reduce the size, and with hopes to > reduce the duration of some operations on portable de

Re: [sqlite] is the sqlite3's C-api used in thread-safety mode ? or non-reentrant?

2009-07-09 Thread Pavel Ivanov
Why do you re-post your code as if it's another question not related to previous one (along with the answer)? > does it mean that the sqlite3's C-api isn't reentrant or thread-safety? If SQLite is compiled with SQLITE_THREADSAFE = 1 or 2 then API is thread-safe (with some limitations when it's 2)

Re: [sqlite] is the sqlite3's C-api used in thread-safety mode ? or non-reentrant?

2009-07-10 Thread Pavel Ivanov
> SQLite does the right thing > for multi-threaded applications and many use it that way - you are not > the first. Roger, note that OP is talking about re-entrance, not thread-safety. He wants to know which functions can be called from signal handlers which can be called in the middle of some oth

Re: [sqlite] range enclosing a number

2009-07-13 Thread Pavel Ivanov
Jay, you're pretty much mistaken: > I'm pretty sure you don't want to do it this way. What this does is > gather every row that meets the WHERE condition and then runs a max() > or min() aggregation function across all of those rows. That means > that even if the column "number" has an index

Re: [sqlite] range enclosing a number

2009-07-14 Thread Pavel Ivanov
t;select * ... where ticks = (select max(ticks) ...)" approach. Pavel On Tue, Jul 14, 2009 at 12:35 AM, Jay A. Kreibich wrote: > On Mon, Jul 13, 2009 at 10:33:00PM -0400, Pavel Ivanov scratched on the wall: >> Jay, you're pretty much mistaken: >> >> >  I&#x

Re: [sqlite] Optimizing insert or replace speed

2009-07-14 Thread Pavel Ivanov
I believe your choice of query is not good enough. Try this one: insert or replace into main.masterlist select d.* from delta.masterlist d left outer join main.masterlist M on d.sn = M.sn where d.write_out_ok=0 and d.record_updatetime >= ifnull(M.record_updatetime, '') Pavel

Re: [sqlite] Protect against SQL injection inside of the database?

2009-07-16 Thread Pavel Ivanov
Does Tcl supports binding of parameters to prepared statement? If yes then do just that and you will not need to do any "quotes" and think of any "ifs". Pavel On Thu, Jul 16, 2009 at 3:49 AM, Fredrik Karlsson wrote: > Dear list, > > Sorry for jumping onto the list mainly to ask a question, but it

Re: [sqlite] Performance issue on records retrieval :: 100, 000 records

2009-07-16 Thread Pavel Ivanov
> Suppose, if I don't have index, is this the desired behavior of Sqlite > to take this much time to fetch just 10 records or am I missing > something here. You're missing that SQLite have to fetch all records satisfying your condition into memory storage, sort all these records in memory and then

Re: [sqlite] Heirarchical queries question

2009-07-17 Thread Pavel Ivanov
Maybe this: select childs.Path, count(*) from Directory childs, Directory hierarchy where childs.ParentDirID = ? and hierarchy.Path like childs.Path || '%' group by childs.Path You should have indexes on ParentDirID and on Path to make this query somewhat effective. And you shouldn't have '%' and

Re: [sqlite] Heirarchical queries question

2009-07-17 Thread Pavel Ivanov
in the path (which is a problem I need > to work around), but what is special about '_' ? > > Thanks > Doug > > >> -Original Message- >> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- >> boun...@sqlite.org] On Behalf Of Pavel I

Re: [sqlite] Some SQL statements are not executing

2009-07-20 Thread Pavel Ivanov
Sounds like you're running several instances of your application in several different processes simultaneously on the same database. Are you sure you don't do that? Pavel On Mon, Jul 20, 2009 at 11:08 AM, Gary Verhaegen wrote: > Hi everybody, > > I just subscribed and this is my first post - I ho

Re: [sqlite] Subqueries

2009-07-21 Thread Pavel Ivanov
Although your query doesn't make sense without any explanation of what did you mean and how it is supposed too work I can provide you a couple of observations: 1) Do you realize that select * doesn't make any sense in this query? The only meaningful field will be ac.AcNum, all others will be essen

Re: [sqlite] Subqueries

2009-07-21 Thread Pavel Ivanov
Then I guess your initial query was almost correct. Try to change it like this: select ac.AcNum, count(au.acNum) as auNum, count(int.acNum) as intNum from academic ac LEFT OUTER JOIN author au on ac.AcNum = au.AcNum LEFT OUTER JOIN interest int on int.AcNum = ac.AcNum group by ac.AcNum having coun

Re: [sqlite] Subqueries

2009-07-21 Thread Pavel Ivanov
Sorry, mis-looked: "as int.AcNumCount" should be "as AcNumCount". Don't see other syntax errors. Pavel On Tue, Jul 21, 2009 at 10:21 AM, Hubboo wrote: > > Thanks. Returns an error > > Likely SQL syntax error: select ac.AcNum, count(au.acNum) as auNum, > count(int.acNum) as intNum > from academic

Re: [sqlite] Memory leak on inserting from sqlite c/c++ interfaces

2009-07-21 Thread Pavel Ivanov
> If I remove or comment out the > three lines with //* in the code above, I get no memory leaks. So basically you're saying that if you don't insert any data into your database and thus effectively don't do with your database anything and thus SQLite don't have to cache anything from database the

Re: [sqlite] Determine if UPDATE has worked.

2009-07-21 Thread Pavel Ivanov
Did you look into this: http://www.sqlite.org/c3ref/changes.html ? Pavel On Tue, Jul 21, 2009 at 7:57 PM, Steve Martin wrote: > Hi List, > > I am new to sqlite and having trouble determining if an update has worked. > > I am using the C/C++ API. > > For an update, when sqlite3_step is executed it

Re: [sqlite] Memory leak on inserting from sqlite c/c++ interfaces

2009-07-22 Thread Pavel Ivanov
ation works and whether it's SQLite uses memory or your application does. BTW, how do you measure memory usage and how do you see leakage? What does sqlite3_memory_used() returns for you? Pavel On Wed, Jul 22, 2009 at 11:26 AM, Zachary Turner wrote: > On Tue, Jul 21, 2009 at 6:45 PM, Pavel

Re: [sqlite] Memory leak on inserting from sqlite c/c++ interfaces

2009-07-22 Thread Pavel Ivanov
se that would obviously be > ideal. Again, try to call sqlite3_memory_used() several times during work of your application. What does it say to you? Pavel On Wed, Jul 22, 2009 at 2:30 PM, Zachary Turner wrote: > On Wed, Jul 22, 2009 at 10:47 AM, Pavel Ivanov wrote: >> SQLite synchr

Re: [sqlite] Reporting on summary data

2009-07-24 Thread Pavel Ivanov
> And how can I calculate the value for Action? Just do the same approach with CASE you've already used: Select ID, CASE WHEN d1='X' AND d2 IS NULL THEN 'NEW' WHEN d1 IS NULL AND d2='X' THEN 'DROP' ELSE 'CHANGE' END AS Action, Sum(CASE WHEN d1='X' THEN AMT ELSE 0 END) - Sum(CASE WHEN d2='

Re: [sqlite] Nested transactions

2009-07-24 Thread Pavel Ivanov
First of all in case you've mentioned it will be not nested transaction but one transaction including all deletes and it will be committed when select statement will be finished. As a second note: it's pretty bad idea to change table which is used in not yet finished select statement. In SQLite it

Re: [sqlite] Reporting on summary data

2009-07-24 Thread Pavel Ivanov
X' then amt else -amt end) as net from Source group by id ) order by 2 desc; Pavel On Fri, Jul 24, 2009 at 3:44 PM, David Bicking wrote: > > >> From: Pavel Ivanov >> >> Just do the same approach with CASE you've already used: >> >> Select ID,

Re: [sqlite] Fastest way to insert lots of data

2009-07-24 Thread Pavel Ivanov
Try to add to your SQLite test these steps: 3.5) Execute statement BEGIN (you can do it via prepared statement). 5.5) Say every 10 000 records execute COMMIT and then BEGIN again. Or if you indeed want to measure maximum write speed then skip this step at all. And your words that pragma synchronou

Re: [sqlite] .lib file?

2009-07-25 Thread Pavel Ivanov
You can take sqlite3.c from amalgamation package and include it into your project. This way SQLite will be included into your application and you won't need any .dll or .lib files. Pavel On Sat, Jul 25, 2009 at 10:41 AM, Paul Claessen wrote: > Greetings, > > > > I'm trying to build and use the sh

Re: [sqlite] Date Modifier '%w' Does Not Behave as INTEGER

2009-07-27 Thread Pavel Ivanov
For me it's pretty obvious that strftime() returns text data type because it returns your date formatted as you like. And SQLite have never compared text and integer as equal even if they have the same notation when converted to text: sqlite> select 1 where '1' = 1; sqlite> select 1 where '1' = '1

Re: [sqlite] How to disable fsync() in SQLite

2009-07-27 Thread Pavel Ivanov
Execute pragma synchronous = off; after opening connection to database. More info: http://www.sqlite.org/pragma.html#pragma_synchronous. Pavel On Mon, Jul 27, 2009 at 2:31 PM, W.-H. Gu wrote: > Hi, > >   Is there a way to disable fsync() in my SQLite application on Linux? I > saw a discussion

Re: [sqlite] a system for arbitrarily tagging rows -- revisited

2009-07-28 Thread Pavel Ivanov
First of all you've mentioned schema which is not in agreement slightly with sql you've given. But of course we can guess... Second your sql seems to do slightly different thing from what you're saying. In particular I'm concerned about this sentence: > If the tag is the same as the 'current_tag',

Re: [sqlite] a system for arbitrarily tagging rows -- revisited

2009-07-28 Thread Pavel Ivanov
ase I've decided to continue to write in your syntax preference and put related conditions (pt_p.page_id = pt_np.page_id AND pt_np.tag_id != 1) in one place because I think when they stand nearby intention of the query is more understandable. Pavel On Tue, Jul 28, 2009 at 9:59 PM, P Kishor

Re: [sqlite] except and select

2009-07-29 Thread Pavel Ivanov
Maybe this way: select t.* from table_name t left outer join table_name t_del on t_del.operation = 'Deleted' and t_del.Filename = t.RenameTo where t.operation = 'Renamed' and t_del.ID is null union all select t.* from table_name t left outer join table_name t_ren

Re: [sqlite] sqlite3_get_table and probable memory leak

2009-07-30 Thread Pavel Ivanov
0x490 = 1168 Sounds like memory required to store one page of size 1024 in SQLite database cache. Does your database has this size of pages? Will this leak be gone if you close database connection? Pavel On Thu, Jul 30, 2009 at 7:00 AM, Maciej Miszczak wrote: > Hi, > > I have a simple function (u

Re: [sqlite] Use of in memory db

2009-07-30 Thread Pavel Ivanov
> What I assume is if I share an in memory db connection handle across threads > then it will not be sqlite's responsibility but the user's responsibility to > protect multiple insert/update statements. On the other hand if the > connection to physical db is shared amongst threads then sqlite ta

Re: [sqlite] sqlite3_get_table and probable memory leak

2009-07-30 Thread Pavel Ivanov
> Is lowering the PRAGMA cache_size a good way to fix this? Yes, it's the only way to fix this. Though IIRC you cannot lower it below 10, so 10 pages will be always stored in memory. OTOH you can implement your own version of page cache that will not leave pages in memory at all (for more informat

Re: [sqlite] Date Comparisons SQL

2009-08-03 Thread Pavel Ivanov
> How do you properly do a Date comparison in SELECT so that the only rows > returned are those that do not exceed the date found in my sDateTemp > variable? As a simple string comparison. You made it perfectly right except that your Date field should be stored in a format '-mm-dd' in database

Re: [sqlite] Date Comparisons SQL

2009-08-03 Thread Pavel Ivanov
> I've attached a view of the results from the working SQL statement that does > not perform the WHERE. Attachments do not come through to this list. > Also, as stated in my previous post, I have sDateTemp formatted in the same > format as that which is in the table. Could you elaborate: your sD

Re: [sqlite] How to create a data of unsigned int?

2009-08-07 Thread Pavel Ivanov
int64 type is okay to store data of type unsigned int. And int64 is exactly the type used for all integers in SQLite. Pavel On Fri, Aug 7, 2009 at 5:53 AM, liubin liu<7101...@sina.com> wrote: > > I want to use a integer to save the ip address of ipv4. Because they all are > 4 bytes. > > but it is

Re: [sqlite] How to create a data of unsigned int?

2009-08-07 Thread Pavel Ivanov
I think that's ok to use the int type to store the four byte. > Because I could get the value by using forced conversion. > > But Do SQLite3 support the unsigned type? > > And You know that int64 is too wasting here. > > > > Pavel Ivanov-2 wrote: >> >

Re: [sqlite] Concurrency Question

2009-08-07 Thread Pavel Ivanov
> If I have 2 separate processes, 1 of which will attempt to Read and Write a > Database (Process A) > and the 2nd which will only Read the database (Process B), then if Process A > is in the middle of a Write when Process B tries to read what will happen? If Process A is in the middle of writing

Re: [sqlite] Busy Handler in Shared Cache Mode?

2009-08-07 Thread Pavel Ivanov
Maybe you could benefit of using sqlite3_unlock_notify()? See more info here: http://www.sqlite.org/c3ref/unlock_notify.html. Pavel On Fri, Aug 7, 2009 at 1:45 PM, Nikolaus Rath wrote: > Hello, > > I have program that continuously runs several threads (about 4 to 10) > which concurrently read an

Re: [sqlite] Table Exists Query

2009-08-16 Thread Pavel Ivanov
Why not make it this way: select 'database1', lists.* from database1.lists union all select 'database2', lists.* from database2.lists; This way you will know exactly which lists persist in which database. Pavel On Sat, Aug 15, 2009 at 10:57 AM, Andrew Gatt wrote: > Simon Slavin wrote: >> On 15

Re: [sqlite] Multiple indexes in SQLite, and selecting which to use

2009-08-16 Thread Pavel Ivanov
> Is there any way the code can 'suggest' SQLite use a certain index? Does INDEXED BY clause work for you? http://www.sqlite.org/lang_select.html Pavel On Sat, Aug 15, 2009 at 2:08 AM, His Nerdship wrote: > > Good day, > We have a puzzling problem with a large (1GB+) database. > Most of our que

Re: [sqlite] Rows where people connected in the past 2 weeks?

2009-08-18 Thread Pavel Ivanov
Just try these and you'll see why. sqlite> select julianday('18-08-2009'); sqlite> select julianday('now') - julianday('18-08-2009'); Pavel On Tue, Aug 18, 2009 at 12:58 PM, Gilles Ganault wrote: > Hello > > I thought this query would work to read a date column that holds the > DD-MM- date

Re: [sqlite] Increment a value if constraint violated

2009-08-18 Thread Pavel Ivanov
You can always do insert into table (id, count) values (?1, (select count(*) + 1 from table where id = ?1)) Though I'd be cautious about race condition that seems like possible here when after select returned some value and before insert was made another process made another insert with the same

Re: [sqlite] Increment a value if constraint violated

2009-08-18 Thread Pavel Ivanov
009 at 1:54 PM, Dan Kennedy wrote: > > On Aug 19, 2009, at 12:35 AM, Pavel Ivanov wrote: > >> You can always do >> >> insert into table (id, count) values (?1, (select count(*) + 1 from >> table where id = ?1)) >> >> Though I'd be cautious about ra

Re: [sqlite] Increment a value if constraint violated

2009-08-18 Thread Pavel Ivanov
>> So executing the insert/update/delete statement places RESERVED lock >> right from the start before executing nested selects? > > Yes. Then I stand corrected. Thank you. Pavel On Tue, Aug 18, 2009 at 2:04 PM, Dan Kennedy wrote: > > On Aug 19, 2009, at 1:0

Re: [sqlite] Increment a value if constraint violated

2009-08-19 Thread Pavel Ivanov
> insert or replace into mytable(id, count) > values (:id, coalesce((select count from mytable where id=:id), 0) + 1); I guess it doesn't work as OP intended: sqlite> select * from t; id|count 1|1 1|2 1|3 1|4 sqlite> insert or replace into t(id, count) values (1, coalesce((select count from t whe

Re: [sqlite] SQL documentation

2009-08-19 Thread Pavel Ivanov
Personally for me the current documentation style is more understandable at a glance. Looking at it it's easier for me to understand the sequence of terms I should use, what can be omitted, what terms cannot be used together and so on. Old style looks for me more like list of requirements for progr

Re: [sqlite] Huge numbers of savepoints.

2009-08-19 Thread Pavel Ivanov
But how do you expect your application to deal with restarts and/or OS crashes? Do you want to still be able to revert to "marks" set in previous application run or not? And what about accessing to the data stored between "marks" from other processes? Pavel On Wed, Aug 19, 2009 at 4:07 AM, Chris

Re: [sqlite] PRAGMA locking_mode could stand a rewrite

2009-08-19 Thread Pavel Ivanov
> 1. When is a lock released during a SELECT? Is it after the first > call to step()? The last call to step()? The call to finalize()? > Yes, I'm using the C API. Lock is released during the call to finalize() or reset(). > 2. If while in the step() process of a SELECT, there is a c

Re: [sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread Pavel Ivanov
Without looking at your select statement it's very hard to help. But general suggestion is insert your results into temporary table and then issue a select on that table joined with itself with condition like t.rowid = prev.rowid + 1. Pavel On Wed, Aug 19, 2009 at 10:10 AM, Mário Anselmo Scandela

Re: [sqlite] Increment a value if constraint violated

2009-08-19 Thread Pavel Ivanov
eted as "unique constraint on id-count pair". So let's wait for the answer. :) Pavel On Wed, Aug 19, 2009 at 12:05 PM, Igor Tandetnik wrote: > Pavel Ivanov wrote: >>> insert or replace into mytable(id, count) >>> values (:id, coalesce((select count from m

Re: [sqlite] update - select

2009-08-20 Thread Pavel Ivanov
If you have synonym for rowid (i.e. column INTEGER PRIMARY KEY) or some other unique columns combination then you can do something like this: INSERT OR REPLACE INTO table_1 (rowid, field_a, field_b, field_c, field_d) SELECT table_1.rowid, table_2.field_a, table_2.field_b, table_2.field_c, ta

Re: [sqlite] (no subject)

2009-08-21 Thread Pavel Ivanov
> If they are stored with wchar_t, then using the '16' APIs is > probably easiest to use (ie sqlite3_open16, sqlite3_prepare16_v2, etc). Just don't forget that wchar_t on some platforms (reportedly on Linux for example) is 32-bit integer. So conversion between wchar_t and UCS-2 encoding is not alw

Re: [sqlite] (no subject)

2009-08-21 Thread Pavel Ivanov
> Is there really anyone using UCS-2 now or did you mean UTF-16? No, I meant exactly UCS-2. Because UCS-2 guarantees that all symbols are represented by 2 bytes when UTF-16 does not. And I had an understanding that Doug said about this 16-bit guarantee. Also if we're talking about encoding where a

Re: [sqlite] Huge numbers of savepoints.

2009-08-23 Thread Pavel Ivanov
f application 'state', allowing current state to be > recalculated if an historic input is received 'late'.  See > http://www.finalcog.com/haskell-decoupling-time-from-physics for a > similar idea (implemented in Haskell). > > Regards, > > Chris. > > On Aug 19, 2:

Re: [sqlite] datetime('now', 'utc') vs. CURRENT_TIMESTAMP

2009-08-25 Thread Pavel Ivanov
> Do I misunderstand something fundamental? According to http://www.sqlite.org/lang_datefunc.html datetime('now') returns date and time already as UTC. If you add 'utc' modifier then it makes datetime() think that it's your local time and convert it to 'utc' thus adding 4 hours (apparently you're

  1   2   3   4   5   6   7   8   9   10   >