Commit f307ebb
sql: sort rulesForRelease versions in descending order
This fix addresses incorrect ordering in the rulesForReleases array
and adds a runtime check to prevent future ordering errors.
Bug Summary:
Location: pkg/sql/schemachanger/scplan/plan.go:157-162
Issue: The rulesForReleases array has incorrect ordering. Entries V25_2
and V25_3 are in ascending order, but the documented requirement
(line 158) and the search logic in GetRulesRegistryForRelease() require
descending order (newest first).
Current (incorrect):
{Latest}, // V25_4
{V25_2}, // ← wrong position
{V25_3}, // ← wrong position
Should be (descending):
{Latest}, // V25_4
{V25_3}, // ← correct
{V25_2}, // ← correct
The GetRulesRegistryForRelease function iterates through rulesForReleases
in order and returns the first entry where activeVersion.IsActive() is
true. With ascending order, it would incorrectly return V25_2 rules when
V25_3 is active.
Changes:
- Fixed ordering in pkg/sql/schemachanger/scplan/plan.go
- Added init-time assertion to validate descending order
- Fixed trailing space in error message in pkg/cli/declarative_print_rules.go
Epic: None
Release note (bug fix): Fix rulesForReleases ordering to correctly match
cluster versions with schema changer rule sets.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 40466eb commit f307ebb
File tree
4 files changed
+285
-254
lines changed- pkg
- cli
- testdata/declarative-rules
- sql/schemachanger/scplan
4 files changed
+285
-254
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
0 commit comments