pingcap / pingcap/tidb

mview: support partition tables

Open
#66,224 0 comments 0 reactions 0 assignees View on GitHub
component/mview type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement
Support materialized view log (mlog) DML writes on partitioned tables.

### Background

PR #66204 introduced mlog DML writing for materialized views. One known limitation is that partitioned base tables are explicitly rejected. In `wrapTableWithMLogIfExists()` (`pkg/executor/builder.go:2899-2903`), when `meta.GetPartitionInfo() != nil`, the function returns `ErrNotSupportedYet`:

```go
// builder.go
// MV log DML write path doesn't support partitioned tables for now. This guard prevents
// accidentally writing inconsistent logs for partitions.
if meta.GetPartitionInfo() != nil {
b.err = plannererrors.ErrNotSupportedYet.GenWithStackByArgs(
"materialized view log on partitioned tables",
)
return nil
}
```

### Current Behavior

Any DML (INSERT, UPDATE, DELETE) on a partitioned base table that has an associated materialized view log results in an `ErrNotSupportedYet` error. The user cannot perform DML on such tables at all while an mlog exists.

### Expected Improvement

Ensuring the `mlogTable` wrapper is applied at the correct level (per-partition or globally) so that mlog rows are written with consistent row data regardless of which partition the row belongs to.

### Related

- #18023
- #66204

Contributor guide

Open the contributing guide

Research direction

Start in pkg/executor/builder.go at wrapTableWithMLogIfExists() and inspect the partition guard around lines 2899-2903. Read PR #66204 and related issue #18023 to understand the existing mlog DML path and partition behavior. Done means INSERT, UPDATE, and DELETE on partitioned tables with an associated mlog no longer return ErrNotSupportedYet and write consistent mlog rows.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.