Skip to content

Commit 2dab378

Browse files
committed
tree: return error instead of panicking
This avoids the risk of a faulty enum comparison causing a node to crash. Release note: None
1 parent 192314f commit 2dab378

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/sql/sem/tree/datum.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5460,7 +5460,7 @@ func (d *DEnum) ResolvedType() *types.T {
54605460
return d.EnumTyp
54615461
}
54625462

5463-
// PlanCistFromCtx returns the plan gist if it is stored in the context. It is
5463+
// PlanGistFromCtx returns the plan gist if it is stored in the context. It is
54645464
// injected from the sql package to avoid import cycle.
54655465
var PlanGistFromCtx func(context.Context) string
54665466

@@ -5487,11 +5487,11 @@ func (d *DEnum) Compare(ctx context.Context, cmpCtx CompareContext, other Datum)
54875487
// safe string.
54885488
gist = redact.SafeString(PlanGistFromCtx(ctx))
54895489
}
5490-
panic(errors.AssertionFailedf(
5490+
return 0, errors.AssertionFailedf(
54915491
"comparison of two different versions of enum %s oid %d: versions %d and %d, gist %q",
54925492
d.EnumTyp.SQLStringForError(), errors.Safe(d.EnumTyp.Oid()), d.EnumTyp.TypeMeta.Version,
54935493
v.EnumTyp.TypeMeta.Version, gist,
5494-
))
5494+
)
54955495
}
54965496

54975497
res := bytes.Compare(d.PhysicalRep, v.PhysicalRep)

0 commit comments

Comments
 (0)