gitlab.com/CoiaPrant/sqlite3@v1.19.1/testdata/tcl/altercorrupt.test (about) 1 # 2019-01-11 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 6 # May you do good and not evil. 7 # May you find forgiveness for yourself and forgive others. 8 # May you share freely, never taking more than you give. 9 # 10 #*********************************************************************** 11 # 12 13 set testdir [file dirname $argv0] 14 source $testdir/tester.tcl 15 set testprefix altercorrupt 16 17 # If SQLITE_OMIT_ALTERTABLE is defined, omit this file. 18 ifcapable !altertable { 19 finish_test 20 return 21 } 22 23 database_may_be_corrupt 24 25 #-------------------------------------------------------------------------- 26 reset_db 27 do_test 1.0 { 28 sqlite3 db {} 29 db deserialize [decode_hexdb { 30 .open --hexdb 31 | size 24576 pagesize 4096 filename crash-685346d89b5e5f.db 32 | page 1 offset 0 33 | 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. 34 | 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06 .....@ ........ 35 | 32: 00 00 63 00 00 05 f0 00 00 00 00 04 10 00 00 04 ..c............. 36 | 48: 00 00 00 00 00 00 0f f0 00 00 00 01 00 00 00 00 ................ 37 | 64: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 38 | 96: 00 00 00 00 0d 0f f8 00 05 0e cf 00 0f 79 0f d3 .............y.. 39 | 112: 0f 2e 0e f3 0e cf 00 00 00 00 00 00 00 00 00 00 ................ 40 | 3776: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22 ................ 41 | 3792: 05 06 17 11 11 01 31 74 61 62 6c 65 74 34 74 34 ......1tablet4t4 42 | 3808: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 34 .CREATE TABLE t4 43 | 3824: 28 7a 29 39 04 06 17 11 11 01 5f 74 61 62 6c 65 (z)9......_table 44 | 3840: 74 33 74 33 05 43 52 45 41 54 45 20 54 41 42 4c t3t3.CREATE TABL 45 | 3856: 45 20 74 33 28 78 20 49 4e 54 45 47 45 52 20 50 E t3(x INTEGER P 46 | 3872: 52 49 4d 41 52 59 20 4b 45 59 2c 20 79 29 49 03 RIMARY KEY, y)I. 47 | 3888: 06 17 11 11 01 7f 74 61 62 6c 65 74 32 74 32 04 ......tablet2t2. 48 | 3904: 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 32 28 CREATE TABLE t2( 49 | 3920: 61 2c 62 2c 63 20 50 52 49 4d 41 52 59 20 4b 45 a,b,c PRIMARY KE 50 | 3936: 59 2c 20 64 2c 20 65 2c 20 66 29 20 57 49 54 48 Y, d, e, f) WITH 51 | 3952: 4f 55 54 20 52 4f 57 49 44 58 03 07 17 11 11 01 OUT ROWIDX...... 52 | 3968: 81 1b 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 ..tablet1t1.CREA 53 | 3984: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 2c TE TABLE t1(a,b, 54 | 4000: 63 20 41 53 20 28 2d 62 29 20 56 49 52 54 55 41 c AS (-b) VIRTUA 55 | 4016: 4c 2c 64 20 43 48 45 43 4b 28 64 3e 35 29 2c 65 L,d CHECK(d>5),e 56 | 4032: 20 55 4e 49 51 55 45 2c 20 66 20 41 53 20 28 2b UNIQUE, f AS (+ 57 | 4048: 62 29 29 23 02 06 17 37 11 01 00 69 6e 64 65 78 b))#...7...index 58 | 4064: 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 sqlite_autoindex 59 | 4080: 5f 74 31 5f 31 74 31 03 00 00 00 08 00 00 00 00 _t1_1t1......... 60 | page 2 offset 4096 61 | 0: 0d 00 00 00 0a 0f 93 00 0f f6 0f eb 0f e0 0f d5 ................ 62 | 16: 0f ca 0f 8f 0f b4 0f a9 0f 9e 0f 93 00 00 00 00 ................ 63 | 3984: 00 00 00 09 0a 05 01 01 01 01 0a 64 6e 14 09 09 ...........dn... 64 | 4000: 05 01 01 01 01 09 5a 6d 12 09 08 05 01 01 01 01 ......Zm........ 65 | 4016: 08 50 6c 10 09 07 05 01 01 01 01 07 46 6b 0e 09 .Pl.........Fk.. 66 | 4032: 06 05 01 01 01 01 06 3c 6a 0c 09 05 05 01 01 01 .......<j....... 67 | 4048: 01 05 32 69 0a 09 04 05 01 01 01 01 04 28 68 08 ..2i.........(h. 68 | 4064: 09 03 05 01 01 01 01 03 1e 67 06 09 02 05 01 01 .........g...... 69 | 4080: 01 01 02 14 66 04 08 01 05 09 01 01 01 0a 65 02 ....f.........e. 70 | page 3 offset 8192 71 | 0: 0a 00 00 00 0a 0f c5 00 0f fb 0f f5 0f ef 0f e9 ................ 72 | 16: 0f e3 0f dd 0f d7 0f d1 0f cb 0f c5 00 00 00 00 ................ 73 | 4032: 00 00 00 00 00 05 03 01 01 14 0a 05 03 01 01 12 ................ 74 | 4048: 09 05 03 01 01 10 08 05 03 01 01 0e 07 05 03 01 ................ 75 | 4064: 01 0c 06 05 03 01 01 0a 05 05 03 01 01 08 04 05 ................ 76 | 4080: 03 01 01 06 03 05 03 01 01 04 02 04 03 01 09 02 ................ 77 | page 4 offset 12288 78 | 0: 0a 00 00 00 0a 0f 75 00 0f 75 0f 83 0f 91 0f 9f ......u..u...... 79 | 16: 0f ad 0f bb 0f 00 00 00 00 00 00 00 00 00 00 00 ................ 80 | 3952: 00 00 00 00 00 0d 07 01 01 01 01 01 01 9c 0a 64 ...............d 81 | 3968: 6e 14 64 0d 07 02 01 01 01 01 01 a6 09 5a 6d 12 n.d..........Zm. 82 | 3984: 5a 0d 07 01 01 01 01 01 01 b0 08 50 6c 10 50 0d Z..........Pl.P. 83 | 4000: 07 01 01 01 01 01 01 ba 07 46 6b 0e 46 0d 07 01 .........Fk.F... 84 | 4016: 01 01 01 01 01 c4 06 3c 6a 0c 3c 0d 07 01 01 01 .......<j.<..... 85 | 4032: 01 01 01 ce 05 32 69 0a 32 0d 07 01 01 01 01 01 .....2i.2....... 86 | 4048: 01 d8 04 28 68 08 28 0d 07 01 01 01 01 01 01 e2 ...(h.(......... 87 | 4064: 03 1e 67 06 1e 0d 07 01 01 01 01 01 01 ec 02 14 ..g............. 88 | 4080: 66 04 14 0c 07 01 09 01 01 01 01 f6 0a 65 02 0a f............e.. 89 | page 5 offset 16384 90 | 0: 0d 00 00 00 03 0f e9 00 0f e9 0f fb 0f f6 00 00 ................ 91 | 16: 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 92 | 4064: 00 00 00 00 00 00 00 00 00 03 ff ff ff ff ff ff ................ 93 | 4080: ff ff 9c 03 00 00 03 64 03 00 00 03 01 03 00 00 .......d........ 94 | page 6 offset 20480 95 | 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................ 96 | end crash-685346d89b5e5f.db 97 }]} {} 98 99 do_catchsql_test 1.1 { 100 ALTER TABLE t2 DROP COLUMN e; 101 ALTER TABLE t1 DROP COLUMN f; 102 } {1 {database disk image is malformed}} 103 104 105 #-------------------------------------------------------------------------- 106 reset_db 107 do_test 2.0 { 108 sqlite3 db {} 109 db deserialize [decode_hexdb { 110 .open --hexdb 111 | size 24576 pagesize 4096 filename crash-0572db8f391431.db 112 | page 1 offset 0 113 | 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. 114 | 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06 .....@ ........ 115 | 32: 00 00 63 00 10 05 f0 00 00 00 00 04 10 00 00 04 ..c............. 116 | 48: 00 00 00 00 00 00 0f f0 00 00 00 00 00 00 00 00 ................ 117 | 96: 00 00 00 00 0d 0f f8 00 05 0e cf 00 0f 79 0f d3 .............y.. 118 | 112: 0f 2e 0e f3 0e cf 00 00 00 00 00 00 00 00 00 00 ................ 119 | 3776: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22 ................ 120 | 3792: 05 06 17 11 11 01 31 74 61 62 6c 65 74 34 74 34 ......1tablet4t4 121 | 3808: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 34 .CREATE TABLE t4 122 | 3824: 28 7a 29 39 04 06 17 11 11 01 5f 74 61 62 6c 65 (z)9......_table 123 | 3840: 74 33 74 33 05 43 52 45 41 54 45 20 54 41 42 4c t3t3.CREATE TABL 124 | 3856: 45 20 74 33 28 78 20 49 4e 54 55 47 45 52 20 50 E t3(x INTUGER P 125 | 3872: 52 49 4d 41 52 59 20 4b 45 59 2c 20 79 29 49 03 RIMARY KEY, y)I. 126 | 3888: 06 17 11 11 01 7f 74 61 62 6c 65 74 32 74 32 04 ......tablet2t2. 127 | 3904: 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 32 28 CREATE TABLE t2( 128 | 3920: 61 2c 62 2c 63 20 50 52 49 4d 41 52 59 20 4b 45 a,b,c PRIMARY KE 129 | 3936: 59 2c 20 64 2c 20 65 2c 20 66 29 20 57 49 54 48 Y, d, e, f) WITH 130 | 3952: 4f 55 54 20 52 4f 57 49 44 58 05 07 17 11 11 01 OUT ROWIDX...... 131 | 3968: 81 1b 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 ..tablet1t1.CREA 132 | 3984: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 2c TE TABLE t1(a,b, 133 | 4000: 63 20 41 53 20 28 2d 62 29 20 56 49 52 54 55 41 c AS (-b) VIRTUA 134 | 4016: 4c 2c 64 20 43 48 45 43 4b 28 64 3e 35 29 2c 65 L,d CHECK(d>5),e 135 | 4032: 20 55 4e 49 51 55 45 2c 20 66 20 41 53 20 28 2b UNIQUE, f AS (+ 136 | 4048: 62 29 29 23 02 06 17 37 11 01 00 69 6e 64 65 78 b))#...7...index 137 | 4064: 73 71 6c 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 sqlite_autoindex 138 | 4080: 5f 74 31 5f 31 84 31 03 01 00 00 08 00 00 00 00 _t1_1.1......... 139 | page 2 offset 4096 140 | 0: 0d 00 00 00 0a 0f 93 00 0f f6 0f eb 0f e0 0f d5 ................ 141 | 16: 0f ca 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 142 | 3984: 00 00 00 09 0a 05 01 01 01 01 0a 64 6e 14 09 09 ...........dn... 143 | 4000: 05 01 01 01 01 09 5a 6d 12 09 08 05 01 00 f1 01 ......Zm........ 144 | 4016: 08 50 6c 10 09 07 05 01 01 01 01 07 46 6b 0e 09 .Pl.........Fk.. 145 | 4032: 06 05 01 00 f1 01 06 3c 6a 0c 09 05 05 01 01 01 .......<j....... 146 | 4048: 01 05 32 69 0a 09 04 05 01 01 01 01 04 28 68 08 ..2i.........(h. 147 | 4064: 57 03 05 01 01 01 01 03 1e 67 06 09 02 05 01 01 W........g...... 148 | 4080: 01 01 02 14 66 04 08 01 05 09 01 01 01 0a 65 02 ....f.........e. 149 | page 3 offset 8192 150 | 0: 09 ff ff ff fa 0f c5 00 0f fb 0f f5 0f ef 0f e9 ................ 151 | 16: 0f e3 0f dd 0f d7 00 00 00 00 00 00 00 00 00 00 ................ 152 | 4032: 00 00 00 00 00 05 03 01 01 14 0a 05 03 01 01 12 ................ 153 | 4048: 09 05 03 01 01 10 08 05 03 01 01 0e 07 05 03 01 ................ 154 | 4064: 01 0c 06 05 03 01 01 0a 05 05 03 01 01 08 04 05 ................ 155 | 4080: 03 01 01 06 03 05 03 01 01 04 02 04 03 01 09 02 ................ 156 | page 4 offset 12288 157 | 0: 0a 00 00 00 0a 0f 75 00 0f 75 0f 83 0f 91 0f 9f ......u..u...... 158 | 16: 0f ad 0f bb 0f 00 00 00 00 00 01 00 00 00 00 00 ................ 159 | 3952: 00 00 00 00 00 0d 07 01 01 01 01 01 01 9c 0a 64 ...............d 160 | 3968: 6e 14 64 0d 07 02 01 01 01 01 01 a6 09 5a 6d 12 n.d..........Zm. 161 | 3984: 5a 0d 07 01 01 01 01 d4 01 b0 08 50 6c 10 50 0d Z..........Pl.P. 162 | 4000: 07 01 01 01 01 01 01 ba 07 46 6b 0e 46 0d 07 00 .........Fk.F... 163 | 4016: 01 01 01 01 01 c4 06 3c 6a 0c 3c 0d 07 01 01 01 .......<j.<..... 164 | 4032: 01 01 01 ce 05 32 69 0a 32 0d 07 01 01 01 01 01 .....2i.2....... 165 | 4048: 01 d8 04 28 68 08 28 0d 07 01 01 01 01 01 01 e2 ...(h.(......... 166 | 4064: 03 1e 67 06 1e 0d 07 01 01 01 01 01 01 ec 02 14 ..g............. 167 | 4080: 66 04 14 0c 07 01 09 01 01 00 f1 f6 0a 65 02 0a f............e.. 168 | page 5 offset 16384 169 | 0: 0d 00 00 00 03 0f e9 00 0f e9 0f fb 0f f6 00 00 ................ 170 | 4064: 00 00 00 00 00 00 00 00 00 03 ff ff ff ff ff ff ................ 171 | 4080: ff ff 9c 03 00 00 03 64 03 00 01 03 01 03 00 00 .......d........ 172 | page 6 offset 20480 173 | 0: 0d 00 10 00 00 10 01 00 00 00 00 00 00 00 00 00 ................ 174 | end crash-0572db8f391431.db 175 }]} {} 176 177 do_catchsql_test 2.1 { 178 ALTER TABLE t1 DROP COLUMN a; 179 } {1 {database disk image is malformed}} 180 181 finish_test