Skip to content

Commit 85886ee

Browse files
redsun82Copilot
andcommitted
Rust: add DB upgrade/downgrade scripts and change note for ra_ap 0.0.347
The schema delta for ra_ap 0.0.347 adds the new node kinds DerefPat, ImplRestriction, IncludeBytesExpr, MutRestriction, NotNull, PatternTypeRepr and VisibilityInner, moves a Visibility path onto the new VisibilityInner, replaces the text-less FormatArgsArgName placeholder with a Name, and adds attrs to the inline assembly nodes, mut_restriction to Struct/TupleField and impl_restriction to Trait. The upgrade repurposes the old format-arg placeholder ids as Name ids (avoiding dangling refs) and synthesises a VisibilityInner per visibility with a path. The downgrade rejoins the visibility path, repurposes ids back to the placeholder, and scrubs the locations of the deleted node kinds. compatibility is partial: the new node kinds are empty on old DBs, so a rebuild yields strictly-better results while existing queries keep working. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
1 parent f334221 commit 85886ee

9 files changed

Lines changed: 14881 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
class Element extends @element {
2+
string toString() { none() }
3+
}
4+
5+
class Location extends @location_default {
6+
string toString() { none() }
7+
}
8+
9+
// Genuinely-new node kinds with no representation in the old schema. Their own child relations are
10+
// dropped via `delete` in upgrade.properties; here we additionally drop their locations so no
11+
// dangling `locatable_locations` rows remain.
12+
private predicate deletedElement(Element id) {
13+
deref_pats(id) or
14+
not_nulls(id) or
15+
include_bytes_exprs(id) or
16+
pattern_type_reprs(id) or
17+
impl_restrictions(id) or
18+
mut_restrictions(id) or
19+
visibility_inners(id)
20+
}
21+
22+
// A `@name` used as a format argument's name. The old schema represents these as dedicated text-less
23+
// `@format_args_arg_name` placeholders, so we repurpose these ids into that entity table and drop
24+
// them (and their text) from `names`/`name_texts`.
25+
private predicate formatArgName(Element name) { format_args_arg_names(_, name) }
26+
27+
// The new schema inserts a `VisibilityInner` node between `Visibility` and its path; the old schema
28+
// stores the path directly on the `Visibility`, so we rejoin the two hops.
29+
query predicate new_visibility_paths(Element visibility, Element path) {
30+
exists(Element inner |
31+
visibility_visibility_inners(visibility, inner) and
32+
visibility_inner_paths(inner, path)
33+
)
34+
}
35+
36+
query predicate new_format_args_arg_names(Element id) { formatArgName(id) }
37+
38+
query predicate new_format_args_arg_arg_names(Element arg, Element name) {
39+
format_args_arg_names(arg, name)
40+
}
41+
42+
query predicate new_names(Element id) { names(id) and not formatArgName(id) }
43+
44+
query predicate new_name_texts(Element id, string text) {
45+
name_texts(id, text) and not formatArgName(id)
46+
}
47+
48+
query predicate new_locatable_locations(Element id, Location location) {
49+
locatable_locations(id, location) and not deletedElement(id)
50+
}

0 commit comments

Comments
 (0)