Skip to content

Commit f307ebb

Browse files
celialaclaude
andcommitted
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 <[email protected]>
1 parent 40466eb commit f307ebb

File tree

4 files changed

+285
-254
lines changed

4 files changed

+285
-254
lines changed

pkg/cli/declarative_print_rules.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ a given corpus file.
3737
Version: version,
3838
})
3939
if rules == nil {
40-
fmt.Printf("unsupported version number, the supported versions are: \n")
40+
fmt.Printf("unsupported version number, the supported versions are:\n")
4141
for _, v := range scplan.GetReleasesForRulesRegistries() {
4242
fmt.Printf(" %s\n", v)
4343
}

0 commit comments

Comments
 (0)