Fixed handling LIKE experrsion in WHERE clause (#1947883)

This commit is contained in:
Ondrej Dubaj 2021-04-14 08:33:09 +02:00
parent cc02f02fbe
commit d95c433dc3
2 changed files with 52 additions and 2 deletions

View File

@ -0,0 +1,43 @@
Subject: [PATCH] Fix a problem with handling expressions like '(col IS NULL
AND <expr1>) 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

View File

@ -12,7 +12,7 @@
Summary: Library that implements an embeddable SQL database engine Summary: Library that implements an embeddable SQL database engine
Name: sqlite Name: sqlite
Version: %{rpmver} Version: %{rpmver}
Release: 1%{?dist} Release: 2%{?dist}
License: Public Domain License: Public Domain
URL: http://www.sqlite.org/ 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 Patch4: sqlite-3.16-datetest-2.2c.patch
# Modify sync2.test to pass with DIRSYNC turned off # Modify sync2.test to pass with DIRSYNC turned off
Patch5: sqlite-3.18.0-sync2-dirsync.patch 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: make
BuildRequires: gcc BuildRequires: gcc
@ -139,6 +142,7 @@ This package contains the analysis program for %{name}.
%patch4 -p1 %patch4 -p1
%endif %endif
%patch5 -p1 %patch5 -p1
%patch6 -p1
# Remove backup-file # Remove backup-file
rm -f %{name}-doc-%{docver}/sqlite.css~ || : rm -f %{name}-doc-%{docver}/sqlite.css~ || :
@ -257,7 +261,10 @@ make test
%endif %endif
%changelog %changelog
* Thu Apr 06 2021 Ondrej Dubaj <odubaj@redhat.com> - 3.35.4-1 * Wed Apr 14 2021 Ondrej Dubaj <odubaj@redhat.com> - 3.35.4-2
- Fixed handling LIKE experrsion in WHERE clause (#1947883)
* Tue Apr 06 2021 Ondrej Dubaj <odubaj@redhat.com> - 3.35.4-1
- Updated to version 3.35.4 (https://sqlite.org/releaselog/3_35_4.html) - Updated to version 3.35.4 (https://sqlite.org/releaselog/3_35_4.html)
* Fri Mar 26 2021 Ondrej Dubaj <odubaj@redhat.com> - 3.35.3-1 * Fri Mar 26 2021 Ondrej Dubaj <odubaj@redhat.com> - 3.35.3-1