Skip to content

master(dm): support extra SHOW FULL TABLES columns from PolarDB-X#12481

Merged
ti-chi-bot[bot] merged 4 commits intopingcap:masterfrom
GMHDBJD:aliShowTables
Mar 25, 2026
Merged

master(dm): support extra SHOW FULL TABLES columns from PolarDB-X#12481
ti-chi-bot[bot] merged 4 commits intopingcap:masterfrom
GMHDBJD:aliShowTables

Conversation

@GMHDBJD
Copy link
Copy Markdown
Contributor

@GMHDBJD GMHDBJD commented Jan 7, 2026

What problem does this PR solve?

Issue Number: close #12569

What is changed and how it works?

  • add a DM-local conn.GetTables helper for table discovery
  • keep the original SHOW FULL TABLES ... WHERE Table_Type != 'VIEW' behavior for normal MySQL/TiDB results
  • ignore extra columns after the first two scan targets so PolarDB-X 4-column results are accepted
  • add regression tests for both standard 2-column results and PolarDB-X-style 4-column results

Check List

Tests

  • Unit test: go test ./dm/pkg/conn -run 'TestGetTables|TestFetchAllDoTables'
  • Build/compile check: go test ./dm/pkg/checker ./dm/master -run '^$'

Questions

Will it cause performance regression or break compatibility?

No. Existing behavior for standard upstreams is kept unchanged. The parsing only becomes more permissive for extra result columns.

Do you need to update user documentation, design documentation or monitoring documentation?

No.

Release note

Support PolarDB-X SHOW FULL TABLES results with extra columns in DM table discovery.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note Denotes a PR that will be considered when it comes time to generate release notes. area/dm Issues or PRs related to DM. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 7, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @GMHDBJD, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a refactoring effort to enhance code consistency by relocating the GetTables utility function. Previously residing in the dbutil package, this function has now been moved to dm/pkg/conn/db.go, centralizing database-related table retrieval logic. All instances where dbutil.GetTables was invoked have been updated to correctly reference the new conn.GetTables function, streamlining dependencies and improving maintainability.

Highlights

  • GetTables Function Relocation: The GetTables utility function has been moved from github.com/pingcap/tidb/pkg/util/dbutil to dm/pkg/conn/db.go to centralize database connection-related utilities.
  • Dependency Update: Imports and call sites across dm/master/openapi_view.go and dm/pkg/checker/onlineddl.go have been updated to reflect the new location of the GetTables function, now referencing conn.GetTables.
  • Code Consistency: This refactoring improves code consistency by consolidating database table retrieval logic within the conn package, reducing reliance on external dbutil for this specific functionality.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the code to use conn.GetTables instead of dbutil.GetTables, which is a good improvement for code organization. The implementation of the new conn.GetTables function is mostly correct, but I've suggested a couple of minor improvements for consistency and idiomatic Go.

A more critical issue is that the unit tests in dm/pkg/conn/db_test.go and dm/master/openapi_view_test.go appear to be broken by this change. They still mock the old SQL query from dbutil.GetTables (SHOW FULL TABLES ... WHERE ...). Please update the mocked queries to SHOW FULL TABLES IN ... without the WHERE clause to match the new implementation in conn.GetTables.

Comment thread dm/pkg/conn/db.go Outdated
Comment on lines +574 to +576
if len(cols) < 2 {
return nil, errors.New("SHOW FULL TABLES returned less than 2 columns")
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the error handling in this package, it's better to return a terror error instead of a raw error created with errors.New. You can use terror.ErrDBUnExpect.Generate for this.

Suggested change
if len(cols) < 2 {
return nil, errors.New("SHOW FULL TABLES returned less than 2 columns")
}
if len(cols) < 2 {
return nil, terror.ErrDBUnExpect.Generate("SHOW FULL TABLES returned less than 2 columns")
}

Comment thread dm/pkg/conn/db.go Outdated
Comment on lines +583 to +584
var dummy interface{}
scanArgs[i] = &dummy
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This loop for creating dummy scan arguments can be made more efficient and idiomatic. Instead of declaring a new dummy variable in each iteration, you can allocate space for the columns you want to ignore directly. Using sql.RawBytes is a good practice for this as it can avoid extra allocations.

Suggested change
var dummy interface{}
scanArgs[i] = &dummy
scanArgs[i] = new(sql.RawBytes)

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 23, 2026
@GMHDBJD GMHDBJD changed the title refactor(conn): replace dbutil.GetTables with conn.GetTables for cons… master(dm): support extra SHOW FULL TABLES columns from PolarDB-X Mar 23, 2026
@GMHDBJD GMHDBJD added type/bugfix This PR fixes a bug. and removed do-not-merge/needs-linked-issue labels Mar 23, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 76.31579% with 9 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@abbaf8d). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
Components Coverage Δ
cdc 57.3464% <ø> (?)
dm 49.1038% <76.3157%> (?)
engine 50.6997% <ø> (?)
Flag Coverage Δ
cdc 57.3464% <ø> (?)
unit 53.3819% <76.3157%> (?)

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

@@             Coverage Diff             @@
##             master     #12481   +/-   ##
===========================================
  Coverage          ?   53.3819%           
===========================================
  Files             ?       1011           
  Lines             ?     139905           
  Branches          ?          0           
===========================================
  Hits              ?      74684           
  Misses            ?      59614           
  Partials          ?       5607           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@GMHDBJD
Copy link
Copy Markdown
Contributor Author

GMHDBJD commented Mar 23, 2026

/retest

Comment thread dm/pkg/conn/table.go
return tables, errors.Trace(rows.Err())
}

func escapeName(name string) string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR, but I found that there are three places in TiDB with this same (unexported) function 😂

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Mar 25, 2026

@joechenrh: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

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.

Comment thread dm/pkg/conn/table.go
Comment thread dm/master/openapi_view.go
}
defer baseDB.Close()
tableList, err := dbutil.GetTables(c.Request.Context(), baseDB.DB, schemaName)
tableList, err := conn.GetTables(c.Request.Context(), baseDB.DB, schemaName)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add one 4-column regression for OpenAPIViewSuite.TestSourceAPI and one for the online-DDL checker path too? Right now the new coverage is mostly helper-level.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread dm/pkg/conn/db_test.go
Copy link
Copy Markdown
Contributor

@OliverS929 OliverS929 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall. One small follow-up: please consider adding a test that actually enables config.OnlineDDLChecking or exercises OnlineDDLChecker.Check.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 25, 2026
@GMHDBJD
Copy link
Copy Markdown
Contributor Author

GMHDBJD commented Mar 25, 2026

/retest

Copy link
Copy Markdown
Contributor

@Benjamin2037 Benjamin2037 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot ti-chi-bot bot added the lgtm label Mar 25, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Mar 25, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, joechenrh, OliverS929

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

The pull request process is described 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 ti-chi-bot bot added approved and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 25, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Mar 25, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-03-25 10:18:00.230622887 +0000 UTC m=+349876.266693167: ☑️ agreed by OliverS929.
  • 2026-03-25 11:50:24.431344606 +0000 UTC m=+355420.467414866: ☑️ agreed by Benjamin2037.

@GMHDBJD
Copy link
Copy Markdown
Contributor Author

GMHDBJD commented Mar 25, 2026

/retest

@ti-chi-bot ti-chi-bot bot merged commit 8c5244d into pingcap:master Mar 25, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved area/dm Issues or PRs related to DM. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/bugfix This PR fixes a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DM: support PolarDB-X SHOW FULL TABLES result with extra columns

4 participants