From: drh <> Date: Sun, 2 Aug 2026 17:12:01 +0000 (+0000) Subject: Enhance the (unsupported) closure extension to support 64-bit "depth" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83e6d3e471787daf4507f1aeeaef81bd4c0cfcda;p=thirdparty%2Fsqlite.git Enhance the (unsupported) closure extension to support 64-bit "depth" values. [bugs:/info/2026-08-02T13:11:13Z|Bug 2026-08-02T13:11:13Z]. FossilOrigin-Name: fccfd5c410c875c35b72475d442c9c1d384deaef1859ba05586841d6c0909e0d --- diff --git a/ext/misc/closure.c b/ext/misc/closure.c index 16ac9a9c26..3abcfe648b 100644 --- a/ext/misc/closure.c +++ b/ext/misc/closure.c @@ -187,7 +187,7 @@ typedef struct closure_avl closure_avl; */ struct closure_avl { sqlite3_int64 id; /* Id of this entry in the table */ - int iGeneration; /* Which generation is this entry part of */ + sqlite3_int64 iGeneration; /* Which generation is this entry part of */ closure_avl *pList; /* A linked list of nodes */ closure_avl *pBefore; /* Other elements less than id */ closure_avl *pAfter; /* Other elements greater than id */ @@ -662,7 +662,7 @@ static int closureInsertNode( closure_queue *pQueue, /* Add new node to this queue */ closure_cursor *pCur, /* The cursor into which to add the node */ sqlite3_int64 id, /* The node ID */ - int iGeneration /* The generation number for this node */ + sqlite3_int64 iGeneration /* The generation number for this node */ ){ closure_avl *pNew = sqlite3_malloc64( sizeof(*pNew) ); if( pNew==0 ) return SQLITE_NOMEM; @@ -693,7 +693,7 @@ static int closureFilter( closure_cursor *pCur = (closure_cursor *)pVtabCursor; closure_vtab *pVtab = pCur->pVtab; sqlite3_int64 iRoot; - int mxGen = 999999999; + sqlite3_int64 mxGen = 999999999; char *zSql; sqlite3_stmt *pStmt; closure_avl *pAvl; @@ -713,7 +713,7 @@ static int closureFilter( } iRoot = sqlite3_value_int64(argv[0]); if( (idxNum & 0x000f0)!=0 ){ - mxGen = sqlite3_value_int(argv[(idxNum>>4)&0x0f]); + mxGen = sqlite3_value_int64(argv[(idxNum>>4)&0x0f]); if( (idxNum & 0x00002)!=0 ) mxGen--; } if( (idxNum & 0x00f00)!=0 ){ @@ -779,7 +779,7 @@ static int closureColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ break; } case CLOSURE_COL_DEPTH: { - sqlite3_result_int(ctx, pCur->pCurrent->iGeneration); + sqlite3_result_int64(ctx, pCur->pCurrent->iGeneration); break; } case CLOSURE_COL_ROOT: { diff --git a/manifest b/manifest index 62bc7c5210..635a7932dd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sallow\sthe\s(obsolete\sand\sunsupported)\sclosure\sextension\sto\suse\sitself\nas\sits\sown\sreference\stable.\n[bugs:/info/2026-08-02T13:07:40Z|Bug\s2026-08-02T13:07:40Z]. -D 2026-08-02T16:32:28.704 +C Enhance\sthe\s(unsupported)\sclosure\sextension\sto\ssupport\s64-bit\s"depth"\nvalues.\s[bugs:/info/2026-08-02T13:11:13Z|Bug\s2026-08-02T13:11:13Z]. +D 2026-08-02T17:12:01.022 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -369,7 +369,7 @@ F ext/misc/base85.c c713c7c81b05558c488cbdd8c68d612d5a97f9f0b8adf1167148dd7c89ce F ext/misc/basexx.c 89ad6b76558efbceb627afd5e2ef1d84b2e96d9aaf9b7ecb20e3d00b51be6fcf F ext/misc/btreeinfo.c 5fe97f798a9ee90e92b3031ed7969ec3f558661bb36b821c3ba045a17cfb951c F ext/misc/cksumvfs.c 83414e220e6cdfb29929f3154a24f32ff219d9794690bcb1b2db48f668651b35 -F ext/misc/closure.c fb13ff55ff19de5e35e08021afeae8d1ff2e1c1f46ff97cb765f26d17c940a3b +F ext/misc/closure.c e1f115c369790512634db8d19ef4f1e45b6c1658c8fe8a9c362aa65805c8a900 F ext/misc/completion.c 3f5db28e88c3313103b2dd86d910a2944fd500c46754e473493968ce81e994a4 F ext/misc/compress.c 5cc142aa82d1589a31c384657d0418c0eb0871348a2201e5dca32d24a0dd6654 F ext/misc/csv.c 5ca451b9ce77322c4ce8476766e7ed18160e5c8b19e7cab76e13006d631b9e8f @@ -977,7 +977,7 @@ F test/checkfault.test da6cb3d50247169efcb20bdf57863a3ccfa1d27d9e55cd324f0680096 F test/chunksize.test faea11c5d6df9d392252a8dd879e1b1d68c9d3e8b7909cbed8bcec3b60c706f1 F test/cksumvfs.test f9639eac08c06485ecf62eed3c558521d2ffe62de0774248d6862826740fe433 F test/close.test eccbad8ecd611d974cbf47278c3d4e5874faf02d811338d5d348af42d56d647c -F test/closure01.test 4e9b77fd90e143b44862c752599fe6c9c94a5996cea6953048a713ccfc27f97f +F test/closure01.test 3ce2739ebd732d9e84005de89bb2ec326198fd03250b9278be7dfd22176b6b61 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91 F test/collate1.test 0890fa372753b59eba53832d37328af815f6b8e4b16761823180eeb62c8e8f64 F test/collate2.test 471c6f74573382b89b0f8b88a05256faa52f7964f9e4799e76708a3b1ece6ba4 @@ -2218,8 +2218,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c -P be245e136a550faa7c84694156c40dc9778f50b00016892c29a2314bef14b6b7 -R 477404288df8619c8c1a404eae12e3af +P 5e347561c3f8d271bf47c44473fa4b51b87ccab91b40c33f5aad28990a26e9ba +R bd10eb8279d2014e2b963934b3496904 U drh -Z 32dff29b9a839514932f6aa2d100f0ae +Z d819623a3f1c0555578818bd773f452c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b62d7d202a..f3f5b0e5f4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5e347561c3f8d271bf47c44473fa4b51b87ccab91b40c33f5aad28990a26e9ba +fccfd5c410c875c35b72475d442c9c1d384deaef1859ba05586841d6c0909e0d diff --git a/test/closure01.test b/test/closure01.test index e4632cf8de..a5305ff8a0 100644 --- a/test/closure01.test +++ b/test/closure01.test @@ -321,4 +321,28 @@ do_catchsql_test 8.2 { SELECT id, depth FROM ct1 WHERE root=1 LIMIT 5; } {1 {no such table: ct1}} +# Bug 2026-08-02T13:11:13Z +# +do_execsql_test 9.1 { + CREATE TABLE grp(groupId INTEGER PRIMARY KEY, parentId INT); + INSERT INTO grp VALUES(1,null); + WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<10) + INSERT INTO grp SELECT n+1, n FROM c; + CREATE VIRTUAL TABLE ct1 USING transitive_closure( + tablename='grp', + idcolumn='groupId', + parentcolumn='parentId' + ); +} {} +do_execsql_test 9.2 { + SELECT id,depth FROM ct1 WHERE root=1 ORDER BY id; +} {1 0 2 1 3 2 4 3 5 4 6 5 7 6 8 7 9 8 10 9 11 10} +do_execsql_test 9.3 { + SELECT id,depth FROM ct1 WHERE root=1 AND depth<=4 ORDER BY id; +} {1 0 2 1 3 2 4 3 5 4} +do_execsql_test 9.4 { + SELECT id,depth FROM ct1 WHERE root=1 AND depth<=9223372036854775807 + ORDER BY id; +} {1 0 2 1 3 2 4 3 5 4 6 5 7 6 8 7 9 8 10 9 11 10} + finish_test