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

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

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