`DEnum.Compare` still fails with an internal "comparison of two
different versions of enum" error when the two values were produced
with descriptor versions of their type more than one version apart. This
indicates stale type metadata (e.g. from a cache) leaked into the query,
which is a bug, but the comparison by physical representation is usually
well-defined, so this commit adds the
`sql.enum.allow_version_skew_in_comparisons.enabled` cluster setting
(off by default) to unblock affected workloads until such bugs are
fixed. The setting is read via a new `CompareContext` method. It stays
off by default since stale metadata can lead to incorrect results that
can't be caught by checking the two versions (e.g. a plan built against
the older version might not know about a value present in the data).
When enabled, the versions must still be consistent, using the same
check as for adjacent versions, so any rename between them or a value
moved to another physical representation (e.g. after dropping it and
adding it back in a different position) fails the assertion. A value
dropped and re-added between the same neighbors gets the same
representations, so it's indistinguishable from the original and is
considered the same value.
Informs: cockroachlabs/cockroach#12711
Epic: none
Release note: None
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>