mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Fix MySQLWire format (in case of multiple writes)
In case of multiple writes File() engine will set doNotWritePrefix(), and this will avoid serializations initilization, move this to do this always. Fixes: #31004
This commit is contained in:
parent
4498aecaf6
commit
6aa94ae032
@ -24,6 +24,15 @@ MySQLOutputFormat::MySQLOutputFormat(WriteBuffer & out_, const Block & header_,
|
||||
/// But it's also possible to specify MySQLWire as output format for clickhouse-client or clickhouse-local.
|
||||
/// There is no `sequence_id` stored in `settings_.mysql_wire` in this case, so we create a dummy one.
|
||||
sequence_id = settings_.mysql_wire.sequence_id ? settings_.mysql_wire.sequence_id : &dummy_sequence_id;
|
||||
|
||||
const auto & header = getPort(PortKind::Main).getHeader();
|
||||
data_types = header.getDataTypes();
|
||||
|
||||
serializations.reserve(data_types.size());
|
||||
for (const auto & type : data_types)
|
||||
serializations.emplace_back(type->getDefaultSerialization());
|
||||
|
||||
packet_endpoint = MySQLProtocol::PacketEndpoint::create(out, *sequence_id);
|
||||
}
|
||||
|
||||
void MySQLOutputFormat::setContext(ContextPtr context_)
|
||||
@ -34,13 +43,6 @@ void MySQLOutputFormat::setContext(ContextPtr context_)
|
||||
void MySQLOutputFormat::writePrefix()
|
||||
{
|
||||
const auto & header = getPort(PortKind::Main).getHeader();
|
||||
data_types = header.getDataTypes();
|
||||
|
||||
serializations.reserve(data_types.size());
|
||||
for (const auto & type : data_types)
|
||||
serializations.emplace_back(type->getDefaultSerialization());
|
||||
|
||||
packet_endpoint = MySQLProtocol::PacketEndpoint::create(out, *sequence_id);
|
||||
|
||||
if (header.columns())
|
||||
{
|
||||
|
6
tests/queries/0_stateless/02123_MySQLWire_regression.sql
Normal file
6
tests/queries/0_stateless/02123_MySQLWire_regression.sql
Normal file
@ -0,0 +1,6 @@
|
||||
DROP TABLE IF EXISTS table_MySQLWire;
|
||||
CREATE TABLE table_MySQLWire (x UInt64) ENGINE = File(MySQLWire);
|
||||
INSERT INTO table_MySQLWire SELECT number FROM numbers(10);
|
||||
-- regression for not initializing serializations
|
||||
INSERT INTO table_MySQLWire SELECT number FROM numbers(10);
|
||||
DROP TABLE table_MySQLWire;
|
Loading…
Reference in New Issue
Block a user