mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Fix mutations text escaping
This commit is contained in:
parent
53d0c9fa72
commit
b1c4e5b9f2
@ -1,5 +1,5 @@
|
||||
#include <Storages/MutationCommands.h>
|
||||
#include <IO/Operators.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <Parsers/formatAST.h>
|
||||
#include <Parsers/ExpressionListParsers.h>
|
||||
#include <Parsers/ParserAlterQuery.h>
|
||||
@ -133,13 +133,13 @@ void MutationCommands::writeText(WriteBuffer & out) const
|
||||
{
|
||||
WriteBufferFromOwnString commands_buf;
|
||||
formatAST(*ast(), commands_buf, /* hilite = */ false, /* one_line = */ true);
|
||||
out << escape << commands_buf.str();
|
||||
writeEscapedString(commands_buf.str(), out);
|
||||
}
|
||||
|
||||
void MutationCommands::readText(ReadBuffer & in)
|
||||
{
|
||||
String commands_str;
|
||||
in >> escape >> commands_str;
|
||||
readEscapedString(commands_str, in);
|
||||
|
||||
ParserAlterCommandList p_alter_commands;
|
||||
auto commands_ast = parseQuery(
|
||||
|
@ -0,0 +1,2 @@
|
||||
foo
|
||||
foo
|
18
tests/queries/0_stateless/01648_mutations_and_escaping.sql
Normal file
18
tests/queries/0_stateless/01648_mutations_and_escaping.sql
Normal file
@ -0,0 +1,18 @@
|
||||
DROP TABLE IF EXISTS mutations_and_escaping_1648;
|
||||
|
||||
CREATE TABLE mutations_and_escaping_1648 (d Date, e Enum8('foo'=1, 'bar'=2)) Engine = MergeTree(d, (d), 8192);
|
||||
INSERT INTO mutations_and_escaping_1648 (d, e) VALUES ('2018-01-01', 'foo');
|
||||
INSERT INTO mutations_and_escaping_1648 (d, e) VALUES ('2018-01-02', 'bar');
|
||||
|
||||
-- slow mutation
|
||||
ALTER TABLE mutations_and_escaping_1648 UPDATE e = CAST('foo', 'Enum8(\'foo\' = 1, \'bar\' = 2)') WHERE d='2018-01-02' and sleepEachRow(1) = 0;
|
||||
|
||||
-- check that we able to read mutation text after serialization
|
||||
DETACH TABLE mutations_and_escaping_1648;
|
||||
ATTACH TABLE mutations_and_escaping_1648;
|
||||
|
||||
ALTER TABLE mutations_and_escaping_1648 UPDATE e = CAST('foo', 'Enum8(\'foo\' = 1, \'bar\' = 2)') WHERE d='2018-01-02' SETTINGS mutations_sync = 1;
|
||||
|
||||
SELECT e FROM mutations_and_escaping_1648 ORDER BY d;
|
||||
|
||||
DROP TABLE mutations_and_escaping_1648;
|
Loading…
Reference in New Issue
Block a user