Skip to content

descs: legacy schema changes should use a dedicated interface with sane defaults #87753

@postamar

Description

@postamar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-schema-catalogRelated to the schema descriptors collection and the catalog API in general.C-cleanupTech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions