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: refine error messages in unsupported column options #11065

Merged
merged 7 commits into from
Jul 12, 2019

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Jul 4, 2019

What problem does this PR solve?

Fix #10731 and fix #11052.

What is changed and how it works?

  1. Add more cases in switch in processColumnOptions(), avoiding the obscure error message in unsupported modify column %!s(ast.ColumnOptionType=12) #10731.

  2. getModifiableColumnJob() is used to build a ActionModifyColumn DDL job. It contains two methods:

    • modifiable(), check whether the FieldType of the origin column can be changed into the new column. The checks include charset, collation, types, Flen/Decimal, etc.
    • processColumnOptions(), set FieldType of the new column, according to Option in ColumnDef, which is filled by SQL parser.

    Obviously, we should first set the FieldType and then check it. So processColumnOptions() should come first.

Check List

Tests

  • Unit test
  • Integration test

Related changes

  • Need to cherry-pick to the release branch

@codecov
Copy link

codecov bot commented Jul 4, 2019

Codecov Report

Merging #11065 into master will decrease coverage by 0.3395%.
The diff coverage is 66.6666%.

@@               Coverage Diff                @@
##             master     #11065        +/-   ##
================================================
- Coverage   81.5925%   81.2529%   -0.3396%     
================================================
  Files           424        423         -1     
  Lines         91626      90025      -1601     
================================================
- Hits          74760      73148      -1612     
- Misses        11540      11578        +38     
+ Partials       5326       5299        -27

Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

LGTM

ddl/ddl_api.go Outdated Show resolved Hide resolved
@AilinKid
Copy link
Contributor

I have tried following SQL on the code, but got following error:
ERROR 1105 (HY000): unsupported modify collate from utf8mb4_bin to utf8mb4_general_ci
Maybe be we should put the modifiable() func first, and that's actually works.

CREATE TABLE t6(a char(1))DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ;

ALTER TABLE t6 MODIFY COLUMN a char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ;

@winkyao winkyao added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 10, 2019
@tangenta
Copy link
Contributor Author

@AilinKid Which TiDB version did you use?

mysql root@127.0.0.1:test> CREATE TABLE t6(a char(1))DEFAULT CHARSET=utf8mb4 COL
                           LATE=utf8mb4_general_ci ;                            
Query OK, 0 rows affected
Time: 0.014s
mysql root@127.0.0.1:test> ALTER TABLE t6 MODIFY COLUMN a char(1) CHARACTER SET 
                           utf8mb4 COLLATE utf8mb4_general_ci ;                 
Query OK, 0 rows affected
Time: 0.014s
mysql root@127.0.0.1:test> select tidb_version();                               
1 row in set
Time: 0.029s
mysql root@127.0.0.1:test> select tidb_version();                                                                                                                                                                                                             
+--------------------------------------------------------------------------+
| tidb_version()                                                           |
+--------------------------------------------------------------------------+
| Release Version: v3.0.0-rc.1-309-g34720acda                              |
| Git Commit Hash: 34720acda1eec86ff93494c8890cb2a1b4d6d478                |
| Git Branch: changing-collation                                           |
| UTC Build Time: 2019-07-10 09:12:23                                      |
| GoVersion: go version go1.12.5 linux/amd64                               |
| Race Enabled: false                                                      |
| TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e |
| Check Table Before Drop: false                                           |
+--------------------------------------------------------------------------+
1 row in set
Time: 0.015s

git log:

commit 34720acda1eec86ff93494c8890cb2a1b4d6d478 (HEAD -> changing-collation, origin/changing-collation)
Author: tangenta <tangenta@126.com>
Date:   Wed Jul 10 15:39:13 2019 +0800

    refine error message

@AilinKid AilinKid closed this Jul 10, 2019
@winkyao winkyao reopened this Jul 10, 2019
ddl/ddl_api.go Outdated Show resolved Hide resolved
@tangenta
Copy link
Contributor Author

/run-all-tests

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

@tangenta tangenta removed the status/LGT1 Indicates that a PR has LGTM 1. label Jul 11, 2019
@tangenta tangenta added the status/LGT2 Indicates that a PR has LGTM 2. label Jul 11, 2019
@AilinKid
Copy link
Contributor

LGTM

Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

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

LGTM

@sre-bot
Copy link
Contributor

sre-bot commented Apr 7, 2020

It seems that, not for sure, we failed to cherry-pick this commit to release-2.1. Please comment '/run-cherry-picker' to try to trigger the cherry-picker if we did fail to cherry-pick this commit before. @tangenta PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/sql-infra SIG: SQL Infra status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
8 participants