Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash in SQLite sqlite3Fts3Incrmerge
Backports https://www.sqlite.org/src/info/361eb2f682a303bb and https://sqlite.org/src/info/67da31e24ebb49c4 Bug: 998494 Change-Id: Icd11546d8f504a1c6df7bc5692b917ded35ba486 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835704 Reviewed-by: Darwin Huang <huangdarwin@chromium.org> Commit-Queue: Darwin Huang <huangdarwin@chromium.org> Cr-Commit-Position: refs/heads/master@{#704392}
- Loading branch information
1 parent
9710388
commit f9f8801
Showing
13 changed files
with
232 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# 2019 October 02 | ||
# | ||
# 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. | ||
# | ||
#************************************************************************* | ||
# This file implements regression tests for SQLite library. The | ||
# focus of this script is testing the FTS4 module. | ||
# | ||
|
||
set testdir [file dirname $argv0] | ||
source $testdir/tester.tcl | ||
set testprefix fts4merge5 | ||
|
||
# If SQLITE_ENABLE_FTS3 is defined, omit this file. | ||
ifcapable !fts3 { | ||
finish_test | ||
return | ||
} | ||
|
||
source $testdir/genesis.tcl | ||
|
||
do_execsql_test 1.1 { | ||
CREATE TABLE t1(docid, words); | ||
} | ||
fts_kjv_genesis | ||
|
||
do_execsql_test 1.2 { | ||
CREATE VIRTUAL TABLE x1 USING fts3; | ||
INSERT INTO x1(x1) VALUES('nodesize=64'); | ||
INSERT INTO x1(x1) VALUES('maxpending=64'); | ||
} | ||
|
||
do_execsql_test 1.3 { | ||
INSERT INTO x1(docid, content) SELECT * FROM t1; | ||
} | ||
|
||
for {set tn 1} {1} {incr tn} { | ||
set tc1 [db total_changes] | ||
do_execsql_test 1.4.$tn.1 { | ||
INSERT INTO x1(x1) VALUES('merge=1,2'); | ||
} | ||
set tc2 [db total_changes] | ||
|
||
if {($tc2 - $tc1)<2} break | ||
|
||
do_execsql_test 1.4.$tn.1 { | ||
INSERT INTO x1(x1) VALUES('integrity-check'); | ||
} | ||
} | ||
|
||
|
||
|
||
finish_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
third_party/sqlite/patches/0007-The-nodeReaderInit-function-in-FTS3-may-not-assume-t.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Conrad Irwin <conrad.irwin@gmail.com> | ||
Date: Wed, 2 Oct 2019 11:17:40 -0700 | ||
Subject: [PATCH 7/8] The nodeReaderInit() function in FTS3 may not assume that | ||
the node is non-empty. | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
|
||
Backports https://www.sqlite.org/src/info/361eb2f682a303bb | ||
|
||
Bug: 998494 | ||
--- | ||
third_party/sqlite/patched/ext/fts3/fts3_write.c | 4 ++-- | ||
1 file changed, 2 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/third_party/sqlite/patched/ext/fts3/fts3_write.c b/third_party/sqlite/patched/ext/fts3/fts3_write.c | ||
index 4be6941579c5..6152c82871cf 100644 | ||
--- a/third_party/sqlite/patched/ext/fts3/fts3_write.c | ||
+++ b/third_party/sqlite/patched/ext/fts3/fts3_write.c | ||
@@ -3797,14 +3797,14 @@ static int nodeReaderInit(NodeReader *p, const char *aNode, int nNode){ | ||
p->nNode = nNode; | ||
|
||
/* Figure out if this is a leaf or an internal node. */ | ||
- if( p->aNode[0] ){ | ||
+ if( aNode && aNode[0] ){ | ||
/* An internal node. */ | ||
p->iOff = 1 + sqlite3Fts3GetVarint(&p->aNode[1], &p->iChild); | ||
}else{ | ||
p->iOff = 1; | ||
} | ||
|
||
- return nodeReaderNext(p); | ||
+ return aNode ? nodeReaderNext(p) : SQLITE_OK; | ||
} | ||
|
||
/* | ||
-- | ||
2.20.1 (Apple Git-117) | ||
|
112 changes: 112 additions & 0 deletions
112
third_party/sqlite/patches/0008-Fix-a-long-standing-problem-in-fts4-incrmental-merge.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Conrad Irwin <conrad.irwin@gmail.com> | ||
Date: Fri, 4 Oct 2019 09:30:44 -0700 | ||
Subject: [PATCH 8/8] Fix a long-standing problem in fts4 incrmental merge. | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
|
||
Backport https://sqlite.org/src/info/67da31e24ebb49c4 | ||
|
||
Bug: 998494 | ||
--- | ||
.../sqlite/patched/ext/fts3/fts3_write.c | 4 +- | ||
.../sqlite/patched/test/fts4merge5.test | 58 +++++++++++++++++++ | ||
.../sqlite/patched/test/permutations.test | 1 + | ||
3 files changed, 61 insertions(+), 2 deletions(-) | ||
create mode 100644 third_party/sqlite/patched/test/fts4merge5.test | ||
|
||
diff --git a/third_party/sqlite/patched/ext/fts3/fts3_write.c b/third_party/sqlite/patched/ext/fts3/fts3_write.c | ||
index 6152c82871cf..c22711dad8c7 100644 | ||
--- a/third_party/sqlite/patched/ext/fts3/fts3_write.c | ||
+++ b/third_party/sqlite/patched/ext/fts3/fts3_write.c | ||
@@ -4295,8 +4295,8 @@ static int fts3IncrmergeLoad( | ||
NodeReader reader; | ||
pNode = &pWriter->aNodeWriter[i]; | ||
|
||
- rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n); | ||
- if( reader.aNode ){ | ||
+ if ( pNode->block.a){ | ||
+ rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n); | ||
while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader); | ||
blobGrowBuffer(&pNode->key, reader.term.n, &rc); | ||
if( rc==SQLITE_OK ){ | ||
diff --git a/third_party/sqlite/patched/test/fts4merge5.test b/third_party/sqlite/patched/test/fts4merge5.test | ||
new file mode 100644 | ||
index 000000000000..1fad778b95e7 | ||
--- /dev/null | ||
+++ b/third_party/sqlite/patched/test/fts4merge5.test | ||
@@ -0,0 +1,58 @@ | ||
+# 2019 October 02 | ||
+# | ||
+# 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. | ||
+# | ||
+#************************************************************************* | ||
+# This file implements regression tests for SQLite library. The | ||
+# focus of this script is testing the FTS4 module. | ||
+# | ||
+ | ||
+set testdir [file dirname $argv0] | ||
+source $testdir/tester.tcl | ||
+set testprefix fts4merge5 | ||
+ | ||
+# If SQLITE_ENABLE_FTS3 is defined, omit this file. | ||
+ifcapable !fts3 { | ||
+ finish_test | ||
+ return | ||
+} | ||
+ | ||
+source $testdir/genesis.tcl | ||
+ | ||
+do_execsql_test 1.1 { | ||
+ CREATE TABLE t1(docid, words); | ||
+} | ||
+fts_kjv_genesis | ||
+ | ||
+do_execsql_test 1.2 { | ||
+ CREATE VIRTUAL TABLE x1 USING fts3; | ||
+ INSERT INTO x1(x1) VALUES('nodesize=64'); | ||
+ INSERT INTO x1(x1) VALUES('maxpending=64'); | ||
+} | ||
+ | ||
+do_execsql_test 1.3 { | ||
+ INSERT INTO x1(docid, content) SELECT * FROM t1; | ||
+} | ||
+ | ||
+for {set tn 1} {1} {incr tn} { | ||
+ set tc1 [db total_changes] | ||
+ do_execsql_test 1.4.$tn.1 { | ||
+ INSERT INTO x1(x1) VALUES('merge=1,2'); | ||
+ } | ||
+ set tc2 [db total_changes] | ||
+ | ||
+ if {($tc2 - $tc1)<2} break | ||
+ | ||
+ do_execsql_test 1.4.$tn.1 { | ||
+ INSERT INTO x1(x1) VALUES('integrity-check'); | ||
+ } | ||
+} | ||
+ | ||
+ | ||
+ | ||
+finish_test | ||
diff --git a/third_party/sqlite/patched/test/permutations.test b/third_party/sqlite/patched/test/permutations.test | ||
index ac2125c73b12..717998ef3e5d 100644 | ||
--- a/third_party/sqlite/patched/test/permutations.test | ||
+++ b/third_party/sqlite/patched/test/permutations.test | ||
@@ -126,6 +126,7 @@ set allquicktests [test_set $alltests -exclude { | ||
walcrash2.test e_fkey.test backup.test | ||
|
||
fts4merge.test fts4merge2.test fts4merge4.test fts4check.test | ||
+ fts4merge5.test | ||
fts3cov.test fts3snippet.test fts3corrupt2.test fts3an.test | ||
fts3defer.test fts4langid.test fts3sort.test fts5unicode.test | ||
|
||
-- | ||
2.20.1 (Apple Git-117) | ||
|