Skip to content

Commit 98c65f0

Browse files
committed
sql/inspect: update package and function names after file move
Previously, inspect_job.go was in the pkg/sql package and exported functions with "Inspect" prefixes (TriggerInspectJob, InspectChecksForTable, etc.). After moving the file to pkg/sql/inspect, this commit updates: - Package declaration from `sql` to `inspect` - Adds `sql` package import for types like ExecutorConfig and PlanHookState - Renames functions to remove redundant "Inspect" prefix: - TriggerInspectJob -> TriggerJob - InspectChecksForTable -> ChecksForTable - InspectChecksForDatabase -> checksForDatabase (now unexported) - InspectChecksByIndexNames -> checksByIndexNames (now unexported) - Updates all callers in inspect_plan.go and import_job.go The "Inspect" prefix is redundant since the functions are now in the inspect package. Functions only used internally are now unexported. Release note: None Epic: None
1 parent d901874 commit 98c65f0

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

pkg/sql/importer/import_job.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,12 @@ func (r *importResumer) Resume(ctx context.Context, execCtx interface{}) error {
329329
}
330330
tblDesc := tabledesc.NewBuilder(table.Desc).BuildImmutableTable()
331331
if len(tblDesc.PublicNonPrimaryIndexes()) > 0 {
332-
checks, err := inspect.InspectChecksForTable(ctx, nil /* p */, tblDesc)
332+
checks, err := inspect.ChecksForTable(ctx, nil /* p */, tblDesc)
333333
if err != nil {
334334
return err
335335
}
336336

337-
job, err := inspect.TriggerInspectJob(
337+
job, err := inspect.TriggerJob(
338338
ctx,
339339
fmt.Sprintf("import-validation-%s", tblDesc.GetName()),
340340
p.ExecCfg(),

pkg/sql/inspect/inspect_job_entry.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
"github.com/cockroachdb/cockroach/pkg/util/log"
2626
)
2727

28-
// TriggerInspectJob starts an inspect job for the snapshot.
29-
func TriggerInspectJob(
28+
// TriggerJob starts an inspect job for the snapshot.
29+
func TriggerJob(
3030
ctx context.Context,
3131
jobRecordDescription string,
3232
execCfg *sql.ExecutorConfig,
@@ -94,9 +94,9 @@ func TriggerInspectJob(
9494
return job, nil
9595
}
9696

97-
// InspectChecksForDatabase generates checks on every supported index on every
97+
// checksForDatabase generates checks on every supported index on every
9898
// table in the given database.
99-
func InspectChecksForDatabase(
99+
func checksForDatabase(
100100
ctx context.Context, p sql.PlanHookState, db catalog.DatabaseDescriptor,
101101
) ([]*jobspb.InspectDetails_Check, error) {
102102
avoidLeased := false
@@ -115,7 +115,7 @@ func InspectChecksForDatabase(
115115
checks := []*jobspb.InspectDetails_Check{}
116116

117117
if err := tables.ForEachDescriptor(func(desc catalog.Descriptor) error {
118-
tableChecks, err := InspectChecksForTable(ctx, p, desc.(catalog.TableDescriptor))
118+
tableChecks, err := ChecksForTable(ctx, p, desc.(catalog.TableDescriptor))
119119
if err != nil {
120120
return err
121121
}
@@ -128,9 +128,9 @@ func InspectChecksForDatabase(
128128
return checks, nil
129129
}
130130

131-
// InspectChecksForTable generates checks on every supported index on the given
131+
// ChecksForTable generates checks on every supported index on the given
132132
// table.
133-
func InspectChecksForTable(
133+
func ChecksForTable(
134134
ctx context.Context, p sql.PlanHookState, table catalog.TableDescriptor,
135135
) ([]*jobspb.InspectDetails_Check, error) {
136136
checks := []*jobspb.InspectDetails_Check{}
@@ -160,10 +160,10 @@ type indexKey struct {
160160
descpb.IndexID
161161
}
162162

163-
// InspectChecksByIndexNames generates checks for the specified index names.
163+
// checksByIndexNames generates checks for the specified index names.
164164
// If index names are not found or are not supported for inspection, an error is returned.
165165
// Index names are deduplicated.
166-
func InspectChecksByIndexNames(
166+
func checksByIndexNames(
167167
ctx context.Context, p sql.PlanHookState, names tree.TableIndexNames,
168168
) ([]*jobspb.InspectDetails_Check, error) {
169169
checks := []*jobspb.InspectDetails_Check{}

pkg/sql/inspect/inspect_plan.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ func newInspectRun(
109109
// No INDEX options or INDEX ALL specified - inspect all indexes.
110110
switch stmt.Typ {
111111
case tree.InspectTable:
112-
checks, err := InspectChecksForTable(ctx, p, run.table)
112+
checks, err := ChecksForTable(ctx, p, run.table)
113113
if err != nil {
114114
return inspectRun{}, err
115115
}
116116
run.checks = checks
117117
case tree.InspectDatabase:
118-
if checks, err := InspectChecksForDatabase(ctx, p, run.db); err != nil {
118+
if checks, err := checksForDatabase(ctx, p, run.db); err != nil {
119119
return inspectRun{}, err
120120
} else {
121121
run.checks = checks
@@ -152,7 +152,7 @@ func newInspectRun(
152152
}
153153
}
154154

155-
if checks, err := InspectChecksByIndexNames(ctx, p, run.namedIndexes); err != nil {
155+
if checks, err := checksByIndexNames(ctx, p, run.namedIndexes); err != nil {
156156
return inspectRun{}, err
157157
} else {
158158
run.checks = checks
@@ -236,7 +236,7 @@ func inspectPlanHook(
236236
// the job record creation happens transactionally.
237237
plannerTxn := p.InternalSQLTxn()
238238

239-
sj, err := sql.TriggerInspectJob(ctx, tree.AsString(stmt), p.ExecCfg(), plannerTxn, run.checks, run.asOfTimestamp)
239+
sj, err := TriggerJob(ctx, tree.AsString(stmt), p.ExecCfg(), plannerTxn, run.checks, run.asOfTimestamp)
240240
if err != nil {
241241
return err
242242
}

0 commit comments

Comments
 (0)