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.
Commit
60debc7ed76b9d8fc0aa9ce1be6793cbb67609c2b1709c39c299249c81b5b306
Parent
a8aaed421614410…
1 file changed
+1
+1
| --- src/descendants.c | ||
| +++ src/descendants.c | ||
| @@ -249,10 +249,11 @@ | ||
| 249 | 249 | " )" |
| 250 | 250 | " SELECT ancestor.rid FROM ancestor" |
| 251 | 251 | " WHERE EXISTS(SELECT 1 FROM tagxref" |
| 252 | 252 | " WHERE tagid=%d AND tagxref.rid=+ancestor.rid" |
| 253 | 253 | " AND value=%Q AND tagtype>0)" |
| 254 | + " ORDER BY mtime DESC" | |
| 254 | 255 | " LIMIT 1", |
| 255 | 256 | rid, rid, TAG_BRANCH, zBranch |
| 256 | 257 | ); |
| 257 | 258 | } |
| 258 | 259 | |
| 259 | 260 |
| --- 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 |