Re: [sqlite] What could be the cause of a zero length database file?

2016-05-26 Thread Rowan Worth
On 25 May 2016 at 19:48, dandl wrote: > This particular program is run as part of a series of > test cases, and the setup for the test involves deleting the database file > and then running the program in a batch file. Since about Windows 7 the > shell does not wait for a file to

[sqlite] Problem with SQLite in C++. DB is BUSY (Multithread)

2015-08-11 Thread Rowan Worth
On 11 August 2015 at 06:22, Simon Slavin wrote: > If you did set a timeout then SQLite wais a very short time (a millisecond > ?) before it tries again, then it waits a little longer, then a little > longer still, etc.. It gradually increases the time until the total time > reaches the time you

[sqlite] Using uninitialized value nDummy when calling vdbePmaReaderInit

2015-08-15 Thread Rowan Worth
On 15 August 2015 at 14:35, Carlos Tangerino wrote: > > The variable nDummy is not initialized *(1)* in the function but its > pointer *(2)* is passed to *vdbePmaReaderInit* that increments *(3)* its > value. > nDummy is never used after vdbePmaReaderInit though, so it doesn't really matter that

[sqlite] ATTACH DATABASE statement speed

2015-08-17 Thread Rowan Worth
On 17 August 2015 at 14:52, Paolo Bolzoni wrote: > After I attach the INPUT db and I copy the useful lines. > > The input db is about 13GB, so not really large, however the step on > this sql statement (where ? is of course binded to the db name) > > ATTACH DATABASE ? AS indb; > > requires

[sqlite] Performance problems on windows

2015-08-26 Thread Rowan Worth
What about fragmentation of the database itself? Does running VACUUM on the database affect performance? -Rowan On 26 August 2015 at 16:16, Jakub Zakrzewski wrote: > Hi, > > nope. The defragmentation job runs every Wednsday night and the > fragmentation is very low. > > PS: I'm putting

[sqlite] SQLite - Support for VSS writer

2015-12-04 Thread Rowan Worth
On 3 December 2015 at 22:00, Richard Hipp wrote: > On 12/3/15, Murdare, Vijaykumar S (GE Oil & Gas) > wrote: > > Hi, > > > > Also, I would like to know while taking the backup of online databases: > > > > 1) If read operation is in progress, then can I take backup safely > with > > file

[sqlite] Using colation in Java

2015-12-29 Thread Rowan Worth
On 29 December 2015 at 08:23, Cecil Westerhof wrote: > When working in Python I can use: > con.create_collation("mycollation", collate) > > To change the sort order. How should I do this in Java? > Note there are multiple ways to use sqlite from java, so it would help to specify which

[sqlite] Interrupting the busy handler

2015-07-25 Thread Rowan Worth
Hiya, Firstly thank you for sqlite, it's proved to be a remarkably solid bit of software. I recently noticed one interesting interaction -- or lack thereof -- between the default busy handler (registered via sqlite3_busy_timeout) and sqlite3_interrupt. Specifically, sqlite3_interrupt appears to

[sqlite] ATTACH Problem

2015-07-31 Thread Rowan Worth
Chris, you have an extra pair of single quotes in your original code compared to Simon's suggestion. Also in your parameter-based attempt you have a typo when assigning the path (@DNName instead of @DBName). Hope that helps, -Rowan On 31 July 2015 at 15:09, Chris Parsonson wrote: > That's

[sqlite] attempt at output with thousands separator via extension

2015-11-23 Thread Rowan Worth
Hi Bruce, I had a go at post-processing the sqlite3 shell's output to apply thousand separators. I don't recommend looking too hard at the sed for the sake of your sanity, but the gist is it repeatedly prepends a comma to trailing groups of three digits, and then repeatedly removes commas which

[sqlite] method for thousands separator via sed post processing

2015-11-27 Thread Rowan Worth
Hi Bruce, On 27 November 2015 at 10:59, Bruce Hohl wrote: > Thanks to suggestions on this list I explored the sed post processing > avenue and found a solution. There are quite a few sed docs at > http://sed.sourceforge.net For my needs I adapted an example from >

[sqlite] Problem with sqlite3_db_filename

2015-10-09 Thread Rowan Worth
Suspect you are running into more VBA<->C issues. The db path, journal path and wal path are stored sequentially in memory, so if you were to skip the NUL terminators you'd see all three paths. But I'm not exactly sure how that might happen without resulting in a segfault, so I could be missing

[sqlite] Compilation fails under Linux (Ubuntu) when FTS5 is enabled

2015-10-19 Thread Rowan Worth
On 18 October 2015 at 04:15, wrote: > I just tried one more time with the -lm switch and this time it worked. > Hmm... > > Problem solved. Thanks. You might find that specifying -lm *after* the .c files works but -lm before the .c files doesn't. The linker processes libraries/object files in

[sqlite] Simple Math Question

2015-10-23 Thread Rowan Worth
On 23 October 2015 at 16:08, Dominique Devienne wrote: > Another good good way to think of IEEE I was presented once with, and which > kind of gave me a ah-ah moment, is the fact that numbers with exact > representation fall on the nodes of grid, and there's plenty of "space" in > between the

[sqlite] Simple Math Question

2015-10-26 Thread Rowan Worth
On 23 October 2015 at 23:34, Rousselot, Richard A < Richard.A.Rousselot at centurylink.com> wrote: > Scott, > > I agree with everything you said but... To me if a program/CPU evaluates > something internally, then when it reports the result it should be the > result as it sees it. It shouldn't

[sqlite] BEGINNER - Transactions in shell script

2015-09-06 Thread Rowan Worth
On 6 September 2015 at 18:26, Luuk wrote: > > Suppose i have 'test.sql': > .echo on > DELETE FROM test; > BEGIN; > INSERT INTO test VALUES(1,'test1'); > INSERT INTO test VALUES(3,'test3',3); > INSERT INTO test VALUES(2,'test2'); > COMMIT; > SELECT * FROM test; > > And a database 'test.sqlite'

[sqlite] About backup example

2015-09-13 Thread Rowan Worth
On 12 September 2015 at 20:59, David Kazlauskas wrote: > Hi, I see something in the second backup example ( > http://www.sqlite.org/backup.html ) that seems like logical error to me. > > if( rc==SQLITE_OK || rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){ > sqlite3_sleep

[sqlite] [OT] Handling the whole select query from an index

2015-09-18 Thread Rowan Worth
> Outside London, a postcode can cover a far, far wider area specially in rural or sparsely populated areas. I would imagine Australian postcodes to be similar but thats based on a guess rather than actually any knowledge. I'm not sure whether to take this claim of ignorance at face value or

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread Rowan Worth
On 21 September 2015 at 14:38, Simon Slavin wrote: > As expected, ALTER TABLE acts like INSERT: it's a change which requires an > exclusive lock. So just as the documentation says, in a normal journal > mode you can't make a change while the database is locked (which it is > during a SELECT),

[sqlite] How to know when a sqlite3_stmt has been recompiled ?

2015-09-21 Thread Rowan Worth
On 21 September 2015 at 16:36, Simon Slavin wrote: > > On 21 Sep 2015, at 8:29am, Rowan Worth wrote: > > > 1) Statement is prepared > > 2) Statement is stepped > > 3) Statement is reset > > 4) ... time passes ... > > 5) Statement is stepped > >

[sqlite] UPDATE silently failing

2015-09-23 Thread Rowan Worth
> SIndex sidx is just a boxed immutable integer. If it were me I'd be reviewing this assumption very carefully. The sequence of events: 1. SIndex.getInt() returns 0 2. SIndex.toString() returns "1" 3. SIndex.getInt() returns 1 Has many possible explanations. You could also try 'final int sid =

[sqlite] UPDATE silently failing

2015-09-23 Thread Rowan Worth
On 23 September 2015 at 12:32, Hugues Bruant wrote: > On Wed, Sep 23, 2015 at 12:00 AM, Rowan Worth wrote: > > > Has many possible explanations. > > I can't think of any that is consistent with the Java specification. > Yeah fair enough, SIndex looks watertight. It's st

[sqlite] SQLITE_BUSY_SNAPSHOT from BEGIN IMMEDIATE

2015-09-29 Thread Rowan Worth
On 29 September 2015 at 03:47, Florian Weimer wrote: > Relatively rarely, while starting a transaction on a concurrently > modified SQLite database in WAL mode, I get a SQLITE_BUSY_SNAPSHOT > error for just-prepared "BEGIN IMMEDIATE" statement. > BEGIN IMMEDIATE takes a RESERVED lock straight

[sqlite] Is it legal SQL to select a specific row of a group via a HAVING clause?

2015-09-29 Thread Rowan Worth
Hi guys, Imagine a DB storing a history of currency exchange rate info. CREATE TABLE Prices ( id INTEGER PRIMARY KEY, day INTEGER, currency TEXT, price FLOAT); Assume 'day' increases monotonically and there is at most one price recorded per currency per day - if you want to know

[sqlite] obtaining bracketing rows where rows are missing

2016-04-15 Thread Rowan Worth
sqlite> create table a(a integer primary key); sqlite> SELECT a1.a, a2.a FROM a AS a1, a AS a2 WHERE a2.a > a1.a GROUP BY a1.a HAVING a2.a = min(a2.a) AND a2.a <> a1.a + 1; 3|5 5|8 11|14 IIRC "HAVING x = min(x)" is not portable SQL but it seems to work in sqlite. -Rowan On 15 April 2016

[sqlite] Is it possible that dropping a big table takes very long

2016-04-18 Thread Rowan Worth
On 18 April 2016 at 06:55, Cecil Westerhof wrote: > ?I put a strace on it. This was what I got: > Process 26455 attached with 20 threads > % time seconds usecs/call callserrors syscall > -- --- --- - - > 99.80 11245.498406

[sqlite] Is it possible that dropping a big table takes very long

2016-04-19 Thread Rowan Worth
On 19 April 2016 at 02:01, Cecil Westerhof wrote: > 2016-04-18 4:04 GMT+02:00 Rowan Worth : > > > On 18 April 2016 at 06:55, Cecil Westerhof > wrote: > > > > > ?I put a strace on it. This was what I got: > > > Process 26455 attached with 20 threads > &g

[sqlite] BUG?

2016-04-22 Thread Rowan Worth
On 22 April 2016 at 14:54, Stephan Beal wrote: > On Fri, Apr 22, 2016 at 8:43 AM, Clemens Ladisch > wrote: > > sqlite> select julianday('2000-01-01 00:00:00'); > > ...> select julianday('2000-01-01 00:00:01'); > > ...> select julianday('2000-01-01 00:00:02'); > > 2451544.5 > >

[sqlite] Is it possible that dropping a big table takes very long

2016-04-22 Thread Rowan Worth
On 22 April 2016 at 16:00, Cecil Westerhof wrote: > What I find very interesting is that the user time and the sys time does > not increase significantly, but the real time does. Does this point to the > problem, or is this to be expected? > It suggests the extra time is spent waiting for I/O

[sqlite] Is it possible that dropping a big table takes very long

2016-04-23 Thread Rowan Worth
On 22 April 2016 at 21:24, Adam Devita wrote: > > That said, why is the dropping of a table dependent on the size of > the table? Does Sqlite have to mark every block of memory it used as > dropped? (This is obvious for high security mode, but otherwise?) In rollback journal mode, every

[sqlite] sqlite3 command line, read-only

2016-04-27 Thread Rowan Worth
On 27 April 2016 at 13:01, Mark Foley wrote: > > Can sqlite handle contention among multiple accessors with read/write if > the > accessors are not on the same host? I.e. is locking intrinsic in sqlite > and any > accessor from any host is able to determine and set a row/table lock? > That

[sqlite] ANALYZE, sqlite_stat1, and query planning

2016-04-29 Thread Rowan Worth
Hi guys, In an attempt to understand a slow query I've had a quick look at the contents of the sqlite_stat1 table. It looks like the stat column contains a series of integers like: ... Is this observation correct? And if so, does sqlite essentially assume that the rows are equally

[sqlite] Customizing the location of the .sqlite_history

2016-02-01 Thread Rowan Worth
sqlite3() { confs='.sqlite_history .sqliterc' for c in $confs; do ln -s ~/.config/$c ~/$c; done (sleep 10; cd; rm $confs)& command sqlite3 "$@" } Alternately, simply create a new user with home directory matching your ~/.config, and su to that user to run sqlite3. (no, neither of

[sqlite] Bug: Successfully committed transaction rolled back after power failure

2016-02-01 Thread Rowan Worth
On 1 February 2016 at 18:58, Simon Slavin wrote: > > On 1 Feb 2016, at 9:23am, bm.email01 at gmail.com wrote: > > > --- > > No, SQLite does not. On COMMIT it fsyncs the database file and unlinks > the > > journal[1], but does not fsync the directory. > > --- > > > > Since that can cause the last

[sqlite] Bug: Successfully committed transaction rolled back after power failure

2016-02-02 Thread Rowan Worth
Hi Stephen, On 1 February 2016 at 21:45, Stephen Chrzanowski wrote: > > SQLite is nothing more than part of a program run by the OS. It completely > relies on whatever the OS tells it. If the OS tells it that things are OK, > then that is all that can be done. SQLite can't take on the

[sqlite] Bug: Successfully committed transaction rolled back after power failure

2016-02-02 Thread Rowan Worth
On 2 February 2016 at 08:22, Stephen Chrzanowski wrote: > On Mon, Feb 1, 2016 at 11:20 AM, Rowan Worth wrote: > As I indicated in the last paragraph of my mail, I'm not in favour of > > fsync-directory-on-commit in the general case. But that's because I worry > > about the

[sqlite] Andl: choices for generic types: bool, binary, number/decimal, date/datetime, text/varchar

2016-02-12 Thread Rowan Worth
On 10 February 2016 at 11:14, wrote: > >>>Every SQLite database file has a text encoding that applies to the > entire > file: one of utf8, utf16be, or utf16le. The database text encoding is > stored in the header. You can see the encoding for a particular database > using: > > sqlite3

[sqlite] Multiple Column index

2016-02-22 Thread Rowan Worth
On 22 February 2016 at 17:07, Michele Pradella wrote: > CREATE INDEX indexAB ON test(DateTime,CarPlate); CREATE INDEX indexA ON test(DateTime); > So if I have a query like this >>> "SELECT * FROM table_name WHERE DateTime>> DateTime>VALUE_MIN" >>> >> > Generally

[sqlite] Why is a separate journal file needed ?

2016-02-26 Thread Rowan Worth
On 24 February 2016 at 21:49, Richard Hipp wrote: > On 2/24/16, Simon Slavin wrote: > > Why can't the information which SQLite > > stores in a journal file be put in the database file ? > > Doing so would double the size of the database file. Every database > file would contain extra space

[sqlite] Why is a separate journal file needed ?

2016-02-26 Thread Rowan Worth
On 24 February 2016 at 23:46, Igor Tandetnik wrote: > On 2/24/2016 10:08 AM, Stephen Chrzanowski wrote: > >> IMO, all that, plus the fact that you have an easy roll back mechanism. >> Anything that needs to be put in the database is external to the pristine >> database. Lock the database with a

[sqlite] Fwd: Re: SQLite and Thunderbird

2016-02-29 Thread Rowan Worth
On 26 February 2016 at 22:42, Howard Chu wrote: > Thunderbird has *always* used its own statically built sqlite, just like > all other Mozilla software. > > In fact, it has more than one copy: > https://hg.mozilla.org/mozilla-central/file/918df3a0bc1c/db/sqlite3/src > > >

[sqlite] Why is a separate journal file needed ?

2016-02-29 Thread Rowan Worth
On 27 February 2016 at 00:02, Igor Tandetnik wrote: > On 2/26/2016 4:01 AM, Rowan Worth wrote: > >> In principle this is correct, but actually the database *file* is not >> immediately modified in rollback mode. Instead when a page is modified the >> original contents a

[sqlite] Why is a separate journal file needed ?

2016-02-29 Thread Rowan Worth
On 29 February 2016 at 12:13, Igor Tandetnik wrote: > On 2/28/2016 9:19 PM, Rowan Worth wrote: > >> On 27 February 2016 at 00:02, Igor Tandetnik wrote: > > > > I simplified to make the main point stand out: it is not true that the >> >>> database file r

[sqlite] About vacuum

2016-01-04 Thread Rowan Worth
On 4 January 2016 at 16:59, Simon Slavin wrote: > The VACUUM function takes so long to run that you cannot get faster > overall. > > Depending on which operating system, file system and storage system you > use, it is possible for VACUUM to increase speed of SELECT a little, but > not much [1].

[sqlite] hard links and SQLite

2016-01-12 Thread Rowan Worth
On 12 January 2016 at 03:00, Felipe Gasper wrote: > On 11 Jan 2016 1:45 PM, Scott Hess wrote: > >> >> As far as preventing the other process from using it before the schema >> exists, do "SELECT count(*) FROM sqlite_master", and if the result is 0, >> the schema does not exist. If you create

[sqlite] hard links and SQLite

2016-01-12 Thread Rowan Worth
On 12 January 2016 at 13:26, Scott Hess wrote: > On Mon, Jan 11, 2016 at 9:12 PM, Felipe Gasper > wrote: > > > On 11 Jan 2016 9:06 PM, Rowan Worth wrote: > > > >> * if it returns SQLITE_OK and zero rows, the schema hasn't been created > >> yet > &g

[sqlite] hard links and SQLite

2016-01-12 Thread Rowan Worth
On 12 January 2016 at 13:12, Felipe Gasper wrote: > Same code, just different processes. > > We?ve just noted over the years with race conditions that that ?if it can > fail, it will?, so we try to be as bulletproof as we can. > Good policy :) After you unlink the temp file, I presume the

[sqlite] WAL: difference between IMMEDIATE and DEFERRED transaction

2016-01-18 Thread Rowan Worth
On 15 January 2016 at 22:09, Olivier Vidal wrote: > For the DEFERRED transaction: > > - BEGIN DEFERRED TRANSACTION > - SELECT > - UPDATE > - SELECT > - UPDATE > - INSERT > - SELECT > - COMMIT > > The lock is requested at the first UPDATE (and there have no TIMEOUT?). > The database cannot be

[sqlite] Bug: Successfully committed transaction rolled back after power failure

2016-01-22 Thread Rowan Worth
> Shutting down power right after a successfully committed > transaction rolls back that transaction on next startup. nitpick: This is sqlite behaving as advertised. See https://www.sqlite.org/lockingv3.html section 5.0 step 6, and https://www.sqlite.org/atomiccommit.html section 3.11 which

[sqlite] Find SQLITE_BUSY reason?

2016-01-22 Thread Rowan Worth
On 22 January 2016 at 06:33, Warren Young wrote: > With SQLite?s lack of row-level locking, your usage pattern should distill > to ?get in, get done, and get out, ASAP.? Many fine-grained queries are > better than heroic multi-statement queries that change the world. > To a point I agree, but

[sqlite] Find SQLITE_BUSY reason?

2016-01-22 Thread Rowan Worth
On 22 January 2016 at 14:24, Simon Slavin wrote: > > On 22 Jan 2016, at 4:01am, Rowan Worth wrote: > > > To a point I agree, but in reality there's a fixed amount of work > involved > > with each write transaction. I recently profiled an operation involving > &g

[sqlite] Bug: Successfully committed transaction rolled back after power failure

2016-01-27 Thread Rowan Worth
On 25 January 2016 at 18:26, Meinlschmidt Stefan < Stefan.Meinlschmidt at esolutions.de> wrote: > > In your case it sounds like a controlled shutdown - is there a reason you > > don't do a full disk sync before that? > > Yes, it is a controlled shutdown, so in my case the /* post-commit logic >

[sqlite] Find out how many times does SQLite hit the disk?

2016-02-01 Thread Rowan Worth
On 31 January 2016 at 15:09, Yannick Duch?ne wrote: > If it's memory mapped, it's less an efficiency issue, > Hm, can you elaborate on this assertion? I don't think I agree. Lets say sqlite wants to access a page in the DB/journal. In the case of normal file access this is a call to

[sqlite] Bug: Successfully committed transaction rolled back after power failure

2016-02-01 Thread Rowan Worth
On 31 January 2016 at 03:56, James K. Lowden wrote: > Surely SQLite does both -- fsync on file and directory -- as part of a > commit. That's not in doubt, is it? > No, SQLite does not. On COMMIT it fsyncs the database file and unlinks the journal[1], but does not fsync the directory. This is

[sqlite] obtainingthe number of rows returned by a query (with a limit)

2016-03-07 Thread Rowan Worth
On 5 March 2016 at 23:52, Paul Sanderson wrote: > That doesn't work for me: > > I am trying to avoid (select col1, col2, ... colx ) from ... > > and want just a row count which is much less resource intensive. > Have you measured this? I think you might be surprised as sqlite doesn't keep track

[sqlite] Fastest way to backup/copy database?

2016-05-06 Thread Rowan Worth
On 4 May 2016 at 20:39, Rob Willett wrote: > Clemens, > > We have 8GB of memory which is the most our VPS provider allows. We?d like > 32GB but its not an option for us. Our desktops have more than that, but > the VPS provider is reasonably priced :) > > We hadn?t considered the WAL mode, my

[sqlite] database is locked when using SQLite3 and MPI to generate different databases

2016-05-09 Thread Rowan Worth
On 8 May 2016 at 10:14, just_rookie <925345468 at qq.com> wrote: > Obviously, I did not do incompatible things with a database at the same > time. > You are attempting to drop a table in databases 300_500.db and 600_900.db. Obviously another process must create that table, since your test code

[sqlite] Good way for CEIL, or is there a better way

2016-05-10 Thread Rowan Worth
On 10 May 2016 at 08:31, Darren Duncan wrote: > The Ceiling function is not that simple, unless you know that your rank > and outOf are always non-negative numbers. If they might be negative, you > would -1 rather than +1 when the result is negative. -- Darren Duncan > Yeah you can't always

Re: [sqlite] Version issues on Mac after updating

2016-06-02 Thread Rowan Worth
On 31 May 2016 at 23:01, Dominique Devienne wrote: > > I'm not an OSX user, but if it's like Linux, you can run the ldd command on > your executable file, > and it will show you which dynamic libraries it depends on. If you don't > see SQLite, it probably statically linked...

Re: [sqlite] Conversion failure

2016-06-24 Thread Rowan Worth
On 24 June 2016 at 16:13, Simon Slavin wrote: > On 24 Jun 2016, at 5:04am, Igor Korot wrote: > > > But everything should work independently of what code page is being used? > > The SQLite shell tool should work independently of the code page you have >

Re: [sqlite] Conversion failure

2016-06-23 Thread Rowan Worth
The sqlite shell, at least historically, has I think not accounted for text encoding and simply passed whatever it reads from the console into the database. There has been recent changes in this area since your last email on the subject, for sqlite 3.12.0. What version are you using, Igor?

Re: [sqlite] Locking semantics are broken?

2016-06-28 Thread Rowan Worth
On 28 June 2016 at 16:07, dandl wrote: > > Do not use SQLite for concurrent access over a network connection. > Locking > > semantics are broken for most network filesystems, so you will have > > corruption issues that are no fault of SQLite. > > I have seen this comment made

Re: [sqlite] SqliteDataAdapter fill wrong data when select data from database

2016-07-29 Thread Rowan Worth
On 27 July 2016 at 18:09, Jin ZhiQiao (Joe) wrote: > When I use sqlite ado.net, I met a bug made me confused. > > > My table schema and data is like this. Table name is "a". > > IDTEXT DOUBLE > > 1 AA 1 > 2 BB 1.2 > 3 CC 2 > > When I run

Re: [sqlite] [Question]SQLite cannot remove journal file as soon as UPDATE transaction finishes?

2016-07-10 Thread Rowan Worth
On 11 July 2016 at 12:18, 刘翔 wrote: > Dear SQLite developers, > > Sqlite version: 3.8.8.3 > Linux version: 3.10.31-ltsi > > Question: > We found when updated a sqlite database in emmc disk, it cannot remove > journal file as soon as the transaction finished. > We know

Re: [sqlite] can't open db when path length extends 512 characters (on linux)

2017-01-31 Thread Rowan Worth
On 31 January 2017 at 17:32, Jan Nijtmans wrote: > 2017-01-30 19:37 GMT+01:00 Dan Kennedy: > > On 01/31/2017 12:48 AM, Nir Paz wrote: > >> Linux doesn't have that limit, my thought is to change the define of > >> MAX_PATHNAME, is there a better option? > > > > I don't

Re: [sqlite] Why does a query run 50x slower across a network?

2017-02-06 Thread Rowan Worth
I'm in a different environment (linux with database on nfs share) but found the same behaviour. I came to the conclusion that the latency of network file system operations combined with database fragmentation was largely responsible for the reduced performance. SQLite is very seek heavy, unlike a

Re: [sqlite] Bulk Insert in Sqlite3

2017-02-06 Thread Rowan Worth
Hi Niti, There's on need to build a giant SQL string; a transaction can span multiple statements. To bind in golang place a ? within your SQL query and provide the values as additional arguments to the Exec/Query function. eg, after using db.Begin() to create a transaction tx, err :=

Re: [sqlite] Bulk Insert in Sqlite3

2017-02-06 Thread Rowan Worth
On 7 February 2017 at 15:11, Simon Slavin wrote: > > On 7 Feb 2017, at 6:56am, Niti Agarwal wrote: > > > Thanks for your reply. The length matters as I am appending 100 rows at a > > time in a sql statement. It is making very fast as compared to

Re: [sqlite] Null returned from NOT NULL column thanks to undetected corruption

2017-01-23 Thread Rowan Worth
m guessing this was pre-fossil. I can't find any reference to ticket #3756 in the current system - is that still around or lost forever? -Rowan On 14 January 2017 at 11:38, Rowan Worth <row...@dug.com> wrote: > On 13 January 2017 at 22:59, David Raymond <david.raym...@tomtom.com&

Re: [sqlite] Bitten by lack of isolation between SELECT and UPDATE on the same connection

2017-01-30 Thread Rowan Worth
The iterator pattern has another caveat when applied to sqlite: foreach (row in statement) { if (isMatch(row)) { return true } } return false If the iterator isn't exhausted, how do you know when to dispose the sqlite3_stmt? There are other ways to manage the

Re: [sqlite] Thread safety of serialized mode

2017-02-19 Thread Rowan Worth
On 18 February 2017 at 01:16, James K. Lowden wrote: > It's why I like Go: it's the first language in 30 years to incorporate > concurrency in its design, and finally support a theoretically sound > model. > I like Go too, but this is giving it a bit too much credit.

Re: [sqlite] schema_version and Vacuum or Backup API

2016-09-07 Thread Rowan Worth
On 6 September 2016 at 20:04, Clemens Ladisch wrote: > Stephen Chrzanowski wrote: > > [...] I'm relying on the results from "pragma > > schema_version". I've noticed that this bumps up every time I run a > vacuum > > or use the backup API against the database. Is this

[sqlite] page_size: bug with PRAGMA or documentation?

2016-09-12 Thread Rowan Worth
Hey guys, The docs for PRAGMA page_size say that it is effective if issued "prior to the first CREATE statement". So imagine my surprise when I found page_size to be ineffective without ever issuing a CREATE statement! The sequence goes like so: $ rm /tmp/lol.db; sqlite3 /tmp/lol.db SQLite

Re: [sqlite] page_size: bug with PRAGMA or documentation?

2016-09-13 Thread Rowan Worth
Thanks Richard, that's much clearer. Just one thing: "The page_size pragma will only set in the page size if ..." The "in" looks out of place :) -Rowan On 12 September 2016 at 19:43, Richard Hipp <d...@sqlite.org> wrote: > On 9/12/16, Rowan Worth <row

Re: [sqlite] Select older or not selected records

2016-11-11 Thread Rowan Worth
ORDER BY CASE timestamp WHEN NULL THEN -9223372036854775808 ELSE abs(random())*timestamp END LIMIT 5? Completely untested, and the weighting function (ELSE clause) is almost certainly terrible :P I think the approach is ok, though I remember some recent threads suggesting the

[sqlite] How does the pager know whether its memory cache is still valid?

2016-10-24 Thread Rowan Worth
Hi guys, I haven't been able to figure this one out from the docs, nor have I stumbled onto the right section of the source. Say you have two separate processes accessing an sqlite DB. P1 starts a transaction, reads page #5, ends transaction. P2 starts a transaction, modifies page #5, ends

Re: [sqlite] How does the pager know whether its memory cache is still valid?

2016-10-24 Thread Rowan Worth
On 24 October 2016 at 15:44, Clemens Ladisch <clem...@ladisch.de> wrote: > Rowan Worth wrote: > > How does sqlite determine that the cached page is out of date? > > http://www.sqlite.org/fileformat2.html#file_change_counter > > > Ultimately the question I'm trying t

Re: [sqlite] Warning automatic index on

2016-10-24 Thread Rowan Worth
On 24 October 2016 at 16:59, Werner Kleiner wrote: > Hello, > > In an error log there is a message like: > SQlite warning (284) automatic index on is_mytable(internalvalue) > > What does this mean? > It means that SQLite's query optimiser has decided the most efficient

Re: [sqlite] Drop Existing Table Results in 'no such table'

2016-10-21 Thread Rowan Worth
On 21 October 2016 at 14:49, sanhua.zh wrote: > Don't do this. > I don’t think so. It is written on the sqlite.com. So it should be a > tricky way but not a wrong way. > The docs say, regarding the procedure you followed: > The following simpler procedure is appropriate

Re: [sqlite] SQLite as a Shell Script

2016-11-16 Thread Rowan Worth
way > execute arbitrary code if the sysadmin visits the system. > > Wout. > > On Wed, Nov 16, 2016 at 11:43 AM Rowan Worth <row...@dug.com> wrote: > > > Interesting but doesn't seem overly practical. If you're in a postiion to > > run 'busybox ash /foo/bar' then y

Re: [sqlite] SQLite as a Shell Script

2016-11-16 Thread Rowan Worth
Interesting but doesn't seem overly practical. If you're in a postiion to run 'busybox ash /foo/bar' then you can easily create a shell script through simpler means. Filesystem access via ATTACH DATABASE is worth bringing attention to though, as I think a lot of developers wouldn't expect that.

Re: [sqlite] SQLite as a Shell Script

2016-11-17 Thread Rowan Worth
g that executable flag is indeed not > trivial. > > On Wed, Nov 16, 2016 at 1:17 PM Rowan Worth <row...@dug.com> wrote: > > > Not true. You can go ahead and create a database called "ls", but: > > > > a) it will not be executable, and > > b) the file

Re: [sqlite] Tcl bindings doc update request

2016-10-27 Thread Rowan Worth
On 28 October 2016 at 02:53, Rolf Ade wrote: > Another plea, since I'm already writing: It isn't immediate and without > any doubt clear, how the "timeout" and the "busy" methods play together, > if both are used. I suspect, the timeout, if given, determines, how long > it

Re: [sqlite] Bus Error on OpenBSD

2016-10-28 Thread Rowan Worth
Hi Mark, A quick google suggests this is a use after free error, as OpenBSD's allocator apparently fills freed memory pages with the pattern 0xdfdfdfdfdf. The stack trace reads like it is crashing while finalizing an sqlite_stmt, as part of some automatic perl destructor logic. Every

Re: [sqlite] using sqlite extensions within Ruby

2016-12-08 Thread Rowan Worth
On 8 December 2016 at 23:23, Don V Nielsen wrote: > Like you, I like ruby and working with sqlite via sqlite3 gem. So you have > recompiled sqlite3 with the sessions extension. Correct? And this modified > sqlite3 is the nearest sqlite3 available in your execution path.

Re: [sqlite] Null returned from NOT NULL column thanks to undetected corruption

2017-01-13 Thread Rowan Worth
On 13 January 2017 at 22:59, David Raymond wrote: > My view is that the general thinking of the program here is simply: "just > don't make things worse." It can't help what pragmas (ie > ignore_check_constraints, writable_schema etc) others may have turned on > for

Re: [sqlite] does integrity check ever modify the db file?

2017-01-13 Thread Rowan Worth
On 14 January 2017 at 03:51, Adam Smith wrote: > Hey all, > can 'pragma integrity_check' ever modify the file? For instance in case > of a journal file laying around (which was journal file of the same schema > db but a bit different data)? > > The following is what

[sqlite] Null returned from NOT NULL column thanks to undetected corruption

2017-01-12 Thread Rowan Worth
Hi guys, Ran into an interesting situation recently where a database was transferred via FTP and the client somehow managed to truncate the file. As a result the last page was only 337 bytes rather than the expected 1024. Surprisingly running a SELECT on the affected table works without sqlite

Re: [sqlite] (dot) output call locks up when used on a named pipe

2017-01-01 Thread Rowan Worth
On 1 January 2017 at 08:55, James K. Lowden wrote: > On Sat, 31 Dec 2016 15:16:19 -0500 > Paul Lambert wrote: > > > I have used the (dot) .output call in conjunction with a both a file > > and name pipe on Linux with Sqlite 3.13 installed. With a

Re: [sqlite] Weird chars inserted

2016-12-19 Thread Rowan Worth
On 20 December 2016 at 08:06, Kevin Youren wrote: > The experiments were conducted by cut-and-paste of the í character from > the email, hence UTF8, "Hence UTF8" is presumptuous. There are many encodings the website could be using to communicate í. The browser may (or

Re: [sqlite] Weird chars inserted

2016-12-18 Thread Rowan Worth
On 19 December 2016 at 08:24, Kevin wrote: > Hi Martin, > > I had a go using a terminal session, with default encoding UTF-8. > > Try using the hex( ) and unicode( ) functions to check what is actually > stored in the sqlite table. > > I put a couple of rows at the end of an

Re: [sqlite] How does one block a reader connection?

2017-03-26 Thread Rowan Worth
On 26 March 2017 at 14:17, Keith Medcalf wrote: > If you do not specify your own custom busy handler (to display flying ball > bearings, etc, or do your own exponential sleeping, etc) then the default > busy_handler is used. The default busy handler does its own exponential

Re: [sqlite] Incompatibility into configure.ac

2017-04-05 Thread Rowan Worth
On 5 April 2017 at 21:37, Scott Robison wrote: > bash supports a --posix switch, which makes it more POSIX-compliant. It > also tries to mimic POSIX if invoked as sh. > And while these methods ensure _compatibility_ with POSIX scripts, they don't ensure that all

Re: [sqlite] Regression 3.18.0 cannot import Lightroom dump - Expression tree is too large (maximum depth 1000)

2017-04-06 Thread Rowan Worth
This was already reported recently - if you need a workaround in the short term (before sqlite itself is fixed) see CL's answer here: http://stackoverflow.com/q/43145117/11654 -Rowan 2017-04-05 14:10 GMT+08:00 Axel Reinhold : > Dear sqlite-team, > > after update to 3.18.0

Re: [sqlite] Issue on Windows 10 app

2017-04-20 Thread Rowan Worth
There's not enough information here to determine what the problem might be. STOWED_EXCEPTION seems to be a microsoft crash dump artifact; I suspect you'll need to somehow extract further exception details from that. I'm not sure how to go about that exactly but here's some links to start you off:

Re: [sqlite] SQLite 3 locking

2017-03-02 Thread Rowan Worth
On 1 March 2017 at 02:39, Matthew Ceroni wrote: > > So since busy_timeout defaults to 0, all write attempts if a lock can't be > obtained will return SQLITE_BUSY immediately. Where does the PENDING lock > come into play here? I thought the PENDING was meant to be an

Re: [sqlite] Incompatibility into configure.ac

2017-04-05 Thread Rowan Worth
On 5 April 2017 at 17:23, Richard Hipp wrote: > On 4/4/17, Jens Alfke wrote: > > > > The issue here seems to be that some scripts in the SQLite source > > distribution are _implicitly_ assuming that the default shell is bash, or > > else that ‘sh’ is an

Re: [sqlite] strange behaviour on sqlite shell output…

2017-04-18 Thread Rowan Worth
On 18 April 2017 at 16:28, Hick Gunter wrote: > Richard Hipp wrote: > >I think the OP is referring to a problem that comes up because the field > width and precision of a printf() format are measured in bytes, not > characters, and if the input is multi-byte UTF then it is

Re: [sqlite] Database corruption, and PRAGMA fullfsync on macOS

2017-04-18 Thread Rowan Worth
Hey Brendan, I'm no OSX expert, but from what I've read this afternoon about NSDocument and friends combined with what I know about sqlite I have to say you are completely mad to continue passing sqlite databases to NSDocument, *especially* as you don't define your own sub-class to do any of the

Re: [sqlite] What's the level of B+-Tree ?

2017-08-11 Thread Rowan Worth
Jump to the byte offset specified by the "start of the cell content" header, which comes just after the number of pages (ie. offset 0x0f90 in your pasted example). Cross reference the data at that offset against section "2.1 Record Format" of the Database File Format page. By decoding the record

  1   2   3   >