Re: [sqlite] ON CONFLICT with partial indexes

2019-02-18 Thread Charles Leifer
> However, suppose you had a partial index that keyed on > > "extra > 4" > > and your SELECT had the clause > > "WHERE extra > ?1" > > The parameter might be set to 7. You and I know that this means SQLite could use the partial index. But SQLite will not compare the 7 and the 4 and decide it can

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-18 Thread Keith Medcalf
pated traffic volume. >-Original Message- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Charles Leifer >Sent: Monday, 18 February, 2019 08:23 >To: SQLite mailing list >Subject: Re: [sqlite] ON CONFLICT with partial indexes > >T

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-18 Thread Simon Slavin
On 18 Feb 2019, at 4:41pm, Charles Leifer wrote: > Simon, I appreciate that, but your comment seems to contradict the example I > provided, as well as the example Dr. Hipp provided. Am I misunderstanding? SQLite can compare two comparators. In Dr. Hipp's example the index says "extra IS NOT

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-18 Thread Charles Leifer
Simon, I appreciate that, but your comment seems to contradict the example I provided, as well as the example Dr. Hipp provided. Am I misunderstanding? On Mon, Feb 18, 2019, 9:44 AM Simon Slavin On 18 Feb 2019, at 3:23pm, Charles Leifer wrote: > > > At some point before actually executing the

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-18 Thread Simon Slavin
On 18 Feb 2019, at 3:23pm, Charles Leifer wrote: > At some point before actually executing the query I'm calling > sqlite3_bind...() to set the value of the parameter placeholder. Presumably > SQLite would know at that point that a certain index is usable (or in this > case, that a certain

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-18 Thread Dominique Devienne
On Mon, Feb 18, 2019 at 4:38 PM Richard Damon wrote: > Remember the query plan is determined when that statement is compiled, > which is BEFORE you do the binding of the parameters, so the plan can not > depend on the value of parameters. There is no later attempt to optimize > once the values

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-18 Thread Richard Damon
> On Feb 18, 2019, at 10:23 AM, Charles Leifer wrote: > > Thanks for the explanation. So does this mean that two identical queries > can have completely different query plans depending on whether they use a > parameters vs literal values embedded in the SQL string? > Remember the query plan is

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-18 Thread Charles Leifer
Thanks for the explanation. So does this mean that two identical queries can have completely different query plans depending on whether they use a parameters vs literal values embedded in the SQL string? > But in this case with the WHERE clause is incompletely specified, there is no way for the

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-17 Thread Richard Hipp
On 2/17/19, Charles Leifer wrote: > I'm having trouble executing an INSERT ... ON CONFLICT with a partial > index. It works fine in the SQLite shell, but it fails when I express the > conflict constraint using a parameterized query. > > For example: > > CREATE TABLE ukvp ("id" integer primary

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-17 Thread Charles Leifer
Olivier, what do you mean "snapshot"? What is a release? How can I find out about the SQLite "releases" you are talking about? On Sun, Feb 17, 2019 at 3:23 PM Olivier Mascia wrote: > > Le 17 févr. 2019 à 22:05, Charles Leifer a écrit : > > > > I run against the latest and greatest. > > > >

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-17 Thread Olivier Mascia
> Le 17 févr. 2019 à 22:05, Charles Leifer a écrit : > > I run against the latest and greatest. > > Python: > > In [1]: import sqlite3 > > In [2]: sqlite3.sqlite_version > Out[2]: '3.28.0' > > > Sqlite: > > sqlite> select sqlite_version(), sqlite_source_id(); > 3.28.0|2019-02-12 22:58:32 >

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-17 Thread Charles Leifer
I run against the latest and greatest. Python: In [1]: import sqlite3 In [2]: sqlite3.sqlite_version Out[2]: '3.28.0' Sqlite: sqlite> select sqlite_version(), sqlite_source_id(); 3.28.0|2019-02-12 22:58:32 167b91df77fff1a84791f6ab5f72239b90475475be690a838248119b6dd312f0 On Sun, Feb 17,

Re: [sqlite] ON CONFLICT with partial indexes

2019-02-17 Thread Simon Slavin
On 17 Feb 2019, at 8:51pm, Charles Leifer wrote: > Is this a bug? Just to make things easier, which version of SQLite are you using in your Python SQLite library ? If you don't know, you can find this out using SELECT sqlite_version(); SELECT sqlite_source_id(); The second may give

[sqlite] ON CONFLICT with partial indexes

2019-02-17 Thread Charles Leifer
I'm having trouble executing an INSERT ... ON CONFLICT with a partial index. It works fine in the SQLite shell, but it fails when I express the conflict constraint using a parameterized query. For example: CREATE TABLE ukvp ("id" integer primary key, "key" text not null, "value" int not null,