Rust: Add DB upgrade script

This commit is contained in:
Tom Hvitved
2026-01-13 09:35:07 +01:00
parent 5d5bad6cd4
commit 4cc4717381
4 changed files with 7181 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
description: Merge the relations `macro_block_exprs` and `block_exprs`
compatibility: full
macro_block_exprs.rel: delete
macro_block_expr_statements.rel: delete
macro_block_expr_tail_exprs.rel: delete
block_exprs.rel: run upgrade.ql new_block_exprs
stmt_lists.rel: run upgrade.ql new_stmt_lists
block_expr_stmt_lists.rel: run upgrade.ql new_block_expr_stmt_lists
stmt_list_statements.rel: run upgrade.ql new_stmt_list_statements
stmt_list_tail_exprs.rel: run upgrade.ql new_stmt_list_tail_exprs
macro_call_macro_call_expansions.rel: run upgrade.ql new_macro_call_macro_call_expansions

View File

@@ -0,0 +1,62 @@
class Element extends @element {
string toString() { none() }
}
newtype TAddedElement =
TBlockExpr(Element macroBlock) { macro_block_exprs(macroBlock) } or
TStmtList(Element macroBlock) { macro_block_exprs(macroBlock) }
module Fresh = QlBuiltins::NewEntity<TAddedElement>;
class TNewElement = @element or Fresh::EntityId;
class NewElement extends TNewElement {
string toString() { none() }
}
query predicate new_block_exprs(NewElement id) {
block_exprs(id) or
id = Fresh::map(TBlockExpr(_))
}
query predicate new_stmt_lists(NewElement id) {
stmt_lists(id) or
id = Fresh::map(TStmtList(_))
}
query predicate new_block_expr_stmt_lists(NewElement id, NewElement list) {
block_expr_stmt_lists(id, list)
or
exists(Element macroBlock |
id = Fresh::map(TBlockExpr(macroBlock)) and
list = Fresh::map(TStmtList(macroBlock))
)
}
query predicate new_stmt_list_statements(NewElement id, int index, Element stmt) {
stmt_list_statements(id, index, stmt)
or
exists(Element macroBlock |
id = Fresh::map(TStmtList(macroBlock)) and
macro_block_expr_statements(macroBlock, index, stmt)
)
}
query predicate new_stmt_list_tail_exprs(NewElement id, Element expr) {
stmt_list_tail_exprs(id, expr)
or
exists(Element macroBlock |
id = Fresh::map(TStmtList(macroBlock)) and
macro_block_expr_tail_exprs(macroBlock, expr)
)
}
query predicate new_macro_call_macro_call_expansions(NewElement id, NewElement expansion) {
macro_call_macro_call_expansions(id, expansion) and
not macro_block_exprs(expansion)
or
exists(Element macroBlock |
expansion = Fresh::map(TBlockExpr(macroBlock)) and
macro_call_macro_call_expansions(id, macroBlock)
)
}