Skip to content

Commit e185915

Browse files
authored
Merge pull request #152287 from cockroachdb/blathers/backport-release-25.3-151878
release-25.3: roachtest: allow for missing system table column during MVT fingerprinting
2 parents 1bf10e5 + b5d6ff6 commit e185915

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

pkg/cmd/roachtest/tests/mixed_version_backup.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,9 @@ func (sr *systemTableRow) skip() bool {
693693
// callback will be passed the value associated with that column, if
694694
// found, and its return value overwrites the value for that
695695
// column. The callback is not called if the column name is invalid.
696-
func (sr *systemTableRow) processColumn(column string, fn func(interface{}) interface{}) {
696+
func (sr *systemTableRow) processColumn(
697+
column string, skipMissing bool, fn func(interface{}) interface{},
698+
) {
697699
if sr.skip() {
698700
return
699701
}
@@ -702,6 +704,9 @@ func (sr *systemTableRow) processColumn(column string, fn func(interface{}) inte
702704
hasCol := colIdx < len(sr.columns) && sr.columns[colIdx] == column
703705

704706
if !hasCol {
707+
if skipMissing {
708+
return
709+
}
705710
sr.err = fmt.Errorf("could not find column %s on %s", column, sr.table)
706711
return
707712
}
@@ -712,19 +717,19 @@ func (sr *systemTableRow) processColumn(column string, fn func(interface{}) inte
712717
// Matches allows the caller to only apply certain changes if the
713718
// value of a certain column matches a given value.
714719
func (sr *systemTableRow) Matches(column string, value interface{}) *systemTableRow {
715-
sr.processColumn(column, func(actualValue interface{}) interface{} {
720+
sr.processColumn(column, false /*skipMissing */, func(actualValue interface{}) interface{} {
716721
sr.matches = reflect.DeepEqual(actualValue, value)
717722
return actualValue
718723
})
719724

720725
return sr
721726
}
722727

723-
// WithSentinel replaces the contents of the given columns with a
724-
// fixed sentinel value.
725-
func (sr *systemTableRow) WithSentinel(columns ...string) *systemTableRow {
728+
// WithSentinelIfExists replaces the contents of the given columns with a
729+
// fixed sentinel value, if the column exists.
730+
func (sr *systemTableRow) WithSentinelIfExists(columns ...string) *systemTableRow {
726731
for _, column := range columns {
727-
sr.processColumn(column, func(value interface{}) interface{} {
732+
sr.processColumn(column, true /* skipMissing */, func(value interface{}) interface{} {
728733
return systemTableSentinel
729734
})
730735
}
@@ -819,7 +824,7 @@ func (sc *systemTableContents) settingsHandler(
819824
// `name` column equals 'version'
820825
Matches("name", "version").
821826
// use the sentinel value for every column in the settings table
822-
WithSentinel(columns...).
827+
WithSentinelIfExists(columns...).
823828
Values()
824829
}
825830

@@ -837,7 +842,7 @@ func (sc *systemTableContents) scheduledJobsHandler(
837842
values []interface{}, columns []string,
838843
) ([]interface{}, error) {
839844
return newSystemTableRow(sc.table, values, columns).
840-
WithSentinel("next_run", "schedule_details", "schedule_state").
845+
WithSentinelIfExists("next_run", "schedule_details", "schedule_state").
841846
Values()
842847
}
843848

@@ -848,15 +853,15 @@ func (sc *systemTableContents) usersHandler(
848853
values []interface{}, columns []string,
849854
) ([]interface{}, error) {
850855
return newSystemTableRow(sc.table, values, columns).
851-
WithSentinel("estimated_last_login_time").
856+
WithSentinelIfExists("estimated_last_login_time").
852857
Values()
853858
}
854859

855860
func (sc *systemTableContents) commentsHandler(
856861
values []interface{}, columns []string,
857862
) ([]interface{}, error) {
858863
return newSystemTableRow(sc.table, values, columns).
859-
WithSentinel("object_id"). // object_id is rekeyed
864+
WithSentinelIfExists("object_id"). // object_id is rekeyed
860865
Values()
861866
}
862867

0 commit comments

Comments
 (0)