Skip to content

Commit 2f474d0

Browse files
committed
sql/schemachanger: rename Transient to TransientAbsent
Now that we have added TransientPublic, we should rename Transient to TransientAbsent for clarity. Release note: None
1 parent 5f317bf commit 2f474d0

25 files changed

+67
-67
lines changed

pkg/sql/schemachanger/scbuild/build.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func makeNameMappings(elementStates []elementState) (ret scpb.NameMappings) {
341341
return &ret[idx], true /* isNew */
342342
}
343343
isNotDropping := func(ts scpb.TargetStatus) bool {
344-
return ts != scpb.ToAbsent && ts != scpb.Transient
344+
return ts != scpb.ToAbsent && ts != scpb.TransientAbsent
345345
}
346346
for _, es := range elementStates {
347347
switch e := es.element.(type) {
@@ -447,7 +447,7 @@ func (b buildCtx) Add(element scpb.Element) {
447447
}
448448

449449
func (b buildCtx) AddTransient(element scpb.Element) {
450-
b.Ensure(element, scpb.Transient, b.TargetMetadata())
450+
b.Ensure(element, scpb.TransientAbsent, b.TargetMetadata())
451451
}
452452

453453
func (b buildCtx) DropTransient(element scpb.Element) {

pkg/sql/schemachanger/scbuild/builder_state.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (b *builderState) QueryByID(id catid.DescID) scbuildstmt.ElementResultSet {
6262
func (b *builderState) Ensure(e scpb.Element, target scpb.TargetStatus, meta scpb.TargetMetadata) {
6363
dst := b.getExistingElementState(e)
6464
switch target {
65-
case scpb.ToAbsent, scpb.ToPublic, scpb.Transient, scpb.TransientPublic:
65+
case scpb.ToAbsent, scpb.ToPublic, scpb.TransientAbsent, scpb.TransientPublic:
6666
// Sanity check.
6767
default:
6868
panic(errors.AssertionFailedf("unsupported target %s", target.Status()))
@@ -108,7 +108,7 @@ func (b *builderState) Ensure(e scpb.Element, target scpb.TargetStatus, meta scp
108108
// of it and investigate it further if needed.
109109
if dst.current == scpb.Status_ABSENT &&
110110
dst.target == scpb.ToAbsent &&
111-
(target == scpb.ToPublic || target == scpb.Transient) &&
111+
(target == scpb.ToPublic || target == scpb.TransientAbsent) &&
112112
dst.metadata.IsLinkedToSchemaChange() {
113113
panic(scerrors.NotImplementedErrorf(
114114
nil,
@@ -156,7 +156,7 @@ func (b *builderState) Ensure(e scpb.Element, target scpb.TargetStatus, meta scp
156156
// the transient path so it can be done but we must take care to migrate
157157
// the current status to its transient equivalent if need be in order to
158158
// avoid the possibility of a future transition to PUBLIC.
159-
if target == scpb.Transient {
159+
if target == scpb.TransientAbsent {
160160
var ok bool
161161
dst.current, ok = scpb.GetTransientEquivalent(dst.current)
162162
if !ok {
@@ -167,7 +167,7 @@ func (b *builderState) Ensure(e scpb.Element, target scpb.TargetStatus, meta scp
167167
}
168168
}
169169
return
170-
case scpb.Transient:
170+
case scpb.TransientAbsent:
171171
// Here the new target is either to-absent, which effectively undoes the
172172
// incumbent target, or it's to-public. In both cases if the current
173173
// status is TRANSIENT_ we need to migrate it to its non-transient

pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_add_column.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ func addColumn(b BuildCtx, spec addColumnSpec, n tree.NodeFormatter) (backing *s
497497
// recognize this and drop redundant primary indexes appropriately.
498498
addStoredColumnToPrimaryIndexTargeting(b, spec.tbl.TableID, inflatedChain.oldSpec.primary, spec.col, scpb.ToPublic)
499499
}
500-
addStoredColumnToPrimaryIndexTargeting(b, spec.tbl.TableID, inflatedChain.inter1Spec.primary, spec.col, scpb.Transient)
501-
addStoredColumnToPrimaryIndexTargeting(b, spec.tbl.TableID, inflatedChain.inter2Spec.primary, spec.col, scpb.Transient)
500+
addStoredColumnToPrimaryIndexTargeting(b, spec.tbl.TableID, inflatedChain.inter1Spec.primary, spec.col, scpb.TransientAbsent)
501+
addStoredColumnToPrimaryIndexTargeting(b, spec.tbl.TableID, inflatedChain.inter2Spec.primary, spec.col, scpb.TransientAbsent)
502502
addStoredColumnToPrimaryIndexTargeting(b, spec.tbl.TableID, inflatedChain.finalSpec.primary, spec.col, scpb.ToPublic)
503503
return inflatedChain.finalSpec.primary
504504
}
@@ -521,8 +521,8 @@ func addColumn(b BuildCtx, spec addColumnSpec, n tree.NodeFormatter) (backing *s
521521

522522
// addStoredColumnToPrimaryIndexTargeting adds a stored column `col` to primary
523523
// index `idx` and its associated temporary index.
524-
// The column in primary index is targeting `target` (either ToPublic or Transient),
525-
// and the column in its temporary index is always targeting Transient.
524+
// The column in primary index is targeting `target` (either ToPublic or TransientAbsent),
525+
// and the column in its temporary index is always targeting TransientAbsent.
526526
func addStoredColumnToPrimaryIndexTargeting(
527527
b BuildCtx,
528528
tableID catid.DescID,
@@ -531,7 +531,7 @@ func addStoredColumnToPrimaryIndexTargeting(
531531
target scpb.TargetStatus,
532532
) {
533533
addIndexColumnToInternal(b, tableID, idx.IndexID, col.ColumnID, scpb.IndexColumn_STORED, target)
534-
addIndexColumnToInternal(b, tableID, idx.TemporaryIndexID, col.ColumnID, scpb.IndexColumn_STORED, scpb.Transient)
534+
addIndexColumnToInternal(b, tableID, idx.TemporaryIndexID, col.ColumnID, scpb.IndexColumn_STORED, scpb.TransientAbsent)
535535
}
536536

537537
func addIndexColumnToInternal(
@@ -569,7 +569,7 @@ func addIndexColumnToInternal(
569569
switch target {
570570
case scpb.ToPublic:
571571
b.Add(&indexCol)
572-
case scpb.Transient:
572+
case scpb.TransientAbsent:
573573
b.AddTransient(&indexCol)
574574
default:
575575
panic(errors.AssertionFailedf("programming error: add index column element "+

pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func undroppedElements(b BuildCtx, id catid.DescID) ElementResultSet {
106106
}
107107
// Ignore any other elements with undefined targets.
108108
return false
109-
case scpb.ToAbsent, scpb.Transient:
109+
case scpb.ToAbsent, scpb.TransientAbsent:
110110
// If the target is already ABSENT or TRANSIENT then the element is going
111111
// away anyway and so it doesn't need to have a target set for this DROP.
112112
return false
@@ -441,7 +441,7 @@ func absentTargetFilter(_ scpb.Status, target scpb.TargetStatus, _ scpb.Element)
441441
}
442442

443443
func transientTargetFilter(_ scpb.Status, target scpb.TargetStatus, _ scpb.Element) bool {
444-
return target == scpb.Transient
444+
return target == scpb.TransientAbsent
445445
}
446446

447447
func validTargetFilter(_ scpb.Status, target scpb.TargetStatus, _ scpb.Element) bool {

pkg/sql/schemachanger/scpb/constants.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ const (
4242
// in any kind of transitory state.
4343
ToPublic TargetStatus = TargetStatus(Status_PUBLIC)
4444

45-
// Transient is like ToAbsent in that the element should no longer exist once
45+
// TransientAbsent is like ToAbsent in that the element should no longer exist once
4646
// the schema change is done. The element is also not assumed to exist prior
4747
// to the schema change, so this target status is used to ensure it comes into
4848
// existence before disappearing again. Otherwise, an element whose current
4949
// and target statuses are both ABSENT won't experience any state transitions.
50-
Transient TargetStatus = TargetStatus(Status_TRANSIENT_ABSENT)
50+
TransientAbsent TargetStatus = TargetStatus(Status_TRANSIENT_ABSENT)
5151

5252
// TransientPublic is similar to ToPublic in that the element should persist after
5353
// the schema change is completed. The element is assumed to exist before the schema
@@ -71,7 +71,7 @@ func (t TargetStatus) InitialStatus() Status {
7171
switch t {
7272
case ToAbsent, TransientPublic:
7373
return Status_PUBLIC
74-
case ToPublic, Transient:
74+
case ToPublic, TransientAbsent:
7575
return Status_ABSENT
7676
default:
7777
panic(errors.AssertionFailedf("unknown target status %v", t.Status()))
@@ -86,7 +86,7 @@ func AsTargetStatus(s Status) TargetStatus {
8686
case Status_PUBLIC:
8787
return ToPublic
8888
case Status_TRANSIENT_ABSENT:
89-
return Transient
89+
return TransientAbsent
9090
case Status_TRANSIENT_PUBLIC:
9191
return TransientPublic
9292
default:

pkg/sql/schemachanger/scpb/element_collection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,17 @@ func (c *ElementCollection[E]) NotToAbsent() *ElementCollection[E] {
214214
})
215215
}
216216

217-
// Transient filters by elements targeting the TRANSIENT_ABSENT state.
217+
// TransientAbsent filters by elements targeting the TRANSIENT_ABSENT state.
218218
func (c *ElementCollection[E]) Transient() *ElementCollection[E] {
219219
return c.FilterTarget(func(target TargetStatus, _ E) bool {
220-
return target == Transient
220+
return target == TransientAbsent
221221
})
222222
}
223223

224224
// NotTransient filters by elements not targeting the TRANSIENT_ABSENT state.
225225
func (c *ElementCollection[E]) NotTransient() *ElementCollection[E] {
226226
return c.FilterTarget(func(target TargetStatus, _ E) bool {
227-
return target != Transient
227+
return target != TransientAbsent
228228
})
229229
}
230230

pkg/sql/schemachanger/scpb/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (s *CurrentState) Rollback() {
9797
switch t.TargetStatus {
9898
case Status_ABSENT:
9999
t.TargetStatus = Status_PUBLIC
100-
// Transient public elements always have the end goal
100+
// TransientAbsent public elements always have the end goal
101101
// of always returning back to public. So, the target
102102
// always stays the same (i.e. turn schema locked off
103103
// and on again).

pkg/sql/schemachanger/scplan/internal/opgen/op_gen.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ type Transition interface {
4242
}
4343

4444
// HasTransient returns true if the element of this type has
45-
// Transient transitions
45+
// TransientAbsent transitions
4646
func HasTransient(elType scpb.Element) bool {
47-
return hasTarget(elType, scpb.Transient)
47+
return hasTarget(elType, scpb.TransientAbsent)
4848
}
4949

5050
// HasTransientPublic returns true if the element of this type

pkg/sql/schemachanger/scplan/internal/rules/current/dep_add_index.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ func init() {
136136
to, screl.TemporaryIndexID,
137137
"temp-index-id",
138138
),
139-
from.TargetStatus(scpb.Transient),
140-
to.TargetStatus(scpb.ToPublic, scpb.Transient),
139+
from.TargetStatus(scpb.TransientAbsent),
140+
to.TargetStatus(scpb.ToPublic, scpb.TransientAbsent),
141141
from.CurrentStatus(scpb.Status_WRITE_ONLY),
142142
to.CurrentStatus(scpb.Status_BACKFILLED),
143143
}
@@ -164,9 +164,9 @@ func init() {
164164
to, screl.IndexID,
165165
"temp-index-id",
166166
),
167-
from.TargetStatus(scpb.ToPublic, scpb.Transient),
167+
from.TargetStatus(scpb.ToPublic, scpb.TransientAbsent),
168168
from.CurrentStatus(scpb.Status_MERGED),
169-
to.TargetStatus(scpb.Transient),
169+
to.TargetStatus(scpb.TransientAbsent),
170170
to.CurrentStatus(scpb.Status_TRANSIENT_DELETE_ONLY),
171171
}
172172
},
@@ -187,9 +187,9 @@ func init() {
187187
to, screl.TemporaryIndexID,
188188
"temp-index-id",
189189
),
190-
from.TargetStatus(scpb.Transient),
190+
from.TargetStatus(scpb.TransientAbsent),
191191
from.CurrentStatus(scpb.Status_TRANSIENT_DELETE_ONLY),
192-
to.TargetStatus(scpb.ToPublic, scpb.Transient),
192+
to.TargetStatus(scpb.ToPublic, scpb.TransientAbsent),
193193
to.CurrentStatus(scpb.Status_WRITE_ONLY),
194194
}
195195
},

pkg/sql/schemachanger/scplan/internal/rules/current/dep_alter_column_type.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func init() {
4545
JoinOnDescID(from, to, "table-id"),
4646
to.El.AttrEqVar(screl.ColumnID, colID),
4747
from.ReferencedColumnIDsContains(colID),
48-
from.TargetStatus(scpb.Transient),
48+
from.TargetStatus(scpb.TransientAbsent),
4949
to.TargetStatus(scpb.ToPublic),
5050
from.CurrentStatus(scpb.Status_TRANSIENT_VALIDATED),
5151
to.CurrentStatus(scpb.Status_PUBLIC),
@@ -63,7 +63,7 @@ func init() {
6363
to.Type((*scpb.ColumnComputeExpression)(nil)),
6464
JoinOnDescID(from, to, "table-id"),
6565
from.TargetStatus(scpb.ToPublic),
66-
to.TargetStatus(scpb.Transient),
66+
to.TargetStatus(scpb.TransientAbsent),
6767
from.CurrentStatus(scpb.Status_VALIDATED),
6868
to.CurrentStatus(scpb.Status_TRANSIENT_ABSENT),
6969
}

0 commit comments

Comments
 (0)