fix parsing of ints

This commit is contained in:
Anton Popov 2022-04-19 13:31:04 +00:00
parent 56bdc654d4
commit 7b7939c52c
6 changed files with 47 additions and 18 deletions

View File

@ -33,7 +33,12 @@ DataTypePtr DataTypeFactory::get(const String & full_name) const
/// Value 315 is known to cause stack overflow in some test configurations (debug build, sanitizers)
/// let's make the threshold significantly lower.
/// It is impractical for user to have complex data types with this depth.
static constexpr size_t data_type_max_parse_depth = 200;
#if defined(SANITIZER) || !defined(NDEBUG)
static constexpr size_t data_type_max_parse_depth = 150;
#else
static constexpr size_t data_type_max_parse_depth = 300;
#endif
ParserDataType parser;
ASTPtr ast = parseQuery(parser, full_name.data(), full_name.data() + full_name.size(), "data type", 0, data_type_max_parse_depth);

View File

@ -100,9 +100,8 @@ bool ParserDataType::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
else if (pos->type == TokenType::OpeningRoundBracket)
{
++pos;
if (pos->type != TokenType::Number)
return false;
++pos;
if (pos->type == TokenType::Number)
++pos;
if (pos->type != TokenType::ClosingRoundBracket)
return false;
++pos;

View File

@ -1,5 +1 @@
1
CREATE TEMPORARY TABLE t3_00841\n(\n `x` UInt32\n)\nENGINE = Memory
1
CREATE TEMPORARY TABLE t4_00841\n(\n `x` Int32\n)\nENGINE = Memory
1

View File

@ -3,13 +3,3 @@ INSERT INTO t1_00841 VALUES (1);
SELECT * FROM t1_00841;
CREATE TEMPORARY TABLE test.t2_00841 (x UInt8); -- { serverError 442 }
CREATE TEMPORARY TABLE t3_00841 (x INT(11) UNSIGNED);
SHOW CREATE TEMPORARY TABLE t3_00841;
INSERT INTO t3_00841 VALUES (1);
SELECT * FROM t3_00841;
CREATE TEMPORARY TABLE t4_00841 (x INT(11) SIGNED);
SHOW CREATE TEMPORARY TABLE t4_00841;
INSERT INTO t4_00841 VALUES (1);
SELECT * FROM t4_00841;

View File

@ -0,0 +1,10 @@
CREATE TEMPORARY TABLE t1_02271\n(\n `x` Int32\n)\nENGINE = Memory
CREATE TEMPORARY TABLE t2_02271\n(\n `x` Int32 DEFAULT 1\n)\nENGINE = Memory
CREATE TEMPORARY TABLE t3_02271\n(\n `x` UInt32\n)\nENGINE = Memory
CREATE TEMPORARY TABLE t4_02271\n(\n `x` Int32\n)\nENGINE = Memory
CREATE TEMPORARY TABLE t5_02271\n(\n `x` Int32 DEFAULT 1\n)\nENGINE = Memory
CREATE TEMPORARY TABLE t6_02271\n(\n `x` Int32\n)\nENGINE = Memory
CREATE TEMPORARY TABLE t7_02271\n(\n `x` Int32 DEFAULT 1\n)\nENGINE = Memory
CREATE TEMPORARY TABLE t8_02271\n(\n `x` UInt32\n)\nENGINE = Memory
CREATE TEMPORARY TABLE t9_02271\n(\n `x` Int32\n)\nENGINE = Memory
CREATE TEMPORARY TABLE t10_02271\n(\n `x` Int32 DEFAULT 1\n)\nENGINE = Memory

View File

@ -0,0 +1,29 @@
CREATE TEMPORARY TABLE t1_02271 (x INT(11));
SHOW CREATE TEMPORARY TABLE t1_02271;
CREATE TEMPORARY TABLE t2_02271 (x INT(11) DEFAULT 1);
SHOW CREATE TEMPORARY TABLE t2_02271;
CREATE TEMPORARY TABLE t3_02271 (x INT(11) UNSIGNED);
SHOW CREATE TEMPORARY TABLE t3_02271;
CREATE TEMPORARY TABLE t4_02271 (x INT(11) SIGNED);
SHOW CREATE TEMPORARY TABLE t4_02271;
CREATE TEMPORARY TABLE t5_02271 (x INT(11) SIGNED DEFAULT 1);
SHOW CREATE TEMPORARY TABLE t5_02271;
CREATE TEMPORARY TABLE t6_02271 (x INT());
SHOW CREATE TEMPORARY TABLE t6_02271;
CREATE TEMPORARY TABLE t7_02271 (x INT() DEFAULT 1);
SHOW CREATE TEMPORARY TABLE t7_02271;
CREATE TEMPORARY TABLE t8_02271 (x INT() UNSIGNED);
SHOW CREATE TEMPORARY TABLE t8_02271;
CREATE TEMPORARY TABLE t9_02271 (x INT() SIGNED);
SHOW CREATE TEMPORARY TABLE t9_02271;
CREATE TEMPORARY TABLE t10_02271 (x INT() SIGNED DEFAULT 1);
SHOW CREATE TEMPORARY TABLE t10_02271;