Skip to content

Commit

Permalink
Fix the inconsistent behavior of CastStringAsDecimal between tiflash …
Browse files Browse the repository at this point in the history
…and tidb/tikv. (#3621) (#3676)

close #3619
  • Loading branch information
ti-chi-bot authored Apr 14, 2022
1 parent 2e942df commit 8b15703
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dbms/src/Functions/FunctionsTiDBConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -1011,9 +1011,9 @@ struct TiDBConvertToDecimal
size_t pos = 0;
if (decimal_parts.int_part.data[pos] == '+' || decimal_parts.int_part.data[pos] == '-')
{
pos++;
if (decimal_parts.int_part.data[pos] == '-')
is_negative = true;
pos++;
}
Int256 max_value = DecimalMaxValue::Get(prec);

Expand Down
22 changes: 22 additions & 0 deletions tests/fullstack-test/expr/cast_string_as_decimal.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
mysql> drop table if exists test.t
mysql> create table test.t(a char(10))
mysql> alter table test.t set tiflash replica 1
mysql> insert into test.t values('-123')
mysql> insert into test.t values('2006-01')

func> wait_table test t

mysql> set tidb_enforce_mpp=1; select cast(a as decimal) from test.t;
+--------------------+
| cast(a as decimal) |
+--------------------+
| -123 |
| 2006 |
+--------------------+
mysql> set @@tidb_isolation_read_engines='tikv'; select cast(a as decimal) from test.t;
+--------------------+
| cast(a as decimal) |
+--------------------+
| -123 |
| 2006 |
+--------------------+

0 comments on commit 8b15703

Please sign in to comment.