mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Fixed incorrect assertion in INSERT queries with binary formats. [#CLICKHOUSE-3242]
This commit is contained in:
parent
7fa337c297
commit
02f0bcb17f
@ -80,22 +80,23 @@ bool ParserInsertQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
|||||||
if (!name_p.parse(pos, format, expected))
|
if (!name_p.parse(pos, format, expected))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (pos->type == TokenType::Semicolon)
|
|
||||||
throw Exception("You have excessive ';' symbol before data for INSERT.\n"
|
|
||||||
"Example:\n\n"
|
|
||||||
"INSERT INTO t (x, y) FORMAT TabSeparated\n"
|
|
||||||
"1\tHello\n"
|
|
||||||
"2\tWorld\n"
|
|
||||||
"\n"
|
|
||||||
"Note that there is no ';' in first line.", ErrorCodes::SYNTAX_ERROR);
|
|
||||||
|
|
||||||
/// Data starts after the first newline, if there is one, or after all the whitespace characters, otherwise.
|
|
||||||
|
|
||||||
data = name_pos->end;
|
data = name_pos->end;
|
||||||
|
|
||||||
|
if (data < end && *data == ';')
|
||||||
|
throw Exception("You have excessive ';' symbol before data for INSERT.\n"
|
||||||
|
"Example:\n\n"
|
||||||
|
"INSERT INTO t (x, y) FORMAT TabSeparated\n"
|
||||||
|
";\tHello\n"
|
||||||
|
"2\tWorld\n"
|
||||||
|
"\n"
|
||||||
|
"Note that there is no ';' just after format name, "
|
||||||
|
"you need to put at least one whitespace symbol before the data.", ErrorCodes::SYNTAX_ERROR);
|
||||||
|
|
||||||
while (data < end && (*data == ' ' || *data == '\t' || *data == '\f'))
|
while (data < end && (*data == ' ' || *data == '\t' || *data == '\f'))
|
||||||
++data;
|
++data;
|
||||||
|
|
||||||
|
/// Data starts after the first newline, if there is one, or after all the whitespace characters, otherwise.
|
||||||
|
|
||||||
if (data < end && *data == '\r')
|
if (data < end && *data == '\r')
|
||||||
++data;
|
++data;
|
||||||
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
59
|
||||||
|
59
|
||||||
|
32
|
||||||
|
59
|
||||||
|
32
|
||||||
|
59
|
||||||
|
|
||||||
|
;
|
||||||
|
;
|
28
dbms/tests/queries/0_stateless/00497_whitespaces_in_insert.sh
Executable file
28
dbms/tests/queries/0_stateless/00497_whitespaces_in_insert.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
clickhouse-client -q "DROP TABLE IF EXISTS test.ws";
|
||||||
|
clickhouse-client -q "CREATE TABLE test.ws (i UInt8) ENGINE = Memory";
|
||||||
|
|
||||||
|
clickhouse-client -q "INSERT INTO test.ws FORMAT RowBinary ;";
|
||||||
|
clickhouse-client -q "INSERT INTO test.ws FORMAT RowBinary ; ";
|
||||||
|
clickhouse-client -q "INSERT INTO test.ws FORMAT RowBinary
|
||||||
|
; ";
|
||||||
|
echo -n ";" | clickhouse-client -q "INSERT INTO test.ws FORMAT RowBinary";
|
||||||
|
|
||||||
|
clickhouse-client --max_threads=1 -q "SELECT * FROM test.ws";
|
||||||
|
clickhouse-client -q "DROP TABLE test.ws";
|
||||||
|
|
||||||
|
|
||||||
|
clickhouse-client -q "SELECT ''";
|
||||||
|
|
||||||
|
|
||||||
|
clickhouse-client -q "CREATE TABLE test.ws (s String) ENGINE = Memory";
|
||||||
|
clickhouse-client -q "INSERT INTO test.ws FORMAT TSV ;
|
||||||
|
";
|
||||||
|
echo ";" | clickhouse-client -q "INSERT INTO test.ws FORMAT TSV"
|
||||||
|
if clickhouse-client -q "INSERT INTO test.ws FORMAT TSV;" 1>/dev/null 2>/dev/null; then
|
||||||
|
echo ERROR;
|
||||||
|
fi
|
||||||
|
clickhouse-client --max_threads=1 -q "SELECT * FROM test.ws";
|
||||||
|
|
||||||
|
clickhouse-client -q "DROP TABLE test.ws";
|
Loading…
Reference in New Issue
Block a user