From f46a6fabd19aeb2c8714510601c5980b33182666 Mon Sep 17 00:00:00 2001 From: Yarik Briukhovetskyi <114298166+yariks5s@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:36:53 +0100 Subject: [PATCH] Fix review issues. --- src/Common/computeMaxTableNameLength.cpp | 2 +- src/Databases/DatabaseOnDisk.cpp | 6 ++++-- src/Functions/getMaxTableNameLength.cpp | 2 -- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Common/computeMaxTableNameLength.cpp b/src/Common/computeMaxTableNameLength.cpp index eb4a72f1863..f74db295bd2 100644 --- a/src/Common/computeMaxTableNameLength.cpp +++ b/src/Common/computeMaxTableNameLength.cpp @@ -23,7 +23,7 @@ size_t computeMaxTableNameLength(const String & database_name, ContextPtr contex size_t escaped_db_name_length = escapeForFileName(database_name).length(); const size_t uuid_length = 36; // Standard UUID length - const size_t extension_length = 6; // Length of ".sql" including three dots + const size_t extension_length = strlen(".sql"); // Length of ".sql" // Adjust for database name and UUID in dropped table filenames size_t max_to_drop = max_dropped_length - escaped_db_name_length - uuid_length - extension_length; diff --git a/src/Databases/DatabaseOnDisk.cpp b/src/Databases/DatabaseOnDisk.cpp index 26486c5fdb1..e16da0ac49a 100644 --- a/src/Databases/DatabaseOnDisk.cpp +++ b/src/Databases/DatabaseOnDisk.cpp @@ -393,10 +393,12 @@ void DatabaseOnDisk::checkMetadataFilenameAvailabilityUnlocked(const String & to size_t allowed_max_length = computeMaxTableNameLength(database_name, getContext()); String table_metadata_path = getObjectMetadataPath(to_table_name); - if (escapeForFileName(to_table_name).length() > allowed_max_length) + const auto escaped_name_length = escapeForFileName(to_table_name).length(); + + if (escaped_length > allowed_max_length) throw Exception(ErrorCodes::ARGUMENT_OUT_OF_BOUND, "The max length of table name for database {} is {}, current length is {}", - database_name, allowed_max_length, to_table_name.length()); + database_name, allowed_max_length, escaped_length); if (fs::exists(table_metadata_path)) { diff --git a/src/Functions/getMaxTableNameLength.cpp b/src/Functions/getMaxTableNameLength.cpp index 263fa2f2919..5b84f88c1a9 100644 --- a/src/Functions/getMaxTableNameLength.cpp +++ b/src/Functions/getMaxTableNameLength.cpp @@ -56,8 +56,6 @@ public: return std::make_shared(); } - bool isDeterministic() const override { return false; } - bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; } ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override