-
Notifications
You must be signed in to change notification settings - Fork 4.1k
descs: legacy schema changes should use a dedicated interface with sane defaults #87753
Description
The default behaviour of GetImmutableTableByID and similar methods is to lookup leased descriptors when available and we have to set an AvoidLeased flag explicitly to avoid that. The problem is that when it comes to schema changes, we always want to avoid leased descriptors. We have a CommonLookupFlags() method on resolver.SchemaResolver which does the right thing but it's not enough.
Case in point: in 21.2, the canRemoveEnumValue is buggy because it happily looks up a leased table descriptor. This has since been fixed by #79697. But this class of bug can easily happen again.
Perhaps the solution is to flip the tables and replace AvoidLeased with IncludeLeased and have the optimizer set that flag. It might be less trouble. Alternatively, wrap the descs.Collection behind an interface that the planner can readily use when operating on schema change PlanNodes.
Jira issue: CRDB-19516