Skip to content

Conversation

@wjhuang2016
Copy link
Member

What problem does this PR solve?

Issue Number: close #0

Problem Summary:

  • Lay down the system tables + SQL syntax + DDL metadata foundation for async Materialized View (scheme2). This PR does not implement refresh/purge execution.

What changed and how does it work?

  • Add mysql physical system tables (bootstrap + upgrade):
    • mysql.tidb_mviews, mysql.tidb_mlogs
    • mysql.tidb_mview_refresh_hist, mysql.tidb_mlog_purge_hist (job id is BIGINT AUTO_INCREMENT, exposed as varchar in information_schema)
    • mysql.tidb_mlog_job (scheme2 coordination table, schema-only for now)
  • Expose metadata via information_schema:
    • information_schema.tidb_mviews, information_schema.tidb_mlogs
    • information_schema.tidb_mview_refresh_hist, information_schema.tidb_mlog_purge_hist
  • Add sysvars:
    • tidb_mview_refresh_hist_time, tidb_mlog_purge_hist_time
  • Add Parser/AST for MV/MV LOG DDL and REFRESH statement:
    • CREATE/ALTER/DROP MATERIALIZED VIEW
    • CREATE/ALTER/DROP MATERIALIZED VIEW LOG
    • REFRESH MATERIALIZED VIEW [WITH SYNC MODE] (parse + DDL entry; execution is still unsupported in this PR)
  • Add DDL executor logic (metadata only):
    • Persist MV/MLOG metadata into mysql.tidb_mviews/mysql.tidb_mlogs
    • Guard DROP TABLE: base table cannot be dropped if its MLOG exists (must drop MLOG first)
    • Default NEXT=5min (stored as REFRESH_MODE=START WITH NOW() NEXT 300 when omitted; MVIEW_DEFINITION keeps the original user statement)

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Add system tables, information_schema exposure, and SQL syntax for materialized view / materialized view log metadata (scheme2).
@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 31, 2026
@codecov
Copy link

codecov bot commented Jan 31, 2026

Codecov Report

❌ Patch coverage is 38.13559% with 657 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (feature/materialized_view@dcad06c). Learn more about missing BASE report.

Additional details and impacted files
@@                      Coverage Diff                       @@
##             feature/materialized_view     #65936   +/-   ##
==============================================================
  Coverage                             ?   36.4008%           
==============================================================
  Files                                ?       1703           
  Lines                                ?     625452           
  Branches                             ?          0           
==============================================================
  Hits                                 ?     227670           
  Misses                               ?     375086           
  Partials                             ?      22696           
Flag Coverage Δ
integration 36.4008% <38.1355%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling ∅ <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 20.9905% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@wjhuang2016 wjhuang2016 force-pushed the mv/scheme2-systables-ddl branch from 68fb542 to b2f3537 Compare January 31, 2026 13:41
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jan 31, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign benmeadowcroft, bornchanger, d3hunter, fixdb for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 1, 2026

@wjhuang2016: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-integration-e2e-test 3c485bf link true /test pull-integration-e2e-test
idc-jenkins-ci-tidb/mysql-test 3c485bf link true /test mysql-test
idc-jenkins-ci-tidb/unit-test 3c485bf link true /test unit-test
pull-br-integration-test 3c485bf link true /test pull-br-integration-test
idc-jenkins-ci-tidb/check_dev_2 3c485bf link true /test check-dev2
pull-lightning-integration-test 3c485bf link true /test pull-lightning-integration-test

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

1 participant