Skip to content

Commit f08b1ac

Browse files
committed
tree: remove DOidWrapper support for DInt
Initially, in 9c9b045, when we added DOidWrapper thingy in the first place, we supported Oid type using it. Soon afterwards in d2526b3 we introduced separate DOid datum to support the Oid type, so we removed that usage of DOidWrapper, which made the relevant code redundant. This commit removes it. Release note: None
1 parent 87f21b0 commit f08b1ac

File tree

16 files changed

+65
-80
lines changed

16 files changed

+65
-80
lines changed

pkg/backup/compaction_job.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ func maybeStartCompactionJob(
161161
if err != nil {
162162
return err
163163
}
164-
idDatum, ok := tree.AsDInt(datums[0])
164+
idDatum, ok := datums[0].(*tree.DInt)
165165
if !ok {
166166
return errors.Newf("expected job ID: unexpected result type %T", datums[0])
167167
}
168-
jobID = jobspb.JobID(idDatum)
168+
jobID = jobspb.JobID(*idDatum)
169169

170170
scheduledJob := jobs.ScheduledJobTxn(txn)
171171
backupSchedule, args, err := getScheduledBackupExecutionArgsFromSchedule(

pkg/backup/schedule_exec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,12 +544,12 @@ func getBackupFnTelemetry(
544544
return jobspb.BackupDetails{}, errors.New("expected job ID as first column of result")
545545
}
546546

547-
jobID, ok := tree.AsDInt(jobIDDatum)
547+
jobID, ok := jobIDDatum.(*tree.DInt)
548548
if !ok {
549549
return jobspb.BackupDetails{}, errors.New("expected job ID as first column of result")
550550
}
551551

552-
job, err := registry.LoadJobWithTxn(ctx, jobspb.JobID(jobID), txn)
552+
job, err := registry.LoadJobWithTxn(ctx, jobspb.JobID(*jobID), txn)
553553
if err != nil {
554554
return jobspb.BackupDetails{}, errors.Wrap(err, "failed to load dry-run backup job")
555555
}

pkg/crosscluster/logical/sql_row_reader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (r *sqlRowReader) ReadRows(
116116
return nil, errors.AssertionFailedf("expected %d columns, got %d", len(r.columns)+3, len(row))
117117
}
118118

119-
rowIndex, ok := tree.AsDInt(row[0])
119+
rowIndex, ok := row[0].(*tree.DInt)
120120
if !ok {
121121
return nil, errors.AssertionFailedf("expected column 0 to be the row index")
122122
}
@@ -138,7 +138,7 @@ func (r *sqlRowReader) ReadRows(
138138
return nil, err
139139
}
140140

141-
result[int(rowIndex)-1] = priorRow{
141+
result[int(*rowIndex)-1] = priorRow{
142142
row: row[prefixColumns:],
143143
logicalTimestamp: logicalTimestamp,
144144
isLocal: isLocal,

pkg/jobs/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ func JobCoordinatorID(
171171
if row == nil {
172172
return 0, errors.Errorf("coordinator not found for job %d", jobID)
173173
}
174-
coordinatorID, ok := tree.AsDInt(row[0])
174+
coordinatorID, ok := row[0].(*tree.DInt)
175175
if !ok {
176176
return 0, errors.AssertionFailedf("expected coordinator ID to be an int, got %T", row[0])
177177
}
178-
return int32(coordinatorID), nil
178+
return int32(*coordinatorID), nil
179179
}
180180

181181
// getJobTypeStrs is a helper function that returns a string representation of

pkg/multitenant/mtinfo/info.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ func GetTenantInfoFromSQLRow(
3636
}
3737
info = &mtinfopb.TenantInfo{}
3838

39-
idval, ok := tree.AsDInt(row[0])
39+
idval, ok := row[0].(*tree.DInt)
4040
if !ok {
4141
return tid, nil, errors.AssertionFailedf("tenant ID: expected int, got %T", row[0])
4242
}
43-
tid, err = roachpb.MakeTenantID(uint64(idval))
43+
tid, err = roachpb.MakeTenantID(uint64(*idval))
4444
if err != nil {
4545
return tid, nil, errors.NewAssertionErrorWithWrappedErrf(err, "%v", idval)
4646
}
@@ -92,14 +92,14 @@ func GetTenantInfoFromSQLRow(
9292
return tid, nil, errors.AssertionFailedf("%v: unhandled: %d", tid, info.ProtoInfo.DeprecatedDataState)
9393
}
9494
if len(row) > 3 && row[3] != tree.DNull {
95-
val, ok := tree.AsDInt(row[3])
95+
val, ok := row[3].(*tree.DInt)
9696
if !ok {
9797
return tid, nil, errors.AssertionFailedf("%v: data state: expected int, got %T", tid, row[3])
9898
}
99-
if val < 0 || mtinfopb.TenantDataState(val) > mtinfopb.MaxDataState {
99+
if *val < 0 || mtinfopb.TenantDataState(*val) > mtinfopb.MaxDataState {
100100
return tid, nil, errors.AssertionFailedf("%v: invalid data state: %d", tid, val)
101101
} else {
102-
info.DataState = mtinfopb.TenantDataState(val)
102+
info.DataState = mtinfopb.TenantDataState(*val)
103103
}
104104
}
105105

@@ -112,14 +112,14 @@ func GetTenantInfoFromSQLRow(
112112
info.ServiceMode = mtinfopb.ServiceModeNone
113113
}
114114
if len(row) > 4 && row[4] != tree.DNull {
115-
val, ok := tree.AsDInt(row[4])
115+
val, ok := row[4].(*tree.DInt)
116116
if !ok {
117117
return tid, nil, errors.AssertionFailedf("%v: service mode: expected int, got %T", tid, row[4])
118118
}
119-
if val < 0 || mtinfopb.TenantServiceMode(val) > mtinfopb.MaxServiceMode {
119+
if *val < 0 || mtinfopb.TenantServiceMode(*val) > mtinfopb.MaxServiceMode {
120120
return tid, nil, errors.AssertionFailedf("%v: invalid service mode: %d", tid, val)
121121
} else {
122-
info.ServiceMode = mtinfopb.TenantServiceMode(val)
122+
info.ServiceMode = mtinfopb.TenantServiceMode(*val)
123123
}
124124
}
125125

pkg/server/admin.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3510,11 +3510,11 @@ func (rs resultScanner) ScanIndex(row tree.Datums, index int, dst interface{}) e
35103510
*d = &val
35113511

35123512
case *int64:
3513-
s, ok := tree.AsDInt(src)
3513+
s, ok := src.(*tree.DInt)
35143514
if !ok {
35153515
return errors.Errorf("source type assertion failed")
35163516
}
3517-
*d = int64(s)
3517+
*d = int64(*s)
35183518

35193519
case **int64:
35203520
s, ok := src.(*tree.DInt)
@@ -3534,11 +3534,11 @@ func (rs resultScanner) ScanIndex(row tree.Datums, index int, dst interface{}) e
35343534
return errors.Errorf("source type assertion failed")
35353535
}
35363536
for i := 0; i < s.Len(); i++ {
3537-
id, ok := tree.AsDInt(s.Array[i])
3537+
id, ok := s.Array[i].(*tree.DInt)
35383538
if !ok {
35393539
return errors.Errorf("source type assertion failed on index %d", i)
35403540
}
3541-
*d = append(*d, int64(id))
3541+
*d = append(*d, int64(*id))
35423542
}
35433543

35443544
case *[]descpb.ID:
@@ -3547,11 +3547,11 @@ func (rs resultScanner) ScanIndex(row tree.Datums, index int, dst interface{}) e
35473547
return errors.Errorf("source type assertion failed")
35483548
}
35493549
for i := 0; i < s.Len(); i++ {
3550-
id, ok := tree.AsDInt(s.Array[i])
3550+
id, ok := s.Array[i].(*tree.DInt)
35513551
if !ok {
35523552
return errors.Errorf("source type assertion failed on index %d", i)
35533553
}
3554-
*d = append(*d, descpb.ID(id))
3554+
*d = append(*d, descpb.ID(*id))
35553555
}
35563556

35573557
case *time.Time:

pkg/sql/catalog/schematelemetry/schematelemetrycontroller/controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ func GetSchemaTelemetryScheduleID(
270270
return 0, errors.AssertionFailedf("unexpectedly received %d columns", len(row))
271271
}
272272
// Defensively check the type.
273-
v, ok := tree.AsDInt(row[0])
273+
v, ok := row[0].(*tree.DInt)
274274
if !ok {
275275
return 0, errors.AssertionFailedf("unexpectedly received non-integer value %v", row[0])
276276
}
277-
return jobspb.ScheduleID(v), nil
277+
return jobspb.ScheduleID(*v), nil
278278
}

pkg/sql/control_jobs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ func (n *controlJobsNode) startExec(params runParams) error {
6161
continue
6262
}
6363

64-
jobID, ok := tree.AsDInt(jobIDDatum)
64+
jobID, ok := jobIDDatum.(*tree.DInt)
6565
if !ok {
6666
return errors.AssertionFailedf("%q: expected *DInt, found %T", jobIDDatum, jobIDDatum)
6767
}
6868

69-
if err := reg.UpdateJobWithTxn(params.ctx, jobspb.JobID(jobID), params.p.InternalSQLTxn(),
69+
if err := reg.UpdateJobWithTxn(params.ctx, jobspb.JobID(*jobID), params.p.InternalSQLTxn(),
7070
func(txn isql.Txn, md jobs.JobMetadata, ju *jobs.JobUpdater) error {
7171
if err := jobsauth.Authorize(params.ctx, params.p,
7272
md.ID, md.Payload.UsernameProto.Decode(), jobsauth.ControlAccess, globalPrivileges); err != nil {

pkg/sql/crdb_internal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7940,8 +7940,8 @@ CREATE TABLE crdb_internal.cluster_locks (
79407940
indexes: []virtualIndex{
79417941
{
79427942
populate: genPopulateClusterLocksWithIndex("table_id" /* idxColumnName */, func(filters *clusterLocksFilters, idxConstraint tree.Datum) {
7943-
if tableID, ok := tree.AsDInt(idxConstraint); ok {
7944-
filters.tableID = (*int64)(&tableID)
7943+
if tableID, ok := idxConstraint.(*tree.DInt); ok {
7944+
filters.tableID = (*int64)(tableID)
79457945
}
79467946
}),
79477947
},

pkg/sql/paramparse/paramparse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ func DatumAsInt(
100100
if err != nil {
101101
return 0, err
102102
}
103-
iv, ok := tree.AsDInt(val)
103+
iv, ok := val.(*tree.DInt)
104104
if !ok {
105105
err = pgerror.Newf(pgcode.InvalidParameterValue,
106106
"parameter %q requires an integer value", name)
107107
err = errors.WithDetailf(err,
108108
"%s is a %s", value, errors.Safe(val.ResolvedType()))
109109
return 0, err
110110
}
111-
return int64(iv), nil
111+
return int64(*iv), nil
112112
}
113113

114114
// DatumAsString transforms a tree.TypedExpr containing a Datum into a string.

0 commit comments

Comments
 (0)