Skip to content

Commit

Permalink
sql: use descs.Txn for schemachanger.txn
Browse files Browse the repository at this point in the history
This commit is to use the new internal executor interface introduced by cockroachdb#93218
for `schemachanger.txn()`.

informs cockroachdb#91004
Release Note: None
  • Loading branch information
ZhouXing19 committed Feb 6, 2023
1 parent 8e24570 commit 8e149bf
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 148 deletions.
4 changes: 2 additions & 2 deletions pkg/ccl/backupccl/restore_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -1917,8 +1917,8 @@ func revalidateIndexes(
// We don't actually need the 'historical' read the way the schema change does
// since our table is offline.
runner := descs.NewHistoricalInternalExecTxnRunner(hlc.Timestamp{}, func(ctx context.Context, fn descs.InternalExecFn) error {
return execCfg.InternalDB.Txn(ctx, func(ctx context.Context, txn isql.Txn) error {
return fn(ctx, txn, descs.FromTxn(txn))
return execCfg.InternalDB.DescsTxn(ctx, func(ctx context.Context, txn descs.Txn) error {
return fn(ctx, txn)
})
})

Expand Down
4 changes: 2 additions & 2 deletions pkg/jobs/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ type Registry struct {
adoptionCh chan adoptionNotice
sqlInstance sqlliveness.Instance

// sessionBoundInternalExecutorFactory provides a way for jobs to create
// internal executors. This is rarely needed, and usually job resumers should
// internalDB provides a way for jobs to create internal executors.
// This is rarely needed, and usually job resumers should
// use the internal executor from the JobExecCtx. The intended user of this
// interface is the schema change job resumer, which needs to set the
// tableCollectionModifier on the internal executor to different values in
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/alter_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ func (n *alterTableNode) startExec(params runParams) error {
ck.CheckDesc().Validity = descpb.ConstraintValidity_Validated
} else if fk := c.AsForeignKey(); fk != nil {
if err := validateFkInTxn(
params.ctx, params.p.InternalSQLTxn(), params.p.descCollection, n.tableDesc, name,
params.ctx, params.p.InternalSQLTxn(), n.tableDesc, name,
); err != nil {
return err
}
Expand Down
Loading

0 comments on commit 8e149bf

Please sign in to comment.