From 85de706d220a204e8ddf4506cfc332b0ab58c1d7 Mon Sep 17 00:00:00 2001 From: groot Date: Sat, 18 Apr 2020 10:26:22 +0800 Subject: [PATCH] #1929 Skip mysql meta schema field width check (#1937) * #1929 Skip mysql meta schema field width check Signed-off-by: groot * typo Signed-off-by: groot * merge master Signed-off-by: groot --- CHANGELOG.md | 1 + core/src/db/meta/MySQLMetaImpl.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e36394e286..8b5c7ccc23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Please mark all change in change log and use the issue from GitHub ## Bug - \#1705 Limit the insert data batch size +- \#1929 Skip MySQL meta schema field width check ## Feature diff --git a/core/src/db/meta/MySQLMetaImpl.cpp b/core/src/db/meta/MySQLMetaImpl.cpp index 3878b2b650..9ce2867042 100644 --- a/core/src/db/meta/MySQLMetaImpl.cpp +++ b/core/src/db/meta/MySQLMetaImpl.cpp @@ -80,6 +80,15 @@ class MetaField { IsEqual(const MetaField& field) const { size_t name_len_min = field.name_.length() > name_.length() ? name_.length() : field.name_.length(); size_t type_len_min = field.type_.length() > type_.length() ? type_.length() : field.type_.length(); + + // only check field type, don't check field width, for example: VARCHAR(255) and VARCHAR(100) is equal + std::vector type_split; + milvus::server::StringHelpFunctions::SplitStringByDelimeter(type_, "(", type_split); + if (!type_split.empty()) { + type_len_min = type_split[0].length() > type_len_min ? type_len_min : type_split[0].length(); + } + + // field name must be equal, ignore type width return strncasecmp(field.name_.c_str(), name_.c_str(), name_len_min) == 0 && strncasecmp(field.type_.c_str(), type_.c_str(), type_len_min) == 0; }