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

types: Regard TypeNewDecimal as not a hasVariantFieldLength type. #21849

Merged
merged 22 commits into from
Dec 23, 2020

Conversation

LittleFall
Copy link
Contributor

@LittleFall LittleFall commented Dec 17, 2020

What problem does this PR solve?

Issue Number: close #21804

Problem Summary:

Tiflash will check whether Decimal's flen is between 1 and 65. But TiDB enable will push down a Decimal constant with flen -1 from the environment parameter.

What is changed and how it works?

What's Changed:

When creating a decimal variable from Parameter, don't set it's flen to -1.

Other types in hasVariantFieldLength don't have this problem.

Related changes

  • Need to cherry-pick to the release 4.0

Check List

Tests

  • Unit test
    (will be added to tiflash repo)
  • Integration test
  • Manual test (add detailed scripts or steps below)
create table t (c_decimal decimal);
alter table t set tiflash replica 1; -- wait ready.
insert into t values (9), (10);
prepare s1 from 'select * from t where ? <= c_decimal';
set @v1 = 9.330;
execute s1 using @v1;
+-----------+
| c_decimal |
+-----------+
|        10 |
+-----------+

test for issue/8644

mysql> create table t(d decimal(3,2));
mysql> alter table t set tiflash replica 1; --wait ready

mysql> insert into t values (1.11), (2.222);
Query OK, 2 rows affected, 1 warning (0.03 sec) -- the warning is: Truncated incorrect DECIMAL value: '2.222'
mysql> insert into t values (33.3);
ERROR 1264 (22003): Out of range value for column 'd' at row 1

mysql> insert into t values ('1.11'), ('2.222');
Query OK, 2 rows affected, 1 warning (0.01 sec)
mysql> insert into t values ('33.3');
ERROR 1264 (22003): Out of range value for column 'd' at row 1

mysql> prepare s1 from 'insert t (d) values (?), (?)';
mysql> prepare s2 from 'insert t (d) values (?)';

mysql> set @a='1.11', @b='2.222', @c='33.3';
mysql> execute s1 using @a, @b;
Query OK, 2 rows affected, 1 warning (0.01 sec)
mysql> execute s2 using @c;
ERROR 1264 (22003): Out of range value for column 'd' at row 1

mysql> set @a=1.11, @b=2.222, @c=33.3;
mysql> execute s1 using @a, @b;
Query OK, 2 rows affected, 1 warning (0.02 sec)
mysql> execute s2 using @c;
ERROR 1264 (22003): Out of range value for column 'd' at row 1

Side effects

  • N/A

Release note

  • Fixed the issue that using prepare statement to cache execution plan caused tiflash to return Wrong precision.

@LittleFall LittleFall requested a review from a team as a code owner December 17, 2020 06:31
@LittleFall LittleFall requested review from SunRunAway and removed request for a team December 17, 2020 06:31
@sre-bot
Copy link
Contributor

sre-bot commented Dec 17, 2020

@sre-bot
Copy link
Contributor

sre-bot commented Dec 17, 2020

1 similar comment
@sre-bot
Copy link
Contributor

sre-bot commented Dec 17, 2020

@LittleFall
Copy link
Contributor Author

/run-check_release_note

@LittleFall
Copy link
Contributor Author

/cc @eurekaka @dbjoa

@LittleFall
Copy link
Contributor Author

/cc eurekaka,dbjoa

@LittleFall
Copy link
Contributor Author

/run-all-tests

@LittleFall
Copy link
Contributor Author

/label needs-cherry-pick-4.0

@LittleFall
Copy link
Contributor Author

/label bug-fix

@ti-srebot
Copy link
Contributor

These labels are not found bug-fix.

@eurekaka eurekaka added the type/bugfix This PR fixes a bug. label Dec 17, 2020
@ichn-hu ichn-hu mentioned this pull request Dec 17, 2020
executor/seqtest/prepared_test.go Outdated Show resolved Hide resolved
executor/seqtest/prepared_test.go Show resolved Hide resolved
Co-authored-by: Kenan Yao <cauchy1992@gmail.com>
Copy link
Contributor

@lzmhhh123 lzmhhh123 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
Copy link
Contributor

@LittleFall merge failed.

@LittleFall LittleFall dismissed stale reviews from ti-srebot, ichn-hu, and eurekaka via ff693ad December 22, 2020 08:15
@LittleFall
Copy link
Contributor Author

/run-all-tests

@lzmhhh123
Copy link
Contributor

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

/run-all-tests

@lzmhhh123
Copy link
Contributor

/merge

@ti-srebot
Copy link
Contributor

Your auto merge job has been accepted, waiting for:

  • 21922
  • 21832

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@LittleFall merge failed.

@lzmhhh123
Copy link
Contributor

/merge

@ti-srebot
Copy link
Contributor

Your auto merge job has been accepted, waiting for:

  • 21903

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@LittleFall merge failed.

@lzmhhh123 lzmhhh123 merged commit 0370fbf into pingcap:master Dec 23, 2020
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Dec 23, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #21960

Tjianke pushed a commit to Tjianke/tidb that referenced this pull request Dec 25, 2020
eurekaka added a commit that referenced this pull request Jan 8, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

Co-authored-by: Zhi Qi <30543181+LittleFall@users.noreply.github.com>
Co-authored-by: Kenan Yao <cauchy1992@gmail.com>
@LittleFall LittleFall deleted the decimal branch May 20, 2021 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong precision using prepare statement and tiflash
6 participants