Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: support column type change between decimal && SQL mode warnings #20012

Merged
merged 19 commits into from
Sep 29, 2020

Conversation

AilinKid
Copy link
Contributor

@AilinKid AilinKid commented Sep 15, 2020

Signed-off-by: AilinKid [email protected]

What problem does this PR solve?

Issue Number: close #19121

Since #19059 has supported the column type change between integers.

Linked Parser PR pingcap/parser#1031

  1. This PR is to support the column type change between decimal, for example, changing decimal(5,2) to decimal(3,1).

  2. This PR also tries to supply a kind of way to support the normal DDL warnings and strict DDL warnings which will be identified as warnings under non-strict SQL mode, otherwise, will be identified as errors.

What is changed and how it works?

What's Changed:

1: We have added the SQL Mode and warnings field in the parser. For why we don't put this into the job args directly, because the job args sometime will be cleaned at the end of finishDDLJob, and be substituted with delete range ids.

2: This PR only handled the SQL Mode and limited warning for column type change of decimal. There will be PRs later to complement the next works. For example, pass the SQL mode parameter to all DDL jobs and handle its warnings.

3: This PR only handled the column type between decimal, for more numeric types, such as float and double, more PRs is necessary.

Check List

Tests

  • Unit test
  • Integration test

Release note

  • ddl: support column type change between decimal && SQL mode warnings

ddl/index.go Outdated Show resolved Hide resolved
ddl/ddl.go Outdated Show resolved Hide resolved
ddl/column.go Outdated Show resolved Hide resolved
ddl/column.go Outdated Show resolved Hide resolved
ddl/backfilling.go Outdated Show resolved Hide resolved
ddl/column.go Outdated Show resolved Hide resolved
ddl/column.go Outdated Show resolved Hide resolved
@AilinKid AilinKid self-assigned this Sep 24, 2020
Comment on lines +4632 to +4641
Warnings: make(map[errors.ErrorID]*terror.Error),
WarningsCount: make(map[errors.ErrorID]int64),
Copy link
Contributor

Choose a reason for hiding this comment

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

How about merge those 2 maps into 1 map?

Copy link
Contributor Author

@AilinKid AilinKid Sep 27, 2020

Choose a reason for hiding this comment

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

good idea, how about refine this point in the next PR? (it needs an update in the parser and covers many code)

ddl/db_test.go Outdated Show resolved Hide resolved
ddl/db_test.go Outdated Show resolved Hide resolved
ddl/db_test.go Outdated Show resolved Hide resolved
ddl/reorg.go Outdated Show resolved Hide resolved
job.SetWarnings(mergeWarningsAndWarningsCount(partWarnings, job.ReorgMeta.Warnings, partWarningsCount, job.ReorgMeta.WarningsCount))
w.reorgCtx.mu.Unlock()

w.reorgCtx.resetWarnings()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we need to reset warnings here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a partial result. After it was merged into the job, the next round DDL will collect new ones.

@AilinKid
Copy link
Contributor Author

/run-all-tests

.
Signed-off-by: AilinKid <[email protected]>
@AilinKid
Copy link
Contributor Author

/run-all-tests

ddl/db_test.go Show resolved Hide resolved
ddl/db_test.go Show resolved Hide resolved
ddl/ddl_api.go Show resolved Hide resolved
ddl/db_test.go Outdated Show resolved Hide resolved
ddl/column.go Outdated Show resolved Hide resolved
Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

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

REST LGTM

@AilinKid
Copy link
Contributor Author

/run-all-tests

Copy link
Member

@bb7133 bb7133 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-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 29, 2020
Copy link
Contributor

@crazycs520 crazycs520 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-srebot ti-srebot removed the status/LGT1 Indicates that a PR has LGTM 1. label Sep 29, 2020
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Sep 29, 2020
@AilinKid
Copy link
Contributor Author

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 29, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@AilinKid merge failed.

@AilinKid
Copy link
Contributor Author

/build

@AilinKid AilinKid merged commit c8221fa into pingcap:master Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/sql-infra SIG: SQL Infra status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supports transitions between the same type (other Numeric types)
5 participants