Back to Tidb

DDL Codebase File Map (quick “where is it implemented?”)

docs/agents/ddl/05-file-map.md

26.3.42.1 KB
Original Source

DDL Codebase File Map (quick “where is it implemented?”)

This is a pragmatic map from common DDL areas to pkg/ddl/ files. It’s intentionally non-exhaustive, but aims to cover the most frequently touched parts.

Core framework (read these first)

  • DDL wiring & lifecycle: pkg/ddl/ddl.go
  • Statement → job(s) → wait: pkg/ddl/executor.go
  • Job batching/submission: pkg/ddl/job_submitter.go
  • Owner scheduler + worker pools: pkg/ddl/job_scheduler.go, pkg/ddl/ddl_workerpool.go
  • Worker job-step execution: pkg/ddl/job_worker.go
  • Schema version sync (owner↔followers): pkg/ddl/schema_version.go, pkg/ddl/schemaver/*
  • System table access (jobs/MDL): pkg/ddl/systable/*

Common DDL domains

Topic / statement familyWhere to look
Create/Drop/Alter databasepkg/ddl/schema.go
Create/Drop/Truncate/Rename tablepkg/ddl/table.go
Add/Drop indexpkg/ddl/index.go, reorg helpers in pkg/ddl/reorg*.go
Modify columnpkg/ddl/modify_column.go
Partition DDLpkg/ddl/partition.go
Multi-schema change (ALTER TABLE ... multi spec)pkg/ddl/multi_schema_change.go
Placement policiespkg/ddl/placement_policy.go, pkg/ddl/placement/*
Resource group DDLpkg/ddl/resource_group.go, pkg/ddl/resourcegroup/*
Sequencepkg/ddl/sequence.go
Table lockspkg/ddl/table_lock.go
Table mode (e.g. cache)pkg/ddl/table_mode.go
TTLpkg/ddl/ttl.go
Split region for table/indexpkg/ddl/split_region.go, pkg/ddl/table_split_test.go
Repair tablepkg/ddl/repair_table*.go
Rolling back / error handling helperspkg/ddl/rollingback*.go

Reorg / backfill & acceleration

  • Reorg framework: pkg/ddl/reorg.go, pkg/ddl/reorg_util.go
  • Distributed backfill hooks: look for proto.Backfill registration in pkg/ddl/ddl.go
  • Ingest / Lightning acceleration: pkg/ddl/ingest/*

Events / notifications

  • Schema change event publish/subscribe: pkg/ddl/notifier/*

Deep dives

  • Add index: docs/agents/ddl/06-add-index.md
  • Modify column: docs/agents/ddl/07-modify-column.md
  • Partition DDL: docs/agents/ddl/08-partition-ddl.md