StringRef -> String (race cond)

This commit is contained in:
Nikita Vasilev 2019-06-25 16:10:09 +03:00
parent 7b7517ff85
commit 9873b04611
4 changed files with 8 additions and 8 deletions

View File

@ -12,7 +12,7 @@ class ASTPartition : public IAST
{
public:
ASTPtr value;
StringRef fields_str; /// The extent of comma-separated partition expression fields without parentheses.
String fields_str; /// The extent of comma-separated partition expression fields without parentheses.
size_t fields_count = 0;
String id;

View File

@ -35,7 +35,7 @@ bool ParserPartition::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
return false;
size_t fields_count;
StringRef fields_str;
String fields_str;
const auto * tuple_ast = value->as<ASTFunction>();
if (tuple_ast && tuple_ast->name == "tuple")
@ -59,17 +59,17 @@ bool ParserPartition::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
if (right_paren->type != TokenType::ClosingRoundBracket)
return false;
fields_str = StringRef(left_paren->end, right_paren->begin - left_paren->end);
fields_str = String(left_paren->end, right_paren->begin - left_paren->end);
}
else
{
fields_count = 1;
fields_str = StringRef(begin->begin, pos->begin - begin->begin);
fields_str = String(begin->begin, pos->begin - begin->begin);
}
partition->value = value;
partition->children.push_back(value);
partition->fields_str = fields_str;
partition->fields_str = std::move(fields_str);
partition->fields_count = fields_count;
}

View File

@ -2492,7 +2492,7 @@ String MergeTreeData::getPartitionIDFromQuery(const ASTPtr & ast, const Context
if (fields_count)
{
ReadBufferFromMemory left_paren_buf("(", 1);
ReadBufferFromMemory fields_buf(partition_ast.fields_str.data, partition_ast.fields_str.size);
ReadBufferFromMemory fields_buf(partition_ast.fields_str.data(), partition_ast.fields_str.size());
ReadBufferFromMemory right_paren_buf(")", 1);
ConcatReadBuffer buf({&left_paren_buf, &fields_buf, &right_paren_buf});
@ -2502,7 +2502,7 @@ String MergeTreeData::getPartitionIDFromQuery(const ASTPtr & ast, const Context
RowReadExtension unused;
if (!input_stream.read(columns, unused))
throw Exception(
"Could not parse partition value: `" + partition_ast.fields_str.toString() + "`",
"Could not parse partition value: `" + partition_ast.fields_str + "`",
ErrorCodes::INVALID_PARTITION_VALUE);
for (size_t i = 0; i < fields_count; ++i)

View File

@ -48,4 +48,4 @@ $CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2;"
$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read"
#$CLICKHOUSE_CLIENT --query="DROP TABLE test.minmax_idx"
$CLICKHOUSE_CLIENT --query="DROP TABLE test.minmax_idx"