Repository navigation
Go: Fix database upgrade script #22783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 4 additions & 1 deletion
5
go/ql/lib/upgrades/5ff5325d274ae4f86defa195577bc7c1370b72fa/upgrade.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| description: Add @rangeelementexpr, grouping the loop variables of a range statement | ||
| compatibility: partial | ||
| compatibility: full | ||
|
|
||
| exprs.rel: run upgrade.qlo new_exprs | ||
| has_location.rel: run upgrade.qlo new_has_location |
69 changes: 69 additions & 0 deletions
69
go/ql/lib/upgrades/5ff5325d274ae4f86defa195577bc7c1370b72fa/upgrade.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| class Expr extends @expr { | ||
| string toString() { none() } | ||
| } | ||
|
|
||
| class ExprParent extends @exprparent { | ||
| string toString() { none() } | ||
| } | ||
|
|
||
| class RangeStmt extends @rangestmt { | ||
| string toString() { none() } | ||
| } | ||
|
|
||
| class Location extends @location { | ||
| string toString() { none() } | ||
| } | ||
|
|
||
| newtype TAddedExpr = TRangeElement(RangeStmt stmt) | ||
|
|
||
| module Fresh = QlBuiltins::NewEntity<TAddedExpr>; | ||
|
|
||
| class TNewExpr = @expr or Fresh::EntityId; | ||
|
|
||
| class NewExpr extends TNewExpr { | ||
| string toString() { none() } | ||
| } | ||
|
|
||
| class TNewExprParent = @exprparent or Fresh::EntityId; | ||
|
|
||
| class NewExprParent extends TNewExprParent { | ||
| string toString() { none() } | ||
| } | ||
|
|
||
| class TNewLocatable = @locatable or Fresh::EntityId; | ||
|
|
||
| class NewLocatable extends TNewLocatable { | ||
| string toString() { none() } | ||
| } | ||
|
|
||
| predicate isRangeElementChild(ExprParent parent, int idx, RangeStmt range) { | ||
| parent = range and | ||
| idx in [0 .. 1] | ||
| } | ||
|
|
||
| query predicate new_exprs(NewExpr id, int kind, NewExprParent parent, int idx) { | ||
| exists(RangeStmt range | | ||
| id = Fresh::map(TRangeElement(range)) and | ||
| kind = 55 and | ||
| parent = range and | ||
| idx = 0 | ||
| ) | ||
| or | ||
| exists(ExprParent oldParent | exprs(id, kind, oldParent, idx) | | ||
| exists(RangeStmt range | isRangeElementChild(oldParent, idx, range) | | ||
| parent = Fresh::map(TRangeElement(range)) | ||
| ) | ||
| or | ||
| not isRangeElementChild(oldParent, idx, _) and | ||
| parent = oldParent | ||
| ) | ||
| } | ||
|
|
||
| query predicate new_has_location(NewLocatable locatable, Location location) { | ||
| has_location(locatable, location) | ||
| or | ||
| exists(RangeStmt range | | ||
| locatable = Fresh::map(TRangeElement(range)) and | ||
| has_location(range, location) | ||
| ) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the upgrade script, the parent/child relation is expanded
Before
After
Perhaps, a downgrade script is needed as well that contracts the parent/child relation (and deletes the range_expression's).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was already done in the original commit.