blob: 183c5e4f952f875dc755d4a993824225b0c4744a [file] [log] [blame]
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Darwin Huang <huangdarwin@chromium.org>
Date: Fri, 17 May 2019 16:00:46 -0700
Subject: [PATCH 7/8] Fix OP_Delete assert
Backports https://www.sqlite.org/src/info/915388ab39ba3ca8
Bug: https://crbug.com/962055#c6
---
third_party/sqlite/patched/src/vdbe.c | 2 +-
third_party/sqlite/patched/test/corruptL.test | 53 +++++++++++++++++++
2 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/third_party/sqlite/patched/src/vdbe.c b/third_party/sqlite/patched/src/vdbe.c
index a5b0d4b48e28..5f0728acd242 100644
--- a/third_party/sqlite/patched/src/vdbe.c
+++ b/third_party/sqlite/patched/src/vdbe.c
@@ -4734,7 +4734,7 @@ case OP_Delete: {
** OP_Delete will have also set the pC->movetoTarget field to the rowid of
** the row that is being deleted */
i64 iKey = sqlite3BtreeIntegerKey(pC->uc.pCursor);
- assert( pC->movetoTarget==iKey );
+ assert( CORRUPT_DB || pC->movetoTarget==iKey );
}
#endif
diff --git a/third_party/sqlite/patched/test/corruptL.test b/third_party/sqlite/patched/test/corruptL.test
index de0196ecc09e..3a6c1384df1d 100644
--- a/third_party/sqlite/patched/test/corruptL.test
+++ b/third_party/sqlite/patched/test/corruptL.test
@@ -838,4 +838,57 @@ do_catchsql_test 8.1 {
INSERT INTO t3 SELECT * FROM t2;
} {1 {database disk image is malformed}}
+
+#-------------------------------------------------------------------------
+reset_db
+do_test 11.0 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 595 pagesize 512 filename x.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 02 00 00 01 00 40 20 20 00 01 00 0c 00 00 00 07 .....@ ........
+| 32: 00 00 00 05 07 a1 1f fa 00 00 00 08 00 00 00 04 ................
+| 48: 00 00 01 00 00 49 00 00 00 00 00 05 00 00 00 00 .....I..........
+| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c ................
+| 96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0 ..,P............
+| 112: 01 56 01 86 01 2a 01 06 00 00 62 00 00 00 00 00 .V...*....b.....
+| 128: 00 ed e2 78 74 64 33 ff 43 52 45 41 54 45 20 49 ...xtd3.CREATE I
+| 144: 4e 44 45 58 20 74 33 78 20 4f 4e 20 74 33 28 38 NDEX t3x ON t3(8
+| 160: 29 2e 04 06 17 15 11 01 45 69 6e 64 65 68 74 32 ).......Eindeht2
+| 176: 63 64 74 31 e5 43 52 45 41 54 45 20 49 4e 44 45 cdt1.CREATE INDE
+| 192: 58 20 74 32 63 c4 20 4f 4e 20 74 32 28 63 2c 64 X t2c. ON t2(c,d
+| 208: 29 28 05 06 17 01 11 11 3d 74 61 6c 36 74 62 74 )(......=tal6tbt
+| 224: 65 32 04 43 52 45 41 54 45 20 54 41 42 4c 45 20 e2.CREATE TABLE
+| 240: 74 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 t...............
+| 256: 00 00 00 00 00 00 22 07 06 17 11 11 01 30 e8 03 .............0..
+| 272: 62 6c 65 74 34 74 35 02 43 52 45 41 54 45 20 54 blet4t5.CREATE T
+| 288: 41 42 4c 45 20 74 34 28 94 29 2a 06 06 17 13 11 ABLE t4(.)*.....
+| 304: 01 3f 69 33 74 6e 65 78 78 74 64 33 ff 43 52 45 .?i3tnexxtd3.CRE
+| 320: 41 54 45 20 49 4e 44 45 58 20 74 33 78 20 4f 4e ATE INDEX t3x ON
+| 336: 20 74 31 28 38 29 2e 04 06 17 15 11 01 45 69 6e t1(8).......Ein
+| 352: 64 65 68 74 32 63 64 74 31 e5 43 52 45 41 54 45 deht2cdt1.CREATE
+| 368: 20 49 4e 44 45 58 20 74 32 63 c4 20 4f 4e 20 74 INDEX t2c. ON t
+| 384: 32 28 63 2c 64 29 28 05 06 17 01 11 11 3d 74 61 2(c,d)(......=ta
+| 400: 6c 32 74 62 74 65 32 04 43 52 45 41 54 45 20 54 l2tbte2.CREATE T
+| 416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 ABLE t3(c,x,e,f)
+| 432: 28 02 06 17 11 11 01 3d 74 61 9e 93 65 74 32 74 (......=ta..et2t
+| 448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 2.CREATE TABLE t
+| 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$.....
+| 480: 01 35 55 61 62 6c 88 74 31 74 31 02 43 52 45 41 .5Uabl.t1t1.CREA
+| 496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 29 TE TABLE t1(a,b)
+| page 2 offset 512
+| 0: 0d 00 00 00 0d 25 00 01 cf 00 01 fa 01 f3 01 de .....%..........
+| 16: 01 00 00 00 fd 00 00 0d 00 00 00 00 45 20 54 41 ............E TA
+| 32: 42 4c 45 20 74 34 28 94 29 2a 06 06 17 13 11 01 BLE t4(.)*......
+| 48: 3f 69 33 74 6e 65 78 78 74 64 33 ff 43 52 45 a0 ?i3tnexxtd3.CRE.
+| 64: a0 a0 a0 a0 a0 a0 a0 a0 a0 a0 a0 a0 74 13 11 01 ............t...
+| 80: 49 45 74 00 00 00 00 00 00 00 00 00 00 00 00 00 IEt.............
+| end x.db
+}]} {}
+
+do_catchsql_test 11.1 {
+ DELETE FROM t3 WHERE x IN (SELECT x FROM t4);
+} {1 {database disk image is malformed}}
+
finish_test
--
2.21.0