提交 c24f4c57 编写于 作者: A Alexey Milovidov

Style; removed useless catch [#CLICKHOUSE-2955].

上级 d7e5e650
......@@ -181,8 +181,8 @@ std::string MySQLDictionarySource::doInvalidateQuery(const std::string & request
Block sample_block;
ColumnPtr column(std::make_shared<ColumnString>());
sample_block.insert(ColumnWithTypeAndName(column, std::make_shared<DataTypeString>(), "Sample Block"));
MySQLBlockInputStream blockInputStream(pool.Get(), request, sample_block, 1);
return readInvalidateQuery(blockInputStream);
MySQLBlockInputStream block_input_stream(pool.Get(), request, sample_block, 1);
return readInvalidateQuery(block_input_stream);
}
}
......
......@@ -116,8 +116,8 @@ std::string ODBCDictionarySource::doInvalidateQuery(const std::string & request)
Block sample_block;
ColumnPtr column(std::make_shared<ColumnString>());
sample_block.insert(ColumnWithTypeAndName(column, std::make_shared<DataTypeString>(), "Sample Block"));
ODBCBlockInputStream blockInputStream(pool->get(), request, sample_block, 1);
return readInvalidateQuery(blockInputStream);
ODBCBlockInputStream block_input_stream(pool->get(), request, sample_block, 1);
return readInvalidateQuery(block_input_stream);
}
}
......@@ -11,44 +11,35 @@ extern const int TOO_MUCH_ROWS;
extern const int RECEIVED_EMPTY_DATA;
}
std::string readInvalidateQuery(IProfilingBlockInputStream & blockInputStream)
std::string readInvalidateQuery(IProfilingBlockInputStream & block_input_stream)
{
blockInputStream.readPrefix();
block_input_stream.readPrefix();
std::string response;
try
{
Block block = blockInputStream.read();
if (!block)
throw Exception("Empty response", ErrorCodes::RECEIVED_EMPTY_DATA);
auto columns = block.columns();
if (columns > 1)
throw Exception("Expected single column in resultset, got " + std::to_string(columns), ErrorCodes::TOO_MUCH_COLUMNS);
auto rows = block.rows();
if (rows == 0)
throw Exception("Expected single row in resultset, got 0", ErrorCodes::RECEIVED_EMPTY_DATA);
if (rows > 1)
throw Exception("Expected single row in resultset, got at least " + std::to_string(rows), ErrorCodes::TOO_MUCH_ROWS);
auto column = block.getByPosition(0).column;
response = column->getDataAt(0).toString();
while (block = blockInputStream.read())
{
if (block.rows() > 0)
throw Exception("Expected single row in resultset, got at least " + std::to_string(rows + 1), ErrorCodes::TOO_MUCH_ROWS);
}
}
catch (Exception& exception)
Block block = block_input_stream.read();
if (!block)
throw Exception("Empty response", ErrorCodes::RECEIVED_EMPTY_DATA);
auto columns = block.columns();
if (columns > 1)
throw Exception("Expected single column in resultset, got " + std::to_string(columns), ErrorCodes::TOO_MUCH_COLUMNS);
auto rows = block.rows();
if (rows == 0)
throw Exception("Expected single row in resultset, got 0", ErrorCodes::RECEIVED_EMPTY_DATA);
if (rows > 1)
throw Exception("Expected single row in resultset, got at least " + std::to_string(rows), ErrorCodes::TOO_MUCH_ROWS);
auto column = block.getByPosition(0).column;
response = column->getDataAt(0).toString();
while (block = block_input_stream.read())
{
blockInputStream.cancel();
blockInputStream.readSuffix();
throw;
if (block.rows() > 0)
throw Exception("Expected single row in resultset, got at least " + std::to_string(rows + 1), ErrorCodes::TOO_MUCH_ROWS);
}
blockInputStream.readSuffix();
block_input_stream.readSuffix();
return response;
}
......
......@@ -7,7 +7,7 @@ namespace DB
{
// Using in MySQLDictionarySource and ODBCDictionarySource after processing invalidate_query
std::string readInvalidateQuery(IProfilingBlockInputStream & blockInputStream);
std::string readInvalidateQuery(IProfilingBlockInputStream & block_input_stream);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册