Skip to content

test: add more cases in correctness_for_shared_column_schema#4093

Merged
ti-chi-bot[bot] merged 2 commits intopingcap:masterfrom
wk989898:shareinfo-test
Feb 11, 2026
Merged

test: add more cases in correctness_for_shared_column_schema#4093
ti-chi-bot[bot] merged 2 commits intopingcap:masterfrom
wk989898:shareinfo-test

Conversation

@wk989898
Copy link
Collaborator

@wk989898 wk989898 commented Jan 29, 2026

What problem does this PR solve?

Issue Number: ref #3876

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.

If you don't think this PR needs a release note then fill it with `None`.

Summary by CodeRabbit

  • Tests
    • Added new test namespaces (600–1000 series) with expanded table schemas including new numeric and site identifier columns, updated inserts and DML to exercise the new fields.
    • Changed composite primary-key scenarios to use (a, e) and broadened test selection pattern to include additional test variants, extending coverage for shared-column schema validation.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: wk989898 <nhsmwk@gmail.com>
@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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 29, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

Adds five new test databases (test_600, test_700, test_800, test_900, test_1000) and expands t1 schema in those databases by adding columns c (DECIMAL NULL), d (FLOAT NULL with per-database default), e (DECIMAL NOT NULL), and site_code; the composite primary key is changed from (a, site_code) to (a, e). INSERTs and DML sequences updated accordingly.

Changes

Cohort / File(s) Summary
Downstream prepare
tests/integration_tests/correctness_for_shared_column_schema/data/downstream_prepare.sql
Adds test databases test_600..test_1000; alters t1 for those DBs to include columns c (DECIMAL NULL), d (FLOAT NULL DEFAULT per-db), e (DECIMAL NOT NULL), and site_code (VARCHAR); changes PRIMARY KEY to (a, e) and updates INSERT shapes.
Upstream prepare
tests/integration_tests/correctness_for_shared_column_schema/data/upstream_prepare.sql
Adds matching upstream schema blocks for test_600..test_1000 with same column additions, per-database defaults for d and site_code, and PRIMARY KEY (a, e); inserts new-row variants including e.
Upstream DML sequences
tests/integration_tests/correctness_for_shared_column_schema/data/upstream_dml.sql
Adds USE/INSERT/UPDATE/DELETE sequences for test_600..test_1000 that operate on the expanded schema (notably using e in DML patterns) mirroring existing test flows.
Diff config
tests/integration_tests/correctness_for_shared_column_schema/conf/diff_config.toml
Widened target-check-tables pattern from test_?00.t1 to test_*00.t1 to include the newly named databases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through schemas, neat and quick,
Added numbers, defaults, and a brand-new trick.
Column e takes center stage,
New databases join the page,
A cheerful hop — the tests grow thick! 🎋

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. While it includes the issue reference (ref #3876), it lacks explanation of what changed and how it works, leaving most required sections empty or unanswered. Complete the 'What is changed and how it works?' section, clarify which test type applies, answer the impact questions, and specify the release note (None if not applicable).
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding more test cases to the correctness_for_shared_column_schema test suite.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @wk989898, 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 significantly enhances the test coverage for the correctness_for_shared_column_schema integration test. It introduces more intricate schema evolution scenarios by adding new columns with diverse data types, nullability, and default values, and then incorporates these into the primary key definitions. This ensures the system robustly handles advanced schema changes and data replication, including cases with divergent primary key definitions between upstream and downstream environments.

Highlights

  • Expanded Schema Evolution Tests: New columns (c DECIMAL NULL, d FLOAT NULL with default, e DECIMAL NOT NULL) are added to the t1 table in five test databases (test_100 to test_500) to simulate more complex schema changes and data types.
  • Primary Key Modifications: The primary key for t1 tables in test_100 through test_400 is extended to include the new columns (a, c, d, e, site_code) in both upstream and downstream setups.
  • Specific Test Case for test_500: The test_500 database is configured with a different primary key definition in the downstream setup (PRIMARY KEY (a, site_code)) compared to the upstream setup (PRIMARY KEY (a, c, d, e, site_code)), likely to test specific replication scenarios with differing primary keys.
  • Enhanced Upstream Data Operations: The upstream preparation script now includes ALTER TABLE statements for dynamically adding columns, modifying column properties (e.g., site_code nullability), and additional INSERT statements to populate data after these schema changes.

🧠 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

@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 adds more complex test cases for shared column schema correctness. The changes introduce several DDLs and DMLs to the test setup. My review found a few critical issues in the SQL scripts that will cause the tests to fail. Specifically, the downstream_prepare.sql has invalid INSERT statements and an incorrect primary key definition. The upstream_prepare.sql contains an ALTER TABLE statement that will fail on a non-empty table. Please address these issues to ensure the tests can run correctly.

CREATE DATABASE test_100;
USE test_100;
CREATE TABLE t1 (a INT, b INT, site_code VARCHAR(64) NOT NULL DEFAULT '', PRIMARY KEY (a, site_code));
CREATE TABLE t1 (a INT, b INT, c DECIMAL NULL, d FLOAT NULL DEFAULT 100.0, e DECIMAL NOT NULL, site_code VARCHAR(64) NOT NULL DEFAULT '', PRIMARY KEY (a, c, d, e, site_code));

Choose a reason for hiding this comment

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

critical

This change to the table schema makes the subsequent INSERT statement on line 5 invalid. The INSERT provides 3 values, but the new schema has 6 columns. This will cause a "Column count doesn't match value count" error. Also, the new column e is NOT NULL without a default, so it must be provided in any INSERT statement.

This issue applies to all INSERT statements in this file (lines 5, 11, 17, 23, 29). You need to update them to be compatible with the new table schemas and to populate the downstream tables with the correct initial data for the test.

INSERT INTO t1 VALUES (1, 2), (2, 3);
ALTER TABLE t1 ADD COLUMN c DECIMAL NULL;
ALTER TABLE t1 ADD COLUMN d FLOAT NULL DEFAULT 100.0;
ALTER TABLE t1 ADD COLUMN e DECIMAL NOT NULL;

Choose a reason for hiding this comment

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

critical

This ALTER TABLE statement will fail. You are adding a NOT NULL column e to a non-empty table without providing a DEFAULT value. TiDB (and modern MySQL versions with strict mode) will return an error because it doesn't know what value to use for existing rows.

To fix this, you should provide a default value. This issue is present for all tables being altered in this file (lines 8, 24, 40, 56, 72).

ALTER TABLE t1 ADD COLUMN e DECIMAL NOT NULL DEFAULT 0;

CREATE DATABASE test_500;
USE test_500;
CREATE TABLE t1 (a INT, b INT, site_code VARCHAR(64) NOT NULL DEFAULT '', PRIMARY KEY (a, site_code));
CREATE TABLE t1 (a INT, b INT, c DECIMAL NULL, d FLOAT NULL DEFAULT 500.0, e DECIMAL NOT NULL, site_code VARCHAR(64) NOT NULL DEFAULT '', PRIMARY KEY (a, site_code));

Choose a reason for hiding this comment

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

high

The PRIMARY KEY for test_500.t1 seems incorrect. It is defined as PRIMARY KEY (a, site_code), while for all other tables (test_100.t1 to test_400.t1) it is PRIMARY KEY (a, c, d, e, site_code). The corresponding upstream_prepare.sql also sets the primary key to (a, c, d, e, site_code) for test_500.t1. This inconsistency will likely cause the sync_diff check to fail.

CREATE TABLE t1 (a INT, b INT, c DECIMAL NULL, d FLOAT NULL DEFAULT 500.0, e DECIMAL NOT NULL, site_code VARCHAR(64) NOT NULL DEFAULT '', PRIMARY KEY (a, c, d, e, site_code));

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In
`@tests/integration_tests/correctness_for_shared_column_schema/data/downstream_prepare.sql`:
- Around line 10-11: The INSERT statements for table t1 are providing 3 values
while the CREATE TABLE defines 6 columns (a,b,c,d,e,site_code) and column e is
NOT NULL; update each bad INSERT (the one after CREATE TABLE t1 and the similar
ones in test_200/test_300/test_400) to supply values for all six columns or
explicitly list the target columns to match the provided values — locate the
INSERTs near the CREATE TABLE t1 and either add appropriate values for d, e, and
site_code (or default placeholders) or change the INSERT to specify only the
columns being inserted (e.g., (a,b,c)) so the statement matches the table
schema.
- Around line 28-29: The CREATE TABLE t1 currently declares PRIMARY KEY (a,
site_code) which is inconsistent with upstream's composite key; update the table
definition in downstream_prepare.sql so the PRIMARY KEY matches the upstream
composite key PRIMARY KEY (a, c, d, e, site_code) (or if the difference is
intentional, add a clear inline comment above the CREATE TABLE t1 explaining the
test rationale for using PRIMARY KEY (a, site_code)). Ensure you modify the
CREATE TABLE t1 declaration (and any related INSERT expectations) so tests
remain consistent with the upstream schema.
- Around line 4-5: The INSERT INTO t1 is providing only three values for table
t1 which declares columns a, b, c, d, e, site_code (and e is NOT NULL without a
default), so fix the INSERT INTO t1 statement by adding an explicit column list
that matches the three provided values (e.g., specify which of
a,b,c,d,e,site_code the three literals map to) or supply the full six values
including a value for e (or a DEFAULT) so the VALUES clause matches the table
schema; locate the INSERT INTO t1 line in downstream_prepare.sql and update
either the column list or the VALUES tuple accordingly.

Comment on lines 28 to 29
CREATE TABLE t1 (a INT, b INT, c DECIMAL NULL, d FLOAT NULL DEFAULT 500.0, e DECIMAL NOT NULL, site_code VARCHAR(64) NOT NULL DEFAULT '', PRIMARY KEY (a, site_code));
INSERT INTO t1 VALUES (1, 2, '500'), (2, 3, '500'), (12, 13, '500');
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Inconsistent primary key in test_500.

Line 28 defines PRIMARY KEY (a, site_code) for test_500, while all other databases use PRIMARY KEY (a, c, d, e, site_code). The upstream file (upstream_prepare.sql) uses the composite key (a, c, d, e, site_code) consistently across all 5 databases.

If this inconsistency is intentional for testing purposes, please add a comment explaining the rationale. Otherwise, this appears to be a copy-paste error.

🐛 Proposed fix for consistency
-CREATE TABLE t1 (a INT, b INT, c DECIMAL NULL, d FLOAT NULL DEFAULT 500.0, e DECIMAL NOT NULL, site_code VARCHAR(64) NOT NULL DEFAULT '', PRIMARY KEY (a, site_code));
+CREATE TABLE t1 (a INT, b INT, c DECIMAL NULL, d FLOAT NULL DEFAULT 500.0, e DECIMAL NOT NULL, site_code VARCHAR(64) NOT NULL DEFAULT '', PRIMARY KEY (a, c, d, e, site_code));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
CREATE TABLE t1 (a INT, b INT, c DECIMAL NULL, d FLOAT NULL DEFAULT 500.0, e DECIMAL NOT NULL, site_code VARCHAR(64) NOT NULL DEFAULT '', PRIMARY KEY (a, site_code));
INSERT INTO t1 VALUES (1, 2, '500'), (2, 3, '500'), (12, 13, '500');
CREATE TABLE t1 (a INT, b INT, c DECIMAL NULL, d FLOAT NULL DEFAULT 500.0, e DECIMAL NOT NULL, site_code VARCHAR(64) NOT NULL DEFAULT '', PRIMARY KEY (a, c, d, e, site_code));
INSERT INTO t1 VALUES (1, 2, '500'), (2, 3, '500'), (12, 13, '500');
🤖 Prompt for AI Agents
In
`@tests/integration_tests/correctness_for_shared_column_schema/data/downstream_prepare.sql`
around lines 28 - 29, The CREATE TABLE t1 currently declares PRIMARY KEY (a,
site_code) which is inconsistent with upstream's composite key; update the table
definition in downstream_prepare.sql so the PRIMARY KEY matches the upstream
composite key PRIMARY KEY (a, c, d, e, site_code) (or if the difference is
intentional, add a clear inline comment above the CREATE TABLE t1 explaining the
test rationale for using PRIMARY KEY (a, site_code)). Ensure you modify the
CREATE TABLE t1 declaration (and any related INSERT expectations) so tests
remain consistent with the upstream schema.

@wk989898
Copy link
Collaborator Author

/test mysql

Signed-off-by: wk989898 <nhsmwk@gmail.com>
@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 Jan 30, 2026
@wk989898
Copy link
Collaborator Author

/test mysql

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Feb 10, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 11, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3AceShowHand, hongyunyan

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:
  • OWNERS [3AceShowHand,hongyunyan]

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 11, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 11, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-02-10 06:02:50.179768121 +0000 UTC m=+251185.873907971: ☑️ agreed by hongyunyan.
  • 2026-02-11 04:14:26.793129772 +0000 UTC m=+331082.487269632: ☑️ agreed by 3AceShowHand.

@wk989898
Copy link
Collaborator Author

/retest

1 similar comment
@wk989898
Copy link
Collaborator Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 5a27a04 into pingcap:master Feb 11, 2026
23 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments