mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
Backward compatibility for write progress with old version of server and client
This commit is contained in:
parent
7b1be6efc4
commit
e0bd16c1f4
@ -56,6 +56,8 @@
|
||||
|
||||
#define DBMS_MIN_REVISION_WITH_LOW_CARDINALITY_TYPE 54405
|
||||
|
||||
#define DBMS_MIN_REVISION_WITH_CLIENT_WRITE_INFO 54421
|
||||
|
||||
/// Version of ClickHouse TCP protocol. Set to git tag with latest protocol change.
|
||||
#define DBMS_TCP_PROTOCOL_VERSION 54226
|
||||
|
||||
|
@ -57,6 +57,30 @@ void AllProgressValueImpl::writeJSON(const ProgressValues & value, WriteBuffer &
|
||||
writeCString("\"}", out);
|
||||
}
|
||||
|
||||
void ReadProgressValueImpl::read(ProgressValues & value, ReadBuffer & in, UInt64 /*server_revision*/)
|
||||
{
|
||||
size_t new_rows = 0;
|
||||
size_t new_bytes = 0;
|
||||
size_t new_total_rows = 0;
|
||||
|
||||
readVarUInt(new_rows, in);
|
||||
readVarUInt(new_bytes, in);
|
||||
readVarUInt(new_total_rows, in);
|
||||
|
||||
value.rows = new_rows;
|
||||
value.bytes = new_bytes;
|
||||
value.total_rows = new_total_rows;
|
||||
}
|
||||
|
||||
|
||||
void ReadProgressValueImpl::write(const ProgressValues & value, WriteBuffer & out, UInt64 /*client_revision*/)
|
||||
{
|
||||
writeVarUInt(value.rows, out);
|
||||
writeVarUInt(value.bytes, out);
|
||||
writeVarUInt(value.total_rows, out);
|
||||
}
|
||||
|
||||
|
||||
void ReadProgressValueImpl::writeJSON(const ProgressValues & value, WriteBuffer & out)
|
||||
{
|
||||
/// Numbers are written in double quotes (as strings) to avoid loss of precision
|
||||
|
@ -23,34 +23,28 @@ struct ProgressValues
|
||||
size_t write_rows;
|
||||
size_t write_bytes;
|
||||
|
||||
|
||||
template <typename ReadImpl = AllProgressValueImpl>
|
||||
void read(ReadBuffer & in, UInt64 server_revision)
|
||||
{
|
||||
ReadImpl::read(*this, in, server_revision);
|
||||
}
|
||||
inline void read(ReadBuffer & in, UInt64 server_revision);
|
||||
|
||||
template <typename WriteImpl = AllProgressValueImpl>
|
||||
void write(WriteBuffer & out, UInt64 client_revision) const
|
||||
{
|
||||
WriteImpl::write(*this, out, client_revision);
|
||||
}
|
||||
inline void write(WriteBuffer & out, UInt64 client_revision) const;
|
||||
|
||||
template <typename WriteJSONImpl = AllProgressValueImpl>
|
||||
void writeJSON(WriteBuffer & out) const
|
||||
{
|
||||
WriteJSONImpl::writeJSON(*this, out);
|
||||
}
|
||||
inline void writeJSON(WriteBuffer & out) const;
|
||||
};
|
||||
|
||||
struct AllProgressValueImpl
|
||||
{
|
||||
static void read(ProgressValues & value, ReadBuffer & in, UInt64 server_revision);
|
||||
static void write(const ProgressValues & value, WriteBuffer & out, UInt64 client_revision) ;
|
||||
static void write(const ProgressValues & value, WriteBuffer & out, UInt64 client_revision);
|
||||
static void writeJSON(const ProgressValues & value, WriteBuffer & out);
|
||||
};
|
||||
|
||||
struct ReadProgressValueImpl : public AllProgressValueImpl
|
||||
{
|
||||
static void read(ProgressValues & value, ReadBuffer & in, UInt64 server_revision);
|
||||
static void write(const ProgressValues & value, WriteBuffer & out, UInt64 client_revision);
|
||||
static void writeJSON(const ProgressValues & value, WriteBuffer & out);
|
||||
};
|
||||
|
||||
@ -198,12 +192,46 @@ void Progress::write(WriteBuffer & out, UInt64 client_revision) const
|
||||
getValues().write<T>(out, client_revision);
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void Progress::writeJSON(WriteBuffer & out) const
|
||||
{
|
||||
getValues().writeJSON<T>(out);
|
||||
}
|
||||
|
||||
template <typename ReadImpl>
|
||||
inline void ProgressValues::read(ReadBuffer & in, UInt64 server_revision)
|
||||
{
|
||||
if (server_revision >= DBMS_MIN_REVISION_WITH_CLIENT_WRITE_INFO)
|
||||
ReadImpl::read(*this, in, server_revision);
|
||||
else
|
||||
read<ReadProgressValueImpl>(in, server_revision);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void ProgressValues::read<ReadProgressValueImpl>(ReadBuffer & in, UInt64 server_revision)
|
||||
{
|
||||
ReadProgressValueImpl::read(*this, in, server_revision);
|
||||
}
|
||||
|
||||
template <typename WriteImpl>
|
||||
inline void ProgressValues::write(WriteBuffer & out, UInt64 client_revision) const
|
||||
{
|
||||
if (client_revision >= DBMS_MIN_REVISION_WITH_CLIENT_WRITE_INFO)
|
||||
WriteImpl::write(*this, out, client_revision);
|
||||
else
|
||||
write<ReadProgressValueImpl>(out, client_revision);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void ProgressValues::write<ReadProgressValueImpl>(WriteBuffer & out, UInt64 client_revision) const
|
||||
{
|
||||
ReadProgressValueImpl::write(*this, out, client_revision);
|
||||
}
|
||||
|
||||
template <typename WriteJSONImpl>
|
||||
void ProgressValues::writeJSON(WriteBuffer & out) const
|
||||
{
|
||||
WriteJSONImpl::writeJSON(*this, out);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user