Skip to content

Commit

Permalink
support TableIDInDDLJob in schema store
Browse files Browse the repository at this point in the history
  • Loading branch information
lidezhu committed Feb 7, 2025
1 parent d5d2a93 commit 1448f20
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 17 deletions.
10 changes: 6 additions & 4 deletions logservice/schemastore/persist_storage_ddl_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ func buildPersistedDDLEventCommon(args buildPersistedDDLEventFuncArgs) Persisted
event := PersistedDDLEvent{
ID: job.ID,
Type: byte(job.Type),
TableIDInDDLJob: job.TableID,
CurrentSchemaID: job.SchemaID,
CurrentTableID: job.TableID,
Query: query,
Expand Down Expand Up @@ -1407,10 +1408,11 @@ func buildDDLEventCommon(rawEvent *PersistedDDLEvent, tableFilter filter.Filter,
SchemaName: rawEvent.CurrentSchemaName,
TableName: rawEvent.CurrentTableName,

Query: rawEvent.Query,
TableInfo: wrapTableInfo,
FinishedTs: rawEvent.FinishedTs,
TiDBOnly: tiDBOnly,
Query: rawEvent.Query,
TableInfo: wrapTableInfo,
FinishedTs: rawEvent.FinishedTs,
TiDBOnly: tiDBOnly,
TableIDInDDLJob: rawEvent.TableIDInDDLJob,
}, !filtered
}

Expand Down
7 changes: 6 additions & 1 deletion logservice/schemastore/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ type PersistedDDLEvent struct {
ID int64 `msg:"id"`
Type byte `msg:"type"`

// the tableID for the ddl job in the information_schema.ddl_jobs table(just ddl job.TableID)
// for the partition table, the TableIDInDDLJob is always the logical table id
// for truncate table, the TableIDInDDLJob is the table id of the old table
TableIDInDDLJob int64 `msg:"table_id_in_ddl_job"`

// for exchange partition, it is the info of the partition table
CurrentSchemaID int64 `msg:"current_schema_id"`
CurrentTableID int64 `msg:"current_table_id"`
Expand All @@ -43,7 +48,7 @@ type PersistedDDLEvent struct {
PrevSchemaNames []string `msg:"prev_schema_names"`
PrevTableNames []string `msg:"prev_table_names"`
CurrentSchemaIDs []int64 `msg:"current_schema_ids"`
CurrentSchemaNames []string `msg:"s"`
CurrentSchemaNames []string `msg:"current_schema_names"`

// The following fields are only set when the ddl job involves a partition table
PrevPartitions []int64 `msg:"prev_partitions"`
Expand Down
49 changes: 37 additions & 12 deletions logservice/schemastore/types_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1448f20

Please sign in to comment.