From 36f904f06574c637a9e28abd7b2be417c45abc83 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 17 Jun 2022 15:11:31 +0000 Subject: [PATCH 1/4] Fix the virtual table detection mechanism to avoid false-positives that were blocking all failures. Then fix a few of the additional problems that are revealed by that fix. More fixes are needed. FossilOrigin-Name: 42b2e6676fed1508ea0ba17c292e83134825469735700da97817c45d45c54e66 --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- test/fuzzcheck.c | 10 +++++++++- test/fuzzinvariants.c | 18 +++++++++++++----- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index e03f7be9c0..ff0e27eca6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\snew\s--query-invariants\soption\son\sfuzzcheck\sso\sthat\sit\sdoes\snot\nuse\san\sunprotected\ssqlite3_value\sobject\sas\san\sargument\sto\ssqlite3_value_int64(). -D 2022-06-17T12:25:33.660 +C Fix\sthe\svirtual\stable\sdetection\smechanism\sto\savoid\sfalse-positives\sthat\swere\nblocking\sall\sfailures.\s\sThen\sfix\sa\sfew\sof\sthe\sadditional\sproblems\sthat\sare\nrevealed\sby\sthat\sfix.\s\sMore\sfixes\sare\sneeded. +D 2022-06-17T15:11:31.795 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1085,7 +1085,7 @@ F test/fuzz3.test 9c813e6613b837cb7a277b0383cd66bfa07042b4cf0317157c35852f30043c F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2 -F test/fuzzcheck.c 609152902fb51e718554719f44d13677f68c53d98d15fb359fbefdd134be153b +F test/fuzzcheck.c b18b6ae117937deac68793385d41ff6d73abcd1bf66f66b5b0cb4151d170c8db F test/fuzzdata1.db 3e86d9cf5aea68ddb8e27c02d7dfdaa226347426c7eb814918e4d95475bf8517 F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -1097,7 +1097,7 @@ F test/fuzzdata8.db ca9a97f401b06b0d5376139ec7e1f9e773e13345a9a2d9ccc0032cdbfede F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8 F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14 F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc -F test/fuzzinvariants.c e7b413a2526d9f702a2bfea5cbe5bdb7cb88c89b433e3e8ad931888bb5597bd0 +F test/fuzzinvariants.c 227ab751f1417bbc135389f2e394ab3f97b4940343aea006283b8888e8166d58 F test/gcfault.test dd28c228a38976d6336a3fc42d7e5f1ad060cb8c F test/gencol1.test cc0dbb0ee116e5602e18ea7d47f2a0f76b26e09a823b7c36ef254370c2b0f3c1 F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 @@ -1978,8 +1978,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f23a429d4153518d37387e121f22a30b22e2b31e126ad168e72049a96be86269 -R 10f66102aac19f279bc67099d1ccf16a +P d9f820151d74a690b5fa560597a5b3ace20165a112e1b58cb4a7c47b42745643 +R 3bffc86c82ff136a0c0c4c0a76be66e5 +T *branch * query-invariants +T *sym-query-invariants * +T -sym-trunk * U drh -Z 8cec7a3e8591667bdea33d0479acc5f3 +Z 8dc954db016e69d2c5b338fff670ae32 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a071fa432c..82f853b1ff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d9f820151d74a690b5fa560597a5b3ace20165a112e1b58cb4a7c47b42745643 \ No newline at end of file +42b2e6676fed1508ea0ba17c292e83134825469735700da97817c45d45c54e66 \ No newline at end of file diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index d09afe6a00..995137838c 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -896,9 +896,17 @@ static int block_troublesome_sql( } case SQLITE_FUNCTION: { static const char *azBadFuncs[] = { + "current_date", + "current_time", + "current_timestamp", + "date", + "datetime", + "julianday", "random", "randomblob", - "rtreedepth", + "strftime", + "time", + "unixepoch", }; int i; for(i=0; i100 ) return SQLITE_DONE; zTest = fuzz_invariant_sql(pStmt, iCnt); if( zTest==0 ) return SQLITE_DONE; rc = sqlite3_prepare_v2(db, zTest, -1, &pTestStmt, 0); @@ -88,7 +91,7 @@ int fuzz_invariant( sqlite3_free(zTest); nCol = sqlite3_column_count(pStmt); for(i=0; i=2 ){ char *zSql = sqlite3_expanded_sql(pTestStmt); @@ -101,7 +104,7 @@ int fuzz_invariant( } if( i>=nCol ) break; } - if( rc!=SQLITE_ROW ){ + if( rc!=SQLITE_ROW && rc!=SQLITE_NOMEM ){ /* No matching output row found */ sqlite3_stmt *pCk = 0; rc = sqlite3_prepare_v2(db, "PRAGMA integrity_check", -1, &pCk, 0); @@ -123,7 +126,10 @@ int fuzz_invariant( sqlite3_finalize(pCk); rc = sqlite3_prepare_v2(db, "SELECT 1 FROM bytecode(?1) WHERE opcode='VOpen'", -1, &pCk, 0); - if( rc==SQLITE_OK ) rc = sqlite3_step(pCk); + if( rc==SQLITE_OK ){ + sqlite3_bind_pointer(pCk, 1, pStmt, "stmt-pointer", 0); + rc = sqlite3_step(pCk); + } sqlite3_finalize(pCk); if( rc==SQLITE_DONE ){ reportInvariantFailed(pStmt, pTestStmt, iRow); @@ -155,6 +161,7 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){ int mxCnt; int bDistinct = 0; int bOrderBy = 0; + int nParam = sqlite3_bind_parameter_count(pStmt); switch( iCnt % 4 ){ case 1: bDistinct = 1; break; @@ -196,7 +203,8 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){ if( sqlite3_column_type(pStmt, i)==SQLITE_NULL ){ sqlite3_str_appendf(pTest, " %s \"%w\" ISNULL", zAnd, zColName); }else{ - sqlite3_str_appendf(pTest, " %s \"%w\"=?%d", zAnd, zColName, i+1); + sqlite3_str_appendf(pTest, " %s \"%w\"=?%d", zAnd, zColName, + i+1+nParam); } zAnd = "AND"; } @@ -253,7 +261,7 @@ static void printRow(sqlite3_stmt *pStmt, int iRow){ int i, nCol; nCol = sqlite3_column_count(pStmt); for(i=0; i Date: Fri, 17 Jun 2022 15:52:43 +0000 Subject: [PATCH 2/4] Only run query-invariant checks after the original query has run to completion, so that we know it does not error-out on a subsequent row. FossilOrigin-Name: d1fc857bb8dcd5914f5a9bbcc4efe5f4abe19a190e42e2c923b28327a95e4de6 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- test/fuzzcheck.c | 43 ++++++++++++++++++++++++------------------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/manifest b/manifest index ff0e27eca6..39989145ee 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\svirtual\stable\sdetection\smechanism\sto\savoid\sfalse-positives\sthat\swere\nblocking\sall\sfailures.\s\sThen\sfix\sa\sfew\sof\sthe\sadditional\sproblems\sthat\sare\nrevealed\sby\sthat\sfix.\s\sMore\sfixes\sare\sneeded. -D 2022-06-17T15:11:31.795 +C Only\srun\squery-invariant\schecks\safter\sthe\soriginal\squery\shas\srun\sto\scompletion,\nso\sthat\swe\sknow\sit\sdoes\snot\serror-out\son\sa\ssubsequent\srow. +D 2022-06-17T15:52:43.687 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1085,7 +1085,7 @@ F test/fuzz3.test 9c813e6613b837cb7a277b0383cd66bfa07042b4cf0317157c35852f30043c F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2 -F test/fuzzcheck.c b18b6ae117937deac68793385d41ff6d73abcd1bf66f66b5b0cb4151d170c8db +F test/fuzzcheck.c 873ea79afe6ffa015bb92bc2b6c8b3b0ae19939f05a2bb170c72554cee7efca6 F test/fuzzdata1.db 3e86d9cf5aea68ddb8e27c02d7dfdaa226347426c7eb814918e4d95475bf8517 F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -1978,11 +1978,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d9f820151d74a690b5fa560597a5b3ace20165a112e1b58cb4a7c47b42745643 -R 3bffc86c82ff136a0c0c4c0a76be66e5 -T *branch * query-invariants -T *sym-query-invariants * -T -sym-trunk * +P 42b2e6676fed1508ea0ba17c292e83134825469735700da97817c45d45c54e66 +R 2ffa9998fa10a6490052b5721ce71198 U drh -Z 8dc954db016e69d2c5b338fff670ae32 +Z e096bb1569d84715c095fddd40356f9f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 82f853b1ff..dd609bff2f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -42b2e6676fed1508ea0ba17c292e83134825469735700da97817c45d45c54e66 \ No newline at end of file +d1fc857bb8dcd5914f5a9bbcc4efe5f4abe19a190e42e2c923b28327a95e4de6 \ No newline at end of file diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index 995137838c..dcce95e936 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -957,24 +957,6 @@ static int runDbSql(sqlite3 *db, const char *zSql, unsigned int *pBtsFlags){ int nRow = 0; while( (rc = sqlite3_step(pStmt))==SQLITE_ROW ){ nRow++; - if( (*pBtsFlags)==BTS_SELECT - && g.doInvariantChecks - && !sqlite3_stmt_isexplain(pStmt) - ){ - int iCnt = 0; - for(iCnt=0; iCnt<99999; iCnt++){ - rc = fuzz_invariant(db, pStmt, iCnt, nRow, &bCorrupt, eVerbosity); - if( rc==SQLITE_DONE ) break; - if( rc!=SQLITE_ERROR ) g.nInvariant++; - if( eVerbosity>0 ){ - if( rc==SQLITE_OK ){ - printf("invariant-check: ok\n"); - }else if( rc==SQLITE_CORRUPT ){ - printf("invariant-check: failed due to database corruption\n"); - } - } - } - } if( eVerbosity>=5 ){ int j; for(j=0; j=5 ) */ } /* End while( SQLITE_ROW */ - if( rc!=SQLITE_DONE && eVerbosity>=4 ){ + if( rc==SQLITE_DONE ){ + if( (*pBtsFlags)==BTS_SELECT + && g.doInvariantChecks + && !sqlite3_stmt_isexplain(pStmt) + && nRow>0 + ){ + sqlite3_reset(pStmt); + while( sqlite3_step(pStmt)==SQLITE_ROW ){ + int iCnt = 0; + for(iCnt=0; iCnt<99999; iCnt++){ + rc = fuzz_invariant(db, pStmt, iCnt, nRow, &bCorrupt, eVerbosity); + if( rc==SQLITE_DONE ) break; + if( rc!=SQLITE_ERROR ) g.nInvariant++; + if( eVerbosity>0 ){ + if( rc==SQLITE_OK ){ + printf("invariant-check: ok\n"); + }else if( rc==SQLITE_CORRUPT ){ + printf("invariant-check: failed due to database corruption\n"); + } + } + } + } + } + }else if( eVerbosity>=4 ){ printf("SQL-ERROR: (%d) %s\n", rc, sqlite3_errmsg(db)); fflush(stdout); } From 63880362ed0cc7cf95371638b3f4baeb603df036 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 17 Jun 2022 16:09:47 +0000 Subject: [PATCH 3/4] Improve query-invariants to the point that it would have discovered the [f23a429d4153518d] bug if that bug had not already been fixed. FossilOrigin-Name: 2a7251ed9c4c959b6df75172159c6b4445e1c2212e357d2c49ab8fa19cb3ac11 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fuzzcheck.c | 8 ++++++-- test/fuzzinvariants.c | 12 +++++------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 39989145ee..8b29566d82 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Only\srun\squery-invariant\schecks\safter\sthe\soriginal\squery\shas\srun\sto\scompletion,\nso\sthat\swe\sknow\sit\sdoes\snot\serror-out\son\sa\ssubsequent\srow. -D 2022-06-17T15:52:43.687 +C Improve\squery-invariants\sto\sthe\spoint\sthat\sit\swould\shave\sdiscovered\sthe\n[f23a429d4153518d]\sbug\sif\sthat\sbug\shad\snot\salready\sbeen\sfixed. +D 2022-06-17T16:09:47.744 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1085,7 +1085,7 @@ F test/fuzz3.test 9c813e6613b837cb7a277b0383cd66bfa07042b4cf0317157c35852f30043c F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634 F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830 F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2 -F test/fuzzcheck.c 873ea79afe6ffa015bb92bc2b6c8b3b0ae19939f05a2bb170c72554cee7efca6 +F test/fuzzcheck.c c50f105aaa5f5cc5ca5248ac8423ec316fbf6a9540236bcbf55999ff364bb49c F test/fuzzdata1.db 3e86d9cf5aea68ddb8e27c02d7dfdaa226347426c7eb814918e4d95475bf8517 F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -1097,7 +1097,7 @@ F test/fuzzdata8.db ca9a97f401b06b0d5376139ec7e1f9e773e13345a9a2d9ccc0032cdbfede F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8 F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14 F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc -F test/fuzzinvariants.c 227ab751f1417bbc135389f2e394ab3f97b4940343aea006283b8888e8166d58 +F test/fuzzinvariants.c df8e8e41e1b3d6a4b2d4af7971b6da546291935344b8b2ddd44a51f12dac773f F test/gcfault.test dd28c228a38976d6336a3fc42d7e5f1ad060cb8c F test/gencol1.test cc0dbb0ee116e5602e18ea7d47f2a0f76b26e09a823b7c36ef254370c2b0f3c1 F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 @@ -1978,8 +1978,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 42b2e6676fed1508ea0ba17c292e83134825469735700da97817c45d45c54e66 -R 2ffa9998fa10a6490052b5721ce71198 +P d1fc857bb8dcd5914f5a9bbcc4efe5f4abe19a190e42e2c923b28327a95e4de6 +R 55960cb339a18680e19e442b178a6dfb U drh -Z e096bb1569d84715c095fddd40356f9f +Z edf9c8ab3b73ba6da0e22cf8e8453a3c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index dd609bff2f..56dec9bb2d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d1fc857bb8dcd5914f5a9bbcc4efe5f4abe19a190e42e2c923b28327a95e4de6 \ No newline at end of file +2a7251ed9c4c959b6df75172159c6b4445e1c2212e357d2c49ab8fa19cb3ac11 \ No newline at end of file diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index dcce95e936..063295ab20 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -934,6 +934,7 @@ int fuzz_invariant( sqlite3_stmt *pStmt, /* Test statement stopped on an SQLITE_ROW */ int iCnt, /* Invariant sequence number, starting at 0 */ int iRow, /* The row number for pStmt */ + int nRow, /* Total number of output rows */ int *pbCorrupt, /* IN/OUT: Flag indicating a corrupt database file */ int eVerbosity /* How much debugging output */ ); @@ -957,7 +958,7 @@ static int runDbSql(sqlite3 *db, const char *zSql, unsigned int *pBtsFlags){ int nRow = 0; while( (rc = sqlite3_step(pStmt))==SQLITE_ROW ){ nRow++; - if( eVerbosity>=5 ){ + if( eVerbosity>=4 ){ int j; for(j=0; j0 ){ + int iRow = 0; sqlite3_reset(pStmt); while( sqlite3_step(pStmt)==SQLITE_ROW ){ int iCnt = 0; + iRow++; for(iCnt=0; iCnt<99999; iCnt++){ - rc = fuzz_invariant(db, pStmt, iCnt, nRow, &bCorrupt, eVerbosity); + rc = fuzz_invariant(db, pStmt, iCnt, iRow, nRow, + &bCorrupt, eVerbosity); if( rc==SQLITE_DONE ) break; if( rc!=SQLITE_ERROR ) g.nInvariant++; if( eVerbosity>0 ){ diff --git a/test/fuzzinvariants.c b/test/fuzzinvariants.c index 05f8cf9b4e..807574ee3d 100644 --- a/test/fuzzinvariants.c +++ b/test/fuzzinvariants.c @@ -62,7 +62,8 @@ int fuzz_invariant( sqlite3 *db, /* The database connection */ sqlite3_stmt *pStmt, /* Test statement stopped on an SQLITE_ROW */ int iCnt, /* Invariant sequence number, starting at 0 */ - int iRow, /* The row number for pStmt */ + int iRow, /* Current row number */ + int nRow, /* Number of output rows from pStmt */ int *pbCorrupt, /* IN/OUT: Flag indicating a corrupt database file */ int eVerbosity /* How much debugging output */ ){ @@ -163,17 +164,14 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){ int bOrderBy = 0; int nParam = sqlite3_bind_parameter_count(pStmt); + iCnt++; switch( iCnt % 4 ){ case 1: bDistinct = 1; break; case 2: bOrderBy = 1; break; case 3: bDistinct = bOrderBy = 1; break; } iCnt /= 4; - if( nCol==1 ){ - mxCnt = 0; - }else{ - mxCnt = nCol; - } + mxCnt = nCol; if( iCnt<0 || iCnt>mxCnt ) return 0; zIn = sqlite3_sql(pStmt); if( zIn==0 ) return 0; @@ -199,7 +197,7 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){ ** WHERE clause. */ continue; } - if( iCnt>0 && i+1!=iCnt ) continue; + if( i+1!=iCnt ) continue; if( sqlite3_column_type(pStmt, i)==SQLITE_NULL ){ sqlite3_str_appendf(pTest, " %s \"%w\" ISNULL", zAnd, zColName); }else{ From ea64cb31a59451dfb6ed7010d96ec8db5b483487 Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 17 Jun 2022 16:32:21 +0000 Subject: [PATCH 4/4] Allow integers and floating point numbers to compare equal. FossilOrigin-Name: 0fe2e465ba931d4bceaf171693d2ee7af45a5f96840e65e9d4ee4a2e60f155d8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/fuzzinvariants.c | 12 +++++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 8b29566d82..f7f8ab1ec3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\squery-invariants\sto\sthe\spoint\sthat\sit\swould\shave\sdiscovered\sthe\n[f23a429d4153518d]\sbug\sif\sthat\sbug\shad\snot\salready\sbeen\sfixed. -D 2022-06-17T16:09:47.744 +C Allow\sintegers\sand\sfloating\spoint\snumbers\sto\scompare\sequal. +D 2022-06-17T16:32:21.419 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1097,7 +1097,7 @@ F test/fuzzdata8.db ca9a97f401b06b0d5376139ec7e1f9e773e13345a9a2d9ccc0032cdbfede F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8 F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14 F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc -F test/fuzzinvariants.c df8e8e41e1b3d6a4b2d4af7971b6da546291935344b8b2ddd44a51f12dac773f +F test/fuzzinvariants.c e1c844a9234329f8e6f84acc4c32c0657aacfde08d69d90cb9c24d332062994d F test/gcfault.test dd28c228a38976d6336a3fc42d7e5f1ad060cb8c F test/gencol1.test cc0dbb0ee116e5602e18ea7d47f2a0f76b26e09a823b7c36ef254370c2b0f3c1 F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 @@ -1978,8 +1978,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d1fc857bb8dcd5914f5a9bbcc4efe5f4abe19a190e42e2c923b28327a95e4de6 -R 55960cb339a18680e19e442b178a6dfb +P 2a7251ed9c4c959b6df75172159c6b4445e1c2212e357d2c49ab8fa19cb3ac11 +R a7fd0f7a55560bceea65dad05280da0e U drh -Z edf9c8ab3b73ba6da0e22cf8e8453a3c +Z 41ab90bc026d0fa40109a7c68e53d405 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 56dec9bb2d..d2890c602d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2a7251ed9c4c959b6df75172159c6b4445e1c2212e357d2c49ab8fa19cb3ac11 \ No newline at end of file +0fe2e465ba931d4bceaf171693d2ee7af45a5f96840e65e9d4ee4a2e60f155d8 \ No newline at end of file diff --git a/test/fuzzinvariants.c b/test/fuzzinvariants.c index 807574ee3d..b40fa1fa55 100644 --- a/test/fuzzinvariants.c +++ b/test/fuzzinvariants.c @@ -218,7 +218,17 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){ */ static int sameValue(sqlite3_stmt *pS1, int i1, sqlite3_stmt *pS2, int i2){ int x = 1; - if( sqlite3_column_type(pS1,i1)!=sqlite3_column_type(pS2,i2) ) return 0; + int t1 = sqlite3_column_type(pS1,i1); + int t2 = sqlite3_column_type(pS2,i2); + if( t1!=t2 ){ + if( (t1==SQLITE_INTEGER && t2==SQLITE_FLOAT) + || (t1==SQLITE_FLOAT && t2==SQLITE_INTEGER) + ){ + /* Comparison of numerics is ok */ + }else{ + return 0; + } + } switch( sqlite3_column_type(pS1,i1) ){ case SQLITE_INTEGER: { x = sqlite3_column_int64(pS1,i1)==sqlite3_column_int64(pS2,i2);