Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(915)

Side by Side Diff: third_party/sqlite/patches/0004-Virtual-table-supporting-recovery-of-corrupted-datab.patch

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 From d176c774ba1a8b431400f38ca71459bf148f0c3a Mon Sep 17 00:00:00 2001 1 From b246b60be3e9e241892d772a324aced44865d7f9 Mon Sep 17 00:00:00 2001
2 From: Scott Hess <shess@chromium.org> 2 From: Scott Hess <shess@chromium.org>
3 Date: Sat, 20 Jul 2013 11:42:21 -0700 3 Date: Sat, 20 Jul 2013 11:42:21 -0700
4 Subject: [PATCH 05/13] Virtual table supporting recovery of corrupted 4 Subject: [PATCH 04/10] Virtual table supporting recovery of corrupted
5 databases. 5 databases.
6 6
7 "recover" implements a virtual table which uses the SQLite pager layer 7 "recover" implements a virtual table which uses the SQLite pager layer
8 to read table pages and pull out the data which is structurally sound 8 to read table pages and pull out the data which is structurally sound
9 (at least at the storage layer). 9 (at least at the storage layer).
10 10
11 BUG=109482 11 BUG=109482
12 12
13 Since this implements a new feature for SQLite, the review URLs aren't 13 Since this implements a new feature for SQLite, the review URLs aren't
14 listed. This patch and the top of recover.c should be considered 14 listed. This patch and the top of recover.c should be considered
15 authoritative. The history is mostly under 15 authoritative. The history is mostly under
16 third_party/sqlite/src/src/{recover,recover-alt}.c . 16 third_party/sqlite/src/src/{recover,recover-alt}.c .
17 --- 17 ---
18 third_party/sqlite/src/main.mk | 6 +- 18 third_party/sqlite/src/main.mk | 5 +
19 third_party/sqlite/src/src/main.c | 8 + 19 third_party/sqlite/src/src/main.c | 8 +
20 third_party/sqlite/src/src/recover.c | 2270 +++++++++++++++++++++++++++ 20 third_party/sqlite/src/src/recover.c | 2270 +++++++++++++++++++++++++++
21 third_party/sqlite/src/src/recover.h | 23 + 21 third_party/sqlite/src/src/recover.h | 23 +
22 third_party/sqlite/src/src/recover_varint.c | 201 +++ 22 third_party/sqlite/src/src/recover_varint.c | 201 +++
23 third_party/sqlite/src/test/recover.test | 164 ++ 23 third_party/sqlite/src/test/recover.test | 164 ++
24 third_party/sqlite/src/test/recover0.test | 532 +++++++ 24 third_party/sqlite/src/test/recover0.test | 532 +++++++
25 third_party/sqlite/src/test/recover1.test | 429 +++++ 25 third_party/sqlite/src/test/recover1.test | 429 +++++
26 third_party/sqlite/src/test/recover2.test | 157 ++ 26 third_party/sqlite/src/test/recover2.test | 157 ++
27 9 files changed, 3789 insertions(+), 1 deletion(-) 27 9 files changed, 3789 insertions(+)
28 create mode 100644 third_party/sqlite/src/src/recover.c 28 create mode 100644 third_party/sqlite/src/src/recover.c
29 create mode 100644 third_party/sqlite/src/src/recover.h 29 create mode 100644 third_party/sqlite/src/src/recover.h
30 create mode 100644 third_party/sqlite/src/src/recover_varint.c 30 create mode 100644 third_party/sqlite/src/src/recover_varint.c
31 create mode 100644 third_party/sqlite/src/test/recover.test 31 create mode 100644 third_party/sqlite/src/test/recover.test
32 create mode 100644 third_party/sqlite/src/test/recover0.test 32 create mode 100644 third_party/sqlite/src/test/recover0.test
33 create mode 100644 third_party/sqlite/src/test/recover1.test 33 create mode 100644 third_party/sqlite/src/test/recover1.test
34 create mode 100644 third_party/sqlite/src/test/recover2.test 34 create mode 100644 third_party/sqlite/src/test/recover2.test
35 35
36 diff --git a/third_party/sqlite/src/main.mk b/third_party/sqlite/src/main.mk 36 diff --git a/third_party/sqlite/src/main.mk b/third_party/sqlite/src/main.mk
37 index 6ff3bd4..26f9f15 100644 37 index 6feb638b9280..b46c5bbc9ced 100644
38 --- a/third_party/sqlite/src/main.mk 38 --- a/third_party/sqlite/src/main.mk
39 +++ b/third_party/sqlite/src/main.mk 39 +++ b/third_party/sqlite/src/main.mk
40 @@ -67,7 +67,8 @@ LIBOBJ+= vdbe.o parse.o \ 40 @@ -75,6 +75,8 @@ LIBOBJ+= vdbe.o parse.o \
41 mutex.o mutex_noop.o mutex_unix.o mutex_w32.o \ 41 » vdbetrace.o wal.o walker.o where.o wherecode.o whereexpr.o \
42 notify.o opcodes.o os.o os_unix.o os_win.o \ 42 utf.o vtab.o
43 pager.o pcache.o pcache1.o pragma.o prepare.o printf.o \ 43
44 - random.o resolve.o rowset.o rtree.o select.o sqlite3rbu.o status.o \ 44 +LIBOBJ += recover.o recover_varint.o resolve.o
45 + random.o recover.o recover_varint.o resolve.o rowset.o rtree.o \ 45 +
46 + select.o sqlite3rbu.o status.o \ 46 LIBOBJ += sqlite3session.o
47 table.o threads.o tokenize.o treeview.o trigger.o \ 47
48 update.o userauth.o util.o vacuum.o \ 48 # All of the source code files.
49 vdbeapi.o vdbeaux.o vdbeblob.o vdbemem.o vdbesort.o \ 49 @@ -370,6 +372,8 @@ TESTSRC2 = \
50 @@ -360,6 +361,8 @@ TESTSRC2 = \
51 $(TOP)/src/prepare.c \ 50 $(TOP)/src/prepare.c \
52 $(TOP)/src/printf.c \ 51 $(TOP)/src/printf.c \
53 $(TOP)/src/random.c \ 52 $(TOP)/src/random.c \
54 + $(TOP)/src/recover.c \ 53 + $(TOP)/src/recover.c \
55 + $(TOP)/src/recover_varint.c \ 54 + $(TOP)/src/recover_varint.c \
56 $(TOP)/src/pcache.c \ 55 $(TOP)/src/pcache.c \
57 $(TOP)/src/pcache1.c \ 56 $(TOP)/src/pcache1.c \
58 $(TOP)/src/select.c \ 57 $(TOP)/src/select.c \
59 @@ -720,6 +723,7 @@ sqlite3_analyzer$(EXE): sqlite3_analyzer.c 58 @@ -768,6 +772,7 @@ TESTFIXTURE_FLAGS = -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1
60 # 59 TESTFIXTURE_FLAGS += -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" -DSQLITE_CORE
61 TESTFIXTURE_FLAGS = -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 60 TESTFIXTURE_FLAGS += -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
62 TESTFIXTURE_FLAGS += -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" -DSQLITE_CORE 61 TESTFIXTURE_FLAGS += -DSQLITE_DEFAULT_PAGE_SIZE=1024
63 +TESTFIXTURE_FLAGS += -DDEFAULT_ENABLE_RECOVER=1 62 +TESTFIXTURE_FLAGS += -DDEFAULT_ENABLE_RECOVER=1
64 63
65 testfixture$(EXE): $(TESTSRC2) libsqlite3.a $(TESTSRC) $(TOP)/src/tclsqlite.c 64 testfixture$(EXE): $(TESTSRC2) libsqlite3.a $(TESTSRC) $(TOP)/src/tclsqlite.c
66 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 $(TESTFIXTURE_FLAGS) \ 65 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 $(TESTFIXTURE_FLAGS) \
67 diff --git a/third_party/sqlite/src/src/main.c b/third_party/sqlite/src/src/main .c 66 diff --git a/third_party/sqlite/src/src/main.c b/third_party/sqlite/src/src/main .c
68 index 3be7c77..301808c 100644 67 index 9aad8fdd4cf8..03e4f1b92845 100644
69 --- a/third_party/sqlite/src/src/main.c 68 --- a/third_party/sqlite/src/src/main.c
70 +++ b/third_party/sqlite/src/src/main.c 69 +++ b/third_party/sqlite/src/src/main.c
71 @@ -2927,6 +2927,14 @@ static int openDatabase( 70 @@ -3014,6 +3014,14 @@ static int openDatabase(
72 } 71 }
73 #endif 72 #endif
74 73
75 +#ifdef DEFAULT_ENABLE_RECOVER 74 +#ifdef DEFAULT_ENABLE_RECOVER
76 + /* Initialize recover virtual table for testing. */ 75 + /* Initialize recover virtual table for testing. */
77 + extern int recoverVtableInit(sqlite3 *db); 76 + extern int recoverVtableInit(sqlite3 *db);
78 + if( !db->mallocFailed && rc==SQLITE_OK ){ 77 + if( !db->mallocFailed && rc==SQLITE_OK ){
79 + rc = recoverVtableInit(db); 78 + rc = recoverVtableInit(db);
80 + } 79 + }
81 +#endif 80 +#endif
82 + 81 +
83 #ifdef SQLITE_ENABLE_ICU 82 #ifdef SQLITE_ENABLE_ICU
84 if( !db->mallocFailed && rc==SQLITE_OK ){ 83 if( !db->mallocFailed && rc==SQLITE_OK ){
85 rc = sqlite3IcuInit(db); 84 rc = sqlite3IcuInit(db);
86 diff --git a/third_party/sqlite/src/src/recover.c b/third_party/sqlite/src/src/r ecover.c 85 diff --git a/third_party/sqlite/src/src/recover.c b/third_party/sqlite/src/src/r ecover.c
87 new file mode 100644 86 new file mode 100644
88 index 0000000..c22fd4d 87 index 000000000000..c22fd4d43166
89 --- /dev/null 88 --- /dev/null
90 +++ b/third_party/sqlite/src/src/recover.c 89 +++ b/third_party/sqlite/src/src/recover.c
91 @@ -0,0 +1,2270 @@ 90 @@ -0,0 +1,2270 @@
92 +/* 91 +/*
93 +** 2012 Jan 11 92 +** 2012 Jan 11
94 +** 93 +**
95 +** The author disclaims copyright to this source code. In place of 94 +** The author disclaims copyright to this source code. In place of
96 +** a legal notice, here is a blessing: 95 +** a legal notice, here is a blessing:
97 +** 96 +**
98 +** May you do good and not evil. 97 +** May you do good and not evil.
(...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 + if( rc!=SQLITE_OK ){ 2353 + if( rc!=SQLITE_OK ){
2355 + recoverRelease(pRecover); 2354 + recoverRelease(pRecover);
2356 + return rc; 2355 + return rc;
2357 + } 2356 + }
2358 + 2357 +
2359 + *ppVtab = (sqlite3_vtab *)pRecover; 2358 + *ppVtab = (sqlite3_vtab *)pRecover;
2360 + return SQLITE_OK; 2359 + return SQLITE_OK;
2361 +} 2360 +}
2362 diff --git a/third_party/sqlite/src/src/recover.h b/third_party/sqlite/src/src/r ecover.h 2361 diff --git a/third_party/sqlite/src/src/recover.h b/third_party/sqlite/src/src/r ecover.h
2363 new file mode 100644 2362 new file mode 100644
2364 index 0000000..691f2fd 2363 index 000000000000..691f2fdbab22
2365 --- /dev/null 2364 --- /dev/null
2366 +++ b/third_party/sqlite/src/src/recover.h 2365 +++ b/third_party/sqlite/src/src/recover.h
2367 @@ -0,0 +1,23 @@ 2366 @@ -0,0 +1,23 @@
2368 +/* TODO(shess): sqliteicu.h is able to make this include without 2367 +/* TODO(shess): sqliteicu.h is able to make this include without
2369 +** trouble. It doesn't work when used with Chromium's SQLite. For 2368 +** trouble. It doesn't work when used with Chromium's SQLite. For
2370 +** now the including code must include sqlite3.h first. 2369 +** now the including code must include sqlite3.h first.
2371 +*/ 2370 +*/
2372 +/* #include "sqlite3.h" */ 2371 +/* #include "sqlite3.h" */
2373 + 2372 +
2374 +#ifdef __cplusplus 2373 +#ifdef __cplusplus
2375 +extern "C" { 2374 +extern "C" {
2376 +#endif 2375 +#endif
2377 + 2376 +
2378 +/* 2377 +/*
2379 +** Call to initialize the recover virtual-table modules (see recover.c). 2378 +** Call to initialize the recover virtual-table modules (see recover.c).
2380 +** 2379 +**
2381 +** This could be loaded by default in main.c, but that would make the 2380 +** This could be loaded by default in main.c, but that would make the
2382 +** virtual table available to Web SQL. Breaking it out allows only 2381 +** virtual table available to Web SQL. Breaking it out allows only
2383 +** selected users to enable it (currently sql/recovery.cc). 2382 +** selected users to enable it (currently sql/recovery.cc).
2384 +*/ 2383 +*/
2385 +SQLITE_API 2384 +SQLITE_API
2386 +int recoverVtableInit(sqlite3 *db); 2385 +int recoverVtableInit(sqlite3 *db);
2387 + 2386 +
2388 +#ifdef __cplusplus 2387 +#ifdef __cplusplus
2389 +} /* End of the 'extern "C"' block */ 2388 +} /* End of the 'extern "C"' block */
2390 +#endif 2389 +#endif
2391 diff --git a/third_party/sqlite/src/src/recover_varint.c b/third_party/sqlite/sr c/src/recover_varint.c 2390 diff --git a/third_party/sqlite/src/src/recover_varint.c b/third_party/sqlite/sr c/src/recover_varint.c
2392 new file mode 100644 2391 new file mode 100644
2393 index 0000000..c111e2c 2392 index 000000000000..c111e2cedc44
2394 --- /dev/null 2393 --- /dev/null
2395 +++ b/third_party/sqlite/src/src/recover_varint.c 2394 +++ b/third_party/sqlite/src/src/recover_varint.c
2396 @@ -0,0 +1,201 @@ 2395 @@ -0,0 +1,201 @@
2397 +/* 2396 +/*
2398 +** 2016 Feb 29 2397 +** 2016 Feb 29
2399 +** 2398 +**
2400 +** The author disclaims copyright to this source code. In place of 2399 +** The author disclaims copyright to this source code. In place of
2401 +** a legal notice, here is a blessing: 2400 +** a legal notice, here is a blessing:
2402 +** 2401 +**
2403 +** May you do good and not evil. 2402 +** May you do good and not evil.
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2590 + b = b>>3; 2589 + b = b>>3;
2591 + s |= b; 2590 + s |= b;
2592 + 2591 +
2593 + *v = ((u64)s)<<32 | a; 2592 + *v = ((u64)s)<<32 | a;
2594 + 2593 +
2595 + return 9; 2594 + return 9;
2596 +} 2595 +}
2597 + 2596 +
2598 diff --git a/third_party/sqlite/src/test/recover.test b/third_party/sqlite/src/t est/recover.test 2597 diff --git a/third_party/sqlite/src/test/recover.test b/third_party/sqlite/src/t est/recover.test
2599 new file mode 100644 2598 new file mode 100644
2600 index 0000000..bfb7888 2599 index 000000000000..bfb788814866
2601 --- /dev/null 2600 --- /dev/null
2602 +++ b/third_party/sqlite/src/test/recover.test 2601 +++ b/third_party/sqlite/src/test/recover.test
2603 @@ -0,0 +1,164 @@ 2602 @@ -0,0 +1,164 @@
2604 +# 2012 January 11 {} 2603 +# 2012 January 11 {}
2605 +# 2604 +#
2606 +# The author disclaims copyright to this source code. In place of 2605 +# The author disclaims copyright to this source code. In place of
2607 +# a legal notice, here is a blessing: 2606 +# a legal notice, here is a blessing:
2608 +# 2607 +#
2609 +# May you do good and not evil. 2608 +# May you do good and not evil.
2610 +# May you find forgiveness for yourself and forgive others. 2609 +# May you find forgiveness for yourself and forgive others.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 + t TEXT, 2759 + t TEXT,
2761 + n INTEGER 2760 + n INTEGER
2762 + ); 2761 + );
2763 + } 2762 + }
2764 + execsql {SELECT t, n FROM interior2_recover WHERE (rowid%500)=0 ORDER BY rowi d} 2763 + execsql {SELECT t, n FROM interior2_recover WHERE (rowid%500)=0 ORDER BY rowi d}
2765 +} {{Interior-node-generating line 499} 499 {Interior-node-generating line 999} 999 {Interior-node-generating line 1499} 1499 {Interior-node-generating line 199 9} 1999 {Interior-node-generating line 2499} 2499 {Interior-node-generating line 2999} 2999 {Interior-node-generating line 3499} 3499 {Interior-node-generating line 3999} 3999 {Interior-node-generating line 4499} 4499 {Interior-node-generat ing line 4999} 4999} 2764 +} {{Interior-node-generating line 499} 499 {Interior-node-generating line 999} 999 {Interior-node-generating line 1499} 1499 {Interior-node-generating line 199 9} 1999 {Interior-node-generating line 2499} 2499 {Interior-node-generating line 2999} 2999 {Interior-node-generating line 3499} 3499 {Interior-node-generating line 3999} 3999 {Interior-node-generating line 4499} 4499 {Interior-node-generat ing line 4999} 4999}
2766 + 2765 +
2767 +finish_test 2766 +finish_test
2768 diff --git a/third_party/sqlite/src/test/recover0.test b/third_party/sqlite/src/ test/recover0.test 2767 diff --git a/third_party/sqlite/src/test/recover0.test b/third_party/sqlite/src/ test/recover0.test
2769 new file mode 100644 2768 new file mode 100644
2770 index 0000000..aac2ed9 2769 index 000000000000..aac2ed9164ba
2771 --- /dev/null 2770 --- /dev/null
2772 +++ b/third_party/sqlite/src/test/recover0.test 2771 +++ b/third_party/sqlite/src/test/recover0.test
2773 @@ -0,0 +1,532 @@ 2772 @@ -0,0 +1,532 @@
2774 +# 2012 January 4 {} 2773 +# 2012 January 4 {}
2775 +# 2774 +#
2776 +# The author disclaims copyright to this source code. In place of 2775 +# The author disclaims copyright to this source code. In place of
2777 +# a legal notice, here is a blessing: 2776 +# a legal notice, here is a blessing:
2778 +# 2777 +#
2779 +# May you do good and not evil. 2778 +# May you do good and not evil.
2780 +# May you find forgiveness for yourself and forgive others. 2779 +# May you find forgiveness for yourself and forgive others.
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
3298 + CREATE VIRTUAL TABLE temp.syntax USING recover( 3297 + CREATE VIRTUAL TABLE temp.syntax USING recover(
3299 + backing, 3298 + backing,
3300 + v INTEGER NOT NULL TEXT 3299 + v INTEGER NOT NULL TEXT
3301 + ); 3300 + );
3302 + } 3301 + }
3303 +} {1 {unable to parse column 0}} 3302 +} {1 {unable to parse column 0}}
3304 + 3303 +
3305 +finish_test 3304 +finish_test
3306 diff --git a/third_party/sqlite/src/test/recover1.test b/third_party/sqlite/src/ test/recover1.test 3305 diff --git a/third_party/sqlite/src/test/recover1.test b/third_party/sqlite/src/ test/recover1.test
3307 new file mode 100644 3306 new file mode 100644
3308 index 0000000..1d90f09 3307 index 000000000000..1d90f096b727
3309 --- /dev/null 3308 --- /dev/null
3310 +++ b/third_party/sqlite/src/test/recover1.test 3309 +++ b/third_party/sqlite/src/test/recover1.test
3311 @@ -0,0 +1,429 @@ 3310 @@ -0,0 +1,429 @@
3312 +# 2012 January 4 {} 3311 +# 2012 January 4 {}
3313 +# 3312 +#
3314 +# The author disclaims copyright to this source code. In place of 3313 +# The author disclaims copyright to this source code. In place of
3315 +# a legal notice, here is a blessing: 3314 +# a legal notice, here is a blessing:
3316 +# 3315 +#
3317 +# May you do good and not evil. 3316 +# May you do good and not evil.
3318 +# May you find forgiveness for yourself and forgive others. 3317 +# May you find forgiveness for yourself and forgive others.
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
3733 + e, 3732 + e,
3734 + v TEXT 3733 + v TEXT
3735 + ); 3734 + );
3736 + SELECT rowid, v FROM e_recover ORDER BY rowid; 3735 + SELECT rowid, v FROM e_recover ORDER BY rowid;
3737 + } 3736 + }
3738 +} {UTF-16be 1 Mjollnir 2 Mjölnir 3 Mjǫlnir 4 Mjölner 5 Mjølner 6 ハンマー} 3737 +} {UTF-16be 1 Mjollnir 2 Mjölnir 3 Mjǫlnir 4 Mjölner 5 Mjølner 6 ハンマー}
3739 + 3738 +
3740 +finish_test 3739 +finish_test
3741 diff --git a/third_party/sqlite/src/test/recover2.test b/third_party/sqlite/src/ test/recover2.test 3740 diff --git a/third_party/sqlite/src/test/recover2.test b/third_party/sqlite/src/ test/recover2.test
3742 new file mode 100644 3741 new file mode 100644
3743 index 0000000..8aa4e04 3742 index 000000000000..8aa4e049a010
3744 --- /dev/null 3743 --- /dev/null
3745 +++ b/third_party/sqlite/src/test/recover2.test 3744 +++ b/third_party/sqlite/src/test/recover2.test
3746 @@ -0,0 +1,157 @@ 3745 @@ -0,0 +1,157 @@
3747 +# 2012 January 4 {} 3746 +# 2012 January 4 {}
3748 +# 3747 +#
3749 +# The author disclaims copyright to this source code. In place of 3748 +# The author disclaims copyright to this source code. In place of
3750 +# a legal notice, here is a blessing: 3749 +# a legal notice, here is a blessing:
3751 +# 3750 +#
3752 +# May you do good and not evil. 3751 +# May you do good and not evil.
3753 +# May you find forgiveness for yourself and forgive others. 3752 +# May you find forgiveness for yourself and forgive others.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3895 + 3894 +
3896 + execsql { 3895 + execsql {
3897 + PRAGMA page_count; 3896 + PRAGMA page_count;
3898 + PRAGMA page_size; 3897 + PRAGMA page_size;
3899 + SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover; 3898 + SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover;
3900 + } 3899 + }
3901 +} [list 4 1024 1 text [string length $substr] $substr] 3900 +} [list 4 1024 1 text [string length $substr] $substr]
3902 + 3901 +
3903 +finish_test 3902 +finish_test
3904 -- 3903 --
3905 2.5.0 3904 2.11.0
3906 3905
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698