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

executor: truncate the trailing spaces for "CHAR[(M)]" types #3878

Merged
merged 15 commits into from Aug 1, 2017

Conversation

zz-jason
Copy link
Member

fix #3660

@zz-jason
Copy link
Member Author

@shenli @XuHuaiyu @zimulala PTAL

@@ -873,11 +871,27 @@ func (e *InsertValues) getRowsSelect(cols []*table.Column) ([][]types.Datum, err
return rows, nil
}

func (e *InsertValues) truncateTrailingSpaces(v *types.Datum) {
if v.Kind() == types.KindNull {
Copy link
Member

@jackysp jackysp Jul 25, 2017

Choose a reason for hiding this comment

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

Is it suitable for all kinds of datum to truncate tail spaces, except KindNull?

Copy link
Member Author

@zz-jason zz-jason Jul 25, 2017

Choose a reason for hiding this comment

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

no, only char[(m)] type with non-null values

@@ -873,11 +871,27 @@ func (e *InsertValues) getRowsSelect(cols []*table.Column) ([][]types.Datum, err
return rows, nil
}

func (e *InsertValues) truncateTrailingSpaces(v *types.Datum) {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a comment for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@XuHuaiyu
Copy link
Contributor

LGTM

XuHuaiyu
XuHuaiyu previously approved these changes Jul 26, 2017
@XuHuaiyu XuHuaiyu added the status/LGT2 Indicates that a PR has LGTM 2. label Jul 26, 2017
@@ -809,6 +809,11 @@ func (s *testSuite) TestStringBuiltin(c *C) {
tk.MustExec(`insert into t values(1, 1.1, "2017-01-01 12:01:01", "12:01:01", "abcdef", 0b10101)`)
result := tk.MustQuery("select length(a), length(b), length(c), length(d), length(e), length(f), length(null) from t")
result.Check(testkit.Rows("1 3 19 8 6 2 <nil>"))
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a char(20))")
Copy link
Member

Choose a reason for hiding this comment

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

In the issue #3660 , the column uses b char (10) binary not null). But the test does not use binary charset? Are they the same scenario?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is another issue. mysql use binary as a flag of that column, while tidb use binary flag to indicate the type of that column is binary

@XuHuaiyu XuHuaiyu added the DNM label Jul 26, 2017
@tiancaiamao
Copy link
Contributor

@zz-jason Please resolve conflict.

@zz-jason
Copy link
Member Author

zz-jason commented Aug 1, 2017

@XuHuaiyu PTAL

@zz-jason zz-jason added status/LGT1 Indicates that a PR has LGTM 1. and removed DNM status/LGT2 Indicates that a PR has LGTM 2. labels Aug 1, 2017
table/column.go Outdated
@@ -135,7 +136,7 @@ func CastValues(ctx context.Context, rec []types.Datum, cols []*Column, ignoreEr
}
}
rec[c.Offset] = converted
if c.Tp == mysql.TypeString && !mysql.HasBinaryFlag(c.Flag) {
if c.Tp == mysql.TypeString && c.Collate != charset.CollationBin {
Copy link
Contributor

Choose a reason for hiding this comment

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

@zz-jason

if c.Tp == mysql.TypeString && types.IsBinaryStr(c.Tp)

fix the implementation of IsBinaryStr()

Copy link
Member Author

Choose a reason for hiding this comment

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

done, @XuHuaiyu PTAL again

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@XuHuaiyu XuHuaiyu merged commit 01c1d4c into master Aug 1, 2017
@XuHuaiyu XuHuaiyu deleted the 3660-insert branch August 1, 2017 08:15
@shenli shenli added the rc3.1 label Aug 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Insert data need to filter spaces
6 participants