From d95c433dc300cf493d86ef6bd9799f34fdd2ab6e Mon Sep 17 00:00:00 2001 From: Ondrej Dubaj Date: Wed, 14 Apr 2021 08:33:09 +0200 Subject: [PATCH] Fixed handling LIKE experrsion in WHERE clause (#1947883) --- ...3.35.4-fix-handling-LIKE-expressions.patch | 43 +++++++++++++++++++ sqlite.spec | 11 ++++- 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 sqlite-3.35.4-fix-handling-LIKE-expressions.patch diff --git a/sqlite-3.35.4-fix-handling-LIKE-expressions.patch b/sqlite-3.35.4-fix-handling-LIKE-expressions.patch new file mode 100644 index 0000000..46d3988 --- /dev/null +++ b/sqlite-3.35.4-fix-handling-LIKE-expressions.patch @@ -0,0 +1,43 @@ +Subject: [PATCH] Fix a problem with handling expressions like '(col IS NULL + AND ) OR col == NULL' in WHERE clauses. + +--- + src/whereexpr.c | 1 + + test/notnull2.test | 10 ++++++++++ + 2 files changed, 11 insertions(+) + +diff --git a/src/whereexpr.c b/src/whereexpr.c +index b3f48fe..1807fbb 100644 +--- a/src/whereexpr.c ++++ b/src/whereexpr.c +@@ -511,6 +511,7 @@ static void whereCombineDisjuncts( + int op; /* Operator for the combined expression */ + int idxNew; /* Index in pWC of the next virtual term */ + ++ if( (pOne->wtFlags | pTwo->wtFlags) & TERM_VNULL ) return; + if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return; + if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return; + if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp +diff --git a/test/notnull2.test b/test/notnull2.test +index 9ae190f..0a7a492 100644 +--- a/test/notnull2.test ++++ b/test/notnull2.test +@@ -97,5 +97,15 @@ do_execsql_test 2.1 { + SELECT * FROM (SELECT a, b FROM t1) LEFT JOIN t3 ON a IS NULL; + } + ++#------------------------------------------------------------------------- ++reset_db ++do_execsql_test 3.0 { ++ CREATE TABLE t0(c0 PRIMARY KEY); ++ INSERT INTO t0(c0) VALUES (0); ++} ++do_execsql_test 3.1 { ++ SELECT * FROM t0 WHERE ((c0 NOT NULL) AND 1) OR (c0 == NULL); ++} {0} ++ + finish_test + +-- +2.30.2 + diff --git a/sqlite.spec b/sqlite.spec index 03ee79e..080f488 100644 --- a/sqlite.spec +++ b/sqlite.spec @@ -12,7 +12,7 @@ Summary: Library that implements an embeddable SQL database engine Name: sqlite Version: %{rpmver} -Release: 1%{?dist} +Release: 2%{?dist} License: Public Domain URL: http://www.sqlite.org/ @@ -31,6 +31,9 @@ Patch3: sqlite-3.8.0-percentile-test.patch Patch4: sqlite-3.16-datetest-2.2c.patch # Modify sync2.test to pass with DIRSYNC turned off Patch5: sqlite-3.18.0-sync2-dirsync.patch +# Fixed handling LIKE experrsion in WHERE clause +# https://sqlite.org/src/info/40852ca8e215e51f +Patch6: sqlite-3.35.4-fix-handling-LIKE-expressions.patch BuildRequires: make BuildRequires: gcc @@ -139,6 +142,7 @@ This package contains the analysis program for %{name}. %patch4 -p1 %endif %patch5 -p1 +%patch6 -p1 # Remove backup-file rm -f %{name}-doc-%{docver}/sqlite.css~ || : @@ -257,7 +261,10 @@ make test %endif %changelog -* Thu Apr 06 2021 Ondrej Dubaj - 3.35.4-1 +* Wed Apr 14 2021 Ondrej Dubaj - 3.35.4-2 +- Fixed handling LIKE experrsion in WHERE clause (#1947883) + +* Tue Apr 06 2021 Ondrej Dubaj - 3.35.4-1 - Updated to version 3.35.4 (https://sqlite.org/releaselog/3_35_4.html) * Fri Mar 26 2021 Ondrej Dubaj - 3.35.3-1