Re: [sqlite] pragma trigger_info?

2019-06-21 Thread Keith Medcalf
What do you want for trigger info? The following pragma code will return all the data in the currently loaded schema for all attached databases (table/index/trigger names). It creates a new pragma called DATABASE_INFO (and table pragme_database_info) that returns three columns: schema type

Re: [sqlite] endianess/signed issue on OpenBSD/sparc64 ?

2019-06-21 Thread Jeremie Courreges-Anglas
On Thu, Jun 13 2019, Richard Hipp wrote: > On 6/9/19, Landry Breuil wrote: >> >> this broke on sparc64 >>>select 298.2564151; >> -298.2564151 >> > > I cannot reproduce this (perhaps because I do not have access to a > sparc64 platform running OpenBSD) and do not have any good ideas about > what

Re: [sqlite] misuse of aggregate function max()

2019-06-21 Thread Jean-Christophe Deschamps
That is what I use now, together with the select as Hick mentioned. An other version I played with is two indexes, one unique on (id, ts_from) to find the last version if eol is not null and one unique on (id, ts_eol) where eol = null to find the current active version of id. Beware that in

[sqlite] pragma trigger_info?

2019-06-21 Thread Dominique Devienne
I trying to reconcile two manually maintained schemas, one that's custom and drives the database code at runtime, and another that's the SQLite (DDL) used to instantiate the DBs. Differences exist, because we humans at not that good at rigour. These are fairly large and old schemas, > 200 tables,

Re: [sqlite] misuse of aggregate function max()

2019-06-21 Thread ingo
On 21-6-2019 11:46, Simon Slavin wrote: > You will note that SQLite is perfectly happy with > > CREATE UNIQUE INDEX idx_test_c >ON test(id, ts_from, ts_eol) > WHERE ts_eol = NULL > ; That is what I use now, together with the select as Hick mentioned. An other version I played with is two

Re: [sqlite] [EXTERNAL] misuse of aggregate function max()

2019-06-21 Thread Hick Gunter
"Expressions in an index may not reference other tables and may not use subqueries nor functions whose result might change" max(ts_from) not only depends on every other record in the table, but is also subject to change dependant on future inserts. If what you want is a field that contains the

Re: [sqlite] misuse of aggregate function max()

2019-06-21 Thread Simon Slavin
On 21 Jun 2019, at 10:29am, ingo wrote: > Is this because max() is not deterministic, > or because current_timestamp is not, > or both? The max(). For the reason you identified: it would have to recalculate the index values for all rows in the table every time any of the rows changed. You

[sqlite] misuse of aggregate function max()

2019-06-21 Thread ingo
CREATE TABLE test( id INTEGER NOT NULL, ts_from TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, ts_eol TEXT DEFAULT NULL ); CREATE UNIQUE INDEX idx_test ON test(id, max(ts_from), ts_eol) WHERE ts_eol = NULL ; --Error: misuse of aggregate function max() Is this because max() is not

Re: [sqlite] OT!!!!! Understanding the WITH clause

2019-06-21 Thread Luuk
On 20-6-2019 08:11, Michael Falconer wrote: SELECT peace FROM disaster WHERE disaster.cause = 'Windows'; Returns: *nix The query should be SELECT peace FROM disaster WHERE (disaster.cause LIKE '%Windows%' OR disaster.cause LIKE '%nix%' OR disaster.cause LIKE '%incompetence%'