Fossil SCM

Fix the query in the compute_youngest_ancestor_in_branch() routine so that it has an ORDER BY to make it safe. The new order-by-subquery optimization in SQLite turns that ORDER BY into a no-op, so there is no performance impact.

drh 2024-08-16 19:24 trunk
Commit 60debc7ed76b9d8fc0aa9ce1be6793cbb67609c2b1709c39c299249c81b5b306
1 file changed +1
--- src/descendants.c
+++ src/descendants.c
@@ -249,10 +249,11 @@
249249
" )"
250250
" SELECT ancestor.rid FROM ancestor"
251251
" WHERE EXISTS(SELECT 1 FROM tagxref"
252252
" WHERE tagid=%d AND tagxref.rid=+ancestor.rid"
253253
" AND value=%Q AND tagtype>0)"
254
+ " ORDER BY mtime DESC"
254255
" LIMIT 1",
255256
rid, rid, TAG_BRANCH, zBranch
256257
);
257258
}
258259
259260
--- src/descendants.c
+++ src/descendants.c
@@ -249,10 +249,11 @@
249 " )"
250 " SELECT ancestor.rid FROM ancestor"
251 " WHERE EXISTS(SELECT 1 FROM tagxref"
252 " WHERE tagid=%d AND tagxref.rid=+ancestor.rid"
253 " AND value=%Q AND tagtype>0)"
 
254 " LIMIT 1",
255 rid, rid, TAG_BRANCH, zBranch
256 );
257 }
258
259
--- src/descendants.c
+++ src/descendants.c
@@ -249,10 +249,11 @@
249 " )"
250 " SELECT ancestor.rid FROM ancestor"
251 " WHERE EXISTS(SELECT 1 FROM tagxref"
252 " WHERE tagid=%d AND tagxref.rid=+ancestor.rid"
253 " AND value=%Q AND tagtype>0)"
254 " ORDER BY mtime DESC"
255 " LIMIT 1",
256 rid, rid, TAG_BRANCH, zBranch
257 );
258 }
259
260

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button