Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#3681
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
LittleFall authored and ti-chi-bot committed Dec 28, 2021
1 parent 0c9c1ff commit 727849c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions dbms/src/Functions/FunctionsTiDBConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,8 @@ struct TiDBConvertToFloat
context.getDAGContext()->handleTruncateError("Truncated incorrect DOUBLE value");
return 0.0;
}
if (float_string.size < trim_string.size())
trim_string[float_string.size] = '\0';
Float64 f = strtod(float_string.data, nullptr);
if (f == std::numeric_limits<Float64>::infinity())
{
Expand Down
12 changes: 9 additions & 3 deletions tests/fullstack-test/expr/cast_string_as_real.test
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
mysql> drop table if exists test.t
mysql> create table test.t(a char(30))
mysql> alter table test.t set tiflash replica 1
mysql> insert into test.t values ('1.23'),('123'),('-123.99'),('+123.123-'),(0),(0.0),(NULL),('1.11.00'),('11xx'),('11.xx'),('xx.11'),('1e649'),('-1e649'),('9.9999999999999999'),('9.999999999999999')
mysql> insert into test.t values ('1.23'),('123'),('-123.99'),('+123.123-'),(0),(0.0),(NULL),('1.11.00'),('11xx'),('11.xx'),('xx.11'),('1e649'),('-1e649'),('9.9999999999999999'),('9.999999999999999');
mysql> insert into test.t values ('0x01'),('-0x01'),('1x01'),('-1x01.2'),('0x01.2'),('x1');

func> wait_table test t

mysql> set tidb_allow_mpp=1; set tidb_isolation_read_engines='tiflash'; select a, b from (select a, cast(a as double) as b from test.t) t group by a, b order by a
mysql> set tidb_enforce_mpp=1; set tidb_isolation_read_engines='tiflash'; select a, cast(a as double) b from test.t order by a;
+--------------------+-------------------------+
| a | b |
+--------------------+-------------------------+
| NULL | NULL |
| +123.123- | 123.123 |
| -0x01 | -0 |
| -123.99 | -123.99 |
| -1e649 | -1.7976931348623157e308 |
| -1x01.2 | -1 |
| 0 | 0 |
| 0.0 | 0 |
| 0x01 | 0 |
| 0x01.2 | 0 |
| 1.11.00 | 1.11 |
| 1.23 | 1.23 |
| 11.xx | 11 |
| 11xx | 11 |
| 123 | 123 |
| 1e649 | 1.7976931348623157e308 |
| 1x01 | 1 |
| 9.999999999999999 | 9.999999999999998 |
| 9.9999999999999999 | 10 |
| x1 | 0 |
| xx.11 | 0 |
+--------------------+-------------------------+

mysql> drop table if exists test.t
14 changes: 14 additions & 0 deletions tests/fullstack-test/expr/issue_3447.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mysql> drop table if exists test.t;
mysql> create table test.t(a char(5));
mysql> alter table test.t set tiflash replica 1;
mysql> insert into test.t values ('0.1'), ('-0.1'), ('0.0'), ('-1'), ('a0.1'), ('0x01');

func> wait_table test t
mysql> select /*+ read_from_storage(tiflash[t]) */ * from test.t where a;
+------+
| a |
+------+
| 0.1 |
| -0.1 |
| -1 |
+------+

0 comments on commit 727849c

Please sign in to comment.