From de30fb5fc2a9832f1f7954779347efef1504acf5 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 3 Sep 2024 18:55:38 +0000 Subject: [PATCH 01/77] Store the values of any UNINDEXED columns of a contentless fts5 table persistently in the database. Warning: This currently creates a (technically) incompatible file-format for contentless fts5 tables that have UNINDEXED columns. FossilOrigin-Name: dcacb1a8ef359b4507b4733356d3150ba5dc105cc9867c103d16a0908a1a9f64 --- ext/fts5/fts5Int.h | 7 +- ext/fts5/fts5_config.c | 22 +++- ext/fts5/fts5_main.c | 4 +- ext/fts5/fts5_storage.c | 104 +++++++++++------- ext/fts5/test/fts5unindexed2.test | 176 ++++++++++++++++++++++++++++++ manifest | 24 ++-- manifest.uuid | 2 +- 7 files changed, 279 insertions(+), 60 deletions(-) create mode 100644 ext/fts5/test/fts5unindexed2.test diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 7e41119572..552f065837 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -262,9 +262,10 @@ struct Fts5Config { #define FTS5_CURRENT_VERSION 4 #define FTS5_CURRENT_VERSION_SECUREDELETE 5 -#define FTS5_CONTENT_NORMAL 0 -#define FTS5_CONTENT_NONE 1 -#define FTS5_CONTENT_EXTERNAL 2 +#define FTS5_CONTENT_NORMAL 0 +#define FTS5_CONTENT_NONE 1 +#define FTS5_CONTENT_EXTERNAL 2 +#define FTS5_CONTENT_UNINDEXED 3 #define FTS5_DETAIL_FULL 0 #define FTS5_DETAIL_NONE 1 diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index 3cb1bd3bea..8f4e57b4b8 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -477,7 +477,8 @@ static int fts5ConfigParseColumn( Fts5Config *p, char *zCol, char *zArg, - char **pzErr + char **pzErr, + int *pbUnindexed ){ int rc = SQLITE_OK; if( 0==sqlite3_stricmp(zCol, FTS5_RANK_NAME) @@ -488,6 +489,7 @@ static int fts5ConfigParseColumn( }else if( zArg ){ if( 0==sqlite3_stricmp(zArg, "unindexed") ){ p->abUnindexed[p->nCol] = 1; + *pbUnindexed = 1; }else{ *pzErr = sqlite3_mprintf("unrecognized column option: %s", zArg); rc = SQLITE_ERROR; @@ -508,11 +510,17 @@ static int fts5ConfigMakeExprlist(Fts5Config *p){ sqlite3Fts5BufferAppendPrintf(&rc, &buf, "T.%Q", p->zContentRowid); if( p->eContent!=FTS5_CONTENT_NONE ){ + assert( p->eContent==FTS5_CONTENT_EXTERNAL + || p->eContent==FTS5_CONTENT_NORMAL + || p->eContent==FTS5_CONTENT_UNINDEXED + ); for(i=0; inCol; i++){ if( p->eContent==FTS5_CONTENT_EXTERNAL ){ sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.%Q", p->azCol[i]); - }else{ + }else if( p->eContent==FTS5_CONTENT_NORMAL || p->abUnindexed[i] ){ sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.c%d", i); + }else{ + sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", NULL"); } } } @@ -546,6 +554,7 @@ int sqlite3Fts5ConfigParse( Fts5Config *pRet; /* New object to return */ int i; sqlite3_int64 nByte; + int bUnindexed = 0; /* True if there are one or more UNINDEXED */ *ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config)); if( pRet==0 ) return SQLITE_NOMEM; @@ -605,7 +614,7 @@ int sqlite3Fts5ConfigParse( pzErr ); }else{ - rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr); + rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr, &bUnindexed); zOne = 0; } } @@ -640,11 +649,14 @@ int sqlite3Fts5ConfigParse( /* If no zContent option was specified, fill in the default values. */ if( rc==SQLITE_OK && pRet->zContent==0 ){ const char *zTail = 0; - assert( pRet->eContent==FTS5_CONTENT_NORMAL - || pRet->eContent==FTS5_CONTENT_NONE + assert( pRet->eContent==FTS5_CONTENT_NORMAL + || pRet->eContent==FTS5_CONTENT_NONE ); if( pRet->eContent==FTS5_CONTENT_NORMAL ){ zTail = "content"; + }else if( bUnindexed ){ + pRet->eContent = FTS5_CONTENT_UNINDEXED; + zTail = "content"; }else if( pRet->bColumnsize ){ zTail = "docsize"; } diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 03c1bb83fa..c5ff2fad75 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1778,7 +1778,9 @@ static int fts5SpecialInsert( } bLoadConfig = 1; }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){ - if( pConfig->eContent==FTS5_CONTENT_NONE ){ + if( pConfig->eContent==FTS5_CONTENT_NONE + || pConfig->eContent==FTS5_CONTENT_UNINDEXED + ){ fts5SetVtabError(pTab, "'rebuild' may not be used with a contentless fts5 table" ); diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index cf25eb361e..e2c47c0072 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -144,19 +144,21 @@ static int fts5StorageGetStmt( case FTS5_STMT_INSERT_CONTENT: case FTS5_STMT_REPLACE_CONTENT: { int nCol = pC->nCol + 1; - char *zBind; + char *zBind = 0; int i; - zBind = sqlite3_malloc64(1 + nCol*2); - if( zBind ){ - for(i=0; ieContent==FTS5_CONTENT_NORMAL + || pC->eContent==FTS5_CONTENT_UNINDEXED + ); + + for(i=0; rc==SQLITE_OK && ieContent==FTS5_CONTENT_NORMAL || pC->abUnindexed[i-1] ){ + zBind = sqlite3Fts5Mprintf(&rc, "%z%s?%d", zBind, zBind?",":"",i+1); } - zBind[i*2-1] = '\0'; - zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName, zBind); - sqlite3_free(zBind); } + + zSql = sqlite3Fts5Mprintf(&rc, azStmt[eStmt], pC->zDb, pC->zName,zBind); + sqlite3_free(zBind); break; } @@ -342,7 +344,9 @@ int sqlite3Fts5StorageOpen( p->pIndex = pIndex; if( bCreate ){ - if( pConfig->eContent==FTS5_CONTENT_NORMAL ){ + if( pConfig->eContent==FTS5_CONTENT_NORMAL + || pConfig->eContent==FTS5_CONTENT_UNINDEXED + ){ int nDefn = 32 + pConfig->nCol*10; char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 10); if( zDefn==0 ){ @@ -353,8 +357,12 @@ int sqlite3Fts5StorageOpen( sqlite3_snprintf(nDefn, zDefn, "id INTEGER PRIMARY KEY"); iOff = (int)strlen(zDefn); for(i=0; inCol; i++){ - sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], ", c%d", i); - iOff += (int)strlen(&zDefn[iOff]); + if( pConfig->eContent==FTS5_CONTENT_NORMAL + || pConfig->abUnindexed[i] + ){ + sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], ", c%d", i); + iOff += (int)strlen(&zDefn[iOff]); + } } rc = sqlite3Fts5CreateTable(pConfig, "content", zDefn, 0, pzErr); } @@ -574,7 +582,9 @@ static int fts5StorageContentlessDelete(Fts5Storage *p, i64 iDel){ int rc = SQLITE_OK; assert( p->pConfig->bContentlessDelete ); - assert( p->pConfig->eContent==FTS5_CONTENT_NONE ); + assert( p->pConfig->eContent==FTS5_CONTENT_NONE + || p->pConfig->eContent==FTS5_CONTENT_UNINDEXED + ); /* Look up the origin of the document in the %_docsize table. Store ** this in stack variable iOrigin. */ @@ -714,7 +724,9 @@ int sqlite3Fts5StorageDelete( } /* Delete the %_content record */ - if( pConfig->eContent==FTS5_CONTENT_NORMAL ){ + if( pConfig->eContent==FTS5_CONTENT_NORMAL + || pConfig->eContent==FTS5_CONTENT_UNINDEXED + ){ if( rc==SQLITE_OK ){ rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_CONTENT, &pDel, 0); } @@ -746,8 +758,13 @@ int sqlite3Fts5StorageDeleteAll(Fts5Storage *p){ ); if( rc==SQLITE_OK && pConfig->bColumnsize ){ rc = fts5ExecPrintf(pConfig->db, 0, - "DELETE FROM %Q.'%q_docsize';", - pConfig->zDb, pConfig->zName + "DELETE FROM %Q.'%q_docsize';", pConfig->zDb, pConfig->zName + ); + } + + if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_UNINDEXED ){ + rc = fts5ExecPrintf(pConfig->db, 0, + "DELETE FROM %Q.'%q_content';", pConfig->zDb, pConfig->zName ); } @@ -875,7 +892,9 @@ int sqlite3Fts5StorageContentInsert( int rc = SQLITE_OK; /* Insert the new row into the %_content table. */ - if( pConfig->eContent!=FTS5_CONTENT_NORMAL ){ + if( pConfig->eContent!=FTS5_CONTENT_NORMAL + && pConfig->eContent!=FTS5_CONTENT_UNINDEXED + ){ if( sqlite3_value_type(apVal[1])==SQLITE_INTEGER ){ *piRowid = sqlite3_value_int64(apVal[1]); }else{ @@ -886,31 +905,36 @@ int sqlite3Fts5StorageContentInsert( int i; /* Counter variable */ rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT, &pInsert, 0); for(i=1; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){ - sqlite3_value *pVal = apVal[i]; - if( sqlite3_value_nochange(pVal) && p->pSavedRow ){ - /* This is an UPDATE statement, and column (i-2) was not modified. - ** Retrieve the value from Fts5Storage.pSavedRow instead. */ - pVal = sqlite3_column_value(p->pSavedRow, i-1); - }else if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE ){ - assert( pConfig->bLocale ); - assert( i>1 ); - if( pConfig->abUnindexed[i-2] ){ - /* At attempt to insert an fts5_locale() value into an UNINDEXED - ** column. Strip the locale away and just bind the text. */ - const char *pText = 0; - int nText = 0; - rc = sqlite3Fts5ExtractText(pConfig, pVal, 0, 0, &pText, &nText); - sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT); - }else{ - const u8 *pBlob = (const u8*)sqlite3_value_blob(pVal); - int nBlob = sqlite3_value_bytes(pVal); - assert( nBlob>4 ); - sqlite3_bind_blob(pInsert, i, pBlob+4, nBlob-4, SQLITE_TRANSIENT); + if( i==1 + || pConfig->eContent==FTS5_CONTENT_NORMAL + || pConfig->abUnindexed[i-2] + ){ + sqlite3_value *pVal = apVal[i]; + if( sqlite3_value_nochange(pVal) && p->pSavedRow ){ + /* This is an UPDATE statement, and column (i-2) was not modified. + ** Retrieve the value from Fts5Storage.pSavedRow instead. */ + pVal = sqlite3_column_value(p->pSavedRow, i-1); + }else if( sqlite3_value_subtype(pVal)==FTS5_LOCALE_SUBTYPE ){ + assert( pConfig->bLocale ); + assert( i>1 ); + if( pConfig->abUnindexed[i-2] ){ + /* At attempt to insert an fts5_locale() value into an UNINDEXED + ** column. Strip the locale away and just bind the text. */ + const char *pText = 0; + int nText = 0; + rc = sqlite3Fts5ExtractText(pConfig, pVal, 0, 0, &pText, &nText); + sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT); + }else{ + const u8 *pBlob = (const u8*)sqlite3_value_blob(pVal); + int nBlob = sqlite3_value_bytes(pVal); + assert( nBlob>4 ); + sqlite3_bind_blob(pInsert, i, pBlob+4, nBlob-4, SQLITE_TRANSIENT); + } + continue; } - continue; + + rc = sqlite3_bind_value(pInsert, i, pVal); } - - rc = sqlite3_bind_value(pInsert, i, pVal); } if( rc==SQLITE_OK ){ sqlite3_step(pInsert); diff --git a/ext/fts5/test/fts5unindexed2.test b/ext/fts5/test/fts5unindexed2.test new file mode 100644 index 0000000000..3f71fa7a93 --- /dev/null +++ b/ext/fts5/test/fts5unindexed2.test @@ -0,0 +1,176 @@ +# 2015 Apr 24 +# +# 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. +# +#*********************************************************************** +# +# The tests in this file focus on "unindexed" columns in contentless +# tables. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5unindexed2 + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + + +do_execsql_test 1.1 { + CREATE VIRTUAL TABLE t1 USING fts5(a, b UNINDEXED, content=); +} {} + +do_execsql_test 1.2 { + INSERT INTO t1 VALUES('abc def', 'ghi jkl'); +} + +do_execsql_test 1.3 { + SELECT rowid, a, b FROM t1 +} {1 {} {ghi jkl}} + +do_execsql_test 1.4 { + INSERT INTO t1(rowid, a, b) VALUES(11, 'hello world', 'one two three'); +} + +do_execsql_test 1.5 { + INSERT INTO t1(t1, rowid, a, b) VALUES('delete', 1, 'abc def', 'ghi jkl'); +} + +do_execsql_test 1.6 { + SELECT rowid, a, b FROM t1 +} { + 11 {} {one two three} +} + +do_execsql_test 1.7 { + PRAGMA integrity_check +} {ok} + +do_execsql_test 1.8 { + INSERT INTO t1(rowid, a, b) VALUES(12, 'abc def', 'ghi jkl'); +} + +do_execsql_test 1.9 { + SELECT rowid, a, b FROM t1('def') +} {12 {} {ghi jkl}} + +do_execsql_test 1.10 { + SELECT rowid, a, b FROM t1('def OR hello') ORDER BY rank +} {11 {} {one two three} 12 {} {ghi jkl}} + +do_execsql_test 1.11 { + SELECT rowid, a, b FROM t1 WHERE rowid=11 +} {11 {} {one two three}} + +do_execsql_test 1.12 { + SELECT rowid, a, b FROM t1 +} {11 {} {one two three} 12 {} {ghi jkl}} + + +fts5_aux_test_functions db +do_execsql_test 1.12.2 { + SELECT rowid, fts5_test_columntext(t1) FROM t1('def OR hello') +} {11 {{} {one two three}} 12 {{} {ghi jkl}}} + +do_execsql_test 1.13 { + INSERT INTO t1(t1) VALUES('delete-all'); +} + +do_execsql_test 1.14 { + SELECT rowid, a, b FROM t1 +} + +do_execsql_test 1.15 { + PRAGMA integrity_check +} {ok} + +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE t4 USING fts5( + x, y UNINDEXED, z, columnsize=0, content='' + ); +} + +do_execsql_test 2.1 { + INSERT INTO t4(rowid, x, y, z) VALUES(1, 'a a', 'b b b', 'c'); +} + +#------------------------------------------------------------------------- +reset_db + +do_execsql_test 3.0 { + CREATE VIRTUAL TABLE x1 USING fts5( + a UNINDEXED, b, c UNINDEXED, d, content=, contentless_delete=1 + ); +} + +do_execsql_test 3.1 { + INSERT INTO x1(rowid, a, b, c, d) VALUES(131, 'aaa', 'bbb', 'ccc', 'ddd'); +} + +do_execsql_test 3.2 { + SELECT * FROM x1 +} {aaa {} ccc {}} + +do_execsql_test 3.3 { + INSERT INTO x1(rowid, a, b, c, d) VALUES(1000, 'AAA', 'BBB', 'CCC', 'DDD'); +} + +do_execsql_test 3.4 { + SELECT rowid, * FROM x1 +} { + 131 aaa {} ccc {} + 1000 AAA {} CCC {} +} + +do_execsql_test 3.5 { + DELETE FROM x1 WHERE rowid=131; + SELECT rowid, * FROM x1 +} { + 1000 AAA {} CCC {} +} + +do_execsql_test 3.6 { + INSERT INTO x1(rowid, a, b, c, d) VALUES(112, 'aaa', 'bbb', 'ccc', 'ddd'); + SELECT rowid, * FROM x1 +} { + 112 aaa {} ccc {} + 1000 AAA {} CCC {} +} + +do_execsql_test 3.7 { + UPDATE x1 SET b='hello', d='world', rowid=1120 WHERE rowid=112 +} + +do_execsql_test 3.8 { + SELECT rowid, * FROM x1 +} { + 1000 AAA {} CCC {} + 1120 aaa {} ccc {} +} + +do_execsql_test 3.9 { + SELECT rowid, * FROM x1('hello'); +} { + 1120 aaa {} ccc {} +} + +do_execsql_test 3.9 { + SELECT rowid, * FROM x1('bbb'); +} { + 1000 AAA {} CCC {} +} + +fts5_aux_test_functions db +do_execsql_test 3.10 { + SELECT rowid, fts5_test_columntext(x1) FROM x1('b*') +} {1000 {AAA {} CCC {}}} + +finish_test + diff --git a/manifest b/manifest index bec335f8c6..1e012e151a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\stestrunner.tcl,\sallow\ssetting\snjob\sto\szero,\swhich\scauses\sno\snew\sjobs\nto\sbe\slaunched\sand\sfor\sthe\sprocess\sto\sshut\sdown\sonce\sall\scurrent\sjobs\sare\ncompleted. -D 2024-09-03T10:53:32.903 +C Store\sthe\svalues\sof\sany\sUNINDEXED\scolumns\sof\sa\scontentless\sfts5\stable\spersistently\sin\sthe\sdatabase.\sWarning:\sThis\scurrently\screates\sa\s(technically)\sincompatible\sfile-format\sfor\scontentless\sfts5\stables\sthat\shave\sUNINDEXED\scolumns. +D 2024-09-03T18:55:38.957 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -93,15 +93,15 @@ F ext/fts3/unicode/mkunicode.tcl 63db9624ccf70d4887836c320eda93ab552f21008f3be7e F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl 009cf59c77afa86d137b0cca3e3b1a5efbe2264faa2df233f9a7aa8563926d15 F ext/fts5/fts5.h efaaac0df3d3bc740383044c144b582f47921aafa21d7b10eb98f42c24c740b0 -F ext/fts5/fts5Int.h 26a71a09cefa4ef6b4516b204ed48da3e1380970a19b3482eea7c5d805655360 +F ext/fts5/fts5Int.h d0c9bee4edfff9f0899648a9efc0afdebabbadb24403e2e50a1bb17aed6267d0 F ext/fts5/fts5_aux.c 65a0468dd177d6093aa9ae1622e6d86b0136b8d267c62c0ad6493ad1e9a3d759 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 -F ext/fts5/fts5_config.c 353d2a0d12678cae6ab5b9ce54aed8dac0825667b69248b5a4ed81cbefc109ea +F ext/fts5/fts5_config.c 8dba11620a7964e1e561aaae3d27fdd2d16b2769c979f157dd55a53903a9b734 F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c 571483823193f09439356741669aa8c81da838ae6f5e1bfa7517f7ee2fb3addd -F ext/fts5/fts5_main.c 1fddb53f495425d9314c74b30c5848a9dd254be0e5f445bfe38292d5ab21c288 -F ext/fts5/fts5_storage.c 9a9b880be12901f1962ae2a5a7e1b74348b3099a1e728764e419f75d98e3e612 +F ext/fts5/fts5_main.c 402a65b6d922203a90e7d440f29d71f19f6863e6b663ca9f06c7321f291bda40 +F ext/fts5/fts5_storage.c ca3bdb799b9b039133e9b6e4881fc974ba34ae4ea57530210289f82313b409b5 F ext/fts5/fts5_tcl.c 4db9258a7882c5eac0da4433042132aaf15b87dd1e1636c7a6ca203abd2c8bfe F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b @@ -246,6 +246,7 @@ F ext/fts5/test/fts5unicode2.test 3bbd30152f9f760bf13886e5b1e5ec23ff62f56758ddda F ext/fts5/test/fts5unicode3.test f4891a3dac3b49c3d7c0fdb29566e9eb0ecff35263370c89f9661b1952b20818 F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8df04eff87923c74b4d0 F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae +F ext/fts5/test/fts5unindexed2.test f8453dcf1df11544263d350d388d5c612be4b379079b308f1ad74cdaa940804e F ext/fts5/test/fts5update.test b8affd796e45c94a4d19ad5c26606ea06065a0f162a9562d9f005b5a80ccf0bc F ext/fts5/test/fts5version.test c22d163c17e60a99f022cbc52de5a48bb7f84deaa00fe15e9bc4c3aa1996204e F ext/fts5/test/fts5vocab.test 2a2bdb60d0998fa3124d541b6d30b019504918dc43a6584645b63a24be72f992 @@ -2212,8 +2213,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7891a266c4425722ae8b9231397ef9e42e2432be9e6b70632dfaf9ff15300d2c -R 6a86d12ea82ce01298969ad043e5cc65 -U drh -Z 5112afd2e4dab18f4b12bbba01825cee +P 0ef65fd4ba17def4c13986365b3af300c4024725af4bc314845d1af8be568ab4 +R 87dfb79be977919afc56ac91ca0cf0b0 +T *branch * fts5-contentless-unindexed +T *sym-fts5-contentless-unindexed * +T -sym-trunk * +U dan +Z f39a0e93422c865c24dfd629a9a47017 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9843b7b310..b545e371ff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0ef65fd4ba17def4c13986365b3af300c4024725af4bc314845d1af8be568ab4 +dcacb1a8ef359b4507b4733356d3150ba5dc105cc9867c103d16a0908a1a9f64 From 0218424e5aefeac54f98305d972eabadafd40d84 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 13 Sep 2024 16:30:18 +0000 Subject: [PATCH 02/77] Require that the contentless_unindexed=1 option be specified before storing the values of fts5 UNINDEXED column belonging to contentless tables. FossilOrigin-Name: c51dc2a5e75baacbd905cf314e7b1a58a81993ff05ca656739e028d7db25d5b2 --- ext/fts5/fts5Int.h | 1 + ext/fts5/fts5_config.c | 26 +++++++++++++++++++++- ext/fts5/test/fts5unindexed2.test | 37 +++++++++++++++++++++++++++---- manifest | 18 +++++++-------- manifest.uuid | 2 +- 5 files changed, 69 insertions(+), 15 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index 310d4f4390..f189edf312 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -224,6 +224,7 @@ struct Fts5Config { int *aPrefix; /* Sizes in bytes of nPrefix prefix indexes */ int eContent; /* An FTS5_CONTENT value */ int bContentlessDelete; /* "contentless_delete=" option (dflt==0) */ + int bContentlessUnindexed; /* "contentless_unindexed=" option (dflt=0) */ char *zContent; /* content table */ char *zContentRowid; /* "content_rowid=" option value */ int bColumnsize; /* "columnsize=" option value (dflt==1) */ diff --git a/ext/fts5/fts5_config.c b/ext/fts5/fts5_config.c index 93ef333285..a674b44d0b 100644 --- a/ext/fts5/fts5_config.c +++ b/ext/fts5/fts5_config.c @@ -241,6 +241,7 @@ static int fts5ConfigParseSpecial( ){ int rc = SQLITE_OK; int nCmd = (int)strlen(zCmd); + if( sqlite3_strnicmp("prefix", zCmd, nCmd)==0 ){ const int nByte = sizeof(int) * FTS5_MAX_PREFIX_INDEXES; const char *p; @@ -360,6 +361,16 @@ static int fts5ConfigParseSpecial( return rc; } + if( sqlite3_strnicmp("contentless_unindexed", zCmd, nCmd)==0 ){ + if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1]!='\0' ){ + *pzErr = sqlite3_mprintf("malformed contentless_delete=... directive"); + rc = SQLITE_ERROR; + }else{ + pConfig->bContentlessUnindexed = (zArg[0]=='1'); + } + return rc; + } + if( sqlite3_strnicmp("content_rowid", zCmd, nCmd)==0 ){ if( pConfig->zContentRowid ){ *pzErr = sqlite3_mprintf("multiple content_rowid=... directives"); @@ -655,6 +666,19 @@ int sqlite3Fts5ConfigParse( rc = SQLITE_ERROR; } + /* We only allow contentless_unindexed=1 if the table is actually a + ** contentless one. + */ + if( rc==SQLITE_OK + && pRet->bContentlessUnindexed + && pRet->eContent!=FTS5_CONTENT_NONE + ){ + *pzErr = sqlite3_mprintf( + "contentless_unindexed=1 requires a contentless table" + ); + rc = SQLITE_ERROR; + } + /* If no zContent option was specified, fill in the default values. */ if( rc==SQLITE_OK && pRet->zContent==0 ){ const char *zTail = 0; @@ -663,7 +687,7 @@ int sqlite3Fts5ConfigParse( ); if( pRet->eContent==FTS5_CONTENT_NORMAL ){ zTail = "content"; - }else if( bUnindexed ){ + }else if( bUnindexed && pRet->bContentlessUnindexed ){ pRet->eContent = FTS5_CONTENT_UNINDEXED; zTail = "content"; }else if( pRet->bColumnsize ){ diff --git a/ext/fts5/test/fts5unindexed2.test b/ext/fts5/test/fts5unindexed2.test index 3f71fa7a93..cc4ddd28d1 100644 --- a/ext/fts5/test/fts5unindexed2.test +++ b/ext/fts5/test/fts5unindexed2.test @@ -1,4 +1,4 @@ -# 2015 Apr 24 +# 2024 Sep 13 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: @@ -24,7 +24,9 @@ ifcapable !fts5 { do_execsql_test 1.1 { - CREATE VIRTUAL TABLE t1 USING fts5(a, b UNINDEXED, content=); + CREATE VIRTUAL TABLE t1 USING fts5( + a, b UNINDEXED, content=, contentless_unindexed=1 + ); } {} do_execsql_test 1.2 { @@ -93,7 +95,7 @@ do_execsql_test 1.15 { do_execsql_test 2.0 { CREATE VIRTUAL TABLE t4 USING fts5( - x, y UNINDEXED, z, columnsize=0, content='' + x, y UNINDEXED, z, columnsize=0, content='', contentless_unindexed=1 ); } @@ -106,7 +108,8 @@ reset_db do_execsql_test 3.0 { CREATE VIRTUAL TABLE x1 USING fts5( - a UNINDEXED, b, c UNINDEXED, d, content=, contentless_delete=1 + a UNINDEXED, b, c UNINDEXED, d, content=, contentless_delete=1, + contentless_unindexed=1 ); } @@ -172,5 +175,31 @@ do_execsql_test 3.10 { SELECT rowid, fts5_test_columntext(x1) FROM x1('b*') } {1000 {AAA {} CCC {}}} +#------------------------------------------------------------------------- +# Check that if contentless_unindexed=1 is not specified, the values +# of UNINDEXED columns are not stored in the database. +# +# Also check that contentless_unindexed=1 is not allowed unless the table +# is actually contentless. +# +reset_db +do_execsql_test 4.0 { + CREATE VIRTUAL TABLE ft USING fts5(a, b, c UNINDEXED, content=''); + INSERT INTO ft VALUES('one', 'two', 'three'); + SELECT rowid, * FROM ft; +} {1 {} {} {}} + +do_execsql_test 4.1 { + SELECT name FROM sqlite_schema ORDER BY 1 +} { + ft ft_config ft_data ft_docsize ft_idx +} + +do_catchsql_test 4.2 { + CREATE VIRTUAL TABLE ft2 USING fts5( + a, b, c UNINDEXED, contentless_unindexed=1 + ); +} {1 {contentless_unindexed=1 requires a contentless table}} + finish_test diff --git a/manifest b/manifest index 5812d09993..251e6f0bd6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\slatest\strunk\schanges,\sincluding\sthe\schanges\sto\sthe\sfts5\slocale=1\sfeature,\sinto\sthis\sbranch. -D 2024-09-13T15:37:31.588 +C Require\sthat\sthe\scontentless_unindexed=1\soption\sbe\sspecified\sbefore\sstoring\sthe\svalues\sof\sfts5\sUNINDEXED\scolumn\sbelonging\sto\scontentless\stables. +D 2024-09-13T16:30:18.635 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -93,10 +93,10 @@ F ext/fts3/unicode/mkunicode.tcl 63db9624ccf70d4887836c320eda93ab552f21008f3be7e F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl 009cf59c77afa86d137b0cca3e3b1a5efbe2264faa2df233f9a7aa8563926d15 F ext/fts5/fts5.h efaaac0df3d3bc740383044c144b582f47921aafa21d7b10eb98f42c24c740b0 -F ext/fts5/fts5Int.h 6ec0c8a49412e2d7433ebc416cc5a5fd8583dbda30ba46c8835027a4e5c9b41a +F ext/fts5/fts5Int.h 927772e795bc897a210630296531c6a397b247f0b6f65ef9e9dc8e03baa77d1d F ext/fts5/fts5_aux.c 65a0468dd177d6093aa9ae1622e6d86b0136b8d267c62c0ad6493ad1e9a3d759 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 -F ext/fts5/fts5_config.c 700d7accca99d931390c4fcb7c71b92bbcff9093aa9c2d566d7f16a3c9550a59 +F ext/fts5/fts5_config.c a6633d88596758941c625b526075b85d3d9fd1089d8d9eab5db6e8a71fd347ad F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c 571483823193f09439356741669aa8c81da838ae6f5e1bfa7517f7ee2fb3addd @@ -246,7 +246,7 @@ F ext/fts5/test/fts5unicode2.test 3bbd30152f9f760bf13886e5b1e5ec23ff62f56758ddda F ext/fts5/test/fts5unicode3.test f4891a3dac3b49c3d7c0fdb29566e9eb0ecff35263370c89f9661b1952b20818 F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8df04eff87923c74b4d0 F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae -F ext/fts5/test/fts5unindexed2.test f8453dcf1df11544263d350d388d5c612be4b379079b308f1ad74cdaa940804e +F ext/fts5/test/fts5unindexed2.test ec091c92a74d9dd8fa968c6de743982a39ab48b3f1d78e85a45865a615a982ce F ext/fts5/test/fts5update.test b8affd796e45c94a4d19ad5c26606ea06065a0f162a9562d9f005b5a80ccf0bc F ext/fts5/test/fts5version.test c22d163c17e60a99f022cbc52de5a48bb7f84deaa00fe15e9bc4c3aa1996204e F ext/fts5/test/fts5vocab.test 2a2bdb60d0998fa3124d541b6d30b019504918dc43a6584645b63a24be72f992 @@ -436,7 +436,7 @@ F ext/misc/urifuncs.c f71360d14fa9e7626b563f1f781c6148109462741c5235ac63ae0f8917 F ext/misc/uuid.c 5bb2264c1b64d163efa46509544fd7500cb8769cb7c16dd52052da8d961505cf F ext/misc/vfslog.c 3932ab932eeb2601dbc4447cb14d445aaa9fbe43b863ef5f014401c3420afd20 F ext/misc/vfsstat.c a85df08654743922a19410d7b1e3111de41bb7cd07d20dd16eda4e2b808d269d -F ext/misc/vfstrace.c 03f90dd465968e01f5d1d3e79c36cbc53a5bfe1bd55d239435ce94df19d5b0ac w src/test_vfstrace.c +F ext/misc/vfstrace.c 03f90dd465968e01f5d1d3e79c36cbc53a5bfe1bd55d239435ce94df19d5b0ac F ext/misc/vtablog.c 1100250ce8782db37c833e3a9a5c9a3ecf1af5e15b8325572b82e6e0a138ffb5 F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd F ext/misc/wholenumber.c 0fa0c082676b7868bf2fa918e911133f2b349bcdceabd1198bba5f65b4fc0668 @@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dcacb1a8ef359b4507b4733356d3150ba5dc105cc9867c103d16a0908a1a9f64 4cad385b90eaca2d90e3375e473472145af4134160b81097a8535d06638c2e4a -R 6b427d068701369235fcf90674c4aaf6 +P d2f0d19936222911bc317efecc831007d3aba81f9b32877030ffb29d1728bbdc +R e6e3b6faf33ff387284e052d2e40ed37 U dan -Z a31c0a78609956d9ed51a360c49325fd +Z 7aa60982204ecdadda49bd214e78d921 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e5ba7a6786..59b7cd9252 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d2f0d19936222911bc317efecc831007d3aba81f9b32877030ffb29d1728bbdc +c51dc2a5e75baacbd905cf314e7b1a58a81993ff05ca656739e028d7db25d5b2 From 777c35dbe8d8081a29d1f4283f901a4ac6c777b8 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 25 Sep 2024 12:03:08 +0000 Subject: [PATCH 03/77] Prevent regular DELETE and UPDATE statements from running against contentless_unindexed=1 tables that are not also contentless_delete=1. FossilOrigin-Name: 21539e9d0d57fdc762affbce9220d1bb1ca009d9dc751b4ccfe63eecbbe2f575 --- ext/fts5/fts5_main.c | 32 ++++++++++-------- ext/fts5/test/fts5unindexed2.test | 54 +++++++++++++++++++++++++++++++ manifest | 14 ++++---- manifest.uuid | 2 +- 4 files changed, 81 insertions(+), 21 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index f2749ffff1..781a8a8719 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -332,10 +332,16 @@ static void fts5CheckTransactionState(Fts5FullTable *p, int op, int iSavepoint){ #endif /* -** Return true if pTab is a contentless table. +** Return true if pTab is a contentless table. If parameter bIncludeUnindexed +** is true, this includes contentless tables that store UNINDEXED columns +** only. */ -static int fts5IsContentless(Fts5FullTable *pTab){ - return pTab->p.pConfig->eContent==FTS5_CONTENT_NONE; +static int fts5IsContentless(Fts5FullTable *pTab, int bIncludeUnindexed){ + int eContent = pTab->p.pConfig->eContent; + return ( + eContent==FTS5_CONTENT_NONE + || (bIncludeUnindexed && eContent==FTS5_CONTENT_UNINDEXED) + ); } /* @@ -1726,9 +1732,7 @@ static int fts5SpecialInsert( } bLoadConfig = 1; }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){ - if( pConfig->eContent==FTS5_CONTENT_NONE - || pConfig->eContent==FTS5_CONTENT_UNINDEXED - ){ + if( fts5IsContentless(pTab, 1) ){ fts5SetVtabError(pTab, "'rebuild' may not be used with a contentless fts5 table" ); @@ -1895,7 +1899,7 @@ static int fts5UpdateMethod( ** This is not suported. Except - they are both supported if the CREATE ** VIRTUAL TABLE statement contained "contentless_delete=1". */ if( eType0==SQLITE_INTEGER - && pConfig->eContent==FTS5_CONTENT_NONE + && fts5IsContentless(pTab, 1) && pConfig->bContentlessDelete==0 ){ pTab->p.base.zErrMsg = sqlite3_mprintf( @@ -2172,7 +2176,7 @@ static int fts5ApiColumnText( assert( pCsr->ePlan!=FTS5_PLAN_SPECIAL ); if( iCol<0 || iCol>=pTab->pConfig->nCol ){ rc = SQLITE_RANGE; - }else if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab)) ){ + }else if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab), 0) ){ *pz = 0; *pn = 0; }else{ @@ -2205,7 +2209,7 @@ static int fts5CsrPoslist( if( iPhrase<0 || iPhrase>=sqlite3Fts5ExprPhraseCount(pCsr->pExpr) ){ rc = SQLITE_RANGE; }else if( pConfig->eDetail!=FTS5_DETAIL_FULL - && pConfig->eContent==FTS5_CONTENT_NONE + && fts5IsContentless((Fts5FullTable*)pCsr->base.pVtab, 1) ){ *pa = 0; *pn = 0; @@ -2689,7 +2693,7 @@ static int fts5ApiColumnLocale( rc = SQLITE_RANGE; }else if( pConfig->abUnindexed[iCol]==0 - && pConfig->eContent!=FTS5_CONTENT_NONE + && 0==fts5IsContentless((Fts5FullTable*)pCsr->base.pVtab, 1) && pConfig->bLocale ){ rc = fts5SeekCursor(pCsr, 0); @@ -2967,13 +2971,15 @@ static int fts5ColumnMethod( /* A column created by the user containing values. */ int bNochange = sqlite3_vtab_nochange(pCtx); - if( fts5IsContentless(pTab) ){ - if( bNochange && pConfig->bContentlessDelete ){ + if( bNochange ){ + if( pConfig->bContentlessDelete + && (pConfig->eContent==FTS5_CONTENT_NONE || !pConfig->abUnindexed[iCol]) + ){ fts5ResultError(pCtx, "cannot UPDATE a subset of " "columns on fts5 contentless-delete table: %s", pConfig->zName ); } - }else if( bNochange==0 || pConfig->eContent!=FTS5_CONTENT_NORMAL ){ + }else if( pConfig->eContent!=FTS5_CONTENT_NONE ){ pConfig->pzErrmsg = &pTab->p.base.zErrMsg; rc = fts5SeekCursor(pCsr, 1); if( rc==SQLITE_OK ){ diff --git a/ext/fts5/test/fts5unindexed2.test b/ext/fts5/test/fts5unindexed2.test index cc4ddd28d1..f2703ac374 100644 --- a/ext/fts5/test/fts5unindexed2.test +++ b/ext/fts5/test/fts5unindexed2.test @@ -201,5 +201,59 @@ do_catchsql_test 4.2 { ); } {1 {contentless_unindexed=1 requires a contentless table}} +do_catchsql_test 4.3 { + DELETE FROM ft WHERE rowid=1 +} {1 {cannot DELETE from contentless fts5 table: ft}} + +#------------------------------------------------------------------------- +# Check that the usual restrictions on contentless tables apply to +# contentless_unindexed=1 tables. +# +reset_db +do_execsql_test 5.0 { + CREATE VIRTUAL TABLE ft USING fts5( + a, b UNINDEXED, c, content='', contentless_unindexed=1 + ); + INSERT INTO ft VALUES('one', 'two', 'three'); + INSERT INTO ft VALUES('four', 'five', 'six'); + INSERT INTO ft VALUES('seven', 'eight', 'nine'); + SELECT rowid, * FROM ft; +} { + 1 {} two {} + 2 {} five {} + 3 {} eight {} +} + +do_execsql_test 5.1 { + PRAGMA integrity_check +} {ok} + +do_catchsql_test 5.2 { + DELETE FROM ft WHERE rowid=2 +} {1 {cannot DELETE from contentless fts5 table: ft}} + +do_execsql_test 5.3 { + SELECT rowid, * FROM ft('six') +} { + 2 {} five {} +} + +do_catchsql_test 5.4 { + UPDATE ft SET a='x', b='y', c='z' WHERE rowid=3 +} {1 {cannot UPDATE contentless fts5 table: ft}} + +fts5_aux_test_functions db + +do_execsql_test 5.5 { + SELECT fts5_test_columntext(ft) FROM ft WHERE rowid=3 +} { + {{} eight {}} +} +do_execsql_test 5.6 { + SELECT fts5_test_columntext(ft) FROM ft('three'); +} { + {{} two {}} +} + finish_test diff --git a/manifest b/manifest index 251e6f0bd6..c9871be60a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Require\sthat\sthe\scontentless_unindexed=1\soption\sbe\sspecified\sbefore\sstoring\sthe\svalues\sof\sfts5\sUNINDEXED\scolumn\sbelonging\sto\scontentless\stables. -D 2024-09-13T16:30:18.635 +C Prevent\sregular\sDELETE\sand\sUPDATE\sstatements\sfrom\srunning\sagainst\scontentless_unindexed=1\stables\sthat\sare\snot\salso\scontentless_delete=1. +D 2024-09-25T12:03:08.340 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c a6633d88596758941c625b526075b85d3d9fd1089d8d9eab5db6e8a F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c 571483823193f09439356741669aa8c81da838ae6f5e1bfa7517f7ee2fb3addd -F ext/fts5/fts5_main.c be195e918c40c304f81d899f8a9b00d47ed266583dd931e22730e83b011ddadc +F ext/fts5/fts5_main.c 0d2013bd03285f4bbcea0f4594f2cd33b68337da709da79cd46379be189d11da F ext/fts5/fts5_storage.c 1fbaf212042bdb363d74a48d3293b2c453a46880e86656df3ee19ade63472681 F ext/fts5/fts5_tcl.c 4db9258a7882c5eac0da4433042132aaf15b87dd1e1636c7a6ca203abd2c8bfe F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -246,7 +246,7 @@ F ext/fts5/test/fts5unicode2.test 3bbd30152f9f760bf13886e5b1e5ec23ff62f56758ddda F ext/fts5/test/fts5unicode3.test f4891a3dac3b49c3d7c0fdb29566e9eb0ecff35263370c89f9661b1952b20818 F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8df04eff87923c74b4d0 F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae -F ext/fts5/test/fts5unindexed2.test ec091c92a74d9dd8fa968c6de743982a39ab48b3f1d78e85a45865a615a982ce +F ext/fts5/test/fts5unindexed2.test 54a924b8acc6270350898e09d56c1b942b6e3cae789b9e5f31ec7b9a3dc7953e F ext/fts5/test/fts5update.test b8affd796e45c94a4d19ad5c26606ea06065a0f162a9562d9f005b5a80ccf0bc F ext/fts5/test/fts5version.test c22d163c17e60a99f022cbc52de5a48bb7f84deaa00fe15e9bc4c3aa1996204e F ext/fts5/test/fts5vocab.test 2a2bdb60d0998fa3124d541b6d30b019504918dc43a6584645b63a24be72f992 @@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d2f0d19936222911bc317efecc831007d3aba81f9b32877030ffb29d1728bbdc -R e6e3b6faf33ff387284e052d2e40ed37 +P c51dc2a5e75baacbd905cf314e7b1a58a81993ff05ca656739e028d7db25d5b2 +R 0573b4e17b15d974d21966942a753c69 U dan -Z 7aa60982204ecdadda49bd214e78d921 +Z 19e56c0d30986f9b0323b85fbd6aa264 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 59b7cd9252..957a7db2aa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c51dc2a5e75baacbd905cf314e7b1a58a81993ff05ca656739e028d7db25d5b2 +21539e9d0d57fdc762affbce9220d1bb1ca009d9dc751b4ccfe63eecbbe2f575 From d0720eee5e19d9d6889b275bdb652e5e0160899c Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 26 Sep 2024 18:02:17 +0000 Subject: [PATCH 04/77] When possible, avoid taking wal file read-lock 0 in sqlite3_snapshot_get(). FossilOrigin-Name: 34b6ac3d76dbc6819778ec2a0f81cbcdcc0cd1a6303381d97f1c479e4ecdd132 --- manifest | 22 ++++++++++++---------- manifest.uuid | 2 +- src/main.c | 4 ++++ src/wal.c | 18 ++++++++++++++++-- test/snapshot3.test | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index e74bcacf3c..83d6936a7d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sCLI,\sfor\scolumnar\soutput\sformats,\stry\sto\saccount\sfor\sthe\spresence\sof\nzero-width\sand\sdouble-width\scharacters\sin\sthe\soutput\sand\sadjust\scolumn\swidths\naccordingly. -D 2024-09-25T09:39:11.501 +C When\spossible,\savoid\staking\swal\sfile\sread-lock\s0\sin\ssqlite3_snapshot_get(). +D 2024-09-26T18:02:17.495 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -730,7 +730,7 @@ F src/insert.c f8d1a0f8ee258411009c6b7f2d93170e351bd19f5ad89d57e1180644297cbe70 F src/json.c 68a98c020c22127f2d65f08855f7fc7460ff352a6ce0b543d8931dde83319c22 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 -F src/main.c 4db6e3bde55ba0b24ccc83600c2b6ea11429f61ce7b3a2e7e3b42e1b45366c3e +F src/main.c 3bb768eeeee1cceaed391327362b8be8b5ce61a12fe24d5b555ce9c6b4a883de F src/malloc.c 410e570b30c26cc36e3372577df50f7a96ee3eed5b2b161c6b6b48773c650c5e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 @@ -849,7 +849,7 @@ F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf8 F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3 F src/vtab.c 316cd48e9320660db3047cd306cd056e4361180cebb4d0f10a39244e10c11422 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 -F src/wal.c ef68130ba330ee18c1cb22da36a881c82e3a3b109badbdc6a9b9acaf788a6688 +F src/wal.c a0d42bfdef935e1389737152394d08e59e7c48697f40a9fc2e0552cb19dc731f F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 F src/where.c 461d41017d900d4248a268df96d2d30506c4dcc2257f4167c4f46072003ce2cf @@ -1647,7 +1647,7 @@ F test/skipscan5.test 0672103fd2c8f96bd114133f356192b35ece45c794fe3677e1d9e5e310 F test/skipscan6.test bddbb35dd335e2d21b7791a61e3b2e1f3255dc307ce80aa6fe19cc298e6feb13 F test/snapshot.test a504f2e7009f512ef66c719f0ea1c55a556bdaf1e1312c80a04d46fc1a3e9632 F test/snapshot2.test 8d6ff5dd9cc503f6e12d408a30409c3f9c653507b24408d9cd7195931c89bc54 -F test/snapshot3.test 8744313270c55f6e18574283553d3c5c5fe4c5970585663613a0e75c151e599b +F test/snapshot3.test 41350216abc6c7da37113ad462259c070786e5ad70bdc8709daaed148b1b3a2c F test/snapshot4.test d4e9347ef2fcabc491fc893506c7bbaf334da3be111d6eb4f3a97cc623b78322 F test/snapshot_fault.test 129234ceb9b26a0e1000e8563a16e790f5c1412354e70749cbd78c3d5d07d60a F test/snapshot_up.test 77dc7853bfb2b4fa249f76e1714cfa1e596826165d9ef22c06ac3a0b7b778d9a @@ -2213,9 +2213,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 42bb941584a1ac922ee6b0b6ecadce71c9259555563cf49913a6f820f3f9b887 b217e3004b58af0e777726bdd652b999ad41815261299ef4ce8f8d2f6b0afe8d -R 5fcf6775e686fdd76943c66cce860cb0 -T +closed b217e3004b58af0e777726bdd652b999ad41815261299ef4ce8f8d2f6b0afe8d -U drh -Z af457fc67e3efab459ef7260d9a5da46 +P 9592b9ba3ad7a842cdd4c4010da278485a6fdec7e811bda01ebe640162a8c3b6 +R 8553e4183ac33940fe95918021cfe535 +T *branch * snapshot_get-locking +T *sym-snapshot_get-locking * +T -sym-trunk * +U dan +Z 2b5e37766517d26ed8f4d4495c7d929b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5d05a8c7ec..986575a33e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9592b9ba3ad7a842cdd4c4010da278485a6fdec7e811bda01ebe640162a8c3b6 +34b6ac3d76dbc6819778ec2a0f81cbcdcc0cd1a6303381d97f1c479e4ecdd132 diff --git a/src/main.c b/src/main.c index 6ab09c5560..fceb7957b9 100644 --- a/src/main.c +++ b/src/main.c @@ -4963,7 +4963,11 @@ int sqlite3_snapshot_get( if( iDb==0 || iDb>1 ){ Btree *pBt = db->aDb[iDb].pBt; if( SQLITE_TXN_WRITE!=sqlite3BtreeTxnState(pBt) ){ + Pager *pPager = sqlite3BtreePager(pBt); + i64 dummy = 0; + sqlite3PagerSnapshotOpen(pPager, (sqlite3_snapshot*)&dummy); rc = sqlite3BtreeBeginTrans(pBt, 0, 0); + sqlite3PagerSnapshotOpen(pPager, 0); if( rc==SQLITE_OK ){ rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot); } diff --git a/src/wal.c b/src/wal.c index 89106038b8..f4aa663fd3 100644 --- a/src/wal.c +++ b/src/wal.c @@ -541,6 +541,7 @@ struct Wal { #endif #ifdef SQLITE_ENABLE_SNAPSHOT WalIndexHdr *pSnapshot; /* Start transaction here if not NULL */ + int bGetSnapshot; /* Transaction opened for sqlite3_get_snapshot() */ #endif #ifdef SQLITE_ENABLE_SETLK_TIMEOUT sqlite3 *db; @@ -3097,7 +3098,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){ SEH_INJECT_FAULT; if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame #ifdef SQLITE_ENABLE_SNAPSHOT - && (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0) + && ((pWal->bGetSnapshot==0 && pWal->pSnapshot==0) || pWal->hdr.mxFrame==0) #endif ){ /* The WAL has been completely backfilled (or it is empty). @@ -4497,7 +4498,20 @@ void sqlite3WalSnapshotOpen( Wal *pWal, sqlite3_snapshot *pSnapshot ){ - pWal->pSnapshot = (WalIndexHdr*)pSnapshot; + if( pSnapshot && ((WalIndexHdr*)pSnapshot)->iVersion==0 ){ + /* iVersion==0 means that this is a call to sqlite3_snapshot_get(). In + ** this case set the bGetSnapshot flag so that if the call to + ** sqlite3_snapshot_get() is about to read transaction on this wal + ** file, it does not take read-lock 0 if the wal file has been completely + ** checkpointed. Taking read-lock 0 would work, but then it would be + ** possible for a subsequent writer to destroy the snapshot even while + ** this connection is holding its read-transaction open. This is contrary + ** to user expectations, so we avoid it by not taking read-lock 0. */ + pWal->bGetSnapshot = 1; + }else{ + pWal->pSnapshot = (WalIndexHdr*)pSnapshot; + pWal->bGetSnapshot = 0; + } } /* diff --git a/test/snapshot3.test b/test/snapshot3.test index 4dca202b1c..470d463a66 100644 --- a/test/snapshot3.test +++ b/test/snapshot3.test @@ -96,4 +96,43 @@ do_test 1.8 { list [catch { sqlite3_snapshot_open_blob db3 main $snap } msg] $msg } {1 SQLITE_ERROR_SNAPSHOT} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 2.0 { + PRAGMA journal_mode = wal; + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 2); + INSERT INTO t1 VALUES(3, 4); +} {wal} + +sqlite3 db2 test.db +sqlite3 db3 test.db +do_execsql_test -db db2 2.0.1 { + SELECT * FROM t1 +} {1 2 3 4} +do_execsql_test -db db3 2.0.2 { + SELECT * FROM t1 +} {1 2 3 4} + +do_execsql_test -db db2 2.2 { + PRAGMA wal_checkpoint; +} {0 4 4} + +do_test 2.1 { + db eval { BEGIN } + set snap [sqlite3_snapshot_get db main] + set {} {} +} {} + +do_execsql_test -db db2 2.3 { + INSERT INTO t1 VALUES(5, 6); +} {} + +do_test 2.2 { + execsql { BEGIN } db3 + sqlite3_snapshot_open db3 main $snap +} {} + +sqlite3_snapshot_free $snap + finish_test From bcd6d5d393ddcce137156a7f73d723e4d3e9ca3f Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 27 Sep 2024 10:57:41 +0000 Subject: [PATCH 05/77] Allow UPDATEs of unindexed columns in fts5 contentless_unindexed=1 tables. Testing to come. FossilOrigin-Name: cd36d66c88d7282eb0a3ccde5713253f72f5843e451b2693b71adfdae28b41fb --- ext/fts5/fts5Int.h | 2 +- ext/fts5/fts5_main.c | 128 +++++++++++++++++++++--------- ext/fts5/fts5_storage.c | 9 ++- ext/fts5/test/fts5unindexed2.test | 38 +++++++++ manifest | 18 ++--- manifest.uuid | 2 +- 6 files changed, 146 insertions(+), 51 deletions(-) diff --git a/ext/fts5/fts5Int.h b/ext/fts5/fts5Int.h index f189edf312..51d8081774 100644 --- a/ext/fts5/fts5Int.h +++ b/ext/fts5/fts5Int.h @@ -726,7 +726,7 @@ int sqlite3Fts5DropAll(Fts5Config*); int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **); int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**, int); -int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*); +int sqlite3Fts5StorageContentInsert(Fts5Storage *p, int, sqlite3_value**, i64*); int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64); int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg); diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 781a8a8719..ff8b76694b 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1801,7 +1801,7 @@ static void fts5StorageInsert( ){ int rc = *pRc; if( rc==SQLITE_OK ){ - rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, piRowid); + rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, 0, apVal, piRowid); } if( rc==SQLITE_OK ){ rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *piRowid); @@ -1809,6 +1809,45 @@ static void fts5StorageInsert( *pRc = rc; } +static int fts5ContentlessUpdateOk( + Fts5Config *pConfig, + sqlite3_value **apVal, + i64 iOld, + i64 iNew, + int *pbContent +){ + int ii; + int bSeenIndex = 0; + int bSeenIndexNC = 0; + int rc = SQLITE_OK; + + for(ii=0; iinCol; ii++){ + if( pConfig->abUnindexed[ii]==0 ){ + if( sqlite3_value_nochange(apVal[ii]) ){ + bSeenIndexNC++; + }else{ + bSeenIndex++; + } + } + } + + if( bSeenIndex==0 && iOld==iNew ){ + *pbContent = 1; + }else{ + if( bSeenIndexNC || pConfig->bContentlessDelete==0 ){ + rc = SQLITE_ERROR; + sqlite3Fts5ConfigErrmsg(pConfig, + (pConfig->bContentlessDelete ? + "%s a subset of columns on fts5 contentless-delete table: %s" : + "%s contentless fts5 table: %s") + , "cannot UPDATE", pConfig->zName + ); + } + } + + return rc; +} + /* ** This function is the implementation of the xUpdate callback used by ** FTS3 virtual tables. It is invoked by SQLite each time a row is to be @@ -1895,25 +1934,35 @@ static int fts5UpdateMethod( assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL ); assert( nArg!=1 || eType0==SQLITE_INTEGER ); - /* Filter out attempts to run UPDATE or DELETE on contentless tables. - ** This is not suported. Except - they are both supported if the CREATE - ** VIRTUAL TABLE statement contained "contentless_delete=1". */ - if( eType0==SQLITE_INTEGER - && fts5IsContentless(pTab, 1) - && pConfig->bContentlessDelete==0 - ){ - pTab->p.base.zErrMsg = sqlite3_mprintf( - "cannot %s contentless fts5 table: %s", - (nArg>1 ? "UPDATE" : "DELETE from"), pConfig->zName - ); - rc = SQLITE_ERROR; - } + /* + ** Extra rule for contentless tables: + ** + ** DELETE: + ** It is only possible to DELETE if the contentless_delete=1 flag + ** is set. + ** + ** UPDATE: + ** A "content-only" UPDATE is one that only affects UNINDEXED + ** columns. And that does not modify the rowid value. + ** + ** If the contentless_delete flag is clear, then content-only UPDATEs + ** are the only ones supported. Or, if contentless_delete=1 is set, + ** then updates that modify all indexed columns are also supported. + ** If all indexed columns are updated, then rowid updates are allowed. + */ /* DELETE */ - else if( nArg==1 ){ - i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0, 0); - bUpdateOrDelete = 1; + if( nArg==1 ){ + if( fts5IsContentless(pTab, 1) && pConfig->bContentlessDelete==0 ){ + fts5SetVtabError(pTab, + "cannot DELETE from contentless fts5 table: %s", pConfig->zName + ); + rc = SQLITE_ERROR; + }else{ + i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */ + rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0, 0); + bUpdateOrDelete = 1; + } } /* INSERT or UPDATE */ @@ -1947,35 +1996,49 @@ static int fts5UpdateMethod( /* UPDATE */ else{ + Fts5Storage *pStorage = pTab->pStorage; i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */ i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */ + int bContent = 0; /* Content only update */ + + if( fts5IsContentless(pTab, 1) ){ + rc = fts5ContentlessUpdateOk(pConfig,&apVal[2],iOld,iNew,&bContent); + if( rc!=SQLITE_OK ) goto update_out; + } + if( eType1!=SQLITE_INTEGER ){ rc = SQLITE_MISMATCH; }else if( iOld!=iNew ){ + assert( bContent==0 ); if( eConflict==SQLITE_REPLACE ){ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1); + rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1); if( rc==SQLITE_OK ){ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0, 0); + rc = sqlite3Fts5StorageDelete(pStorage, iNew, 0, 0); } fts5StorageInsert(&rc, pTab, apVal, pRowid); }else{ - rc = sqlite3Fts5StorageFindDeleteRow(pTab->pStorage, iOld); + rc = sqlite3Fts5StorageFindDeleteRow(pStorage, iOld); if( rc==SQLITE_OK ){ - rc = sqlite3Fts5StorageContentInsert(pTab->pStorage,apVal,pRowid); + rc = sqlite3Fts5StorageContentInsert(pStorage, 0, apVal, pRowid); } if( rc==SQLITE_OK ){ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1); + rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1); } if( rc==SQLITE_OK ){ - rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal,*pRowid); + rc = sqlite3Fts5StorageIndexInsert(pStorage, apVal,*pRowid); } } + }else if( bContent ){ + rc = sqlite3Fts5StorageFindDeleteRow(pStorage, iOld); + if( rc==SQLITE_OK ){ + rc = sqlite3Fts5StorageContentInsert(pStorage, 1, apVal, pRowid); + } }else{ - rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1); + rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1); fts5StorageInsert(&rc, pTab, apVal, pRowid); } bUpdateOrDelete = 1; - sqlite3Fts5StorageReleaseDeleteRow(pTab->pStorage); + sqlite3Fts5StorageReleaseDeleteRow(pStorage); } } @@ -2968,18 +3031,7 @@ static int fts5ColumnMethod( } } }else{ - /* A column created by the user containing values. */ - int bNochange = sqlite3_vtab_nochange(pCtx); - - if( bNochange ){ - if( pConfig->bContentlessDelete - && (pConfig->eContent==FTS5_CONTENT_NONE || !pConfig->abUnindexed[iCol]) - ){ - fts5ResultError(pCtx, "cannot UPDATE a subset of " - "columns on fts5 contentless-delete table: %s", pConfig->zName - ); - } - }else if( pConfig->eContent!=FTS5_CONTENT_NONE ){ + if( !sqlite3_vtab_nochange(pCtx) && pConfig->eContent!=FTS5_CONTENT_NONE ){ pConfig->pzErrmsg = &pTab->p.base.zErrMsg; rc = fts5SeekCursor(pCsr, 1); if( rc==SQLITE_OK ){ diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index ee65b0f7ee..7f149eee8a 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -141,7 +141,8 @@ static int fts5StorageGetStmt( ); break; - case FTS5_STMT_INSERT_CONTENT: { + case FTS5_STMT_INSERT_CONTENT: + case FTS5_STMT_REPLACE_CONTENT: { char *zBind = 0; int i; @@ -930,6 +931,7 @@ static int fts5StorageNewRowid(Fts5Storage *p, i64 *piRowid){ */ int sqlite3Fts5StorageContentInsert( Fts5Storage *p, + int bReplace, /* True to use REPLACE instead of INSERT */ sqlite3_value **apVal, i64 *piRowid ){ @@ -948,7 +950,10 @@ int sqlite3Fts5StorageContentInsert( }else{ sqlite3_stmt *pInsert = 0; /* Statement to write %_content table */ int i; /* Counter variable */ - rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT, &pInsert, 0); + + assert( FTS5_STMT_INSERT_CONTENT+1==FTS5_STMT_REPLACE_CONTENT ); + assert( bReplace==0 || bReplace==1 ); + rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT+bReplace, &pInsert, 0); if( pInsert ) sqlite3_clear_bindings(pInsert); /* Bind the rowid value */ diff --git a/ext/fts5/test/fts5unindexed2.test b/ext/fts5/test/fts5unindexed2.test index f2703ac374..c0abfc3980 100644 --- a/ext/fts5/test/fts5unindexed2.test +++ b/ext/fts5/test/fts5unindexed2.test @@ -255,5 +255,43 @@ do_execsql_test 5.6 { {{} two {}} } +#------------------------------------------------------------------------- +# Check that it is possible to UPDATE a contentless_unindexed=1 table +# if the only columns being modified are UNINDEXED. +# +# If the contentless_unindexed=1 table is also contentless_delete=1, then +# it is also possible to update indexed columns - but only if *all* indexed +# columns are updated. +# +reset_db +do_execsql_test 6.0 { + CREATE VIRTUAL TABLE ft1 USING fts5(a, b UNINDEXED, c UNINDEXED, d, + contentless_unindexed=1, content='' + ); + + INSERT INTO ft1(rowid, a, b, c, d) VALUES + (100, 'x y', 'b1', 'c1', 'a b'), + (200, 'c d', 'b2', 'c2', 'a b'), + (300, 'e f', 'b3', 'c3', 'a b'); +} + +do_execsql_test 6.1 { + UPDATE ft1 SET b='b1.1', c='c1.1' WHERE rowid=100; +} +do_execsql_test 6.2 { + UPDATE ft1 SET b='b2.1' WHERE rowid=200; +} +do_execsql_test 6.3 { + UPDATE ft1 SET c='c3.1' WHERE rowid=300; +} + +do_execsql_test 6.4 { + SELECT rowid, a, b, c, d FROM ft1 +} { + 100 {} b1.1 c1.1 {} + 200 {} b2.1 c2 {} + 300 {} b3 c3.1 {} +} + finish_test diff --git a/manifest b/manifest index c9871be60a..0daa473be9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prevent\sregular\sDELETE\sand\sUPDATE\sstatements\sfrom\srunning\sagainst\scontentless_unindexed=1\stables\sthat\sare\snot\salso\scontentless_delete=1. -D 2024-09-25T12:03:08.340 +C Allow\sUPDATEs\sof\sunindexed\scolumns\sin\sfts5\scontentless_unindexed=1\stables.\sTesting\sto\scome. +D 2024-09-27T10:57:41.777 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -93,15 +93,15 @@ F ext/fts3/unicode/mkunicode.tcl 63db9624ccf70d4887836c320eda93ab552f21008f3be7e F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb F ext/fts5/extract_api_docs.tcl 009cf59c77afa86d137b0cca3e3b1a5efbe2264faa2df233f9a7aa8563926d15 F ext/fts5/fts5.h efaaac0df3d3bc740383044c144b582f47921aafa21d7b10eb98f42c24c740b0 -F ext/fts5/fts5Int.h 927772e795bc897a210630296531c6a397b247f0b6f65ef9e9dc8e03baa77d1d +F ext/fts5/fts5Int.h bf0d3efa144f36e00f9b5206626aec2f436f58186a0835092394f2202e9828e3 F ext/fts5/fts5_aux.c 65a0468dd177d6093aa9ae1622e6d86b0136b8d267c62c0ad6493ad1e9a3d759 F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70673cb6f09 F ext/fts5/fts5_config.c a6633d88596758941c625b526075b85d3d9fd1089d8d9eab5db6e8a71fd347ad F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c 571483823193f09439356741669aa8c81da838ae6f5e1bfa7517f7ee2fb3addd -F ext/fts5/fts5_main.c 0d2013bd03285f4bbcea0f4594f2cd33b68337da709da79cd46379be189d11da -F ext/fts5/fts5_storage.c 1fbaf212042bdb363d74a48d3293b2c453a46880e86656df3ee19ade63472681 +F ext/fts5/fts5_main.c 853d44c804b6d842f0197002a03ecf482b721834b0bf3d2f1ab3a21e4fd13df5 +F ext/fts5/fts5_storage.c 3b5d743e97502263961e706aedd1000c394ee9df7942ba6671ce4bc41fcf9993 F ext/fts5/fts5_tcl.c 4db9258a7882c5eac0da4433042132aaf15b87dd1e1636c7a6ca203abd2c8bfe F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b @@ -246,7 +246,7 @@ F ext/fts5/test/fts5unicode2.test 3bbd30152f9f760bf13886e5b1e5ec23ff62f56758ddda F ext/fts5/test/fts5unicode3.test f4891a3dac3b49c3d7c0fdb29566e9eb0ecff35263370c89f9661b1952b20818 F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8df04eff87923c74b4d0 F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae -F ext/fts5/test/fts5unindexed2.test 54a924b8acc6270350898e09d56c1b942b6e3cae789b9e5f31ec7b9a3dc7953e +F ext/fts5/test/fts5unindexed2.test 516236eceaac05ace322290a0d3705b4c4ffe4760d8eb9d014d9d27d56dfcc02 F ext/fts5/test/fts5update.test b8affd796e45c94a4d19ad5c26606ea06065a0f162a9562d9f005b5a80ccf0bc F ext/fts5/test/fts5version.test c22d163c17e60a99f022cbc52de5a48bb7f84deaa00fe15e9bc4c3aa1996204e F ext/fts5/test/fts5vocab.test 2a2bdb60d0998fa3124d541b6d30b019504918dc43a6584645b63a24be72f992 @@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c51dc2a5e75baacbd905cf314e7b1a58a81993ff05ca656739e028d7db25d5b2 -R 0573b4e17b15d974d21966942a753c69 +P 21539e9d0d57fdc762affbce9220d1bb1ca009d9dc751b4ccfe63eecbbe2f575 +R de377aee83cef1249306ac8b9c4a8126 U dan -Z 19e56c0d30986f9b0323b85fbd6aa264 +Z cfbbba283553b2d6b64e253eb6c401a0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 957a7db2aa..28116b337f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -21539e9d0d57fdc762affbce9220d1bb1ca009d9dc751b4ccfe63eecbbe2f575 +cd36d66c88d7282eb0a3ccde5713253f72f5843e451b2693b71adfdae28b41fb From 08f1ba0767d6bfe1cf098e8e81aa74681277ec0f Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 27 Sep 2024 18:32:52 +0000 Subject: [PATCH 06/77] Fix a problem with UPDATEs that do not modify all UNINDEXED columns of a contentless_delete=1, contentless_unindexed=1 table. FossilOrigin-Name: b6b1db8d343d3e55c3a5589af3ec629762e06c6b689b77defd445347198cb2e7 --- ext/fts5/fts5_main.c | 61 ++++++++++------- ext/fts5/fts5_storage.c | 6 ++ ext/fts5/test/fts5update2.test | 122 +++++++++++++++++++++++++++++++++ manifest | 15 ++-- manifest.uuid | 2 +- 5 files changed, 174 insertions(+), 32 deletions(-) create mode 100644 ext/fts5/test/fts5update2.test diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index ff8b76694b..4ea727cac2 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -1809,16 +1809,38 @@ static void fts5StorageInsert( *pRc = rc; } -static int fts5ContentlessUpdateOk( +/* +** +** This function is called when the user attempts an UPDATE on a contentless +** table. Parameter bRowidModified is true if the UPDATE statement modifies +** the rowid value. Parameter apVal[] contains the new values for each user +** defined column of the fts5 table. pConfig is the configuration object of the +** table being updated (guaranteed to be contentless). The contentless_delete=1 +** and contentless_unindexed=1 options may or may not be set. +** +** This function returns SQLITE_OK if the UPDATE can go ahead, or an SQLite +** error code if it cannot. In this case an error message is also loaded into +** pConfig. Output parameter (*pbContent) is set to true if the caller should +** update the %_content table only - not the FTS index or any other shadow +** table. This occurs when an UPDATE modifies only UNINDEXED columns of the +** table. +** +** An UPDATE may proceed if: +** +** * The only columns modified are UNINDEXED columns, or +** +** * The contentless_delete=1 option was specified and all of the indexed +** columns (not a subset) have been modified. +*/ +static int fts5ContentlessUpdate( Fts5Config *pConfig, sqlite3_value **apVal, - i64 iOld, - i64 iNew, + int bRowidModified, int *pbContent ){ int ii; - int bSeenIndex = 0; - int bSeenIndexNC = 0; + int bSeenIndex = 0; /* Have seen modified indexed column */ + int bSeenIndexNC = 0; /* Have seen unmodified indexed column */ int rc = SQLITE_OK; for(ii=0; iinCol; ii++){ @@ -1831,7 +1853,7 @@ static int fts5ContentlessUpdateOk( } } - if( bSeenIndex==0 && iOld==iNew ){ + if( bSeenIndex==0 && bRowidModified==0 ){ *pbContent = 1; }else{ if( bSeenIndexNC || pConfig->bContentlessDelete==0 ){ @@ -1934,25 +1956,10 @@ static int fts5UpdateMethod( assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL ); assert( nArg!=1 || eType0==SQLITE_INTEGER ); - /* - ** Extra rule for contentless tables: - ** - ** DELETE: - ** It is only possible to DELETE if the contentless_delete=1 flag - ** is set. - ** - ** UPDATE: - ** A "content-only" UPDATE is one that only affects UNINDEXED - ** columns. And that does not modify the rowid value. - ** - ** If the contentless_delete flag is clear, then content-only UPDATEs - ** are the only ones supported. Or, if contentless_delete=1 is set, - ** then updates that modify all indexed columns are also supported. - ** If all indexed columns are updated, then rowid updates are allowed. - */ - /* DELETE */ if( nArg==1 ){ + /* It is only possible to DELETE from a contentless table if the + ** contentless_delete=1 flag is set. */ if( fts5IsContentless(pTab, 1) && pConfig->bContentlessDelete==0 ){ fts5SetVtabError(pTab, "cannot DELETE from contentless fts5 table: %s", pConfig->zName @@ -2001,8 +2008,10 @@ static int fts5UpdateMethod( i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */ int bContent = 0; /* Content only update */ + /* If this is a contentless table (including contentless_unindexed=1 + ** tables), check if the UPDATE may proceed. */ if( fts5IsContentless(pTab, 1) ){ - rc = fts5ContentlessUpdateOk(pConfig,&apVal[2],iOld,iNew,&bContent); + rc = fts5ContentlessUpdate(pConfig, &apVal[2], iOld!=iNew, &bContent); if( rc!=SQLITE_OK ) goto update_out; } @@ -2029,6 +2038,10 @@ static int fts5UpdateMethod( } } }else if( bContent ){ + /* This occurs when an UPDATE on a contentless table affects *only* + ** UNINDEXED columns. This is a no-op for contentless_unindexed=0 + ** tables, or a write to the %_content table only for =1 tables. */ + assert( fts5IsContentless(pTab, 1) ); rc = sqlite3Fts5StorageFindDeleteRow(pStorage, iOld); if( rc==SQLITE_OK ){ rc = sqlite3Fts5StorageContentInsert(pStorage, 1, apVal, pRowid); diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 7f149eee8a..31f5fc5dc3 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -739,6 +739,12 @@ int sqlite3Fts5StorageDelete( if( rc==SQLITE_OK ){ if( p->pConfig->bContentlessDelete ){ rc = fts5StorageContentlessDelete(p, iDel); + if( rc==SQLITE_OK + && bSaveRow + && p->pConfig->eContent==FTS5_CONTENT_UNINDEXED + ){ + rc = sqlite3Fts5StorageFindDeleteRow(p, iDel); + } }else{ rc = fts5StorageDeleteFromIndex(p, iDel, apVal, bSaveRow); } diff --git a/ext/fts5/test/fts5update2.test b/ext/fts5/test/fts5update2.test new file mode 100644 index 0000000000..a402b3cb23 --- /dev/null +++ b/ext/fts5/test/fts5update2.test @@ -0,0 +1,122 @@ +# 2024 Sep 27 +# +# 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 FTS5 module. +# + +source [file join [file dirname [info script]] fts5_common.tcl] +set testprefix fts5update2 + +# If SQLITE_ENABLE_FTS5 is not defined, omit this file. +ifcapable !fts5 { + finish_test + return +} + + +#------------------------------------------------------------------------- +# Test that the various types of UPDATE statement are handled correctly +# by different table types. +# +foreach {tn cu} { + 1 0 + 2 1 +} { + reset_db + do_execsql_test 1.$tn.1 " + CREATE VIRTUAL TABLE ft1 USING fts5(a, b UNINDEXED, c UNINDEXED, d, + content='', + contentless_unindexed=$cu + ); + CREATE VIRTUAL TABLE ft2 USING fts5(a, b UNINDEXED, c UNINDEXED, d, + content='', + contentless_unindexed=$cu, contentless_delete=1 + ); + " + + do_execsql_test 1.$tn.2 { + INSERT INTO ft1(rowid, a, b, c, d) VALUES(1, 'a1', 'b1', 'c1', 'd1'); + INSERT INTO ft1(rowid, a, b, c, d) VALUES(2, 'a2', 'b2', 'c2', 'd2'); + INSERT INTO ft1(rowid, a, b, c, d) VALUES(3, 'a3', 'b3', 'c3', 'd3'); + + INSERT INTO ft2(rowid, a, b, c, d) VALUES(1, 'a1', 'b1', 'c1', 'd1'); + INSERT INTO ft2(rowid, a, b, c, d) VALUES(2, 'a2', 'b2', 'c2', 'd2'); + INSERT INTO ft2(rowid, a, b, c, d) VALUES(3, 'a3', 'b3', 'c3', 'd3'); + } + + # It should be possible to update a subset of the UNINDEXED columns of + # a contentless table. Regardless of whether or not contentless_unindexed=1 + # or contentless_delete=1 is set. + do_execsql_test 1.$tn.3 { + UPDATE ft1 SET b=b||'.1'; + UPDATE ft2 SET b=b||'.1'; + } + do_execsql_test 1.$tn.4 { + UPDATE ft1 SET b=b||'.2', c=c||'.2'; + UPDATE ft2 SET b=b||'.2', c=c||'.2'; + } + + set res(0) { + 1 {} {} {} {} + 2 {} {} {} {} + 3 {} {} {} {} + } + set res(1) { + 1 {} b1.1.2 c1.2 {} + 2 {} b2.1.2 c2.2 {} + 3 {} b3.1.2 c3.2 {} + } + + do_execsql_test 1.$tn.5 { + SELECT rowid, * FROM ft2 + } $res($cu) + + do_execsql_test 1.6.1 { SELECT rowid FROM ft1('a2') } {2} + do_execsql_test 1.6.2 { SELECT rowid FROM ft2('a2') } {2} + + # It should be possible to update all indexed columns (but no other subset) + # if the contentless_delete=1 option is set, as it is for "ft2". + do_execsql_test 1.$tn.7 { + UPDATE ft2 SET a='a22', d='d22' WHERE rowid=2; + } + do_execsql_test 1.$tn.8 { SELECT rowid FROM ft2('a22 AND d22') } {2} + + do_execsql_test 1.$tn.9 { + UPDATE ft2 SET a='a33', d='d33', b='b3' WHERE rowid=3; + } + + set res(1) { + 1 {} b1.1.2 c1.2 {} + 2 {} b2.1.2 c2.2 {} + 3 {} b3 c3.2 {} + } + do_execsql_test 1.$tn.10 { + SELECT rowid, * FROM ft2 + } $res($cu) + + do_catchsql_test 1.$tn.11 { + UPDATE ft2 SET a='a11' WHERE rowid=1 + } {1 {cannot UPDATE a subset of columns on fts5 contentless-delete table: ft2}} + do_catchsql_test 1.$tn.12 { + UPDATE ft2 SET d='d11' WHERE rowid=1 + } {1 {cannot UPDATE a subset of columns on fts5 contentless-delete table: ft2}} + + # It is not possible to update the values of indexed columns if + # contentless_delete=1 is not set. + do_catchsql_test 1.$tn.13 { + UPDATE ft1 SET a='a11' WHERE rowid=1 + } {1 {cannot UPDATE contentless fts5 table: ft1}} + do_catchsql_test 1.$tn.14 { + UPDATE ft1 SET d='d11' WHERE rowid=1 + } {1 {cannot UPDATE contentless fts5 table: ft1}} +} + +finish_test diff --git a/manifest b/manifest index 2888f0d958..9524da68c3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\strunk\schanges\sinto\sthis\sbranch. -D 2024-09-27T11:35:22.006 +C Fix\sa\sproblem\swith\sUPDATEs\sthat\sdo\snot\smodify\sall\sUNINDEXED\scolumns\sof\sa\scontentless_delete=1,\scontentless_unindexed=1\stable. +D 2024-09-27T18:32:52.251 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,8 +100,8 @@ F ext/fts5/fts5_config.c a6633d88596758941c625b526075b85d3d9fd1089d8d9eab5db6e8a F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c 571483823193f09439356741669aa8c81da838ae6f5e1bfa7517f7ee2fb3addd -F ext/fts5/fts5_main.c 853d44c804b6d842f0197002a03ecf482b721834b0bf3d2f1ab3a21e4fd13df5 -F ext/fts5/fts5_storage.c 3b5d743e97502263961e706aedd1000c394ee9df7942ba6671ce4bc41fcf9993 +F ext/fts5/fts5_main.c 4e4a23b76b7ec8d93c6bcad0468d0871cf2d6d270369bfa80d2e1d3a1fc33d92 +F ext/fts5/fts5_storage.c 337b05e4c66fc822d031e264d65bde807ec2fab08665ca2cc8aaf9c5fa06792c F ext/fts5/fts5_tcl.c 4db9258a7882c5eac0da4433042132aaf15b87dd1e1636c7a6ca203abd2c8bfe F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b @@ -248,6 +248,7 @@ F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8d F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae F ext/fts5/test/fts5unindexed2.test 516236eceaac05ace322290a0d3705b4c4ffe4760d8eb9d014d9d27d56dfcc02 F ext/fts5/test/fts5update.test b8affd796e45c94a4d19ad5c26606ea06065a0f162a9562d9f005b5a80ccf0bc +F ext/fts5/test/fts5update2.test 1564d67b209a7d9358c450ecc53b12fcfbf176e865a3d340a31fc603cf3c0c2b F ext/fts5/test/fts5version.test c22d163c17e60a99f022cbc52de5a48bb7f84deaa00fe15e9bc4c3aa1996204e F ext/fts5/test/fts5vocab.test 2a2bdb60d0998fa3124d541b6d30b019504918dc43a6584645b63a24be72f992 F ext/fts5/test/fts5vocab2.test bbba149c254375d00055930c1a501c9a51e80b0d20bf7b98f3e9fa3b03786373 @@ -2216,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cd36d66c88d7282eb0a3ccde5713253f72f5843e451b2693b71adfdae28b41fb 27ef1909bb0c4d9470c6074b40500632c68341127a079a3eb3b6a19dbfb2aeac -R af6ff70b1f29deaae408cb2f001619bf +P 4a26a4e0015bc42b1d007def3750caf7baefe429270a295cc2f4499c98c07247 +R 95c3ae17f3cd6ac697952fa425e027b2 U dan -Z 395c4e3ba81ec86081df96a010608d77 +Z 35986965a22be180ac5ad4eb973f5b34 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9188350703..7207c2799c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4a26a4e0015bc42b1d007def3750caf7baefe429270a295cc2f4499c98c07247 +b6b1db8d343d3e55c3a5589af3ec629762e06c6b689b77defd445347198cb2e7 From 43eafb7b7608257d2263256c6b3bc9c2e31ad35f Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 27 Sep 2024 19:10:54 +0000 Subject: [PATCH 07/77] Fix a problem with UPDATE statements that modify the rowid of contentless_delete=1 tables. FossilOrigin-Name: d69abca82145465c85241a12322986f22bf12ffe42f86c2c8e8e2f2a77d53bf8 --- ext/fts5/fts5_main.c | 4 ++-- ext/fts5/test/fts5update2.test | 21 +++++++++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_main.c b/ext/fts5/fts5_main.c index 4ea727cac2..5713fccdd1 100644 --- a/ext/fts5/fts5_main.c +++ b/ext/fts5/fts5_main.c @@ -2031,10 +2031,10 @@ static int fts5UpdateMethod( rc = sqlite3Fts5StorageContentInsert(pStorage, 0, apVal, pRowid); } if( rc==SQLITE_OK ){ - rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1); + rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 0); } if( rc==SQLITE_OK ){ - rc = sqlite3Fts5StorageIndexInsert(pStorage, apVal,*pRowid); + rc = sqlite3Fts5StorageIndexInsert(pStorage, apVal, *pRowid); } } }else if( bContent ){ diff --git a/ext/fts5/test/fts5update2.test b/ext/fts5/test/fts5update2.test index a402b3cb23..64bc856452 100644 --- a/ext/fts5/test/fts5update2.test +++ b/ext/fts5/test/fts5update2.test @@ -117,6 +117,27 @@ foreach {tn cu} { do_catchsql_test 1.$tn.14 { UPDATE ft1 SET d='d11' WHERE rowid=1 } {1 {cannot UPDATE contentless fts5 table: ft1}} + + # It should be possible to update the rowid if contentless_delete=1 is + # set and all indexed columns are updated. + if {$tn==2} breakpoint + do_execsql_test 1.$tn.15 { + UPDATE ft2 SET a='a_one', d='d_one', rowid=11 WHERE rowid=1 + } + + set res(0) { + 2 {} {} {} {} + 3 {} {} {} {} + 11 {} {} {} {} + } + set res(1) { + 2 {} b2.1.2 c2.2 {} + 3 {} b3 c3.2 {} + 11 {} b1.1.2 c1.2 {} + } + do_execsql_test 1.$tn.16 { + SELECT rowid, * FROM ft2 + } $res($cu) } finish_test diff --git a/manifest b/manifest index 9524da68c3..fbcaee7341 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sUPDATEs\sthat\sdo\snot\smodify\sall\sUNINDEXED\scolumns\sof\sa\scontentless_delete=1,\scontentless_unindexed=1\stable. -D 2024-09-27T18:32:52.251 +C Fix\sa\sproblem\swith\sUPDATE\sstatements\sthat\smodify\sthe\srowid\sof\scontentless_delete=1\stables. +D 2024-09-27T19:10:54.658 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -100,7 +100,7 @@ F ext/fts5/fts5_config.c a6633d88596758941c625b526075b85d3d9fd1089d8d9eab5db6e8a F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 F ext/fts5/fts5_index.c 571483823193f09439356741669aa8c81da838ae6f5e1bfa7517f7ee2fb3addd -F ext/fts5/fts5_main.c 4e4a23b76b7ec8d93c6bcad0468d0871cf2d6d270369bfa80d2e1d3a1fc33d92 +F ext/fts5/fts5_main.c 50eb059e51d730e8e0c77df4e568b018079e112a755c094488b0d5b1aa06afbb F ext/fts5/fts5_storage.c 337b05e4c66fc822d031e264d65bde807ec2fab08665ca2cc8aaf9c5fa06792c F ext/fts5/fts5_tcl.c 4db9258a7882c5eac0da4433042132aaf15b87dd1e1636c7a6ca203abd2c8bfe F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee @@ -248,7 +248,7 @@ F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8d F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae F ext/fts5/test/fts5unindexed2.test 516236eceaac05ace322290a0d3705b4c4ffe4760d8eb9d014d9d27d56dfcc02 F ext/fts5/test/fts5update.test b8affd796e45c94a4d19ad5c26606ea06065a0f162a9562d9f005b5a80ccf0bc -F ext/fts5/test/fts5update2.test 1564d67b209a7d9358c450ecc53b12fcfbf176e865a3d340a31fc603cf3c0c2b +F ext/fts5/test/fts5update2.test 8d201489b3f3fa253bea592ba6c943d49d80d6bdd7ca8002e70005ec89df3f44 F ext/fts5/test/fts5version.test c22d163c17e60a99f022cbc52de5a48bb7f84deaa00fe15e9bc4c3aa1996204e F ext/fts5/test/fts5vocab.test 2a2bdb60d0998fa3124d541b6d30b019504918dc43a6584645b63a24be72f992 F ext/fts5/test/fts5vocab2.test bbba149c254375d00055930c1a501c9a51e80b0d20bf7b98f3e9fa3b03786373 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4a26a4e0015bc42b1d007def3750caf7baefe429270a295cc2f4499c98c07247 -R 95c3ae17f3cd6ac697952fa425e027b2 +P b6b1db8d343d3e55c3a5589af3ec629762e06c6b689b77defd445347198cb2e7 +R acb0bb065c957a3db625bc75e5d80840 U dan -Z 35986965a22be180ac5ad4eb973f5b34 +Z c447109d9b6c39331039c8ac2d02cdb0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7207c2799c..cce3bd5450 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b6b1db8d343d3e55c3a5589af3ec629762e06c6b689b77defd445347198cb2e7 +d69abca82145465c85241a12322986f22bf12ffe42f86c2c8e8e2f2a77d53bf8 From 58b4a8f6e741b31790ce0a4cd7ad6a2b5dfe0b82 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 27 Sep 2024 19:21:09 +0000 Subject: [PATCH 08/77] Extra test cases for UPDATEs of contentless tables. FossilOrigin-Name: 4d11d844de3edd82f022c36381ca7f14a546a608293c329b91e7f041cec82ff5 --- ext/fts5/test/fts5update2.test | 34 +++++++++++++++++++++++++++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/ext/fts5/test/fts5update2.test b/ext/fts5/test/fts5update2.test index 64bc856452..9e5e6c81db 100644 --- a/ext/fts5/test/fts5update2.test +++ b/ext/fts5/test/fts5update2.test @@ -120,7 +120,6 @@ foreach {tn cu} { # It should be possible to update the rowid if contentless_delete=1 is # set and all indexed columns are updated. - if {$tn==2} breakpoint do_execsql_test 1.$tn.15 { UPDATE ft2 SET a='a_one', d='d_one', rowid=11 WHERE rowid=1 } @@ -138,6 +137,39 @@ foreach {tn cu} { do_execsql_test 1.$tn.16 { SELECT rowid, * FROM ft2 } $res($cu) + + # Should not be possible to update the rowid of a contentless_delete=1 + # table if no indexed columns are updated. + do_catchsql_test 1.$tn.17 { + UPDATE ft2 SET rowid=12 WHERE rowid=11 + } {1 {cannot UPDATE a subset of columns on fts5 contentless-delete table: ft2}} + do_catchsql_test 1.$tn.18 { + UPDATE ft1 SET rowid=12 WHERE rowid=1 + } {1 {cannot UPDATE contentless fts5 table: ft1}} + + do_execsql_test 1.$tn.19 { + UPDATE ft2 SET a='a_two', d='d_two', c='newval', rowid=12 WHERE rowid=2 + } {} + + set res(0) { + 3 {} {} {} {} + 11 {} {} {} {} + 12 {} {} {} {} + } + set res(1) { + 3 {} b3 c3.2 {} + 11 {} b1.1.2 c1.2 {} + 12 {} b2.1.2 newval {} + } + do_execsql_test 1.$tn.20 { + SELECT rowid, * FROM ft2 + } $res($cu) + + do_execsql_test 1.$tn.21 { + SELECT rowid, * FROM ft2('a_two AND d_two') + } [lrange $res($cu) 10 end] + + } finish_test diff --git a/manifest b/manifest index fbcaee7341..11bbbe30ca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sUPDATE\sstatements\sthat\smodify\sthe\srowid\sof\scontentless_delete=1\stables. -D 2024-09-27T19:10:54.658 +C Extra\stest\scases\sfor\sUPDATEs\sof\scontentless\stables. +D 2024-09-27T19:21:09.689 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -248,7 +248,7 @@ F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8d F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae F ext/fts5/test/fts5unindexed2.test 516236eceaac05ace322290a0d3705b4c4ffe4760d8eb9d014d9d27d56dfcc02 F ext/fts5/test/fts5update.test b8affd796e45c94a4d19ad5c26606ea06065a0f162a9562d9f005b5a80ccf0bc -F ext/fts5/test/fts5update2.test 8d201489b3f3fa253bea592ba6c943d49d80d6bdd7ca8002e70005ec89df3f44 +F ext/fts5/test/fts5update2.test 1757efae987e6a5a8ac75e3d487fe7be0b8de6006c12f3789fa5d86ee1012706 F ext/fts5/test/fts5version.test c22d163c17e60a99f022cbc52de5a48bb7f84deaa00fe15e9bc4c3aa1996204e F ext/fts5/test/fts5vocab.test 2a2bdb60d0998fa3124d541b6d30b019504918dc43a6584645b63a24be72f992 F ext/fts5/test/fts5vocab2.test bbba149c254375d00055930c1a501c9a51e80b0d20bf7b98f3e9fa3b03786373 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b6b1db8d343d3e55c3a5589af3ec629762e06c6b689b77defd445347198cb2e7 -R acb0bb065c957a3db625bc75e5d80840 +P d69abca82145465c85241a12322986f22bf12ffe42f86c2c8e8e2f2a77d53bf8 +R 817da49217632f1ab83203ed5615b513 U dan -Z c447109d9b6c39331039c8ac2d02cdb0 +Z b50e3f13244bcc732f70d03504469c39 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cce3bd5450..fb8124c66b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d69abca82145465c85241a12322986f22bf12ffe42f86c2c8e8e2f2a77d53bf8 +4d11d844de3edd82f022c36381ca7f14a546a608293c329b91e7f041cec82ff5 From 54e35b543df1c19be47e868e27e46bb312d706c2 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 28 Sep 2024 15:09:43 +0000 Subject: [PATCH 09/77] Add tests for DELETE on contentless, contentless-delete and contentless-unindexed fts5 tables. FossilOrigin-Name: 74832fffb61d5e09ff256622cc9aa1fd2c40d30324c410bd6a8c688f0506a536 --- ext/fts5/test/fts5delete.test | 52 ++++++++++++++++++++++++++++++++++ ext/fts5/test/fts5update2.test | 16 ++++++----- manifest | 14 ++++----- manifest.uuid | 2 +- 4 files changed, 69 insertions(+), 15 deletions(-) diff --git a/ext/fts5/test/fts5delete.test b/ext/fts5/test/fts5delete.test index 1214fec4f4..c9c55e8a4f 100644 --- a/ext/fts5/test/fts5delete.test +++ b/ext/fts5/test/fts5delete.test @@ -113,5 +113,57 @@ do_execsql_test 3.4 { INSERT INTO tx(tx) VALUES('integrity-check'); } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 4.0 { + CREATE VIRTUAL TABLE ft1 USING fts5(a, b UNINDEXED, + content='', contentless_unindexed=1 + ); + CREATE VIRTUAL TABLE ft2 USING fts5(a, b UNINDEXED, + content='', contentless_unindexed=1, contentless_delete=1 + ); + + INSERT INTO ft1(rowid, a, b) VALUES(1, 'one', 'i'); + INSERT INTO ft1(rowid, a, b) VALUES(2, 'two', 'ii'); + INSERT INTO ft1(rowid, a, b) VALUES(3, 'three', 'iii'); + INSERT INTO ft2(rowid, a, b) VALUES(1, 'one', 'i'); + INSERT INTO ft2(rowid, a, b) VALUES(2, 'two', 'ii'); + INSERT INTO ft2(rowid, a, b) VALUES(3, 'three', 'iii'); +} + +do_catchsql_test 4.1 { + DELETE FROM ft1 WHERE rowid=2 +} {1 {cannot DELETE from contentless fts5 table: ft1}} +do_catchsql_test 4.2 { + DELETE FROM ft2 WHERE rowid=2 +} {0 {}} + +do_catchsql_test 4.3 { + INSERT INTO ft1(ft1, rowid, a) VALUES('delete', 2, 'two'); +} {0 {}} +do_catchsql_test 4.2 { + INSERT INTO ft2(ft2, rowid, a) VALUES('delete', 2, 'two'); +} {1 {'delete' may not be used with a contentless_delete=1 table}} + +do_execsql_test 4.3 { + SELECT rowid, * FROM ft1; +} { + 1 {} i + 3 {} iii +} +do_execsql_test 4.4 { + SELECT rowid, * FROM ft2; +} { + 1 {} i + 3 {} iii +} + +do_execsql_test 4.5 { + SELECT * FROM ft1_content +} {1 i 3 iii} +do_execsql_test 4.6 { + SELECT * FROM ft1_content +} {1 i 3 iii} + finish_test diff --git a/ext/fts5/test/fts5update2.test b/ext/fts5/test/fts5update2.test index 9e5e6c81db..d04af4800d 100644 --- a/ext/fts5/test/fts5update2.test +++ b/ext/fts5/test/fts5update2.test @@ -26,6 +26,7 @@ ifcapable !fts5 { # Test that the various types of UPDATE statement are handled correctly # by different table types. # +foreach_detail_mode $testprefix { foreach {tn cu} { 1 0 2 1 @@ -34,11 +35,13 @@ foreach {tn cu} { do_execsql_test 1.$tn.1 " CREATE VIRTUAL TABLE ft1 USING fts5(a, b UNINDEXED, c UNINDEXED, d, content='', - contentless_unindexed=$cu + contentless_unindexed=$cu, + detail=%DETAIL% ); CREATE VIRTUAL TABLE ft2 USING fts5(a, b UNINDEXED, c UNINDEXED, d, content='', - contentless_unindexed=$cu, contentless_delete=1 + contentless_unindexed=$cu, contentless_delete=1, + detail=%DETAIL% ); " @@ -121,7 +124,7 @@ foreach {tn cu} { # It should be possible to update the rowid if contentless_delete=1 is # set and all indexed columns are updated. do_execsql_test 1.$tn.15 { - UPDATE ft2 SET a='a_one', d='d_one', rowid=11 WHERE rowid=1 + UPDATE ft2 SET a='aXone', d='dXone', rowid=11 WHERE rowid=1 } set res(0) { @@ -148,7 +151,7 @@ foreach {tn cu} { } {1 {cannot UPDATE contentless fts5 table: ft1}} do_execsql_test 1.$tn.19 { - UPDATE ft2 SET a='a_two', d='d_two', c='newval', rowid=12 WHERE rowid=2 + UPDATE ft2 SET a='aXtwo', d='dXtwo', c='newval', rowid=12 WHERE rowid=2 } {} set res(0) { @@ -166,10 +169,9 @@ foreach {tn cu} { } $res($cu) do_execsql_test 1.$tn.21 { - SELECT rowid, * FROM ft2('a_two AND d_two') + SELECT rowid, * FROM ft2('aXtwo AND dXtwo') } [lrange $res($cu) 10 end] - -} +}} ;# end of [foreach_detail_mode] loop finish_test diff --git a/manifest b/manifest index 11bbbe30ca..015a187a8e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Extra\stest\scases\sfor\sUPDATEs\sof\scontentless\stables. -D 2024-09-27T19:21:09.689 +C Add\stests\sfor\sDELETE\son\scontentless,\scontentless-delete\sand\scontentless-unindexed\sfts5\stables. +D 2024-09-28T15:09:43.754 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -154,7 +154,7 @@ F ext/fts5/test/fts5corrupt5.test 11b47126f5772cc37b67e3e8b2ed05895c4d07c05338bc F ext/fts5/test/fts5corrupt6.test 2d72db743db7b5d9c9a6d0cfef24d799ed1aa5e8192b66c40e871a37ed9eed06 F ext/fts5/test/fts5corrupt7.test 4e830875c33b9ea3c4cf1ba71e692b63893cbb4faae8c69b1071889dc26e211c F ext/fts5/test/fts5corrupt8.test b81d802e41631e98100f49a1aadeeffef860e30a62d6ed7d743c2797c477239e -F ext/fts5/test/fts5delete.test 619295b20dbc1d840b403ee07c878f52378849c3c02e44f2ee143b3e978a0aa7 +F ext/fts5/test/fts5delete.test e5ad73ce7cda1201b15ead1170f0bc6a2402107b4c2b4e8c8d38c3c7a5140739 F ext/fts5/test/fts5detail.test 54015e9c43ec4ba542cfb93268abdf280e0300f350efd08ee411284b03595cc4 F ext/fts5/test/fts5determin.test 1b77879b2ae818b5b71c859e534ee334dac088b7cf3ff3bf76a2c82b1c788d11 F ext/fts5/test/fts5dlidx.test a7c42b0a74dc7c8aa1a46d586e0aadda4b6cc42c24450f8d3774b21166e93159 @@ -248,7 +248,7 @@ F ext/fts5/test/fts5unicode4.test 728c8f0caafb05567f524ad313d9f8b780fa45987b8a8d F ext/fts5/test/fts5unindexed.test 168838d2c385e131120bbf5b516d2432a5fabc4caa2259c932e1d49ae209a4ae F ext/fts5/test/fts5unindexed2.test 516236eceaac05ace322290a0d3705b4c4ffe4760d8eb9d014d9d27d56dfcc02 F ext/fts5/test/fts5update.test b8affd796e45c94a4d19ad5c26606ea06065a0f162a9562d9f005b5a80ccf0bc -F ext/fts5/test/fts5update2.test 1757efae987e6a5a8ac75e3d487fe7be0b8de6006c12f3789fa5d86ee1012706 +F ext/fts5/test/fts5update2.test c5baa76799ac605ebb8e5e21035db2014b396cef25c903eb96ba39b1d6f9f046 F ext/fts5/test/fts5version.test c22d163c17e60a99f022cbc52de5a48bb7f84deaa00fe15e9bc4c3aa1996204e F ext/fts5/test/fts5vocab.test 2a2bdb60d0998fa3124d541b6d30b019504918dc43a6584645b63a24be72f992 F ext/fts5/test/fts5vocab2.test bbba149c254375d00055930c1a501c9a51e80b0d20bf7b98f3e9fa3b03786373 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d69abca82145465c85241a12322986f22bf12ffe42f86c2c8e8e2f2a77d53bf8 -R 817da49217632f1ab83203ed5615b513 +P 4d11d844de3edd82f022c36381ca7f14a546a608293c329b91e7f041cec82ff5 +R 252b3e37ef138d75d16ca0a09145d26b U dan -Z b50e3f13244bcc732f70d03504469c39 +Z 1c5135e581d8308e18c2303d6757adc4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fb8124c66b..ca318965b4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4d11d844de3edd82f022c36381ca7f14a546a608293c329b91e7f041cec82ff5 +74832fffb61d5e09ff256622cc9aa1fd2c40d30324c410bd6a8c688f0506a536 From d5838eaa42c103649fde3ee1806ff03f7ddece9d Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 30 Sep 2024 17:28:45 +0000 Subject: [PATCH 10/77] In fts5, avoid starting a new merge of level L if there exists already an ongoing merge of a level less than L. FossilOrigin-Name: 350c6e75ce3c1e81458d1baa73045df489284206e8b279ab3c2f5e3d011c262a --- ext/fts5/fts5_index.c | 7 +++- ext/fts5/test/fts5contentless5.test | 56 +++++++++++++++++++++++++++-- manifest | 16 ++++----- manifest.uuid | 2 +- 4 files changed, 69 insertions(+), 12 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 4363305a56..a51ae19e72 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -4889,6 +4889,11 @@ static int fts5IndexFindDeleteMerge(Fts5Index *p, Fts5Structure *pStruct){ nBest = nPercent; } } + + /* If pLvl is already the input level to an ongoing merge, look no + ** further for a merge candidate. The caller should be allowed to + ** continue merging from pLvl first. */ + if( pLvl->nMerge ) break; } } return iRet; @@ -8813,7 +8818,7 @@ static int fts5structConnectMethod( /* ** We must have a single struct=? constraint that will be passed through -** into the xFilter method. If there is no valid stmt=? constraint, +** into the xFilter method. If there is no valid struct=? constraint, ** then return an SQLITE_CONSTRAINT error. */ static int fts5structBestIndexMethod( diff --git a/ext/fts5/test/fts5contentless5.test b/ext/fts5/test/fts5contentless5.test index 3563678868..86d0753286 100644 --- a/ext/fts5/test/fts5contentless5.test +++ b/ext/fts5/test/fts5contentless5.test @@ -35,8 +35,8 @@ do_execsql_test 1.01 { } # explain_i "UPDATE t1 SET a='a' WHERE t1.rowid=1" -breakpoint -explain_i "UPDATE t1 SET a='a' FROM t2 WHERE t1.rowid=1 AND b IS NULL" +#breakpoint +#explain_i "UPDATE t1 SET a='a' FROM t2 WHERE t1.rowid=1 AND b IS NULL" #breakpoint #explain_i "UPDATE t1 SET a='a' WHERE b IS NULL AND rowid=?" @@ -56,4 +56,56 @@ foreach {tn up err} { do_catchsql_test 1.$tn $up $res($err) } +#------------------------------------------------------------------------- +reset_db + +proc random {n} { expr {abs(int(rand()*$n))} } +proc select_one {list} { + set n [llength $list] + lindex $list [random $n] +} +proc vocab {} { + list abc def ghi jkl mno pqr stu vwx yza +} +proc term {} { + select_one [vocab] +} +proc document {} { + set nTerm [expr [random 3] + 7] + set doc "" + for {set ii 0} {$ii < $nTerm} {incr ii} { + lappend doc [term] + } + set doc +} +db func document document + +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE ft USING fts5(a, contentless_delete=1, content=''); + INSERT INTO ft(ft, rank) VALUES('pgsz', 64); +} + +do_test 2.1 { + for {set ii 1} {$ii < 12} {incr ii} { + db transaction { + for {set jj 0} {$jj < 10} {incr jj} { + set doc [document] + execsql { INSERT INTO ft VALUES($doc); } + } + } + } +} {} + +do_test 2.2 { + foreach r [db eval {SELECT rowid FROM ft}] { + execsql { DELETE FROM ft WHERE rowid=$r } + } +} {} + +set doc [document] +do_execsql_test 2.3 { + INSERT INTO ft VALUES($doc) +} + + finish_test diff --git a/manifest b/manifest index 7566dedc21..77ea93c261 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sCLI\sso\sthat\sthe\s--bom\soption\sonly\soutputs\sa\ssingle\sBOM,\snot\stwo. -D 2024-09-28T19:52:38.443 +C In\sfts5,\savoid\sstarting\sa\snew\smerge\sof\slevel\sL\sif\sthere\sexists\salready\san\songoing\smerge\sof\sa\slevel\sless\sthan\sL. +D 2024-09-30T17:28:45.511 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -99,7 +99,7 @@ F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70 F ext/fts5/fts5_config.c da21548ddbc1a457cb42545f527065221ede8ada6a734891b8c34317a7a9506b F ext/fts5/fts5_expr.c 9a56f53700d1860f0ee2f373c2b9074eaf2a7aa0637d0e27a6476de26a3fee33 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1 -F ext/fts5/fts5_index.c 571483823193f09439356741669aa8c81da838ae6f5e1bfa7517f7ee2fb3addd +F ext/fts5/fts5_index.c 368a968570ce12ba40223e284a588d9f93ee23a0133727f0df1fcd64086b1fb6 F ext/fts5/fts5_main.c 4503498d3453e29a3cd89dacaba029011e89cb8c481a6241611d106e7a369bd4 F ext/fts5/fts5_storage.c 3332497823c3d171cf56379f2bd8c971ce15a19aadacff961106462022c92470 F ext/fts5/fts5_tcl.c 4db9258a7882c5eac0da4433042132aaf15b87dd1e1636c7a6ca203abd2c8bfe @@ -145,7 +145,7 @@ F ext/fts5/test/fts5contentless.test 606f063b29ba0f46d4b79aa36cdd1ef4dab5de53eae F ext/fts5/test/fts5contentless2.test 70ffe6c611d8f278240da56734df8a77948f04e2739b358439e9bdcf56ced35f F ext/fts5/test/fts5contentless3.test 75eaae5ad6b284ee447788943974d323228f27cc35a1681da997135cff95bc6a F ext/fts5/test/fts5contentless4.test ec34dc69ef474ca9997dae6d91e072906e0e9a5a4b05ea89964c863833b6eff8 -F ext/fts5/test/fts5contentless5.test 40cdcb4fe751672450829c5a96bd32c25fc2f6076279dd2ce5c58ac9a390132a +F ext/fts5/test/fts5contentless5.test 38cd0392c730dc7090c550321ce3c24ba4c392bc97308b51a4180e9959dca7b5 F ext/fts5/test/fts5corrupt.test 6485f721b88ba355ca5d701e7ee87a4efa3ea578d8e6adb26f51ef956c8328bd F ext/fts5/test/fts5corrupt2.test 335911e3f68b9625d850325f9e29a128db3f4276a8c9d4e32134580da8f924c4 F ext/fts5/test/fts5corrupt3.test 4fc3bf129f1616bea00884a23fd9d7b0e46d01791d2b57fe8d68ac36e8d3ff7c @@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e815055b321085deda8607ac3279ef1a1c890fe3bf9d9b9c0a74028e87857a7d -R c0b23dfcab02e83590bbedcac610fa7b -U drh -Z 5a1528ca859870969ffba6e26496a443 +P 76b6331e6a705a420a64820a18214f07cf4c1d5151e7158d6fff09964e63f352 +R af602edd5730d15273eb424f12f293da +U dan +Z 7c2ca47bd5a0ad794a2bc7691bf0167e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f56b36fa0b..35fff3b926 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -76b6331e6a705a420a64820a18214f07cf4c1d5151e7158d6fff09964e63f352 +350c6e75ce3c1e81458d1baa73045df489284206e8b279ab3c2f5e3d011c262a From cacef23082b8c60a7c211821a1d679bd25348a1e Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 30 Sep 2024 18:19:38 +0000 Subject: [PATCH 11/77] Fix the character width tables for the CLI such that all unicode code-points less than 0x300 have a width of 1. This is in fact the case for Mac, Ubuntu, and Windows. FossilOrigin-Name: f0c5a86fefecded07e098e1326dd54c72504b0bb480f710e395d4041a322dfcb --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c.in | 5 +---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 77ea93c261..cd4363196a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sfts5,\savoid\sstarting\sa\snew\smerge\sof\slevel\sL\sif\sthere\sexists\salready\san\songoing\smerge\sof\sa\slevel\sless\sthan\sL. -D 2024-09-30T17:28:45.511 +C Fix\sthe\scharacter\swidth\stables\sfor\sthe\sCLI\ssuch\sthat\sall\sunicode\scode-points\nless\sthan\s0x300\shave\sa\swidth\sof\s1.\s\sThis\sis\sin\sfact\sthe\scase\sfor\sMac,\sUbuntu,\nand\sWindows. +D 2024-09-30T18:19:38.492 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -768,7 +768,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9750a281f7ba073b4e6da2be1a6c4071f5d841a7746c5fb3f70d6d793b6675ea F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in 345173187067363374187176a8bbe779e359849e635d8288202000ee87f4405a +F src/shell.c.in d71d2463459e6cd9c2f2d702545aed5113ffbcea963c19c1e6d3a6d762ef959c F src/sqlite.h.in b20547021d20ba016c2fd0500f14f08a21ff23e64a0ed93e72ca0fecb9e1d0a0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 76b6331e6a705a420a64820a18214f07cf4c1d5151e7158d6fff09964e63f352 -R af602edd5730d15273eb424f12f293da -U dan -Z 7c2ca47bd5a0ad794a2bc7691bf0167e +P 350c6e75ce3c1e81458d1baa73045df489284206e8b279ab3c2f5e3d011c262a +R 196058ccce20b5d040ef28c3115701ff +U drh +Z c9a58ad028df05647dcb5802e9848199 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 35fff3b926..4742ec1d1d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -350c6e75ce3c1e81458d1baa73045df489284206e8b279ab3c2f5e3d011c262a +f0c5a86fefecded07e098e1326dd54c72504b0bb480f710e395d4041a322dfcb diff --git a/src/shell.c.in b/src/shell.c.in index d1fc6aa748..35b9b089fa 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -631,7 +631,7 @@ static const struct { unsigned char w; /* Width of the character in columns */ int iFirst; /* First character in a span having this width */ } aUWidth[] = { - /* {0, 0x00000}, {1, 0x00020}, {0, 0x0007f}, {1, 0x000a0}, */ + /* {1, 0x00000}, */ {0, 0x00300}, {1, 0x00370}, {0, 0x00483}, {1, 0x00487}, {0, 0x00488}, {1, 0x0048a}, {0, 0x00591}, {1, 0x005be}, {0, 0x005bf}, {1, 0x005c0}, {0, 0x005c1}, {1, 0x005c3}, {0, 0x005c4}, {1, 0x005c6}, {0, 0x005c7}, @@ -709,9 +709,6 @@ int cli_wcwidth(int c){ int iFirst, iLast; /* Fast path for common characters */ - if( c<0x20 ) return 0; - if( c<0x7f ) return 1; - if( c<0xa0 ) return 0; if( c<=0x300 ) return 1; /* The general case */ From ed94e0e6778ca00db96690fe93820436cf2676d2 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 1 Oct 2024 10:49:30 +0000 Subject: [PATCH 12/77] Add an #if'd-out block to sqlite3-wasm.c mentioning the LONGDOUBLE_TYPE, as brought up in [forum:cbfb0d0ac0a4e349 | forum post cbfb0d0ac]. No functional changes. FossilOrigin-Name: 0b83e8f1ef53b35a9dda0740b4922b8691428f7484f3058833a961f3f8d0b178 --- ext/wasm/api/sqlite3-wasm.c | 15 +++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index c5dd495e54..1c46b0ec05 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -221,6 +221,21 @@ // See also: //__attribute__((export_name("theExportedName"), used, visibility("default"))) +#if 0 +/* Details at https://sqlite.org/forum/forumpost/cbfb0d0ac0a4e349 +** +** Summary: changing to `double` reduces the wasm file size by a mere +** 2k. It is hypothetically not possible that any clients rely on +** doubles larger than 64-bit because there is no mapping between C +** and JS for them. i.e. we "could" switch LONGDOUBLE_TYPE to double +** for wasm builds with very little risk of problems. Clang 18.1 maps +** `long double` to float128 but Emscripten doesn't (cannot) expose +** that to JS. +*/ +#undef LONGDOUBLE_TYPE +#define LONGDOUBLE_TYPE double +#endif + /* ** Which sqlite3.c we're using needs to be configurable to enable ** building against a custom copy, e.g. the SEE variant. Note that we diff --git a/manifest b/manifest index cd4363196a..77242f8aca 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\scharacter\swidth\stables\sfor\sthe\sCLI\ssuch\sthat\sall\sunicode\scode-points\nless\sthan\s0x300\shave\sa\swidth\sof\s1.\s\sThis\sis\sin\sfact\sthe\scase\sfor\sMac,\sUbuntu,\nand\sWindows. -D 2024-09-30T18:19:38.492 +C Add\san\s#if'd-out\sblock\sto\ssqlite3-wasm.c\smentioning\sthe\sLONGDOUBLE_TYPE,\sas\sbrought\sup\sin\s[forum:cbfb0d0ac0a4e349\s|\sforum\spost\scbfb0d0ac].\sNo\sfunctional\schanges. +D 2024-10-01T10:49:30.088 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -632,7 +632,7 @@ F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e529a99b7d5a088284821e2902b20d3404b561126969876997d5a73a656c9199 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e99e3d99f736937914527070f00ab13e9391d3f1cef884ab99a64cbcbee8d675 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 -F ext/wasm/api/sqlite3-wasm.c 83f5e9f998e9fa4261eb84e9f092210e3ffe03895119f5ded0429eb34ab9d2be +F ext/wasm/api/sqlite3-wasm.c e94665e6625c8b35113cf0eb7dec7acc2d9ed76eed78b3a1abf6cae5ad8097d3 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 350c6e75ce3c1e81458d1baa73045df489284206e8b279ab3c2f5e3d011c262a -R 196058ccce20b5d040ef28c3115701ff -U drh -Z c9a58ad028df05647dcb5802e9848199 +P f0c5a86fefecded07e098e1326dd54c72504b0bb480f710e395d4041a322dfcb +R 95713aa430bd45b55e204d70dfdb0e42 +U stephan +Z 75aa095723616959401f433a579dd985 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4742ec1d1d..f0f46579dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f0c5a86fefecded07e098e1326dd54c72504b0bb480f710e395d4041a322dfcb +0b83e8f1ef53b35a9dda0740b4922b8691428f7484f3058833a961f3f8d0b178 From dac22f656646db9b9429d13c7fcd0a20d6b8a9d6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 1 Oct 2024 16:55:30 +0000 Subject: [PATCH 13/77] Add compile-time option -DSQLITE_USE_LONG_DOUBLE=0 to omit all attempts to use "long double". Or =1 to omit attempts to use the Dekker algorithms to achieve high-resolution floating point. FossilOrigin-Name: ca5964ef70efad3332e0bf9c158eb5fd5006d3022051d1ac506c097c427735a1 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/main.c | 15 ++++++++++----- src/sqliteInt.h | 35 +++++++++++++++++++++++++++++++++++ src/util.c | 4 ++-- src/vdbeaux.c | 2 +- 6 files changed, 59 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 77242f8aca..38a8eea1a6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\s#if'd-out\sblock\sto\ssqlite3-wasm.c\smentioning\sthe\sLONGDOUBLE_TYPE,\sas\sbrought\sup\sin\s[forum:cbfb0d0ac0a4e349\s|\sforum\spost\scbfb0d0ac].\sNo\sfunctional\schanges. -D 2024-10-01T10:49:30.088 +C Add\scompile-time\soption\s-DSQLITE_USE_LONG_DOUBLE=0\sto\somit\sall\sattempts\sto\suse\n"long\sdouble".\s\sOr\s=1\sto\somit\sattempts\sto\suse\sthe\sDekker\salgorithms\sto\sachieve\nhigh-resolution\sfloating\spoint. +D 2024-10-01T16:55:30.223 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -730,7 +730,7 @@ F src/insert.c f8d1a0f8ee258411009c6b7f2d93170e351bd19f5ad89d57e1180644297cbe70 F src/json.c 68a98c020c22127f2d65f08855f7fc7460ff352a6ce0b543d8931dde83319c22 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 -F src/main.c 4db6e3bde55ba0b24ccc83600c2b6ea11429f61ce7b3a2e7e3b42e1b45366c3e +F src/main.c 651be111d1fc05dae62d31cc41335748c27c67455cf777a2d7f48ce1fef585f6 F src/malloc.c 410e570b30c26cc36e3372577df50f7a96ee3eed5b2b161c6b6b48773c650c5e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 @@ -772,7 +772,7 @@ F src/shell.c.in d71d2463459e6cd9c2f2d702545aed5113ffbcea963c19c1e6d3a6d762ef959 F src/sqlite.h.in b20547021d20ba016c2fd0500f14f08a21ff23e64a0ed93e72ca0fecb9e1d0a0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 5978cbb11becc3ce6471015d770d95f694ece06336c496f691df1b02460e9cd5 +F src/sqliteInt.h e4940181e20f67b23b7e1b43807ceb3a9cdb38860225de3d5df7eea37bbe6651 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -835,13 +835,13 @@ F src/trigger.c 0bb986a5b96047fd597c6aac28588853df56064e576e6b81ba777ef2ccaac461 F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 F src/utf.c 7bc550af6f3ddd5f5dc82d092c41f728acb760c92e0b47f391963b01ae52569b -F src/util.c 5d1a0134cf4240648d1c6bb5cc8efaca0ea2b5d5c840985aec7e947271f04375 +F src/util.c ae41aadb960cb15d17e8bb9ec0ebb514e1f7ead773ae9fba281ed67c4d240c48 F src/vacuum.c b763b6457bd058d2072ef9364832351fd8d11e8abf70cbb349657360f7d55c40 F src/vdbe.c be5f58bc29f60252e041a618eae59e8d57d460ba136c5403cf0abf955560c457 F src/vdbe.h c2549a215898a390de6669cfa32adba56f0d7e17ba5a7f7b14506d6fd5f0c36a F src/vdbeInt.h af7d7e8291edd0b19f2cd698e60e4d4031078f9a2f2328ac8f0b7efb134f8a1d F src/vdbeapi.c 53c7e26a2c0821a892b20eee2cde4656e31998212f3d515576c780dfaa45fd17 -F src/vdbeaux.c 676dbee99b4febdd94bc9658667a2e3bc413c4c0e356242d90f98a1155d513e5 +F src/vdbeaux.c aa1bd97dc53406c26619b847f4c7f4f0137ee8c7ba9b266f93351e06aefb522e F src/vdbeblob.c 255be187436da38b01f276c02e6a08103489bbe2a7c6c21537b7aecbe0e1f797 F src/vdbemem.c df568ef0187e4be2788c35174f6d9b8566ab9475f9aff2d73907ed05aa5684b2 F src/vdbesort.c d0a3c7056c081703c8b6d91ad60f17da5e062a5c64bf568ed0fa1b5f4cae311f @@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f0c5a86fefecded07e098e1326dd54c72504b0bb480f710e395d4041a322dfcb -R 95713aa430bd45b55e204d70dfdb0e42 -U stephan -Z 75aa095723616959401f433a579dd985 +P 0b83e8f1ef53b35a9dda0740b4922b8691428f7484f3058833a961f3f8d0b178 +R 1afae59e0efb08982f93adc40d14c2a9 +U drh +Z 56bb71650eaf744de022c729aea7d991 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f0f46579dc..72b7e4100f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0b83e8f1ef53b35a9dda0740b4922b8691428f7484f3058833a961f3f8d0b178 +ca5964ef70efad3332e0bf9c158eb5fd5006d3022051d1ac506c097c427735a1 diff --git a/src/main.c b/src/main.c index 6ab09c5560..bd0cbc731a 100644 --- a/src/main.c +++ b/src/main.c @@ -159,6 +159,7 @@ char *sqlite3_temp_directory = 0; */ char *sqlite3_data_directory = 0; +#if !defined(SQLITE_OMIT_WSD) && !defined(SQLITE_USE_LONG_DOUBLE) /* ** Determine whether or not high-precision (long double) floating point ** math works correctly on CPU currently running. @@ -183,7 +184,7 @@ static SQLITE_NOINLINE int hasHighPrecisionDouble(int rc){ return b!=c; } } - +#endif /* !SQLITE_OMIT_WSD && !SQLITE_USE_LONG_DOUBLE */ /* ** Initialize SQLite. @@ -380,9 +381,7 @@ int sqlite3_initialize(void){ } #endif - /* Experimentally determine if high-precision floating point is - ** available. */ -#ifndef SQLITE_OMIT_WSD +#if !defined(SQLITE_OMIT_WSD) && !defined(SQLITE_USE_LONG_DOUBLE) sqlite3Config.bUseLongDouble = hasHighPrecisionDouble(rc); #endif @@ -4645,12 +4644,18 @@ int sqlite3_test_control(int op, ...){ ** X==0 Disable bUseLongDouble ** X==1 Enable bUseLongDouble ** X>=2 Set bUseLongDouble to its default value for this platform + ** + ** If the SQLITE_USE_LONG_DOUBLE compile-time option has been used, then + ** the bUseLongDouble setting is fixed. This test-control becomes a + ** no-op, except that it still reports the fixed setting. */ case SQLITE_TESTCTRL_USELONGDOUBLE: { +#if !defined(SQLITE_USE_LONG_DOUBLE) int b = va_arg(ap, int); if( b>=2 ) b = hasHighPrecisionDouble(b); if( b>=0 ) sqlite3Config.bUseLongDouble = b>0; - rc = sqlite3Config.bUseLongDouble!=0; +#endif + rc = SqliteUseLongDouble!=0; break; } #endif diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 604f7e975e..5b166d9a36 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4249,6 +4249,41 @@ typedef struct { # define Tuning(X) 0 #endif +/* By default, SQLite will use long double if the long double type +** actually provides higher resolution than double. This use or non-use +** of long double is switchable at run-time by a test-control. Dekker +** algorithms are used for high-precision floating point when long double +** is not available. +** +** Having the run-time option to enable/disable long double support +** causes problems for some compiler tool chains. So the following +** compile-time option is available to permanently enable/disable the use +** of long double. +** +** -DSQLITE_USE_LONG_DOUBLE=0 Omit all use of "long double" from +** the code. Instead, the Dekker algorithm +** is always used when high-precision +** floating point is required. +** +** -DSQLITE_USE_LONG_DOUBLE=1 Always use long double when high +** precision is needed. Never fall back +** to using Dekker algorithms. +** +** If the SQLITE_USE_LONG_DOUBLE macro is not defined, then the determination +** of whether or not to use long double is made at run-time. +*/ +#ifndef SQLITE_USE_LONG_DOUBLE +# define SqliteUseLongDouble sqlite3Config.bUseLongDouble +#elif SQLITE_USE_LONG_DOUBLE+0==1 +# define SqliteUseLongDouble 1 +#elif SQLITE_USE_LONG_DOUBLE+0==0 +# undef LONGDOUBLE_TYPE +# define LONGDOUBLE_TYPE double +# define SqliteUseLongDouble 0 +#else +# error "SQLITE_USE_LONG_DOUBLE should be set to either 0 or 1" +#endif + /* ** Structure containing global configuration data for the SQLite library. ** diff --git a/src/util.c b/src/util.c index 0cebb474a2..7a82ce81bf 100644 --- a/src/util.c +++ b/src/util.c @@ -652,7 +652,7 @@ do_atof_calc: if( e==0 ){ *pResult = s; - }else if( sqlite3Config.bUseLongDouble ){ + }else if( SqliteUseLongDouble ){ LONGDOUBLE_TYPE r = (LONGDOUBLE_TYPE)s; if( e>0 ){ while( e>=100 ){ e-=100; r *= 1.0e+100L; } @@ -1063,7 +1063,7 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){ /* Multiply r by powers of ten until it lands somewhere in between ** 1.0e+19 and 1.0e+17. */ - if( sqlite3Config.bUseLongDouble ){ + if( SqliteUseLongDouble ){ LONGDOUBLE_TYPE rr = r; if( rr>=1.0e+19 ){ while( rr>=1.0e+119L ){ exp+=100; rr *= 1.0e-100L; } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index a66bdecffb..929190b3af 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -4528,7 +4528,7 @@ int sqlite3IntFloatCompare(i64 i, double r){ ** than NULL */ return 1; } - if( sqlite3Config.bUseLongDouble ){ + if( SqliteUseLongDouble ){ LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i; testcase( xr ); From c9c1b65698ed3fa83985c92e02dd872b56948f79 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 1 Oct 2024 17:08:23 +0000 Subject: [PATCH 14/77] Use the new SQLITE_USE_LONG_DOUBLE to disable long-double support in WASM builds, as they cannot be represented in JS and this saves approximately 5.5kb in the resulting wasm file. FossilOrigin-Name: fa7b56f776b715d061581fad6f04b871504ff5d808e7364419d1d6cdef82c5ee --- ext/wasm/GNUmakefile | 2 ++ ext/wasm/api/sqlite3-wasm.c | 6 ++++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 2602e6b792..a68f813d6b 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -239,6 +239,7 @@ SQLITE_OPT.common := \ '-DSQLITE_DEFAULT_UNIX_VFS="unix-none"' \ -DSQLITE_USE_URI=1 \ -DSQLITE_C=$(sqlite3.c) \ + -DSQLITE_USE_LONG_DOUBLE=0 \ -DSQLITE_OMIT_DEPRECATED \ -DSQLITE_OMIT_UTF16 \ -DSQLITE_OMIT_LOAD_EXTENSION \ @@ -251,6 +252,7 @@ SQLITE_OPT.common := \ # to be able to run without this: SQLITE_OPT.common += -DSQLITE_WASM_ENABLE_C_TESTS +# Extra flags for full-featured builds... SQLITE_OPT.full-featured := \ -DSQLITE_ENABLE_BYTECODE_VTAB \ -DSQLITE_ENABLE_DBPAGE_VTAB \ diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index 1c46b0ec05..945acd23dd 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -127,6 +127,10 @@ # define SQLITE_USE_URI 1 #endif +#ifndef SQLITE_USE_LONG_DOUBLE +# define SQLITE_USE_LONG_DOUBLE 0 +#endif + #ifdef SQLITE_WASM_EXTRA_INIT # define SQLITE_EXTRA_INIT sqlite3_wasm_extra_init #endif @@ -159,6 +163,8 @@ # define SQLITE_OMIT_PROGRESS_CALLBACK # undef SQLITE_OMIT_WAL # define SQLITE_OMIT_WAL +# undef SQLITE_USE_LONG_DOUBLE +# define SQLITE_USE_LONG_DOUBLE 0 /* The following OMITs do not work with the standard amalgamation, so require a custom build: diff --git a/manifest b/manifest index 38a8eea1a6..037e9a4724 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\scompile-time\soption\s-DSQLITE_USE_LONG_DOUBLE=0\sto\somit\sall\sattempts\sto\suse\n"long\sdouble".\s\sOr\s=1\sto\somit\sattempts\sto\suse\sthe\sDekker\salgorithms\sto\sachieve\nhigh-resolution\sfloating\spoint. -D 2024-10-01T16:55:30.223 +C Use\sthe\snew\sSQLITE_USE_LONG_DOUBLE\sto\sdisable\slong-double\ssupport\sin\sWASM\sbuilds,\sas\sthey\scannot\sbe\srepresented\sin\sJS\sand\sthis\ssaves\sapproximately\s5.5kb\sin\sthe\sresulting\swasm\sfile. +D 2024-10-01T17:08:23.912 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -603,7 +603,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile 6b94c3125c40932e71bbe46e582d24ed4c829b9fa2ff34dd842b0ed8a948ac6a +F ext/wasm/GNUmakefile c2ee5993e727dd2c1f0f784f47843fb7af45cebd23626b537bae2d2d8f4a3abd F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -632,7 +632,7 @@ F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e529a99b7d5a088284821e2902b20d3404b561126969876997d5a73a656c9199 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e99e3d99f736937914527070f00ab13e9391d3f1cef884ab99a64cbcbee8d675 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 -F ext/wasm/api/sqlite3-wasm.c e94665e6625c8b35113cf0eb7dec7acc2d9ed76eed78b3a1abf6cae5ad8097d3 +F ext/wasm/api/sqlite3-wasm.c 2ac6cff59668eed42a87b8b21ff66f0edf82b25c04bbb8adda0c4eff28ed11ce F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0b83e8f1ef53b35a9dda0740b4922b8691428f7484f3058833a961f3f8d0b178 -R 1afae59e0efb08982f93adc40d14c2a9 -U drh -Z 56bb71650eaf744de022c729aea7d991 +P ca5964ef70efad3332e0bf9c158eb5fd5006d3022051d1ac506c097c427735a1 +R 7b5589656a320d55088e87a9d21d3695 +U stephan +Z b3281d7ec085a9e7d4c5e83e25b26b8b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 72b7e4100f..7113b4ff6a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ca5964ef70efad3332e0bf9c158eb5fd5006d3022051d1ac506c097c427735a1 +fa7b56f776b715d061581fad6f04b871504ff5d808e7364419d1d6cdef82c5ee From 1f2faa647f32b4182c43156f5107a59574647104 Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 1 Oct 2024 17:57:55 +0000 Subject: [PATCH 15/77] Another comment about the LONGDOUBLE wasm topic. No code changes. FossilOrigin-Name: 1755831cb1ac58241e0b11d8d003b5eca39b65aa3cb84229b215662028b1b3c0 --- ext/wasm/api/sqlite3-wasm.c | 2 ++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index 945acd23dd..b689b426fb 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -237,6 +237,8 @@ ** for wasm builds with very little risk of problems. Clang 18.1 maps ** `long double` to float128 but Emscripten doesn't (cannot) expose ** that to JS. +** +** See also: SQLITE_USE_LONG_DOUBLE */ #undef LONGDOUBLE_TYPE #define LONGDOUBLE_TYPE double diff --git a/manifest b/manifest index 037e9a4724..65c7f28e25 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sthe\snew\sSQLITE_USE_LONG_DOUBLE\sto\sdisable\slong-double\ssupport\sin\sWASM\sbuilds,\sas\sthey\scannot\sbe\srepresented\sin\sJS\sand\sthis\ssaves\sapproximately\s5.5kb\sin\sthe\sresulting\swasm\sfile. -D 2024-10-01T17:08:23.912 +C Another\scomment\sabout\sthe\sLONGDOUBLE\swasm\stopic.\sNo\scode\schanges. +D 2024-10-01T17:57:55.467 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -632,7 +632,7 @@ F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e529a99b7d5a088284821e2902b20d3404b561126969876997d5a73a656c9199 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e99e3d99f736937914527070f00ab13e9391d3f1cef884ab99a64cbcbee8d675 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 -F ext/wasm/api/sqlite3-wasm.c 2ac6cff59668eed42a87b8b21ff66f0edf82b25c04bbb8adda0c4eff28ed11ce +F ext/wasm/api/sqlite3-wasm.c 2d4340f2dacd9119e95c470d9c4f392e399feffc292962b855f0a67ffb0fc418 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ca5964ef70efad3332e0bf9c158eb5fd5006d3022051d1ac506c097c427735a1 -R 7b5589656a320d55088e87a9d21d3695 +P fa7b56f776b715d061581fad6f04b871504ff5d808e7364419d1d6cdef82c5ee +R f9afa03cdf9385554f9061800ab5a24b U stephan -Z b3281d7ec085a9e7d4c5e83e25b26b8b +Z 7a6ac00554cffba6a7d224734b670d11 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7113b4ff6a..d4c262a19a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fa7b56f776b715d061581fad6f04b871504ff5d808e7364419d1d6cdef82c5ee +1755831cb1ac58241e0b11d8d003b5eca39b65aa3cb84229b215662028b1b3c0 From 7151010919cff7ab5134173f5d22fdf534104c34 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 1 Oct 2024 19:10:47 +0000 Subject: [PATCH 16/77] New #ifdefs to omit code that is unused when SQLITE_USE_LONG DOUBLE is defined. FossilOrigin-Name: 98066e2d226e7d2eceec1931a1432baea956f49bf3c708d8a6d511fa4e864ca3 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/util.c | 4 ++++ src/vdbeaux.c | 6 +++++- test/speedtest1.c | 12 +++++++++--- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 65c7f28e25..ac49e358bf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Another\scomment\sabout\sthe\sLONGDOUBLE\swasm\stopic.\sNo\scode\schanges. -D 2024-10-01T17:57:55.467 +C New\s#ifdefs\sto\somit\scode\sthat\sis\sunused\swhen\sSQLITE_USE_LONG\sDOUBLE\sis\sdefined. +D 2024-10-01T19:10:47.855 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -835,13 +835,13 @@ F src/trigger.c 0bb986a5b96047fd597c6aac28588853df56064e576e6b81ba777ef2ccaac461 F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 F src/utf.c 7bc550af6f3ddd5f5dc82d092c41f728acb760c92e0b47f391963b01ae52569b -F src/util.c ae41aadb960cb15d17e8bb9ec0ebb514e1f7ead773ae9fba281ed67c4d240c48 +F src/util.c aea7987484ec05764eabdd63b55eb63ea85cfb5b95dde70a667711c1d326f1a7 F src/vacuum.c b763b6457bd058d2072ef9364832351fd8d11e8abf70cbb349657360f7d55c40 F src/vdbe.c be5f58bc29f60252e041a618eae59e8d57d460ba136c5403cf0abf955560c457 F src/vdbe.h c2549a215898a390de6669cfa32adba56f0d7e17ba5a7f7b14506d6fd5f0c36a F src/vdbeInt.h af7d7e8291edd0b19f2cd698e60e4d4031078f9a2f2328ac8f0b7efb134f8a1d F src/vdbeapi.c 53c7e26a2c0821a892b20eee2cde4656e31998212f3d515576c780dfaa45fd17 -F src/vdbeaux.c aa1bd97dc53406c26619b847f4c7f4f0137ee8c7ba9b266f93351e06aefb522e +F src/vdbeaux.c a30204ae8820ee5165736c2e67fe9b62ad47690c72248b4adba0435b0b3f8bfe F src/vdbeblob.c 255be187436da38b01f276c02e6a08103489bbe2a7c6c21537b7aecbe0e1f797 F src/vdbemem.c df568ef0187e4be2788c35174f6d9b8566ab9475f9aff2d73907ed05aa5684b2 F src/vdbesort.c d0a3c7056c081703c8b6d91ad60f17da5e062a5c64bf568ed0fa1b5f4cae311f @@ -1668,7 +1668,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c -F test/speedtest1.c 19c9b60908d25502d2831f97efee8b81006c356ab8c08327e25d24a4144f2131 +F test/speedtest1.c 82f273f6df420bb1563d5202277e4a907e4e032a96a86fa7cf8c7aed34b32724 F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fa7b56f776b715d061581fad6f04b871504ff5d808e7364419d1d6cdef82c5ee -R f9afa03cdf9385554f9061800ab5a24b -U stephan -Z 7a6ac00554cffba6a7d224734b670d11 +P 1755831cb1ac58241e0b11d8d003b5eca39b65aa3cb84229b215662028b1b3c0 +R aec30d14f5d302123caffa8ac548b88e +U drh +Z 3d8c02a9a1123f16b58018bc4d458ba9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d4c262a19a..19cf9165e2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1755831cb1ac58241e0b11d8d003b5eca39b65aa3cb84229b215662028b1b3c0 +98066e2d226e7d2eceec1931a1432baea956f49bf3c708d8a6d511fa4e864ca3 diff --git a/src/util.c b/src/util.c index 7a82ce81bf..6725306eda 100644 --- a/src/util.c +++ b/src/util.c @@ -458,6 +458,7 @@ u8 sqlite3StrIHash(const char *z){ return h; } +#if !defined(SQLITE_USE_LONG_DOUBLE) || SQLITE_USE_LONG_DOUBLE+0==0 /* Double-Double multiplication. (x[0],x[1]) *= (y,yy) ** ** Reference: @@ -493,6 +494,9 @@ static void dekkerMul2(volatile double *x, double y, double yy){ x[1] = c - x[0]; x[1] += cc; } +#else +# define dekkerMul2(A,B,C) /* No-op if SqliteUseLongDouble is always true */ +#endif /* ** The string z[] is an text representation of a real number. diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 929190b3af..5ff4ca928c 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -4512,9 +4512,13 @@ SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){ ** We must use separate SQLITE_NOINLINE functions here, since otherwise ** optimizer code movement causes gcov to become very confused. */ -#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG) +#if (defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG)) \ + && (!defined(SQLITE_USE_LONG_DOUBLE) || SQLITE_USE_LONG_DOUBLE+0==0) static int SQLITE_NOINLINE doubleLt(double a, double b){ return a=0 ){ + sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, useLongDouble); + } +#endif if( g.nReserve>0 ){ sqlite3_file_control(g.db, 0, SQLITE_FCNTL_RESERVE_BYTES, &g.nReserve); } From e8b2c92240388cad4d41e83a7383b179b7a78acd Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 1 Oct 2024 20:29:43 +0000 Subject: [PATCH 17/77] Remove all code that makes use of the C-language "long double" datatype. FossilOrigin-Name: f622b52024c8bec1d241b1dc480fbbd839fc1af50b6220f012812503de2c656e --- manifest | 45 +++++----- manifest.uuid | 2 +- src/global.c | 1 - src/main.c | 56 ------------ src/shell.c.in | 16 ---- src/sqlite.h.in | 2 +- src/sqliteInt.h | 40 --------- src/test1.c | 35 -------- src/test_config.c | 4 - src/util.c | 181 +++++++++++++++------------------------ src/vdbeaux.c | 13 +-- test/atof1.test | 2 +- test/cast.test | 30 +++---- test/fp-speed-1.c | 10 --- test/func4.test | 2 +- test/speedtest1.c | 11 --- test/testrunner_data.tcl | 2 - tool/speed-check.sh | 3 - 18 files changed, 109 insertions(+), 346 deletions(-) diff --git a/manifest b/manifest index ac49e358bf..6f37d1934e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C New\s#ifdefs\sto\somit\scode\sthat\sis\sunused\swhen\sSQLITE_USE_LONG\sDOUBLE\sis\sdefined. -D 2024-10-01T19:10:47.855 +C Remove\sall\scode\sthat\smakes\suse\sof\sthe\sC-language\s"long\sdouble"\sdatatype. +D 2024-10-01T20:29:43.065 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -721,7 +721,7 @@ F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f F src/func.c df400a1d3f4625997d4dd8a81951c303e066277c29b861d37e03cd152d7858dd -F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90 +F src/global.c a19e4b1ca1335f560e9560e590fc13081e21f670643367f99cb9e8f9dc7d615b F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 @@ -730,7 +730,7 @@ F src/insert.c f8d1a0f8ee258411009c6b7f2d93170e351bd19f5ad89d57e1180644297cbe70 F src/json.c 68a98c020c22127f2d65f08855f7fc7460ff352a6ce0b543d8931dde83319c22 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36 -F src/main.c 651be111d1fc05dae62d31cc41335748c27c67455cf777a2d7f48ce1fef585f6 +F src/main.c e42b9134800a577060e4cd325ddf88c289a99ed57519553ad3465c1080a4d6d6 F src/malloc.c 410e570b30c26cc36e3372577df50f7a96ee3eed5b2b161c6b6b48773c650c5e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2 @@ -768,17 +768,17 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 9750a281f7ba073b4e6da2be1a6c4071f5d841a7746c5fb3f70d6d793b6675ea F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in d71d2463459e6cd9c2f2d702545aed5113ffbcea963c19c1e6d3a6d762ef959c -F src/sqlite.h.in b20547021d20ba016c2fd0500f14f08a21ff23e64a0ed93e72ca0fecb9e1d0a0 +F src/shell.c.in 981efe98f98a983c1d0193d18528eb2d765207c0c82b67b610be60f17995a43e +F src/sqlite.h.in 29bd29520f8dad4754f8d9a195edd5ec2598d2d3b1e9085a25d01697f70545c0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h e4940181e20f67b23b7e1b43807ceb3a9cdb38860225de3d5df7eea37bbe6651 +F src/sqliteInt.h 6ffd984ac04b5cfbe03f985a79d4664fe40be1198482add1c3de1137a8d9b86f F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 F src/tclsqlite.c c6888598f08dee3d9112a38ef42c8f5c89ca7f3190f4694744d0b84250f4bf8c F src/tclsqlite.h c6af51f31a2b2172d674608763a4b98fdf5cd587e4025053e546fb8077757262 -F src/test1.c 8d7cd219c004cd2ced60659ebf045025cc5c16ce19d12459589dacd4310f7f07 +F src/test1.c 8bf8b74145b768f42386787f93f6d6dad7bc400a4ee2d50e4ad5a06a20a97ef1 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 F src/test3.c e7573aa0f78ee4e070a4bc8c3493941c1aa64d5c66d4825c74c0f055451f432b F src/test4.c 13e57ae7ec7a959ee180970aef09deed141252fe9bb07c61054f0dfa4f1dfd5d @@ -792,7 +792,7 @@ F src/test_backup.c bd901e3c116c7f3b3bbbd4aae4ce87d99b400c9cbb0a9e7b4610af451d97 F src/test_bestindex.c 3401bee51665cbf7f9ed2552b5795452a8b86365e4c9ece745b54155a55670c6 F src/test_blob.c bcdf6a6c22d0bcc13c41479d63692ef413add2a4d30e1e26b9f74ab85b9fb4d5 F src/test_btree.c 28283787d32b8fa953eb77412ad0de2c9895260e4e5bd5a94b3c7411664f90d5 -F src/test_config.c 345b8e383f71cecc36d0fa05f2f06639c254b188f98101c3c97749df43037086 +F src/test_config.c e8d041a84151cbaee4dd82eb32e4153abe06856bcfab4771968a8cf930a86332 F src/test_delete.c e2fe07646dff6300b48d49b2fee2fe192ed389e834dd635e3b3bac0ce0bf9f8f F src/test_demovfs.c 3efa2adf4f21e10d95521721687d5ca047aea91fa62dd8cc22ac9e5a9c942383 F src/test_devsym.c 649434ed34d0b03fbd5a6b42df80f0f9a7e53f94dd1710aad5dd8831e91c4e86 @@ -835,13 +835,13 @@ F src/trigger.c 0bb986a5b96047fd597c6aac28588853df56064e576e6b81ba777ef2ccaac461 F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 F src/utf.c 7bc550af6f3ddd5f5dc82d092c41f728acb760c92e0b47f391963b01ae52569b -F src/util.c aea7987484ec05764eabdd63b55eb63ea85cfb5b95dde70a667711c1d326f1a7 +F src/util.c 4d57ae861d0e234019be9596818228d7715e44e6efaccb612cf4498bedc2e023 F src/vacuum.c b763b6457bd058d2072ef9364832351fd8d11e8abf70cbb349657360f7d55c40 F src/vdbe.c be5f58bc29f60252e041a618eae59e8d57d460ba136c5403cf0abf955560c457 F src/vdbe.h c2549a215898a390de6669cfa32adba56f0d7e17ba5a7f7b14506d6fd5f0c36a F src/vdbeInt.h af7d7e8291edd0b19f2cd698e60e4d4031078f9a2f2328ac8f0b7efb134f8a1d F src/vdbeapi.c 53c7e26a2c0821a892b20eee2cde4656e31998212f3d515576c780dfaa45fd17 -F src/vdbeaux.c a30204ae8820ee5165736c2e67fe9b62ad47690c72248b4adba0435b0b3f8bfe +F src/vdbeaux.c f06f011e4fac948941ea821ac365a9f1c163ef473e63756d6e499a37c6bda9ef F src/vdbeblob.c 255be187436da38b01f276c02e6a08103489bbe2a7c6c21537b7aecbe0e1f797 F src/vdbemem.c df568ef0187e4be2788c35174f6d9b8566ab9475f9aff2d73907ed05aa5684b2 F src/vdbesort.c d0a3c7056c081703c8b6d91ad60f17da5e062a5c64bf568ed0fa1b5f4cae311f @@ -906,7 +906,7 @@ F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7 F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a F test/async5.test 383ab533fdb9f7ad228cc99ee66e1acb34cc0dc0 -F test/atof1.test f2765d7fdc1348ae58b279d096d301a208e46da623213877b2ba580dc2768975 +F test/atof1.test 7ec56debc04b32e8f9dc87239f4bbb07d84550fb83dd7475b0ead9e83beb35da F test/atomic.test 065a453dde33c77ff586d91ccaa6ed419829d492dbb1a5694b8a09f3f9d7d061 F test/atomic2.test b6863b4aa552543874f80b42fb3063f1c8c2e3d8e56b6562f00a3cc347b5c1da F test/atrc.c c388fac43dbba05c804432a7135ae688b32e8f25818e9994ffba4b64cf60c27c @@ -989,7 +989,7 @@ F test/capi3c.test 31d3a6778f2d06f2d9222bd7660c41a516d1518a059b069e96ebbeadb5a49 F test/capi3d.test 8b778794af891b0dca3d900bd345fbc8ebd2aa2aae425a9dccdd10d5233dfbde F test/capi3e.test 3d49c01ef2a1a55f41d73cba2b23b5059ec460fe F test/carray01.test 23ed7074307c4a829ba5ff2970993a9d87db7c5cdbbe1a2cbef672d0df6d6e31 -F test/cast.test 42f7d79d88ab5e8080e96c650c52fcf72eef3e6476aaaee2c9f6e074396cfdfc +F test/cast.test 6d095303492432a973e6dfc0071cb94cac2969ffbe2e6a68432be0c7b3b0a2d3 F test/cffault.test 9d6b20606afe712374952eec4f8fd74b1a8097ef F test/changes.test 4377d202a487f66fc2822c1bf57c46798c8b2caf7446f4f701723b1dbb6b86f6 F test/changes2.test 07949edcc732af28cb54276bfb7d99723bccc1e905a423648bf57ac5cb0dc792 @@ -1153,7 +1153,7 @@ F test/fkey8.test 51deda7f1a1448bca95875e4a6e1a3a75b4bd7215e924e845bd60de60e4d84 F test/fkey_malloc.test 594a7ea1fbab553c036c70813cd8bd9407d63749 F test/fordelete.test ba98f14446b310f9c9d935b97ec748753d0144a28b356ba30d1f4f6958fdde5c F test/format4.test eeae341953db8b6bda7f549044797c3278a6cc345d11ada81471671b654f8ef4 -F test/fp-speed-1.c ca95152d579530c967240ead1387dc1208052d310dfa22bc9ebded56d4e6c026 +F test/fp-speed-1.c b37de94eba034e1703668816225f54510ec60fb0685406608cc707afe6b8234d F test/fpconv1.test d5d8aa0c427533006c112fb1957cdd1ea68c1d0709470dabb9ca02c2e4c06ad8 F test/fts-9fd058691.test 78b887e30ae6816df0e1fed6259de4b5a64ad33c F test/fts3.test 672a040ea57036fb4b6fdc09027c18d7d24ab654 @@ -1254,7 +1254,7 @@ F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test b56905748ce0567c01d60005f3e6ad1af19453d224ba4730ee687d048fd09ef9 F test/func2.test 69f6ae3751b4ec765bdc3b803c0a255aa0f693f28f44805bef03e6b4a3fd242f F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a -F test/func4.test a3f9062487dbd826776f54f4e0e9517fe8c3cf689af92735308965774d51fac5 +F test/func4.test a02e695f62beb31cb092dccf6873ff97543407fff97a5f3ec4da70b5b337bc84 F test/func5.test 863e6d1bd0013d09c17236f8a13ea34008dd857d87d85a13a673960e4c25d82a F test/func6.test 3bc89ec0f2605736d3a118f43d25ef58115a7db4dba8ae939a363917d815c0bb F test/func7.test 7e009275f52c52954c8c028fdb62f8bc16cc47276fcc8753c1d2b22c6e074598 @@ -1668,7 +1668,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 377a0c48e5a92e0b11c1c5ebb1bc9d83a7312c922bc0cb05970ef5d6a96d1f0c -F test/speedtest1.c 82f273f6df420bb1563d5202277e4a907e4e032a96a86fa7cf8c7aed34b32724 +F test/speedtest1.c cc503febbb8559d541a67d7a33d3d7bb8a2c8cbbfc89eb336e2e2bd6ad6a63ee F test/spellfix.test 951a6405d49d1a23d6b78027d3877b4a33eeb8221dcab5704b499755bb4f552e F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33 @@ -1716,7 +1716,7 @@ F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc F test/tester.tcl 7b44f1a9b9a2de8112695b908afc21dd9a68cd2d44e84b73f1b27b53492c0d59 F test/testrunner.tcl 3dd75b45593d2afa2e3bca76121297a9f163bebb98474b13536f326829a71db1 x -F test/testrunner_data.tcl dbc0bb1c5b912dfd1e32b25d544318e412edd6085bd5fc9e6619cb93a739b786 +F test/testrunner_data.tcl c7b3b911e44f7e8c01cc6bc7571e16115cdc2e4db46630bd2acd7a931a46380e F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899 F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -2165,7 +2165,7 @@ F tool/showstat4.c 0682ebea7abf4d3657f53c4a243f2e7eab48eab344ed36a94bb75dcd19a5c F tool/showwal.c 11eca547980a066b081f512636151233350ac679f29ecf4ebfce7f4530230b3d F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/spaceanal.tcl 1f83962090a6b60e1d7bf92495d643e622bef9fe82ea3f2d22350dcbce9a12d0 -F tool/speed-check.sh e8d20cc2eb9c85ec1ba562226de144435456dcdff4ee618de49603c6958f6116 +F tool/speed-check.sh e566ab3934d7d78631743a984ad3f67c331c911bb18ff5d0a6c616a2afee7f91 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff @@ -2213,8 +2213,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1755831cb1ac58241e0b11d8d003b5eca39b65aa3cb84229b215662028b1b3c0 -R aec30d14f5d302123caffa8ac548b88e +P 98066e2d226e7d2eceec1931a1432baea956f49bf3c708d8a6d511fa4e864ca3 +R e46e6a9a210c9b73f42cca2feacde577 +T *branch * omit-long-double +T *sym-omit-long-double * +T -sym-trunk * U drh -Z 3d8c02a9a1123f16b58018bc4d458ba9 +Z a2f14f0f092d0810a1e1643e01967575 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 19cf9165e2..85854fe7bb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -98066e2d226e7d2eceec1931a1432baea956f49bf3c708d8a6d511fa4e864ca3 +f622b52024c8bec1d241b1dc480fbbd839fc1af50b6220f012812503de2c656e diff --git a/src/global.c b/src/global.c index 121b3f6d6b..b4864a446c 100644 --- a/src/global.c +++ b/src/global.c @@ -243,7 +243,6 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = { SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */ 0, /* bSmallMalloc */ 1, /* bExtraSchemaChecks */ - sizeof(LONGDOUBLE_TYPE)>8, /* bUseLongDouble */ #ifdef SQLITE_DEBUG 0, /* bJsonSelfcheck */ #endif diff --git a/src/main.c b/src/main.c index bd0cbc731a..4ed7e08cbd 100644 --- a/src/main.c +++ b/src/main.c @@ -159,33 +159,6 @@ char *sqlite3_temp_directory = 0; */ char *sqlite3_data_directory = 0; -#if !defined(SQLITE_OMIT_WSD) && !defined(SQLITE_USE_LONG_DOUBLE) -/* -** Determine whether or not high-precision (long double) floating point -** math works correctly on CPU currently running. -*/ -static SQLITE_NOINLINE int hasHighPrecisionDouble(int rc){ - if( sizeof(LONGDOUBLE_TYPE)<=8 ){ - /* If the size of "long double" is not more than 8, then - ** high-precision math is not possible. */ - return 0; - }else{ - /* Just because sizeof(long double)>8 does not mean that the underlying - ** hardware actually supports high-precision floating point. For example, - ** clearing the 0x100 bit in the floating-point control word on Intel - ** processors will make long double work like double, even though long - ** double takes up more space. The only way to determine if long double - ** actually works is to run an experiment. */ - LONGDOUBLE_TYPE a, b, c; - rc++; - a = 1.0+rc*0.1; - b = 1.0e+18+rc*25.0; - c = a+b; - return b!=c; - } -} -#endif /* !SQLITE_OMIT_WSD && !SQLITE_USE_LONG_DOUBLE */ - /* ** Initialize SQLite. ** @@ -380,11 +353,6 @@ int sqlite3_initialize(void){ rc = SQLITE_EXTRA_INIT(0); } #endif - -#if !defined(SQLITE_OMIT_WSD) && !defined(SQLITE_USE_LONG_DOUBLE) - sqlite3Config.bUseLongDouble = hasHighPrecisionDouble(rc); -#endif - return rc; } @@ -4637,30 +4605,6 @@ int sqlite3_test_control(int op, ...){ break; } -#if !defined(SQLITE_OMIT_WSD) - /* sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, int X); - ** - ** X<0 Make no changes to the bUseLongDouble. Just report value. - ** X==0 Disable bUseLongDouble - ** X==1 Enable bUseLongDouble - ** X>=2 Set bUseLongDouble to its default value for this platform - ** - ** If the SQLITE_USE_LONG_DOUBLE compile-time option has been used, then - ** the bUseLongDouble setting is fixed. This test-control becomes a - ** no-op, except that it still reports the fixed setting. - */ - case SQLITE_TESTCTRL_USELONGDOUBLE: { -#if !defined(SQLITE_USE_LONG_DOUBLE) - int b = va_arg(ap, int); - if( b>=2 ) b = hasHighPrecisionDouble(b); - if( b>=0 ) sqlite3Config.bUseLongDouble = b>0; -#endif - rc = SqliteUseLongDouble!=0; - break; - } -#endif - - #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD) /* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue) ** diff --git a/src/shell.c.in b/src/shell.c.in index 35b9b089fa..140fd0d9de 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -11257,7 +11257,6 @@ static int do_meta_command(char *zLine, ShellState *p){ {"seek_count", SQLITE_TESTCTRL_SEEK_COUNT, 0, "" }, {"sorter_mmap", SQLITE_TESTCTRL_SORTER_MMAP, 0, "NMAX" }, {"tune", SQLITE_TESTCTRL_TUNE, 1, "ID VALUE" }, - {"uselongdouble", SQLITE_TESTCTRL_USELONGDOUBLE,0,"?BOOLEAN|\"default\"?"}, }; int testctrl = -1; int iCtrl = -1; @@ -11491,21 +11490,6 @@ static int do_meta_command(char *zLine, ShellState *p){ } break; - /* sqlite3_test_control(int, int) */ - case SQLITE_TESTCTRL_USELONGDOUBLE: { - int opt = -1; - if( nArg==3 ){ - if( cli_strcmp(azArg[2],"default")==0 ){ - opt = 2; - }else{ - opt = booleanValue(azArg[2]); - } - } - rc2 = sqlite3_test_control(testctrl, opt); - isOk = 1; - break; - } - /* sqlite3_test_control(sqlite3*) */ case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS: rc2 = sqlite3_test_control(testctrl, p->db); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 72190beec5..4fff4b7508 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -8368,7 +8368,7 @@ int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_TRACEFLAGS 31 #define SQLITE_TESTCTRL_TUNE 32 #define SQLITE_TESTCTRL_LOGEST 33 -#define SQLITE_TESTCTRL_USELONGDOUBLE 34 +#define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */ #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */ /* diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 5b166d9a36..2b800abd95 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -660,7 +660,6 @@ # define float sqlite_int64 # define fabs(X) ((X)<0?-(X):(X)) # define sqlite3IsOverflow(X) 0 -# define LONGDOUBLE_TYPE sqlite_int64 # ifndef SQLITE_BIG_DBL # define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50) # endif @@ -835,9 +834,6 @@ # define INT8_TYPE signed char # endif #endif -#ifndef LONGDOUBLE_TYPE -# define LONGDOUBLE_TYPE long double -#endif typedef sqlite_int64 i64; /* 8-byte signed integer */ typedef sqlite_uint64 u64; /* 8-byte unsigned integer */ typedef UINT32_TYPE u32; /* 4-byte unsigned integer */ @@ -4249,41 +4245,6 @@ typedef struct { # define Tuning(X) 0 #endif -/* By default, SQLite will use long double if the long double type -** actually provides higher resolution than double. This use or non-use -** of long double is switchable at run-time by a test-control. Dekker -** algorithms are used for high-precision floating point when long double -** is not available. -** -** Having the run-time option to enable/disable long double support -** causes problems for some compiler tool chains. So the following -** compile-time option is available to permanently enable/disable the use -** of long double. -** -** -DSQLITE_USE_LONG_DOUBLE=0 Omit all use of "long double" from -** the code. Instead, the Dekker algorithm -** is always used when high-precision -** floating point is required. -** -** -DSQLITE_USE_LONG_DOUBLE=1 Always use long double when high -** precision is needed. Never fall back -** to using Dekker algorithms. -** -** If the SQLITE_USE_LONG_DOUBLE macro is not defined, then the determination -** of whether or not to use long double is made at run-time. -*/ -#ifndef SQLITE_USE_LONG_DOUBLE -# define SqliteUseLongDouble sqlite3Config.bUseLongDouble -#elif SQLITE_USE_LONG_DOUBLE+0==1 -# define SqliteUseLongDouble 1 -#elif SQLITE_USE_LONG_DOUBLE+0==0 -# undef LONGDOUBLE_TYPE -# define LONGDOUBLE_TYPE double -# define SqliteUseLongDouble 0 -#else -# error "SQLITE_USE_LONG_DOUBLE should be set to either 0 or 1" -#endif - /* ** Structure containing global configuration data for the SQLite library. ** @@ -4297,7 +4258,6 @@ struct Sqlite3Config { u8 bUseCis; /* Use covering indices for full-scans */ u8 bSmallMalloc; /* Avoid large memory allocations if true */ u8 bExtraSchemaChecks; /* Verify type,name,tbl_name in schema */ - u8 bUseLongDouble; /* Make use of long double */ #ifdef SQLITE_DEBUG u8 bJsonSelfcheck; /* Double-check JSON parsing */ #endif diff --git a/src/test1.c b/src/test1.c index 38ea6229ee..5af066c6b2 100644 --- a/src/test1.c +++ b/src/test1.c @@ -7313,37 +7313,6 @@ static int SQLITE_TCLAPI extra_schema_checks( return TCL_OK; } -/* -** tclcmd: use_long_double BOOLEAN|"default" -** -** If no argument, report the current value of the use-long-double flag. -** -** If argument is "default", set the use-long-double flag to the default -** value for this build, based on the size of LONGDOUBLE_TYPE. -** -** If argument is a boolean, set the use-long-double flag accordingly. -** -** Return the new setting. -*/ -static int SQLITE_TCLAPI use_long_double( - ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ - Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ - int objc, /* Number of arguments */ - Tcl_Obj *CONST objv[] /* Command arguments */ -){ - int i = -1; - if( objc==2 ){ - if( strcmp(Tcl_GetString(objv[1]),"default")==0 ){ - i = 2; - }else{ - if( Tcl_GetBooleanFromObj(interp,objv[1],&i) ) return TCL_ERROR; - } - } - i = sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, i); - Tcl_SetObjResult(interp, Tcl_NewIntObj(i)); - return TCL_OK; -} - /* ** tclcmd: database_may_be_corrupt ** @@ -9150,7 +9119,6 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "reset_prng_state", reset_prng_state, 0 }, { "prng_seed", prng_seed, 0 }, { "extra_schema_checks", extra_schema_checks, 0}, - { "use_long_double", use_long_double, 0}, { "database_never_corrupt", database_never_corrupt, 0}, { "database_may_be_corrupt", database_may_be_corrupt, 0}, { "optimization_control", optimization_control,0}, @@ -9299,7 +9267,6 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ #endif }; static int bitmask_size = sizeof(Bitmask)*8; - static int longdouble_size = sizeof(LONGDOUBLE_TYPE); int i; extern int sqlite3_sync_count, sqlite3_fullsync_count; extern int sqlite3_opentemp_count; @@ -9400,8 +9367,6 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ (char*)&sqlite3_data_directory, TCL_LINK_STRING); Tcl_LinkVar(interp, "bitmask_size", (char*)&bitmask_size, TCL_LINK_INT|TCL_LINK_READ_ONLY); - Tcl_LinkVar(interp, "longdouble_size", - (char*)&longdouble_size, TCL_LINK_INT|TCL_LINK_READ_ONLY); Tcl_LinkVar(interp, "sqlite_sync_count", (char*)&sqlite3_sync_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_fullsync_count", diff --git a/src/test_config.c b/src/test_config.c index 49527861a4..ad315c723c 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -512,10 +512,6 @@ static void set_options(Tcl_Interp *interp){ Tcl_SetVar2(interp, "sqlite_options", "lookaside", "1", TCL_GLOBAL_ONLY); #endif -Tcl_SetVar2(interp, "sqlite_options", "long_double", - sizeof(LONGDOUBLE_TYPE)>sizeof(double) ? "1" : "0", - TCL_GLOBAL_ONLY); - #ifdef SQLITE_OMIT_MEMORYDB Tcl_SetVar2(interp, "sqlite_options", "memorydb", "0", TCL_GLOBAL_ONLY); #else diff --git a/src/util.c b/src/util.c index 6725306eda..9ad294016a 100644 --- a/src/util.c +++ b/src/util.c @@ -458,7 +458,6 @@ u8 sqlite3StrIHash(const char *z){ return h; } -#if !defined(SQLITE_USE_LONG_DOUBLE) || SQLITE_USE_LONG_DOUBLE+0==0 /* Double-Double multiplication. (x[0],x[1]) *= (y,yy) ** ** Reference: @@ -494,9 +493,6 @@ static void dekkerMul2(volatile double *x, double y, double yy){ x[1] = c - x[0]; x[1] += cc; } -#else -# define dekkerMul2(A,B,C) /* No-op if SqliteUseLongDouble is always true */ -#endif /* ** The string z[] is an text representation of a real number. @@ -543,6 +539,8 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ int eValid = 1; /* True exponent is either not used or is well-formed */ int nDigit = 0; /* Number of digits processed */ int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */ + double rr[2]; + u64 s2; assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); *pResult = 0.0; /* Default return value, in case of an error */ @@ -654,68 +652,41 @@ do_atof_calc: e++; } - if( e==0 ){ - *pResult = s; - }else if( SqliteUseLongDouble ){ - LONGDOUBLE_TYPE r = (LONGDOUBLE_TYPE)s; - if( e>0 ){ - while( e>=100 ){ e-=100; r *= 1.0e+100L; } - while( e>=10 ){ e-=10; r *= 1.0e+10L; } - while( e>=1 ){ e-=1; r *= 1.0e+01L; } - }else{ - while( e<=-100 ){ e+=100; r *= 1.0e-100L; } - while( e<=-10 ){ e+=10; r *= 1.0e-10L; } - while( e<=-1 ){ e+=1; r *= 1.0e-01L; } - } - assert( r>=0.0 ); - if( r>+1.7976931348623157081452742373e+308L ){ -#ifdef INFINITY - *pResult = +INFINITY; -#else - *pResult = 1.0e308*10.0; + rr[0] = (double)s; + s2 = (u64)rr[0]; +#if defined(_MSC_VER) && _MSC_VER<1700 + if( s2==0x8000000000000000LL ){ s2 = 2*(u64)(0.5*rr[0]); } #endif - }else{ - *pResult = (double)r; + rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s); + if( e>0 ){ + while( e>=100 ){ + e -= 100; + dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); + } + while( e>=10 ){ + e -= 10; + dekkerMul2(rr, 1.0e+10, 0.0); + } + while( e>=1 ){ + e -= 1; + dekkerMul2(rr, 1.0e+01, 0.0); } }else{ - double rr[2]; - u64 s2; - rr[0] = (double)s; - s2 = (u64)rr[0]; -#if defined(_MSC_VER) && _MSC_VER<1700 - if( s2==0x8000000000000000LL ){ s2 = 2*(u64)(0.5*rr[0]); } -#endif - rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s); - if( e>0 ){ - while( e>=100 ){ - e -= 100; - dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); - } - while( e>=10 ){ - e -= 10; - dekkerMul2(rr, 1.0e+10, 0.0); - } - while( e>=1 ){ - e -= 1; - dekkerMul2(rr, 1.0e+01, 0.0); - } - }else{ - while( e<=-100 ){ - e += 100; - dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); - } - while( e<=-10 ){ - e += 10; - dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); - } - while( e<=-1 ){ - e += 1; - dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); - } + while( e<=-100 ){ + e += 100; + dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); + } + while( e<=-10 ){ + e += 10; + dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); + } + while( e<=-1 ){ + e += 1; + dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); } - *pResult = rr[0]+rr[1]; - if( sqlite3IsNaN(*pResult) ) *pResult = 1e300*1e300; } + *pResult = rr[0]+rr[1]; + if( sqlite3IsNaN(*pResult) ) *pResult = 1e300*1e300; if( sign<0 ) *pResult = -*pResult; assert( !sqlite3IsNaN(*pResult) ); @@ -1036,9 +1007,10 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){ int i; u64 v; int e, exp = 0; + double rr[2]; + p->isSpecial = 0; p->z = p->zBuf; - assert( mxRound>0 ); /* Convert negative numbers to positive. Deal with Infinity, 0.0, and @@ -1066,62 +1038,45 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){ /* Multiply r by powers of ten until it lands somewhere in between ** 1.0e+19 and 1.0e+17. + ** + ** Use Dekker-style double-double computation to increase the + ** precision. + ** + ** The error terms on constants like 1.0e+100 computed using the + ** decimal extension, for example as follows: + ** + ** SELECT decimal_exp(decimal_sub('1.0e+100',decimal(1.0e+100))); */ - if( SqliteUseLongDouble ){ - LONGDOUBLE_TYPE rr = r; - if( rr>=1.0e+19 ){ - while( rr>=1.0e+119L ){ exp+=100; rr *= 1.0e-100L; } - while( rr>=1.0e+29L ){ exp+=10; rr *= 1.0e-10L; } - while( rr>=1.0e+19L ){ exp++; rr *= 1.0e-1L; } - }else{ - while( rr<1.0e-97L ){ exp-=100; rr *= 1.0e+100L; } - while( rr<1.0e+07L ){ exp-=10; rr *= 1.0e+10L; } - while( rr<1.0e+17L ){ exp--; rr *= 1.0e+1L; } + rr[0] = r; + rr[1] = 0.0; + if( rr[0]>9.223372036854774784e+18 ){ + while( rr[0]>9.223372036854774784e+118 ){ + exp += 100; + dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); + } + while( rr[0]>9.223372036854774784e+28 ){ + exp += 10; + dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); + } + while( rr[0]>9.223372036854774784e+18 ){ + exp += 1; + dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); } - v = (u64)rr; }else{ - /* If high-precision floating point is not available using "long double", - ** then use Dekker-style double-double computation to increase the - ** precision. - ** - ** The error terms on constants like 1.0e+100 computed using the - ** decimal extension, for example as follows: - ** - ** SELECT decimal_exp(decimal_sub('1.0e+100',decimal(1.0e+100))); - */ - double rr[2]; - rr[0] = r; - rr[1] = 0.0; - if( rr[0]>9.223372036854774784e+18 ){ - while( rr[0]>9.223372036854774784e+118 ){ - exp += 100; - dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); - } - while( rr[0]>9.223372036854774784e+28 ){ - exp += 10; - dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); - } - while( rr[0]>9.223372036854774784e+18 ){ - exp += 1; - dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); - } - }else{ - while( rr[0]<9.223372036854774784e-83 ){ - exp -= 100; - dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); - } - while( rr[0]<9.223372036854774784e+07 ){ - exp -= 10; - dekkerMul2(rr, 1.0e+10, 0.0); - } - while( rr[0]<9.22337203685477478e+17 ){ - exp -= 1; - dekkerMul2(rr, 1.0e+01, 0.0); - } + while( rr[0]<9.223372036854774784e-83 ){ + exp -= 100; + dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); + } + while( rr[0]<9.223372036854774784e+07 ){ + exp -= 10; + dekkerMul2(rr, 1.0e+10, 0.0); + } + while( rr[0]<9.22337203685477478e+17 ){ + exp -= 1; + dekkerMul2(rr, 1.0e+01, 0.0); } - v = rr[1]<0.0 ? (u64)rr[0]-(u64)(-rr[1]) : (u64)rr[0]+(u64)rr[1]; } - + v = rr[1]<0.0 ? (u64)rr[0]-(u64)(-rr[1]) : (u64)rr[0]+(u64)rr[1]; /* Extract significant digits. */ i = sizeof(p->zBuf)-1; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 5ff4ca928c..8120536b98 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -4512,13 +4512,9 @@ SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){ ** We must use separate SQLITE_NOINLINE functions here, since otherwise ** optimizer code movement causes gcov to become very confused. */ -#if (defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG)) \ - && (!defined(SQLITE_USE_LONG_DOUBLE) || SQLITE_USE_LONG_DOUBLE+0==0) +#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG) static int SQLITE_NOINLINE doubleLt(double a, double b){ return ar ); - testcase( x==r ); - return (xr); }else{ i64 y; if( r<-9223372036854775808.0 ) return +1; diff --git a/test/atof1.test b/test/atof1.test index 95f443ce0d..1a5db2cc79 100644 --- a/test/atof1.test +++ b/test/atof1.test @@ -15,7 +15,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl -set mxpow [expr {[use_long_double]?100:35}] +set mxpow 35 expr srand(1) for {set i 1} {$i<20000} {incr i} { set pow [expr {int((rand()-0.5)*$mxpow)}] diff --git a/test/cast.test b/test/cast.test index 7f48ed80bf..1c9071d775 100644 --- a/test/cast.test +++ b/test/cast.test @@ -262,11 +262,9 @@ do_test cast-3.12 { do_realnum_test cast-3.13 { execsql {SELECT CAST('9223372036854774800' AS real)} } 9.22337203685477e+18 -ifcapable long_double { - do_test cast-3.14 { - execsql {SELECT CAST(CAST('9223372036854774800' AS real) AS integer)} - } 9223372036854774784 -} +do_test cast-3.14 { + execsql {SELECT CAST(CAST('9223372036854774800' AS real) AS integer)} +} 9223372036854774784 do_test cast-3.15 { execsql {SELECT CAST('-9223372036854774800' AS integer)} } -9223372036854774800 @@ -276,11 +274,9 @@ do_test cast-3.16 { do_realnum_test cast-3.17 { execsql {SELECT CAST('-9223372036854774800' AS real)} } -9.22337203685477e+18 -ifcapable long_double { - do_test cast-3.18 { - execsql {SELECT CAST(CAST('-9223372036854774800' AS real) AS integer)} - } -9223372036854774784 -} +do_test cast-3.18 { + execsql {SELECT CAST(CAST('-9223372036854774800' AS real) AS integer)} +} -9223372036854774784 if {[db eval {PRAGMA encoding}]=="UTF-8"} { do_test cast-3.21 { execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS integer)} @@ -291,14 +287,12 @@ if {[db eval {PRAGMA encoding}]=="UTF-8"} { do_realnum_test cast-3.23 { execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS real)} } 9.22337203685477e+18 - ifcapable long_double { - do_test cast-3.24 { - execsql { - SELECT CAST(CAST(x'39323233333732303336383534373734383030' AS real) - AS integer) - } - } 9223372036854774784 - } + do_test cast-3.24 { + execsql { + SELECT CAST(CAST(x'39323233333732303336383534373734383030' AS real) + AS integer) + } + } 9223372036854774784 } do_test cast-3.31 { execsql {SELECT CAST(NULL AS numeric)} diff --git a/test/fp-speed-1.c b/test/fp-speed-1.c index 5eeb95d348..cb4e0409c3 100644 --- a/test/fp-speed-1.c +++ b/test/fp-speed-1.c @@ -12,7 +12,6 @@ ** ** time ./a.out 0 10000000 <-- standard library ** time ./a.out 1 10000000 <-- SQLite -** time ./a.out 2 10000000 <-- SQLite with long-double disabled */ static double aVal[] = { -1.0163830486285643089e+063, @@ -150,15 +149,6 @@ int main(int argc, char **argv){ } break; } - case 2: { - printf("Doing %d calls to sqlite3_snprintf() without long double\n", cnt); - sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, 0); - for(i=0; i=0 ){ - sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, useLongDouble); - } -#endif if( g.nReserve>0 ){ sqlite3_file_control(g.db, 0, SQLITE_FCNTL_RESERVE_BYTES, &g.nReserve); } diff --git a/test/testrunner_data.tcl b/test/testrunner_data.tcl index 78f28bbf8e..98b3669a33 100644 --- a/test/testrunner_data.tcl +++ b/test/testrunner_data.tcl @@ -203,7 +203,6 @@ namespace eval trd { -DSQLITE_MAX_ATTACHED=125 -DSQLITE_MAX_MMAP_SIZE=12884901888 -DSQLITE_ENABLE_SORTER_MMAP=1 - -DLONGDOUBLE_TYPE=double --enable-session } set build(Device-One) { @@ -343,7 +342,6 @@ namespace eval trd { -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_HIDDEN_COLUMNS - -DLONGDOUBLE_TYPE=double -DCONFIG_SLOWDOWN_FACTOR=8.0 } diff --git a/tool/speed-check.sh b/tool/speed-check.sh index 5d425c3b37..8a9e67a38b 100644 --- a/tool/speed-check.sh +++ b/tool/speed-check.sh @@ -99,9 +99,6 @@ while test "$1" != ""; do --stmtcache) shift; SPEEDTEST_OPTS="$SPEEDTEST_OPTS --stmtcache $1" ;; - --nolongdouble) - SPEEDTEST_OPTS="$SPEEDTEST_OPTS --nolongdouble" - ;; --checkpoint) SPEEDTEST_OPTS="$SPEEDTEST_OPTS --checkpoint" ;; From f9d1141a3b34e36cf26be87dbd199b036985b2d6 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 2 Oct 2024 11:11:00 +0000 Subject: [PATCH 18/77] Update docs for sqlite3_snapshot_get(). FossilOrigin-Name: 78c3892ab777a39406da8a9df84d0634397514e25512b0363a13bff3b8bc8925 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 8 ++++++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 83d6936a7d..7342f3b4a1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\spossible,\savoid\staking\swal\sfile\sread-lock\s0\sin\ssqlite3_snapshot_get(). -D 2024-09-26T18:02:17.495 +C Update\sdocs\sfor\ssqlite3_snapshot_get(). +D 2024-10-02T11:11:00.069 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -769,7 +769,7 @@ F src/resolve.c 9750a281f7ba073b4e6da2be1a6c4071f5d841a7746c5fb3f70d6d793b6675ea F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe F src/shell.c.in 9b68a945f3aafc78eac1a256a4a588a9310dbc61a0cd60378c5b7a78f789af50 -F src/sqlite.h.in 77f55bd1978a04a14db211732f0a609077cf60ba4ccf9baf39988f508945419c +F src/sqlite.h.in 496f927cf2a687f313c6ac41c03e46f45c8f91c84d8f3ff6607aa9f2794e2ec3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 5978cbb11becc3ce6471015d770d95f694ece06336c496f691df1b02460e9cd5 @@ -2213,11 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9592b9ba3ad7a842cdd4c4010da278485a6fdec7e811bda01ebe640162a8c3b6 -R 8553e4183ac33940fe95918021cfe535 -T *branch * snapshot_get-locking -T *sym-snapshot_get-locking * -T -sym-trunk * +P 34b6ac3d76dbc6819778ec2a0f81cbcdcc0cd1a6303381d97f1c479e4ecdd132 +R a30055f90af028e040102b1e9655fa8f U dan -Z 2b5e37766517d26ed8f4d4495c7d929b +Z 068c609e961149f2eac59f5d7b1ce4b0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 986575a33e..00ceed77c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -34b6ac3d76dbc6819778ec2a0f81cbcdcc0cd1a6303381d97f1c479e4ecdd132 +78c3892ab777a39406da8a9df84d0634397514e25512b0363a13bff3b8bc8925 diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 5546793c94..013be20371 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -10539,6 +10539,14 @@ typedef struct sqlite3_snapshot { ** If there is not already a read-transaction open on schema S when ** this function is called, one is opened automatically. ** +** If a read-transaction is opened by this function, then it is guaranteed +** that the returned snapshot object may not be invalidated by a database +** writer or checkpointer until after the read-transaction is closed. This +** is not guaranteed if a read-transaction is already open when this +** function is called. In that case, any subsequent write or checkpoint +** operation on the database may invalidate the returned snapshot handle, +** even while the read-transaction remains open. +** ** The following must be true for this function to succeed. If any of ** the following statements are false when sqlite3_snapshot_get() is ** called, SQLITE_ERROR is returned. The final value of *P is undefined From 010f9f8704563b904083363d236bd0adcab329d8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 2 Oct 2024 11:34:11 +0000 Subject: [PATCH 19/77] Remove a few more traces of long double from the code. FossilOrigin-Name: 11d6a89e4a25c3f884ff617036d239dc42522859400cd1f4674634f6c7adbb02 --- ext/wasm/GNUmakefile | 1 - ext/wasm/api/sqlite3-wasm.c | 23 ----------------------- manifest | 19 ++++++++----------- manifest.uuid | 2 +- test/func.test | 3 --- 5 files changed, 9 insertions(+), 39 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index a68f813d6b..00f1ee50a7 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -239,7 +239,6 @@ SQLITE_OPT.common := \ '-DSQLITE_DEFAULT_UNIX_VFS="unix-none"' \ -DSQLITE_USE_URI=1 \ -DSQLITE_C=$(sqlite3.c) \ - -DSQLITE_USE_LONG_DOUBLE=0 \ -DSQLITE_OMIT_DEPRECATED \ -DSQLITE_OMIT_UTF16 \ -DSQLITE_OMIT_LOAD_EXTENSION \ diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index b689b426fb..c5dd495e54 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -127,10 +127,6 @@ # define SQLITE_USE_URI 1 #endif -#ifndef SQLITE_USE_LONG_DOUBLE -# define SQLITE_USE_LONG_DOUBLE 0 -#endif - #ifdef SQLITE_WASM_EXTRA_INIT # define SQLITE_EXTRA_INIT sqlite3_wasm_extra_init #endif @@ -163,8 +159,6 @@ # define SQLITE_OMIT_PROGRESS_CALLBACK # undef SQLITE_OMIT_WAL # define SQLITE_OMIT_WAL -# undef SQLITE_USE_LONG_DOUBLE -# define SQLITE_USE_LONG_DOUBLE 0 /* The following OMITs do not work with the standard amalgamation, so require a custom build: @@ -227,23 +221,6 @@ // See also: //__attribute__((export_name("theExportedName"), used, visibility("default"))) -#if 0 -/* Details at https://sqlite.org/forum/forumpost/cbfb0d0ac0a4e349 -** -** Summary: changing to `double` reduces the wasm file size by a mere -** 2k. It is hypothetically not possible that any clients rely on -** doubles larger than 64-bit because there is no mapping between C -** and JS for them. i.e. we "could" switch LONGDOUBLE_TYPE to double -** for wasm builds with very little risk of problems. Clang 18.1 maps -** `long double` to float128 but Emscripten doesn't (cannot) expose -** that to JS. -** -** See also: SQLITE_USE_LONG_DOUBLE -*/ -#undef LONGDOUBLE_TYPE -#define LONGDOUBLE_TYPE double -#endif - /* ** Which sqlite3.c we're using needs to be configurable to enable ** building against a custom copy, e.g. the SEE variant. Note that we diff --git a/manifest b/manifest index 6f37d1934e..0e151bff01 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sall\scode\sthat\smakes\suse\sof\sthe\sC-language\s"long\sdouble"\sdatatype. -D 2024-10-01T20:29:43.065 +C Remove\sa\sfew\smore\straces\sof\slong\sdouble\sfrom\sthe\scode. +D 2024-10-02T11:34:11.757 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -603,7 +603,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt ca7e9ee82ca4e1c1744295f8184dd70edfae1992865d26c64303f539eb6c084c F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c -F ext/wasm/GNUmakefile c2ee5993e727dd2c1f0f784f47843fb7af45cebd23626b537bae2d2d8f4a3abd +F ext/wasm/GNUmakefile bfd63f0462ac7e5b814a267e9101b8284d61731574ec673dae3178643cdb89ef F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -632,7 +632,7 @@ F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js e529a99b7d5a088284821e2902b20d3404b561126969876997d5a73a656c9199 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e99e3d99f736937914527070f00ab13e9391d3f1cef884ab99a64cbcbee8d675 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 -F ext/wasm/api/sqlite3-wasm.c 2d4340f2dacd9119e95c470d9c4f392e399feffc292962b855f0a67ffb0fc418 +F ext/wasm/api/sqlite3-wasm.c 83f5e9f998e9fa4261eb84e9f092210e3ffe03895119f5ded0429eb34ab9d2be F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 @@ -1251,7 +1251,7 @@ F test/fts4umlaut.test fcaca4471de7e78c9d1f7e8976e3e8704d7d8ad979d57a739d00f3f75 F test/fts4unicode.test 82a9c16b68ba2f358a856226bb2ee02f81583797bc4744061c54401bf1a0f4c9 F test/fts4upfrom.test f25835162c989dffd5e2ef91ec24c4848cc9973093e2d492d1c7b32afac1b49d F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d -F test/func.test b56905748ce0567c01d60005f3e6ad1af19453d224ba4730ee687d048fd09ef9 +F test/func.test 098d28ecd1284e0625797a981c9dbf7c1664763af2900f96b9716af80e6cbe40 F test/func2.test 69f6ae3751b4ec765bdc3b803c0a255aa0f693f28f44805bef03e6b4a3fd242f F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a F test/func4.test a02e695f62beb31cb092dccf6873ff97543407fff97a5f3ec4da70b5b337bc84 @@ -2213,11 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 98066e2d226e7d2eceec1931a1432baea956f49bf3c708d8a6d511fa4e864ca3 -R e46e6a9a210c9b73f42cca2feacde577 -T *branch * omit-long-double -T *sym-omit-long-double * -T -sym-trunk * +P f622b52024c8bec1d241b1dc480fbbd839fc1af50b6220f012812503de2c656e +R 7cb8c5e39f3b0a66c9a6cd2a8aa3a2f9 U drh -Z a2f14f0f092d0810a1e1643e01967575 +Z 479f0ce23bd7d658aebb57b7e11ea9e8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 85854fe7bb..90f9e11206 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f622b52024c8bec1d241b1dc480fbbd839fc1af50b6220f012812503de2c656e +11d6a89e4a25c3f884ff617036d239dc42522859400cd1f4674634f6c7adbb02 diff --git a/test/func.test b/test/func.test index a3ecd4e30b..228adcc2d6 100644 --- a/test/func.test +++ b/test/func.test @@ -261,9 +261,6 @@ ifcapable floatingpoint { catchsql {SELECT round(b,2.0) FROM t1 ORDER BY b} } {0 {-2.0 1.23 2.0}} # Verify some values reported on the mailing list. - # Some of these fail on MSVC builds with 64-bit - # long doubles, but not on GCC builds with 80-bit - # long doubles. for {set i 1} {$i<999} {incr i} { set x1 [expr 40222.5 + $i] set x2 [expr 40223.0 + $i] From 3b3f230d9511162e7d8ab00253fb9f515ec1b8fe Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 2 Oct 2024 16:55:27 +0000 Subject: [PATCH 20/77] Adjust the new truncation behavior of sqlite_dbpage(N,null) such that it causes the database to be truncated to N-1 pages. This makes more since. An error is raised if N is less than 2. FossilOrigin-Name: 7d5ff86ef7386f4f7f6a956dc0de607e61040d335c9f98d1f71e76a39f4f5e03 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/dbpage.c | 5 ++++- tool/sqlite3-rsync.c | 19 +++++++++++-------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 3aa5a7d760..e28592bcfa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sall\suse\sof\sthe\s"long\sdouble"\sdata\stype\sfrom\sSQLite,\sas\shardware\ssupport\nfor\slong\sdouble\sis\sincreasingly\srare\sand\sthe\suse\sof\slong\sdouble\screates\nchallenges\sfor\ssome\scompilers. -D 2024-10-02T13:26:17.391 +C Adjust\sthe\snew\struncation\sbehavior\sof\ssqlite_dbpage(N,null)\ssuch\sthat\sit\scauses\nthe\sdatabase\sto\sbe\struncated\sto\sN-1\spages.\s\sThis\smakes\smore\ssince.\s\sAn\serror\sis\nraised\sif\sN\sis\sless\sthan\s2. +D 2024-10-02T16:55:27.051 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -714,7 +714,7 @@ F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d49 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c b224d3db0f28c4a5f1407c50107a0a8133bd244ff3c7f6f8cedeb896a8cf1b64 F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a -F src/dbpage.c 12e49515d67d4a59625d71f9aa42499556cfdc2e4f1ea49086e674a7f47f46e5 +F src/dbpage.c 9da735cb2eef4ab6941ddb235c8d2c2764e0bb5bd20f7ca3003be1d4ab8d49c9 F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 @@ -2174,7 +2174,7 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60 F tool/sqldiff.c 2a0987d183027c795ced13d6749061c1d2f38e24eddb428f56fa64c3a8f51e4b -F tool/sqlite3-rsync.c 187b262035c1159b047dbfa1959c168b87b5a153b63465e8c8bd1b54fabf4460 +F tool/sqlite3-rsync.c 2f06f02ee3a28f847b3fb8c0f32e3b3296571e0f8027939b95d32df5edfe1dd9 F tool/sqlite3_analyzer.c.in 348ba349bbdc93c9866439f9f935d7284866a2a4e6898bc906ae1204ade56918 F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 @@ -2213,9 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P eb5277e490a9b48c865f2dc449cdb8f1b604e233737e492abb4f2f7101a6715b 11d6a89e4a25c3f884ff617036d239dc42522859400cd1f4674634f6c7adbb02 -R dd2610993cca357884642ff1a0c9d8c4 -T +closed 11d6a89e4a25c3f884ff617036d239dc42522859400cd1f4674634f6c7adbb02 +P 761d8fd18b0ee8681b12998f01a2eca1b796807a5174a1270cfb9bdc841424ac +R afa8cb87d393983234687bde8f6e9625 U drh -Z 3a98d9548ba7ad8d74362f910ad4f724 +Z 3ddb58c2554e681f7603c7c59106deb3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dde70a7d00..6b9a9877b2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -761d8fd18b0ee8681b12998f01a2eca1b796807a5174a1270cfb9bdc841424ac +7d5ff86ef7386f4f7f6a956dc0de607e61040d335c9f98d1f71e76a39f4f5e03 diff --git a/src/dbpage.c b/src/dbpage.c index 42b24f9b8d..136c8b0b39 100644 --- a/src/dbpage.c +++ b/src/dbpage.c @@ -375,7 +375,9 @@ static int dbpageUpdate( if( sqlite3_value_type(argv[3])!=SQLITE_BLOB || sqlite3_value_bytes(argv[3])!=szPage ){ - if( sqlite3_value_type(argv[3])==SQLITE_NULL && isInsert ){ + if( sqlite3_value_type(argv[3])==SQLITE_NULL && isInsert && pgno>1 ){ + /* "INSERT INTO dbpage($PGNO,NULL)" causes page number $PGNO and + ** all subsequent pages to be deleted. */ if( iDb>=pTab->nTrunc ){ testcase( pTab->aTrunc!=0 ); pTab->aTrunc = sqlite3_realloc(pTab->aTrunc, (iDb+1)*sizeof(Pgno)); @@ -387,6 +389,7 @@ static int dbpageUpdate( return SQLITE_NOMEM; } } + pgno--; pTab->aTrunc[iDb] = pgno; }else{ zErr = "bad page value"; diff --git a/tool/sqlite3-rsync.c b/tool/sqlite3-rsync.c index 1be206a758..216390c182 100644 --- a/tool/sqlite3-rsync.c +++ b/tool/sqlite3-rsync.c @@ -1456,15 +1456,18 @@ static void replicaSide(SQLiteRsync *p){ }else if( p->nErr ){ runSql(p, "ROLLBACK"); }else{ - int rc; - sqlite3_bind_int64(pIns, 1, nOPage); - sqlite3_bind_null(pIns, 2); - rc = sqlite3_step(pIns); - if( rc!=SQLITE_DONE ){ - reportError(p, "SQL statement [%s] failed (pgno=%u, data=NULL): %s", - sqlite3_sql(pIns), nOPage, sqlite3_errmsg(p->db)); + if( nOPage<0xffffffff ){ + int rc; + sqlite3_bind_int64(pIns, 1, nOPage+1); + sqlite3_bind_null(pIns, 2); + rc = sqlite3_step(pIns); + if( rc!=SQLITE_DONE ){ + reportError(p, + "SQL statement [%s] failed (pgno=%u, data=NULL): %s", + sqlite3_sql(pIns), nOPage, sqlite3_errmsg(p->db)); + } + sqlite3_reset(pIns); } - sqlite3_reset(pIns); p->nPage = nOPage; runSql(p, "COMMIT"); } From 44b8c37017e25e8cc6a1703b37e47524cba08bcc Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 2 Oct 2024 17:43:06 +0000 Subject: [PATCH 21/77] Fix a typo in fts5delete.test. FossilOrigin-Name: b1f001435eff72c2119ecee973194385f70fd1b66ef0be8a66c0b0ad02ae43df --- ext/fts5/test/fts5delete.test | 3 ++- manifest | 13 ++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/fts5/test/fts5delete.test b/ext/fts5/test/fts5delete.test index c9c55e8a4f..024f89594c 100644 --- a/ext/fts5/test/fts5delete.test +++ b/ext/fts5/test/fts5delete.test @@ -161,8 +161,9 @@ do_execsql_test 4.4 { do_execsql_test 4.5 { SELECT * FROM ft1_content } {1 i 3 iii} + do_execsql_test 4.6 { - SELECT * FROM ft1_content + SELECT * FROM ft2_content } {1 i 3 iii} finish_test diff --git a/manifest b/manifest index 739de72095..2f603be8f6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\scontentless_unindexed=1\soption\sto\sfts5.\sThis\scauses\sthe\svalues\sof\sany\sUNINDEXED\scolumns\sof\sa\scontentless\sfts5\stable\sto\sbe\sstored\spersistently\sin\sthe\sdatabase. -D 2024-10-02T17:04:30.788 +C Fix\sa\stypo\sin\sfts5delete.test. +D 2024-10-02T17:43:06.145 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -154,7 +154,7 @@ F ext/fts5/test/fts5corrupt5.test 11b47126f5772cc37b67e3e8b2ed05895c4d07c05338bc F ext/fts5/test/fts5corrupt6.test 2d72db743db7b5d9c9a6d0cfef24d799ed1aa5e8192b66c40e871a37ed9eed06 F ext/fts5/test/fts5corrupt7.test 4e830875c33b9ea3c4cf1ba71e692b63893cbb4faae8c69b1071889dc26e211c F ext/fts5/test/fts5corrupt8.test b81d802e41631e98100f49a1aadeeffef860e30a62d6ed7d743c2797c477239e -F ext/fts5/test/fts5delete.test e5ad73ce7cda1201b15ead1170f0bc6a2402107b4c2b4e8c8d38c3c7a5140739 +F ext/fts5/test/fts5delete.test 2a5008f8b1174ef41d1974e606928c20e4f9da77d9f8347aed818994d89cced4 F ext/fts5/test/fts5detail.test 54015e9c43ec4ba542cfb93268abdf280e0300f350efd08ee411284b03595cc4 F ext/fts5/test/fts5determin.test 1b77879b2ae818b5b71c859e534ee334dac088b7cf3ff3bf76a2c82b1c788d11 F ext/fts5/test/fts5dlidx.test a7c42b0a74dc7c8aa1a46d586e0aadda4b6cc42c24450f8d3774b21166e93159 @@ -2215,9 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7d5ff86ef7386f4f7f6a956dc0de607e61040d335c9f98d1f71e76a39f4f5e03 81d48df62ccf8b56e7adbc5327103e8ab5499bb22e587c4f0d0780a66adbdb67 -R a123da90db9c6c32b958de081bea877e -T +closed 81d48df62ccf8b56e7adbc5327103e8ab5499bb22e587c4f0d0780a66adbdb67 +P 58313ac59e0bd164f601d68a1474f658c5d1c038638e00f3dc15eb58202e661c +R c9854e52c5a2262f4abddd59c7216292 U dan -Z 2e9bc797f2c159dea04278d2c7653c83 +Z 46008f325e9f0a47cd9f68f44b346532 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 806f03565e..28469eeaae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -58313ac59e0bd164f601d68a1474f658c5d1c038638e00f3dc15eb58202e661c +b1f001435eff72c2119ecee973194385f70fd1b66ef0be8a66c0b0ad02ae43df From 46a62afbaba8e4e47d86ce9a03c242aa12402e99 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 2 Oct 2024 18:54:40 +0000 Subject: [PATCH 22/77] Modify the behavior of sqlite_dbpage so that the null-INSERT that truncates a database must be the very last INSERT operation within a transaction in order to be effective. This simplifies the code and also makes the behavior easier to document and understand. FossilOrigin-Name: b869a7d9ce9567a61d2257272032aaee705bbc6158c7f2cd36e7f3ee66d72722 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/dbpage.c | 48 +++++++++++++++++++----------------------------- 3 files changed, 27 insertions(+), 37 deletions(-) diff --git a/manifest b/manifest index 2f603be8f6..23af5a0848 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\sfts5delete.test. -D 2024-10-02T17:43:06.145 +C Modify\sthe\sbehavior\sof\ssqlite_dbpage\sso\sthat\sthe\snull-INSERT\sthat\struncates\na\sdatabase\smust\sbe\sthe\svery\slast\sINSERT\soperation\swithin\sa\stransaction\sin\sorder\nto\sbe\seffective.\s\sThis\ssimplifies\sthe\scode\sand\salso\smakes\sthe\sbehavior\neasier\sto\sdocument\sand\sunderstand. +D 2024-10-02T18:54:40.278 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -716,7 +716,7 @@ F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d49 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c b224d3db0f28c4a5f1407c50107a0a8133bd244ff3c7f6f8cedeb896a8cf1b64 F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a -F src/dbpage.c 9da735cb2eef4ab6941ddb235c8d2c2764e0bb5bd20f7ca3003be1d4ab8d49c9 +F src/dbpage.c 6199d8c8d6d37a405a92a5da4ed9a69829d7453e6d5ea7b852d58d1fd41d549c F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 @@ -2215,8 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 58313ac59e0bd164f601d68a1474f658c5d1c038638e00f3dc15eb58202e661c -R c9854e52c5a2262f4abddd59c7216292 -U dan -Z 46008f325e9f0a47cd9f68f44b346532 +P b1f001435eff72c2119ecee973194385f70fd1b66ef0be8a66c0b0ad02ae43df +R cb980b8ea9ae6c90e71d1e6639808d4a +U drh +Z 0bd24346b1d9b6d9280a2c12dd94f943 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 28469eeaae..93c9829452 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b1f001435eff72c2119ecee973194385f70fd1b66ef0be8a66c0b0ad02ae43df +b869a7d9ce9567a61d2257272032aaee705bbc6158c7f2cd36e7f3ee66d72722 diff --git a/src/dbpage.c b/src/dbpage.c index 136c8b0b39..0a2020883f 100644 --- a/src/dbpage.c +++ b/src/dbpage.c @@ -57,8 +57,8 @@ struct DbpageCursor { struct DbpageTable { sqlite3_vtab base; /* Base class. Must be first */ sqlite3 *db; /* The database */ - int nTrunc; /* Entries in aTrunc[] */ - Pgno *aTrunc; /* Truncation size for each database */ + int iDbTrunc; /* Database to truncate */ + Pgno pgnoTrunc; /* Size to truncate to */ }; /* Columns */ @@ -107,8 +107,6 @@ static int dbpageConnect( ** Disconnect from or destroy a dbpagevfs virtual table. */ static int dbpageDisconnect(sqlite3_vtab *pVtab){ - DbpageTable *pTab = (DbpageTable *)pVtab; - sqlite3_free(pTab->aTrunc); sqlite3_free(pVtab); return SQLITE_OK; } @@ -378,19 +376,9 @@ static int dbpageUpdate( if( sqlite3_value_type(argv[3])==SQLITE_NULL && isInsert && pgno>1 ){ /* "INSERT INTO dbpage($PGNO,NULL)" causes page number $PGNO and ** all subsequent pages to be deleted. */ - if( iDb>=pTab->nTrunc ){ - testcase( pTab->aTrunc!=0 ); - pTab->aTrunc = sqlite3_realloc(pTab->aTrunc, (iDb+1)*sizeof(Pgno)); - if( pTab->aTrunc ){ - int j; - for(j=pTab->nTrunc; jaTrunc[j] = 0; - pTab->nTrunc = iDb+1; - }else{ - return SQLITE_NOMEM; - } - } + pTab->iDbTrunc = iDb; pgno--; - pTab->aTrunc[iDb] = pgno; + pTab->pgnoTrunc = pgno; }else{ zErr = "bad page value"; goto update_fail; @@ -403,6 +391,7 @@ static int dbpageUpdate( if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){ unsigned char *aPage = sqlite3PagerGetData(pDbPage); memcpy(aPage, pData, szPage); + pTab->pgnoTrunc = 0; } } sqlite3PagerUnref(pDbPage); @@ -426,29 +415,30 @@ static int dbpageBegin(sqlite3_vtab *pVtab){ Btree *pBt = db->aDb[i].pBt; if( pBt ) (void)sqlite3BtreeBeginTrans(pBt, 1, 0); } - if( pTab->nTrunc>0 ){ - memset(pTab->aTrunc, 0, sizeof(pTab->aTrunc[0])*pTab->nTrunc); - } + pTab->pgnoTrunc = 0; return SQLITE_OK; } /* Invoke sqlite3PagerTruncate() as necessary, just prior to COMMIT */ static int dbpageSync(sqlite3_vtab *pVtab){ - int iDb; DbpageTable *pTab = (DbpageTable *)pVtab; - - for(iDb=0; iDbnTrunc; iDb++){ - if( pTab->aTrunc[iDb]>0 ){ - Btree *pBt = pTab->db->aDb[iDb].pBt; - Pager *pPager = sqlite3BtreePager(pBt); - sqlite3PagerTruncateImage(pPager, pTab->aTrunc[iDb]); - pTab->aTrunc[iDb] = 0; - } + if( pTab->pgnoTrunc>0 ){ + Btree *pBt = pTab->db->aDb[pTab->iDbTrunc].pBt; + Pager *pPager = sqlite3BtreePager(pBt); + sqlite3PagerTruncateImage(pPager, pTab->pgnoTrunc); } + pTab->pgnoTrunc = 0; return SQLITE_OK; } +/* Cancel any pending truncate. +*/ +static dbpageRollbackTo(sqlite3_vtab *pVtab, int notUsed1){ + DbpageTable *pTab = (DbpageTable *)pVtab; + pTab->pgnoTrunc = 0; + (void)notUsed1; +} /* ** Invoke this routine to register the "dbpage" virtual table module @@ -477,7 +467,7 @@ int sqlite3DbpageRegister(sqlite3 *db){ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ - 0, /* xRollbackTo */ + dbpageRollbackTo, /* xRollbackTo */ 0, /* xShadowName */ 0 /* xIntegrity */ }; From c51dccbd8bacbe2d25d4285b48820a264f13d572 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 3 Oct 2024 09:53:44 +0000 Subject: [PATCH 23/77] Fix missing return value from the new dbpageRollbackTo() callback. FossilOrigin-Name: d1e0992e1f2885be9725d872b8688806e06788f3d66a70de86255179d93f74d3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/dbpage.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 23af5a0848..819246082f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sthe\sbehavior\sof\ssqlite_dbpage\sso\sthat\sthe\snull-INSERT\sthat\struncates\na\sdatabase\smust\sbe\sthe\svery\slast\sINSERT\soperation\swithin\sa\stransaction\sin\sorder\nto\sbe\seffective.\s\sThis\ssimplifies\sthe\scode\sand\salso\smakes\sthe\sbehavior\neasier\sto\sdocument\sand\sunderstand. -D 2024-10-02T18:54:40.278 +C Fix\smissing\sreturn\svalue\sfrom\sthe\snew\sdbpageRollbackTo()\scallback. +D 2024-10-03T09:53:44.301 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -716,7 +716,7 @@ F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d49 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c b224d3db0f28c4a5f1407c50107a0a8133bd244ff3c7f6f8cedeb896a8cf1b64 F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a -F src/dbpage.c 6199d8c8d6d37a405a92a5da4ed9a69829d7453e6d5ea7b852d58d1fd41d549c +F src/dbpage.c 83d8ac377c3dc293ff8b6d36edceffe3b703be954807ae44b1207086e9dff839 F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 @@ -2215,8 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b1f001435eff72c2119ecee973194385f70fd1b66ef0be8a66c0b0ad02ae43df -R cb980b8ea9ae6c90e71d1e6639808d4a +P b869a7d9ce9567a61d2257272032aaee705bbc6158c7f2cd36e7f3ee66d72722 +R 7bc0596096bbb333fc73b05e652b41df U drh -Z 0bd24346b1d9b6d9280a2c12dd94f943 +Z 0297a20d69432f196ae033089ef7da4d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 93c9829452..6a7530fd47 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b869a7d9ce9567a61d2257272032aaee705bbc6158c7f2cd36e7f3ee66d72722 +d1e0992e1f2885be9725d872b8688806e06788f3d66a70de86255179d93f74d3 diff --git a/src/dbpage.c b/src/dbpage.c index 0a2020883f..76e79f9546 100644 --- a/src/dbpage.c +++ b/src/dbpage.c @@ -434,7 +434,7 @@ static int dbpageSync(sqlite3_vtab *pVtab){ /* Cancel any pending truncate. */ -static dbpageRollbackTo(sqlite3_vtab *pVtab, int notUsed1){ +static int dbpageRollbackTo(sqlite3_vtab *pVtab, int notUsed1){ DbpageTable *pTab = (DbpageTable *)pVtab; pTab->pgnoTrunc = 0; (void)notUsed1; From 1e2834dd45069a664822ae3f75db00b8bf285e39 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 3 Oct 2024 10:06:51 +0000 Subject: [PATCH 24/77] Fix to the previous: The dbpageRollbackTo() method should return SQLITE_OK. FossilOrigin-Name: 4dea7221129350a15df8dee5aabd5567e47adda4d255b65d4ba82fd821913759 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/dbpage.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 819246082f..e6055c8eb3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\smissing\sreturn\svalue\sfrom\sthe\snew\sdbpageRollbackTo()\scallback. -D 2024-10-03T09:53:44.301 +C Fix\sto\sthe\sprevious:\s\sThe\sdbpageRollbackTo()\smethod\sshould\sreturn\sSQLITE_OK. +D 2024-10-03T10:06:51.322 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -716,7 +716,7 @@ F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d49 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c b224d3db0f28c4a5f1407c50107a0a8133bd244ff3c7f6f8cedeb896a8cf1b64 F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a -F src/dbpage.c 83d8ac377c3dc293ff8b6d36edceffe3b703be954807ae44b1207086e9dff839 +F src/dbpage.c db1be8adaf1f839ad733c08baeac5c22aa912f7b535865c0c061382602081360 F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 @@ -2215,8 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b869a7d9ce9567a61d2257272032aaee705bbc6158c7f2cd36e7f3ee66d72722 -R 7bc0596096bbb333fc73b05e652b41df +P d1e0992e1f2885be9725d872b8688806e06788f3d66a70de86255179d93f74d3 +R 07d0f94fc8d3eb3dc6f1d0e0fdfaf3d3 U drh -Z 0297a20d69432f196ae033089ef7da4d +Z a4eec9783f650abfafca00d3ce1f718c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 6a7530fd47..e8bc481a7c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d1e0992e1f2885be9725d872b8688806e06788f3d66a70de86255179d93f74d3 +4dea7221129350a15df8dee5aabd5567e47adda4d255b65d4ba82fd821913759 diff --git a/src/dbpage.c b/src/dbpage.c index 76e79f9546..a0ee9246dc 100644 --- a/src/dbpage.c +++ b/src/dbpage.c @@ -438,6 +438,7 @@ static int dbpageRollbackTo(sqlite3_vtab *pVtab, int notUsed1){ DbpageTable *pTab = (DbpageTable *)pVtab; pTab->pgnoTrunc = 0; (void)notUsed1; + return SQLITE_OK; } /* From 51bbf0c7b88db09970dd34844180b299db1ce032 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 3 Oct 2024 16:31:08 +0000 Subject: [PATCH 25/77] Unconditionally include <ctype.h> in sqliteInt.h, even in builds where it is not needed. FossilOrigin-Name: 825f01d7e258ac7981f715fd10708560381b079f0e026abc414cf56d16d862da --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 10 +--------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index e6055c8eb3..dd25afaa33 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sto\sthe\sprevious:\s\sThe\sdbpageRollbackTo()\smethod\sshould\sreturn\sSQLITE_OK. -D 2024-10-03T10:06:51.322 +C Unconditionally\sinclude\s<ctype.h>\sin\ssqliteInt.h,\seven\sin\sbuilds\swhere\nit\sis\snot\sneeded. +D 2024-10-03T16:31:08.852 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -774,7 +774,7 @@ F src/shell.c.in 981efe98f98a983c1d0193d18528eb2d765207c0c82b67b610be60f17995a43 F src/sqlite.h.in 8a6dfab34cf3ad687346446a8c930e49132770ac380e8317f1aa3383e86fcaed F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 6ffd984ac04b5cfbe03f985a79d4664fe40be1198482add1c3de1137a8d9b86f +F src/sqliteInt.h 989dca8b25ca11f5c52e5a457cc500042c43b0b3e5fea9a12d9020d0350722cd F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -2215,8 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d1e0992e1f2885be9725d872b8688806e06788f3d66a70de86255179d93f74d3 -R 07d0f94fc8d3eb3dc6f1d0e0fdfaf3d3 +P 4dea7221129350a15df8dee5aabd5567e47adda4d255b65d4ba82fd821913759 +R f2244f797434d5d72e0a77b20c024462 U drh -Z a4eec9783f650abfafca00d3ce1f718c +Z 01a73e86129b00ff79017b970432daf9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e8bc481a7c..4b29a72009 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4dea7221129350a15df8dee5aabd5567e47adda4d255b65d4ba82fd821913759 +825f01d7e258ac7981f715fd10708560381b079f0e026abc414cf56d16d862da diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 2b800abd95..0e0035ce60 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -638,6 +638,7 @@ #include #include #include +#include /* ** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY. @@ -4632,15 +4633,6 @@ int sqlite3CantopenError(int); # define SQLITE_ENABLE_FTS3 1 #endif -/* -** The ctype.h header is needed for non-ASCII systems. It is also -** needed by FTS3 when FTS3 is included in the amalgamation. -*/ -#if !defined(SQLITE_ASCII) || \ - (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION)) -# include -#endif - /* ** The following macros mimic the standard library functions toupper(), ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The From c8c95f514947b26f522183bfa7c5db76c5df9285 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 4 Oct 2024 17:02:36 +0000 Subject: [PATCH 26/77] Fix typo in documentation for SQLITE_SUBTYPE. No code changes. FossilOrigin-Name: 6733893f450097e07cbd563d6a46790825fd0689283d60181c09793ce7d5509e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index dd25afaa33..85f652cffa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Unconditionally\sinclude\s<ctype.h>\sin\ssqliteInt.h,\seven\sin\sbuilds\swhere\nit\sis\snot\sneeded. -D 2024-10-03T16:31:08.852 +C Fix\stypo\sin\sdocumentation\sfor\sSQLITE_SUBTYPE.\sNo\scode\schanges. +D 2024-10-04T17:02:36.758 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -771,7 +771,7 @@ F src/resolve.c 9750a281f7ba073b4e6da2be1a6c4071f5d841a7746c5fb3f70d6d793b6675ea F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe F src/shell.c.in 981efe98f98a983c1d0193d18528eb2d765207c0c82b67b610be60f17995a43e -F src/sqlite.h.in 8a6dfab34cf3ad687346446a8c930e49132770ac380e8317f1aa3383e86fcaed +F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h 989dca8b25ca11f5c52e5a457cc500042c43b0b3e5fea9a12d9020d0350722cd @@ -2215,8 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4dea7221129350a15df8dee5aabd5567e47adda4d255b65d4ba82fd821913759 -R f2244f797434d5d72e0a77b20c024462 -U drh -Z 01a73e86129b00ff79017b970432daf9 +P 825f01d7e258ac7981f715fd10708560381b079f0e026abc414cf56d16d862da +R 97cc1dd0446101afb82e95a43b8cd5d1 +U dan +Z 7fafcff3019d45fab79373554fe0a5e2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4b29a72009..9b7bdc0c33 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -825f01d7e258ac7981f715fd10708560381b079f0e026abc414cf56d16d862da +6733893f450097e07cbd563d6a46790825fd0689283d60181c09793ce7d5509e diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 27f7a8cfeb..5108d3c1e9 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5603,7 +5603,7 @@ int sqlite3_create_window_function( ** This flag instructs SQLite to omit some corner-case optimizations that ** might disrupt the operation of the [sqlite3_value_subtype()] function, ** causing it to return zero rather than the correct subtype(). -** SQL functions that invokes [sqlite3_value_subtype()] should have this +** All SQL functions that invoke [sqlite3_value_subtype()] should have this ** property. If the SQLITE_SUBTYPE property is omitted, then the return ** value from [sqlite3_value_subtype()] might sometimes be zero even though ** a non-zero subtype was specified by the function argument expression. From 706fdeebb834a11fedc5e9473f951af79e6f2d65 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 5 Oct 2024 12:02:17 +0000 Subject: [PATCH 27/77] Add ext/wasm to the top-level clean/distclean rules in such a way that any error due to a lack of gmake are ignored. FossilOrigin-Name: 2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f --- Makefile.in | 2 ++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Makefile.in b/Makefile.in index 6fc821da23..91ba94c1aa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1663,11 +1663,13 @@ tidy: # clean: tidy rm -rf omittest* testrunner* testdir* + -gmake -C ext/wasm clean # Clean up everything. No exceptions. # distclean: clean rm -f sqlite_cfg.h config.log config.status Makefile $(LIBTOOL) + -gmake -C ext/wasm distclean # # Windows section diff --git a/manifest b/manifest index 85f652cffa..3a576a9093 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Fix\stypo\sin\sdocumentation\sfor\sSQLITE_SUBTYPE.\sNo\scode\schanges. -D 2024-10-04T17:02:36.758 +C Add\sext/wasm\sto\sthe\stop-level\sclean/distclean\srules\sin\ssuch\sa\sway\sthat\sany\serror\sdue\sto\sa\slack\sof\sgmake\sare\signored. +D 2024-10-05T12:02:17.445 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 6a826facc78c3c8ad38bf00ed588f6aa3665ccd7a9749b891d20582fc290c77e +F Makefile.in 71c69b6eb6d8a5e2d418ab80d16f3621099d58f8afabe4ab0d7240c5ca57494a F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 9c6d80d9d103fa42e931f4c464884a5e577fae8563acc7589bff4e43fbe8f864 F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -2215,8 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 825f01d7e258ac7981f715fd10708560381b079f0e026abc414cf56d16d862da -R 97cc1dd0446101afb82e95a43b8cd5d1 -U dan -Z 7fafcff3019d45fab79373554fe0a5e2 +P 6733893f450097e07cbd563d6a46790825fd0689283d60181c09793ce7d5509e +R 749ae8645be170a25b1c641eade23387 +U stephan +Z c3b0bf3081778b6e6721957f472a53c9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9b7bdc0c33..717f299acd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6733893f450097e07cbd563d6a46790825fd0689283d60181c09793ce7d5509e +2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f From c857b9eb5d9cfab1366fb80e5d1c306e340b6d65 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 5 Oct 2024 17:37:19 +0000 Subject: [PATCH 28/77] Experimental change to allow expressions with subtypes to be read from indexes in situations where they are not used as function parameters. FossilOrigin-Name: ac63f98ad85a4dd1e49cc64b41f0ca0044153972c15d71c669f4bc3ec590e268 --- manifest | 22 ++++++++------ manifest.uuid | 2 +- src/expr.c | 70 ++++++++++++++++++++++++++++++++++++++++++++ src/sqliteInt.h | 2 +- src/where.c | 58 ------------------------------------ test/indexexpr3.test | 70 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 155 insertions(+), 69 deletions(-) create mode 100644 test/indexexpr3.test diff --git a/manifest b/manifest index 3a576a9093..37b5b5e282 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sext/wasm\sto\sthe\stop-level\sclean/distclean\srules\sin\ssuch\sa\sway\sthat\sany\serror\sdue\sto\sa\slack\sof\sgmake\sare\signored. -D 2024-10-05T12:02:17.445 +C Experimental\schange\sto\sallow\sexpressions\swith\ssubtypes\sto\sbe\sread\sfrom\sindexes\sin\ssituations\swhere\sthey\sare\snot\sused\sas\sfunction\sparameters. +D 2024-10-05T17:37:19.432 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -719,7 +719,7 @@ F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a F src/dbpage.c db1be8adaf1f839ad733c08baeac5c22aa912f7b535865c0c061382602081360 F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 -F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 +F src/expr.c 9441dc9f9f4dd3a172270d3dbf476d709aa82ca9bab73a5f3bb878654afe4424 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f F src/func.c df400a1d3f4625997d4dd8a81951c303e066277c29b861d37e03cd152d7858dd @@ -774,7 +774,7 @@ F src/shell.c.in 981efe98f98a983c1d0193d18528eb2d765207c0c82b67b610be60f17995a43 F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 989dca8b25ca11f5c52e5a457cc500042c43b0b3e5fea9a12d9020d0350722cd +F src/sqliteInt.h 40552bd22f4bc3330f2a73633d12f12863c5aa4e409af75f8ebfaeb794b11e4f F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -854,7 +854,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c a0d42bfdef935e1389737152394d08e59e7c48697f40a9fc2e0552cb19dc731f F src/wal.h ba252daaa94f889f4b2c17c027e823d9be47ce39da1d3799886bbd51f0490452 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 -F src/where.c 461d41017d900d4248a268df96d2d30506c4dcc2257f4167c4f46072003ce2cf +F src/where.c 12fe24880901997372b88fd7ca9a21457404ad35201712c02cc57978578abb10 F src/whereInt.h a5d079c346a658b7a6e9e47bb943d021e02fa1e6aed3b964ca112112a4892192 F src/wherecode.c 5172d647798134e7c92536ddffe7e530c393d79b5dedd648b88faf2646c65baf F src/whereexpr.c 44f41ae554c7572e1de1485b3169b233ee04d464b2ee5881687ede3bf07cacfa @@ -1324,6 +1324,7 @@ F test/indexA.test 11d84f6995e6e5b9d8315953fb1b6d29772ee7c7803ee9112715e7e4dd3e4 F test/indexedby.test f21eca4f7a6ffe14c8500a7ad6cd53166666c99e5ccd311842a28bc94a195fe0 F test/indexexpr1.test 24fa85a12da384dd1d56f7b24e593c51a8a54b4c5e2e8bbb9e5fdf1099427faf F test/indexexpr2.test 1c382e81ef996d8ae8b834a74f2a9013dddf59214c32201d7c8a656d739f999a +F test/indexexpr3.test 7689d11a60dca09879f490db5fd26b9171a57e31d97282d9963e944b1536f676 F test/indexfault.test 98d78a8ff1f5335628b62f886a1cb7c7dac1ef6d48fa39c51ec871c87dce9811 F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 F test/insert.test 4e3f0de67aac3c5be1f4aaedbcea11638f1b5cdc9a3115be14d19aa9db7623c6 @@ -2215,8 +2216,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6733893f450097e07cbd563d6a46790825fd0689283d60181c09793ce7d5509e -R 749ae8645be170a25b1c641eade23387 -U stephan -Z c3b0bf3081778b6e6721957f472a53c9 +P 2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f +R 05b36287276c4340f7e35170606a310b +T *branch * indexed-subtype-expr +T *sym-indexed-subtype-expr * +T -sym-trunk * +U dan +Z 943b26137ccac8e38cc1774f405e6dc0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 717f299acd..a0670d9728 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f +ac63f98ad85a4dd1e49cc64b41f0ca0044153972c15d71c669f4bc3ec590e268 diff --git a/src/expr.c b/src/expr.c index 1b18828dd6..83b1ff56cd 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1164,6 +1164,7 @@ Expr *sqlite3ExprFunction( ){ Expr *pNew; sqlite3 *db = pParse->db; + int ii; assert( pToken ); pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1); if( pNew==0 ){ @@ -1178,6 +1179,11 @@ Expr *sqlite3ExprFunction( ){ sqlite3ErrorMsg(pParse, "too many arguments on function %T", pToken); } + if( pList && pParse->nErr==0 ){ + for(ii=0; iinExpr; ii++){ + ExprSetProperty(pList->a[ii].pExpr, EP_FuncArg); + } + } pNew->x.pList = pList; ExprSetProperty(pNew, EP_HasFunc); assert( ExprUseXList(pNew) ); @@ -4554,6 +4560,59 @@ static int exprCodeInlineFunction( return target; } +/* +** Expression Node callback for sqlite3ExprCanReturnSubtype(). +** +** Only a function call is able to return a subtype. So if the node +** is not a function call, return WRC_Prune immediately. +** +** A function call is able to return a subtype if it has the +** SQLITE_RESULT_SUBTYPE property. +** +** Assume that every function is able to pass-through a subtype from +** one of its argument (using sqlite3_result_value()). Most functions +** are not this way, but we don't have a mechanism to distinguish those +** that are from those that are not, so assume they all work this way. +** That means that if one of its arguments is another function and that +** other function is able to return a subtype, then this function is +** able to return a subtype. +*/ +static int exprNodeCanReturnSubtype(Walker *pWalker, Expr *pExpr){ + int n; + FuncDef *pDef; + sqlite3 *db; + if( pExpr->op!=TK_FUNCTION ){ + return WRC_Prune; + } + assert( ExprUseXList(pExpr) ); + db = pWalker->pParse->db; + n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; + pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0); + if( pDef==0 || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ + pWalker->eCode = 1; + return WRC_Prune; + } + return WRC_Continue; +} + +/* +** Return TRUE if expression pExpr is able to return a subtype. +** +** A TRUE return does not guarantee that a subtype will be returned. +** It only indicates that a subtype return is possible. False positives +** are acceptable as they only disable an optimization. False negatives, +** on the other hand, can lead to incorrect answers. +*/ +static int sqlite3ExprCanReturnSubtype(Parse *pParse, Expr *pExpr){ + Walker w; + memset(&w, 0, sizeof(w)); + w.pParse = pParse; + w.xExprCallback = exprNodeCanReturnSubtype; + sqlite3WalkExpr(&w, pExpr); + return w.eCode; +} + + /* ** Check to see if pExpr is one of the indexed expressions on pParse->pIdxEpr. ** If it is, then resolve the expression by reading from the index and @@ -4586,6 +4645,17 @@ static SQLITE_NOINLINE int sqlite3IndexedExprLookup( continue; } + + /* Functions that might set a subtype should not be replaced by the + ** value taken from an expression index if they are themselves an + ** argument to another scalar function or aggregate. + ** https://sqlite.org/forum/forumpost/68d284c86b082c3e */ + if( ExprHasProperty(pExpr, EP_FuncArg) + && sqlite3ExprCanReturnSubtype(pParse, pExpr) + ){ + continue; + } + v = pParse->pVdbe; assert( v!=0 ); if( p->bMaybeNullRow ){ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 0e0035ce60..8288786700 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3104,7 +3104,7 @@ struct Expr { #define EP_IsTrue 0x10000000 /* Always has boolean value of TRUE */ #define EP_IsFalse 0x20000000 /* Always has boolean value of FALSE */ #define EP_FromDDL 0x40000000 /* Originates from sqlite_schema */ - /* 0x80000000 // Available */ +#define EP_FuncArg 0x80000000 /* Is a function() argument */ /* The EP_Propagate mask is a set of properties that automatically propagate ** upwards into parent nodes. diff --git a/src/where.c b/src/where.c index 9aaa082cd3..c2fc338247 100644 --- a/src/where.c +++ b/src/where.c @@ -6302,58 +6302,6 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful( } } -/* -** Expression Node callback for sqlite3ExprCanReturnSubtype(). -** -** Only a function call is able to return a subtype. So if the node -** is not a function call, return WRC_Prune immediately. -** -** A function call is able to return a subtype if it has the -** SQLITE_RESULT_SUBTYPE property. -** -** Assume that every function is able to pass-through a subtype from -** one of its argument (using sqlite3_result_value()). Most functions -** are not this way, but we don't have a mechanism to distinguish those -** that are from those that are not, so assume they all work this way. -** That means that if one of its arguments is another function and that -** other function is able to return a subtype, then this function is -** able to return a subtype. -*/ -static int exprNodeCanReturnSubtype(Walker *pWalker, Expr *pExpr){ - int n; - FuncDef *pDef; - sqlite3 *db; - if( pExpr->op!=TK_FUNCTION ){ - return WRC_Prune; - } - assert( ExprUseXList(pExpr) ); - db = pWalker->pParse->db; - n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; - pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0); - if( pDef==0 || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ - pWalker->eCode = 1; - return WRC_Prune; - } - return WRC_Continue; -} - -/* -** Return TRUE if expression pExpr is able to return a subtype. -** -** A TRUE return does not guarantee that a subtype will be returned. -** It only indicates that a subtype return is possible. False positives -** are acceptable as they only disable an optimization. False negatives, -** on the other hand, can lead to incorrect answers. -*/ -static int sqlite3ExprCanReturnSubtype(Parse *pParse, Expr *pExpr){ - Walker w; - memset(&w, 0, sizeof(w)); - w.pParse = pParse; - w.xExprCallback = exprNodeCanReturnSubtype; - sqlite3WalkExpr(&w, pExpr); - return w.eCode; -} - /* ** The index pIdx is used by a query and contains one or more expressions. ** In other words pIdx is an index on an expression. iIdxCur is the cursor @@ -6387,12 +6335,6 @@ static SQLITE_NOINLINE void whereAddIndexedExpr( continue; } if( sqlite3ExprIsConstant(0,pExpr) ) continue; - if( pExpr->op==TK_FUNCTION && sqlite3ExprCanReturnSubtype(pParse,pExpr) ){ - /* Functions that might set a subtype should not be replaced by the - ** value taken from an expression index since the index omits the - ** subtype. https://sqlite.org/forum/forumpost/68d284c86b082c3e */ - continue; - } p = sqlite3DbMallocRaw(pParse->db, sizeof(IndexedExpr)); if( p==0 ) break; p->pIENext = pParse->pIdxEpr; diff --git a/test/indexexpr3.test b/test/indexexpr3.test new file mode 100644 index 0000000000..e3cfcd116a --- /dev/null +++ b/test/indexexpr3.test @@ -0,0 +1,70 @@ +# 2024-10-05 +# +# 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 file is testing indexes on expressions. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix indexexpr3 + + +do_execsql_test 1.0 { + CREATE TABLE t1(a, j); + INSERT INTO t1 VALUES(1, '{x:"one"}'); + INSERT INTO t1 VALUES(2, '{x:"two"}'); + INSERT INTO t1 VALUES(3, '{x:"three"}'); + + CREATE INDEX i1 ON t1( json_extract(j, '$.x') ); + CREATE INDEX i2 ON t1( a, json_extract(j, '$.x') ); +} + +proc do_hasfunction_test {tn sql res} { + set bFunction 0 + db eval "EXPLAIN $sql" x { + if {$x(opcode)=="Function"} { + set bFunction 1 + } + } + + do_execsql_test $tn " + SELECT $bFunction; + $sql + " $res +} + +do_hasfunction_test 1.1 { + SELECT json_extract(j, '$.x') FROM t1 ORDER BY 1; +} { + 0 one three two +} + +do_hasfunction_test 1.2 { + SELECT json_extract(j, '$.x') FROM t1 WHERE a=2 +} { + 0 two +} + +do_hasfunction_test 1.3 { + SELECT coalesce(json_extract(j, '$.x'), 0) FROM t1 WHERE a=2 +} { + 1 two +} + +do_hasfunction_test 1.3 { + SELECT json_extract(j, '$.x') || '.two' FROM t1 WHERE a=2 +} { + 0 two.two +} + + +finish_test + From d564bdb0507aabce5d64905734d5d7e050a2c86d Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 5 Oct 2024 18:10:02 +0000 Subject: [PATCH 29/77] Allow expressions with subtypes to be read from indexes unless they are being used as direct or indirect parameters to SQLITE_SUBTYPE functions. FossilOrigin-Name: aa440e78e9004c7ca3e03beaf264f54d0070ad7298a3c96ca097d8b35c872e5f --- manifest | 21 +++++++++------------ manifest.uuid | 2 +- src/expr.c | 8 +------- src/resolve.c | 18 ++++++++++++++++++ src/sqliteInt.h | 2 +- test/indexexpr3.test | 25 +++++++++++++++++++------ 6 files changed, 49 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index 37b5b5e282..4f91484dbd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Experimental\schange\sto\sallow\sexpressions\swith\ssubtypes\sto\sbe\sread\sfrom\sindexes\sin\ssituations\swhere\sthey\sare\snot\sused\sas\sfunction\sparameters. -D 2024-10-05T17:37:19.432 +C Allow\sexpressions\swith\ssubtypes\sto\sbe\sread\sfrom\sindexes\sunless\sthey\sare\sbeing\sused\sas\sdirect\sor\sindirect\sparameters\sto\sSQLITE_SUBTYPE\sfunctions. +D 2024-10-05T18:10:02.045 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -719,7 +719,7 @@ F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a F src/dbpage.c db1be8adaf1f839ad733c08baeac5c22aa912f7b535865c0c061382602081360 F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 -F src/expr.c 9441dc9f9f4dd3a172270d3dbf476d709aa82ca9bab73a5f3bb878654afe4424 +F src/expr.c 0aafe1b0d3893e9f568f30efa2e7b96a6e6bcc072e481ae68c5abe3f01d81367 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f F src/func.c df400a1d3f4625997d4dd8a81951c303e066277c29b861d37e03cd152d7858dd @@ -767,14 +767,14 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 3ba0ad907b7773ed642f66cea8a2c9c8edc18841aa1050b6218dbb3479e86225 F src/printf.c 6a87534ebfb9e5346011191b1f3a7ebc457f5938c7e4feeea478ecf53f6a41b2 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c -F src/resolve.c 9750a281f7ba073b4e6da2be1a6c4071f5d841a7746c5fb3f70d6d793b6675ea +F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe F src/shell.c.in 981efe98f98a983c1d0193d18528eb2d765207c0c82b67b610be60f17995a43e F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 -F src/sqliteInt.h 40552bd22f4bc3330f2a73633d12f12863c5aa4e409af75f8ebfaeb794b11e4f +F src/sqliteInt.h ad02397dc4d22b77f9a331412d46e4c1e49459dd386fba8373fa148998e1e7d0 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -1324,7 +1324,7 @@ F test/indexA.test 11d84f6995e6e5b9d8315953fb1b6d29772ee7c7803ee9112715e7e4dd3e4 F test/indexedby.test f21eca4f7a6ffe14c8500a7ad6cd53166666c99e5ccd311842a28bc94a195fe0 F test/indexexpr1.test 24fa85a12da384dd1d56f7b24e593c51a8a54b4c5e2e8bbb9e5fdf1099427faf F test/indexexpr2.test 1c382e81ef996d8ae8b834a74f2a9013dddf59214c32201d7c8a656d739f999a -F test/indexexpr3.test 7689d11a60dca09879f490db5fd26b9171a57e31d97282d9963e944b1536f676 +F test/indexexpr3.test 9d893bf440937ebcc1e59c7c9c1505c40c918346a3ddde76a69078f3c733c45d F test/indexfault.test 98d78a8ff1f5335628b62f886a1cb7c7dac1ef6d48fa39c51ec871c87dce9811 F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 F test/insert.test 4e3f0de67aac3c5be1f4aaedbcea11638f1b5cdc9a3115be14d19aa9db7623c6 @@ -2216,11 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f -R 05b36287276c4340f7e35170606a310b -T *branch * indexed-subtype-expr -T *sym-indexed-subtype-expr * -T -sym-trunk * +P ac63f98ad85a4dd1e49cc64b41f0ca0044153972c15d71c669f4bc3ec590e268 +R d7f4847c66a2bc32b5fcb862258f0d6b U dan -Z 943b26137ccac8e38cc1774f405e6dc0 +Z f387b8ba9011d1385bb9a2c14c76e4d1 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a0670d9728..2574038fb7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ac63f98ad85a4dd1e49cc64b41f0ca0044153972c15d71c669f4bc3ec590e268 +aa440e78e9004c7ca3e03beaf264f54d0070ad7298a3c96ca097d8b35c872e5f diff --git a/src/expr.c b/src/expr.c index 83b1ff56cd..506b92c828 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1164,7 +1164,6 @@ Expr *sqlite3ExprFunction( ){ Expr *pNew; sqlite3 *db = pParse->db; - int ii; assert( pToken ); pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1); if( pNew==0 ){ @@ -1179,11 +1178,6 @@ Expr *sqlite3ExprFunction( ){ sqlite3ErrorMsg(pParse, "too many arguments on function %T", pToken); } - if( pList && pParse->nErr==0 ){ - for(ii=0; iinExpr; ii++){ - ExprSetProperty(pList->a[ii].pExpr, EP_FuncArg); - } - } pNew->x.pList = pList; ExprSetProperty(pNew, EP_HasFunc); assert( ExprUseXList(pNew) ); @@ -4650,7 +4644,7 @@ static SQLITE_NOINLINE int sqlite3IndexedExprLookup( ** value taken from an expression index if they are themselves an ** argument to another scalar function or aggregate. ** https://sqlite.org/forum/forumpost/68d284c86b082c3e */ - if( ExprHasProperty(pExpr, EP_FuncArg) + if( ExprHasProperty(pExpr, EP_SubtArg) && sqlite3ExprCanReturnSubtype(pParse, pExpr) ){ continue; diff --git a/src/resolve.c b/src/resolve.c index 8e8da66910..d6a5144af8 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -1183,6 +1183,24 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ } } #endif + + /* If the function may call sqlite3_value_subtype(), then set the + ** EP_SubtArg flag on all of its argument expressions. This prevents + ** where.c from replacing the expression with a value read from an + ** index on the same expression, which will not have the correct + ** subtype. Also set the flag if the function expression itself is + ** an EP_SubtArg expression. In this case subtypes are required as + ** the function may return a value with a subtype back to its + ** caller using sqlite3_result_value(). */ + if( (pDef->funcFlags & SQLITE_SUBTYPE) + || ExprHasProperty(pExpr, EP_SubtArg) + ){ + int ii; + for(ii=0; iia[ii].pExpr, EP_SubtArg); + } + } + if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){ /* For the purposes of the EP_ConstFunc flag, date and time ** functions and other functions that change slowly are considered diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 8288786700..f88b9e67c3 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3104,7 +3104,7 @@ struct Expr { #define EP_IsTrue 0x10000000 /* Always has boolean value of TRUE */ #define EP_IsFalse 0x20000000 /* Always has boolean value of FALSE */ #define EP_FromDDL 0x40000000 /* Originates from sqlite_schema */ -#define EP_FuncArg 0x80000000 /* Is a function() argument */ +#define EP_SubtArg 0x80000000 /* Is argument to SQLITE_SUBTYPE function */ /* The EP_Propagate mask is a set of properties that automatically propagate ** upwards into parent nodes. diff --git a/test/indexexpr3.test b/test/indexexpr3.test index e3cfcd116a..21e1d329ad 100644 --- a/test/indexexpr3.test +++ b/test/indexexpr3.test @@ -28,15 +28,15 @@ do_execsql_test 1.0 { } proc do_hasfunction_test {tn sql res} { - set bFunction 0 + set nFunction 0 db eval "EXPLAIN $sql" x { if {$x(opcode)=="Function"} { - set bFunction 1 + incr nFunction } } do_execsql_test $tn " - SELECT $bFunction; + SELECT $nFunction; $sql " $res } @@ -54,17 +54,30 @@ do_hasfunction_test 1.2 { } do_hasfunction_test 1.3 { - SELECT coalesce(json_extract(j, '$.x'), 0) FROM t1 WHERE a=2 + SELECT coalesce(json_extract(j, '$.x'), 'five') FROM t1 WHERE a=2 } { - 1 two + 0 two } -do_hasfunction_test 1.3 { +do_hasfunction_test 1.4 { SELECT json_extract(j, '$.x') || '.two' FROM t1 WHERE a=2 } { 0 two.two } +do_hasfunction_test 1.5 { + SELECT json_insert( '{}', '$.y', json_extract(j, '$.x') ) FROM t1 WHERE a=2 +} { + 2 {{"y":"two"}} +} + +do_hasfunction_test 1.6 { + SELECT json_insert( '{}', '$.y', coalesce( json_extract(j, '$.x'), 'five' ) ) + FROM t1 WHERE a=2 +} { + 2 {{"y":"two"}} +} + finish_test From 2c72c55dcac876e61a10b672489985f000038eff Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 5 Oct 2024 21:44:21 +0000 Subject: [PATCH 30/77] Back out [2f7eab381e16] because the stderr output on systems without gmake causes grief in the testing tools. FossilOrigin-Name: cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 --- Makefile.in | 2 -- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index 91ba94c1aa..6fc821da23 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1663,13 +1663,11 @@ tidy: # clean: tidy rm -rf omittest* testrunner* testdir* - -gmake -C ext/wasm clean # Clean up everything. No exceptions. # distclean: clean rm -f sqlite_cfg.h config.log config.status Makefile $(LIBTOOL) - -gmake -C ext/wasm distclean # # Windows section diff --git a/manifest b/manifest index 3a576a9093..8c049eb6a7 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\sext/wasm\sto\sthe\stop-level\sclean/distclean\srules\sin\ssuch\sa\sway\sthat\sany\serror\sdue\sto\sa\slack\sof\sgmake\sare\signored. -D 2024-10-05T12:02:17.445 +C Back\sout\s[2f7eab381e16]\sbecause\sthe\sstderr\soutput\son\ssystems\swithout\sgmake\scauses\sgrief\sin\sthe\stesting\stools. +D 2024-10-05T21:44:21.913 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 71c69b6eb6d8a5e2d418ab80d16f3621099d58f8afabe4ab0d7240c5ca57494a +F Makefile.in 6a826facc78c3c8ad38bf00ed588f6aa3665ccd7a9749b891d20582fc290c77e F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 9c6d80d9d103fa42e931f4c464884a5e577fae8563acc7589bff4e43fbe8f864 F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -2215,8 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6733893f450097e07cbd563d6a46790825fd0689283d60181c09793ce7d5509e -R 749ae8645be170a25b1c641eade23387 +P 2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f +R 97cc1dd0446101afb82e95a43b8cd5d1 U stephan -Z c3b0bf3081778b6e6721957f472a53c9 +Z 6431efa2a9010e78c1fbe7fa1b33270f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 717f299acd..aec7c8a62f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f +cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 From 74672acd946d12d23f65c3e07f9f88e407784145 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sun, 6 Oct 2024 15:01:31 +0000 Subject: [PATCH 31/77] New SQL function for testing/debugging use only: parseuri(). FossilOrigin-Name: 37d3b6b17e92b2c760239c3053bbc7fb85091acd688c54a73af7611fe9501312 --- manifest | 17 ++++++----- manifest.uuid | 2 +- src/func.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 95 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 8c049eb6a7..39ed9b3502 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Back\sout\s[2f7eab381e16]\sbecause\sthe\sstderr\soutput\son\ssystems\swithout\sgmake\scauses\sgrief\sin\sthe\stesting\stools. -D 2024-10-05T21:44:21.913 +C New\sSQL\sfunction\sfor\stesting/debugging\suse\sonly:\sparseuri(). +D 2024-10-06T15:01:31.737 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -722,7 +722,7 @@ F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f -F src/func.c df400a1d3f4625997d4dd8a81951c303e066277c29b861d37e03cd152d7858dd +F src/func.c ed6baeeb414ef18ce729793587dae8bd30f11e6aacec8675bd33727e0bcb3765 F src/global.c a19e4b1ca1335f560e9560e590fc13081e21f670643367f99cb9e8f9dc7d615b F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -2215,8 +2215,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f -R 97cc1dd0446101afb82e95a43b8cd5d1 -U stephan -Z 6431efa2a9010e78c1fbe7fa1b33270f +P cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 +R 6e07384677af3f3c36d6573a7730f2e0 +T *branch * parseuri +T *sym-parseuri * +T -sym-trunk * +U drh +Z a932a90a1e85d41407c9c1eb7bdee53f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aec7c8a62f..68845d202e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 +37d3b6b17e92b2c760239c3053bbc7fb85091acd688c54a73af7611fe9501312 diff --git a/src/func.c b/src/func.c index a634a7fbea..b17ffa52c4 100644 --- a/src/func.c +++ b/src/func.c @@ -2535,7 +2535,13 @@ static void signFunc( ** Implementation of fpdecode(x,y,z) function. ** ** x is a real number that is to be decoded. y is the precision. -** z is the maximum real precision. +** z is the maximum real precision. Return a string that shows the +** results of the sqlite3FpDecode() function. +** +** Used for testing and debugging only, specifically testing and debugging +** of the sqlite3FpDecode() function. This SQL function does not appear +** in production builds. This function is not an API and is subject to +** modification or removal in future versions of SQLite. */ static void fpdecodeFunc( sqlite3_context *context, @@ -2562,6 +2568,82 @@ static void fpdecodeFunc( } #endif /* SQLITE_DEBUG */ +#ifdef SQLITE_DEBUG +/* +** Implementation of parseuri(uri,flags) function. +** +** Required Arguments: +** "uri" The URI to parse. +** "flags" Bitmask of flags, as if to sqlite3_open_v2(). +** +** Additional arguments beyond the first two make calls to +** sqlite3_uri_key() for integers and sqlite3_uri_parameter for +** anything else. +** +** The result is a string showing the results of calling sqlite3ParseUri(). +** +** Used for testing and debugging only, specifically testing and debugging +** of the sqlite3ParseUri() function. This SQL function does not appear +** in production builds. This function is not an API and is subject to +** modification or removal in future versions of SQLite. +*/ +static void parseuriFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + sqlite3_str *pResult; + const char *zVfs; + const char *zUri; + unsigned int flgs; + int rc; + sqlite3_vfs *pVfs = 0; + char *zFile = 0; + char *zErr = 0; + + if( argc<2 ) return; + pVfs = sqlite3_vfs_find(0); + assert( pVfs ); + zVfs = pVfs->zName; + zUri = (const char*)sqlite3_value_text(argv[0]); + if( zUri==0 ) return; + flgs = (unsigned int)sqlite3_value_int(argv[1]); + rc = sqlite3ParseUri(zVfs, zUri, &flgs, &pVfs, &zFile, &zErr); + pResult = sqlite3_str_new(0); + if( pResult ){ + int i; + sqlite3_str_appendf(pResult, "rc=%d", rc); + sqlite3_str_appendf(pResult, ", flags=0x%x", flgs); + sqlite3_str_appendf(pResult, ", vfs=%Q", pVfs ? pVfs->zName: 0); + sqlite3_str_appendf(pResult, ", err=%Q", zErr); + sqlite3_str_appendf(pResult, ", file=%Q", zFile); + if( zFile ){ + const char *z = zFile; + z += sqlite3Strlen30(z)+1; + while( z[0] ){ + sqlite3_str_appendf(pResult, ", %Q", z); + z += sqlite3Strlen30(z)+1; + } + for(i=2; i Date: Sun, 6 Oct 2024 21:26:56 +0000 Subject: [PATCH 32/77] Origin should not send content for the lock-byte page to the replica, in sqlite3-rsync. [forum:/forumpost/d14b55e5fa19c25f|Forum post d14b55e5fa19c25f]. FossilOrigin-Name: aa9bd711cc1b0136098388976d22adc0a2fc89f50fe2273ed80ee3e4e50c98b6 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- tool/sqlite3-rsync.c | 3 +++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 39ed9b3502..ecfa81388e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C New\sSQL\sfunction\sfor\stesting/debugging\suse\sonly:\sparseuri(). -D 2024-10-06T15:01:31.737 +C Origin\sshould\snot\ssend\scontent\sfor\sthe\slock-byte\spage\sto\sthe\sreplica,\sin\nsqlite3-rsync.\n[forum:/forumpost/d14b55e5fa19c25f|Forum\spost\sd14b55e5fa19c25f]. +D 2024-10-06T21:26:56.282 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2176,7 +2176,7 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60 F tool/sqldiff.c 2a0987d183027c795ced13d6749061c1d2f38e24eddb428f56fa64c3a8f51e4b -F tool/sqlite3-rsync.c 2f06f02ee3a28f847b3fb8c0f32e3b3296571e0f8027939b95d32df5edfe1dd9 +F tool/sqlite3-rsync.c 7c78ba15afa0b929604adb91c94af8dbdf8cbe87be8a5cba5353af0e320ca65a F tool/sqlite3_analyzer.c.in 348ba349bbdc93c9866439f9f935d7284866a2a4e6898bc906ae1204ade56918 F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 @@ -2215,11 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 -R 6e07384677af3f3c36d6573a7730f2e0 -T *branch * parseuri -T *sym-parseuri * -T -sym-trunk * +P 37d3b6b17e92b2c760239c3053bbc7fb85091acd688c54a73af7611fe9501312 +R dbb5b993debce35e50244d3495f9b61e U drh -Z a932a90a1e85d41407c9c1eb7bdee53f +Z 45e873ac682d74f4a4a29dbca970bb7d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 68845d202e..c653996c4f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -37d3b6b17e92b2c760239c3053bbc7fb85091acd688c54a73af7611fe9501312 +aa9bd711cc1b0136098388976d22adc0a2fc89f50fe2273ed80ee3e4e50c98b6 diff --git a/tool/sqlite3-rsync.c b/tool/sqlite3-rsync.c index 216390c182..401c4b33ef 100644 --- a/tool/sqlite3-rsync.c +++ b/tool/sqlite3-rsync.c @@ -1197,6 +1197,7 @@ static void originSide(SQLiteRsync *p){ int c = 0; unsigned int nPage = 0; unsigned int iPage = 0; + unsigned int lockBytePage = 0; unsigned int szPg = 0; sqlite3_stmt *pCkHash = 0; char buf[200]; @@ -1235,6 +1236,7 @@ static void originSide(SQLiteRsync *p){ p->nPage = nPage; p->szPage = szPg; p->iProtocol = PROTOCOL_VERSION; + lockBytePage = (1<<30)/szPg + 1; } } @@ -1290,6 +1292,7 @@ static void originSide(SQLiteRsync *p){ " INSERT INTO badHash SELECT n FROM c", iPage+1, p->nPage); } + runSql(p, "DELETE FROM badHash WHERE pgno=%d", lockBytePage); pStmt = prepareStmt(p, "SELECT pgno, data" " FROM badHash JOIN sqlite_dbpage('main') USING(pgno)"); From 29f976432a87793d7b9e29fd4ed0209d634113f7 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 7 Oct 2024 11:47:05 +0000 Subject: [PATCH 33/77] Fix an assert() failure in "PRAGMA integrity_check" that could occur when checking a corrupt database. FossilOrigin-Name: d218993be5886f07193d5c2a66ccd0ecdd7bb87687947b89945c90e31cea5451 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/pragma.c | 1 + test/corruptN.test | 27 +++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 8c049eb6a7..921101d073 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Back\sout\s[2f7eab381e16]\sbecause\sthe\sstderr\soutput\son\ssystems\swithout\sgmake\scauses\sgrief\sin\sthe\stesting\stools. -D 2024-10-05T21:44:21.913 +C Fix\san\sassert()\sfailure\sin\s"PRAGMA\sintegrity_check"\sthat\scould\soccur\swhen\schecking\sa\scorrupt\sdatabase. +D 2024-10-07T11:47:05.013 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -762,7 +762,7 @@ F src/parse.y a7a8d42eeff01d267444ddb476029b0b1726fb70ae3d77984140f17ad02e2d61 F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484 F src/pcache.h 1497ce1b823cf00094bb0cf3bac37b345937e6f910890c626b16512316d3abf5 F src/pcache1.c 49516ad7718a3626f28f710fa7448ef1fce3c07fd169acbb4817341950264319 -F src/pragma.c 52bfbf6dfd668b69b5eb9bd1186e3a67367c8453807150d6e75239229924f684 +F src/pragma.c cd613126f7cdd0c2ded4648c3c7b7b0239e678d7f3489e88c4b6d6858372fd07 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/prepare.c 3ba0ad907b7773ed642f66cea8a2c9c8edc18841aa1050b6218dbb3479e86225 F src/printf.c 6a87534ebfb9e5346011191b1f3a7ebc457f5938c7e4feeea478ecf53f6a41b2 @@ -1042,7 +1042,7 @@ F test/corruptJ.test 4d5ccc4bf959464229a836d60142831ef76a5aa4 F test/corruptK.test ac13504593d89d69690d45479547616ed12644d42b5cb7eeb2e759a76fc23dcb F test/corruptL.test 652fc8ac0763a6fd3eb28b951d481924167b2d9936083bcc68253b2274a0c8fe F test/corruptM.test 7d574320e08c1b36caa3e47262061f186367d593a7e305d35f15289cc2c3e067 -F test/corruptN.test 7c099d153a554001b4fb829c799b01f2ea6276cbc32479131e0db0da4efd9cc4 +F test/corruptN.test 40bc47aee4af9aadff902be43f14d69dc17b3731448dad6c7cc722da913f1455 F test/cost.test cc434a026b1e9d0d98137a147e24e5daf1b1ad09e9ff7da63b34c83ddd136d92 F test/count.test cd4bd531066e8d77ef8fe1e3fc8253d042072e117ccab214b290cf83f1602249 F test/countofview.test 4088e461a10ee33e69803c177a69aa1d7bba81a9ffc2df66d76465a22ca7fdfc @@ -2215,8 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f -R 97cc1dd0446101afb82e95a43b8cd5d1 -U stephan -Z 6431efa2a9010e78c1fbe7fa1b33270f +P cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 +R 886d14b6c55746d1f77a7d0f4215362a +U dan +Z 224c1064901e8a73a6947d128b8e36d7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aec7c8a62f..aa365f77bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 +d218993be5886f07193d5c2a66ccd0ecdd7bb87687947b89945c90e31cea5451 diff --git a/src/pragma.c b/src/pragma.c index a8045aab1e..07139015f9 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1761,6 +1761,7 @@ void sqlite3Pragma( /* Make sure sufficient number of registers have been allocated */ sqlite3TouchRegister(pParse, 8+cnt); + sqlite3VdbeAddOp3(v, OP_Null, 0, 8, 8+cnt); sqlite3ClearTempRegCache(pParse); /* Do the b-tree integrity checks */ diff --git a/test/corruptN.test b/test/corruptN.test index 376325f5c5..8108609c09 100644 --- a/test/corruptN.test +++ b/test/corruptN.test @@ -276,4 +276,31 @@ do_catchsql_test 6.3 { UPDATE t1 SET x='hello world' WHERE rowid=1; } {1 {database disk image is malformed}} +#------------------------------------------------------------------------- +reset_db +do_execsql_test 7.0 { + BEGIN; + CREATE TABLE p1(x PRIMARY KEY); + CREATE TABLE c1(y); + + PRAGMA schema_version = 0; + PRAGMA writable_schema = RESET; + + INSERT INTO c1 VALUES(1000); + ROLLBACK; +} + +do_execsql_test 7.1 { + PRAGMA table_info = p1; +} {0 x {} 0 {} 1} + +do_catchsql_test 7.2 { + SELECT * FROM p1; +} {1 {database disk image is malformed}} + +do_catchsql_test 7.3 { + PRAGMA integrity_check +} {1 {database disk image is malformed}} + + finish_test From ce527f2e971d0c50c779f00fa6a3af61cc94e52e Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 7 Oct 2024 12:19:23 +0000 Subject: [PATCH 34/77] Fix handling of U+fffd in the LIKE optimization. dbsqlfuzz eee57fb9eea1dfa5aa40dfa87865cf8c84d12f96. FossilOrigin-Name: bce52ce2a6e7f3d3d1b2807d1ea95243d9b655e557c1bb6f0b8a9a6cefb1aed6 --- manifest | 17 +++++++++-------- manifest.uuid | 2 +- src/whereexpr.c | 25 +++++++++++++++---------- test/like.test | 6 +++--- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 921101d073..7bc5b30095 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sassert()\sfailure\sin\s"PRAGMA\sintegrity_check"\sthat\scould\soccur\swhen\schecking\sa\scorrupt\sdatabase. -D 2024-10-07T11:47:05.013 +C Fix\shandling\sof\sU+fffd\sin\sthe\sLIKE\soptimization.\ndbsqlfuzz\seee57fb9eea1dfa5aa40dfa87865cf8c84d12f96. +D 2024-10-07T12:19:23.717 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -857,7 +857,7 @@ F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 F src/where.c 461d41017d900d4248a268df96d2d30506c4dcc2257f4167c4f46072003ce2cf F src/whereInt.h a5d079c346a658b7a6e9e47bb943d021e02fa1e6aed3b964ca112112a4892192 F src/wherecode.c 5172d647798134e7c92536ddffe7e530c393d79b5dedd648b88faf2646c65baf -F src/whereexpr.c 44f41ae554c7572e1de1485b3169b233ee04d464b2ee5881687ede3bf07cacfa +F src/whereexpr.c 562ce89d7f1c24a54c5124576e04928600061c87d83a30e63dcbaadf20eb0653 F src/window.c 499d48f315a09242dc68f2fac635ed27dcf6bbb0d9ab9084857898c64489e975 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -1390,7 +1390,7 @@ F test/kvtest.c 6e0228409ea7ca0497dad503fbd109badb5e59545d131014b6aaac68b56f484a F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 F test/lemon-test01.y 70110eff607ab137ccc851edb2bc7e14a6d4f246b5d2d25f82a60b69d87a9ff2 -F test/like.test 242ee7f5d08a031144c0daf63bbd7e7710c847ccf387a83347e0b61b3aa69526 +F test/like.test b3ea2ba3558199aa8f25a42ddeb54772e234fab50868c9f066047acdbda8fc58 F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3d3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf @@ -2215,8 +2215,9 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135 -R 886d14b6c55746d1f77a7d0f4215362a -U dan -Z 224c1064901e8a73a6947d128b8e36d7 +P d218993be5886f07193d5c2a66ccd0ecdd7bb87687947b89945c90e31cea5451 +Q +13addee687c3fef02c6ef1af9f446822fe0945815648fb2198933c7c644798b2 +R 85a4f3886dc5b88ca917188b27f8b4cb +U drh +Z d22e20bac83a8cacb503bd8770c0d69a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index aa365f77bd..31cbb26ab2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d218993be5886f07193d5c2a66ccd0ecdd7bb87687947b89945c90e31cea5451 +bce52ce2a6e7f3d3d1b2807d1ea95243d9b655e557c1bb6f0b8a9a6cefb1aed6 diff --git a/src/whereexpr.c b/src/whereexpr.c index 7ea2956a75..24d203046f 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -219,20 +219,25 @@ static int isLikeOrGlob( z = (u8*)pRight->u.zToken; } if( z ){ - - /* Count the number of prefix characters prior to the first wildcard. - ** If the underlying database has a UTF16LE encoding, then only consider - ** ASCII characters. Note that the encoding of z[] is UTF8 - we are - ** dealing with only UTF8 here in this code, but the database engine - ** itself might be processing content using a different encoding. */ + /* Count the number of prefix bytes prior to the first wildcard. + ** or U+fffd character. If the underlying database has a UTF16LE + ** encoding, then only consider ASCII characters. Note that the + ** encoding of z[] is UTF8 - we are dealing with only UTF8 here in + ** this code, but the database engine itself might be processing + ** content using a different encoding. */ cnt = 0; while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){ cnt++; if( c==wc[3] && z[cnt]!=0 ){ cnt++; - }else if( c>=0x80 && ENC(db)==SQLITE_UTF16LE ){ - cnt--; - break; + }else if( c>=0x80 ){ + const u8 *z2 = z+cnt-1; + if( sqlite3Utf8Read(&z2)==0xfffd || ENC(db)==SQLITE_UTF16LE ){ + cnt--; + break; + }else{ + cnt = (int)(z2-z); + } } } @@ -244,7 +249,7 @@ static int isLikeOrGlob( ** range search. The third is because the caller assumes that the pattern ** consists of at least one character after all escapes have been ** removed. */ - if( (cnt>1 || (cnt>0 && z[0]!=wc[3])) && 255!=(u8)z[cnt-1] ){ + if( (cnt>1 || (cnt>0 && z[0]!=wc[3])) && ALWAYS(255!=(u8)z[cnt-1]) ){ Expr *pPrefix; /* A "complete" match if the pattern ends with "*" or "%" */ diff --git a/test/like.test b/test/like.test index d314e96a19..0d732b569c 100644 --- a/test/like.test +++ b/test/like.test @@ -731,16 +731,16 @@ ifcapable like_opt&&!icu { } do_test like-9.5.1 { set res [sqlite3_exec_hex db { - SELECT x FROM t2 WHERE x LIKE '%fe%25' + SELECT 1 FROM t2 WHERE x LIKE '%fe%25' }] - } {0 {}} + } {0 {1 1}} ifcapable explain { do_test like-9.5.2 { set res [sqlite3_exec_hex db { EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%fe%25' }] regexp {INDEX i2} $res - } {1} + } {0} } # Do an SQL statement. Append the search count to the end of the result. From f7f78a624d69ee606cc5aad1c3490bccdbe5dfa5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 7 Oct 2024 18:06:17 +0000 Subject: [PATCH 35/77] The (undocumented) subtype() SQL function should have the SQLITE_SUBTYPE flag. FossilOrigin-Name: c361dd91841da64fdd009e6eab389ccd81266a24d1070e5313fe1d22e6cef65a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 33977615bc..984b147ed3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\slatest\strunk\senhancements\sinto\sthe\sindexed-subtype-expr\sbranch. -D 2024-10-07T16:53:41.722 +C The\s(undocumented)\ssubtype()\sSQL\sfunction\sshould\shave\sthe\sSQLITE_SUBTYPE\sflag. +D 2024-10-07T18:06:17.888 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -722,7 +722,7 @@ F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 F src/expr.c 0aafe1b0d3893e9f568f30efa2e7b96a6e6bcc072e481ae68c5abe3f01d81367 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f -F src/func.c ed6baeeb414ef18ce729793587dae8bd30f11e6aacec8675bd33727e0bcb3765 +F src/func.c 281b373af97eba0a014aed754da952001fbf2899af362a268cdf59061eb749ad F src/global.c a19e4b1ca1335f560e9560e590fc13081e21f670643367f99cb9e8f9dc7d615b F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P aa440e78e9004c7ca3e03beaf264f54d0070ad7298a3c96ca097d8b35c872e5f 011fab70cb3d194b27742ebb236b05be582230567cf78e3e6cac6911de86922f -R 42a50f33acc0ba8243932461cf488c55 +P 2fe2f374584b025676684ebe4ef29304883a3b0b125b62abc1dbf74815eecdfb +R a94f143c3aa0e261df71b070177a6103 U drh -Z 5fcca3b69bb5d4d198a98a886d1914e0 +Z daf7125707a76e5c147ce1091b351dd3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e912c56088..04a9720569 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2fe2f374584b025676684ebe4ef29304883a3b0b125b62abc1dbf74815eecdfb +c361dd91841da64fdd009e6eab389ccd81266a24d1070e5313fe1d22e6cef65a diff --git a/src/func.c b/src/func.c index b17ffa52c4..845d88b083 100644 --- a/src/func.c +++ b/src/func.c @@ -2706,7 +2706,8 @@ void sqlite3RegisterBuiltinFunctions(void){ WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0, SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ), FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF), - FUNCTION2(subtype, 1, 0, 0, subtypeFunc, SQLITE_FUNC_TYPEOF), + FUNCTION2(subtype, 1, 0, 0, subtypeFunc, + SQLITE_FUNC_TYPEOF|SQLITE_SUBTYPE), FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH), FUNCTION2(octet_length, 1, 0, 0, bytelengthFunc,SQLITE_FUNC_BYTELEN), FUNCTION(instr, 2, 0, 0, instrFunc ), From ddc764b274b2eadebef91dc3adef44158a8c15ef Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 7 Oct 2024 21:04:57 +0000 Subject: [PATCH 36/77] Add a NEVER() to an unreachable branch in the new indexed-subtype logic. Mark the pi() function as deterministic. FossilOrigin-Name: 50be8f5091b2202b67a80f826feee2c378f001745ad5acb7c4374423bbf6ff22 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 2 +- src/func.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 984b147ed3..90933ecb13 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\s(undocumented)\ssubtype()\sSQL\sfunction\sshould\shave\sthe\sSQLITE_SUBTYPE\sflag. -D 2024-10-07T18:06:17.888 +C Add\sa\sNEVER()\sto\san\sunreachable\sbranch\sin\sthe\snew\sindexed-subtype\slogic.\nMark\sthe\spi()\sfunction\sas\sdeterministic. +D 2024-10-07T21:04:57.392 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -719,10 +719,10 @@ F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a F src/dbpage.c db1be8adaf1f839ad733c08baeac5c22aa912f7b535865c0c061382602081360 F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 -F src/expr.c 0aafe1b0d3893e9f568f30efa2e7b96a6e6bcc072e481ae68c5abe3f01d81367 +F src/expr.c 6800ecb6c48d9ab0b73e5b25dd1f6176fe4ffae89de2edfb9604e290ae5c7be4 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f -F src/func.c 281b373af97eba0a014aed754da952001fbf2899af362a268cdf59061eb749ad +F src/func.c 1d093b93b8f097665721e59a1c404d7db4dc591e1a777a7a1022dfbda21e108b F src/global.c a19e4b1ca1335f560e9560e590fc13081e21f670643367f99cb9e8f9dc7d615b F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220 F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2fe2f374584b025676684ebe4ef29304883a3b0b125b62abc1dbf74815eecdfb -R a94f143c3aa0e261df71b070177a6103 +P c361dd91841da64fdd009e6eab389ccd81266a24d1070e5313fe1d22e6cef65a +R 4fa3cedbad7dc576720ba11e0ac36827 U drh -Z daf7125707a76e5c147ce1091b351dd3 +Z ff784421601a4233097df0f7c86caf61 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 04a9720569..dcd3d5cf34 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c361dd91841da64fdd009e6eab389ccd81266a24d1070e5313fe1d22e6cef65a +50be8f5091b2202b67a80f826feee2c378f001745ad5acb7c4374423bbf6ff22 diff --git a/src/expr.c b/src/expr.c index 506b92c828..4404f30c16 100644 --- a/src/expr.c +++ b/src/expr.c @@ -4582,7 +4582,7 @@ static int exprNodeCanReturnSubtype(Walker *pWalker, Expr *pExpr){ db = pWalker->pParse->db; n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0); - if( pDef==0 || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ + if( NEVER(pDef==0) || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ pWalker->eCode = 1; return WRC_Prune; } diff --git a/src/func.c b/src/func.c index 845d88b083..2de16b8aa9 100644 --- a/src/func.c +++ b/src/func.c @@ -2813,7 +2813,7 @@ void sqlite3RegisterBuiltinFunctions(void){ MFUNCTION(sqrt, 1, sqrt, math1Func ), MFUNCTION(radians, 1, degToRad, math1Func ), MFUNCTION(degrees, 1, radToDeg, math1Func ), - FUNCTION(pi, 0, 0, 0, piFunc ), + MFUNCTION(pi, 0, 0, piFunc ), #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */ FUNCTION(sign, 1, 0, 0, signFunc ), INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ), From 7998b889e884b5752ac3c11da443022343ba1b8a Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 8 Oct 2024 00:15:22 +0000 Subject: [PATCH 37/77] Add an ALWAYS() on a branch in the new indexed-subtype logic. FossilOrigin-Name: f150c3c5b898975b1f83d61fa589753449a48f8a0007e8e167dbd702528197c5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 90933ecb13..0d63b0cdd2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\sNEVER()\sto\san\sunreachable\sbranch\sin\sthe\snew\sindexed-subtype\slogic.\nMark\sthe\spi()\sfunction\sas\sdeterministic. -D 2024-10-07T21:04:57.392 +C Add\san\sALWAYS()\son\sa\sbranch\sin\sthe\snew\sindexed-subtype\slogic. +D 2024-10-08T00:15:22.623 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -719,7 +719,7 @@ F src/date.c 89ce1ff20512a7fa5070ba6e7dd5c171148ca7d580955795bf97c79c2456144a F src/dbpage.c db1be8adaf1f839ad733c08baeac5c22aa912f7b535865c0c061382602081360 F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42 -F src/expr.c 6800ecb6c48d9ab0b73e5b25dd1f6176fe4ffae89de2edfb9604e290ae5c7be4 +F src/expr.c a9d9f5fdfbdd3b2c94d7af1b11f181464b8a641736cf32cb92fa3c5e7ecb30df F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f F src/func.c 1d093b93b8f097665721e59a1c404d7db4dc591e1a777a7a1022dfbda21e108b @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c361dd91841da64fdd009e6eab389ccd81266a24d1070e5313fe1d22e6cef65a -R 4fa3cedbad7dc576720ba11e0ac36827 +P 50be8f5091b2202b67a80f826feee2c378f001745ad5acb7c4374423bbf6ff22 +R 4f5fad7a5b3f0800af84dc5d2cb9639f U drh -Z ff784421601a4233097df0f7c86caf61 +Z c1cd4067e85475803952865dab33ef60 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dcd3d5cf34..57a56b0df1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -50be8f5091b2202b67a80f826feee2c378f001745ad5acb7c4374423bbf6ff22 +f150c3c5b898975b1f83d61fa589753449a48f8a0007e8e167dbd702528197c5 diff --git a/src/expr.c b/src/expr.c index 4404f30c16..cc915987dd 100644 --- a/src/expr.c +++ b/src/expr.c @@ -4580,7 +4580,7 @@ static int exprNodeCanReturnSubtype(Walker *pWalker, Expr *pExpr){ } assert( ExprUseXList(pExpr) ); db = pWalker->pParse->db; - n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; + n = ALWAYS(pExpr->x.pList) ? pExpr->x.pList->nExpr : 0; pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0); if( NEVER(pDef==0) || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ pWalker->eCode = 1; From dd2deecbbd03ec1478701b2029479c4983d8fae7 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 8 Oct 2024 14:07:28 +0000 Subject: [PATCH 38/77] Fix the .crnl command in the shell so that it does not get undone by calls to print a quoted string or CSV output. FossilOrigin-Name: 6b932337c8dee3e52b472a38984e91b5091f3d90c41ac1cc171fa4149cc491c5 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/shell.c.in | 49 +++++++++++++++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index 2789b4b2b8..8fe0047b29 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sexpressions\swith\ssubtypes\sto\sbe\sread\sfrom\sindexes\sunless\sthey\sare\nbeing\sused\sas\sdirect\sor\sindirect\sparameters\sto\sSQLITE_SUBTYPE\sfunctions. -D 2024-10-08T10:10:42.057 +C Fix\sthe\s.crnl\scommand\sin\sthe\sshell\sso\sthat\sit\sdoes\snot\sget\sundone\sby\ncalls\sto\sprint\sa\squoted\sstring\sor\sCSV\soutput. +D 2024-10-08T14:07:28.260 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -770,7 +770,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in 981efe98f98a983c1d0193d18528eb2d765207c0c82b67b610be60f17995a43e +F src/shell.c.in 188b1fe5e403e8e0638e0aa1151a95d47e841ddaf0545973cae09e4a6cef4d98 F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2216,9 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 011fab70cb3d194b27742ebb236b05be582230567cf78e3e6cac6911de86922f f150c3c5b898975b1f83d61fa589753449a48f8a0007e8e167dbd702528197c5 -R 4f5fad7a5b3f0800af84dc5d2cb9639f -T +closed f150c3c5b898975b1f83d61fa589753449a48f8a0007e8e167dbd702528197c5 +P 39a56a23fec24dd713905457b6d4ed7c148f88e325a26c376f1e6daf147c69c8 +R f65d905956fc73a7bb20b3c2e0376b8f U drh -Z d4cafc45e7a2f93bf4c10b241262518d +Z b2ad2cadf0ade220cb843ebb395ae876 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b5aa88440f..3f330f95b5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -39a56a23fec24dd713905457b6d4ed7c148f88e325a26c376f1e6daf147c69c8 +6b932337c8dee3e52b472a38984e91b5091f3d90c41ac1cc171fa4149cc491c5 diff --git a/src/shell.c.in b/src/shell.c.in index 140fd0d9de..0485fb2a23 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1448,6 +1448,7 @@ struct ShellState { u8 bSafeMode; /* True to prohibit unsafe operations */ u8 bSafeModePersist; /* The long-term value of bSafeMode */ u8 eRestoreState; /* See comments above doAutoDetectRestore() */ + u8 crnlMode; /* Do NL-to-CRLF translations when enabled (maybe) */ ColModeOpts cmOpts; /* Option values affecting columnar mode output */ unsigned statsOn; /* True to display memory stats before each finalize */ unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */ @@ -1851,6 +1852,19 @@ static void outputModePop(ShellState *p){ memcpy(p->rowSeparator, p->rowSepPrior, sizeof(p->rowSeparator)); } +/* +** Set output mode to text or binary for Windows. +*/ +static void setCrnlMode(ShellState *p){ +#ifdef _WIN32 + if( p->crnlMode ){ + sqlite3_fsetmode(p->out, _O_TEXT); + }else{ + sqlite3_fsetmode(p->out, _O_BINARY); + } +#endif +} + /* ** Output the given string as a hex-encoded blob (eg. X'1234' ) */ @@ -1901,9 +1915,10 @@ static const char *unused_string( ** ** See also: output_quoted_escaped_string() */ -static void output_quoted_string(FILE *out, const char *z){ +static void output_quoted_string(ShellState *p, const char *z){ int i; char c; + FILE *out = p->out; sqlite3_fsetmode(out, _O_BINARY); if( z==0 ) return; for(i=0; (c = z[i])!=0 && c!='\''; i++){} @@ -1929,7 +1944,7 @@ static void output_quoted_string(FILE *out, const char *z){ } sqlite3_fputs("'", out); } - sqlite3_fsetmode(out, _O_TEXT); + setCrnlMode(p); } /* @@ -1941,9 +1956,10 @@ static void output_quoted_string(FILE *out, const char *z){ ** This is like output_quoted_string() but with the addition of the \r\n ** escape mechanism. */ -static void output_quoted_escaped_string(FILE *out, const char *z){ +static void output_quoted_escaped_string(ShellState *p, const char *z){ int i; char c; + FILE *out = p->out; sqlite3_fsetmode(out, _O_BINARY); for(i=0; (c = z[i])!=0 && c!='\'' && c!='\n' && c!='\r'; i++){} if( c==0 ){ @@ -1996,7 +2012,7 @@ static void output_quoted_escaped_string(FILE *out, const char *z){ sqlite3_fprintf(out, ",'%s',char(10))", zNL); } } - sqlite3_fsetmode(stdout, _O_TEXT); + setCrnlMode(p); } /* @@ -2793,7 +2809,7 @@ static int shell_callback( } sqlite3_fputs(p->rowSeparator, p->out); } - sqlite3_fsetmode(p->out, _O_TEXT); + setCrnlMode(p); break; } case MODE_Insert: { @@ -2821,9 +2837,9 @@ static int shell_callback( sqlite3_fputs("NULL", p->out); }else if( aiType && aiType[i]==SQLITE_TEXT ){ if( ShellHasFlag(p, SHFLG_Newlines) ){ - output_quoted_string(p->out, azArg[i]); + output_quoted_string(p, azArg[i]); }else{ - output_quoted_escaped_string(p->out, azArg[i]); + output_quoted_escaped_string(p, azArg[i]); } }else if( aiType && aiType[i]==SQLITE_INTEGER ){ sqlite3_fputs(azArg[i], p->out); @@ -2852,9 +2868,9 @@ static int shell_callback( }else if( isNumber(azArg[i], 0) ){ sqlite3_fputs(azArg[i], p->out); }else if( ShellHasFlag(p, SHFLG_Newlines) ){ - output_quoted_string(p->out, azArg[i]); + output_quoted_string(p, azArg[i]); }else{ - output_quoted_escaped_string(p->out, azArg[i]); + output_quoted_escaped_string(p, azArg[i]); } } sqlite3_fputs(");\n", p->out); @@ -2907,7 +2923,7 @@ static int shell_callback( if( p->cnt==0 && p->showHeader ){ for(i=0; i0 ) sqlite3_fputs(p->colSeparator, p->out); - output_quoted_string(p->out, azCol[i]); + output_quoted_string(p, azCol[i]); } sqlite3_fputs(p->rowSeparator, p->out); } @@ -2917,7 +2933,7 @@ static int shell_callback( if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){ sqlite3_fputs("NULL", p->out); }else if( aiType && aiType[i]==SQLITE_TEXT ){ - output_quoted_string(p->out, azArg[i]); + output_quoted_string(p, azArg[i]); }else if( aiType && aiType[i]==SQLITE_INTEGER ){ sqlite3_fputs(azArg[i], p->out); }else if( aiType && aiType[i]==SQLITE_FLOAT ){ @@ -2932,7 +2948,7 @@ static int shell_callback( }else if( isNumber(azArg[i], 0) ){ sqlite3_fputs(azArg[i], p->out); }else{ - output_quoted_string(p->out, azArg[i]); + output_quoted_string(p, azArg[i]); } } sqlite3_fputs(p->rowSeparator, p->out); @@ -8429,7 +8445,7 @@ static int do_meta_command(char *zLine, ShellState *p){ /* Undocumented. Legacy only. See "crnl" below */ if( c=='b' && n>=3 && cli_strncmp(azArg[0], "binary", n)==0 ){ - eputz("The \".binary\" command is deprecated. Use \".crnl\" instead.\n"); + eputz("The \".binary\" command is deprecated.\n"); rc = 1; }else @@ -8561,11 +8577,8 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_fputs("The \".crnl\" command is disable in this build.\n", p->out); #else if( nArg==2 ){ - if( booleanValue(azArg[1]) ){ - sqlite3_fsetmode(p->out, _O_TEXT); - }else{ - sqlite3_fsetmode(p->out, _O_BINARY); - } + p->crnlMode = booleanValue(azArg[1]); + setCrnlMode(p); }else{ eputz("Usage: .crnl on|off\n"); rc = 1; From ab85d9abd6e5ed5997387c9db31dd6dfaece2681 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 8 Oct 2024 15:11:43 +0000 Subject: [PATCH 39/77] Additional improvements to the behavior of ".crnl" in the CLI. The default output mode is O_BINARY so that results are identical on Windows and non-Windows systems. On Windows you can optionally do ".crnl on" to enable NL-to-CRLF conversion on output. Output to Windows console is always O_U8TEXT and so is unaffected by the .crnl setting. FossilOrigin-Name: dbfc10b8981bcce4f875c4adef43f398871b41551074445087e343ded50253c5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 11 ++++++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8fe0047b29..7f6a38ca30 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\s.crnl\scommand\sin\sthe\sshell\sso\sthat\sit\sdoes\snot\sget\sundone\sby\ncalls\sto\sprint\sa\squoted\sstring\sor\sCSV\soutput. -D 2024-10-08T14:07:28.260 +C Additional\simprovements\sto\sthe\sbehavior\sof\s".crnl"\sin\sthe\sCLI.\s\sThe\sdefault\noutput\smode\sis\sO_BINARY\sso\sthat\sresults\sare\sidentical\son\sWindows\sand\nnon-Windows\ssystems.\s\sOn\sWindows\syou\scan\soptionally\sdo\s".crnl\son"\sto\senable\nNL-to-CRLF\sconversion\son\soutput.\s\sOutput\sto\sWindows\sconsole\sis\salways\nO_U8TEXT\sand\sso\sis\sunaffected\sby\sthe\s.crnl\ssetting. +D 2024-10-08T15:11:43.353 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -770,7 +770,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in 188b1fe5e403e8e0638e0aa1151a95d47e841ddaf0545973cae09e4a6cef4d98 +F src/shell.c.in 01f24bedda2d555f3f6782c0a68c3ca8deaf5a310a0bbec034544eade146fab5 F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 39a56a23fec24dd713905457b6d4ed7c148f88e325a26c376f1e6daf147c69c8 -R f65d905956fc73a7bb20b3c2e0376b8f +P 6b932337c8dee3e52b472a38984e91b5091f3d90c41ac1cc171fa4149cc491c5 +R e82f4f1afba280f0e1242353ec41fc12 U drh -Z b2ad2cadf0ade220cb843ebb395ae876 +Z 8e8e0c8d96720025c8b99c6e17a99bf2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3f330f95b5..9d63130107 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6b932337c8dee3e52b472a38984e91b5091f3d90c41ac1cc171fa4149cc491c5 +dbfc10b8981bcce4f875c4adef43f398871b41551074445087e343ded50253c5 diff --git a/src/shell.c.in b/src/shell.c.in index 0485fb2a23..3f894e973a 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -6436,6 +6436,7 @@ static void output_redir(ShellState *p, FILE *pfNew){ sqlite3_fputs("Output already redirected.\n", stderr); }else{ p->out = pfNew; + setCrnlMode(p); if( p->mode==MODE_Www ){ sqlite3_fputs( "\n" @@ -6491,6 +6492,7 @@ static void output_reset(ShellState *p){ } p->outfile[0] = 0; p->out = stdout; + setCrnlMode(p); } #else # define output_redir(SS,pfO) @@ -10239,7 +10241,6 @@ static int do_meta_command(char *zLine, ShellState *p){ #ifdef SQLITE_OMIT_POPEN eputz("Error: pipes are not supported in this OS\n"); rc = 1; - p->out = stdout; #else p->in = sqlite3_popen(azArg[1]+1, "r"); if( p->in==0 ){ @@ -12620,6 +12621,14 @@ static void main_init(ShellState *data) { sqlite3_config(SQLITE_CONFIG_MULTITHREAD); sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); + + /* By default, come up in O_BINARY mode. That way, the default output is + ** the same for Windows and non-Windows systems. Use the ".crnl on" + ** command to change into O_TEXT mode to do automatic NL-to-CRLF + ** conversions on output for Windows. Windows console output is not + ** subject to the crnlMode setting and is unaffected either way. This + ** setting only affects output going into a file or pipe. */ + data->crnlMode = 0; } /* From 7f5a10e4ba20826b03ea898945f3ae9138b5568e Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 8 Oct 2024 17:27:00 +0000 Subject: [PATCH 40/77] Enable the ".crnl" command on Windows builds of the CLI even if the SQLITE_U8TEXT_ONLY or SQLITE_U8TEST_STDIO compile-time options are used. FossilOrigin-Name: 6364a2f0449794b0c089ba9fbc099f5558b88ac91c459caf7fae3a43dfcd192e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 8 +++----- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 7f6a38ca30..2057f3a14e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\simprovements\sto\sthe\sbehavior\sof\s".crnl"\sin\sthe\sCLI.\s\sThe\sdefault\noutput\smode\sis\sO_BINARY\sso\sthat\sresults\sare\sidentical\son\sWindows\sand\nnon-Windows\ssystems.\s\sOn\sWindows\syou\scan\soptionally\sdo\s".crnl\son"\sto\senable\nNL-to-CRLF\sconversion\son\soutput.\s\sOutput\sto\sWindows\sconsole\sis\salways\nO_U8TEXT\sand\sso\sis\sunaffected\sby\sthe\s.crnl\ssetting. -D 2024-10-08T15:11:43.353 +C Enable\sthe\s".crnl"\scommand\son\sWindows\sbuilds\sof\sthe\sCLI\seven\sif\sthe\nSQLITE_U8TEXT_ONLY\sor\sSQLITE_U8TEST_STDIO\scompile-time\soptions\sare\sused. +D 2024-10-08T17:27:00.361 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -770,7 +770,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in 01f24bedda2d555f3f6782c0a68c3ca8deaf5a310a0bbec034544eade146fab5 +F src/shell.c.in 1b5fda8bebb23783985744fde738976791fca5fd98d4382c4572e13cce2a0e29 F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6b932337c8dee3e52b472a38984e91b5091f3d90c41ac1cc171fa4149cc491c5 -R e82f4f1afba280f0e1242353ec41fc12 +P dbfc10b8981bcce4f875c4adef43f398871b41551074445087e343ded50253c5 +R 4c54522422d06a33902f30cd91a1b430 U drh -Z 8e8e0c8d96720025c8b99c6e17a99bf2 +Z 9d705152c398cbd25be925515dab0f70 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9d63130107..f58143baf7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dbfc10b8981bcce4f875c4adef43f398871b41551074445087e343ded50253c5 +6364a2f0449794b0c089ba9fbc099f5558b88ac91c459caf7fae3a43dfcd192e diff --git a/src/shell.c.in b/src/shell.c.in index 3f894e973a..50eb3ae2c0 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4952,10 +4952,9 @@ static const char *(azHelp[]) = { ".clone NEWDB Clone data into NEWDB from the existing database", #endif ".connection [close] [#] Open or close an auxiliary database connection", -#if defined(_WIN32) && !defined(SQLITE_U8TEXT_ONLY) \ - && !defined(SQLITE_U8TEXT_STDIO) +#if defined(_WIN32) ".crnl on|off Translate \\n to \\r\\n. Default ON", -#endif /* _WIN32 && U8TEXT_ONLY && U8TEXT_STDIO */ +#endif ".databases List names and files of attached databases", ".dbconfig ?op? ?val? List or change sqlite3_db_config() options", #if SQLITE_SHELL_HAVE_RECOVER @@ -8574,8 +8573,7 @@ static int do_meta_command(char *zLine, ShellState *p){ }else if( c=='c' && n==4 && cli_strncmp(azArg[0], "crnl", n)==0 ){ -#if !defined(_WIN32) || defined(SQLITE_U8TEXT_ONLY) \ - || defined(SQLITE_U8TEXT_STDIO) +#if !defined(_WIN32) sqlite3_fputs("The \".crnl\" command is disable in this build.\n", p->out); #else if( nArg==2 ){ From 48d11044ba27cae4144b96adccc9075223dfd47f Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 9 Oct 2024 05:20:32 +0000 Subject: [PATCH 41/77] Add a few missing $(BEXE) suffixes on makefile targets which are apparently never run on platforms where that var is non-empty. FossilOrigin-Name: 1218a203483cecdc8c9abdc970ad68eba0dfa9cafbed95c63cefb7e8af8babee --- Makefile.in | 8 ++++---- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile.in b/Makefile.in index 6fc821da23..61c26c51c7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -722,13 +722,13 @@ srcck1$(BEXE): $(TOP)/tool/srcck1.c $(BCC) -o srcck1$(BEXE) $(TOP)/tool/srcck1.c sourcetest: srcck1$(BEXE) sqlite3.c - ./srcck1 sqlite3.c + ./srcck1$(BEXE) sqlite3.c -src-verify: $(TOP)/tool/src-verify.c +src-verify$(BEXE): $(TOP)/tool/src-verify.c $(BCC) -o src-verify$(BEXE) $(TOP)/tool/src-verify.c -verify-source: ./src-verify - ./src-verify $(TOP) +verify-source: ./src-verify$(BEXE) + ./src-verify$(BEXE) $(TOP) fuzzershell$(TEXE): $(TOP)/tool/fuzzershell.c sqlite3.c sqlite3.h $(LTLINK) -o $@ $(FUZZERSHELL_OPT) \ diff --git a/manifest b/manifest index 2057f3a14e..99c7a0f6f8 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Enable\sthe\s".crnl"\scommand\son\sWindows\sbuilds\sof\sthe\sCLI\seven\sif\sthe\nSQLITE_U8TEXT_ONLY\sor\sSQLITE_U8TEST_STDIO\scompile-time\soptions\sare\sused. -D 2024-10-08T17:27:00.361 +C Add\sa\sfew\smissing\s$(BEXE)\ssuffixes\son\smakefile\stargets\swhich\sare\sapparently\snever\srun\son\splatforms\swhere\sthat\svar\sis\snon-empty. +D 2024-10-09T05:20:32.007 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 6a826facc78c3c8ad38bf00ed588f6aa3665ccd7a9749b891d20582fc290c77e +F Makefile.in 07a52a88eabbb996b91b82f17e7a6b11202845b06056c620b2c4f3a7e473554f F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 9c6d80d9d103fa42e931f4c464884a5e577fae8563acc7589bff4e43fbe8f864 F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dbfc10b8981bcce4f875c4adef43f398871b41551074445087e343ded50253c5 -R 4c54522422d06a33902f30cd91a1b430 -U drh -Z 9d705152c398cbd25be925515dab0f70 +P 6364a2f0449794b0c089ba9fbc099f5558b88ac91c459caf7fae3a43dfcd192e +R 36fe54ac92487d52d0151526708ec7a1 +U stephan +Z d3bb00965caef64bd9a43497ec172f45 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f58143baf7..ddc65d8abc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6364a2f0449794b0c089ba9fbc099f5558b88ac91c459caf7fae3a43dfcd192e +1218a203483cecdc8c9abdc970ad68eba0dfa9cafbed95c63cefb7e8af8babee From 4b0a2e01068e14b6cd78a582c41d2b203c421d22 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 9 Oct 2024 11:52:29 +0000 Subject: [PATCH 42/77] Improved handling of unicode characters in the LIKE optimization. Follow-up to [bce52ce2a6e7f3d3]. FossilOrigin-Name: 9d0eb3980409115f2f6fd1720a03f34e3968c93be55feafdfef20bf5f711c17f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/whereexpr.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 99c7a0f6f8..2f16d8e027 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\sfew\smissing\s$(BEXE)\ssuffixes\son\smakefile\stargets\swhich\sare\sapparently\snever\srun\son\splatforms\swhere\sthat\svar\sis\snon-empty. -D 2024-10-09T05:20:32.007 +C Improved\shandling\sof\sunicode\scharacters\sin\sthe\sLIKE\soptimization.\nFollow-up\sto\s[bce52ce2a6e7f3d3]. +D 2024-10-09T11:52:29.532 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -857,7 +857,7 @@ F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 F src/where.c 12fe24880901997372b88fd7ca9a21457404ad35201712c02cc57978578abb10 F src/whereInt.h a5d079c346a658b7a6e9e47bb943d021e02fa1e6aed3b964ca112112a4892192 F src/wherecode.c 5172d647798134e7c92536ddffe7e530c393d79b5dedd648b88faf2646c65baf -F src/whereexpr.c 562ce89d7f1c24a54c5124576e04928600061c87d83a30e63dcbaadf20eb0653 +F src/whereexpr.c 0f93a29cabd3a338d09a1f5c6770620a1ac51ec1157f3229502a7e7767c60b6f F src/window.c 499d48f315a09242dc68f2fac635ed27dcf6bbb0d9ab9084857898c64489e975 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6364a2f0449794b0c089ba9fbc099f5558b88ac91c459caf7fae3a43dfcd192e -R 36fe54ac92487d52d0151526708ec7a1 -U stephan -Z d3bb00965caef64bd9a43497ec172f45 +P 1218a203483cecdc8c9abdc970ad68eba0dfa9cafbed95c63cefb7e8af8babee +R caf8280fa8e7a7de178081dbae97667f +U drh +Z 3adb35abb1bf3d691bca5f7e2785786d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ddc65d8abc..5abf6c8472 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1218a203483cecdc8c9abdc970ad68eba0dfa9cafbed95c63cefb7e8af8babee +9d0eb3980409115f2f6fd1720a03f34e3968c93be55feafdfef20bf5f711c17f diff --git a/src/whereexpr.c b/src/whereexpr.c index 24d203046f..2b6eb6a78d 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -228,7 +228,7 @@ static int isLikeOrGlob( cnt = 0; while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){ cnt++; - if( c==wc[3] && z[cnt]!=0 ){ + if( c==wc[3] && z[cnt]>0 && z[cnt]<0x80 ){ cnt++; }else if( c>=0x80 ){ const u8 *z2 = z+cnt-1; From 50bb0aaa2c1b3157d49a250026ba8915d5bccef8 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 9 Oct 2024 13:19:21 +0000 Subject: [PATCH 43/77] Changes to the TCL extension and how it is built, suggested by Jan Nijtmans. FossilOrigin-Name: 9c0690193200551a3218c576b19eaf40e330dc252d67b430204ff44495e4793e --- Makefile.in | 2 +- Makefile.msc | 2 +- autoconf/tea/pkgIndex.tcl.in | 4 ++-- autoconf/tea/win/makefile.vc | 2 +- manifest | 25 ++++++++++++++----------- manifest.uuid | 2 +- src/tclsqlite.c | 2 +- test/thread_common.tcl | 3 +-- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Makefile.in b/Makefile.in index 61c26c51c7..43709ff5c4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1602,7 +1602,7 @@ install: sqlite3$(TEXE) lib_install sqlite3.h sqlite3.pc $(tcl_install_$(HAVE_TC $(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(pkgconfigdir) pkgIndex.tcl: - echo 'package ifneeded sqlite3 $(RELEASE) [list load [file join $$dir libtclsqlite3[info sharedlibextension]] sqlite3]' > $@ + echo 'package ifneeded sqlite3 $(RELEASE) [list load [file join $$dir libtclsqlite3[info sharedlibextension]] Sqlite3]' > $@ tcl_install: lib_install libtclsqlite3.la pkgIndex.tcl $(INSTALL) -d $(DESTDIR)$(TCLLIBDIR) diff --git a/Makefile.msc b/Makefile.msc index 60669993c1..7cdbda0c42 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1824,7 +1824,7 @@ tclsqlite3.def: tclsqlite.lo pkgIndex.tcl: $(TOP)\VERSION for /F %%V in ('type "$(TOP)\VERSION"') do ( \ - echo package ifneeded sqlite3 @version@ [list load [file join $$dir $(SQLITE3TCLDLL)] sqlite3] \ + echo package ifneeded sqlite3 @version@ [list load [file join $$dir $(SQLITE3TCLDLL)] Sqlite3] \ | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact @version@ %%V > pkgIndex.tcl \ ) diff --git a/autoconf/tea/pkgIndex.tcl.in b/autoconf/tea/pkgIndex.tcl.in index f95f7d3893..666812dee7 100644 --- a/autoconf/tea/pkgIndex.tcl.in +++ b/autoconf/tea/pkgIndex.tcl.in @@ -3,8 +3,8 @@ # if {[package vsatisfies [package provide Tcl] 9.0-]} { package ifneeded sqlite3 @PACKAGE_VERSION@ \ - [list load [file join $dir @PKG_LIB_FILE9@] sqlite3] + [list load [file join $dir @PKG_LIB_FILE9@] Sqlite3] } else { package ifneeded sqlite3 @PACKAGE_VERSION@ \ - [list load [file join $dir @PKG_LIB_FILE8@] sqlite3] + [list load [file join $dir @PKG_LIB_FILE8@] Sqlite3] } diff --git a/autoconf/tea/win/makefile.vc b/autoconf/tea/win/makefile.vc index da56e811fc..dacb7c6b3a 100644 --- a/autoconf/tea/win/makefile.vc +++ b/autoconf/tea/win/makefile.vc @@ -407,7 +407,7 @@ install-libraries: @echo Installing package index in '$(SCRIPT_INSTALL_DIR)' @type << >"$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl" package ifneeded $(PROJECT) $(DOTVERSION) \ - [list load [file join $$dir $(PRJLIBNAME)] sqlite3] + [list load [file join $$dir $(PRJLIBNAME)] Sqlite3] << install-docs: diff --git a/manifest b/manifest index 2f16d8e027..3c11ff81dd 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Improved\shandling\sof\sunicode\scharacters\sin\sthe\sLIKE\soptimization.\nFollow-up\sto\s[bce52ce2a6e7f3d3]. -D 2024-10-09T11:52:29.532 +C Changes\sto\sthe\sTCL\sextension\sand\show\sit\sis\sbuilt,\ssuggested\sby\sJan\sNijtmans. +D 2024-10-09T13:19:21.954 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 07a52a88eabbb996b91b82f17e7a6b11202845b06056c620b2c4f3a7e473554f +F Makefile.in a994d7642ebb6cb9cd49884a929ed33dc6b309b6bc55ea85c33db9ec5aa96af6 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 9c6d80d9d103fa42e931f4c464884a5e577fae8563acc7589bff4e43fbe8f864 +F Makefile.msc 13357270c2434dfda7e38dd95bd1d1bd7f832c77fe275ec867c12d14d7a4631b F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -27,10 +27,10 @@ F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 F autoconf/tea/configure.ac 0deb5d6c49c8119f75f436488219fc043127d72057af5dfba2c9ce096a5734bc F autoconf/tea/doc/sqlite3.n e1fe45d4f5286ee3d0ccc877aca2a0def488e9bb F autoconf/tea/license.terms 13bd403c9610fd2b76ece0ab50c4c5eda933d523 -F autoconf/tea/pkgIndex.tcl.in b9eb6dd37f64e08e637d576b3c83259814b9cddd78bec4af2e5abfc6c5c750ce +F autoconf/tea/pkgIndex.tcl.in 55aec3c6d7e9a1de9b8d2fdc9c27fd055da3ac3a51b572195e2ae7300bcfd3a2 F autoconf/tea/tclconfig/install-sh bdd5e293591621ae60d9824d86a4b1c5f22c3d00 F autoconf/tea/tclconfig/tcl.m4 c6e5f2fc7178f40d087403daa044ef3b86a8e30793f3b121bdcbdf152c6a776a -F autoconf/tea/win/makefile.vc 2c478a9a962e48b2bf9062734e04d7c63c556e217095419173f9d7938d7d78f7 +F autoconf/tea/win/makefile.vc 9b33af4214a5c8360549b96380f55ece1a2df76a51ab4c726296e5c43d8a2227 F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea00342d1a1a7eaa19cb F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 @@ -778,7 +778,7 @@ F src/sqliteInt.h ad02397dc4d22b77f9a331412d46e4c1e49459dd386fba8373fa148998e1e7 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c c6888598f08dee3d9112a38ef42c8f5c89ca7f3190f4694744d0b84250f4bf8c +F src/tclsqlite.c b3fea4c31c22e7b545681221a53eba9a358602706e04e066f88e2c63d99fe12f F src/tclsqlite.h c6af51f31a2b2172d674608763a4b98fdf5cd587e4025053e546fb8077757262 F src/test1.c 8bf8b74145b768f42386787f93f6d6dad7bc400a4ee2d50e4ad5a06a20a97ef1 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 @@ -1728,7 +1728,7 @@ F test/thread005.test 50d10b5684399676174bd96c94ad4250b1a2c8b6 F test/thread1.test df115faa10a4ba1d456e9d4d9ec165016903eae4 F test/thread2.test f35d2106452b77523b3a2b7d1dcde2e5ee8f9e46 F test/thread3.test a12656a56cdf67acb6a2ff7638826c6d6a645f79909d86df521045ad31cf547d -F test/thread_common.tcl 334639cadcb9f912bf82aa73f49efd5282e6cadd +F test/thread_common.tcl b3b19a769fe30ef5537cdfa60acd49b78f771301627720d1add2d3bac77d9039 F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b F test/threadtest2.c a70a8e94bef23339d34226eb9521015ef99f4df8 F test/threadtest3.c 655bff6c0895ec03f014126aa65e808fac9aae8c5a7a7da58a510cbe8b43b781 @@ -2216,8 +2216,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1218a203483cecdc8c9abdc970ad68eba0dfa9cafbed95c63cefb7e8af8babee -R caf8280fa8e7a7de178081dbae97667f +P 9d0eb3980409115f2f6fd1720a03f34e3968c93be55feafdfef20bf5f711c17f +R 525968629ef8a97f7864de3317394574 +T *branch * make-install-fixes +T *sym-make-install-fixes * +T -sym-trunk * U drh -Z 3adb35abb1bf3d691bca5f7e2785786d +Z 004d1cd0c9856b8ead77a78c5a8afb90 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5abf6c8472..9609fd1107 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d0eb3980409115f2f6fd1720a03f34e3968c93be55feafdfef20bf5f711c17f +9c0690193200551a3218c576b19eaf40e330dc252d67b430204ff44495e4793e diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 0c8888fd48..3ff14a2f9a 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -3981,7 +3981,7 @@ static int SQLITE_TCLAPI DbMain( ** The EXTERN macros are required by TCL in order to work on windows. */ EXTERN int Sqlite3_Init(Tcl_Interp *interp){ - int rc = Tcl_InitStubs(interp, "8.4", 0) ? TCL_OK : TCL_ERROR; + int rc = Tcl_InitStubs(interp, "8.6-", 0) ? TCL_OK : TCL_ERROR; if( rc==TCL_OK ){ Tcl_CreateObjCommand(interp, "sqlite3", (Tcl_ObjCmdProc*)DbMain, 0, 0); #ifndef SQLITE_3_SUFFIX_ONLY diff --git a/test/thread_common.tcl b/test/thread_common.tcl index 6b17082ad4..1ebc6573a9 100644 --- a/test/thread_common.tcl +++ b/test/thread_common.tcl @@ -95,7 +95,7 @@ proc run_thread_tests {{print_warning 0}} { if {[info commands sqlthread] eq ""} { set zProblem "SQLite build is not threadsafe" } - if {![info exists ::tcl_platform(threaded)]} { + if {![tcl::pkgconfig get threaded]} { set zProblem "Linked against a non-threadsafe Tcl build" } if {[info exists zProblem]} { @@ -107,4 +107,3 @@ proc run_thread_tests {{print_warning 0}} { } return 0 - From 97b061060247a4852954ecf825b97b6eedf44f61 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 9 Oct 2024 13:40:49 +0000 Subject: [PATCH 44/77] Make it so that the TCL extension installed using "make install" has the same name as the one installed by "make tclextension-install". FossilOrigin-Name: e21fc1ba44dc88547fd2cdfaed90717566153880e79d862e2b3e54ba7f8f0a2e --- Makefile.in | 13 ++----------- manifest | 15 ++++++--------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Makefile.in b/Makefile.in index 43709ff5c4..efdd6d056a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1587,10 +1587,10 @@ lib_install: libsqlite3.la $(INSTALL) -d $(DESTDIR)$(libdir) $(LTINSTALL) libsqlite3.la $(DESTDIR)$(libdir) -# Use $(tcl_install_$(HAVE_TCL)) to resolve to either tcl_install or +# Use $(tcl_install_$(HAVE_TCL)) to resolve to either tclextension-install or # an empty value. tcl_install_0 = -tcl_install_1 = tcl_install +tcl_install_1 = tclextension-install install: sqlite3$(TEXE) lib_install sqlite3.h sqlite3.pc $(tcl_install_$(HAVE_TCL)) $(INSTALL) -d $(DESTDIR)$(bindir) @@ -1601,15 +1601,6 @@ install: sqlite3$(TEXE) lib_install sqlite3.h sqlite3.pc $(tcl_install_$(HAVE_TC $(INSTALL) -d $(DESTDIR)$(pkgconfigdir) $(INSTALL) -m 0644 sqlite3.pc $(DESTDIR)$(pkgconfigdir) -pkgIndex.tcl: - echo 'package ifneeded sqlite3 $(RELEASE) [list load [file join $$dir libtclsqlite3[info sharedlibextension]] Sqlite3]' > $@ - -tcl_install: lib_install libtclsqlite3.la pkgIndex.tcl - $(INSTALL) -d $(DESTDIR)$(TCLLIBDIR) - $(LTINSTALL) libtclsqlite3.la $(DESTDIR)$(TCLLIBDIR) - rm -f $(DESTDIR)$(TCLLIBDIR)/libtclsqlite3.la $(DESTDIR)$(TCLLIBDIR)/libtclsqlite3.a - $(INSTALL) -m 0644 pkgIndex.tcl $(DESTDIR)$(TCLLIBDIR) - # Build the SQLite TCL extension in a way that make it compatible # with whatever version of TCL is running as $TCLSH_CMD, possibly defined # by --with-tclsh= diff --git a/manifest b/manifest index 3c11ff81dd..ed9d25983e 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Changes\sto\sthe\sTCL\sextension\sand\show\sit\sis\sbuilt,\ssuggested\sby\sJan\sNijtmans. -D 2024-10-09T13:19:21.954 +C Make\sit\sso\sthat\sthe\sTCL\sextension\sinstalled\susing\s"make\sinstall"\shas\sthe\nsame\sname\sas\sthe\sone\sinstalled\sby\s"make\stclextension-install". +D 2024-10-09T13:40:49.112 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in a994d7642ebb6cb9cd49884a929ed33dc6b309b6bc55ea85c33db9ec5aa96af6 +F Makefile.in 48c133f8d4aa69fc1d461864cf5e008534880d33e93ef942ea58ef591a0569cd F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 13357270c2434dfda7e38dd95bd1d1bd7f832c77fe275ec867c12d14d7a4631b F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -2216,11 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9d0eb3980409115f2f6fd1720a03f34e3968c93be55feafdfef20bf5f711c17f -R 525968629ef8a97f7864de3317394574 -T *branch * make-install-fixes -T *sym-make-install-fixes * -T -sym-trunk * +P 9c0690193200551a3218c576b19eaf40e330dc252d67b430204ff44495e4793e +R 923d4cd7cb78af9845370c2fe6b3cf93 U drh -Z 004d1cd0c9856b8ead77a78c5a8afb90 +Z 3a79948d3d4fb197913c1113a9a14bc7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9609fd1107..a5401ff882 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9c0690193200551a3218c576b19eaf40e330dc252d67b430204ff44495e4793e +e21fc1ba44dc88547fd2cdfaed90717566153880e79d862e2b3e54ba7f8f0a2e From 492925a8f01495329b9b2afc0be3d4fd6787da0c Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 9 Oct 2024 13:54:24 +0000 Subject: [PATCH 45/77] Change the makefile to prefer the use of tclsh9.0 if it is available. FossilOrigin-Name: 28e2b9a23f61530bc5eea364a74817fca03fa31f70d4eefb0942a89c1d79f765 --- configure | 2 +- configure.ac | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/configure b/configure index 22b961e554..0ddfa67aa6 100755 --- a/configure +++ b/configure @@ -10335,7 +10335,7 @@ fi original_use_tcl=${use_tcl} if test x"${with_tclsh}" == x -a x"${with_tcl}" == x; then - for ac_prog in tclsh8.6 tclsh tclsh9.0 + for ac_prog in tclsh9.0 tclsh8.6 tclsh do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 diff --git a/configure.ac b/configure.ac index b3a0dd299f..f2ec22aae2 100644 --- a/configure.ac +++ b/configure.ac @@ -125,7 +125,7 @@ AC_ARG_ENABLE(tcl, AS_HELP_STRING([--disable-tcl],[omit building accessory progr [use_tcl=$enableval],[use_tcl=yes]) original_use_tcl=${use_tcl} if test x"${with_tclsh}" == x -a x"${with_tcl}" == x; then - AC_CHECK_PROGS(TCLSH_CMD, [tclsh8.6 tclsh tclsh9.0],none) + AC_CHECK_PROGS(TCLSH_CMD, [tclsh9.0 tclsh8.6 tclsh],none) with_tclsh=${TCLSH_CMD} fi if test x"${with_tclsh}" != x -a x"${with_tclsh}" != xnone; then diff --git a/manifest b/manifest index ed9d25983e..7367c76fef 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sit\sso\sthat\sthe\sTCL\sextension\sinstalled\susing\s"make\sinstall"\shas\sthe\nsame\sname\sas\sthe\sone\sinstalled\sby\s"make\stclextension-install". -D 2024-10-09T13:40:49.112 +C Change\sthe\smakefile\sto\sprefer\sthe\suse\sof\stclsh9.0\sif\sit\sis\savailable. +D 2024-10-09T13:54:24.437 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -35,8 +35,8 @@ F autoconf/tea/win/nmakehlp.c b01f822eabbe1ed2b64e70882d97d48402b42d2689a1ea0034 F autoconf/tea/win/rules.vc 7b3bb2ef32ade0f3f14d951231811678722725e3bca240dd9727ae0dfe10f6a5 F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6 F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559 -F configure 49523f0a070b583cea040d26eff53a65fb0893eca4663b1343a4d5a9a964da53 x -F configure.ac a100ebf7a07f5dedd319ef547dd467d1676ed059b85a7877aa9c44ac309f7000 +F configure 135e050689ea244477582e6d77cc7867dfcfe6e0f82e3eab3e47655a67035f8f x +F configure.ac aca8ebf47b7644c473e11e599ea986eeb23860a8732a8812039ad961ef52a713 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd F doc/compile-for-windows.md 4d4bfafda42a7a33f166d23aed4db1bb4ea1e5751595a5cced2bad349fd14652 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9c0690193200551a3218c576b19eaf40e330dc252d67b430204ff44495e4793e -R 923d4cd7cb78af9845370c2fe6b3cf93 +P e21fc1ba44dc88547fd2cdfaed90717566153880e79d862e2b3e54ba7f8f0a2e +R 43a3ec8b90a9e71d80fbd60d9b6497e3 U drh -Z 3a79948d3d4fb197913c1113a9a14bc7 +Z cb990e9dc67b861b1e4007698e41b060 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a5401ff882..1336366679 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e21fc1ba44dc88547fd2cdfaed90717566153880e79d862e2b3e54ba7f8f0a2e +28e2b9a23f61530bc5eea364a74817fca03fa31f70d4eefb0942a89c1d79f765 From 48dd75df73c53a28ef4e4a8dfd58787fa9893ac6 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 9 Oct 2024 15:40:07 +0000 Subject: [PATCH 46/77] Fix the xCheckReservedLock() method of the flock VFS to avoid dropping the file-lock. FossilOrigin-Name: 8ffaf85249ff38ceea037a6e96b3484c912f1c1aa55b8642297d592768661344 --- manifest | 19 ++++++++++------- manifest.uuid | 2 +- src/os_unix.c | 57 ++++++++++++++----------------------------------- test/lock5.test | 46 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 50 deletions(-) diff --git a/manifest b/manifest index 2f16d8e027..ad17a5c555 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\shandling\sof\sunicode\scharacters\sin\sthe\sLIKE\soptimization.\nFollow-up\sto\s[bce52ce2a6e7f3d3]. -D 2024-10-09T11:52:29.532 +C Fix\sthe\sxCheckReservedLock()\smethod\sof\sthe\sflock\sVFS\sto\savoid\sdropping\sthe\sfile-lock. +D 2024-10-09T15:40:07.361 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -753,7 +753,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06 F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107 -F src/os_unix.c 779e83666ecd535f6725497ba6da069c1d15138ff6a4ee123edad1ae0cdfbe83 +F src/os_unix.c 4086be39edc253ca75d4f447972e26f6998023ab519d1a176e3b3a72fae609d0 F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c b08600ebf0db90b6d1e9b8b6577c6fa3877cbe1a100bd0b2899e4c6e9adad4b3 @@ -1405,7 +1405,7 @@ F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff F test/lock3.test f271375930711ae044080f4fe6d6eda930870d00 F test/lock4.test 27143363eda1622f03c133efc8db808fc331afd973486cb571ea71cd717d37b8 -F test/lock5.test 24693e40a805f71d80836f720d1f2034684a39b64f1e1990989002c7968c11ee +F test/lock5.test 51e9e2e8d5aed4ec470be19dfc0d630388a7444a8fc812ec8d08e46469a15726 F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5 F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431 F test/lock_common.tcl 2f3f7f2e9637f93ccf609df48ef5b27a50278b6b1cd752b445d52262e5841413 @@ -2216,8 +2216,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1218a203483cecdc8c9abdc970ad68eba0dfa9cafbed95c63cefb7e8af8babee -R caf8280fa8e7a7de178081dbae97667f -U drh -Z 3adb35abb1bf3d691bca5f7e2785786d +P 9d0eb3980409115f2f6fd1720a03f34e3968c93be55feafdfef20bf5f711c17f +R 1326bd74517af8f0c3bf930ca135c7cd +T *branch * flock-vfs-fix +T *sym-flock-vfs-fix * +T -sym-trunk * +U dan +Z 010da7dfc98fb9ecd5cbc3e4ca08a182 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5abf6c8472..23d8cb612d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d0eb3980409115f2f6fd1720a03f34e3968c93be55feafdfef20bf5f711c17f +8ffaf85249ff38ceea037a6e96b3484c912f1c1aa55b8642297d592768661344 diff --git a/src/os_unix.c b/src/os_unix.c index 92ad9d8607..2106dee8f0 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2464,54 +2464,29 @@ static int robust_flock(int fd, int op){ ** is set to SQLITE_OK unless an I/O error occurs during lock checking. */ static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){ - int rc = SQLITE_OK; - int reserved = 0; unixFile *pFile = (unixFile*)id; SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; ); assert( pFile ); + assert( pFile->eFileLock<=SHARED_LOCK ); - /* Check if a thread in this process holds such a lock */ - if( pFile->eFileLock>SHARED_LOCK ){ - reserved = 1; - } + /* The flock VFS only ever takes exclusive locks (see function flockLock). + ** Therefore, if this connection is holding any lock at all, no other + ** connection may be holding a RESERVED lock. So set *pResOut to 0 + ** in this case. + ** + ** Or, this connection may be holding no lock. In that case, set *pResOut to + ** 0 as well. The caller will then attempt to take an EXCLUSIVE lock on the + ** db in order to roll the hot journal back. If there is another connection + ** holding a lock, that attempt will fail and an SQLITE_BUSY returned to + ** the user. With other VFS, we try to avoid this, in order to allow a reader + ** to proceed while a writer is preparing its transaction. But that won't + ** work with the flock VFS - as it always takes EXCLUSIVE locks - so it is + ** not a problem in this case. */ + *pResOut = 0; - /* Otherwise see if some other process holds it. */ - if( !reserved ){ - /* attempt to get the lock */ - int lrc = robust_flock(pFile->h, LOCK_EX | LOCK_NB); - if( !lrc ){ - /* got the lock, unlock it */ - lrc = robust_flock(pFile->h, LOCK_UN); - if ( lrc ) { - int tErrno = errno; - /* unlock failed with an error */ - lrc = SQLITE_IOERR_UNLOCK; - storeLastErrno(pFile, tErrno); - rc = lrc; - } - } else { - int tErrno = errno; - reserved = 1; - /* someone else might have it reserved */ - lrc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK); - if( IS_LOCK_ERROR(lrc) ){ - storeLastErrno(pFile, tErrno); - rc = lrc; - } - } - } - OSTRACE(("TEST WR-LOCK %d %d %d (flock)\n", pFile->h, rc, reserved)); - -#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS - if( (rc & 0xff) == SQLITE_IOERR ){ - rc = SQLITE_OK; - reserved=1; - } -#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */ - *pResOut = reserved; - return rc; + return SQLITE_OK; } /* diff --git a/test/lock5.test b/test/lock5.test index e0c88aedcf..b656aa2af4 100644 --- a/test/lock5.test +++ b/test/lock5.test @@ -146,6 +146,52 @@ do_test lock5-flock.8 { db2 close } {} +do_test lock5-flock.9 { + sqlite3 db test.db -vfs unix-flock + execsql { + SELECT * FROM t1 + } +} {1 2} + +do_test lock5-flock.10 { + sqlite3 db2 test.db -vfs unix-flock + execsql { + SELECT * FROM t1 + } db2 +} {1 2} + +do_test lock5-flock.10 { + execsql { + PRAGMA cache_size = 1; + BEGIN; + WITH s(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000 + ) + INSERT INTO t1 SELECT i, i+1 FROM s; + } + + catchsql { + SELECT * FROM t1 + } db2 +} {1 {database is locked}} + +do_test lock5-flock.11 { + forcecopy test.db test.db2 + forcecopy test.db-journal test.db2-journal + db2 close + sqlite3 db2 test.db2 -vfs unix-flock + catchsql { + SELECT * FROM t1 + } db2 +} {0 {1 2}} + +do_test lock5-flock.12 { + file exists test.db2-journal +} 0 + +db close +db2 close + } ##################################################################### From da1bf77cc250414d61128085867b5d7490de6532 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 9 Oct 2024 16:32:19 +0000 Subject: [PATCH 47/77] Fix a problem in the generate_series() extension introduced by [d50b784807333c54]. FossilOrigin-Name: 41d58a014ce89356932d717843a1fa6e0735f15a7b7265c41ac85a9722a5d826 --- ext/misc/series.c | 82 ++++++++++++++++++++++++----------------------- manifest | 15 ++++----- manifest.uuid | 2 +- 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/ext/misc/series.c b/ext/misc/series.c index f2ca75c253..faf8fd0306 100644 --- a/ext/misc/series.c +++ b/ext/misc/series.c @@ -658,46 +658,48 @@ static int seriesBestIndex( } continue; } - if( pConstraint->iColumn==SERIES_COLUMN_VALUE ){ - switch( op ){ - case SQLITE_INDEX_CONSTRAINT_EQ: - case SQLITE_INDEX_CONSTRAINT_IS: { - idxNum |= 0x0080; - idxNum &= ~0x3300; - aIdx[5] = i; - aIdx[6] = -1; - bStartSeen = 1; - break; - } - case SQLITE_INDEX_CONSTRAINT_GE: { - if( idxNum & 0x0080 ) break; - idxNum |= 0x0100; - idxNum &= ~0x0200; - aIdx[5] = i; - bStartSeen = 1; - break; - } - case SQLITE_INDEX_CONSTRAINT_GT: { - if( idxNum & 0x0080 ) break; - idxNum |= 0x0200; - idxNum &= ~0x0100; - aIdx[5] = i; - bStartSeen = 1; - break; - } - case SQLITE_INDEX_CONSTRAINT_LE: { - if( idxNum & 0x0080 ) break; - idxNum |= 0x1000; - idxNum &= ~0x2000; - aIdx[6] = i; - break; - } - case SQLITE_INDEX_CONSTRAINT_LT: { - if( idxNum & 0x0080 ) break; - idxNum |= 0x2000; - idxNum &= ~0x1000; - aIdx[6] = i; - break; + if( pConstraint->iColumniColumn==SERIES_COLUMN_VALUE ){ + switch( op ){ + case SQLITE_INDEX_CONSTRAINT_EQ: + case SQLITE_INDEX_CONSTRAINT_IS: { + idxNum |= 0x0080; + idxNum &= ~0x3300; + aIdx[5] = i; + aIdx[6] = -1; + bStartSeen = 1; + break; + } + case SQLITE_INDEX_CONSTRAINT_GE: { + if( idxNum & 0x0080 ) break; + idxNum |= 0x0100; + idxNum &= ~0x0200; + aIdx[5] = i; + bStartSeen = 1; + break; + } + case SQLITE_INDEX_CONSTRAINT_GT: { + if( idxNum & 0x0080 ) break; + idxNum |= 0x0200; + idxNum &= ~0x0100; + aIdx[5] = i; + bStartSeen = 1; + break; + } + case SQLITE_INDEX_CONSTRAINT_LE: { + if( idxNum & 0x0080 ) break; + idxNum |= 0x1000; + idxNum &= ~0x2000; + aIdx[6] = i; + break; + } + case SQLITE_INDEX_CONSTRAINT_LT: { + if( idxNum & 0x0080 ) break; + idxNum |= 0x2000; + idxNum &= ~0x1000; + aIdx[6] = i; + break; + } } } continue; diff --git a/manifest b/manifest index 7c686dc508..126f85ad50 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sxCheckReservedLock()\smethod\sof\sthe\sflock\sVFS\sto\savoid\sdropping\sthe\sfile\slock. -D 2024-10-09T16:28:26.644 +C Fix\sa\sproblem\sin\sthe\sgenerate_series()\sextension\sintroduced\sby\n[d50b784807333c54]. +D 2024-10-09T16:32:19.421 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -421,7 +421,7 @@ F ext/misc/regexp.c 4bdd0045912f81c84908bd535ec5ad3b1c8540b4287c70ab840709636240 F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946 -F ext/misc/series.c a6089b5e8e3002bd1e5d9877cee6aead0b9a6426e406c09a399817db9e9ae823 +F ext/misc/series.c 596afbfbbc81ccf4ea6da11f016f7eed630ed195b5e9d548117e19f06d63f641 F ext/misc/sha1.c cb5002148c2661b5946f34561701e9105e9d339b713ec8ac057fd888b196dcb9 F ext/misc/shathree.c 1821d90a0040c9accdbe3e3527d378d30569475d758aa70f6848924c0b430e8c F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 @@ -2216,9 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9d0eb3980409115f2f6fd1720a03f34e3968c93be55feafdfef20bf5f711c17f 8ffaf85249ff38ceea037a6e96b3484c912f1c1aa55b8642297d592768661344 -R 1326bd74517af8f0c3bf930ca135c7cd -T +closed 8ffaf85249ff38ceea037a6e96b3484c912f1c1aa55b8642297d592768661344 -U dan -Z f63fcc94a9c77284788c7f94ef1468fb +P f7acb189d8eadf2de2fa992b3ff7293838fd0f8fd3c61e9f0238226a36ea6bcf +R a2ee738e138d3fd76c622231c3a068a8 +U drh +Z 898a13abf8610a35615e136dfd53c619 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0cd0ca1921..d45260e403 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f7acb189d8eadf2de2fa992b3ff7293838fd0f8fd3c61e9f0238226a36ea6bcf +41d58a014ce89356932d717843a1fa6e0735f15a7b7265c41ac85a9722a5d826 From 94fe1ad1c6cf5966f76c443d680465551798b6f0 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 9 Oct 2024 17:47:43 +0000 Subject: [PATCH 48/77] Add quotes around $(CC) in tclextension-related targets so that a CC of "ccache cc" works. FossilOrigin-Name: e8f719d13fbcbaf1b52b421d7af59759b1b4692d4010a68d5865dfeaf3cf8cb0 --- Makefile.in | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.in b/Makefile.in index efdd6d056a..556b3600a1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1606,13 +1606,13 @@ install: sqlite3$(TEXE) lib_install sqlite3.h sqlite3.pc $(tcl_install_$(HAVE_TC # by --with-tclsh= # tclextension: tclsqlite3.c - $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --build-only --cc $(CC) $(CFLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) + $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --build-only --cc "$(CC)" $(CFLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) # Install the SQLite TCL extension in a way that is appropriate for $TCLSH_CMD # to find it. # tclextension-install: tclsqlite3.c - $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --cc $(CC) $(CFLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) + $(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --cc "$(CC)" $(CFLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) # Install the SQLite TCL extension that is used by $TCLSH_CMD # diff --git a/manifest b/manifest index 7367c76fef..ae5ea2e0f0 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Change\sthe\smakefile\sto\sprefer\sthe\suse\sof\stclsh9.0\sif\sit\sis\savailable. -D 2024-10-09T13:54:24.437 +C Add\squotes\saround\s$(CC)\sin\stclextension-related\stargets\sso\sthat\sa\sCC\sof\s"ccache\scc"\sworks. +D 2024-10-09T17:47:43.543 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 48c133f8d4aa69fc1d461864cf5e008534880d33e93ef942ea58ef591a0569cd +F Makefile.in e504a9f003b2de41447b81296d9a6988a67ffabc34fa396b60ffd89b0c63a7bf F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 13357270c2434dfda7e38dd95bd1d1bd7f832c77fe275ec867c12d14d7a4631b F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e21fc1ba44dc88547fd2cdfaed90717566153880e79d862e2b3e54ba7f8f0a2e -R 43a3ec8b90a9e71d80fbd60d9b6497e3 -U drh -Z cb990e9dc67b861b1e4007698e41b060 +P 28e2b9a23f61530bc5eea364a74817fca03fa31f70d4eefb0942a89c1d79f765 +R 5d1fcd827a8facd387ccc45fec2ba4a3 +U stephan +Z 4ca8372b73f0c06cd72b28d7956268de # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 1336366679..9f8f2cda57 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -28e2b9a23f61530bc5eea364a74817fca03fa31f70d4eefb0942a89c1d79f765 +e8f719d13fbcbaf1b52b421d7af59759b1b4692d4010a68d5865dfeaf3cf8cb0 From 50ec92f7ce21b031ccc8df1e9637cd67124d57db Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 9 Oct 2024 20:05:26 +0000 Subject: [PATCH 49/77] Improvements to Makefile.msc: (1) Attempt to find sane values for key variables based on the value of TCLDIR. (2) Default to TCLVERSION 90 instead of 86. (3) Add the "tcl-env" target that shows the values of key variables associated with TCL. FossilOrigin-Name: 6b7a789a416fb62a532882d10e41c7048a6805f5fbbc008f36f9802be45d9ebb --- Makefile.msc | 45 ++++++++++++++++++++++++++++++++++++++------- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 7cdbda0c42..148e09ab73 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -929,10 +929,6 @@ TCC = $(TCC) /fsanitize=address # prior to running nmake in order to match the actual installed location and # version on this machine. # -!IFNDEF TCLVERSION -TCLVERSION = 86 -!ENDIF - !IFNDEF TCLSUFFIX TCLSUFFIX = !ENDIF @@ -941,6 +937,19 @@ TCLSUFFIX = TCLDIR = C:\Tcl !ENDIF +!IFNDEF TCLVERSION +!IF EXISTS("$(TCLDIR)\lib\tcl90$(TCLSUFFIX).lib") +TCLVERSION = 90 +!ELSEIF EXISTS("$(TCLDIR)\lib\tcl86$(TCLSUFFIX).lib") +TCLVERSION = 86 +!ELSEIF EXISTS("$(TCLDIR)\lib\tcl86t.lib") +TCLSUFFIX = t +TCLVERSION = 86 +!ELSE +TCLVERSION = 90 +!ENDIF +!ENDIF + !IFNDEF TCLINCDIR TCLINCDIR = $(TCLDIR)\include !ENDIF @@ -954,8 +963,12 @@ LIBTCL = tcl$(TCLVERSION)$(TCLSUFFIX).lib !ENDIF !IFNDEF LIBTCLSTUB +!IF EXISTS("$(TCLLIBDIR)\tclstub$(TCLSUFFIX).lib") +LIBTCLSTUB = tclstub$(TCLSUFFIX).lib +!ELSE LIBTCLSTUB = tclstub$(TCLVERSION)$(TCLSUFFIX).lib !ENDIF +!ENDIF !IFNDEF LIBTCLPATH LIBTCLPATH = $(TCLDIR)\bin @@ -1013,10 +1026,18 @@ LIBICU = icuuc.lib icuin.lib # specific Tcl shell to use. # !IFNDEF TCLSH_CMD -!IF $(USE_TCLSH_IN_PATH)!=0 || !EXIST("$(TCLDIR)\bin\tclsh.exe") -TCLSH_CMD = tclsh -!ELSE +!IF EXISTS("$(TCLDIR)\bin\tclsh$(TCLVERSION).exe") +TCLSH_CMD = $(TCLDIR)\bin\tclsh$(TCLVERSION).exe +!ELSEIF EXISTS("$(TCLDIR)\bin\tclsh90.exe") +TCLSH_CMD = $(TCLDIR)\bin\tclsh90.exe +!ELSEIF EXISTS("$(TCLDIR)\bin\tclsh86.exe") +TCLSH_CMD = $(TCLDIR)\bin\tclsh86.exe +!ELSEIF EXISTS("$(TCLDIR)\bin\tclsh86t.exe") +TCLSH_CMD = $(TCLDIR)\bin\tclsh86t.exe +!ELSEIF EXISTS("$(TCLDIR)\bin\tclsh.exe") TCLSH_CMD = $(TCLDIR)\bin\tclsh.exe +!ELSE +TCLSH_CMD = tclsh !ENDIF !ENDIF # <> @@ -2746,6 +2767,16 @@ THREADTEST3_SRC = \ threadtest3.exe: $(THREADTEST3_SRC) $(TOP)\src\test_multiplex.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) $(TOP)\test\threadtest3.c $(TOP)\src\test_multiplex.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) +# Display key variables that control which version of TCL is to be used. +# +tcl-env: + @echo TCLDIR = $(TCLDIR) + @echo TCLVERSION = $(TCLVERSION) + @echo TCLSUFFIX = $(TCLSUFFIX) + @echo LIBTCL = $(LIBTCL) + @echo LIBTCLSTUB = $(LIBTCLSTUB) + @echo TCLSH_CMD = $(TCLSH_CMD) + LSMDIR=$(TOP)\ext\lsm1 !INCLUDE $(LSMDIR)\Makefile.msc diff --git a/manifest b/manifest index ae5ea2e0f0..cdce6cf63e 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Add\squotes\saround\s$(CC)\sin\stclextension-related\stargets\sso\sthat\sa\sCC\sof\s"ccache\scc"\sworks. -D 2024-10-09T17:47:43.543 +C Improvements\sto\sMakefile.msc:\s(1)\sAttempt\sto\sfind\ssane\svalues\sfor\skey\nvariables\sbased\son\sthe\svalue\sof\sTCLDIR.\s\s(2)\sDefault\sto\sTCLVERSION\s90\sinstead\nof\s86.\s\s(3)\sAdd\sthe\s"tcl-env"\starget\sthat\sshows\sthe\svalues\sof\skey\svariables\nassociated\swith\sTCL. +D 2024-10-09T20:05:26.424 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F Makefile.in e504a9f003b2de41447b81296d9a6988a67ffabc34fa396b60ffd89b0c63a7bf F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 13357270c2434dfda7e38dd95bd1d1bd7f832c77fe275ec867c12d14d7a4631b +F Makefile.msc c6abbbe25cef6bf1eb255884cd9137b6afa4f850f4bdc78ba718f4035c35000b F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 28e2b9a23f61530bc5eea364a74817fca03fa31f70d4eefb0942a89c1d79f765 -R 5d1fcd827a8facd387ccc45fec2ba4a3 -U stephan -Z 4ca8372b73f0c06cd72b28d7956268de +P e8f719d13fbcbaf1b52b421d7af59759b1b4692d4010a68d5865dfeaf3cf8cb0 +R 6adacab87cffb89c84a1bbdbcff4792d +U drh +Z f45d0adbf7e7e6e176374a9b7492aa02 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9f8f2cda57..783841eca9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e8f719d13fbcbaf1b52b421d7af59759b1b4692d4010a68d5865dfeaf3cf8cb0 +6b7a789a416fb62a532882d10e41c7048a6805f5fbbc008f36f9802be45d9ebb From f553588c76ee1adbdc7b7c8ec340c687a2f881be Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 10 Oct 2024 09:59:06 +0000 Subject: [PATCH 50/77] Adjustments to the Makefile.msc to get static builds of sqlite3_analyzer.exe working with TCL9. Update the compile-for-windows.md document for TCL9. FossilOrigin-Name: df16d07d8db042cdb1dc6bb9a00a0265ba791a615d74f9152d0b3344e618fe93 --- Makefile.msc | 4 ++++ doc/compile-for-windows.md | 35 +++++++++++++++++------------------ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 148e09ab73..529e6995c0 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -962,6 +962,10 @@ TCLLIBDIR = $(TCLDIR)\lib LIBTCL = tcl$(TCLVERSION)$(TCLSUFFIX).lib !ENDIF +!IFNDEF TCLLIBS +TCLLIBS = /NODEFAULTLIB:libucrt.lib netapi32.lib user32.lib ucrt.lib +!ENDIF + !IFNDEF LIBTCLSTUB !IF EXISTS("$(TCLLIBDIR)\tclstub$(TCLSUFFIX).lib") LIBTCLSTUB = tclstub$(TCLSUFFIX).lib diff --git a/doc/compile-for-windows.md b/doc/compile-for-windows.md index 1627188acd..18189f5376 100644 --- a/doc/compile-for-windows.md +++ b/doc/compile-for-windows.md @@ -1,7 +1,7 @@ # Notes On Compiling SQLite On Windows 11 Here are step-by-step instructions on how to build SQLite from -canonical source on a new Windows 11 PC, as of 2023-11-01: +canonical source on a new Windows 11 PC, as of 2024-10-09: 1. Install Microsoft Visual Studio. The free "community edition" will work fine. Do a standard install for C++ development. @@ -20,9 +20,11 @@ canonical source on a new Windows 11 PC, as of 2023-11-01: install the TCL development libraries in the "`c:\Tcl`" directory. Make adjustments if you want TCL installed somewhere else. SQLite needs both the - "tclsh.exe" command-line tool as part of the build process, and - the "tcl86.lib" library in order to run tests. You will need - TCL version 8.6 or later. + "tclsh90.exe" command-line tool as part of the build process, and + the "tcl90.lib" and "tclstub.lib" libraries in order to run tests. + This document assumes you are working with TCL version 9.0. + See versions of this document from prior to 2024-10-10 for + instructions on how to build using TCL version 8.6.
  1. Get the TCL source archive, perhaps from [https://www.tcl.tk/software/tcltk/download.html](https://www.tcl.tk/software/tcltk/download.html). @@ -30,13 +32,10 @@ canonical source on a new Windows 11 PC, as of 2023-11-01: of the source tree.
  2. Run: `nmake /f makefile.vc release`
  3. Run: `nmake /f makefile.vc INSTALLDIR=c:\Tcl install` -
  4. CD to `c:\Tcl\lib`. In that subfolder make a copy of the - "`tcl86t.lib`" file to the alternative name "`tcl86.lib`" - (omitting the second 't'). Leave the copy in the same directory - as the original. -
  5. CD to `c:\Tcl\bin`. Make a copy of the "`tclsh86t.exe`" - file into "`tclsh.exe`" (without the "86t") in the same directory. -
  6. Add `c:\Tcl\bin` to your %PATH%. To do this, go to Settings +
  7. Optional: CD to `c:\Tcl\bin` and make a copy of + `tclsh90.exe` over into just `tclsh.exe`. +
  8. Optional: + Add `c:\Tcl\bin` to your %PATH%. To do this, go to Settings and search for "path". Select "edit environment variables for your account" and modify your default PATH accordingly. You will need to close and reopen your command prompts after @@ -59,6 +58,7 @@ canonical source on a new Windows 11 PC, as of 2023-11-01:
  9. `nmake /f makefile.msc sqlite3.c`
  10. `nmake /f makefile.msc sqlite3.exe`
  11. `nmake /f makefile.msc sqldiff.exe` +
  12. `nmake /f makefile.msc sqlite3-rsync.exe`
  13. `nmake /f makefile.msc tclextension-install`
  14. `nmake /f makefile.msc devtest`
  15. `nmake /f makefile.msc releasetest` @@ -127,7 +127,7 @@ nmake /f Makefile.msc sqlite3_analyzer.exe ~~~~ And you will end up with a working executable. However, that executable -will depend on having the "tcl86.dll" library somewhere on your %PATH%. +will depend on having the "tcl98.dll" library somewhere on your %PATH%. Use the following steps to build an executable that has the TCL library statically linked so that it does not depend on separate DLL: @@ -137,13 +137,12 @@ statically linked so that it does not depend on separate DLL: 2. Untar the TCL source tarball into a fresh directory. CD into the "win/" subfolder. - 3. Run: `nmake /f makefile.vc OPTS=nothreads,static shell` - + 3. Run: `nmake /f makefile.vc OPTS=static shell` 4. CD into the "Release*" subfolder that is created (note the wildcard - the full name of the directory might vary). There - you will find the "tcl86s.lib" file. Copy this file into the - same directory that you put the "tcl86.lib" on your initial + you will find the "tcl90s.lib" file. Copy this file into the + same directory that you put the "tcl90.lib" on your initial installation. (In this document, that directory is "`C:\Tcl32\lib`" for 32-bit builds and "`C:\Tcl\lib`" for 64-bit builds.) @@ -152,12 +151,12 @@ statically linked so that it does not depend on separate DLL: utility program, but add the following extra arguments to the nmake command line:
    -      CCOPTS="-DSTATIC_BUILD" LIBTCL="tcl86s.lib netapi32.lib user32.lib"
    +      CCOPTS="-DSTATIC_BUILD" LIBTCL="tcl90s.lib"
           

    So, for example, to build a statically linked version of sqlite3_analyzer.exe, you might type:

    -      nmake /f Makefile.msc CCOPTS="-DSTATIC_BUILD" LIBTCL="tcl86s.lib netapi32.lib user32.lib" sqlite3_analyzer.exe
    +      nmake /f Makefile.msc CCOPTS="-DSTATIC_BUILD" LIBTCL="tcl90s.lib" sqlite3_analyzer.exe
           
    6. After your executable is built, you can verify that it does not diff --git a/manifest b/manifest index cdce6cf63e..21bb077fd9 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Improvements\sto\sMakefile.msc:\s(1)\sAttempt\sto\sfind\ssane\svalues\sfor\skey\nvariables\sbased\son\sthe\svalue\sof\sTCLDIR.\s\s(2)\sDefault\sto\sTCLVERSION\s90\sinstead\nof\s86.\s\s(3)\sAdd\sthe\s"tcl-env"\starget\sthat\sshows\sthe\svalues\sof\skey\svariables\nassociated\swith\sTCL. -D 2024-10-09T20:05:26.424 +C Adjustments\sto\sthe\sMakefile.msc\sto\sget\sstatic\sbuilds\sof\ssqlite3_analyzer.exe\nworking\swith\sTCL9.\s\sUpdate\sthe\scompile-for-windows.md\sdocument\sfor\sTCL9. +D 2024-10-10T09:59:06.503 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F Makefile.in e504a9f003b2de41447b81296d9a6988a67ffabc34fa396b60ffd89b0c63a7bf F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc c6abbbe25cef6bf1eb255884cd9137b6afa4f850f4bdc78ba718f4035c35000b +F Makefile.msc 34801b42a51a9c3cb2c98fb83e3e3a08c1a304b73e7a1ef30846fe6848c1ffd7 F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -39,7 +39,7 @@ F configure 135e050689ea244477582e6d77cc7867dfcfe6e0f82e3eab3e47655a67035f8f x F configure.ac aca8ebf47b7644c473e11e599ea986eeb23860a8732a8812039ad961ef52a713 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd -F doc/compile-for-windows.md 4d4bfafda42a7a33f166d23aed4db1bb4ea1e5751595a5cced2bad349fd14652 +F doc/compile-for-windows.md 8402957e1ba3ddae2d37cb44fab7fca7e099b3f2fcf33bced3a16188a00b955e F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347bb123ce1ea4f F doc/jsonb.md 5fab4b8613aa9153fbeb6259297bd4697988af8b3d23900deba588fa7841456b F doc/lemon.html 8b266ff711d2ec7f867c3dca37634963f48a630329908cc282beebfa8c708706 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e8f719d13fbcbaf1b52b421d7af59759b1b4692d4010a68d5865dfeaf3cf8cb0 -R 6adacab87cffb89c84a1bbdbcff4792d +P 6b7a789a416fb62a532882d10e41c7048a6805f5fbbc008f36f9802be45d9ebb +R c9f14e0cb6269b0c33c6b11339c3cd13 U drh -Z f45d0adbf7e7e6e176374a9b7492aa02 +Z 3a6d1e8e76a2ebf4de7346b7f2c5b6fe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 783841eca9..e5bc20be19 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6b7a789a416fb62a532882d10e41c7048a6805f5fbbc008f36f9802be45d9ebb +df16d07d8db042cdb1dc6bb9a00a0265ba791a615d74f9152d0b3344e618fe93 From 7b179a309802dc588af2dc028f570f388f482734 Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 10 Oct 2024 10:33:31 +0000 Subject: [PATCH 51/77] For compatibility, allow the TCL interfact to continue working with TCL 8.5. FossilOrigin-Name: 69346e9d4704e8fd82cbb3359913191e05cb38ee591baf97dcfe321db0ea085e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/tclsqlite.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 21bb077fd9..930fe64197 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjustments\sto\sthe\sMakefile.msc\sto\sget\sstatic\sbuilds\sof\ssqlite3_analyzer.exe\nworking\swith\sTCL9.\s\sUpdate\sthe\scompile-for-windows.md\sdocument\sfor\sTCL9. -D 2024-10-10T09:59:06.503 +C For\scompatibility,\sallow\sthe\sTCL\sinterfact\sto\scontinue\sworking\swith\sTCL\s8.5. +D 2024-10-10T10:33:31.177 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -778,7 +778,7 @@ F src/sqliteInt.h ad02397dc4d22b77f9a331412d46e4c1e49459dd386fba8373fa148998e1e7 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c b3fea4c31c22e7b545681221a53eba9a358602706e04e066f88e2c63d99fe12f +F src/tclsqlite.c e4bd0a252e7f73f338b98b8a0d8fe1017cfd0e171841cefc7776307b7304424d F src/tclsqlite.h c6af51f31a2b2172d674608763a4b98fdf5cd587e4025053e546fb8077757262 F src/test1.c 8bf8b74145b768f42386787f93f6d6dad7bc400a4ee2d50e4ad5a06a20a97ef1 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6b7a789a416fb62a532882d10e41c7048a6805f5fbbc008f36f9802be45d9ebb -R c9f14e0cb6269b0c33c6b11339c3cd13 +P df16d07d8db042cdb1dc6bb9a00a0265ba791a615d74f9152d0b3344e618fe93 +R 1604dcef7855fc28056bdb569bc407b0 U drh -Z 3a6d1e8e76a2ebf4de7346b7f2c5b6fe +Z 991f53deff2137d0600e8c28c3576019 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e5bc20be19..2fe0cc0654 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -df16d07d8db042cdb1dc6bb9a00a0265ba791a615d74f9152d0b3344e618fe93 +69346e9d4704e8fd82cbb3359913191e05cb38ee591baf97dcfe321db0ea085e diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 3ff14a2f9a..1fd214fe88 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -3981,7 +3981,7 @@ static int SQLITE_TCLAPI DbMain( ** The EXTERN macros are required by TCL in order to work on windows. */ EXTERN int Sqlite3_Init(Tcl_Interp *interp){ - int rc = Tcl_InitStubs(interp, "8.6-", 0) ? TCL_OK : TCL_ERROR; + int rc = Tcl_InitStubs(interp, "8.5-", 0) ? TCL_OK : TCL_ERROR; if( rc==TCL_OK ){ Tcl_CreateObjCommand(interp, "sqlite3", (Tcl_ObjCmdProc*)DbMain, 0, 0); #ifndef SQLITE_3_SUFFIX_ONLY From 0b453b3b3379f34527c957c6e1f7631a887c7340 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 11 Oct 2024 14:02:48 +0000 Subject: [PATCH 52/77] Avoid undesirable NL to CRLF translation when doing binary output to the Windows console. FossilOrigin-Name: d25bdce36abed95524ad058a277aba7bb17270e7ff1476474713dbc29742c762 --- ext/misc/sqlite3_stdio.c | 84 ++++++++++++++++++++++++++++++++++++---- manifest | 15 ++++--- manifest.uuid | 2 +- src/shell.c.in | 17 ++++---- 4 files changed, 92 insertions(+), 26 deletions(-) diff --git a/ext/misc/sqlite3_stdio.c b/ext/misc/sqlite3_stdio.c index 46f12dff36..393815522b 100644 --- a/ext/misc/sqlite3_stdio.c +++ b/ext/misc/sqlite3_stdio.c @@ -67,6 +67,31 @@ # define IsConsole(fd) 1 #endif +/* +** Global variables determine if simulated O_BINARY mode is to be +** used for stdout or other, respectively. Simulated O_BINARY mode +** means the mode is usually O_BINARY, but switches to O_U8TEXT for +** unicode characters U+0080 or greater (any character that has a +** multi-byte representation in UTF-8). This is the only way we +** have found to render Unicode characters on a Windows console while +** at the same time avoiding undesirable \n to \r\n translation. +*/ +static int simBinaryStdout = 0; +static int simBinaryOther = 0; + + +/* +** Determine if simulated binary mode should be used for output to fd +*/ +static int UseBinaryWText(FILE *fd){ + if( fd==stdout || fd==stderr ){ + return simBinaryStdout; + }else{ + return simBinaryOther; + } +} + + /* ** Work-alike for the fopen() routine from the standard C library. */ @@ -88,6 +113,7 @@ FILE *sqlite3_fopen(const char *zFilename, const char *zMode){ } free(b1); free(b2); + simBinaryOther = 0; return fp; } @@ -143,13 +169,53 @@ char *sqlite3_fgets(char *buf, int sz, FILE *in){ } } +/* +** Send ASCII text as O_BINARY. But for Unicode characters U+0080 and +** greater, switch to O_U8TEXT. +*/ +static void piecemealOutput(wchar_t *b1, int sz, FILE *out){ + int i; + wchar_t c; + while( sz>0 ){ + for(i=0; i=0x80; i++){} + if( i>0 ){ + c = b1[i]; + b1[i] = 0; + fflush(out); + _setmode(_fileno(out), _O_U8TEXT); + fputws(b1, out); + fflush(out); + b1 += i; + b1[0] = c; + sz -= i; + }else{ + fflush(out); + _setmode(_fileno(out), _O_TEXT); + _setmode(_fileno(out), _O_BINARY); + fwrite(&b1[0], 1, 1, out); + for(i=1; ipLog); if( cli_strcmp(zFile,"on")==0 ) zFile = "stdout"; - p->pLog = output_file_open(zFile, 0); + p->pLog = output_file_open(zFile); } }else @@ -9918,7 +9918,6 @@ static int do_meta_command(char *zLine, ShellState *p){ || (c=='w' && n==3 && cli_strcmp(azArg[0],"www")==0) ){ char *zFile = 0; - int bTxtMode = 0; int i; int eMode = 0; int bOnce = 0; /* 0: .output, 1: .once, 2: .excel/.www */ @@ -10000,11 +9999,9 @@ static int do_meta_command(char *zLine, ShellState *p){ /* web-browser mode. */ newTempFile(p, "html"); if( !bPlain ) p->mode = MODE_Www; - bTxtMode = 1; }else{ /* text editor mode */ newTempFile(p, "txt"); - bTxtMode = 1; } sqlite3_free(zFile); zFile = sqlite3_mprintf("%s", p->zTempFile); @@ -10028,7 +10025,7 @@ static int do_meta_command(char *zLine, ShellState *p){ } #endif }else{ - FILE *pfFile = output_file_open(zFile, bTxtMode); + FILE *pfFile = output_file_open(zFile); if( pfFile==0 ){ if( cli_strcmp(zFile,"off")!=0 ){ sqlite3_fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile); @@ -10036,13 +10033,13 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = 1; } else { output_redir(p, pfFile); + if( zBom ) sqlite3_fputs(zBom, pfFile); if( bPlain && eMode=='w' ){ sqlite3_fputs( "\n\n\n", pfFile ); } - if( zBom ) sqlite3_fputs(zBom, pfFile); sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", zFile); } } @@ -11225,7 +11222,7 @@ static int do_meta_command(char *zLine, ShellState *p){ /* Begin redirecting output to the file "testcase-out.txt" */ if( c=='t' && cli_strcmp(azArg[0],"testcase")==0 ){ output_reset(p); - p->out = output_file_open("testcase-out.txt", 0); + p->out = output_file_open("testcase-out.txt"); if( p->out==0 ){ eputz("Error: cannot open 'testcase-out.txt'\n"); } @@ -11729,7 +11726,7 @@ static int do_meta_command(char *zLine, ShellState *p){ } }else{ output_file_close(p->traceOut); - p->traceOut = output_file_open(z, 0); + p->traceOut = output_file_open(z); } } if( p->traceOut==0 ){ From b23cce9a16a6b90fed2bd3e189fe4e9f2ff63b68 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 11 Oct 2024 14:30:58 +0000 Subject: [PATCH 53/77] Fix the CSV output mode in the CLI such that the line ending is NL by default but goes to CRLF if ".crnl on" is set. Make the .crnl command available on non-Windows builds. Update the .crnl command such that if it has no arguments it shows the current setting. FossilOrigin-Name: da750e39df7bf42330d8c8b266300da07247c9619895861b4cff4be7c94db7cf --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 40 +++++++++++++++++++--------------------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/manifest b/manifest index f410abbe68..a632e75473 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sundesirable\sNL\sto\sCRLF\stranslation\swhen\sdoing\sbinary\soutput\sto\sthe\nWindows\sconsole. -D 2024-10-11T14:02:48.369 +C Fix\sthe\sCSV\soutput\smode\sin\sthe\sCLI\ssuch\sthat\sthe\sline\sending\sis\sNL\sby\sdefault\nbut\sgoes\sto\sCRLF\sif\s".crnl\son"\sis\sset.\s\sMake\sthe\s.crnl\scommand\savailable\son\nnon-Windows\sbuilds.\s\sUpdate\sthe\s.crnl\scommand\ssuch\sthat\sif\sit\shas\sno\sarguments\nit\sshows\sthe\scurrent\ssetting. +D 2024-10-11T14:30:58.752 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -770,7 +770,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in 0701ac81f16d1b23254f141118ea064c33c153d7099d3bf7db650ce45eead689 +F src/shell.c.in 46fa7b8be665d17c9593fbf40299ee799e6a932a9b59e7f2e5c686f574136cae F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bcfae7183e92ce37717852bae5b1dd526903fa8429fb6f738c2147d4e5231642 -R ce21189a126f3d2c64453710bc34a276 +P d25bdce36abed95524ad058a277aba7bb17270e7ff1476474713dbc29742c762 +R 1814f31c76f5b99a165395372f50c6cf U drh -Z 1e590b34c76a965a6a2ae1e5a7b7871c +Z d664c82762a3265052efdefacef5a18c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e116a9db35..77aea442ee 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d25bdce36abed95524ad058a277aba7bb17270e7ff1476474713dbc29742c762 +da750e39df7bf42330d8c8b266300da07247c9619895861b4cff4be7c94db7cf diff --git a/src/shell.c.in b/src/shell.c.in index 5a90fec7e0..ec32acca78 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1629,13 +1629,7 @@ static const char *modeDescr[] = { #define SEP_Tab "\t" #define SEP_Space " " #define SEP_Comma "," -#ifdef SQLITE_U8TEXT_ONLY - /* With the SQLITE_U8TEXT_ONLY option, the output will always be in - ** text mode. The \r will be inserted automatically. */ -# define SEP_CrLf "\n" -#else -# define SEP_CrLf "\r\n" -#endif +#define SEP_CrLf "\n" /* Use ".crnl on" to get \r\n line endings */ #define SEP_Unit "\x1F" #define SEP_Record "\x1E" @@ -2801,13 +2795,21 @@ static int shell_callback( for(i=0; i<nArg; i++){ output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1); } - sqlite3_fputs(p->rowSeparator, p->out); + if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){ + sqlite3_fputs("\r\n", p->out); + }else{ + sqlite3_fputs(p->rowSeparator, p->out); + } } if( nArg>0 ){ for(i=0; i<nArg; i++){ output_csv(p, azArg[i], i<nArg-1); } - sqlite3_fputs(p->rowSeparator, p->out); + if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){ + sqlite3_fputs("\r\n", p->out); + }else{ + sqlite3_fputs(p->rowSeparator, p->out); + } } setCrnlMode(p); break; @@ -4952,9 +4954,7 @@ static const char *(azHelp[]) = { ".clone NEWDB Clone data into NEWDB from the existing database", #endif ".connection [close] [#] Open or close an auxiliary database connection", -#if defined(_WIN32) - ".crnl on|off Translate \\n to \\r\\n. Default ON", -#endif + ".crnl on|off Translate \\n to \\r\\n sometimes. Default OFF", ".databases List names and files of attached databases", ".dbconfig ?op? ?val? List or change sqlite3_db_config() options", #if SQLITE_SHELL_HAVE_RECOVER @@ -8573,17 +8573,13 @@ static int do_meta_command(char *zLine, ShellState *p){ }else if( c=='c' && n==4 && cli_strncmp(azArg[0], "crnl", n)==0 ){ -#if !defined(_WIN32) - sqlite3_fputs("The \".crnl\" command is disable in this build.\n", p->out); -#else if( nArg==2 ){ p->crnlMode = booleanValue(azArg[1]); setCrnlMode(p); }else{ - eputz("Usage: .crnl on|off\n"); - rc = 1; + sqlite3_fprintf(stderr, "crnl is currently %s\n", + p->crnlMode ? "ON" : "OFF"); } -#endif }else if( c=='d' && n>1 && cli_strncmp(azArg[0], "databases", n)==0 ){ @@ -12620,9 +12616,11 @@ static void main_init(ShellState *data) { /* By default, come up in O_BINARY mode. That way, the default output is ** the same for Windows and non-Windows systems. Use the ".crnl on" ** command to change into O_TEXT mode to do automatic NL-to-CRLF - ** conversions on output for Windows. Windows console output is not - ** subject to the crnlMode setting and is unaffected either way. This - ** setting only affects output going into a file or pipe. */ + ** conversions on output for Windows. + ** + ** End-of-line marks on CVS output is CRLF when in .crnl is on and + ** NL when .crnl is off. + */ data->crnlMode = 0; } From 17408fbbd85e970be0aeb42c0bf87e6dcb486059 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 11 Oct 2024 17:02:37 +0000 Subject: [PATCH 54/77] An improved method for statically linking sqlite3_analyzer.exe using Tcl9. Enable wildcard expansion of arguments to testfiture on Windows. FossilOrigin-Name: 9b87ea219bce5689a69efac31063b9b11928e59124c0d36194715ff7faa5129d --- Makefile.msc | 15 +++++++++++++++ doc/compile-for-windows.md | 6 +++--- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/tclsqlite.c | 14 ++++++++++++++ test/shell1.test | 5 ++++- 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 529e6995c0..0977a49351 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -66,6 +66,14 @@ USE_STDCALL = 0 USE_SEH = 1 !ENDIF +# Use STATICALLY_LINK_TCL=1 to statically link against TCL +# +!IFNDEF STATICALLY_LINK_TCL +STATICALLY_LINK_TCL = 0 +!ELSEIF $(STATICALLY_LINK_TCL)!=0 +CCOPTS = $(CCOPTS) -DSTATIC_BUILD +!ENDIF + # Set this non-0 to have the shell executable link against the core dynamic # link library. # @@ -929,6 +937,9 @@ TCC = $(TCC) /fsanitize=address # prior to running nmake in order to match the actual installed location and # version on this machine. # +!IF $(STATICALLY_LINK_TCL)!=0 +TCLSUFFIX = s +!ENDIF !IFNDEF TCLSUFFIX TCLSUFFIX = !ENDIF @@ -963,7 +974,11 @@ LIBTCL = tcl$(TCLVERSION)$(TCLSUFFIX).lib !ENDIF !IFNDEF TCLLIBS +!IF $(STATICALLY_LINK_TCL)!=0 TCLLIBS = /NODEFAULTLIB:libucrt.lib netapi32.lib user32.lib ucrt.lib +!ELSE +TCLLIBS = +!ENDIF !ENDIF !IFNDEF LIBTCLSTUB diff --git a/doc/compile-for-windows.md b/doc/compile-for-windows.md index 18189f5376..acc7335618 100644 --- a/doc/compile-for-windows.md +++ b/doc/compile-for-windows.md @@ -148,15 +148,15 @@ statically linked so that it does not depend on separate DLL: "`C:\Tcl\lib`" for 64-bit builds.) 5. CD into your SQLite source code directory and build the desired - utility program, but add the following extra arguments to the + utility program, but add the following extra argument to the nmake command line: <blockquote><pre> - CCOPTS="-DSTATIC_BUILD" LIBTCL="tcl90s.lib" + STATICALLY_LINK_TCL=1 </pre></blockquote> <p>So, for example, to build a statically linked version of sqlite3_analyzer.exe, you might type: <blockquote><pre> - nmake /f Makefile.msc CCOPTS="-DSTATIC_BUILD" LIBTCL="tcl90s.lib" sqlite3_analyzer.exe + nmake /f Makefile.msc STATICALLY_LINK_TCL=1 sqlite3_analyzer.exe </pre></blockquote> 6. After your executable is built, you can verify that it does not diff --git a/manifest b/manifest index a632e75473..dd462bbb45 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Fix\sthe\sCSV\soutput\smode\sin\sthe\sCLI\ssuch\sthat\sthe\sline\sending\sis\sNL\sby\sdefault\nbut\sgoes\sto\sCRLF\sif\s".crnl\son"\sis\sset.\s\sMake\sthe\s.crnl\scommand\savailable\son\nnon-Windows\sbuilds.\s\sUpdate\sthe\s.crnl\scommand\ssuch\sthat\sif\sit\shas\sno\sarguments\nit\sshows\sthe\scurrent\ssetting. -D 2024-10-11T14:30:58.752 +C An\simproved\smethod\sfor\sstatically\slinking\ssqlite3_analyzer.exe\susing\sTcl9.\nEnable\swildcard\sexpansion\sof\sarguments\sto\stestfiture\son\sWindows. +D 2024-10-11T17:02:37.285 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F Makefile.in e504a9f003b2de41447b81296d9a6988a67ffabc34fa396b60ffd89b0c63a7bf F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 34801b42a51a9c3cb2c98fb83e3e3a08c1a304b73e7a1ef30846fe6848c1ffd7 +F Makefile.msc 829ad1543511bd2953b0f9ac41e494daf96e25b4ec2e00c2abe76a08d7b46b3d F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -39,7 +39,7 @@ F configure 135e050689ea244477582e6d77cc7867dfcfe6e0f82e3eab3e47655a67035f8f x F configure.ac aca8ebf47b7644c473e11e599ea986eeb23860a8732a8812039ad961ef52a713 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd -F doc/compile-for-windows.md 8402957e1ba3ddae2d37cb44fab7fca7e099b3f2fcf33bced3a16188a00b955e +F doc/compile-for-windows.md 8e00693196087e3564a9a2bce642fa39febc1c901212832fbe0637681dada3db F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347bb123ce1ea4f F doc/jsonb.md 5fab4b8613aa9153fbeb6259297bd4697988af8b3d23900deba588fa7841456b F doc/lemon.html 8b266ff711d2ec7f867c3dca37634963f48a630329908cc282beebfa8c708706 @@ -778,7 +778,7 @@ F src/sqliteInt.h ad02397dc4d22b77f9a331412d46e4c1e49459dd386fba8373fa148998e1e7 F src/sqliteLimit.h 6878ab64bdeb8c24a1d762d45635e34b96da21132179023338c93f820eee6728 F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c e4bd0a252e7f73f338b98b8a0d8fe1017cfd0e171841cefc7776307b7304424d +F src/tclsqlite.c e2b752dd08034c834e3639afa3300940d6e847fcd94207e1f2f1b83ce08b87be F src/tclsqlite.h c6af51f31a2b2172d674608763a4b98fdf5cd587e4025053e546fb8077757262 F src/test1.c 8bf8b74145b768f42386787f93f6d6dad7bc400a4ee2d50e4ad5a06a20a97ef1 F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3 @@ -1629,7 +1629,7 @@ F test/sharedA.test 64bdd21216dda2c6a3bd3475348ccdc108160f34682c97f2f51c19fc0e21 F test/sharedB.test 1a84863d7a2204e0d42f2e1606577c5e92e4473fa37ea0f5bdf829e4bf8ee707 F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test b02d628494fa284cdb2b7b2fecdadea96913796afd623f340a79d68f055dcb7e +F test/shell1.test 5d84e415adf7cc4edd5913c4f23c761104ff135b9c190fcf7b430a4cbca6cb65 F test/shell2.test 01a01f76ed98088ce598794fbf5b359e148271541a8ddbf79d21cc353cc67a24 F test/shell3.test db1953a8e59d08e9240b7cc5948878e184f7eb2623591587f8fd1f1a5bd536d8 F test/shell4.test 522fdc628c55eff697b061504fb0a9e4e6dfc5d9087a633ab0f3dd11bcc4f807 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d25bdce36abed95524ad058a277aba7bb17270e7ff1476474713dbc29742c762 -R 1814f31c76f5b99a165395372f50c6cf +P da750e39df7bf42330d8c8b266300da07247c9619895861b4cff4be7c94db7cf +R d5a71ea2b4b6f4e15db36a5243995451 U drh -Z d664c82762a3265052efdefacef5a18c +Z c56b353e7027413971154cd95e000d9f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 77aea442ee..cf20709695 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -da750e39df7bf42330d8c8b266300da07247c9619895861b4cff4be7c94db7cf +9b87ea219bce5689a69efac31063b9b11928e59124c0d36194715ff7faa5129d diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 1fd214fe88..9ed6669515 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -4037,6 +4037,20 @@ EXTERN int sqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp);} static const char *tclsh_main_loop(void){ static const char zMainloop[] = "if {[llength $argv]>=1} {\n" +#ifdef WIN32 + "set new [list]\n" + "foreach arg $argv {\n" + "if {[file exists $arg]} {\n" + "lappend new $arg\n" + "} else {\n" + "foreach match [lsort [glob -nocomplain $arg]] {\n" + "lappend new $match\n" + "}\n" + "}\n" + "}\n" + "set argv $new\n" + "unset new\n" +#endif "set argv0 [lindex $argv 0]\n" "set argv [lrange $argv 1 end]\n" "source $argv0\n" diff --git a/test/shell1.test b/test/shell1.test index b4883e3521..a272295f55 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -1063,7 +1063,10 @@ do_test shell1-5.0 { continue } # Tcl 8.7 maps 0x80 through 0x9f into valid UTF8. So skip those tests. - if {$i>=0x80 && ($i<=0x9F || $tcl_version>=9.0)} continue + if {$i>=0x80} { + if {$i<=0x9F || $tcl_version>=9.0} continue + if {$tcl_platform(platform)=="windows"} continue + } if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue if {$i>=0xE0 && $i<=0xEF && $tcl_platform(os)=="Linux"} continue set hex [format %02X $i] From ed3cf6ef37b7a736d4cd6119af92f51aa7e97796 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 11 Oct 2024 17:43:47 +0000 Subject: [PATCH 55/77] Update the autoconf Makefile.msc FossilOrigin-Name: 911ab3299771a607a135f0bcde3057b0ed337870362396bf72506210fdff729e --- autoconf/Makefile.msc | 8 ++++++++ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/autoconf/Makefile.msc b/autoconf/Makefile.msc index f8a65e90cc..efebc9931a 100644 --- a/autoconf/Makefile.msc +++ b/autoconf/Makefile.msc @@ -66,6 +66,14 @@ USE_STDCALL = 0 USE_SEH = 1 !ENDIF +# Use STATICALLY_LINK_TCL=1 to statically link against TCL +# +!IFNDEF STATICALLY_LINK_TCL +STATICALLY_LINK_TCL = 0 +!ELSEIF $(STATICALLY_LINK_TCL)!=0 +CCOPTS = $(CCOPTS) -DSTATIC_BUILD +!ENDIF + # Set this non-0 to have the shell executable link against the core dynamic # link library. # diff --git a/manifest b/manifest index dd462bbb45..6a15812298 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C An\simproved\smethod\sfor\sstatically\slinking\ssqlite3_analyzer.exe\susing\sTcl9.\nEnable\swildcard\sexpansion\sof\sarguments\sto\stestfiture\son\sWindows. -D 2024-10-11T17:02:37.285 +C Update\sthe\sautoconf\sMakefile.msc +D 2024-10-11T17:43:47.578 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -17,7 +17,7 @@ F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac -F autoconf/Makefile.msc 2aced6442addab13ed115696eba28d9ed29caa3dd604a31392c2c7a5da301492 +F autoconf/Makefile.msc 0a1fdef1f2c618815cf7c82c817a7369c1e07b3cfed490803db16fb43326d506 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 42cfd21d0b19dc7d5d85fb5c405c5f3c6a4c923021c39128f6ba685355d8fd56 F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d5893b277 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P da750e39df7bf42330d8c8b266300da07247c9619895861b4cff4be7c94db7cf -R d5a71ea2b4b6f4e15db36a5243995451 +P 9b87ea219bce5689a69efac31063b9b11928e59124c0d36194715ff7faa5129d +R 415017f225f4ead5616580cc6f510f56 U drh -Z c56b353e7027413971154cd95e000d9f +Z f7c4ce89fa70bec4a747e36d57c54025 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cf20709695..cca1a8ebc2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b87ea219bce5689a69efac31063b9b11928e59124c0d36194715ff7faa5129d +911ab3299771a607a135f0bcde3057b0ed337870362396bf72506210fdff729e From 4723539637b25794d7a3db6dc927f1b618c48cf8 Mon Sep 17 00:00:00 2001 From: dan <Dan Kennedy> Date: Fri, 11 Oct 2024 18:59:29 +0000 Subject: [PATCH 56/77] Avoid running some new tests in lock5.test with the inmemory_journal permutation. FossilOrigin-Name: 0b12e2e55c6d4b329f0a7629965f313f48b6d3918d36d3371953c56e0c688a28 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/lock5.test | 28 +++++++++++++++------------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 6a15812298..e1e55ddb14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sautoconf\sMakefile.msc -D 2024-10-11T17:43:47.578 +C Avoid\srunning\ssome\snew\stests\sin\slock5.test\swith\sthe\sinmemory_journal\spermutation. +D 2024-10-11T18:59:29.579 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1405,7 +1405,7 @@ F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff F test/lock3.test f271375930711ae044080f4fe6d6eda930870d00 F test/lock4.test 27143363eda1622f03c133efc8db808fc331afd973486cb571ea71cd717d37b8 -F test/lock5.test 51e9e2e8d5aed4ec470be19dfc0d630388a7444a8fc812ec8d08e46469a15726 +F test/lock5.test 583cae05992af0f66607286917f7d5f8aed3b6053c52df5994efb98f2a8fdbaf F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5 F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431 F test/lock_common.tcl 2f3f7f2e9637f93ccf609df48ef5b27a50278b6b1cd752b445d52262e5841413 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9b87ea219bce5689a69efac31063b9b11928e59124c0d36194715ff7faa5129d -R 415017f225f4ead5616580cc6f510f56 -U drh -Z f7c4ce89fa70bec4a747e36d57c54025 +P 911ab3299771a607a135f0bcde3057b0ed337870362396bf72506210fdff729e +R 390e9a5d3a3b1b4ebd0cb5dbdeac1eef +U dan +Z c3b55c0485ea7f9cce6371c8af190d47 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index cca1a8ebc2..afb5b7aca9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -911ab3299771a607a135f0bcde3057b0ed337870362396bf72506210fdff729e +0b12e2e55c6d4b329f0a7629965f313f48b6d3918d36d3371953c56e0c688a28 diff --git a/test/lock5.test b/test/lock5.test index b656aa2af4..8ebc277018 100644 --- a/test/lock5.test +++ b/test/lock5.test @@ -175,19 +175,21 @@ do_test lock5-flock.10 { } db2 } {1 {database is locked}} -do_test lock5-flock.11 { - forcecopy test.db test.db2 - forcecopy test.db-journal test.db2-journal - db2 close - sqlite3 db2 test.db2 -vfs unix-flock - catchsql { - SELECT * FROM t1 - } db2 -} {0 {1 2}} - -do_test lock5-flock.12 { - file exists test.db2-journal -} 0 +if {[permutation]!="inmemory_journal"} { + do_test lock5-flock.11 { + forcecopy test.db test.db2 + forcecopy test.db-journal test.db2-journal + db2 close + sqlite3 db2 test.db2 -vfs unix-flock + catchsql { + SELECT * FROM t1 + } db2 + } {0 {1 2}} + + do_test lock5-flock.12 { + file exists test.db2-journal + } 0 +} db close db2 close From b8d18f321c8cdfd8d9b0cf9a8e95ab4367882ac5 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 11 Oct 2024 19:08:45 +0000 Subject: [PATCH 57/77] Update the README for the TEA extension in the amalgamation tarball. FossilOrigin-Name: acc866c8f1b73fd57f434c5cb2576c2a7b9475a127febbcc27e8c714bbe29a8a --- autoconf/tea/{README => README.txt} | 17 +++++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 25 insertions(+), 8 deletions(-) rename autoconf/tea/{README => README.txt} (72%) diff --git a/autoconf/tea/README b/autoconf/tea/README.txt similarity index 72% rename from autoconf/tea/README rename to autoconf/tea/README.txt index 99dc8b8f03..e213afa3e4 100644 --- a/autoconf/tea/README +++ b/autoconf/tea/README.txt @@ -3,6 +3,23 @@ Architecture (TEA). For additional information on SQLite see http://www.sqlite.org/ +------------------------------------------------------------------- +Update 2024-10-11: + +A better way to build the TCL extension for SQLite is to use the +canonical source code tarball. For Unix: + + ./configure && make tclextension-install + +For Windows: + + nmake /f Makefile.msc tclextension-install + +This TEA builder is antiquated. It does not work for TCL9. The +SQLite devs don't know how to fix it. If you would like to help +fix it, contact us. +------------------------------------------------------------------ + UNIX BUILD ========== diff --git a/manifest b/manifest index e1e55ddb14..ab4412988e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\srunning\ssome\snew\stests\sin\slock5.test\swith\sthe\sinmemory_journal\spermutation. -D 2024-10-11T18:59:29.579 +C Update\sthe\sREADME\sfor\sthe\sTEA\sextension\sin\sthe\samalgamation\starball. +D 2024-10-11T19:08:45.077 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -22,7 +22,7 @@ F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 42cfd21d0b19dc7d5d85fb5c405c5f3c6a4c923021c39128f6ba685355d8fd56 F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d5893b277 F autoconf/tea/Makefile.in 106a96f2f745d41a0f6193f1de98d7355830b65d45032c18cd7c90295ec24196 -F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873 +F autoconf/tea/README.txt be9392c4c5b417376847fa48b129a2ef7963e32a5a49ee42f70cf78f6633ec0b w autoconf/tea/README F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 F autoconf/tea/configure.ac 0deb5d6c49c8119f75f436488219fc043127d72057af5dfba2c9ce096a5734bc F autoconf/tea/doc/sqlite3.n e1fe45d4f5286ee3d0ccc877aca2a0def488e9bb @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 911ab3299771a607a135f0bcde3057b0ed337870362396bf72506210fdff729e -R 390e9a5d3a3b1b4ebd0cb5dbdeac1eef -U dan -Z c3b55c0485ea7f9cce6371c8af190d47 +P 0b12e2e55c6d4b329f0a7629965f313f48b6d3918d36d3371953c56e0c688a28 +R 8170fa711e2545cebc17a8c24d23cbab +U drh +Z bceed50e054186e2b2112bc60382b7f2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index afb5b7aca9..93dfaaee71 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0b12e2e55c6d4b329f0a7629965f313f48b6d3918d36d3371953c56e0c688a28 +acc866c8f1b73fd57f434c5cb2576c2a7b9475a127febbcc27e8c714bbe29a8a From 2623a19ab0c6e9714e60de73020e1c1549a6bc0e Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 11 Oct 2024 19:13:02 +0000 Subject: [PATCH 58/77] Improved instructions in the TEA readme for building the TCL extension. FossilOrigin-Name: bf996f710212fbc0c0c67789e3f6f1a805e7b81e0265b312265ca7286e76d6f3 --- autoconf/tea/README.txt | 8 ++++++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/autoconf/tea/README.txt b/autoconf/tea/README.txt index e213afa3e4..ea7eb930f2 100644 --- a/autoconf/tea/README.txt +++ b/autoconf/tea/README.txt @@ -9,11 +9,15 @@ Update 2024-10-11: A better way to build the TCL extension for SQLite is to use the canonical source code tarball. For Unix: - ./configure && make tclextension-install + ./configure --with-tclsh=$(TCLSH) + make tclextension-install For Windows: - nmake /f Makefile.msc tclextension-install + nmake /f Makefile.msc tclextension-install TCLSH_CMD=$(TCLSH) + +In both of the above, replace $(TCLSH) with the full pathname of +of the tclsh that you want the SQLite extension to work with. This TEA builder is antiquated. It does not work for TCL9. The SQLite devs don't know how to fix it. If you would like to help diff --git a/manifest b/manifest index ab4412988e..64519ab42c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sREADME\sfor\sthe\sTEA\sextension\sin\sthe\samalgamation\starball. -D 2024-10-11T19:08:45.077 +C Improved\sinstructions\sin\sthe\sTEA\sreadme\sfor\sbuilding\sthe\sTCL\sextension. +D 2024-10-11T19:13:02.143 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -22,7 +22,7 @@ F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 42cfd21d0b19dc7d5d85fb5c405c5f3c6a4c923021c39128f6ba685355d8fd56 F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d5893b277 F autoconf/tea/Makefile.in 106a96f2f745d41a0f6193f1de98d7355830b65d45032c18cd7c90295ec24196 -F autoconf/tea/README.txt be9392c4c5b417376847fa48b129a2ef7963e32a5a49ee42f70cf78f6633ec0b w autoconf/tea/README +F autoconf/tea/README.txt 94fa2472d3ee4139ab24b364d99a70445d0a25531dac3ce03af2055d581f76b4 F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43 F autoconf/tea/configure.ac 0deb5d6c49c8119f75f436488219fc043127d72057af5dfba2c9ce096a5734bc F autoconf/tea/doc/sqlite3.n e1fe45d4f5286ee3d0ccc877aca2a0def488e9bb @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0b12e2e55c6d4b329f0a7629965f313f48b6d3918d36d3371953c56e0c688a28 -R 8170fa711e2545cebc17a8c24d23cbab +P acc866c8f1b73fd57f434c5cb2576c2a7b9475a127febbcc27e8c714bbe29a8a +R 712bf875e7c1c6a34f715ccf3b4ae9ee U drh -Z bceed50e054186e2b2112bc60382b7f2 +Z eb48fec82885f230614043e4219cfa3f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 93dfaaee71..b7b64d5732 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -acc866c8f1b73fd57f434c5cb2576c2a7b9475a127febbcc27e8c714bbe29a8a +bf996f710212fbc0c0c67789e3f6f1a805e7b81e0265b312265ca7286e76d6f3 From c85c102efeff34a6d33748e2338f90556fa37939 Mon Sep 17 00:00:00 2001 From: stephan <stephan@noemail.net> Date: Fri, 11 Oct 2024 19:18:44 +0000 Subject: [PATCH 59/77] Add two missing $(BEXE) suffixes, as reported in [forum:9ad28680d394afda | forum post 9ad28680d3]. Problem introduced by [1218a203483cecdc] being incomplete in where it added that suffix. FossilOrigin-Name: de9663c0aae92e457ddda48b751b32f205bfab29f60b055571e5f69b41ffd584 --- Makefile.in | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.in b/Makefile.in index 556b3600a1..c3f9c15c36 100644 --- a/Makefile.in +++ b/Makefile.in @@ -846,7 +846,7 @@ has_tclconfig: cp fts5.c fts5.h tsrc touch .target_source -sqlite3.c: .target_source $(TOP)/tool/mksqlite3c.tcl src-verify has_tclsh84 +sqlite3.c: .target_source $(TOP)/tool/mksqlite3c.tcl src-verify$(BEXE) has_tclsh84 $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl $(AMALGAMATION_LINE_MACROS) $(EXTRA_SRC) cp tsrc/sqlite3ext.h . cp $(TOP)/ext/session/sqlite3session.h . @@ -1648,7 +1648,7 @@ tidy: rm -f mptester$(TEXE) rbu$(TEXE) srcck1$(TEXE) rm -f fuzzershell$(TEXE) fuzzcheck$(TEXE) sqldiff$(TEXE) dbhash$(TEXE) rm -f threadtest5$(TEXE) - rm -f src-verify has_tclsh* + rm -f src-verify$(BEXE) has_tclsh* # Removes build products and test logs. Retains ./configure outputs. # diff --git a/manifest b/manifest index 64519ab42c..60d7c02ac1 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Improved\sinstructions\sin\sthe\sTEA\sreadme\sfor\sbuilding\sthe\sTCL\sextension. -D 2024-10-11T19:13:02.143 +C Add\stwo\smissing\s$(BEXE)\ssuffixes,\sas\sreported\sin\s[forum:9ad28680d394afda\s|\sforum\spost\s9ad28680d3].\sProblem\sintroduced\sby\s[1218a203483cecdc]\sbeing\sincomplete\sin\swhere\sit\sadded\sthat\ssuffix. +D 2024-10-11T19:18:44.588 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in e504a9f003b2de41447b81296d9a6988a67ffabc34fa396b60ffd89b0c63a7bf +F Makefile.in 209f43b9a484118a838d52d2b351f756bd8ec5cbc1181c6308f185ea364d4420 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 829ad1543511bd2953b0f9ac41e494daf96e25b4ec2e00c2abe76a08d7b46b3d F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P acc866c8f1b73fd57f434c5cb2576c2a7b9475a127febbcc27e8c714bbe29a8a -R 712bf875e7c1c6a34f715ccf3b4ae9ee -U drh -Z eb48fec82885f230614043e4219cfa3f +P bf996f710212fbc0c0c67789e3f6f1a805e7b81e0265b312265ca7286e76d6f3 +R c1596485fe08faef2532f3355a796371 +U stephan +Z c9b6b67c140ab2544242449edb704a7d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b7b64d5732..84d2d4ef9a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf996f710212fbc0c0c67789e3f6f1a805e7b81e0265b312265ca7286e76d6f3 +de9663c0aae92e457ddda48b751b32f205bfab29f60b055571e5f69b41ffd584 From ea7ea76a5937e257efe5cb4df89e23822e36a317 Mon Sep 17 00:00:00 2001 From: stephan <stephan@noemail.net> Date: Fri, 11 Oct 2024 19:22:32 +0000 Subject: [PATCH 60/77] Avoid a segfault when calling src-verify without any arguments. FossilOrigin-Name: c0c4e6f111b9b16538aad33e83f02f8d7835e952649f5cee610c068722bea4a4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/src-verify.c | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 60d7c02ac1..7256758673 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stwo\smissing\s$(BEXE)\ssuffixes,\sas\sreported\sin\s[forum:9ad28680d394afda\s|\sforum\spost\s9ad28680d3].\sProblem\sintroduced\sby\s[1218a203483cecdc]\sbeing\sincomplete\sin\swhere\sit\sadded\sthat\ssuffix. -D 2024-10-11T19:18:44.588 +C Avoid\sa\ssegfault\swhen\scalling\ssrc-verify\swithout\sany\sarguments. +D 2024-10-11T19:22:32.233 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2181,7 +2181,7 @@ F tool/sqlite3-rsync.c 7c78ba15afa0b929604adb91c94af8dbdf8cbe87be8a5cba5353af0e3 F tool/sqlite3_analyzer.c.in 348ba349bbdc93c9866439f9f935d7284866a2a4e6898bc906ae1204ade56918 F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 -F tool/src-verify.c 41c586dee84d0b190ad13e0282ed83d4a65ec9fefde9adf4943efdf6558eea7f +F tool/src-verify.c d00f93263aa2fa6ba0cba0106d95458e6effb94fdb5fc634f56834f90c05bbb4 F tool/srcck1.c 371de5363b70154012955544f86fdee8f6e5326f F tool/srctree-check.tcl c15f860a3c97d5f7b4c14b60392d9466af29dd006c4ef18127f502641e2977a8 F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 @@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bf996f710212fbc0c0c67789e3f6f1a805e7b81e0265b312265ca7286e76d6f3 -R c1596485fe08faef2532f3355a796371 +P de9663c0aae92e457ddda48b751b32f205bfab29f60b055571e5f69b41ffd584 +R 9bd2bb9818dfd0677d48239709bdf115 U stephan -Z c9b6b67c140ab2544242449edb704a7d +Z cd2bcf638ae2cec928818c120f6c2ee2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 84d2d4ef9a..18a34670b7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -de9663c0aae92e457ddda48b751b32f205bfab29f60b055571e5f69b41ffd584 +c0c4e6f111b9b16538aad33e83f02f8d7835e952649f5cee610c068722bea4a4 diff --git a/tool/src-verify.c b/tool/src-verify.c index 7629046564..0c7ed6f4c4 100644 --- a/tool/src-verify.c +++ b/tool/src-verify.c @@ -854,12 +854,16 @@ int main(int argc, char **argv){ xErr = errorMsgNH; continue; } + usage: fprintf(stderr, "Usage: %s DIRECTORY\n" " or: %s --sha1 FILE ...\n" " or: %s --sha3 FILE ...\n", argv[0], argv[0], argv[0]); return 1; } + if( !zDir ){ + goto usage; + } if( strlen(zDir)>1000 ){ fprintf(stderr, "Directory argument too big: [%s]\n", zDir); return 1; From 4dfc4dc2dfebea8a6f3a73f82977160833ecf156 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 11 Oct 2024 19:33:22 +0000 Subject: [PATCH 61/77] Add the doc/compile-for-unix.md document. FossilOrigin-Name: a3e16e478b03ccc12888eb5700c2e480a446957368f4b37ed322af2f4c9cd7c4 --- doc/compile-for-unix.md | 58 +++++++++++++++++++++++++++++++++++++++++ manifest | 13 ++++----- manifest.uuid | 2 +- 3 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 doc/compile-for-unix.md diff --git a/doc/compile-for-unix.md b/doc/compile-for-unix.md new file mode 100644 index 0000000000..f35e013420 --- /dev/null +++ b/doc/compile-for-unix.md @@ -0,0 +1,58 @@ +# Notes On Compiling SQLite On All Kinds Of Unix + +Here are step-by-step instructions on how to build SQLite from +canonical source on any modern machine that isn't Windows. These +notes are tested (on 2024-10-11) on Ubuntu and on MacOS, but they +are general and should work on most any modern unix platform. + + 1. Install a C-compiler. GCC or Clang both work fine. If you are + reading this document, you've probably already done that. + + 2. Install TCL9 development libraries. In this note, we'll do a + private install in the $HOME/local directory, but you can make + adjustments to install TCL9 wherever you like. + install the TCL development libraries in the "`c:\Tcl`" directory. + <p> + This document assumes you are working with <b>TCL version 9.0</b>. + <ol type="a"> + <li>Get the TCL source archive, perhaps from + [https://www.tcl.tk/software/tcltk/download.html](https://www.tcl.tk/software/tcltk/download.html) + or [https://sqlite.org/tmp/tcl9.0.0.tar.gz](https://sqlite.org/tmp/tcl9.0.0.tar.gz) + <li>Untar the source archive. CD into the "unix/" subfolder + of the source tree. + <li>Run: `mkdir $HOME/local` + <li>Run: `./configure --prefix=$HOME/local` + <li>Run: `make install` + </ol> + + 4. Download the SQLite source tree and unpack it. CD into the + toplevel directory of the source tree. + + 5. Run: `./configure --enable-all --with-tclsh=$HOME/local/bin/tclsh9.0` + + You do not need to use --with-tclsh if the tclsh you want to use is the + first one on your PATH. + + 6. Run the "`Makefile`" makefile with an appropriate target. + Examples: + <ul> + <li> `make sqlite3.c` + <li> `make sqlite3` + <li> `make sqldiff` + <li> `make sqlite3-rsync` + <li> `make tclextension-install` + <li> `make devtest` + <li> `make releasetest` + <li> `make sqlite3_analyzer` + </ul> + + It is not required that you run the "tclextension-install" target prior to + running tests. However, the tests will run more smoothly if you do. + The version of SQLite used for the TCL extension does *not* need to + correspond to the version of SQLite under test. So you can install the + SQLite TCL extension once, and then use it to test many different versions + of SQLite. + + + 7. For a debugging build of the CLI, where the ".treetrace" and ".wheretrace" + commands work, add the the --enable-debug argument to configure. diff --git a/manifest b/manifest index 7256758673..1eeecded52 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sa\ssegfault\swhen\scalling\ssrc-verify\swithout\sany\sarguments. -D 2024-10-11T19:22:32.233 +C Add\sthe\sdoc/compile-for-unix.md\sdocument. +D 2024-10-11T19:33:22.928 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -39,6 +39,7 @@ F configure 135e050689ea244477582e6d77cc7867dfcfe6e0f82e3eab3e47655a67035f8f x F configure.ac aca8ebf47b7644c473e11e599ea986eeb23860a8732a8812039ad961ef52a713 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd +F doc/compile-for-unix.md 37a3a7cfe32ed74b15d099f56e583f9e9df37b7109a8df880ff5e725424f8f17 F doc/compile-for-windows.md 8e00693196087e3564a9a2bce642fa39febc1c901212832fbe0637681dada3db F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347bb123ce1ea4f F doc/jsonb.md 5fab4b8613aa9153fbeb6259297bd4697988af8b3d23900deba588fa7841456b @@ -2216,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P de9663c0aae92e457ddda48b751b32f205bfab29f60b055571e5f69b41ffd584 -R 9bd2bb9818dfd0677d48239709bdf115 -U stephan -Z cd2bcf638ae2cec928818c120f6c2ee2 +P c0c4e6f111b9b16538aad33e83f02f8d7835e952649f5cee610c068722bea4a4 +R df2e0da3465ed81f9803a54efe976008 +U drh +Z d3c0161590f1e87174d191e4d2fda132 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 18a34670b7..75e38fdffa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c0c4e6f111b9b16538aad33e83f02f8d7835e952649f5cee610c068722bea4a4 +a3e16e478b03ccc12888eb5700c2e480a446957368f4b37ed322af2f4c9cd7c4 From 4859bc9a9ffdb9fa555a57db3593ccb08a0be983 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 11 Oct 2024 19:57:41 +0000 Subject: [PATCH 62/77] Update comments in ext/misc/sqlite3_stdio.c to reflect the latest enhancements. No changes to code. FossilOrigin-Name: 9621c3b527702b47799538e028f96945b5697752dbb56078aa7f114c72fd4e1a --- ext/misc/sqlite3_stdio.c | 28 +++++++++------------------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/ext/misc/sqlite3_stdio.c b/ext/misc/sqlite3_stdio.c index 393815522b..81fcfe23ff 100644 --- a/ext/misc/sqlite3_stdio.c +++ b/ext/misc/sqlite3_stdio.c @@ -31,27 +31,17 @@ #include <fcntl.h> /* -** If the SQLITE_U8TEXT_ONLY option is defined, then only use -** _O_U8TEXT, _O_WTEXT, and similar together with the UTF-16 -** interfaces to the Windows CRT. The use of ANSI-only routines -** like fputs() and ANSI modes like _O_TEXT and _O_BINARY is -** avoided. +** If the SQLITE_U8TEXT_ONLY option is defined, then use O_U8TEXT +** when appropriate on all output. ** -** The downside of using SQLITE_U8TEXT_ONLY is that it becomes -** impossible to output a bare newline character (0x0a) - that is, -** a newline that is not preceded by a carriage return (0x0d). -** And without that capability, sometimes the output will be slightly -** incorrect, as extra 0x0d characters will have been inserted where -** they do not belong. +** If the SQLITE_U8TEXT_STDIO option is defined, then use O_U8TEXT +** when appropriate when writing to stdout or stderr. Use O_BINARY for +** anything else. ** -** The SQLITE_U8TEXT_STDIO compile-time option is a compromise. -** It always enables _O_WTEXT or similar for stdin, stdout, stderr, -** but allows other streams to be _O_TEXT and/or O_BINARY. The -** SQLITE_U8TEXT_STDIO option has the same downside as SQLITE_U8TEXT_ONLY -** in that stray 0x0d characters might appear where they ought not, but -** at least with this option those characters only appear on standard -** I/O streams, and not on new streams that might be created by the -** application using sqlite3_fopen() or sqlite3_popen(). +** The default behavior, if neither of the above is defined is to +** use O_U8TEXT when writing to the Windows console (or anything +** else for which _isatty() returns true) and to use O_BINARY for +** all other output. */ #if defined(SQLITE_U8TEXT_ONLY) # define UseWtextForOutput(fd) 1 diff --git a/manifest b/manifest index 1eeecded52..9e10c216c6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sdoc/compile-for-unix.md\sdocument. -D 2024-10-11T19:33:22.928 +C Update\scomments\sin\sext/misc/sqlite3_stdio.c\sto\sreflect\sthe\slatest\senhancements.\nNo\schanges\sto\scode. +D 2024-10-11T19:57:41.456 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -428,7 +428,7 @@ F ext/misc/shathree.c 1821d90a0040c9accdbe3e3527d378d30569475d758aa70f6848924c0b F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bcc42ef3fd29429bc01a83e751332b8d4690e65d45008449bdffe7656371487f F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 -F ext/misc/sqlite3_stdio.c 74d86044cc45475cb0f7fa0d07e7bb5b3cc77c4339b084af7a4afe1b9cc008ef +F ext/misc/sqlite3_stdio.c 3ffe113d4d56ca05a2e2df0f79fede7d255ab40a1be3c5a5e8cdf74333031663 F ext/misc/sqlite3_stdio.h f05eaf5e0258f0573910324a789a9586fc360a57678c57a6d63cfaa2245b6176 F ext/misc/stmt.c b090086cd6bd6281c21271d38d576eeffe662f0e6b67536352ce32bbaa438321 F ext/misc/stmtrand.c 59cffa5d8e158943ff1ce078956d8e208e8c04e67307e8f249dece2436dcb7fc @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c0c4e6f111b9b16538aad33e83f02f8d7835e952649f5cee610c068722bea4a4 -R df2e0da3465ed81f9803a54efe976008 +P a3e16e478b03ccc12888eb5700c2e480a446957368f4b37ed322af2f4c9cd7c4 +R 1291abc09c87e338ea2cfa1281bb85ca U drh -Z d3c0161590f1e87174d191e4d2fda132 +Z 347c97452247d4e75e184990772431fa # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 75e38fdffa..b9e0ede130 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a3e16e478b03ccc12888eb5700c2e480a446957368f4b37ed322af2f4c9cd7c4 +9621c3b527702b47799538e028f96945b5697752dbb56078aa7f114c72fd4e1a From 589ce93e9efc754334ef1f38c04bef9d0cbac891 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 11 Oct 2024 23:31:37 +0000 Subject: [PATCH 63/77] Additional clarification in the comments to sqlite3_stdio.c. No changes to code. FossilOrigin-Name: 2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470 --- ext/misc/sqlite3_stdio.c | 14 +++++++++----- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ext/misc/sqlite3_stdio.c b/ext/misc/sqlite3_stdio.c index 81fcfe23ff..6c0f5afcaf 100644 --- a/ext/misc/sqlite3_stdio.c +++ b/ext/misc/sqlite3_stdio.c @@ -32,16 +32,20 @@ /* ** If the SQLITE_U8TEXT_ONLY option is defined, then use O_U8TEXT -** when appropriate on all output. +** when appropriate on all output. (Sometimes use O_BINARY when +** rendering ASCII text in cases where NL-to-CRLF expansion would +** not be correct.) ** ** If the SQLITE_U8TEXT_STDIO option is defined, then use O_U8TEXT -** when appropriate when writing to stdout or stderr. Use O_BINARY for -** anything else. +** when appropriate when writing to stdout or stderr. Use O_BINARY +** or O_TEXT (depending on things like the .mode and the .crnl setting +** in the CLI, or other context clues in other applications) for all +** other output channels. ** ** The default behavior, if neither of the above is defined is to ** use O_U8TEXT when writing to the Windows console (or anything -** else for which _isatty() returns true) and to use O_BINARY for -** all other output. +** else for which _isatty() returns true) and to use O_BINARY or O_TEXT +** for all other output channels. */ #if defined(SQLITE_U8TEXT_ONLY) # define UseWtextForOutput(fd) 1 diff --git a/manifest b/manifest index 9e10c216c6..3cf5a67ce9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\scomments\sin\sext/misc/sqlite3_stdio.c\sto\sreflect\sthe\slatest\senhancements.\nNo\schanges\sto\scode. -D 2024-10-11T19:57:41.456 +C Additional\sclarification\sin\sthe\scomments\sto\ssqlite3_stdio.c.\s\sNo\schanges\nto\scode. +D 2024-10-11T23:31:37.983 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -428,7 +428,7 @@ F ext/misc/shathree.c 1821d90a0040c9accdbe3e3527d378d30569475d758aa70f6848924c0b F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bcc42ef3fd29429bc01a83e751332b8d4690e65d45008449bdffe7656371487f F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 -F ext/misc/sqlite3_stdio.c 3ffe113d4d56ca05a2e2df0f79fede7d255ab40a1be3c5a5e8cdf74333031663 +F ext/misc/sqlite3_stdio.c 6857992f5e39992c9d44ad36230e28cbb0d630d6b0967c59e79ba13f2027ae49 F ext/misc/sqlite3_stdio.h f05eaf5e0258f0573910324a789a9586fc360a57678c57a6d63cfaa2245b6176 F ext/misc/stmt.c b090086cd6bd6281c21271d38d576eeffe662f0e6b67536352ce32bbaa438321 F ext/misc/stmtrand.c 59cffa5d8e158943ff1ce078956d8e208e8c04e67307e8f249dece2436dcb7fc @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a3e16e478b03ccc12888eb5700c2e480a446957368f4b37ed322af2f4c9cd7c4 -R 1291abc09c87e338ea2cfa1281bb85ca +P 9621c3b527702b47799538e028f96945b5697752dbb56078aa7f114c72fd4e1a +R 659759ae0159a7655f5b52c1145c8c1c U drh -Z 347c97452247d4e75e184990772431fa +Z 640899f5a3ac016602bbc301589aaa54 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b9e0ede130..f6d8769d34 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9621c3b527702b47799538e028f96945b5697752dbb56078aa7f114c72fd4e1a +2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470 From d5a780fddfa033de4848151bdbca1892bdfc607d Mon Sep 17 00:00:00 2001 From: dan <Dan Kennedy> Date: Sat, 12 Oct 2024 18:00:22 +0000 Subject: [PATCH 64/77] Allow the ".expert" command to analyze statements that use built-in virtual tables. FossilOrigin-Name: a201906cd3c85080f9b739c2d347c51348ebebd3dc9b647d33d8dcae4b6e5850 --- ext/expert/expert1.test | 72 ++++++++++++++++++++++++++++++ ext/expert/sqlite3expert.c | 89 ++++++++++++++++++++++++++++++++++---- manifest | 19 ++++---- manifest.uuid | 2 +- 4 files changed, 165 insertions(+), 17 deletions(-) diff --git a/ext/expert/expert1.test b/ext/expert/expert1.test index 239450442e..0bfdbcce1b 100644 --- a/ext/expert/expert1.test +++ b/ext/expert/expert1.test @@ -402,6 +402,19 @@ do_setup_rec_test $tn.19.0 { SCAN t1 USING COVERING INDEX t1_idx_01a7214e } +ifcapable fts5 { + do_setup_rec_test $tn.20.0 { + CREATE VIRTUAL TABLE ft USING fts5(a); + CREATE TABLE t1(x, y); + } { + SELECT * FROM ft, t1 WHERE a=x + } { + CREATE INDEX t1_idx_00000078 ON t1(x); + SCAN ft VIRTUAL TABLE INDEX 0: + SEARCH t1 USING INDEX t1_idx_00000078 (x=?) + } +} + } proc do_candidates_test {tn sql res} { @@ -507,4 +520,63 @@ do_candidates_test 6.1 { CREATE INDEX x1_idx_00000062 ON x1(b); } +#------------------------------------------------------------------------- +reset_db +do_execsql_test 7.0 { + CREATE VIRTUAL TABLE ft USING fts5(a); + CREATE TABLE t1(x, y); +} + +do_candidates_test 7.1 { + SELECT * FROM ft, t1 WHERE a=x +} { + CREATE INDEX t1_idx_00000078 ON t1(x); +} + +register_tcl_module db +proc vtab_command {method args} { + global G + + switch -- $method { + xConnect { + return "CREATE TABLE t1(a, b, c);" + } + + xBestIndex { + return [list] + } + + xFilter { + return [list sql "SELECT rowid, * FROM t0"] + } + } + + return {} +} + +do_execsql_test 7.2 { + CREATE TABLE t0(a, b, c); + INSERT INTO t0 VALUES(1, 2, 3), (11, 22, 33); + CREATE VIRTUAL TABLE t2 USING tcl(vtab_command); +} + +do_execsql_test 7.3 { + SELECT * FROM t2 +} { + 1 2 3 + 11 22 33 +} + +do_candidates_test 7.4 { + SELECT * FROM ft, t1 WHERE a=x +} { + CREATE INDEX t1_idx_00000078 ON t1(x); +} + +do_test 7.5 { + set expert [sqlite3_expert_new db] + list [catch { $expert sql "SELECT * FROM ft, t2 WHERE b=1" } msg] $msg +} {1 {no such table: t2}} +$expert destroy + finish_test diff --git a/ext/expert/sqlite3expert.c b/ext/expert/sqlite3expert.c index 3177339584..099a5235dd 100644 --- a/ext/expert/sqlite3expert.c +++ b/ext/expert/sqlite3expert.c @@ -1392,6 +1392,66 @@ static int idxProcessTriggers(sqlite3expert *p, char **pzErr){ return rc; } +/* +** This function tests if the schema of the main database of database handle +** db contains an object named zTab. Assuming no error occurs, output parameter +** (*pbContains) is set to true if zTab exists, or false if it does not. +** +** Or, if an error occurs, an SQLite error code is returned. The final value +** of (*pbContains) is undefined in this case. +*/ +static int expertDbContainsObject( + sqlite3 *db, + const char *zTab, + int *pbContains /* OUT: True if object exists */ +){ + const char *zSql = "SELECT 1 FROM sqlite_schema WHERE name = ?"; + sqlite3_stmt *pSql = 0; + int rc = SQLITE_OK; + int ret = 0; + + rc = sqlite3_prepare_v2(db, zSql, -1, &pSql, 0); + if( rc==SQLITE_OK ){ + sqlite3_bind_text(pSql, 1, zTab, -1, SQLITE_STATIC); + if( SQLITE_ROW==sqlite3_step(pSql) ){ + ret = 1; + } + rc = sqlite3_finalize(pSql); + } + + *pbContains = ret; + return rc; +} + +/* +** Execute SQL command zSql using database handle db. If no error occurs, +** set (*pzErr) to NULL and return SQLITE_OK. +** +** If an error does occur, return an SQLite error code and set (*pzErr) to +** point to a buffer containing an English language error message. Except, +** if the error message begins with "no such module:", then ignore the +** error and return as if the SQL statement had succeeded. +** +** This is used to copy as much of the database schema as possible while +** ignoring any errors related to missing virtual table modules. +*/ +static int expertSchemaSql(sqlite3 *db, const char *zSql, char **pzErr){ + int rc = SQLITE_OK; + char *zErr = 0; + + rc = sqlite3_exec(db, zSql, 0, 0, &zErr); + if( rc!=SQLITE_OK && zErr ){ + int nErr = STRLEN(zErr); + if( nErr>=15 && memcmp(zErr, "no such module:", 15)==0 ){ + sqlite3_free(zErr); + rc = SQLITE_OK; + zErr = 0; + } + } + + *pzErr = zErr; + return rc; +} static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){ int rc = idxRegisterVtab(p); @@ -1403,22 +1463,29 @@ static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){ ** 2) Create the equivalent virtual table in dbv. */ rc = idxPrepareStmt(p->db, &pSchema, pzErrmsg, - "SELECT type, name, sql, 1 FROM sqlite_schema " + "SELECT type, name, sql, 1, sql LIKE 'create virtual%' " + "FROM sqlite_schema " "WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%%' " " UNION ALL " - "SELECT type, name, sql, 2 FROM sqlite_schema " + "SELECT type, name, sql, 2, 0 FROM sqlite_schema " "WHERE type = 'trigger'" " AND tbl_name IN(SELECT name FROM sqlite_schema WHERE type = 'view') " - "ORDER BY 4, 1" + "ORDER BY 4, 5 DESC, 1" ); while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSchema) ){ const char *zType = (const char*)sqlite3_column_text(pSchema, 0); const char *zName = (const char*)sqlite3_column_text(pSchema, 1); const char *zSql = (const char*)sqlite3_column_text(pSchema, 2); + int bVirtual = sqlite3_column_int(pSchema, 4); + int bExists = 0; if( zType==0 || zName==0 ) continue; - if( zType[0]=='v' || zType[1]=='r' ){ - if( zSql ) rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg); + rc = expertDbContainsObject(p->dbv, zName, &bExists); + if( rc || bExists ) continue; + + if( zType[0]=='v' || zType[1]=='r' || bVirtual ){ + /* A view. Or a trigger on a view. */ + if( zSql ) rc = expertSchemaSql(p->dbv, zSql, pzErrmsg); }else{ IdxTable *pTab; rc = idxGetTableInfo(p->db, zName, &pTab, pzErrmsg); @@ -1957,12 +2024,18 @@ sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErrmsg){ if( rc==SQLITE_OK ){ sqlite3_stmt *pSql = 0; rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg, - "SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'" - " AND sql NOT LIKE 'CREATE VIRTUAL %%' ORDER BY rowid" + "SELECT sql, name " + " FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'" + " ORDER BY rowid" ); while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ const char *zSql = (const char*)sqlite3_column_text(pSql, 0); - if( zSql ) rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg); + const char *zName = (const char*)sqlite3_column_text(pSql, 1); + int bExists = 0; + rc = expertDbContainsObject(pNew->dbm, zName, &bExists); + if( rc==SQLITE_OK && zSql && bExists==0 ){ + rc = expertSchemaSql(pNew->dbm, zSql, pzErrmsg); + } } idxFinalize(&rc, pSql); } diff --git a/manifest b/manifest index 3cf5a67ce9..95c8dbbc32 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\sclarification\sin\sthe\scomments\sto\ssqlite3_stdio.c.\s\sNo\schanges\nto\scode. -D 2024-10-11T23:31:37.983 +C Allow\sthe\s".expert"\scommand\sto\sanalyze\sstatements\sthat\suse\sbuilt-in\svirtual\stables. +D 2024-10-12T18:00:22.050 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -58,8 +58,8 @@ F ext/consio/console_io.c d2b74afae8d301de2e8447b1045fcd33eb59df13bf581d906d99c7 F ext/consio/console_io.h b5ebe34aa15b357621ebbea3d3f2e2b24750d4280b5802516409e23947fd9ee5 F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 -F ext/expert/expert1.test b10f9e20f64102a015c0fcf54cb7b7680266b397e91d93cdad45f57857cdfba6 -F ext/expert/sqlite3expert.c df417a6d91873a74d35daa9259171647c23c6601415e938e8a71702703f3d677 +F ext/expert/expert1.test e049c507d33f7a7cf92ea6b15ac630cbc22598e387ec6749c2c5e1a5405e15a7 +F ext/expert/sqlite3expert.c b7cbbd7cc109c66ebdf6091467d790abb9d7c25ae3b822bb76388509641d37de F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b F ext/expert/test_expert.c b767b2039a0df707eb3147e86bcf68b252d8455d9a41774b1a836cd052ceca70 F ext/fts3/README.content b9078d0843a094d86af0d48dffbff13c906702b4c3558012e67b9c7cc3bf59ee @@ -2217,8 +2217,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9621c3b527702b47799538e028f96945b5697752dbb56078aa7f114c72fd4e1a -R 659759ae0159a7655f5b52c1145c8c1c -U drh -Z 640899f5a3ac016602bbc301589aaa54 +P 2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470 +R 3ec70cb458fa17a25b97de6754d185ac +T *branch * expert-vtab-fix +T *sym-expert-vtab-fix * +T -sym-trunk * +U dan +Z e6ab462e3ffdb8d19a80b4f488adc3f5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f6d8769d34..06dff7be3c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470 +a201906cd3c85080f9b739c2d347c51348ebebd3dc9b647d33d8dcae4b6e5850 From 629e1bfa6deef6f8f6407297653403278872d43c Mon Sep 17 00:00:00 2001 From: dan <Dan Kennedy> Date: Sat, 12 Oct 2024 18:33:40 +0000 Subject: [PATCH 65/77] Ensure that test file ext/expert/expert1.test works with non-fts5 builds. FossilOrigin-Name: 933dfd06188b487f14e522453a83b06e491aea97b4248c17f87727b56694acb5 --- ext/expert/expert1.test | 112 ++++++++++++++++++++-------------------- manifest | 15 +++--- manifest.uuid | 2 +- 3 files changed, 64 insertions(+), 65 deletions(-) diff --git a/ext/expert/expert1.test b/ext/expert/expert1.test index 0bfdbcce1b..16bd149fa1 100644 --- a/ext/expert/expert1.test +++ b/ext/expert/expert1.test @@ -521,62 +521,64 @@ do_candidates_test 6.1 { } #------------------------------------------------------------------------- -reset_db -do_execsql_test 7.0 { - CREATE VIRTUAL TABLE ft USING fts5(a); - CREATE TABLE t1(x, y); -} - -do_candidates_test 7.1 { - SELECT * FROM ft, t1 WHERE a=x -} { - CREATE INDEX t1_idx_00000078 ON t1(x); -} - -register_tcl_module db -proc vtab_command {method args} { - global G - - switch -- $method { - xConnect { - return "CREATE TABLE t1(a, b, c);" - } - - xBestIndex { - return [list] - } - - xFilter { - return [list sql "SELECT rowid, * FROM t0"] - } +ifcapable fts5 { + reset_db + do_execsql_test 7.0 { + CREATE VIRTUAL TABLE ft USING fts5(a); + CREATE TABLE t1(x, y); } - - return {} + + do_candidates_test 7.1 { + SELECT * FROM ft, t1 WHERE a=x + } { + CREATE INDEX t1_idx_00000078 ON t1(x); + } + + register_tcl_module db + proc vtab_command {method args} { + global G + + switch -- $method { + xConnect { + return "CREATE TABLE t1(a, b, c);" + } + + xBestIndex { + return [list] + } + + xFilter { + return [list sql "SELECT rowid, * FROM t0"] + } + } + + return {} + } + + do_execsql_test 7.2 { + CREATE TABLE t0(a, b, c); + INSERT INTO t0 VALUES(1, 2, 3), (11, 22, 33); + CREATE VIRTUAL TABLE t2 USING tcl(vtab_command); + } + + do_execsql_test 7.3 { + SELECT * FROM t2 + } { + 1 2 3 + 11 22 33 + } + + do_candidates_test 7.4 { + SELECT * FROM ft, t1 WHERE a=x + } { + CREATE INDEX t1_idx_00000078 ON t1(x); + } + + do_test 7.5 { + set expert [sqlite3_expert_new db] + list [catch { $expert sql "SELECT * FROM ft, t2 WHERE b=1" } msg] $msg + } {1 {no such table: t2}} + $expert destroy } -do_execsql_test 7.2 { - CREATE TABLE t0(a, b, c); - INSERT INTO t0 VALUES(1, 2, 3), (11, 22, 33); - CREATE VIRTUAL TABLE t2 USING tcl(vtab_command); -} - -do_execsql_test 7.3 { - SELECT * FROM t2 -} { - 1 2 3 - 11 22 33 -} - -do_candidates_test 7.4 { - SELECT * FROM ft, t1 WHERE a=x -} { - CREATE INDEX t1_idx_00000078 ON t1(x); -} - -do_test 7.5 { - set expert [sqlite3_expert_new db] - list [catch { $expert sql "SELECT * FROM ft, t2 WHERE b=1" } msg] $msg -} {1 {no such table: t2}} -$expert destroy - finish_test diff --git a/manifest b/manifest index 95c8dbbc32..06e9d8ec1d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sthe\s".expert"\scommand\sto\sanalyze\sstatements\sthat\suse\sbuilt-in\svirtual\stables. -D 2024-10-12T18:00:22.050 +C Ensure\sthat\stest\sfile\sext/expert/expert1.test\sworks\swith\snon-fts5\sbuilds. +D 2024-10-12T18:33:40.532 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -58,7 +58,7 @@ F ext/consio/console_io.c d2b74afae8d301de2e8447b1045fcd33eb59df13bf581d906d99c7 F ext/consio/console_io.h b5ebe34aa15b357621ebbea3d3f2e2b24750d4280b5802516409e23947fd9ee5 F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 -F ext/expert/expert1.test e049c507d33f7a7cf92ea6b15ac630cbc22598e387ec6749c2c5e1a5405e15a7 +F ext/expert/expert1.test 1fa0201d8610883c32214b1d83e3a6cc582694ac1067be8319b280235145a555 F ext/expert/sqlite3expert.c b7cbbd7cc109c66ebdf6091467d790abb9d7c25ae3b822bb76388509641d37de F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b F ext/expert/test_expert.c b767b2039a0df707eb3147e86bcf68b252d8455d9a41774b1a836cd052ceca70 @@ -2217,11 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470 -R 3ec70cb458fa17a25b97de6754d185ac -T *branch * expert-vtab-fix -T *sym-expert-vtab-fix * -T -sym-trunk * +P a201906cd3c85080f9b739c2d347c51348ebebd3dc9b647d33d8dcae4b6e5850 +R 6f739da0cd1664c0785c7542d02d878e U dan -Z e6ab462e3ffdb8d19a80b4f488adc3f5 +Z 0f71cd593125b9b696ef9a239504e6a3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 06dff7be3c..7e911ed943 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a201906cd3c85080f9b739c2d347c51348ebebd3dc9b647d33d8dcae4b6e5850 +933dfd06188b487f14e522453a83b06e491aea97b4248c17f87727b56694acb5 From 72fea118094177bcc9971d9937bb1f704b22d9f3 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 14 Oct 2024 09:08:02 +0000 Subject: [PATCH 66/77] Fix a harmless compiler warning in the CLI. FossilOrigin-Name: 31c46e84fffe29c45fc63ae8cd1f96f42196f0ab56e72cd07b4eedbd9058e85b --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/shell.c.in | 2 ++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 14dcac5ffc..418cdc500f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sthe\s".expert"\scommand\sand\squeries\sthat\suse\svirtual\stables. -D 2024-10-12T19:33:47.535 +C Fix\sa\sharmless\scompiler\swarning\sin\sthe\sCLI. +D 2024-10-14T09:08:02.231 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -771,7 +771,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in 46fa7b8be665d17c9593fbf40299ee799e6a932a9b59e7f2e5c686f574136cae +F src/shell.c.in e1e38be42a5a8a2d1732d684f6c5f13ca0be28d66ab16ed7553c53a287602796 F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2217,9 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470 933dfd06188b487f14e522453a83b06e491aea97b4248c17f87727b56694acb5 -R 6f739da0cd1664c0785c7542d02d878e -T +closed 933dfd06188b487f14e522453a83b06e491aea97b4248c17f87727b56694acb5 -U dan -Z decdebb3aeaa997fcf622998bf5851b9 +P 43787b8ec5348207ae84e6f16acf2605c1ca024fc02b022ce2f36b8495e88384 +R dc6bf56e3dd7752d134a3df81d5dd0b4 +U drh +Z 8d8c0b91bf578f1da5d0fabaf0b54fde # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b7d900aeb8..3a6f7a1c2c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -43787b8ec5348207ae84e6f16acf2605c1ca024fc02b022ce2f36b8495e88384 +31c46e84fffe29c45fc63ae8cd1f96f42196f0ab56e72cd07b4eedbd9058e85b diff --git a/src/shell.c.in b/src/shell.c.in index ec32acca78..13a362a857 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1856,6 +1856,8 @@ static void setCrnlMode(ShellState *p){ }else{ sqlite3_fsetmode(p->out, _O_BINARY); } +#else + UNUSED_PARAMETER(p); #endif } From 863fcdc1167f67d20d9e7b5c11c02fafcb3b8678 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 14 Oct 2024 09:19:02 +0000 Subject: [PATCH 67/77] Be consistent about using "CRLF" instead of "CRNL". FossilOrigin-Name: ec4f4cfd5f8ca83fad4f08cf6566251d9c63e50a3a4284baca299bd94b047951 --- ext/misc/sqlite3_stdio.c | 2 +- ext/recover/sqlite3recover.c | 8 +++--- manifest | 16 +++++------ manifest.uuid | 2 +- src/shell.c.in | 53 +++++++++++++++++++----------------- 5 files changed, 42 insertions(+), 39 deletions(-) diff --git a/ext/misc/sqlite3_stdio.c b/ext/misc/sqlite3_stdio.c index 6c0f5afcaf..5bb26084c2 100644 --- a/ext/misc/sqlite3_stdio.c +++ b/ext/misc/sqlite3_stdio.c @@ -38,7 +38,7 @@ ** ** If the SQLITE_U8TEXT_STDIO option is defined, then use O_U8TEXT ** when appropriate when writing to stdout or stderr. Use O_BINARY -** or O_TEXT (depending on things like the .mode and the .crnl setting +** or O_TEXT (depending on things like the .mode and the .crlf setting ** in the CLI, or other context clues in other applications) for all ** other output channels. ** diff --git a/ext/recover/sqlite3recover.c b/ext/recover/sqlite3recover.c index afa1ae8619..b16c09827e 100644 --- a/ext/recover/sqlite3recover.c +++ b/ext/recover/sqlite3recover.c @@ -744,7 +744,7 @@ static const char *recoverUnusedString( } /* -** Implementation of scalar SQL function "escape_crnl". The argument passed to +** Implementation of scalar SQL function "escape_crlf". The argument passed to ** this function is the output of built-in function quote(). If the first ** character of the input is "'", indicating that the value passed to quote() ** was a text value, then this function searches the input for "\n" and "\r" @@ -755,7 +755,7 @@ static const char *recoverUnusedString( ** Or, if the first character of the input is not "'", then a copy of the input ** is returned. */ -static void recoverEscapeCrnl( +static void recoverEscapeCrlf( sqlite3_context *context, int argc, sqlite3_value **argv @@ -970,7 +970,7 @@ static int recoverOpenOutput(sqlite3_recover *p){ { "getpage", 1, recoverGetPage }, { "page_is_used", 1, recoverPageIsUsed }, { "read_i32", 2, recoverReadI32 }, - { "escape_crnl", 1, recoverEscapeCrnl }, + { "escape_crlf", 1, recoverEscapeCrlf }, }; const int flags = SQLITE_OPEN_URI|SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE; @@ -1323,7 +1323,7 @@ static sqlite3_stmt *recoverInsertStmt( if( bSql ){ zBind = recoverMPrintf(p, - "%z%sescape_crnl(quote(?%d))", zBind, zSqlSep, pTab->aCol[ii].iBind + "%z%sescape_crlf(quote(?%d))", zBind, zSqlSep, pTab->aCol[ii].iBind ); zSqlSep = "||', '||"; }else{ diff --git a/manifest b/manifest index 418cdc500f..f233734dc9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\scompiler\swarning\sin\sthe\sCLI. -D 2024-10-14T09:08:02.231 +C Be\sconsistent\sabout\susing\s"CRLF"\sinstead\sof\s"CRNL". +D 2024-10-14T09:19:02.237 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -428,7 +428,7 @@ F ext/misc/shathree.c 1821d90a0040c9accdbe3e3527d378d30569475d758aa70f6848924c0b F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bcc42ef3fd29429bc01a83e751332b8d4690e65d45008449bdffe7656371487f F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 -F ext/misc/sqlite3_stdio.c 6857992f5e39992c9d44ad36230e28cbb0d630d6b0967c59e79ba13f2027ae49 +F ext/misc/sqlite3_stdio.c 73192f75e1e89722fbdf209056a562ca2a35df3c9e998f9270331e03cb621e7a F ext/misc/sqlite3_stdio.h f05eaf5e0258f0573910324a789a9586fc360a57678c57a6d63cfaa2245b6176 F ext/misc/stmt.c b090086cd6bd6281c21271d38d576eeffe662f0e6b67536352ce32bbaa438321 F ext/misc/stmtrand.c 59cffa5d8e158943ff1ce078956d8e208e8c04e67307e8f249dece2436dcb7fc @@ -509,7 +509,7 @@ F ext/recover/recoverpgsz.test 88766fcb810e52ee05335c456d4e5fb06d02b73d3ccb48c52 F ext/recover/recoverrowid.test f948bf4024a5f41b0e21b8af80c60564c5b5d78c05a8d64fc00787715ff9f45f F ext/recover/recoverslowidx.test 5205a9742dd9490ee99950dabb622307355ef1662dea6a3a21030057bfd81411 F ext/recover/recoversql.test e66d01f95302a223bcd3fd42b5ee58dc2b53d70afa90b0d00e41e4b8eab20486 -F ext/recover/sqlite3recover.c 2dcf6b56c5e0e2b43fc4c6115b689ab194c374ced7f7f8380ad9a24d8ef24ac9 +F ext/recover/sqlite3recover.c e822ecbb05a04a5c85d1309765fcd6cf392d100d02d2227cd7720c9d6921a17a F ext/recover/sqlite3recover.h 011c799f02deb70ab685916f6f538e6bb32c4e0025e79bfd0e24ff9c74820959 F ext/recover/test_recover.c 072260d7452a3b81aba995b2b3269e7ec2aa7f06725544ba4c25b1b0a1dbc61a F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b1446997e0c15 @@ -771,7 +771,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in e1e38be42a5a8a2d1732d684f6c5f13ca0be28d66ab16ed7553c53a287602796 +F src/shell.c.in a4174d9d73223ccc9b6bfa98a2feccf6af9f6386a1bdcbf7a4c527909a130bba F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 43787b8ec5348207ae84e6f16acf2605c1ca024fc02b022ce2f36b8495e88384 -R dc6bf56e3dd7752d134a3df81d5dd0b4 +P 31c46e84fffe29c45fc63ae8cd1f96f42196f0ab56e72cd07b4eedbd9058e85b +R 0ddfce1b00f5e783e91c489309275ead U drh -Z 8d8c0b91bf578f1da5d0fabaf0b54fde +Z 0bab3d34918042e28b7a5784677fe83e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3a6f7a1c2c..b820220c96 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -31c46e84fffe29c45fc63ae8cd1f96f42196f0ab56e72cd07b4eedbd9058e85b +ec4f4cfd5f8ca83fad4f08cf6566251d9c63e50a3a4284baca299bd94b047951 diff --git a/src/shell.c.in b/src/shell.c.in index 13a362a857..31c4a51cb5 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1448,7 +1448,7 @@ struct ShellState { u8 bSafeMode; /* True to prohibit unsafe operations */ u8 bSafeModePersist; /* The long-term value of bSafeMode */ u8 eRestoreState; /* See comments above doAutoDetectRestore() */ - u8 crnlMode; /* Do NL-to-CRLF translations when enabled (maybe) */ + u8 crlfMode; /* Do NL-to-CRLF translations when enabled (maybe) */ ColModeOpts cmOpts; /* Option values affecting columnar mode output */ unsigned statsOn; /* True to display memory stats before each finalize */ unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */ @@ -1629,7 +1629,7 @@ static const char *modeDescr[] = { #define SEP_Tab "\t" #define SEP_Space " " #define SEP_Comma "," -#define SEP_CrLf "\n" /* Use ".crnl on" to get \r\n line endings */ +#define SEP_CrLf "\n" /* Use ".crlf on" to get \r\n line endings */ #define SEP_Unit "\x1F" #define SEP_Record "\x1E" @@ -1714,7 +1714,7 @@ static void editFunc( char *zCmd = 0; int bBin; int rc; - int hasCRNL = 0; + int hasCRLF = 0; FILE *f = 0; sqlite3_int64 sz; sqlite3_int64 x; @@ -1759,7 +1759,7 @@ static void editFunc( }else{ const char *z = (const char*)sqlite3_value_text(argv[0]); /* Remember whether or not the value originally contained \r\n */ - if( z && strstr(z,"\r\n")!=0 ) hasCRNL = 1; + if( z && strstr(z,"\r\n")!=0 ) hasCRLF = 1; x = fwrite(sqlite3_value_text(argv[0]), 1, (size_t)sz, f); } fclose(f); @@ -1804,7 +1804,7 @@ static void editFunc( sqlite3_result_blob64(context, p, sz, sqlite3_free); }else{ sqlite3_int64 i, j; - if( hasCRNL ){ + if( hasCRLF ){ /* If the original contains \r\n then do no conversions back to \n */ }else{ /* If the file did not originally contain \r\n then convert any new @@ -1849,9 +1849,9 @@ static void outputModePop(ShellState *p){ /* ** Set output mode to text or binary for Windows. */ -static void setCrnlMode(ShellState *p){ +static void setCrlfMode(ShellState *p){ #ifdef _WIN32 - if( p->crnlMode ){ + if( p->crlfMode ){ sqlite3_fsetmode(p->out, _O_TEXT); }else{ sqlite3_fsetmode(p->out, _O_BINARY); @@ -1940,7 +1940,7 @@ static void output_quoted_string(ShellState *p, const char *z){ } sqlite3_fputs("'", out); } - setCrnlMode(p); + setCrlfMode(p); } /* @@ -2008,7 +2008,7 @@ static void output_quoted_escaped_string(ShellState *p, const char *z){ sqlite3_fprintf(out, ",'%s',char(10))", zNL); } } - setCrnlMode(p); + setCrlfMode(p); } /* @@ -2797,7 +2797,7 @@ static int shell_callback( for(i=0; i<nArg; i++){ output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1); } - if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){ + if( p->crlfMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){ sqlite3_fputs("\r\n", p->out); }else{ sqlite3_fputs(p->rowSeparator, p->out); @@ -2807,13 +2807,13 @@ static int shell_callback( for(i=0; i<nArg; i++){ output_csv(p, azArg[i], i<nArg-1); } - if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){ + if( p->crlfMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){ sqlite3_fputs("\r\n", p->out); }else{ sqlite3_fputs(p->rowSeparator, p->out); } } - setCrnlMode(p); + setCrlfMode(p); break; } case MODE_Insert: { @@ -4956,7 +4956,7 @@ static const char *(azHelp[]) = { ".clone NEWDB Clone data into NEWDB from the existing database", #endif ".connection [close] [#] Open or close an auxiliary database connection", - ".crnl on|off Translate \\n to \\r\\n sometimes. Default OFF", + ".crlf on|off Translate \\n to \\r\\n sometimes. Default OFF", ".databases List names and files of attached databases", ".dbconfig ?op? ?val? List or change sqlite3_db_config() options", #if SQLITE_SHELL_HAVE_RECOVER @@ -6437,7 +6437,7 @@ static void output_redir(ShellState *p, FILE *pfNew){ sqlite3_fputs("Output already redirected.\n", stderr); }else{ p->out = pfNew; - setCrnlMode(p); + setCrlfMode(p); if( p->mode==MODE_Www ){ sqlite3_fputs( "<!DOCTYPE html>\n" @@ -6493,7 +6493,7 @@ static void output_reset(ShellState *p){ } p->outfile[0] = 0; p->out = stdout; - setCrnlMode(p); + setCrlfMode(p); } #else # define output_redir(SS,pfO) @@ -8446,7 +8446,7 @@ static int do_meta_command(char *zLine, ShellState *p){ } }else - /* Undocumented. Legacy only. See "crnl" below */ + /* Undocumented. Legacy only. See "crlf" below */ if( c=='b' && n>=3 && cli_strncmp(azArg[0], "binary", n)==0 ){ eputz("The \".binary\" command is deprecated.\n"); rc = 1; @@ -8574,13 +8574,16 @@ static int do_meta_command(char *zLine, ShellState *p){ } }else - if( c=='c' && n==4 && cli_strncmp(azArg[0], "crnl", n)==0 ){ + if( c=='c' && n==4 + && (cli_strncmp(azArg[0], "crlf", n)==0 + || cli_strncmp(azArg[0], "crnl",n)==0) + ){ if( nArg==2 ){ - p->crnlMode = booleanValue(azArg[1]); - setCrnlMode(p); + p->crlfMode = booleanValue(azArg[1]); + setCrlfMode(p); }else{ - sqlite3_fprintf(stderr, "crnl is currently %s\n", - p->crnlMode ? "ON" : "OFF"); + sqlite3_fprintf(stderr, "crlf is currently %s\n", + p->crlfMode ? "ON" : "OFF"); } }else @@ -12616,14 +12619,14 @@ static void main_init(ShellState *data) { sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); /* By default, come up in O_BINARY mode. That way, the default output is - ** the same for Windows and non-Windows systems. Use the ".crnl on" + ** the same for Windows and non-Windows systems. Use the ".crlf on" ** command to change into O_TEXT mode to do automatic NL-to-CRLF ** conversions on output for Windows. ** - ** End-of-line marks on CVS output is CRLF when in .crnl is on and - ** NL when .crnl is off. + ** End-of-line marks on CVS output is CRLF when in .crlf is on and + ** NL when .crlf is off. */ - data->crnlMode = 0; + data->crlfMode = 0; } /* From 39b9249562d460f1d1a372467b48308968fdf3b0 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 14 Oct 2024 10:45:02 +0000 Subject: [PATCH 68/77] The CLI now default to ".crlf ON" in Windows. CSV output always uses CRLF on all platforms. FossilOrigin-Name: 84d19f03b1989d665547745defcd95fc927f8389ed65c76195a39206435791ba --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 38 ++++++++++++-------------------------- 3 files changed, 19 insertions(+), 33 deletions(-) diff --git a/manifest b/manifest index f233734dc9..e151a057b5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Be\sconsistent\sabout\susing\s"CRLF"\sinstead\sof\s"CRNL". -D 2024-10-14T09:19:02.237 +C The\sCLI\snow\sdefault\sto\s".crlf\sON"\sin\sWindows.\s\sCSV\soutput\salways\suses\sCRLF\son\nall\splatforms. +D 2024-10-14T10:45:02.572 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -771,7 +771,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in a4174d9d73223ccc9b6bfa98a2feccf6af9f6386a1bdcbf7a4c527909a130bba +F src/shell.c.in 3e53af7cc5dd0f4710e7249b66f522f43df20579bf9f5d36ba294f537fbe8d1d F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 31c46e84fffe29c45fc63ae8cd1f96f42196f0ab56e72cd07b4eedbd9058e85b -R 0ddfce1b00f5e783e91c489309275ead +P ec4f4cfd5f8ca83fad4f08cf6566251d9c63e50a3a4284baca299bd94b047951 +R b04dc4d5fe6236e22abab8975f6627f9 U drh -Z 0bab3d34918042e28b7a5784677fe83e +Z 6ce380ef14a7f907fc64ecc1f59106c2 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b820220c96..08c03b54af 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ec4f4cfd5f8ca83fad4f08cf6566251d9c63e50a3a4284baca299bd94b047951 +84d19f03b1989d665547745defcd95fc927f8389ed65c76195a39206435791ba diff --git a/src/shell.c.in b/src/shell.c.in index 31c4a51cb5..9f7ab6b34b 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1629,7 +1629,7 @@ static const char *modeDescr[] = { #define SEP_Tab "\t" #define SEP_Space " " #define SEP_Comma "," -#define SEP_CrLf "\n" /* Use ".crlf on" to get \r\n line endings */ +#define SEP_CrLf "\r\n" #define SEP_Unit "\x1F" #define SEP_Record "\x1E" @@ -2797,21 +2797,13 @@ static int shell_callback( for(i=0; i<nArg; i++){ output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1); } - if( p->crlfMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){ - sqlite3_fputs("\r\n", p->out); - }else{ - sqlite3_fputs(p->rowSeparator, p->out); - } + sqlite3_fputs(p->rowSeparator, p->out); } if( nArg>0 ){ for(i=0; i<nArg; i++){ output_csv(p, azArg[i], i<nArg-1); } - if( p->crlfMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){ - sqlite3_fputs("\r\n", p->out); - }else{ - sqlite3_fputs(p->rowSeparator, p->out); - } + sqlite3_fputs(p->rowSeparator, p->out); } setCrlfMode(p); break; @@ -4956,7 +4948,7 @@ static const char *(azHelp[]) = { ".clone NEWDB Clone data into NEWDB from the existing database", #endif ".connection [close] [#] Open or close an auxiliary database connection", - ".crlf on|off Translate \\n to \\r\\n sometimes. Default OFF", + ".crlf ?on|off? Whether or not to use \\r\\n line endings", ".databases List names and files of attached databases", ".dbconfig ?op? ?val? List or change sqlite3_db_config() options", #if SQLITE_SHELL_HAVE_RECOVER @@ -8579,12 +8571,13 @@ static int do_meta_command(char *zLine, ShellState *p){ || cli_strncmp(azArg[0], "crnl",n)==0) ){ if( nArg==2 ){ +#ifdef _WIN32 p->crlfMode = booleanValue(azArg[1]); - setCrlfMode(p); - }else{ - sqlite3_fprintf(stderr, "crlf is currently %s\n", - p->crlfMode ? "ON" : "OFF"); +#else + p->crlfMode = 0; +#endif } + sqlite3_fprintf(stderr, "crlf is %s\n", p->crlfMode ? "ON" : "OFF"); }else if( c=='d' && n>1 && cli_strncmp(azArg[0], "databases", n)==0 ){ @@ -12604,6 +12597,9 @@ static void main_init(ShellState *data) { memset(data, 0, sizeof(*data)); data->normalMode = data->cMode = data->mode = MODE_List; data->autoExplain = 1; +#ifdef _WIN32 + data->crlfMode = 1; +#endif data->pAuxDb = &data->aAuxDb[0]; memcpy(data->colSeparator,SEP_Column, 2); memcpy(data->rowSeparator,SEP_Row, 2); @@ -12617,16 +12613,6 @@ static void main_init(ShellState *data) { sqlite3_config(SQLITE_CONFIG_MULTITHREAD); sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); - - /* By default, come up in O_BINARY mode. That way, the default output is - ** the same for Windows and non-Windows systems. Use the ".crlf on" - ** command to change into O_TEXT mode to do automatic NL-to-CRLF - ** conversions on output for Windows. - ** - ** End-of-line marks on CVS output is CRLF when in .crlf is on and - ** NL when .crlf is off. - */ - data->crlfMode = 0; } /* From 5899d9c08f1291584f6b5799402d847b2ce051d1 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 14 Oct 2024 11:48:19 +0000 Subject: [PATCH 69/77] There is no need to DELETE the content of sqlite_sequence in the output of the CLI ".dump" command because that table will initially be empty if it exists at all. [forum:/forumpost/2e31f49d00472cec|Forum post 2e31f49d004] FossilOrigin-Name: 8d7fe903d09a2a7961f506b2c8e93765e4feb7cd48aac436d75c7ec7838e856a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e151a057b5..a55e448e1b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sCLI\snow\sdefault\sto\s".crlf\sON"\sin\sWindows.\s\sCSV\soutput\salways\suses\sCRLF\son\nall\splatforms. -D 2024-10-14T10:45:02.572 +C There\sis\sno\sneed\sto\sDELETE\sthe\scontent\sof\ssqlite_sequence\sin\sthe\soutput\sof\nthe\sCLI\s".dump"\scommand\sbecause\sthat\stable\swill\sinitially\sbe\sempty\sif\sit\nexists\sat\sall.\s\s[forum:/forumpost/2e31f49d00472cec|Forum\spost\s2e31f49d004] +D 2024-10-14T11:48:19.953 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -771,7 +771,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in 3e53af7cc5dd0f4710e7249b66f522f43df20579bf9f5d36ba294f537fbe8d1d +F src/shell.c.in 0662f9bcf0725461778d0254a06150e5d61c08c5a87a7281ccdf45552050c79d F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ec4f4cfd5f8ca83fad4f08cf6566251d9c63e50a3a4284baca299bd94b047951 -R b04dc4d5fe6236e22abab8975f6627f9 +P 84d19f03b1989d665547745defcd95fc927f8389ed65c76195a39206435791ba +R 1ef34f05629f791da5b9980e1ed8e3d1 U drh -Z 6ce380ef14a7f907fc64ecc1f59106c2 +Z 7bb3b0ccb15b1050d4f6808a12c898f4 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 08c03b54af..82f13f9594 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -84d19f03b1989d665547745defcd95fc927f8389ed65c76195a39206435791ba +8d7fe903d09a2a7961f506b2c8e93765e4feb7cd48aac436d75c7ec7838e856a diff --git a/src/shell.c.in b/src/shell.c.in index 9f7ab6b34b..bbf08f8098 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4763,7 +4763,7 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azNotUsed){ noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0; if( cli_strcmp(zTable, "sqlite_sequence")==0 && !noSys ){ - if( !dataOnly ) sqlite3_fputs("DELETE FROM sqlite_sequence;\n", p->out); + /* no-op */ }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 && !noSys ){ if( !dataOnly ) sqlite3_fputs("ANALYZE sqlite_schema;\n", p->out); }else if( cli_strncmp(zTable, "sqlite_", 7)==0 ){ From 4924847cb9bfa0d2ff99b325a125bdf78c17cbb6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 14 Oct 2024 18:43:04 +0000 Subject: [PATCH 70/77] Avoid the possibility of buffer overrun in the READ_UTF8 macro by using an less-than operator rather than not-equal-to. FossilOrigin-Name: 20e60bf058c54bc818ea1b8ce54ace8bcd50699734713cef622bf79e49a9a279 --- ext/fts5/fts5_tokenize.c | 2 +- manifest | 14 +++++++------- manifest.uuid | 2 +- src/utf.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/fts5/fts5_tokenize.c b/ext/fts5/fts5_tokenize.c index f92529b840..f9581b080c 100644 --- a/ext/fts5/fts5_tokenize.c +++ b/ext/fts5/fts5_tokenize.c @@ -198,7 +198,7 @@ static const unsigned char sqlite3Utf8Trans1[] = { c = *(zIn++); \ if( c>=0xc0 ){ \ c = sqlite3Utf8Trans1[c-0xc0]; \ - while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \ + while( zIn<zTerm && (*zIn & 0xc0)==0x80 ){ \ c = (c<<6) + (0x3f & *(zIn++)); \ } \ if( c<0x80 \ diff --git a/manifest b/manifest index a55e448e1b..da1c9d2d95 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C There\sis\sno\sneed\sto\sDELETE\sthe\scontent\sof\ssqlite_sequence\sin\sthe\soutput\sof\nthe\sCLI\s".dump"\scommand\sbecause\sthat\stable\swill\sinitially\sbe\sempty\sif\sit\nexists\sat\sall.\s\s[forum:/forumpost/2e31f49d00472cec|Forum\spost\s2e31f49d004] -D 2024-10-14T11:48:19.953 +C Avoid\sthe\spossibility\sof\sbuffer\soverrun\sin\sthe\sREAD_UTF8\smacro\sby\susing\nan\sless-than\soperator\srather\sthan\snot-equal-to. +D 2024-10-14T18:43:04.340 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -106,7 +106,7 @@ F ext/fts5/fts5_storage.c 337b05e4c66fc822d031e264d65bde807ec2fab08665ca2cc8aaf9 F ext/fts5/fts5_tcl.c 4db9258a7882c5eac0da4433042132aaf15b87dd1e1636c7a6ca203abd2c8bfe F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee F ext/fts5/fts5_test_tok.c 3cb0a9b508b30d17ef025ccddd26ae3dc8ddffbe76c057616e59a9aa85d36f3b -F ext/fts5/fts5_tokenize.c ae9c4fa93174ef06ffc138bd4280a1c37f7e13624d3d2706aad4b80573f23c41 +F ext/fts5/fts5_tokenize.c 033e2e43b8e852c0ef6cecc611266d61e2346e52ec7dcfb76a428fe56a07efa9 F ext/fts5/fts5_unicode2.c 6f9b0fb79a8facaed76628ffd4eb9c16d7f2b84b52872784f617cf3422a9b043 F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d09885d1dadf80 F ext/fts5/fts5_vocab.c e4830b00809e5da53bc10f93adc59e321407b0f801c7f4167c0e47f5552267e0 @@ -837,7 +837,7 @@ F src/treeview.c 88aa39b754f5ef7214385c1bbbdd2f3dc20efafeed0cf590e8d1199b9c6e44a F src/trigger.c 0bb986a5b96047fd597c6aac28588853df56064e576e6b81ba777ef2ccaac461 F src/update.c 0e01aa6a3edf9ec112b33eb714b9016a81241497b1fb7c3e74332f4f71756508 F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 -F src/utf.c 7bc550af6f3ddd5f5dc82d092c41f728acb760c92e0b47f391963b01ae52569b +F src/utf.c 8b29d9a5956569ea2700f869669b8ef67a9662ee5e724ff77ab3c387e27094ba F src/util.c 4d57ae861d0e234019be9596818228d7715e44e6efaccb612cf4498bedc2e023 F src/vacuum.c b763b6457bd058d2072ef9364832351fd8d11e8abf70cbb349657360f7d55c40 F src/vdbe.c be5f58bc29f60252e041a618eae59e8d57d460ba136c5403cf0abf955560c457 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 84d19f03b1989d665547745defcd95fc927f8389ed65c76195a39206435791ba -R 1ef34f05629f791da5b9980e1ed8e3d1 +P 8d7fe903d09a2a7961f506b2c8e93765e4feb7cd48aac436d75c7ec7838e856a +R 15be0cd34b76a89f2a4632e2831492f6 U drh -Z 7bb3b0ccb15b1050d4f6808a12c898f4 +Z 7cf34cfe3b4d97664da1ae98f0058b06 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 82f13f9594..0ee78eb807 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8d7fe903d09a2a7961f506b2c8e93765e4feb7cd48aac436d75c7ec7838e856a +20e60bf058c54bc818ea1b8ce54ace8bcd50699734713cef622bf79e49a9a279 diff --git a/src/utf.c b/src/utf.c index 083ada7882..c934bb234c 100644 --- a/src/utf.c +++ b/src/utf.c @@ -136,7 +136,7 @@ static const unsigned char sqlite3Utf8Trans1[] = { c = *(zIn++); \ if( c>=0xc0 ){ \ c = sqlite3Utf8Trans1[c-0xc0]; \ - while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \ + while( zIn<zTerm && (*zIn & 0xc0)==0x80 ){ \ c = (c<<6) + (0x3f & *(zIn++)); \ } \ if( c<0x80 \ From dcaae8fd4bb2831fd448c6b5c77885f0dcbcf947 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 15 Oct 2024 14:00:29 +0000 Subject: [PATCH 71/77] Cross-reference the sqlite3_backup_init() function to the documentation for VACUUM INTO and sqlite3-rsync. Comment changes only. No changes to code. FossilOrigin-Name: 405c23ce02cc7f970e732afc26e01d0267b8fa89d8edc3d53fae2b3bc8405cbb --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 10 ++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index da1c9d2d95..88ed57f718 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sthe\spossibility\sof\sbuffer\soverrun\sin\sthe\sREAD_UTF8\smacro\sby\susing\nan\sless-than\soperator\srather\sthan\snot-equal-to. -D 2024-10-14T18:43:04.340 +C Cross-reference\sthe\ssqlite3_backup_init()\sfunction\sto\sthe\sdocumentation\sfor\nVACUUM\sINTO\sand\ssqlite3-rsync.\s\sComment\schanges\sonly.\s\sNo\schanges\sto\scode. +D 2024-10-15T14:00:29.768 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -772,7 +772,7 @@ F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe F src/shell.c.in 0662f9bcf0725461778d0254a06150e5d61c08c5a87a7281ccdf45552050c79d -F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e +F src/sqlite.h.in b4bb0ef2209199ff39946adb62abfb316d288a3ce9ef46cc1e8514d46f7bbcf7 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h ad02397dc4d22b77f9a331412d46e4c1e49459dd386fba8373fa148998e1e7d0 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8d7fe903d09a2a7961f506b2c8e93765e4feb7cd48aac436d75c7ec7838e856a -R 15be0cd34b76a89f2a4632e2831492f6 +P 20e60bf058c54bc818ea1b8ce54ace8bcd50699734713cef622bf79e49a9a279 +R b5b1ff932683ee99575e97488a29d8d4 U drh -Z 7cf34cfe3b4d97664da1ae98f0058b06 +Z 5f285a9b6162aaeb2664fdd848672415 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0ee78eb807..425748862f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -20e60bf058c54bc818ea1b8ce54ace8bcd50699734713cef622bf79e49a9a279 +405c23ce02cc7f970e732afc26e01d0267b8fa89d8edc3d53fae2b3bc8405cbb diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 5108d3c1e9..6508b54397 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -9344,6 +9344,16 @@ typedef struct sqlite3_backup sqlite3_backup; ** APIs are not strictly speaking threadsafe. If they are invoked at the ** same time as another thread is invoking sqlite3_backup_step() it is ** possible that they return invalid values. +** +** <b>Alternatives To Using The Backup API</b> +** +** Other techniques for safely creating a consistent backup of an SQLite +** database include: +** +** <ul> +** <li> The [VACUUM INTO] command. +** <li> The [sqlite3-rsync] utility program. +** </ul> */ sqlite3_backup *sqlite3_backup_init( sqlite3 *pDest, /* Destination database handle */ From 1b59f37c0604ffc61b96d24654f365a47083b102 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 15 Oct 2024 14:28:23 +0000 Subject: [PATCH 72/77] Fix a typo in a comment used to generate document. No code changes. FossilOrigin-Name: 9b4bc5c4c1dc7c4ba359babc71c07ac3a6719971766951a8d2cb1df9e2396a83 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 88ed57f718..0ef21134bd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Cross-reference\sthe\ssqlite3_backup_init()\sfunction\sto\sthe\sdocumentation\sfor\nVACUUM\sINTO\sand\ssqlite3-rsync.\s\sComment\schanges\sonly.\s\sNo\schanges\sto\scode. -D 2024-10-15T14:00:29.768 +C Fix\sa\stypo\sin\sa\scomment\sused\sto\sgenerate\sdocument.\s\sNo\scode\schanges. +D 2024-10-15T14:28:23.268 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -772,7 +772,7 @@ F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe F src/shell.c.in 0662f9bcf0725461778d0254a06150e5d61c08c5a87a7281ccdf45552050c79d -F src/sqlite.h.in b4bb0ef2209199ff39946adb62abfb316d288a3ce9ef46cc1e8514d46f7bbcf7 +F src/sqlite.h.in 547508e419f83421fea0282dee4ea82fc575cc8bfd6ec13d333fc1bd82b9f70e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h ad02397dc4d22b77f9a331412d46e4c1e49459dd386fba8373fa148998e1e7d0 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 20e60bf058c54bc818ea1b8ce54ace8bcd50699734713cef622bf79e49a9a279 -R b5b1ff932683ee99575e97488a29d8d4 +P 405c23ce02cc7f970e732afc26e01d0267b8fa89d8edc3d53fae2b3bc8405cbb +R 9fb12d9ed97d139a0344d179255e7067 U drh -Z 5f285a9b6162aaeb2664fdd848672415 +Z e131015db60bc2c35aa320017b31d7a0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 425748862f..c65b900626 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -405c23ce02cc7f970e732afc26e01d0267b8fa89d8edc3d53fae2b3bc8405cbb +9b4bc5c4c1dc7c4ba359babc71c07ac3a6719971766951a8d2cb1df9e2396a83 diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 6508b54397..a46b1b6450 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4232,7 +4232,7 @@ int sqlite3_limit(sqlite3*, int id, int newVal); ** is the number of bytes in the input string <i>including</i> ** the nul-terminator. ** Note that nByte measure the length of the input in bytes, not -** characters, even for the UTF-16 inferfaces. +** characters, even for the UTF-16 interfaces. ** ** ^If pzTail is not NULL then *pzTail is made to point to the first byte ** past the end of the first SQL statement in zSql. These routines only From 45b4dca606fbf70d901637328c4329275ba0e1f4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 15 Oct 2024 18:45:21 +0000 Subject: [PATCH 73/77] Fix the "tool-zip" makefile target so that it includes sqlite3-rsync. FossilOrigin-Name: ecdbedb16bbc467b0bc56badae2a4d407b4ea2085312b50af56af8cd110f055c --- Makefile.in | 2 +- Makefile.msc | 2 +- manifest | 16 ++++++++-------- manifest.uuid | 2 +- tool/mktoolzip.tcl | 17 ++++------------- 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/Makefile.in b/Makefile.in index c3f9c15c36..9e9cc0a5f2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1558,7 +1558,7 @@ snapshot-tarball: sqlite3.c sqlite3rc.h # Build a ZIP archive containing various command-line tools. # -tool-zip: testfixture sqlite3 sqldiff sqlite3_analyzer $(TOP)/tool/mktoolzip.tcl +tool-zip: testfixture sqlite3 sqldiff sqlite3_analyzer sqlite3-rsync $(TOP)/tool/mktoolzip.tcl ./testfixture $(TOP)/tool/mktoolzip.tcl # The next two rules are used to support the "threadtest" target. Building diff --git a/Makefile.msc b/Makefile.msc index 0977a49351..4a8abc9e3d 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -2577,7 +2577,7 @@ extensiontest: testfixture.exe testloadext.dll @set PATH=$(LIBTCLPATH);$(PATH) .\testfixture.exe $(TOP)\test\loadext.test $(TESTOPTS) -tool-zip: testfixture.exe sqlite3.exe sqldiff.exe sqlite3_analyzer.exe $(TOP)\tool\mktoolzip.tcl +tool-zip: testfixture.exe sqlite3.exe sqldiff.exe sqlite3_analyzer.exe sqlite3-rsync.exe $(TOP)\tool\mktoolzip.tcl .\testfixture.exe $(TOP)\tool\mktoolzip.tcl coretestprogs: testfixture.exe sqlite3.exe diff --git a/manifest b/manifest index 0ef21134bd..6d4811fd0d 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Fix\sa\stypo\sin\sa\scomment\sused\sto\sgenerate\sdocument.\s\sNo\scode\schanges. -D 2024-10-15T14:28:23.268 +C Fix\sthe\s"tool-zip"\smakefile\starget\sso\sthat\sit\sincludes\ssqlite3-rsync. +D 2024-10-15T18:45:21.791 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 209f43b9a484118a838d52d2b351f756bd8ec5cbc1181c6308f185ea364d4420 +F Makefile.in b4e88cf9a1260273ad88ef8e65de3de81c0af8010782a7fc685884551220445f F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 829ad1543511bd2953b0f9ac41e494daf96e25b4ec2e00c2abe76a08d7b46b3d +F Makefile.msc 12d2c38554bddf5e698aba580eb863c762c0e1d46f5cad60d028e7270c33cdc2 F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -2150,7 +2150,7 @@ F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6 F tool/mksqlite3c.tcl c6acfdf4e4ef93478ff3ce3cd593e17abb03f446036ce710c3156bcfa18665e0 F tool/mksqlite3h.tcl d391cff7cad0a372ee1406faee9ccc7dad9cb80a0c95cae0f73d10dd26e06762 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b -F tool/mktoolzip.tcl c7a9b685f5131d755e7d941cec50cee7f34178b9e34c9a89811eeb08617f8423 +F tool/mktoolzip.tcl ca5d73696b0c0b58a071add0fd082aaeb8050bd9072f34c69e68a60624d6a165 F tool/mkvsix.tcl 67b40996a50f985a573278eea32fc5a5eb6110bdf14d33f1d8086e48c69e540a F tool/offsets.c 8ed2b344d33f06e71366a9b93ccedaa38c096cc1dbd4c3c26ad08c6115285845 F tool/omittest-msvc.tcl d6b8f501ac1d7798c4126065030f89812379012cad98a1735d6d7221492abc08 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 405c23ce02cc7f970e732afc26e01d0267b8fa89d8edc3d53fae2b3bc8405cbb -R 9fb12d9ed97d139a0344d179255e7067 +P 9b4bc5c4c1dc7c4ba359babc71c07ac3a6719971766951a8d2cb1df9e2396a83 +R 2ed74e1453ff42b0ea3799af4d62c8c1 U drh -Z e131015db60bc2c35aa320017b31d7a0 +Z 58979b2cefb747fe9b44a98ef6a6d211 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c65b900626..9478dacd09 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b4bc5c4c1dc7c4ba359babc71c07ac3a6719971766951a8d2cb1df9e2396a83 +ecdbedb16bbc467b0bc56badae2a4d407b4ea2085312b50af56af8cd110f055c diff --git a/tool/mktoolzip.tcl b/tool/mktoolzip.tcl index 885bae960b..2f002accd1 100644 --- a/tool/mktoolzip.tcl +++ b/tool/mktoolzip.tcl @@ -54,16 +54,7 @@ close $in scan $vers %d.%d.%d v1 v2 v3 set v2 [format 3%02d%02d00 $v2 $v3] set name sqlite-tools-$OS-$ARCH-$v2.zip - -if {$OS=="win32"} { - # The win32 tar.exe supports the -a ("auto-compress") option. This causes - # tar to create an archive type based on the extension of the output file. - # In this case, a zip file. - puts "tar -a -cf $name sqlite3$EXE sqldiff$EXE sqlite3_analyzer$EXE" - puts [exec tar -a -cf $name sqlite3$EXE sqldiff$EXE sqlite3_analyzer$EXE] - puts "$name: [file size $name] bytes" -} else { - puts "zip $name sqlite3$EXE sqldiff$EXE sqlite3_analyzer$EXE" - puts [exec zip $name sqlite3$EXE sqldiff$EXE sqlite3_analyzer$EXE] - puts [exec ls -l $name] -} +set toollist "sqlite3$EXE sqldiff$EXE sqlite3_analyzer$EXE sqlite3-rsync$EXE" +puts "zip $name {*}$toollist" +exec zip $name {*}$toollist +puts "$name: [file size $name] bytes" From 87cb97b0ec57e55e644f5fd8c0630823e37ec745 Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 15 Oct 2024 22:22:53 +0000 Subject: [PATCH 74/77] Fix harmless compiler warning in flockCheckReservedLock(). FossilOrigin-Name: f369de3d8fa34a403b5c9f6269f7e3fdb16a13784a70460c5032ad4e66615d64 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 6d4811fd0d..0d594a6646 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\s"tool-zip"\smakefile\starget\sso\sthat\sit\sincludes\ssqlite3-rsync. -D 2024-10-15T18:45:21.791 +C Fix\sharmless\scompiler\swarning\sin\sflockCheckReservedLock(). +D 2024-10-15T22:22:53.374 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -754,7 +754,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06 F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107 -F src/os_unix.c 4086be39edc253ca75d4f447972e26f6998023ab519d1a176e3b3a72fae609d0 +F src/os_unix.c 14d0f80e4779f5f76bcc71e7af97e3efe318fa3d0b22335623c59fab7d39302b F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c b08600ebf0db90b6d1e9b8b6577c6fa3877cbe1a100bd0b2899e4c6e9adad4b3 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9b4bc5c4c1dc7c4ba359babc71c07ac3a6719971766951a8d2cb1df9e2396a83 -R 2ed74e1453ff42b0ea3799af4d62c8c1 +P ecdbedb16bbc467b0bc56badae2a4d407b4ea2085312b50af56af8cd110f055c +R 9f52713e8eaa9976f4131eab2f8af10c U drh -Z 58979b2cefb747fe9b44a98ef6a6d211 +Z 789bdcffe52cd99fcbdd811406537eae # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9478dacd09..38b21ff87a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ecdbedb16bbc467b0bc56badae2a4d407b4ea2085312b50af56af8cd110f055c +f369de3d8fa34a403b5c9f6269f7e3fdb16a13784a70460c5032ad4e66615d64 diff --git a/src/os_unix.c b/src/os_unix.c index 2106dee8f0..f71fa8e029 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2464,7 +2464,11 @@ static int robust_flock(int fd, int op){ ** is set to SQLITE_OK unless an I/O error occurs during lock checking. */ static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){ +#ifdef SQLITE_DEBUG unixFile *pFile = (unixFile*)id; +#else + UNUSED_PARAMETER(id); +#endif SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; ); From 9c5fb63d374032c1bf912a197ccc1e7e2bac3a3a Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 16 Oct 2024 10:20:30 +0000 Subject: [PATCH 75/77] In the unix Makefile, strip compiled binaries prior to adding them to the tool ZIP archive. FossilOrigin-Name: cd8ae6fd7166680a6d121d710ff9d722e3e14d1d3538fc8ea1ea2690035ba80e --- Makefile.in | 1 + manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile.in b/Makefile.in index 9e9cc0a5f2..e11c33d370 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1559,6 +1559,7 @@ snapshot-tarball: sqlite3.c sqlite3rc.h # Build a ZIP archive containing various command-line tools. # tool-zip: testfixture sqlite3 sqldiff sqlite3_analyzer sqlite3-rsync $(TOP)/tool/mktoolzip.tcl + strip sqlite3 sqldiff sqlite3_analyzer sqlite3-rsync ./testfixture $(TOP)/tool/mktoolzip.tcl # The next two rules are used to support the "threadtest" target. Building diff --git a/manifest b/manifest index 0d594a6646..d1fd7a5af5 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Fix\sharmless\scompiler\swarning\sin\sflockCheckReservedLock(). -D 2024-10-15T22:22:53.374 +C In\sthe\sunix\sMakefile,\sstrip\scompiled\sbinaries\sprior\sto\sadding\sthem\sto\sthe\ntool\sZIP\sarchive. +D 2024-10-16T10:20:30.451 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in b4e88cf9a1260273ad88ef8e65de3de81c0af8010782a7fc685884551220445f +F Makefile.in 78e76e161981608a8c96ef92045d024ff8fced0b6d6ff442c1bafb93e2cf4467 F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 12d2c38554bddf5e698aba580eb863c762c0e1d46f5cad60d028e7270c33cdc2 F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ecdbedb16bbc467b0bc56badae2a4d407b4ea2085312b50af56af8cd110f055c -R 9f52713e8eaa9976f4131eab2f8af10c +P f369de3d8fa34a403b5c9f6269f7e3fdb16a13784a70460c5032ad4e66615d64 +R a516d4923c3cbd6116cdc55d9e1d772d U drh -Z 789bdcffe52cd99fcbdd811406537eae +Z 650ee0412157fb1bcbcde3dfc36af0ff # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 38b21ff87a..7941bce70b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f369de3d8fa34a403b5c9f6269f7e3fdb16a13784a70460c5032ad4e66615d64 +cd8ae6fd7166680a6d121d710ff9d722e3e14d1d3538fc8ea1ea2690035ba80e From f578ce102eaf001fe54aaefd3fd112a07788b763 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 16 Oct 2024 11:05:11 +0000 Subject: [PATCH 76/77] Change the name of the new utility program from sqlite3-rsync to sqlite3_rsync - dash changed to underscore - for consistency with the preexisting sqlite3_analyzer. FossilOrigin-Name: 86e794cbaa5ae600635c933b46298a39f2465daf4c5cd1570f2a03e19ac08d9d --- Makefile.in | 10 ++++----- Makefile.msc | 8 +++---- doc/compile-for-unix.md | 2 +- doc/compile-for-windows.md | 2 +- main.mk | 6 +++--- manifest | 26 +++++++++++------------ manifest.uuid | 2 +- src/sqlite.h.in | 2 +- tool/mktoolzip.tcl | 2 +- tool/{sqlite3-rsync.c => sqlite3_rsync.c} | 14 ++++++------ 10 files changed, 37 insertions(+), 37 deletions(-) rename tool/{sqlite3-rsync.c => sqlite3_rsync.c} (99%) diff --git a/Makefile.in b/Makefile.in index e11c33d370..ac1e627f52 100644 --- a/Makefile.in +++ b/Makefile.in @@ -701,7 +701,7 @@ dbhash$(TEXE): $(TOP)/tool/dbhash.c sqlite3.lo sqlite3.h $(LTLINK) -o $@ $(TOP)/tool/dbhash.c sqlite3.lo $(TLIBS) RSYNC_SRC = \ - $(TOP)/tool/sqlite3-rsync.c \ + $(TOP)/tool/sqlite3_rsync.c \ sqlite3.c RSYNC_OPT = \ @@ -711,7 +711,7 @@ RSYNC_OPT = \ -DSQLITE_OMIT_LOAD_EXTENSION \ -DSQLITE_OMIT_DEPRECATED -sqlite3-rsync$(TEXE): $(RSYNC_SRC) +sqlite3_rsync$(TEXE): $(RSYNC_SRC) $(TCC) -o $@ $(RSYNC_OPT) $(RSYNC_SRC) $(TLIBS) scrub$(TEXE): $(TOP)/ext/misc/scrub.c sqlite3.lo @@ -1558,8 +1558,8 @@ snapshot-tarball: sqlite3.c sqlite3rc.h # Build a ZIP archive containing various command-line tools. # -tool-zip: testfixture sqlite3 sqldiff sqlite3_analyzer sqlite3-rsync $(TOP)/tool/mktoolzip.tcl - strip sqlite3 sqldiff sqlite3_analyzer sqlite3-rsync +tool-zip: testfixture sqlite3 sqldiff sqlite3_analyzer sqlite3_rsync $(TOP)/tool/mktoolzip.tcl + strip sqlite3 sqldiff sqlite3_analyzer sqlite3_rsync ./testfixture $(TOP)/tool/mktoolzip.tcl # The next two rules are used to support the "threadtest" target. Building @@ -1645,7 +1645,7 @@ tidy: rm -f showjournal$(TEXE) showstat4$(TEXE) showwal$(TEXE) speedtest1$(TEXE) rm -f wordcount$(TEXE) changeset$(TEXE) version-info$(TEXE) rm -f *.dll *.lib *.exp *.def *.pc *.vsix *.so *.dylib pkgIndex.tcl - rm -f sqlite3_analyzer$(TEXE) sqlite3-rsync$(TEXE) + rm -f sqlite3_analyzer$(TEXE) sqlite3_rsync$(TEXE) rm -f mptester$(TEXE) rbu$(TEXE) srcck1$(TEXE) rm -f fuzzershell$(TEXE) fuzzcheck$(TEXE) sqldiff$(TEXE) dbhash$(TEXE) rm -f threadtest5$(TEXE) diff --git a/Makefile.msc b/Makefile.msc index 4a8abc9e3d..1e20849107 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1908,7 +1908,7 @@ dbhash.exe: $(TOP)\tool\dbhash.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) $(TOP)\tool\dbhash.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) RSYNC_SRC = \ - $(TOP)\tool\sqlite3-rsync.c \ + $(TOP)\tool\sqlite3_rsync.c \ $(SQLITE3C) RSYNC_OPT = \ @@ -1917,7 +1917,7 @@ RSYNC_OPT = \ -DSQLITE_OMIT_LOAD_EXTENSION \ -DSQLITE_OMIT_DEPRECATED -sqlite3-rsync.exe: $(RSYNC_SRC) $(LIBRESOBJS) +sqlite3_rsync.exe: $(RSYNC_SRC) $(LIBRESOBJS) $(LTLINK) $(RSYNC_OPT) $(NO_WARN) $(RSYNC_SRC) /link $(LDFLAGS) $(LTLINKOPTS) $(LIBRESOBJS) scrub.exe: $(TOP)\ext\misc\scrub.c $(SQLITE3C) $(SQLITE3H) @@ -2577,7 +2577,7 @@ extensiontest: testfixture.exe testloadext.dll @set PATH=$(LIBTCLPATH);$(PATH) .\testfixture.exe $(TOP)\test\loadext.test $(TESTOPTS) -tool-zip: testfixture.exe sqlite3.exe sqldiff.exe sqlite3_analyzer.exe sqlite3-rsync.exe $(TOP)\tool\mktoolzip.tcl +tool-zip: testfixture.exe sqlite3.exe sqldiff.exe sqlite3_analyzer.exe sqlite3_rsync.exe $(TOP)\tool\mktoolzip.tcl .\testfixture.exe $(TOP)\tool\mktoolzip.tcl coretestprogs: testfixture.exe sqlite3.exe @@ -2829,7 +2829,7 @@ clean: del /Q sqlite3.c sqlite3-*.c sqlite3.h 2>NUL del /Q sqlite3rc.h 2>NUL del /Q shell.c sqlite3ext.h sqlite3session.h 2>NUL - del /Q sqlite3_analyzer.exe sqlite3_analyzer.c sqlite3-rsync.exe 2>NUL + del /Q sqlite3_analyzer.exe sqlite3_analyzer.c sqlite3_rsync.exe 2>NUL del /Q sqlite-*-output.vsix 2>NUL del /Q fuzzershell.exe fuzzcheck.exe sqldiff.exe dbhash.exe 2>NUL del /Q sqltclsh.* 2>NUL diff --git a/doc/compile-for-unix.md b/doc/compile-for-unix.md index f35e013420..ff5e2111a7 100644 --- a/doc/compile-for-unix.md +++ b/doc/compile-for-unix.md @@ -39,7 +39,7 @@ are general and should work on most any modern unix platform. <li> `make sqlite3.c` <li> `make sqlite3` <li> `make sqldiff` - <li> `make sqlite3-rsync` + <li> `make sqlite3_rsync` <li> `make tclextension-install` <li> `make devtest` <li> `make releasetest` diff --git a/doc/compile-for-windows.md b/doc/compile-for-windows.md index acc7335618..fe06697c56 100644 --- a/doc/compile-for-windows.md +++ b/doc/compile-for-windows.md @@ -58,7 +58,7 @@ canonical source on a new Windows 11 PC, as of 2024-10-09: <li> `nmake /f makefile.msc sqlite3.c` <li> `nmake /f makefile.msc sqlite3.exe` <li> `nmake /f makefile.msc sqldiff.exe` - <li> `nmake /f makefile.msc sqlite3-rsync.exe` + <li> `nmake /f makefile.msc sqlite3_rsync.exe` <li> `nmake /f makefile.msc tclextension-install` <li> `nmake /f makefile.msc devtest` <li> `nmake /f makefile.msc releasetest` diff --git a/main.mk b/main.mk index f0f41736d1..3c2c379a39 100644 --- a/main.mk +++ b/main.mk @@ -569,7 +569,7 @@ dbhash$(EXE): $(TOP)/tool/dbhash.c sqlite3.c sqlite3.h $(TOP)/tool/dbhash.c sqlite3.c $(TLIBS) $(THREADLIB) RSYNC_SRC = \ - $(TOP)/tool/sqlite3-rsync.c \ + $(TOP)/tool/sqlite3_rsync.c \ sqlite3.c RSYNC_OPT = \ @@ -578,7 +578,7 @@ RSYNC_OPT = \ -DSQLITE_OMIT_LOAD_EXTENSION \ -DSQLITE_OMIT_DEPRECATED -sqlite3-rsync$(EXE): $(RSYNC_SRC) +sqlite3_rsync$(EXE): $(RSYNC_SRC) $(TCC) -o $@ $(RSYNC_OPT) $(RSYNC_SRC) $(TLIBS) scrub$(EXE): $(TOP)/ext/misc/scrub.c sqlite3.o @@ -1159,7 +1159,7 @@ clean: rm -f showjournal$(TEXE) showstat4$(TEXE) showwal$(TEXE) speedtest1$(TEXE) rm -f wordcount$(TEXE) changeset$(TEXE) version-info$(TEXE) rm -f *.dll *.lib *.exp *.def *.pc *.vsix - rm -f sqlite3_analyzer$(TEXE) sqlite3-rsync$(TEXE) + rm -f sqlite3_analyzer$(TEXE) sqlite3_rsync$(TEXE) rm -f mptester$(TEXE) rbu$(TEXE) srcck1$(TEXE) rm -f fuzzershell$(TEXE) fuzzcheck$(TEXE) sqldiff$(TEXE) dbhash$(TEXE) rm -f threadtest5$(TEXE) diff --git a/manifest b/manifest index d1fd7a5af5..31c14437a8 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C In\sthe\sunix\sMakefile,\sstrip\scompiled\sbinaries\sprior\sto\sadding\sthem\sto\sthe\ntool\sZIP\sarchive. -D 2024-10-16T10:20:30.451 +C Change\sthe\sname\sof\sthe\snew\sutility\sprogram\sfrom\ssqlite3-rsync\sto\nsqlite3_rsync\s-\sdash\schanged\sto\sunderscore\s-\sfor\sconsistency\swith\sthe\npreexisting\ssqlite3_analyzer. +D 2024-10-16T11:05:11.378 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 78e76e161981608a8c96ef92045d024ff8fced0b6d6ff442c1bafb93e2cf4467 +F Makefile.in c7dfd928d41c791ccaabdb87512bd95d826fc275884912b1b89ff3f96bb791aa F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 12d2c38554bddf5e698aba580eb863c762c0e1d46f5cad60d028e7270c33cdc2 +F Makefile.msc 58b69eda1faad5d475092b8aeffab9156ee4901a82db089b166607f2ec907ee4 F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -39,8 +39,8 @@ F configure 135e050689ea244477582e6d77cc7867dfcfe6e0f82e3eab3e47655a67035f8f x F configure.ac aca8ebf47b7644c473e11e599ea986eeb23860a8732a8812039ad961ef52a713 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd -F doc/compile-for-unix.md 37a3a7cfe32ed74b15d099f56e583f9e9df37b7109a8df880ff5e725424f8f17 -F doc/compile-for-windows.md 8e00693196087e3564a9a2bce642fa39febc1c901212832fbe0637681dada3db +F doc/compile-for-unix.md 90f17554cc3d19b2dae8142b5aeda1a8890692d5f2e091ed4a6f9b46b8f10f62 +F doc/compile-for-windows.md a9ab9f6c49763d63d177a386a9e53ee670101f80e8bcb73cafca438156229076 F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347bb123ce1ea4f F doc/jsonb.md 5fab4b8613aa9153fbeb6259297bd4697988af8b3d23900deba588fa7841456b F doc/lemon.html 8b266ff711d2ec7f867c3dca37634963f48a630329908cc282beebfa8c708706 @@ -690,7 +690,7 @@ F ext/wasm/wasmfs.make bc8bb227f35d5bd3863a7bd2233437c37472a0d81585979f058f9b9b5 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 0a55ebec3508ca1bdb593d86f3aa19d7fa42a2ddd3220703e6dc0a65f1338a43 +F main.mk c6501abe2d915ed1a2ec3d074e652c096177f93c50ac91f815c831e3417f9019 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -772,7 +772,7 @@ F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe F src/shell.c.in 0662f9bcf0725461778d0254a06150e5d61c08c5a87a7281ccdf45552050c79d -F src/sqlite.h.in 547508e419f83421fea0282dee4ea82fc575cc8bfd6ec13d333fc1bd82b9f70e +F src/sqlite.h.in add9e064d6b42af8f1a4a3322bddadec76696e520aedebd83e0d3211c15ac999 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 F src/sqliteInt.h ad02397dc4d22b77f9a331412d46e4c1e49459dd386fba8373fa148998e1e7d0 @@ -2150,7 +2150,7 @@ F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6 F tool/mksqlite3c.tcl c6acfdf4e4ef93478ff3ce3cd593e17abb03f446036ce710c3156bcfa18665e0 F tool/mksqlite3h.tcl d391cff7cad0a372ee1406faee9ccc7dad9cb80a0c95cae0f73d10dd26e06762 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b -F tool/mktoolzip.tcl ca5d73696b0c0b58a071add0fd082aaeb8050bd9072f34c69e68a60624d6a165 +F tool/mktoolzip.tcl 1b3383c6cd1ca3e1bfdf157d1383f29d6264b9600c381e682789c83617dc1014 F tool/mkvsix.tcl 67b40996a50f985a573278eea32fc5a5eb6110bdf14d33f1d8086e48c69e540a F tool/offsets.c 8ed2b344d33f06e71366a9b93ccedaa38c096cc1dbd4c3c26ad08c6115285845 F tool/omittest-msvc.tcl d6b8f501ac1d7798c4126065030f89812379012cad98a1735d6d7221492abc08 @@ -2178,8 +2178,8 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60 F tool/sqldiff.c 2a0987d183027c795ced13d6749061c1d2f38e24eddb428f56fa64c3a8f51e4b -F tool/sqlite3-rsync.c 7c78ba15afa0b929604adb91c94af8dbdf8cbe87be8a5cba5353af0e320ca65a F tool/sqlite3_analyzer.c.in 348ba349bbdc93c9866439f9f935d7284866a2a4e6898bc906ae1204ade56918 +F tool/sqlite3_rsync.c 2a2b79a0463d400696aa9429be5c0ddec6b1f7ceefa5fed7acfdc859a435221f w tool/sqlite3-rsync.c F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 F tool/src-verify.c d00f93263aa2fa6ba0cba0106d95458e6effb94fdb5fc634f56834f90c05bbb4 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f369de3d8fa34a403b5c9f6269f7e3fdb16a13784a70460c5032ad4e66615d64 -R a516d4923c3cbd6116cdc55d9e1d772d +P cd8ae6fd7166680a6d121d710ff9d722e3e14d1d3538fc8ea1ea2690035ba80e +R f59e8e07aac901ad2c06b0e923cde90c U drh -Z 650ee0412157fb1bcbcde3dfc36af0ff +Z 5c76d596036c1f5be231ab915cf12e72 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 7941bce70b..eaa5902a6f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cd8ae6fd7166680a6d121d710ff9d722e3e14d1d3538fc8ea1ea2690035ba80e +86e794cbaa5ae600635c933b46298a39f2465daf4c5cd1570f2a03e19ac08d9d diff --git a/src/sqlite.h.in b/src/sqlite.h.in index a46b1b6450..7097e6bb55 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -9352,7 +9352,7 @@ typedef struct sqlite3_backup sqlite3_backup; ** ** <ul> ** <li> The [VACUUM INTO] command. -** <li> The [sqlite3-rsync] utility program. +** <li> The [sqlite3_rsync] utility program. ** </ul> */ sqlite3_backup *sqlite3_backup_init( diff --git a/tool/mktoolzip.tcl b/tool/mktoolzip.tcl index 2f002accd1..a5951168a8 100644 --- a/tool/mktoolzip.tcl +++ b/tool/mktoolzip.tcl @@ -54,7 +54,7 @@ close $in scan $vers %d.%d.%d v1 v2 v3 set v2 [format 3%02d%02d00 $v2 $v3] set name sqlite-tools-$OS-$ARCH-$v2.zip -set toollist "sqlite3$EXE sqldiff$EXE sqlite3_analyzer$EXE sqlite3-rsync$EXE" +set toollist "sqlite3$EXE sqldiff$EXE sqlite3_analyzer$EXE sqlite3_rsync$EXE" puts "zip $name {*}$toollist" exec zip $name {*}$toollist puts "$name: [file size $name] bytes" diff --git a/tool/sqlite3-rsync.c b/tool/sqlite3_rsync.c similarity index 99% rename from tool/sqlite3-rsync.c rename to tool/sqlite3_rsync.c index 401c4b33ef..688ff1efe3 100644 --- a/tool/sqlite3-rsync.c +++ b/tool/sqlite3_rsync.c @@ -21,7 +21,7 @@ #include "sqlite3.h" static const char zUsage[] = - "sqlite3-rsync ORIGIN REPLICA ?OPTIONS?\n" + "sqlite3_rsync ORIGIN REPLICA ?OPTIONS?\n" "\n" "One of ORIGIN or REPLICA is a pathname to a database on the local\n" "machine and the other is of the form \"USER@HOST:PATH\" describing\n" @@ -30,7 +30,7 @@ static const char zUsage[] = "\n" "OPTIONS:\n" "\n" - " --exe PATH Name of the sqlite3-rsync program on the remote side\n" + " --exe PATH Name of the sqlite3_rsync program on the remote side\n" " --help Show this help screen\n" " --ssh PATH Name of the SSH program used to reach the remote side\n" " -v Verbose. Multiple v's for increasing output\n" @@ -1586,13 +1586,13 @@ static char *hostSeparator(const char *zIn){ ** ** Input formats: ** -** (1) sqlite3-rsync FILENAME1 USER@HOST:FILENAME2 +** (1) sqlite3_rsync FILENAME1 USER@HOST:FILENAME2 ** -** (2) sqlite3-rsync USER@HOST:FILENAME1 FILENAME2 +** (2) sqlite3_rsync USER@HOST:FILENAME1 FILENAME2 ** -** (3) sqlite3-rsync --origin FILENAME1 +** (3) sqlite3_rsync --origin FILENAME1 ** -** (4) sqlite3-rsync --replica FILENAME2 +** (4) sqlite3_rsync --replica FILENAME2 ** ** The user types (1) or (2). SSH launches (3) or (4). ** @@ -1616,7 +1616,7 @@ int main(int argc, char const * const *argv){ FILE *pOut = 0; int childPid = 0; const char *zSsh = "ssh"; - const char *zExe = "sqlite3-rsync"; + const char *zExe = "sqlite3_rsync"; char *zCmd = 0; sqlite3_int64 tmStart; sqlite3_int64 tmEnd; From 88282af521692b398b0d0cc58a8bdb220a8ff58c Mon Sep 17 00:00:00 2001 From: stephan <stephan@noemail.net> Date: Wed, 16 Oct 2024 14:05:39 +0000 Subject: [PATCH 77/77] Add has_tclconfig to the tidy makefile target. FossilOrigin-Name: 309e6d6f07d4169fbd6ea1d8b3d4809186ad9b7a2e69bbd33eedb9a55e831d68 --- Makefile.in | 2 +- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.in b/Makefile.in index ac1e627f52..e284a305ce 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1649,7 +1649,7 @@ tidy: rm -f mptester$(TEXE) rbu$(TEXE) srcck1$(TEXE) rm -f fuzzershell$(TEXE) fuzzcheck$(TEXE) sqldiff$(TEXE) dbhash$(TEXE) rm -f threadtest5$(TEXE) - rm -f src-verify$(BEXE) has_tclsh* + rm -f src-verify$(BEXE) has_tclsh* has_tclconfig # Removes build products and test logs. Retains ./configure outputs. # diff --git a/manifest b/manifest index 31c14437a8..ff584761e6 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Change\sthe\sname\sof\sthe\snew\sutility\sprogram\sfrom\ssqlite3-rsync\sto\nsqlite3_rsync\s-\sdash\schanged\sto\sunderscore\s-\sfor\sconsistency\swith\sthe\npreexisting\ssqlite3_analyzer. -D 2024-10-16T11:05:11.378 +C Add\shas_tclconfig\sto\sthe\stidy\smakefile\starget. +D 2024-10-16T14:05:39.591 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in c7dfd928d41c791ccaabdb87512bd95d826fc275884912b1b89ff3f96bb791aa +F Makefile.in fac8bdd16e874e06ed635af0671da745467c48ac18746f39b0ed5bea5eb7c3cd F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 58b69eda1faad5d475092b8aeffab9156ee4901a82db089b166607f2ec907ee4 F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 @@ -2179,7 +2179,7 @@ F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60 F tool/sqldiff.c 2a0987d183027c795ced13d6749061c1d2f38e24eddb428f56fa64c3a8f51e4b F tool/sqlite3_analyzer.c.in 348ba349bbdc93c9866439f9f935d7284866a2a4e6898bc906ae1204ade56918 -F tool/sqlite3_rsync.c 2a2b79a0463d400696aa9429be5c0ddec6b1f7ceefa5fed7acfdc859a435221f w tool/sqlite3-rsync.c +F tool/sqlite3_rsync.c 2a2b79a0463d400696aa9429be5c0ddec6b1f7ceefa5fed7acfdc859a435221f F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 F tool/src-verify.c d00f93263aa2fa6ba0cba0106d95458e6effb94fdb5fc634f56834f90c05bbb4 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P cd8ae6fd7166680a6d121d710ff9d722e3e14d1d3538fc8ea1ea2690035ba80e -R f59e8e07aac901ad2c06b0e923cde90c -U drh -Z 5c76d596036c1f5be231ab915cf12e72 +P 86e794cbaa5ae600635c933b46298a39f2465daf4c5cd1570f2a03e19ac08d9d +R 6d7f362ce02ddb09816fb4a964c469dc +U stephan +Z cd1d3303e56f0d3e84aeead9caca08c6 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index eaa5902a6f..7e839ca5a8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -86e794cbaa5ae600635c933b46298a39f2465daf4c5cd1570f2a03e19ac08d9d +309e6d6f07d4169fbd6ea1d8b3d4809186ad9b7a2e69bbd33eedb9a55e831d68