Skip to content

Deprecate ExtraPidCol and use ExtraPhysTblIDCol instead of it. #17138

@Defined2014

Description

@Defined2014

Feature Request

Is your feature request related to a problem? Please describe:

See the tidb issue.

The problem is we added ExtraPhysTblID to DataSource's schema for get the partition id. But it returns table id instead of partition id when using indexReader executor working with global index, because we decode index key to get it. After deep into the code, I found it's hard to fix it elegantly. In logical plan builder phase, we can't determined it will select a global index path or not which means we can't addExtraPidColID column into DataSource in this phase.

Then I think maybe we could combine two columns, let it gets return values from different place(Seems ExtraPhysTblID is useless for global index, always return table ID for every records). When it is a global index, we could decode pid by index value, otherwise we could decode table id by index/row key. Also it could reduce potential errors, no need to select to use ExtraPhysTblID or ExtraPidColID when we write the code.

Describe the feature you'd like:

Let ExtraPhysTblIDCol returns partition id when it is a global index request and deprecate ExtraPidCol.

Describe alternatives you've considered:

Keep both of them and do it in TiDB side. But as mentioned earlier, it's hard to fix it elegantly.

Also it could reduce potential errors, no need to select to use ExtraPhysTblID or ExtraPidColID when we write the code.

Teachability, Documentation, Adoption, Migration Strategy:

It works for partition tables, when you want get the partition id from cop, you could add this column to your schema.

Metadata

Metadata

Assignees

Labels

type/feature-requestCategorizes issue or PR as related to a new feature.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions