Make the value of invalidate_query human readable

This commit is contained in:
Alexey Milovidov 2019-03-04 21:21:07 +03:00
parent e418e4da33
commit 5bac476eb1
2 changed files with 8 additions and 6 deletions

View File

@ -1,8 +1,10 @@
#include "readInvalidateQuery.h"
#include <DataStreams/IBlockInputStream.h>
#include <IO/WriteBufferFromString.h>
namespace DB
{
namespace ErrorCodes
{
extern const int TOO_MANY_COLUMNS;
@ -13,7 +15,6 @@ namespace ErrorCodes
std::string readInvalidateQuery(IBlockInputStream & block_input_stream)
{
block_input_stream.readPrefix();
std::string response;
Block block = block_input_stream.read();
if (!block)
@ -29,8 +30,9 @@ std::string readInvalidateQuery(IBlockInputStream & block_input_stream)
if (rows > 1)
throw Exception("Expected single row in resultset, got at least " + std::to_string(rows), ErrorCodes::TOO_MANY_ROWS);
auto column = block.getByPosition(0).column;
response = column->getDataAt(0).toString();
WriteBufferFromOwnString out;
auto & column_type = block.getByPosition(0);
column_type.type->serializeAsText(*column_type.column, 0, out, FormatSettings());
while ((block = block_input_stream.read()))
{
@ -40,7 +42,7 @@ std::string readInvalidateQuery(IBlockInputStream & block_input_stream)
block_input_stream.readSuffix();
return response;
return out.str();
}
}

View File

@ -5,8 +5,8 @@ class IBlockInputStream;
namespace DB
{
// Using in MySQLDictionarySource and XDBCDictionarySource after processing invalidate_query
/// Using in MySQLDictionarySource and XDBCDictionarySource after processing invalidate_query.
std::string readInvalidateQuery(IBlockInputStream & block_input_stream);
}