u8 *pData,
sqlite3_int64 nData
){
- if( eType>=0 && dbdataValueBytes(eType)<=nData ){
- switch( eType ){
- case 0:
- case 10:
- case 11:
- sqlite3_result_null(pCtx);
- break;
-
- case 8:
- sqlite3_result_int(pCtx, 0);
- break;
- case 9:
- sqlite3_result_int(pCtx, 1);
- break;
-
- case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
- sqlite3_uint64 v = (signed char)pData[0];
- pData++;
- switch( eType ){
- case 7:
- case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
- case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
- case 4: v = (v<<8) + pData[0]; pData++;
- case 3: v = (v<<8) + pData[0]; pData++;
- case 2: v = (v<<8) + pData[0]; pData++;
- }
-
- if( eType==7 ){
- double r;
- memcpy(&r, &v, sizeof(r));
- sqlite3_result_double(pCtx, r);
- }else{
- sqlite3_result_int64(pCtx, (sqlite3_int64)v);
+ if( eType>=0 ){
+ if( dbdataValueBytes(eType)<=nData ){
+ switch( eType ){
+ case 0:
+ case 10:
+ case 11:
+ sqlite3_result_null(pCtx);
+ break;
+
+ case 8:
+ sqlite3_result_int(pCtx, 0);
+ break;
+ case 9:
+ sqlite3_result_int(pCtx, 1);
+ break;
+
+ case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
+ sqlite3_uint64 v = (signed char)pData[0];
+ pData++;
+ switch( eType ){
+ case 7:
+ case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
+ case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
+ case 4: v = (v<<8) + pData[0]; pData++;
+ case 3: v = (v<<8) + pData[0]; pData++;
+ case 2: v = (v<<8) + pData[0]; pData++;
+ }
+
+ if( eType==7 ){
+ double r;
+ memcpy(&r, &v, sizeof(r));
+ sqlite3_result_double(pCtx, r);
+ }else{
+ sqlite3_result_int64(pCtx, (sqlite3_int64)v);
+ }
+ break;
}
- break;
- }
-
- default: {
- int n = ((eType-12) / 2);
- if( eType % 2 ){
- switch( enc ){
-#ifndef SQLITE_OMIT_UTF16
- case SQLITE_UTF16BE:
- sqlite3_result_text16be(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
- break;
- case SQLITE_UTF16LE:
- sqlite3_result_text16le(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
- break;
-#endif
- default:
- sqlite3_result_text(pCtx, (char*)pData, n, SQLITE_TRANSIENT);
- break;
+
+ default: {
+ int n = ((eType-12) / 2);
+ if( eType % 2 ){
+ switch( enc ){
+ #ifndef SQLITE_OMIT_UTF16
+ case SQLITE_UTF16BE:
+ sqlite3_result_text16be(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
+ break;
+ case SQLITE_UTF16LE:
+ sqlite3_result_text16le(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
+ break;
+ #endif
+ default:
+ sqlite3_result_text(pCtx, (char*)pData, n, SQLITE_TRANSIENT);
+ break;
+ }
+ }else{
+ sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT);
}
- }else{
- sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT);
}
}
+ }else{
+ if( eType==7 ){
+ sqlite3_result_double(pCtx, 0.0);
+ }else if( eType<7 ){
+ sqlite3_result_int(pCtx, 0);
+ }else if( eType%2 ){
+ sqlite3_result_text(pCtx, "", 0, SQLITE_STATIC);
+ }else{
+ sqlite3_result_blob(pCtx, "", 0, SQLITE_STATIC);
+ }
}
}
}
DELETE FROM sqlite_schema WHERE name='t1';
}
- proc my_sql_hook {sql} {
+ proc my_sql_hook2 {sql} {
if {[string match "INSERT INTO lostandfound*" $sql]} {
lappend ::script $sql
}
}
do_test 18.$enc.2 {
set ::script [list]
- set R [sqlite3_recover_init_sql db main my_sql_hook]
+ set R [sqlite3_recover_init_sql db main my_sql_hook2]
$R config lostandfound lostandfound
$R run
$R finish
} {{INSERT INTO lostandfound VALUES(2, 2, 2, 1, 'abc', 'def')}}
}
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 19.0 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO t1 VALUES(1, 'one');
+ INSERT INTO t1 VALUES(2, 'two');
+
+ ALTER TABLE t1 ADD COLUMN c NOT NULL DEFAULT 13;
+ INSERT INTO t1 VALUES(3, 'three', 'hello world');
+}
+do_recover_test 19.1
--- /dev/null
+# 2024 May 15
+#
+# 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.
+#
+#***********************************************************************
+#
+
+source [file join [file dirname [info script]] recover_common.tcl]
+set testprefix recovercorrupt4
+
+database_may_be_corrupt
+
+do_execsql_test 1.0 {
+ CREATE TABLE rows(indexed INTEGER NOT NULL, unindexed INTEGER NOT NULL, filler BLOB NOT NULL DEFAULT 13);
+ -- CREATE UNIQUE INDEX rows_index ON rows(indexed);
+ INSERT INTO rows(indexed, unindexed, filler) VALUES(1, 1, x'31');
+ INSERT INTO rows(indexed, unindexed, filler) VALUES(2, 2, x'32');
+ INSERT INTO rows(indexed, unindexed, filler) VALUES(4, 4, x'34');
+ INSERT INTO rows(indexed, unindexed, filler) VALUES(8, 8, randomblob(2048));
+}
+
+db close
+
+do_test 1.1 {
+ set sz [expr [file size test.db] - 1024]
+ set fd [open test.db]
+ fconfigure $fd -encoding binary -translation binary
+
+ set data [read $fd $sz]
+ set fd2 [open test.db2 w]
+ fconfigure $fd2 -encoding binary -translation binary
+ puts -nonewline $fd2 $data
+ close $fd2
+ set {} {}
+} {}
+
+do_test 1.2 {
+ forcedelete test.db3
+ sqlite3 db test.db2
+ set R [sqlite3_recover_init db main test.db3]
+ $R run
+ $R finish
+} {}
+
+do_test 1.3 {
+ sqlite3 db test.db3
+ execsql {
+ SELECT indexed, unindexed FROM rows
+ }
+} {1 1 2 2 4 4 8 8}
+
+finish_test
+
-C Reformulate\sa\sfor-in\sloop\sto\sa\sfor\sloop\sin\swasm.xWrap()\sto\swork\saround\sdownstream\sframeworks\smodifying\sthe\sJS\sArray\sprototype,\sas\sreported\sin\s[forum:b549992634b55104|forum\spost\sb549992634b55104].
-D 2024-05-09T18:54:05.532
+C If\sthere\sis\sno\sdata\savailable\sfor\sa\sfield\sin\sa\scorrupted\srecord,\sbut\sthe\stype\sis\savailable,\shave\sthe\srecovery\sextension\ssubstitute\s0,\s0.0,\s''\sor\sX''\sinstead\sof\sa\sNULL\svalue.
+D 2024-05-15T15:11:51.599
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/rbu/sqlite3rbu.c d4ddf8f0e93772556e452a6c2814063cf47efb760a0834391a9d0cd9859fa4b9
F ext/rbu/sqlite3rbu.h 9d923eb135c5d04aa6afd7c39ca47b0d1d0707c100e02f19fdde6a494e414304
F ext/rbu/test_rbu.c ee6ede75147bc081fe9bc3931e6b206277418d14d3fbceea6fdc6216d9b47055
-F ext/recover/dbdata.c e518c1a221a259a1ea594d9db8fce356861bfa450e6f54eda999242b9bd5c50a
-F ext/recover/recover1.test c484d01502239f11b61f23c1cee9f5dd19fa17617f8974e42e74d64639c524cf
+F ext/recover/dbdata.c 0a943861ec096de375097e0aaff07b480a002eab9b01fecd3f9e828faf4ef624
+F ext/recover/recover1.test e16d78e94183562abff569967b18b7c77451d7044365516cd0fe14713a284851
F ext/recover/recover_common.tcl a61306c1eb45c0c3fc45652c35b2d4ec19729e340bdf65a272ce4c229cefd85a
F ext/recover/recoverbuild.test c74170e0f7b02456af41838afeb5353fdb985a48cc2331d661bbabbca7c6b8e3
F ext/recover/recoverclobber.test 3ba6c0c373c5c63d17e82eced64c05c57ccaf26c1abe1ca7141334022a79f32e
F ext/recover/recovercorrupt.test 64c081ad1200ae77b447da99eb724785d6bf71715f394543dc7689642e92bf49
F ext/recover/recovercorrupt2.test 1418f1710debc24ff38276cedfcea234beb37a34205708e7e3e6d76cc4a979db
F ext/recover/recovercorrupt3.test 2e7b9a1b528ca23ed382cec6f64e3fcbbd0f8e852add7562397fd8df83f335d5
+F ext/recover/recovercorrupt4.test 8990c3a76da616b938e800cd2b40eb1f7adf9352624966ba0af0303c7a015f00
F ext/recover/recoverfault.test 9d9f88eeb222615a25e7514f234c950d46bee20d24cd8db49d8fff8d650dcfe1
F ext/recover/recoverfault2.test 730e7371bcda769554d15460cb23126abba1be8eca9539ccabf63623e7bb7e09
F ext/recover/recoverold.test 68db3d6f85dd2b98e785b6c4da4f5eea4bbe52ccf6674d9a94c7506dc92596aa
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P bc394acb6e6bcaccd17d8afe559d743799c0cb8d7aec709306181673a35dcb86
-Q +857f5d7fadce1cfe30b3468826f403f736cfecacb1eb6d3b858b01ea3cfd6ffc
-Q +dc58ed654928574ef254af289bd21c654c587aac80aea36ab96772c35d4ca754
-R 3a7c1263734f65e3c8fd8f8afd4c271c
-U stephan
-Z 41872c5ab92e2de07cd7488f196ff91a
+P ce2eb6d89a75204ef3e1f74f763d297108525533bea404f7c0dbaffe834144f6
+Q +8eb326c24981647e2df90e4b9d75db52a552bd997bd821f5898c7ff3fb93a57d
+R c150a8a659f8eefc2c9eb88300491b31
+U dan
+Z 22cd71cc730c21513bc182c1a3b5a225
# Remove this line to create a well-formed Fossil manifest.
-ce2eb6d89a75204ef3e1f74f763d297108525533bea404f7c0dbaffe834144f6
\ No newline at end of file
+78051359256c7e56a0aad5706bacbad5447b25ebef8088a6194886728d6deab4
\ No newline at end of file