[sqlite] offset of file position is beyond EOF

2017-08-18 Thread Jacky Lam
Hi All, I recently meet a case that the file position offset of a pager is beyond EOF position of db. I would like to know if it is normal or it is a bug makes from my OS ( SQLITE_OS_OTHER=1)? Thanks. Jacky ___ sqlite-users mailing list

Re: [sqlite] possible json1 bug?

2017-08-18 Thread Richard Hipp
On 8/18/17, Jose Manuel wrote: > There is a problem whenever you try to define an INDEX over a json column > and then using a Query with a JOIN over the same table. Thanks for the report. But OSSFuzz already found that bug. It was fixed four days ago:

[sqlite] possible json1 bug?

2017-08-18 Thread Jose Manuel
There is a problem whenever you try to define an INDEX over a json column and then using a Query with a JOIN over the same table. Here is the code that triggers the problem: SQLiteConnection _dbc1 = new SQLiteConnection("Data Source=test.db;Version=3;"); _dbc1.Open();

Re: [sqlite] Enforcing uniqueness from multiple indexes

2017-08-18 Thread David Raymond
Tried it and found a issue with update, though it might actually work the way he wants. Good call though, I keep forgetting the on conflict thing can be on table creation and not just for a query. --continuing from your script... sqlite> select * from demo; --EQP-- 0,0,0,SCAN TABLE demo

Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !

2017-08-18 Thread Simon Slavin
On 18 Aug 2017, at 5:39pm, Jens Alfke wrote: > Actually, "multi-threaded mode" usually means using a _single_ connection on > multiple threads. > > What you're doing — a separate connection for each thread — is effectively* > the same as running multiple single-threaded

Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !

2017-08-18 Thread Jens Alfke
> On Aug 18, 2017, at 2:04 AM, sanhua.zh wrote: > > I am using SQLite in multi-thread mode, which means that different threads > using different SQLite connection. Actually, "multi-threaded mode" usually means using a _single_ connection on multiple threads. What

Re: [sqlite] Enforcing uniqueness from multiple indexes

2017-08-18 Thread R Smith
On 2017/08/18 6:08 PM, R Smith wrote: Isn't this what conflict clauses on constraints are for? Apologies, I usually add the test-case scripts in case anyone else wish to test it or similar, the case in question herewith added below: -- SQLite version 3.17.0 [ Release: 2017-02-13 ]

Re: [sqlite] Enforcing uniqueness from multiple indexes

2017-08-18 Thread R Smith
On 2017/08/18 1:47 PM, Richard Hipp wrote: On 8/18/17, Wout Mertens wrote: So, bottom line, is there a way to insert or replace a row so that first the id constraint is observed (replacing a previous row with the same id), and then the k constraint is verified (failing

Re: [sqlite] Enforcing uniqueness from multiple indexes

2017-08-18 Thread Nico Williams
An INSERT OR UPDATE sure would be nice. What i often do in cases like this is: UPDATE .. WHERE; INSERT .. SELECT .. WHERE NOT EXISTS (SELECT ..);. That's two statements -- if that's a problem, then you should use D. R. Hipp's trigger-based solution. ___

Re: [sqlite] 'database disk image is malformed' only on the mac

2017-08-18 Thread Simon Slavin
On 18 Aug 2017, at 12:30am, Fahad G wrote: > I do not have a way to reproduce this just yet, but I've been seeing way too > many diagnostic logs from customers where their databases are being corrupt > primarily on the Mac (the exact same code is shared between a Mac app,

Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !

2017-08-18 Thread Jay Kreibich
On Aug 18, 2017, at 7:37 AM, Clemens Ladisch wrote: > Jay Kreibich wrote: >> On Aug 18, 2017, at 5:33 AM, Clemens Ladisch wrote: >>> sanhua.zh wrote: 1. Conn A: Open, PRAGMA journal_mode=WAL 2.ConnB: Open, PRAGMA journal_mode=WAL 3.ConnA:

[sqlite] Enforcing uniqueness from multiple indexes

2017-08-18 Thread wout.mertens
The UNIQUE will either do nothing, or will erase existing lines if a trigger is forgotten. So not having the UNIQUE seems safer. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

Re: [sqlite] Enforcing uniqueness from multiple indexes

2017-08-18 Thread Richard Hipp
On 8/18/17, Gerry Snyder wrote: > Should it be : > > CREATE UNIQUE INDEX ... I don't think it matters in this case. The trigger is also enforcing uniqueness. -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list

Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !

2017-08-18 Thread Clemens Ladisch
Jay Kreibich wrote: > On Aug 18, 2017, at 5:33 AM, Clemens Ladisch wrote: >> sanhua.zh wrote: >>> 1. Conn A: Open, PRAGMA journal_mode=WAL >>> 2.ConnB: Open, PRAGMA journal_mode=WAL >>> 3.ConnA: CREATE TABLE sample (i INTEGER); >>> 4.ConnB: PRAGMA table_info('sample') >>> >>>

Re: [sqlite] Enforcing uniqueness from multiple indexes

2017-08-18 Thread Gerry Snyder
Should it be : CREATE UNIQUE INDEX ... Gerry Snyder On Aug 18, 2017 4:47 AM, "Richard Hipp" wrote: > On 8/18/17, Wout Mertens wrote: > > > > So, bottom line, is there a way to insert or replace a row so that first > > the id constraint is observed

Re: [sqlite] Enforcing uniqueness from multiple indexes

2017-08-18 Thread Wout Mertens
Splendid! Many thanks! On Fri, Aug 18, 2017 at 1:47 PM Richard Hipp wrote: > On 8/18/17, Wout Mertens wrote: > > > > So, bottom line, is there a way to insert or replace a row so that first > > the id constraint is observed (replacing a previous row

[sqlite] 'database disk image is malformed' only on the mac

2017-08-18 Thread Fahad G
Hi Although I've read all the rules (and am otherwise aware of what it takes to report a bug), I want to apologise upfront. I do not have a way to reproduce this just yet, but I've been seeing way too many diagnostic logs from customers where their databases are being corrupt primarily on the

Re: [sqlite] Enforcing uniqueness from multiple indexes

2017-08-18 Thread Richard Hipp
On 8/18/17, Wout Mertens wrote: > > So, bottom line, is there a way to insert or replace a row so that first > the id constraint is observed (replacing a previous row with the same id), > and then the k constraint is verified (failing to replace if k is already > present

Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !

2017-08-18 Thread Jay Kreibich
On Aug 18, 2017, at 4:04 AM, sanhua.zh wrote: > I am using SQLite in multi-thread mode, which means that different threads > using different SQLite connection. > And now I find an issue that the results of SQLite C interface returned is > expired while the schema of

Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !

2017-08-18 Thread Jay Kreibich
On Aug 18, 2017, at 5:33 AM, Clemens Ladisch wrote: > sanhua.zh wrote: >> 1. Conn A: Open, PRAGMA journal_mode=WAL >> 2.ConnB: Open, PRAGMA journal_mode=WAL >> 3.ConnA: CREATE TABLE sample (i INTEGER); >> 4.ConnB: PRAGMA table_info('sample') >> >> Firstly, both thread 1 and

[sqlite] Enforcing uniqueness from multiple indexes

2017-08-18 Thread Wout Mertens
Hi, I have the following problem: I have data where two independent values need to be unique. I'm using one (id) as the primary key, and the other (let's call it k) should just cause insertion or updating to fail if it already exists in another row with a different id in the table. Furthermore,

Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !

2017-08-18 Thread Clemens Ladisch
sanhua.zh wrote: > 1. Conn A: Open, PRAGMA journal_mode=WAL > 2.ConnB: Open, PRAGMA journal_mode=WAL > 3.ConnA: CREATE TABLE sample (i INTEGER); > 4.ConnB: PRAGMA table_info('sample') > > Firstly, both thread 1 and 2 do initialization for their own conn, which is > to read to schema into memory.

[sqlite] SQLite's Results Are Expired While Schema Is Changed !

2017-08-18 Thread sanhua.zh
I am using SQLite in multi-thread mode, which means that different threads using different SQLite connection. And now I find an issue that the results of SQLite C interface returned is expired while the schema of database is changed. The following sample runs in different threads, but I force