From 11371e886ce69580cafba85905b81fe4d9a497bd Mon Sep 17 00:00:00 2001 From: Mikhail Koviazin Date: Wed, 13 Dec 2023 08:21:43 +0700 Subject: [PATCH] Update protobuf to v25.1 The new version deprecates `syntax()` and makes it inaccessible. Instead, the attributes corresponding to a feature should be used. This commit addresses this. --- contrib/google-protobuf | 2 +- contrib/google-protobuf-cmake/CMakeLists.txt | 6 +++++- src/Formats/ProtobufSerializer.cpp | 18 ++---------------- src/Server/grpc_protos/clickhouse_grpc.proto | 2 +- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/contrib/google-protobuf b/contrib/google-protobuf index 0862007f6ca..0fae801fb47 160000 --- a/contrib/google-protobuf +++ b/contrib/google-protobuf @@ -1 +1 @@ -Subproject commit 0862007f6ca1f5723c58f10f0ca34f3f25a63b2e +Subproject commit 0fae801fb4785175a4481aae1c0f721700e7bd99 diff --git a/contrib/google-protobuf-cmake/CMakeLists.txt b/contrib/google-protobuf-cmake/CMakeLists.txt index dda6dfe85e4..e44f737cfc3 100644 --- a/contrib/google-protobuf-cmake/CMakeLists.txt +++ b/contrib/google-protobuf-cmake/CMakeLists.txt @@ -305,12 +305,16 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/retention.cc ${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.cc ${protobuf_source_dir}/src/google/protobuf/compiler/rust/accessors/accessors.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/rust/accessors/singular_bytes.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/rust/accessors/singular_message.cc ${protobuf_source_dir}/src/google/protobuf/compiler/rust/accessors/singular_scalar.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/rust/accessors/singular_string.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/rust/accessors/unsupported_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/rust/context.cc ${protobuf_source_dir}/src/google/protobuf/compiler/rust/generator.cc ${protobuf_source_dir}/src/google/protobuf/compiler/rust/message.cc ${protobuf_source_dir}/src/google/protobuf/compiler/rust/naming.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/rust/oneof.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/rust/relative_path.cc ${protobuf_source_dir}/src/google/protobuf/compiler/subprocess.cc ${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc ) diff --git a/src/Formats/ProtobufSerializer.cpp b/src/Formats/ProtobufSerializer.cpp index c0d0713e254..9c6bfd148db 100644 --- a/src/Formats/ProtobufSerializer.cpp +++ b/src/Formats/ProtobufSerializer.cpp @@ -53,7 +53,6 @@ namespace ErrorCodes { extern const int NO_COLUMNS_SERIALIZED_TO_PROTOBUF_FIELDS; extern const int MULTIPLE_COLUMNS_SERIALIZED_TO_SAME_PROTOBUF_FIELD; - extern const int NO_COLUMN_SERIALIZED_TO_REQUIRED_PROTOBUF_FIELD; extern const int DATA_TYPE_INCOMPATIBLE_WITH_PROTOBUF_FIELD; extern const int PROTOBUF_FIELD_NOT_REPEATED; extern const int PROTOBUF_BAD_CAST; @@ -140,7 +139,7 @@ namespace return false; if (google_wrappers_special_treatment && isGoogleWrapperField(field_descriptor)) return false; - return field_descriptor.message_type() || (field_descriptor.file()->syntax() == google::protobuf::FileDescriptor::SYNTAX_PROTO3); + return field_descriptor.message_type() || !field_descriptor.has_presence(); } // Should we pack repeated values while storing them. @@ -170,7 +169,7 @@ namespace } if (field_descriptor.options().has_packed()) return field_descriptor.options().packed(); - return field_descriptor.file()->syntax() == google::protobuf::FileDescriptor::SYNTAX_PROTO3; + return field_descriptor.is_packed(); } WriteBuffer & writeIndent(WriteBuffer & out, size_t size) { return out << String(size * 4, ' '); } @@ -3445,19 +3444,6 @@ namespace } } - /// Check that we've found matching columns for all the required fields. - if ((message_descriptor.file()->syntax() == google::protobuf::FileDescriptor::SYNTAX_PROTO2) - && reader_or_writer.writer) - { - for (int i : collections::range(message_descriptor.field_count())) - { - const auto & field_descriptor = *message_descriptor.field(i); - if (field_descriptor.is_required() && !field_descriptors_in_use.count(&field_descriptor)) - throw Exception(ErrorCodes::NO_COLUMN_SERIALIZED_TO_REQUIRED_PROTOBUF_FIELD, "Field {} is required to be set", - quoteString(field_descriptor.full_name())); - } - } - if (field_descs.empty()) return nullptr; diff --git a/src/Server/grpc_protos/clickhouse_grpc.proto b/src/Server/grpc_protos/clickhouse_grpc.proto index 4593cfff096..c9ba6f28506 100644 --- a/src/Server/grpc_protos/clickhouse_grpc.proto +++ b/src/Server/grpc_protos/clickhouse_grpc.proto @@ -192,7 +192,7 @@ message Exception { message Result { string query_id = 9; string time_zone = 10; - + // The format in which `output`, `totals` and `extremes` are written. // It's either the same as `output_format` specified in `QueryInfo` or the format specified in the query itself. string output_format = 11;