Skip to content

Commit e589e57

Browse files
committed
base: introduce TableNum
We should rename all uses of `FileNum` to `TableNum`. But changing all uses would be a massive diff, causing problems with backports. This change renames `base.FileNum` to `TableNum` and leaves a `FileNum` alias that we will deprecate in time.
1 parent b99c8d2 commit e589e57

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

internal/base/filenames.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,32 @@ import (
1616
"github.com/cockroachdb/redact"
1717
)
1818

19-
// FileNum is an internal DB identifier for a table. Tables can be physical (in
20-
// which case the FileNum also identifies the backing object) or virtual.
21-
type FileNum uint64
19+
// TableNum is an internal DB identifier for a table. Tables can be physical (in
20+
// which case the numeric TableNum value coincides with the DiskFileNum of the
21+
// backing object) or virtual.
22+
type TableNum uint64
23+
24+
// FileNum is a deprecated alias for TableNum.
25+
type FileNum = TableNum
2226

2327
// String returns a string representation of the file number.
24-
func (fn FileNum) String() string { return fmt.Sprintf("%06d", fn) }
28+
func (tn TableNum) String() string { return fmt.Sprintf("%06d", tn) }
2529

2630
// SafeFormat implements redact.SafeFormatter.
27-
func (fn FileNum) SafeFormat(w redact.SafePrinter, _ rune) {
28-
w.Printf("%06d", redact.SafeUint(fn))
31+
func (tn TableNum) SafeFormat(w redact.SafePrinter, _ rune) {
32+
w.Printf("%06d", redact.SafeUint(tn))
2933
}
3034

31-
// PhysicalTableDiskFileNum converts the FileNum of a physical table to the
35+
// PhysicalTableDiskFileNum converts the TableNum of a physical table to the
3236
// backing DiskFileNum. The underlying numbers always match for physical tables.
33-
func PhysicalTableDiskFileNum(n FileNum) DiskFileNum {
37+
func PhysicalTableDiskFileNum(n TableNum) DiskFileNum {
3438
return DiskFileNum(n)
3539
}
3640

3741
// PhysicalTableFileNum converts the DiskFileNum backing a physical table into
38-
// the table's FileNum. The underlying numbers always match for physical tables.
39-
func PhysicalTableFileNum(f DiskFileNum) FileNum {
40-
return FileNum(f)
42+
// the table's TableNum. The underlying numbers always match for physical tables.
43+
func PhysicalTableFileNum(f DiskFileNum) TableNum {
44+
return TableNum(f)
4145
}
4246

4347
// A DiskFileNum identifies a file or object with exists on disk.

internal/base/filenames_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ Error types: (1) *hintdetail.withDetail (2) *errors.errorString`, filename)
120120

121121
func TestRedactFileNum(t *testing.T) {
122122
// Ensure that redaction never redacts file numbers.
123-
require.Equal(t, redact.RedactableString("000005"), redact.Sprint(FileNum(5)))
123+
require.Equal(t, redact.RedactableString("000005"), redact.Sprint(TableNum(5)))
124124
require.Equal(t, redact.RedactableString("000005"), redact.Sprint(DiskFileNum(5)))
125125
}

0 commit comments

Comments
 (0)