From 282a5b42d0cc78bf972209788d850e4bce957ca2 Mon Sep 17 00:00:00 2001 From: Lloyd-Pottiger Date: Thu, 8 Dec 2022 19:55:38 +0800 Subject: [PATCH] fix Signed-off-by: Lloyd-Pottiger --- dbms/src/Storages/Transaction/TiDB.cpp | 76 ++++++-------------------- 1 file changed, 16 insertions(+), 60 deletions(-) diff --git a/dbms/src/Storages/Transaction/TiDB.cpp b/dbms/src/Storages/Transaction/TiDB.cpp index ae4ebf2920a..2a05432b92a 100644 --- a/dbms/src/Storages/Transaction/TiDB.cpp +++ b/dbms/src/Storages/Transaction/TiDB.cpp @@ -47,7 +47,6 @@ Field ColumnInfo::defaultValueToField() const } switch (tp) { -<<<<<<< HEAD // TODO: Consider unsigned? // Integer Type. case TypeTiny: @@ -55,43 +54,23 @@ Field ColumnInfo::defaultValueToField() const case TypeLong: case TypeLongLong: case TypeInt24: - return value.convert(); - case TypeBit: -======= - // Integer Type. - case TypeTiny: - case TypeShort: - case TypeLong: - case TypeLongLong: - case TypeInt24: - { - // In c++, cast a unsigned integer to signed integer will not change the value. - // like 9223372036854775808 which is larger than the maximum value of Int64, - // static_cast(static_cast(9223372036854775808)) == 9223372036854775808 - // so we don't need consider unsigned here. - try - { - return value.convert(); - } - catch (...) { - // due to https://github.com/pingcap/tidb/issues/34881 - // we do this to avoid exception in older version of TiDB. - return static_cast(std::llround(value.convert())); + // In c++, cast a unsigned integer to signed integer will not change the value. + // like 9223372036854775808 which is larger than the maximum value of Int64, + // static_cast(static_cast(9223372036854775808)) == 9223372036854775808 + // so we don't need consider unsigned here. + try + { + return value.convert(); + } + catch (...) + { + // due to https://github.com/pingcap/tidb/issues/34881 + // we do this to avoid exception in older version of TiDB. + return static_cast(std::llround(value.convert())); + } } - } - case TypeBit: - { - // TODO: We shall use something like `orig_default_bit`, which will never change once created, - // rather than `default_bit`, which could be altered. - // See https://github.com/pingcap/tidb/issues/17641 and https://github.com/pingcap/tidb/issues/17642 - const auto & bit_value = default_bit_value; - // TODO: There might be cases that `orig_default` is not null but `default_bit` is null, - // i.e. bit column added with an default value but later modified to another. - // For these cases, neither `orig_default` (may get corrupted) nor `default_bit` (modified) is correct. - // This is a bug anyway, we choose to make it simple, i.e. use `default_bit`. - if (bit_value.isEmpty()) ->>>>>>> ca3e1c6be8 (Fix an invalid default value cause bootstrap failed (#4916)) + case TypeBit: { // TODO: We shall use something like `orig_default_bit`, which will never change once created, // rather than `default_bit`, which could be altered. @@ -572,16 +551,7 @@ catch (const Poco::Exception & e) /// IndexColumnInfo /// /////////////////////// -<<<<<<< HEAD IndexColumnInfo::IndexColumnInfo(Poco::JSON::Object::Ptr json) { deserialize(json); } -======= -IndexColumnInfo::IndexColumnInfo(Poco::JSON::Object::Ptr json) - : offset() - , length() -{ - deserialize(json); -} ->>>>>>> ca3e1c6be8 (Fix an invalid default value cause bootstrap failed (#4916)) Poco::JSON::Object::Ptr IndexColumnInfo::getJSONObject() const try @@ -625,21 +595,7 @@ catch (const Poco::Exception & e) ////// IndexInfo ////// /////////////////////// -<<<<<<< HEAD IndexInfo::IndexInfo(Poco::JSON::Object::Ptr json) { deserialize(json); } -======= -IndexInfo::IndexInfo(Poco::JSON::Object::Ptr json) - : id() - , state() - , index_type() - , is_unique() - , is_primary() - , is_invisible() - , is_global() -{ - deserialize(json); -} ->>>>>>> ca3e1c6be8 (Fix an invalid default value cause bootstrap failed (#4916)) Poco::JSON::Object::Ptr IndexInfo::getJSONObject() const try { @@ -1037,4 +993,4 @@ ColumnInfo fieldTypeToColumnInfo(const tipb::FieldType & field_type) return ret; } -} // namespace TiDB +} // namespace TiDB \ No newline at end of file