Re: [sqlite] [EXTERNAL] 'where ... isnull' in create index

2019-06-05 Thread Hick Gunter
NULL is considered different from any other value, including another NULL, in the context of UNIQUE. So your unique index has 2 entries (1, NULL1) for rowid 1 and (1, NULL2) for rowid2. See https://sqlite.org/nulls.html It also states that NULL1 == NULL2 is TRUE in UNION and DISTINCT

[sqlite] 'where ... isnull' in create index

2019-06-05 Thread ingo
For the second insert in the code below I expected a failure. From the diagrams in the create index doc I understand the WHERE ts_to ISNULL is legal. Do I misunderstand the docs or is there an other place where I should look. I'm awar that I could use some future data as default for ts_to but it

Re: [sqlite] [EXTERNAL] 'where ... isnull' in create index

2019-06-05 Thread ingo
On 5-6-2019 09:38, Hick Gunter wrote: > NULL is considered different from any other value, including another NULL, in > the context of UNIQUE. > > So your unique index has 2 entries (1, NULL1) for rowid 1 and (1, NULL2) for > rowid2. > > See https://sqlite.org/nulls.html > > It also states

Re: [sqlite] upsert unique partial index

2019-06-05 Thread Richard Hipp
On 6/5/19, ingo wrote: > First it tells me an unique constraint failed and then it can't find it? > > CREATE TABLE testupsert ( >id INTEGER NOT NULL, >param TEXT NOT NULL DEFAULT '_', >sometxt TEXT > ); > > CREATE UNIQUE INDEX up > ON testupsert (id, param) > WHERE param =

[sqlite] upsert unique partial index

2019-06-05 Thread ingo
First it tells me an unique constraint failed and then it can't find it? CREATE TABLE testupsert ( id INTEGER NOT NULL, param TEXT NOT NULL DEFAULT '_', sometxt TEXT ); CREATE UNIQUE INDEX up ON testupsert (id, param) WHERE param = '_'; INSERT INTO testupsert (id, sometxt)

Re: [sqlite] upsert unique partial index

2019-06-05 Thread ingo
On 5-6-2019 12:52, Richard Hipp wrote: > WHERE param='_' query executed, thanks, ingo ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

[sqlite] sqlite3_reset() bug?

2019-06-05 Thread Josef Barnes
Hi, We've come across a situation where we think there is a bug in the sqlite3_reset() function. The documentation states: "Any SQL statement variables that had values bound to them using the sqlite3_bind_*() API retain their values" The behaviour we are seeing appears to contradict this

Re: [sqlite] sqlite3_reset() bug?

2019-06-05 Thread Shawn Wagner
If you tweak that to include some error checking: if (sqlite3_bind_int64(stmt, 1, vals[i]) != SQLITE_OK) { fprintf(stderr, "BIND ERROR: %s\n", sqlite3_errmsg(db)); } You'll see output like: BOUND 4 FOUND 1,4 BIND ERROR: bad parameter or other API misuse BOUND 5 FOUND 1,4 BIND

Re: [sqlite] sqlite3_reset() bug?

2019-06-05 Thread Josef Barnes
It doesn't look like my attachment worked, so here is the code: #include #include int main (void) { inti; sqlite3_stmt *stmt = NULL; sqlite3 *db = NULL; int vals[] = { 4, 5, 6 };

Re: [sqlite] sqlite3_reset() bug?

2019-06-05 Thread Josef Barnes
Thank you!! You've saved our sanity for today! Perhaps I should RTFM a bit more thoroughly next time. We usually include plenty of error checking, but do get lazy with the bind() ones. Won't happen again! Joe ⁣Sent from BlueMail ​ On 5 Jun. 2019, 23:26, at 23:26, Shawn Wagner wrote: >If you

Re: [sqlite] [EXTERNAL] Re: sqlite3_reset() bug?

2019-06-05 Thread Hick Gunter
The sqlite3_reset() call is used to reset the statement AFTER having called sqlite3_step(). -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Josef Barnes Gesendet: Mittwoch, 05. Juni 2019 15:07 An: