From b8456c3029ae59b4d44e276ece326c7cda6ecbdf47600a1518e7d8c17bb8cd35 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 7 Oct 2019 07:50:05 +0000 Subject: [PATCH 1/4] Accepting request 735530 from home:AndreasStieger:branches:server:database sqlite3 3.30.0 OBS-URL: https://build.opensuse.org/request/show/735530 OBS-URL: https://build.opensuse.org/package/show/server:database/sqlite3?expand=0&rev=233 --- sqlite-doc-3290000.zip | 3 --- sqlite-doc-3300000.zip | 3 +++ sqlite-src-3290000.zip | 3 --- sqlite-src-3300000.zip | 3 +++ sqlite3-CVE-2019-16168.patch | 46 ------------------------------------ sqlite3.changes | 28 ++++++++++++++++++++++ sqlite3.spec | 6 ++--- 7 files changed, 36 insertions(+), 56 deletions(-) delete mode 100644 sqlite-doc-3290000.zip create mode 100644 sqlite-doc-3300000.zip delete mode 100644 sqlite-src-3290000.zip create mode 100644 sqlite-src-3300000.zip delete mode 100644 sqlite3-CVE-2019-16168.patch diff --git a/sqlite-doc-3290000.zip b/sqlite-doc-3290000.zip deleted file mode 100644 index c5993cb..0000000 --- a/sqlite-doc-3290000.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4fb9cc6d1f29560300692029089ca1d2feb7c397df6f6eb4c2998856d3bc2929 -size 9415641 diff --git a/sqlite-doc-3300000.zip b/sqlite-doc-3300000.zip new file mode 100644 index 0000000..6c4f6cb --- /dev/null +++ b/sqlite-doc-3300000.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb4deed80e94c7c0d7ee4a5c76d9d91e4deec48e8b158b473b27253fbfc891d6 +size 9484386 diff --git a/sqlite-src-3290000.zip b/sqlite-src-3290000.zip deleted file mode 100644 index 1ec07ba..0000000 --- a/sqlite-src-3290000.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a1533d97504e969ca766da8ff393e71edd70798564813fc2620b0708944c8817 -size 12557725 diff --git a/sqlite-src-3300000.zip b/sqlite-src-3300000.zip new file mode 100644 index 0000000..dd13350 --- /dev/null +++ b/sqlite-src-3300000.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cd9d9e0b7dd0c7359eea714b9e67e47ea17a7ac91574f572bd281807f0419134 +size 12647593 diff --git a/sqlite3-CVE-2019-16168.patch b/sqlite3-CVE-2019-16168.patch deleted file mode 100644 index c584e2d..0000000 --- a/sqlite3-CVE-2019-16168.patch +++ /dev/null @@ -1,46 +0,0 @@ ---- src/analyze.c.orig -+++ src/analyze.c -@@ -1497,7 +1497,9 @@ static void decodeIntArray( - if( sqlite3_strglob("unordered*", z)==0 ){ - pIndex->bUnordered = 1; - }else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){ -- pIndex->szIdxRow = sqlite3LogEst(sqlite3Atoi(z+3)); -+ int sz = sqlite3Atoi(z+3); -+ if( sz<2 ) sz = 2; -+ pIndex->szIdxRow = sqlite3LogEst(sz); - }else if( sqlite3_strglob("noskipscan*", z)==0 ){ - pIndex->noSkipScan = 1; - } ---- src/where.c.orig -+++ src/where.c -@@ -2668,6 +2668,7 @@ static int whereLoopAddBtreeIndex( - ** it to pNew->rRun, which is currently set to the cost of the index - ** seek only. Then, if this is a non-covering index, add the cost of - ** visiting the rows in the main table. */ -+ assert( pSrc->pTab->szTabRow>0 ); - rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow; - pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx); - if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){ ---- test/analyzeC.test.orig -+++ test/analyzeC.test -@@ -132,6 +132,20 @@ do_execsql_test 4.3 { - SELECT count(a) FROM t1; - } {/.*INDEX t1ca.*/} - -+# 2019-08-15. -+# Ticket https://www.sqlite.org/src/tktview/e4598ecbdd18bd82945f602901 -+# The sz=N parameter in the sqlite_stat1 table needs to have a value of -+# 2 or more to avoid a division by zero in the query planner. -+# -+do_execsql_test 4.4 { -+ DROP TABLE IF EXISTS t44; -+ CREATE TABLE t44(a PRIMARY KEY); -+ INSERT INTO sqlite_stat1 VALUES('t44',null,'sz=0'); -+ ANALYZE sqlite_master; -+ SELECT 0 FROM t44 WHERE a IN(1,2,3); -+} {} -+ -+ - - # The sz=NNN parameter works even if there is other extraneous text - # in the sqlite_stat1.stat column. diff --git a/sqlite3.changes b/sqlite3.changes index 60508fa..2d2d305 100644 --- a/sqlite3.changes +++ b/sqlite3.changes @@ -1,3 +1,31 @@ +------------------------------------------------------------------- +Sun Oct 6 15:43:57 UTC 2019 - Andreas Stieger + +- update to 3.30.0: + * Add support for the FILTER clause on aggregate functions + * Add support for the NULLS FIRST and NULLS LAST syntax in ORDER BY clauses + * The index_info and index_xinfo pragmas are enhanced to provide + information about the on-disk representation of WITHOUT ROWID tables + * Add the sqlite3_drop_modules() interface, allowing applications + to disable automatically loaded virtual tables that they do not need + * Improvements to the .recover dot-command in the CLI so that it + recovers more content from corrupt database files + * Enhance the RBU extension to support indexes on expressions + * Change the schema parser so that it will error out if any of + the type, name, and tbl_name columns of the sqlite_master table + have been corrupted and the database connection is not in + writable_schema mode. + * The PRAGMA function_list, PRAGMA module_list, and PRAGMA + pragma_list commands are now enabled in all builds by default + * Add the SQLITE_DBCONFIG_ENABLE_VIEW option for sqlite3_db_config(). + * Added the TCL Interface config method in order to be able to + disable SQLITE_DBCONFIG_ENABLE_VIEW as well as control other + sqlite3_db_config() options from TCL. + * Added the SQLITE_DIRECTONLY flag for application-defined SQL + functions to prevent those functions from being used inside + triggers and views +- drop sqlite3-CVE-2019-16168.patch, upstream + ------------------------------------------------------------------- Tue Sep 10 15:17:35 UTC 2019 - Reinhard Max diff --git a/sqlite3.spec b/sqlite3.spec index d062eb3..1a32251 100644 --- a/sqlite3.spec +++ b/sqlite3.spec @@ -17,9 +17,9 @@ %define oname sqlite -%define tarversion 3290000 +%define tarversion 3300000 Name: sqlite3 -Version: 3.29.0 +Version: 3.30.0 Release: 0 Summary: Embeddable SQL Database Engine License: SUSE-Public-Domain @@ -28,7 +28,6 @@ URL: http://www.sqlite.org/ Source0: http://www.sqlite.org/2019/sqlite-src-%{tarversion}.zip Source1: baselibs.conf Source2: http://www.sqlite.org/2019/sqlite-doc-%{tarversion}.zip -Patch0: sqlite3-CVE-2019-16168.patch BuildRequires: automake BuildRequires: libtool BuildRequires: pkgconfig @@ -104,7 +103,6 @@ other documentation found on sqlite.org. The files can be found in %prep %setup -q -n sqlite-src-%{tarversion} -a2 -%patch0 rm -v sqlite-doc-%{tarversion}/releaselog/current.html ln -sv `echo %{version} | sed "s/\./_/g"`.html sqlite-doc-%{tarversion}/releaselog/current.html find -type f -name sqlite.css~ -delete From 8693102bf0d32b9826d128bd1dba098bc723c905c0bb3932af7381480a06af5e Mon Sep 17 00:00:00 2001 From: Martin Pluskal Date: Sat, 12 Oct 2019 11:07:28 +0000 Subject: [PATCH 2/4] Accepting request 737540 from home:AndreasStieger:branches:server:database 3.30.1 OBS-URL: https://build.opensuse.org/request/show/737540 OBS-URL: https://build.opensuse.org/package/show/server:database/sqlite3?expand=0&rev=234 --- sqlite-doc-3300000.zip | 3 --- sqlite-doc-3300100.zip | 3 +++ sqlite-src-3300000.zip | 3 --- sqlite-src-3300100.zip | 3 +++ sqlite3.changes | 7 +++++++ sqlite3.spec | 4 ++-- 6 files changed, 15 insertions(+), 8 deletions(-) delete mode 100644 sqlite-doc-3300000.zip create mode 100644 sqlite-doc-3300100.zip delete mode 100644 sqlite-src-3300000.zip create mode 100644 sqlite-src-3300100.zip diff --git a/sqlite-doc-3300000.zip b/sqlite-doc-3300000.zip deleted file mode 100644 index 6c4f6cb..0000000 --- a/sqlite-doc-3300000.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cb4deed80e94c7c0d7ee4a5c76d9d91e4deec48e8b158b473b27253fbfc891d6 -size 9484386 diff --git a/sqlite-doc-3300100.zip b/sqlite-doc-3300100.zip new file mode 100644 index 0000000..ef0cb7c --- /dev/null +++ b/sqlite-doc-3300100.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:10f585ad8c631c47187510a895944ac47e8f6f23b1171aebc8f8ce6c0c650415 +size 9485342 diff --git a/sqlite-src-3300000.zip b/sqlite-src-3300000.zip deleted file mode 100644 index dd13350..0000000 --- a/sqlite-src-3300000.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cd9d9e0b7dd0c7359eea714b9e67e47ea17a7ac91574f572bd281807f0419134 -size 12647593 diff --git a/sqlite-src-3300100.zip b/sqlite-src-3300100.zip new file mode 100644 index 0000000..974081e --- /dev/null +++ b/sqlite-src-3300100.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4690370737189149c9e8344414aa371f89a70e3744ba317cef1a49fb0ee81ce1 +size 12648162 diff --git a/sqlite3.changes b/sqlite3.changes index 2d2d305..4328ca6 100644 --- a/sqlite3.changes +++ b/sqlite3.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Oct 11 15:05:00 UTC 2019 - Andreas Stieger + +- sqlite 3.30.1: + * fix a segfault for nested queries that use the FILTER clause + ib aggregate functions (introduced in 3.30.0) + ------------------------------------------------------------------- Sun Oct 6 15:43:57 UTC 2019 - Andreas Stieger diff --git a/sqlite3.spec b/sqlite3.spec index 1a32251..6dc58f8 100644 --- a/sqlite3.spec +++ b/sqlite3.spec @@ -17,9 +17,9 @@ %define oname sqlite -%define tarversion 3300000 +%define tarversion 3300100 Name: sqlite3 -Version: 3.30.0 +Version: 3.30.1 Release: 0 Summary: Embeddable SQL Database Engine License: SUSE-Public-Domain From 5ce7153b11d94684cd88db935a2fbedad9a662dc57fed4616bb5ffb0381a91ce Mon Sep 17 00:00:00 2001 From: Martin Pluskal Date: Tue, 10 Dec 2019 11:41:51 +0000 Subject: [PATCH 3/4] - Add sqlite3-django.patch to fix builds of django OBS-URL: https://build.opensuse.org/package/show/server:database/sqlite3?expand=0&rev=235 --- sqlite3-django.patch | 147 +++++++++++++++++++++++++++++++++++++++++++ sqlite3.changes | 5 ++ sqlite3.spec | 4 +- 3 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 sqlite3-django.patch diff --git a/sqlite3-django.patch b/sqlite3-django.patch new file mode 100644 index 0000000..556b249 --- /dev/null +++ b/sqlite3-django.patch @@ -0,0 +1,147 @@ +Index: sqlite-src-3300100/ext/fts5/test/fts5misc.test +=================================================================== +--- sqlite-src-3300100.orig/ext/fts5/test/fts5misc.test ++++ sqlite-src-3300100/ext/fts5/test/fts5misc.test +@@ -106,6 +106,31 @@ do_execsql_test 2.2.5 { + INSERT INTO vt0(vt0) VALUES('integrity-check'); + } + ++#------------------------------------------------------------------------- ++# ++reset_db ++do_execsql_test 7.0 { ++ CREATE VIRTUAL TABLE t1 USING fts5(x); ++ INSERT INTO t1(rowid, x) VALUES(1, 'hello world'); ++ INSERT INTO t1(rowid, x) VALUES(2, 'well said'); ++ INSERT INTO t1(rowid, x) VALUES(3, 'hello said'); ++ INSERT INTO t1(rowid, x) VALUES(4, 'well world'); ++ ++ CREATE TABLE t2 (a, b); ++ INSERT INTO t2 VALUES(1, 'hello'); ++ INSERT INTO t2 VALUES(2, 'world'); ++ INSERT INTO t2 VALUES(3, 'said'); ++ INSERT INTO t2 VALUES(4, 'hello'); ++} ++ ++do_execsql_test 7.1 { ++ SELECT rowid FROM t1 WHERE (rowid, x) IN (SELECT a, b FROM t2); ++} ++ ++do_execsql_test 7.2 { ++ SELECT rowid FROM t1 WHERE rowid=2 AND t1 = 'hello'; ++} ++ + + finish_test + +Index: sqlite-src-3300100/src/wherecode.c +=================================================================== +--- sqlite-src-3300100.orig/src/wherecode.c ++++ sqlite-src-3300100/src/wherecode.c +@@ -1307,7 +1307,9 @@ Bitmask sqlite3WhereCodeOneLoopStart( + pTerm = pLoop->aLTerm[j]; + if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){ + disableTerm(pLevel, pTerm); +- }else if( (pTerm->eOperator & WO_IN)!=0 ){ ++ }else if( (pTerm->eOperator & WO_IN)!=0 && ++ sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1 ++ ){ + Expr *pCompare; /* The comparison operator */ + Expr *pRight; /* RHS of the comparison */ + VdbeOp *pOp; /* Opcode to access the value of the IN constraint */ +Index: sqlite-src-3300100/test/rowvaluevtab.test +=================================================================== +--- /dev/null ++++ sqlite-src-3300100/test/rowvaluevtab.test +@@ -0,0 +1,91 @@ ++# 2018 October 14 ++# ++# The author disclaims copyright to this source code. In place of ++# a legal notice, here is a blessing: ++# ++# May you do good and not evil. ++# May you find forgiveness for yourself and forgive others. ++# May you share freely, never taking more than you give. ++# ++#*********************************************************************** ++# ++ ++ ++set testdir [file dirname $argv0] ++source $testdir/tester.tcl ++set ::testprefix rowvaluevtab ++ ++register_echo_module db ++ ++do_execsql_test 1.0 { ++ CREATE TABLE t1(a, b, c); ++ CREATE INDEX t1b ON t1(b); ++ INSERT INTO t1 VALUES('one', 1, 1); ++ INSERT INTO t1 VALUES('two', 1, 2); ++ INSERT INTO t1 VALUES('three', 1, 3); ++ INSERT INTO t1 VALUES('four', 2, 1); ++ INSERT INTO t1 VALUES('five', 2, 2); ++ INSERT INTO t1 VALUES('six', 2, 3); ++ INSERT INTO t1 VALUES('seven', 3, 1); ++ INSERT INTO t1 VALUES('eight', 3, 2); ++ INSERT INTO t1 VALUES('nine', 3, 3); ++ ++ WITH s(i) AS ( ++ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000 ++ ) INSERT INTO t1 SELECT NULL, NULL, NULL FROM s; ++ CREATE VIRTUAL TABLE e1 USING echo(t1); ++} ++ ++proc do_vfilter4_test {tn sql expected} { ++ set res [list] ++ db eval "explain $sql" { ++ if {$opcode=="VFilter"} { ++ lappend res $p4 ++ } ++ } ++ uplevel [list do_test $tn [list set {} $res] [list {*}$expected]] ++} ++ ++do_execsql_test 1.1 { ++ SELECT a FROM e1 WHERE (b, c) = (2, 2) ++} {five} ++do_vfilter4_test 1.1f { ++ SELECT a FROM e1 WHERE (b, c) = (?, ?) ++} {{SELECT rowid, a, b, c FROM 't1' WHERE b = ?}} ++ ++do_execsql_test 1.2 { ++ SELECT a FROM e1 WHERE (b, c) > (2, 2) ++} {six seven eight nine} ++do_vfilter4_test 1.2f { ++ SELECT a FROM e1 WHERE (b, c) > (2, 2) ++} { ++ {SELECT rowid, a, b, c FROM 't1' WHERE b >= ?} ++} ++ ++do_execsql_test 1.3 { ++ SELECT a FROM e1 WHERE (b, c) >= (2, 2) ++} {five six seven eight nine} ++do_vfilter4_test 1.3f { ++ SELECT a FROM e1 WHERE (b, c) >= (2, 2) ++} { ++ {SELECT rowid, a, b, c FROM 't1' WHERE b >= ?} ++} ++ ++do_execsql_test 1.3 { ++ SELECT a FROM e1 WHERE (b, c) BETWEEN (1, 2) AND (2, 3) ++} {two three four five six} ++do_vfilter4_test 1.3f { ++ SELECT a FROM e1 WHERE (b, c) BETWEEN (1, 2) AND (2, 3) ++} { ++ {SELECT rowid, a, b, c FROM 't1' WHERE b >= ? AND b <= ?} ++} ++ ++do_execsql_test 1.4 { ++ SELECT a FROM e1 WHERE (b, c) IN ( VALUES(2, 2) ) ++} {five} ++do_vfilter4_test 1.4f { ++ SELECT a FROM e1 WHERE (b, c) IN ( VALUES(2, 2) ) ++} {{SELECT rowid, a, b, c FROM 't1' WHERE b = ?}} ++ ++finish_test ++ diff --git a/sqlite3.changes b/sqlite3.changes index 4328ca6..0a39447 100644 --- a/sqlite3.changes +++ b/sqlite3.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Dec 10 11:30:35 UTC 2019 - Martin Pluskal + +- Add sqlite3-django.patch to fix builds of django + ------------------------------------------------------------------- Fri Oct 11 15:05:00 UTC 2019 - Andreas Stieger diff --git a/sqlite3.spec b/sqlite3.spec index 6dc58f8..a4c0d22 100644 --- a/sqlite3.spec +++ b/sqlite3.spec @@ -1,7 +1,7 @@ # # spec file for package sqlite3 # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -28,6 +28,7 @@ URL: http://www.sqlite.org/ Source0: http://www.sqlite.org/2019/sqlite-src-%{tarversion}.zip Source1: baselibs.conf Source2: http://www.sqlite.org/2019/sqlite-doc-%{tarversion}.zip +Patch0: sqlite3-django.patch BuildRequires: automake BuildRequires: libtool BuildRequires: pkgconfig @@ -103,6 +104,7 @@ other documentation found on sqlite.org. The files can be found in %prep %setup -q -n sqlite-src-%{tarversion} -a2 +%patch0 -p1 rm -v sqlite-doc-%{tarversion}/releaselog/current.html ln -sv `echo %{version} | sed "s/\./_/g"`.html sqlite-doc-%{tarversion}/releaselog/current.html find -type f -name sqlite.css~ -delete From e5d5862acbda4aa6f98950e2deee91b9cd17f96127713e7457d3e050b1fc8962 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Tue, 21 Jan 2020 07:56:37 +0000 Subject: [PATCH 4/4] Accepting request 765315 from home:StefanBruens:branches:openSUSE:Factory:Staging:O Fix failing Django/Django1 testsuites Fix some more errors OBS-URL: https://build.opensuse.org/request/show/765315 OBS-URL: https://build.opensuse.org/package/show/server:database/sqlite3?expand=0&rev=236 --- ...82dfab-Improvements-to-the-LEFT-JOIN.patch | 23 +++ ...vent-SQLite-from-bad-NULL-assumption.patch | 91 +++++++++++ ...d2-Further-improvements-to-LEFT-JOIN.patch | 24 +++ fix_dir_exists_on_btrfs.patch | 12 ++ sqlite3-avoid-truncation-error.patch | 18 +++ sqlite3-django.patch | 147 ------------------ sqlite3.changes | 17 +- sqlite3.spec | 34 +++- 8 files changed, 207 insertions(+), 159 deletions(-) create mode 100644 548082dfab-Improvements-to-the-LEFT-JOIN.patch create mode 100644 7833feecfe-Prevent-SQLite-from-bad-NULL-assumption.patch create mode 100644 8a39167bd2-Further-improvements-to-LEFT-JOIN.patch create mode 100644 fix_dir_exists_on_btrfs.patch create mode 100644 sqlite3-avoid-truncation-error.patch delete mode 100644 sqlite3-django.patch diff --git a/548082dfab-Improvements-to-the-LEFT-JOIN.patch b/548082dfab-Improvements-to-the-LEFT-JOIN.patch new file mode 100644 index 0000000..0399157 --- /dev/null +++ b/548082dfab-Improvements-to-the-LEFT-JOIN.patch @@ -0,0 +1,23 @@ +Index: src/expr.c +================================================================== +--- src/expr.c ++++ src/expr.c +@@ -5229,12 +5229,16 @@ + ** ordinary join. + */ + int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){ + Walker w; + p = sqlite3ExprSkipCollateAndLikely(p); +- if( p && p->op==TK_NOTNULL ){ ++ if( p==0 ) return 0; ++ if( p->op==TK_NOTNULL ){ + p = p->pLeft; ++ }else if( p->op==TK_AND ){ ++ if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1; ++ p = p->pRight; + } + w.xExprCallback = impliesNotNullRow; + w.xSelectCallback = 0; + w.xSelectCallback2 = 0; + w.eCode = 0; + diff --git a/7833feecfe-Prevent-SQLite-from-bad-NULL-assumption.patch b/7833feecfe-Prevent-SQLite-from-bad-NULL-assumption.patch new file mode 100644 index 0000000..d7bc71f --- /dev/null +++ b/7833feecfe-Prevent-SQLite-from-bad-NULL-assumption.patch @@ -0,0 +1,91 @@ +Index: src/expr.c +================================================================== +--- src/expr.c ++++ src/expr.c +@@ -5166,14 +5166,15 @@ + return WRC_Abort; + } + return WRC_Prune; + + case TK_AND: +- if( sqlite3ExprImpliesNonNullRow(pExpr->pLeft, pWalker->u.iCur) +- && sqlite3ExprImpliesNonNullRow(pExpr->pRight, pWalker->u.iCur) +- ){ +- pWalker->eCode = 1; ++ assert( pWalker->eCode==0 ); ++ sqlite3WalkExpr(pWalker, pExpr->pLeft); ++ if( pWalker->eCode ){ ++ pWalker->eCode = 0; ++ sqlite3WalkExpr(pWalker, pExpr->pRight); + } + return WRC_Prune; + + case TK_BETWEEN: + sqlite3WalkExpr(pWalker, pExpr->pLeft); +@@ -5228,19 +5229,12 @@ + ** ordinary join. + */ + int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){ + Walker w; + p = sqlite3ExprSkipCollateAndLikely(p); +- while( p ){ +- if( p->op==TK_NOTNULL ){ +- p = p->pLeft; +- }else if( p->op==TK_AND ){ +- if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1; +- p = p->pRight; +- }else{ +- break; +- } ++ if( p && p->op==TK_NOTNULL ){ ++ p = p->pLeft; + } + w.xExprCallback = impliesNotNullRow; + w.xSelectCallback = 0; + w.xSelectCallback2 = 0; + w.eCode = 0; + +Index: test/join.test +================================================================== +--- test/join.test ++++ test/join.test +@@ -902,8 +902,38 @@ + } {1 {}} + + do_execsql_test join-18.4 { + SELECT NOT(v0.a IS FALSE) FROM v0 + } {1} ++ ++#------------------------------------------------------------------------- ++reset_db ++do_execsql_test join-19.0 { ++ CREATE TABLE t1(a); ++ CREATE TABLE t2(b); ++ INSERT INTO t1(a) VALUES(0); ++ CREATE VIEW v0(c) AS SELECT t2.b FROM t1 LEFT JOIN t2; ++} ++ ++do_execsql_test join-19.1 { ++ SELECT * FROM v0 WHERE v0.c NOTNULL NOTNULL; ++} {{}} ++ ++do_execsql_test join-19.2 { ++ SELECT * FROM t1 LEFT JOIN t2 ++} {0 {}} ++ ++do_execsql_test join-19.3 { ++ SELECT * FROM t1 LEFT JOIN t2 WHERE (b IS NOT NULL) IS NOT NULL; ++} {0 {}} ++ ++do_execsql_test join-19.4 { ++ SELECT (b IS NOT NULL) IS NOT NULL FROM t1 LEFT JOIN t2 ++} {1} ++ ++do_execsql_test join-19.5 { ++ SELECT * FROM t1 LEFT JOIN t2 WHERE ++ (b IS NOT NULL AND b IS NOT NULL) IS NOT NULL; ++} {0 {}} + + finish_test + + diff --git a/8a39167bd2-Further-improvements-to-LEFT-JOIN.patch b/8a39167bd2-Further-improvements-to-LEFT-JOIN.patch new file mode 100644 index 0000000..571993f --- /dev/null +++ b/8a39167bd2-Further-improvements-to-LEFT-JOIN.patch @@ -0,0 +1,24 @@ +Index: src/expr.c +================================================================== +--- src/expr.c ++++ src/expr.c +@@ -5232,13 +5232,15 @@ + Walker w; + p = sqlite3ExprSkipCollateAndLikely(p); + if( p==0 ) return 0; + if( p->op==TK_NOTNULL ){ + p = p->pLeft; +- }else if( p->op==TK_AND ){ +- if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1; +- p = p->pRight; ++ }else{ ++ while( p->op==TK_AND ){ ++ if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1; ++ p = p->pRight; ++ } + } + w.xExprCallback = impliesNotNullRow; + w.xSelectCallback = 0; + w.xSelectCallback2 = 0; + w.eCode = 0; + diff --git a/fix_dir_exists_on_btrfs.patch b/fix_dir_exists_on_btrfs.patch new file mode 100644 index 0000000..062ec1c --- /dev/null +++ b/fix_dir_exists_on_btrfs.patch @@ -0,0 +1,12 @@ +--- src/os_unix.c_orig 2019-12-26 00:56:55.810897741 +0100 ++++ src/os_unix.c 2019-12-26 00:59:29.904449135 +0100 +@@ -6259,7 +6259,8 @@ + + if( flags==SQLITE_ACCESS_EXISTS ){ + struct stat buf; +- *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0); ++ *pResOut = (0==osStat(zPath, &buf) && ++ ((buf.st_size>0) || S_ISDIR(buf.st_mode))); + }else{ + *pResOut = osAccess(zPath, W_OK|R_OK)==0; + } diff --git a/sqlite3-avoid-truncation-error.patch b/sqlite3-avoid-truncation-error.patch new file mode 100644 index 0000000..5c0062f --- /dev/null +++ b/sqlite3-avoid-truncation-error.patch @@ -0,0 +1,18 @@ +Index: src/date.c +================================================================== +--- src/date.c ++++ src/date.c +@@ -686,11 +686,11 @@ + */ + if( sqlite3_stricmp(z, "unixepoch")==0 && p->rawS ){ + r = p->s*1000.0 + 210866760000000.0; + if( r>=0.0 && r<464269060800000.0 ){ + clearYMD_HMS_TZ(p); +- p->iJD = (sqlite3_int64)r; ++ p->iJD = (sqlite3_int64)(r + 0.5); + p->validJD = 1; + p->rawS = 0; + rc = 0; + } + } + diff --git a/sqlite3-django.patch b/sqlite3-django.patch deleted file mode 100644 index 556b249..0000000 --- a/sqlite3-django.patch +++ /dev/null @@ -1,147 +0,0 @@ -Index: sqlite-src-3300100/ext/fts5/test/fts5misc.test -=================================================================== ---- sqlite-src-3300100.orig/ext/fts5/test/fts5misc.test -+++ sqlite-src-3300100/ext/fts5/test/fts5misc.test -@@ -106,6 +106,31 @@ do_execsql_test 2.2.5 { - INSERT INTO vt0(vt0) VALUES('integrity-check'); - } - -+#------------------------------------------------------------------------- -+# -+reset_db -+do_execsql_test 7.0 { -+ CREATE VIRTUAL TABLE t1 USING fts5(x); -+ INSERT INTO t1(rowid, x) VALUES(1, 'hello world'); -+ INSERT INTO t1(rowid, x) VALUES(2, 'well said'); -+ INSERT INTO t1(rowid, x) VALUES(3, 'hello said'); -+ INSERT INTO t1(rowid, x) VALUES(4, 'well world'); -+ -+ CREATE TABLE t2 (a, b); -+ INSERT INTO t2 VALUES(1, 'hello'); -+ INSERT INTO t2 VALUES(2, 'world'); -+ INSERT INTO t2 VALUES(3, 'said'); -+ INSERT INTO t2 VALUES(4, 'hello'); -+} -+ -+do_execsql_test 7.1 { -+ SELECT rowid FROM t1 WHERE (rowid, x) IN (SELECT a, b FROM t2); -+} -+ -+do_execsql_test 7.2 { -+ SELECT rowid FROM t1 WHERE rowid=2 AND t1 = 'hello'; -+} -+ - - finish_test - -Index: sqlite-src-3300100/src/wherecode.c -=================================================================== ---- sqlite-src-3300100.orig/src/wherecode.c -+++ sqlite-src-3300100/src/wherecode.c -@@ -1307,7 +1307,9 @@ Bitmask sqlite3WhereCodeOneLoopStart( - pTerm = pLoop->aLTerm[j]; - if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){ - disableTerm(pLevel, pTerm); -- }else if( (pTerm->eOperator & WO_IN)!=0 ){ -+ }else if( (pTerm->eOperator & WO_IN)!=0 && -+ sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1 -+ ){ - Expr *pCompare; /* The comparison operator */ - Expr *pRight; /* RHS of the comparison */ - VdbeOp *pOp; /* Opcode to access the value of the IN constraint */ -Index: sqlite-src-3300100/test/rowvaluevtab.test -=================================================================== ---- /dev/null -+++ sqlite-src-3300100/test/rowvaluevtab.test -@@ -0,0 +1,91 @@ -+# 2018 October 14 -+# -+# The author disclaims copyright to this source code. In place of -+# a legal notice, here is a blessing: -+# -+# May you do good and not evil. -+# May you find forgiveness for yourself and forgive others. -+# May you share freely, never taking more than you give. -+# -+#*********************************************************************** -+# -+ -+ -+set testdir [file dirname $argv0] -+source $testdir/tester.tcl -+set ::testprefix rowvaluevtab -+ -+register_echo_module db -+ -+do_execsql_test 1.0 { -+ CREATE TABLE t1(a, b, c); -+ CREATE INDEX t1b ON t1(b); -+ INSERT INTO t1 VALUES('one', 1, 1); -+ INSERT INTO t1 VALUES('two', 1, 2); -+ INSERT INTO t1 VALUES('three', 1, 3); -+ INSERT INTO t1 VALUES('four', 2, 1); -+ INSERT INTO t1 VALUES('five', 2, 2); -+ INSERT INTO t1 VALUES('six', 2, 3); -+ INSERT INTO t1 VALUES('seven', 3, 1); -+ INSERT INTO t1 VALUES('eight', 3, 2); -+ INSERT INTO t1 VALUES('nine', 3, 3); -+ -+ WITH s(i) AS ( -+ SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000 -+ ) INSERT INTO t1 SELECT NULL, NULL, NULL FROM s; -+ CREATE VIRTUAL TABLE e1 USING echo(t1); -+} -+ -+proc do_vfilter4_test {tn sql expected} { -+ set res [list] -+ db eval "explain $sql" { -+ if {$opcode=="VFilter"} { -+ lappend res $p4 -+ } -+ } -+ uplevel [list do_test $tn [list set {} $res] [list {*}$expected]] -+} -+ -+do_execsql_test 1.1 { -+ SELECT a FROM e1 WHERE (b, c) = (2, 2) -+} {five} -+do_vfilter4_test 1.1f { -+ SELECT a FROM e1 WHERE (b, c) = (?, ?) -+} {{SELECT rowid, a, b, c FROM 't1' WHERE b = ?}} -+ -+do_execsql_test 1.2 { -+ SELECT a FROM e1 WHERE (b, c) > (2, 2) -+} {six seven eight nine} -+do_vfilter4_test 1.2f { -+ SELECT a FROM e1 WHERE (b, c) > (2, 2) -+} { -+ {SELECT rowid, a, b, c FROM 't1' WHERE b >= ?} -+} -+ -+do_execsql_test 1.3 { -+ SELECT a FROM e1 WHERE (b, c) >= (2, 2) -+} {five six seven eight nine} -+do_vfilter4_test 1.3f { -+ SELECT a FROM e1 WHERE (b, c) >= (2, 2) -+} { -+ {SELECT rowid, a, b, c FROM 't1' WHERE b >= ?} -+} -+ -+do_execsql_test 1.3 { -+ SELECT a FROM e1 WHERE (b, c) BETWEEN (1, 2) AND (2, 3) -+} {two three four five six} -+do_vfilter4_test 1.3f { -+ SELECT a FROM e1 WHERE (b, c) BETWEEN (1, 2) AND (2, 3) -+} { -+ {SELECT rowid, a, b, c FROM 't1' WHERE b >= ? AND b <= ?} -+} -+ -+do_execsql_test 1.4 { -+ SELECT a FROM e1 WHERE (b, c) IN ( VALUES(2, 2) ) -+} {five} -+do_vfilter4_test 1.4f { -+ SELECT a FROM e1 WHERE (b, c) IN ( VALUES(2, 2) ) -+} {{SELECT rowid, a, b, c FROM 't1' WHERE b = ?}} -+ -+finish_test -+ diff --git a/sqlite3.changes b/sqlite3.changes index 0a39447..365284c 100644 --- a/sqlite3.changes +++ b/sqlite3.changes @@ -1,7 +1,16 @@ ------------------------------------------------------------------- -Tue Dec 10 11:30:35 UTC 2019 - Martin Pluskal +Fri Jan 17 14:29:39 UTC 2020 - Stefan BrĂ¼ns -- Add sqlite3-django.patch to fix builds of django +- Fix regression found when running python-Django/Djano1 testsuite: + + 7833feecfe-Prevent-SQLite-from-bad-NULL-assumption.patch + + 548082dfab-Improvements-to-the-LEFT-JOIN.patch + + 8a39167bd2-Further-improvements-to-LEFT-JOIN.patch +- Fix check for existing dirs, triggers when running the testsuite + on BTRFS or XFS: + + fix_dir_exists_on_btrfs.patch +- Fix truncation/bad rounding of timestamps in SQLite strftime + function, exposed when running testsuite on i586: + + sqlite3-avoid-truncation-error.patch ------------------------------------------------------------------- Fri Oct 11 15:05:00 UTC 2019 - Andreas Stieger @@ -27,7 +36,7 @@ Sun Oct 6 15:43:57 UTC 2019 - Andreas Stieger the type, name, and tbl_name columns of the sqlite_master table have been corrupted and the database connection is not in writable_schema mode. - * The PRAGMA function_list, PRAGMA module_list, and PRAGMA + * The PRAGMA function_list, PRAGMA module_list, and PRAGMA pragma_list commands are now enabled in all builds by default * Add the SQLITE_DBCONFIG_ENABLE_VIEW option for sqlite3_db_config(). * Added the TCL Interface config method in order to be able to @@ -35,7 +44,7 @@ Sun Oct 6 15:43:57 UTC 2019 - Andreas Stieger sqlite3_db_config() options from TCL. * Added the SQLITE_DIRECTONLY flag for application-defined SQL functions to prevent those functions from being used inside - triggers and views + triggers and views - drop sqlite3-CVE-2019-16168.patch, upstream ------------------------------------------------------------------- diff --git a/sqlite3.spec b/sqlite3.spec index a4c0d22..cd9f69d 100644 --- a/sqlite3.spec +++ b/sqlite3.spec @@ -1,7 +1,7 @@ # # spec file for package sqlite3 # -# Copyright (c) 2019 SUSE LLC +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,6 +16,7 @@ # +%bcond_with icu %define oname sqlite %define tarversion 3300100 Name: sqlite3 @@ -28,8 +29,20 @@ URL: http://www.sqlite.org/ Source0: http://www.sqlite.org/2019/sqlite-src-%{tarversion}.zip Source1: baselibs.conf Source2: http://www.sqlite.org/2019/sqlite-doc-%{tarversion}.zip -Patch0: sqlite3-django.patch +# PATCH-FIX-UPSTREAM -- Fix errors with NULL +Patch0: 7833feecfe-Prevent-SQLite-from-bad-NULL-assumption.patch +# PATCH-FIX-UPSTREAM -- Fix errors in LEFT JOIN +Patch1: 548082dfab-Improvements-to-the-LEFT-JOIN.patch +# PATCH-FIX-UPSTREAM -- Fix errors in LEFT JOIN +Patch2: 8a39167bd2-Further-improvements-to-LEFT-JOIN.patch +# PATCH-FIX-UPSTREAM -- Fix incorrect check of stat.size for directories +Patch3: fix_dir_exists_on_btrfs.patch +# PATCH-FIX-OPENSUSE -- Fix error introduced by rounding and truncation, mostly visible on x86 / 80 bit floats +Patch4: sqlite3-avoid-truncation-error.patch BuildRequires: automake +%if %{with icu} +BuildRequires: libicu-devel +%endif BuildRequires: libtool BuildRequires: pkgconfig BuildRequires: readline-devel @@ -104,13 +117,19 @@ other documentation found on sqlite.org. The files can be found in %prep %setup -q -n sqlite-src-%{tarversion} -a2 -%patch0 -p1 +%patch0 -p0 +%patch1 -p0 +%patch2 -p0 +%patch3 -p0 +%patch4 -p0 + rm -v sqlite-doc-%{tarversion}/releaselog/current.html ln -sv `echo %{version} | sed "s/\./_/g"`.html sqlite-doc-%{tarversion}/releaselog/current.html find -type f -name sqlite.css~ -delete +cmp sqlite-doc-%{tarversion}/fileformat{,2}.html && ln -sf fileformat.html sqlite-doc-%{tarversion}/fileformat2.html %build -export LIBS="$LIBS -lm " +export LIBS="$LIBS -lm %{?with_icu:-licuuc -licui18n}" export CFLAGS="%{optflags} \ -DSQLITE_ENABLE_API_ARMOR \ -DSQLITE_ENABLE_COLUMN_METADATA \ @@ -119,6 +138,9 @@ export CFLAGS="%{optflags} \ -DSQLITE_ENABLE_FTS3 \ -DSQLITE_ENABLE_FTS4 \ -DSQLITE_ENABLE_FTS5 \ +%if %{with icu} + -DSQLITE_ENABLE_ICU \ +%endif -DSQLITE_ENABLE_JSON1 \ -DSQLITE_ENABLE_RBU \ -DSQLITE_ENABLE_RTREE \ @@ -140,12 +162,8 @@ export CFLAGS="%{optflags} \ make %{?_smp_mflags} sqlite3.c make %{?_smp_mflags} -%ifnarch %{ix86} -# Tests fail due to slight precision variation caused by FPU being 80-bit internally. -# see https://bugs.gentoo.org/628242 %check make %{?_smp_mflags} test -%endif %install %make_install