mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 13:32:13 +00:00
Consume leading zeroes when parsing a number in ConstantExpressionTemplate
This commit is contained in:
parent
57df56733f
commit
7e3587034d
@ -597,6 +597,10 @@ bool ConstantExpressionTemplate::parseLiteralAndAssertType(
|
|||||||
if (negative || *istr.position() == '+')
|
if (negative || *istr.position() == '+')
|
||||||
++istr.position();
|
++istr.position();
|
||||||
|
|
||||||
|
/// Consume leading zeroes - we don't want any funny octal business
|
||||||
|
while (*istr.position() == '0')
|
||||||
|
++istr.position();
|
||||||
|
|
||||||
static constexpr size_t MAX_LENGTH_OF_NUMBER = 319;
|
static constexpr size_t MAX_LENGTH_OF_NUMBER = 319;
|
||||||
char buf[MAX_LENGTH_OF_NUMBER + 1];
|
char buf[MAX_LENGTH_OF_NUMBER + 1];
|
||||||
size_t bytes_to_copy = std::min(istr.available(), MAX_LENGTH_OF_NUMBER);
|
size_t bytes_to_copy = std::min(istr.available(), MAX_LENGTH_OF_NUMBER);
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
-0.02 0
|
||||||
|
0 0
|
||||||
|
0.01 0
|
||||||
|
0.02 1
|
||||||
|
0.03 1
|
||||||
|
0.04 -1
|
||||||
|
1 1
|
||||||
|
2 5
|
||||||
|
3 8
|
||||||
|
4 17
|
||||||
|
5 21
|
||||||
|
6 51
|
||||||
|
7 123
|
||||||
|
8 16
|
||||||
|
9 43981
|
@ -0,0 +1,8 @@
|
|||||||
|
DROP TABLE IF EXISTS t_leading_zeroes;
|
||||||
|
CREATE TABLE t_leading_zeroes(ref Float64, val INTEGER) ENGINE=MergeTree ORDER BY ref;
|
||||||
|
|
||||||
|
INSERT INTO t_leading_zeroes VALUES (-0.02, 00000), (0, 0), (0.01, 00), (0.02, 01), (0.03, +01), (0.04, -01), (1, 0001), (2, 0005), (3, 0008), (4, 0017), (5, 0021), (6, 0051), (7, 00000123), (8, 0b10000), (9, 0x0abcd);
|
||||||
|
|
||||||
|
SELECT * FROM t_leading_zeroes;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS t_leading_zeroes;
|
Loading…
Reference in New Issue
Block a user