This is an automated email from the ASF dual-hosted git repository.
panxiaolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 4b6ba8adfb2 [fix](ub) fix some ub error (#35769)
4b6ba8adfb2 is described below
commit 4b6ba8adfb206b087e1dbe997e4ce9903f3fbb97
Author: Mryange <[email protected]>
AuthorDate: Mon Jun 3 11:40:00 2024 +0800
[fix](ub) fix some ub error (#35769)
## Proposed changes
test pr in this https://github.com/apache/doris/pull/35177
---
be/src/exprs/hybrid_set.h | 2 +-
be/src/olap/memtable_memory_limiter.h | 2 +-
be/src/olap/rowset/segment_v2/bloom_filter.cpp | 8 ++---
be/src/pipeline/exec/exchange_source_operator.cpp | 7 ++--
be/src/runtime/decimalv2_value.cpp | 5 +--
be/src/util/frame_of_reference_coding.h | 15 +++++++--
be/src/util/timezone_utils.cpp | 6 ++--
be/src/vec/columns/column_decimal.h | 1 +
be/src/vec/columns/column_nullable.h | 3 +-
be/src/vec/columns/column_object.cpp | 2 +-
be/src/vec/columns/column_vector.h | 1 +
be/src/vec/common/hash_table/hash_map_context.h | 11 +++++--
be/src/vec/common/hash_table/hash_table.h | 3 +-
.../serde/data_type_datetimev2_serde.cpp | 2 +-
.../format/parquet/byte_array_dict_decoder.cpp | 10 +++---
.../format/parquet/fix_length_dict_decoder.hpp | 4 +--
be/src/vec/exec/jni_connector.cpp | 38 +++++++++++-----------
.../vec/functions/array/function_array_element.h | 4 +--
be/src/vec/functions/function_bit_shift.cpp | 16 +++++----
be/src/vec/json/path_in_data.cpp | 4 ++-
.../data/correctness_p0/test_bit_shift_lagency.out | 8 ++---
.../data/correctness_p0/test_bit_shift_nereids.out | 8 ++---
.../datetime_functions/test_date_function.out | 18 +++++-----
.../correctness_p0/test_bit_shift_nereids.groovy | 2 +-
.../datetime_functions/test_date_function.groovy | 6 ++--
25 files changed, 107 insertions(+), 79 deletions(-)
diff --git a/be/src/exprs/hybrid_set.h b/be/src/exprs/hybrid_set.h
index fae387afcb2..b75cc81ebf1 100644
--- a/be/src/exprs/hybrid_set.h
+++ b/be/src/exprs/hybrid_set.h
@@ -668,7 +668,7 @@ public:
const doris::vectorized::NullMap* null_map,
doris::vectorized::ColumnUInt8::Container& results) {
const auto& col = assert_cast<const
doris::vectorized::ColumnString&>(column);
- const uint32_t* __restrict offset = col.get_offsets().data();
+ const auto& offset = col.get_offsets();
const uint8_t* __restrict data = col.get_chars().data();
auto* __restrict cursor = const_cast<uint8_t*>(data);
const uint8_t* __restrict null_map_data;
diff --git a/be/src/olap/memtable_memory_limiter.h
b/be/src/olap/memtable_memory_limiter.h
index 895b0bbe2ca..38cd83e61dc 100644
--- a/be/src/olap/memtable_memory_limiter.h
+++ b/be/src/olap/memtable_memory_limiter.h
@@ -76,7 +76,7 @@ private:
int64_t _load_soft_mem_limit = -1;
int64_t _load_safe_mem_permit = -1;
- enum Limit { NONE, SOFT, HARD } _last_limit;
+ enum Limit { NONE, SOFT, HARD } _last_limit = Limit::NONE;
MonotonicStopWatch _log_timer;
static const int64_t LOG_INTERVAL = 1 * 1000 * 1000 * 1000; // 1s
diff --git a/be/src/olap/rowset/segment_v2/bloom_filter.cpp
b/be/src/olap/rowset/segment_v2/bloom_filter.cpp
index 19e2b93d29c..5e188c29d0b 100644
--- a/be/src/olap/rowset/segment_v2/bloom_filter.cpp
+++ b/be/src/olap/rowset/segment_v2/bloom_filter.cpp
@@ -26,6 +26,7 @@
#include "common/status.h"
#include "olap/rowset/segment_v2/block_split_bloom_filter.h"
#include "olap/rowset/segment_v2/ngram_bloom_filter.h"
+#include "util/frame_of_reference_coding.h"
namespace doris {
namespace segment_v2 {
@@ -43,12 +44,7 @@ Status BloomFilter::create(BloomFilterAlgorithmPB algorithm,
std::unique_ptr<Blo
}
uint32_t BloomFilter::used_bits(uint64_t value) {
- // counting leading zero, builtin function, this will generate BSR(Bit
Scan Reverse)
- // instruction for X86
- if (value == 0) {
- return 0;
- }
- return 64 - __builtin_clzll(value);
+ return 64 - leading_zeroes(value);
}
uint32_t BloomFilter::optimal_bit_num(uint64_t n, double fpp) {
diff --git a/be/src/pipeline/exec/exchange_source_operator.cpp
b/be/src/pipeline/exec/exchange_source_operator.cpp
index e37233f641b..b561e407812 100644
--- a/be/src/pipeline/exec/exchange_source_operator.cpp
+++ b/be/src/pipeline/exec/exchange_source_operator.cpp
@@ -85,9 +85,10 @@ Status ExchangeLocalState::open(RuntimeState* state) {
SCOPED_TIMER(exec_time_counter());
SCOPED_TIMER(_open_timer);
RETURN_IF_ERROR(Base::open(state));
-
-
RETURN_IF_ERROR(_parent->cast<ExchangeSourceOperatorX>()._vsort_exec_exprs.clone(
- state, vsort_exec_exprs));
+ auto& p = _parent->cast<ExchangeSourceOperatorX>();
+ if (p.is_merging()) {
+ RETURN_IF_ERROR(p._vsort_exec_exprs.clone(state, vsort_exec_exprs));
+ }
return Status::OK();
}
diff --git a/be/src/runtime/decimalv2_value.cpp
b/be/src/runtime/decimalv2_value.cpp
index f3466ca47b1..feeb45645c8 100644
--- a/be/src/runtime/decimalv2_value.cpp
+++ b/be/src/runtime/decimalv2_value.cpp
@@ -24,6 +24,7 @@
#include <iostream>
#include <utility>
+#include "util/frame_of_reference_coding.h"
#include "util/string_parser.hpp"
namespace doris {
@@ -58,9 +59,9 @@ static int clz128(unsigned __int128 v) {
if (v == 0) return sizeof(__int128);
unsigned __int128 shifted = v >> 64;
if (shifted != 0) {
- return __builtin_clzll(shifted);
+ return leading_zeroes(shifted);
} else {
- return __builtin_clzll(v) + 64;
+ return leading_zeroes(v) + 64;
}
}
diff --git a/be/src/util/frame_of_reference_coding.h
b/be/src/util/frame_of_reference_coding.h
index bc0812d53c4..30aeeca760e 100644
--- a/be/src/util/frame_of_reference_coding.h
+++ b/be/src/util/frame_of_reference_coding.h
@@ -28,15 +28,26 @@
namespace doris {
+inline uint8_t leading_zeroes(const uint64_t v) {
+ if (v == 0) {
+ return 64;
+ }
+ return __builtin_clzll(v);
+}
+
inline uint8_t bits_less_than_64(const uint64_t v) {
- return v == 0 ? 0 : 64 - __builtin_clzll(v);
+ return 64 - leading_zeroes(v);
}
// See
https://stackoverflow.com/questions/28423405/counting-the-number-of-leading-zeros-in-a-128-bit-integer
inline uint8_t bits_may_more_than_64(const uint128_t v) {
+ // See
https://stackoverflow.com/questions/49580083/builtin-clz-returns-incorrect-value-for-input-zero
+ if (v == 0) {
+ return 0;
+ }
uint64_t hi = v >> 64;
uint64_t lo = v;
- int z[3] = {__builtin_clzll(hi), __builtin_clzll(lo) + 64, 128};
+ int z[3] = {leading_zeroes(hi), leading_zeroes(lo) + 64, 128};
int idx = !hi + ((!lo) & (!hi));
return 128 - z[idx];
}
diff --git a/be/src/util/timezone_utils.cpp b/be/src/util/timezone_utils.cpp
index 8ea3990a6f6..e0afd797fff 100644
--- a/be/src/util/timezone_utils.cpp
+++ b/be/src/util/timezone_utils.cpp
@@ -108,8 +108,10 @@ T swapEndianness(T value) {
template <typename T>
T next_from_charstream(int8_t*& src) {
- T value = *reinterpret_cast<T*>(src);
- src += sizeof(T) / sizeof(int8_t);
+ T value = 0;
+ constexpr auto step = sizeof(T) / sizeof(int8_t);
+ memcpy(&value, src, step);
+ src += step;
if constexpr (std::endian::native == std::endian::little) {
return swapEndianness(
value); // timezone information files use network endianess,
which is big-endian
diff --git a/be/src/vec/columns/column_decimal.h
b/be/src/vec/columns/column_decimal.h
index 705e29134c7..24982b7504c 100644
--- a/be/src/vec/columns/column_decimal.h
+++ b/be/src/vec/columns/column_decimal.h
@@ -138,6 +138,7 @@ public:
void insert_many_fix_len_data(const char* data_ptr, size_t num) override;
void insert_many_raw_data(const char* pos, size_t num) override {
+ DCHECK(pos);
size_t old_size = data.size();
data.resize(old_size + num);
memcpy(data.data() + old_size, pos, num * sizeof(T));
diff --git a/be/src/vec/columns/column_nullable.h
b/be/src/vec/columns/column_nullable.h
index ffa32a96860..718d5e9e6cf 100644
--- a/be/src/vec/columns/column_nullable.h
+++ b/be/src/vec/columns/column_nullable.h
@@ -150,6 +150,7 @@ public:
}
void insert_many_raw_data(const char* pos, size_t num) override {
+ DCHECK(pos);
_get_null_map_column().insert_many_vals(0, num);
get_nested_column().insert_many_raw_data(pos, num);
}
@@ -414,7 +415,7 @@ private:
WrappedPtr null_map;
bool _need_update_has_null = true;
- bool _has_null;
+ bool _has_null = true;
void _update_has_null();
template <bool negative>
diff --git a/be/src/vec/columns/column_object.cpp
b/be/src/vec/columns/column_object.cpp
index 36a267bc0d8..e18c988e348 100644
--- a/be/src/vec/columns/column_object.cpp
+++ b/be/src/vec/columns/column_object.cpp
@@ -205,7 +205,7 @@ public:
private:
TypeIndex type = TypeIndex::Nothing;
- bool have_nulls;
+ bool have_nulls = false;
};
/// Visitor that allows to get type of scalar field
diff --git a/be/src/vec/columns/column_vector.h
b/be/src/vec/columns/column_vector.h
index af87c270ba6..240229d2a1f 100644
--- a/be/src/vec/columns/column_vector.h
+++ b/be/src/vec/columns/column_vector.h
@@ -227,6 +227,7 @@ public:
}
void insert_many_raw_data(const char* data_ptr, size_t num) override {
+ DCHECK(data_ptr);
auto old_size = data.size();
data.resize(old_size + num);
memcpy(data.data() + old_size, data_ptr, num * sizeof(T));
diff --git a/be/src/vec/common/hash_table/hash_map_context.h
b/be/src/vec/common/hash_table/hash_map_context.h
index d4b41dc26e0..8795d90553a 100644
--- a/be/src/vec/common/hash_table/hash_map_context.h
+++ b/be/src/vec/common/hash_table/hash_map_context.h
@@ -295,7 +295,7 @@ struct MethodStringNoCache : public MethodBase<TData> {
column.is_nullable()
? assert_cast<const
ColumnNullable&>(column).get_nested_column()
: column);
- const auto* offsets = column_string.get_offsets().data();
+ const auto& offsets = column_string.get_offsets();
const auto* chars = column_string.get_chars().data();
stored_keys.resize(column_string.size());
@@ -346,7 +346,10 @@ struct MethodOneNumber : public MethodBase<TData> {
void insert_keys_into_columns(std::vector<typename Base::Key>& input_keys,
MutableColumns& key_columns, const size_t
num_rows) override {
- key_columns[0]->insert_many_raw_data((char*)input_keys.data(),
num_rows);
+ if (!input_keys.empty()) {
+ // If size() is 0, data() may or may not return a null pointer.
+ key_columns[0]->insert_many_raw_data((char*)input_keys.data(),
num_rows);
+ }
}
};
@@ -570,6 +573,10 @@ struct MethodSingleNullableColumn : public
SingleColumnMethod {
MutableColumns& key_columns, const size_t
num_rows) override {
auto* col = key_columns[0].get();
col->reserve(num_rows);
+ if (input_keys.empty()) {
+ // If size() is 0, data() may or may not return a null pointer.
+ return;
+ }
if constexpr (std::is_same_v<typename Base::Key, StringRef>) {
col->insert_many_strings(input_keys.data(), num_rows);
} else {
diff --git a/be/src/vec/common/hash_table/hash_table.h
b/be/src/vec/common/hash_table/hash_table.h
index 04a5ff8f0e4..490cd501692 100644
--- a/be/src/vec/common/hash_table/hash_table.h
+++ b/be/src/vec/common/hash_table/hash_table.h
@@ -268,7 +268,8 @@ struct HashTableGrower {
/// Set the buffer size by the number of elements in the hash table. Used
when deserializing a hash table.
void set(size_t num_elems) {
- size_t fill_capacity = static_cast<size_t>(log2(num_elems - 1)) + 1;
+ size_t fill_capacity =
+ (num_elems <= 1) ? 1 : (static_cast<size_t>(log2(num_elems -
1)) + 1);
fill_capacity =
fill_capacity < double_grow_degree
? fill_capacity + 1
diff --git a/be/src/vec/data_types/serde/data_type_datetimev2_serde.cpp
b/be/src/vec/data_types/serde/data_type_datetimev2_serde.cpp
index 73e859f985a..f2a0e68100d 100644
--- a/be/src/vec/data_types/serde/data_type_datetimev2_serde.cpp
+++ b/be/src/vec/data_types/serde/data_type_datetimev2_serde.cpp
@@ -129,7 +129,7 @@ void DataTypeDateTimeV2SerDe::write_column_to_arrow(const
IColumn& column, const
void DataTypeDateTimeV2SerDe::read_column_from_arrow(IColumn& column,
const arrow::Array*
arrow_array, int start,
int end, const
cctz::time_zone& ctz) const {
- auto& col_data = static_cast<ColumnVector<Int64>&>(column).get_data();
+ auto& col_data = static_cast<ColumnDateTimeV2&>(column).get_data();
int64_t divisor = 1;
if (arrow_array->type()->id() == arrow::Type::TIMESTAMP) {
auto concrete_array = dynamic_cast<const
arrow::TimestampArray*>(arrow_array);
diff --git a/be/src/vec/exec/format/parquet/byte_array_dict_decoder.cpp
b/be/src/vec/exec/format/parquet/byte_array_dict_decoder.cpp
index b6a614831a3..8b9532e68d0 100644
--- a/be/src/vec/exec/format/parquet/byte_array_dict_decoder.cpp
+++ b/be/src/vec/exec/format/parquet/byte_array_dict_decoder.cpp
@@ -72,7 +72,7 @@ Status
ByteArrayDictDecoder::set_dict(std::unique_ptr<uint8_t[]>& dict, int32_t
}
Status ByteArrayDictDecoder::read_dict_values_to_column(MutableColumnPtr&
doris_column) {
- doris_column->insert_many_strings_overflow(&_dict_items[0],
_dict_items.size(),
+ doris_column->insert_many_strings_overflow(_dict_items.data(),
_dict_items.size(),
_max_value_length);
return Status::OK();
}
@@ -94,7 +94,7 @@ MutableColumnPtr
ByteArrayDictDecoder::convert_dict_column_to_string_column(
for (size_t i = 0; i < dict_column->size(); ++i) {
dict_values[i] = _dict_items[data[i]];
}
- res->insert_many_strings_overflow(&dict_values[0], dict_values.size(),
_max_value_length);
+ res->insert_many_strings_overflow(dict_values.data(), dict_values.size(),
_max_value_length);
return res;
}
@@ -115,11 +115,11 @@ Status
ByteArrayDictDecoder::_decode_values(MutableColumnPtr& doris_column, Data
if (doris_column->is_column_dictionary()) {
ColumnDictI32& dict_column =
assert_cast<ColumnDictI32&>(*doris_column);
if (dict_column.dict_size() == 0) {
- dict_column.insert_many_dict_data(&_dict_items[0],
_dict_items.size());
+ dict_column.insert_many_dict_data(_dict_items.data(),
_dict_items.size());
}
}
_indexes.resize(non_null_size);
- _index_batch_decoder->GetBatch(&_indexes[0], non_null_size);
+ _index_batch_decoder->GetBatch(_indexes.data(), non_null_size);
if (doris_column->is_column_dictionary() || is_dict_filter) {
return _decode_dict_values<has_filter>(doris_column, select_vector,
is_dict_filter);
@@ -136,7 +136,7 @@ Status
ByteArrayDictDecoder::_decode_values(MutableColumnPtr& doris_column, Data
for (size_t i = 0; i < run_length; ++i) {
string_values.emplace_back(_dict_items[_indexes[dict_index++]]);
}
- doris_column->insert_many_strings_overflow(&string_values[0],
run_length,
+ doris_column->insert_many_strings_overflow(string_values.data(),
run_length,
_max_value_length);
break;
}
diff --git a/be/src/vec/exec/format/parquet/fix_length_dict_decoder.hpp
b/be/src/vec/exec/format/parquet/fix_length_dict_decoder.hpp
index acee20275b1..115ca68bc1e 100644
--- a/be/src/vec/exec/format/parquet/fix_length_dict_decoder.hpp
+++ b/be/src/vec/exec/format/parquet/fix_length_dict_decoder.hpp
@@ -51,10 +51,10 @@ public:
dict_items.emplace_back(_dict_items[i], _type_length);
}
assert_cast<ColumnDictI32&>(*doris_column)
- .insert_many_dict_data(&dict_items[0], dict_items.size());
+ .insert_many_dict_data(dict_items.data(),
dict_items.size());
}
_indexes.resize(non_null_size);
- _index_batch_decoder->GetBatch(&_indexes[0], non_null_size);
+ _index_batch_decoder->GetBatch(_indexes.data(), non_null_size);
if (doris_column->is_column_dictionary() || is_dict_filter) {
return _decode_dict_values<has_filter>(doris_column,
select_vector, is_dict_filter);
diff --git a/be/src/vec/exec/jni_connector.cpp
b/be/src/vec/exec/jni_connector.cpp
index 3df8044f66a..66b01bbe847 100644
--- a/be/src/vec/exec/jni_connector.cpp
+++ b/be/src/vec/exec/jni_connector.cpp
@@ -44,25 +44,25 @@ class RuntimeProfile;
namespace doris::vectorized {
-#define FOR_FIXED_LENGTH_TYPES(M) \
- M(TypeIndex::Int8, ColumnVector<Int8>, Int8) \
- M(TypeIndex::UInt8, ColumnVector<UInt8>, UInt8) \
- M(TypeIndex::Int16, ColumnVector<Int16>, Int16) \
- M(TypeIndex::UInt16, ColumnVector<UInt16>, UInt16) \
- M(TypeIndex::Int32, ColumnVector<Int32>, Int32) \
- M(TypeIndex::UInt32, ColumnVector<UInt32>, UInt32) \
- M(TypeIndex::Int64, ColumnVector<Int64>, Int64) \
- M(TypeIndex::UInt64, ColumnVector<UInt64>, UInt64) \
- M(TypeIndex::Int128, ColumnVector<Int128>, Int128) \
- M(TypeIndex::Float32, ColumnVector<Float32>, Float32) \
- M(TypeIndex::Float64, ColumnVector<Float64>, Float64) \
- M(TypeIndex::Decimal128V2, ColumnDecimal<Decimal<Int128>>, Int128) \
- M(TypeIndex::Decimal128V3, ColumnDecimal<Decimal<Int128>>, Int128) \
- M(TypeIndex::Decimal32, ColumnDecimal<Decimal<Int32>>, Int32) \
- M(TypeIndex::Decimal64, ColumnDecimal<Decimal<Int64>>, Int64) \
- M(TypeIndex::Date, ColumnVector<Int64>, Int64) \
- M(TypeIndex::DateV2, ColumnVector<UInt32>, UInt32) \
- M(TypeIndex::DateTime, ColumnVector<Int64>, Int64) \
+#define FOR_FIXED_LENGTH_TYPES(M) \
+ M(TypeIndex::Int8, ColumnVector<Int8>, Int8) \
+ M(TypeIndex::UInt8, ColumnVector<UInt8>, UInt8) \
+ M(TypeIndex::Int16, ColumnVector<Int16>, Int16) \
+ M(TypeIndex::UInt16, ColumnVector<UInt16>, UInt16) \
+ M(TypeIndex::Int32, ColumnVector<Int32>, Int32) \
+ M(TypeIndex::UInt32, ColumnVector<UInt32>, UInt32) \
+ M(TypeIndex::Int64, ColumnVector<Int64>, Int64) \
+ M(TypeIndex::UInt64, ColumnVector<UInt64>, UInt64) \
+ M(TypeIndex::Int128, ColumnVector<Int128>, Int128) \
+ M(TypeIndex::Float32, ColumnVector<Float32>, Float32) \
+ M(TypeIndex::Float64, ColumnVector<Float64>, Float64) \
+ M(TypeIndex::Decimal128V2, ColumnDecimal<Decimal128V2>, Int128) \
+ M(TypeIndex::Decimal128V3, ColumnDecimal<Decimal128V3>, Int128) \
+ M(TypeIndex::Decimal32, ColumnDecimal<Decimal<Int32>>, Int32) \
+ M(TypeIndex::Decimal64, ColumnDecimal<Decimal<Int64>>, Int64) \
+ M(TypeIndex::Date, ColumnVector<Int64>, Int64) \
+ M(TypeIndex::DateV2, ColumnVector<UInt32>, UInt32) \
+ M(TypeIndex::DateTime, ColumnVector<Int64>, Int64) \
M(TypeIndex::DateTimeV2, ColumnVector<UInt64>, UInt64)
Status JniConnector::open(RuntimeState* state, RuntimeProfile* profile) {
diff --git a/be/src/vec/functions/array/function_array_element.h
b/be/src/vec/functions/array/function_array_element.h
index fef7aa3beab..49fdc4176ce 100644
--- a/be/src/vec/functions/array/function_array_element.h
+++ b/be/src/vec/functions/array/function_array_element.h
@@ -360,8 +360,8 @@ private:
res = _execute_number<ColumnDateV2>(offsets, *nested_column,
src_null_map, *idx_col,
nested_null_map, dst_null_map);
} else if (which_type.is_date_time_v2()) {
- res = _execute_number<ColumnDateTime>(offsets, *nested_column,
src_null_map, *idx_col,
- nested_null_map,
dst_null_map);
+ res = _execute_number<ColumnDateTimeV2>(offsets, *nested_column,
src_null_map, *idx_col,
+ nested_null_map,
dst_null_map);
} else if (which_type.is_uint8()) {
res = _execute_number<ColumnUInt8>(offsets, *nested_column,
src_null_map, *idx_col,
nested_null_map, dst_null_map);
diff --git a/be/src/vec/functions/function_bit_shift.cpp
b/be/src/vec/functions/function_bit_shift.cpp
index 36a5c59e3cb..9812e874a91 100644
--- a/be/src/vec/functions/function_bit_shift.cpp
+++ b/be/src/vec/functions/function_bit_shift.cpp
@@ -22,6 +22,7 @@
#include <stdexcept>
#include <type_traits>
+#include "common/compiler_util.h"
#include "common/exception.h"
#include "common/logging.h"
#include "common/status.h"
@@ -53,9 +54,10 @@ struct BitShiftLeftImpl {
} else {
// return zero if b < 0, keep consistent with mysql
// cast to unsigned so that we can do logical shift by default,
keep consistent with mysql
- return b < 0 ? 0
- : static_cast<typename std::make_unsigned<A>::type>(a)
- << static_cast<Result>(b);
+ if (UNLIKELY(b >= 64 || b < 0)) {
+ return 0;
+ }
+ return static_cast<typename std::make_unsigned<A>::type>(a) <<
static_cast<Result>(b);
}
}
};
@@ -72,9 +74,11 @@ struct BitShiftRightImpl {
} else {
// return zero if b < 0, keep consistent with mysql
// cast to unsigned so that we can do logical shift by default,
keep consistent with mysql
- return b < 0 ? 0
- : static_cast<typename
std::make_unsigned<A>::type>(a) >>
- static_cast<Result>(b);
+ if (UNLIKELY(b >= 64 || b < 0)) {
+ return 0;
+ }
+
+ return static_cast<typename std::make_unsigned<A>::type>(a) >>
static_cast<Result>(b);
}
}
};
diff --git a/be/src/vec/json/path_in_data.cpp b/be/src/vec/json/path_in_data.cpp
index 30c9ff21768..d5128d2b32e 100644
--- a/be/src/vec/json/path_in_data.cpp
+++ b/be/src/vec/json/path_in_data.cpp
@@ -213,7 +213,9 @@ PathInDataBuilder& PathInDataBuilder::append(const
PathInData::Parts& path, bool
}
void PathInDataBuilder::pop_back() {
- parts.pop_back();
+ if (!parts.empty()) {
+ parts.pop_back();
+ }
}
void PathInDataBuilder::pop_back(size_t n) {
diff --git a/regression-test/data/correctness_p0/test_bit_shift_lagency.out
b/regression-test/data/correctness_p0/test_bit_shift_lagency.out
index 1c956fe3c74..7c8883653bf 100644
--- a/regression-test/data/correctness_p0/test_bit_shift_lagency.out
+++ b/regression-test/data/correctness_p0/test_bit_shift_lagency.out
@@ -24,7 +24,7 @@ testing big_shift_left
-9223372036854775808
-- !3 --
-1
+0
-- !select --
254
@@ -39,7 +39,7 @@ testing big_shift_left
-9223372036854775808 0
-- !select --
-127 -9223372036854775808
+127 0
-- !select --
-128 0
@@ -64,7 +64,7 @@ testing big_shift_right
0
-- !select --
-9223372036854775807
+0
-- !select --
2
@@ -73,7 +73,7 @@ testing big_shift_right
1
-- !select --
--9223372036854775808
+0
-- !select --
0
diff --git a/regression-test/data/correctness_p0/test_bit_shift_nereids.out
b/regression-test/data/correctness_p0/test_bit_shift_nereids.out
index 1c956fe3c74..7c8883653bf 100644
--- a/regression-test/data/correctness_p0/test_bit_shift_nereids.out
+++ b/regression-test/data/correctness_p0/test_bit_shift_nereids.out
@@ -24,7 +24,7 @@ testing big_shift_left
-9223372036854775808
-- !3 --
-1
+0
-- !select --
254
@@ -39,7 +39,7 @@ testing big_shift_left
-9223372036854775808 0
-- !select --
-127 -9223372036854775808
+127 0
-- !select --
-128 0
@@ -64,7 +64,7 @@ testing big_shift_right
0
-- !select --
-9223372036854775807
+0
-- !select --
2
@@ -73,7 +73,7 @@ testing big_shift_right
1
-- !select --
--9223372036854775808
+0
-- !select --
0
diff --git
a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
index ecf83359db8..4561180c496 100644
---
a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
+++
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
@@ -691,34 +691,34 @@ true
-- !sql_varchar1 --
0000-00-00 %Y-%m-%d \N
-9999-12-31 23:59:59.999999 %Y-%m-%d %H:%i:%s.%f 0.000000
-9999-12-31 23:59:59.9999999 %Y-%m-%d %H:%i:%s.%f 0.000000
0000-01-01 %Y-%m-%d 0.000000
9999-12-31 23:59:59 %Y-%m-%d %H:%i:%s 0.000000
+9999-12-31 23:59:59.999999 %Y-%m-%d %H:%i:%s.%f 0.000000
+9999-12-31 23:59:59.9999999 %Y-%m-%d %H:%i:%s.%f 0.000000
1999-12-31 23:59:59.9999999 %Y-%m-%d %H:%i:%s.%f 946655999.999999
20201111 %Y%m%d 1605024000.000000
2020-12-12 %Y-%m-%d 1607702400.000000
202012-13 %Y%m-%d 1607788800.000000
-- !sql_varchar1 --
-20201111 \N
0000-00-00 \N
+20201111 \N
202012-13 \N
0000-01-01 0.000000
-9999-12-31 23:59:59.9999999 0.000000
-9999-12-31 23:59:59.999999 0.000000
9999-12-31 23:59:59 0.000000
+9999-12-31 23:59:59.999999 0.000000
+9999-12-31 23:59:59.9999999 0.000000
1999-12-31 23:59:59.9999999 946569600.000000
2020-12-12 1607702400.000000
-- !sql_varchar1 --
-%Y%m-%d \N
%Y%m%d \N
-%Y-%m-%d 660931200.000000
-%Y-%m-%d %H:%i:%s.%f 660931200.000000
-%Y-%m-%d %H:%i:%s.%f 660931200.000000
+%Y%m-%d \N
%Y-%m-%d 660931200.000000
%Y-%m-%d 660931200.000000
%Y-%m-%d %H:%i:%s.%f 660931200.000000
+%Y-%m-%d 660931200.000000
%Y-%m-%d %H:%i:%s 660931200.000000
+%Y-%m-%d %H:%i:%s.%f 660931200.000000
+%Y-%m-%d %H:%i:%s.%f 660931200.000000
diff --git
a/regression-test/suites/correctness_p0/test_bit_shift_nereids.groovy
b/regression-test/suites/correctness_p0/test_bit_shift_nereids.groovy
index 65f86877374..3b099efed3e 100644
--- a/regression-test/suites/correctness_p0/test_bit_shift_nereids.groovy
+++ b/regression-test/suites/correctness_p0/test_bit_shift_nereids.groovy
@@ -102,4 +102,4 @@ suite("test_bit_shift_nereids") {
qt_select """SELECT bit_shift_right(1, -number) from
numbers("number"="129") order by number;"""
qt_select """SELECT bit_shift_right(1, -number) from
numbers("number"="129") order by number;"""
-}
+}
\ No newline at end of file
diff --git
a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
index 49db2bb4c80..05b5b54d3d3 100644
---
a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
+++
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
@@ -811,7 +811,7 @@ suite("test_date_function") {
("0000-00-00", "%Y-%m-%d"),("0000-01-01", "%Y-%m-%d"),("9999-12-31
23:59:59", "%Y-%m-%d %H:%i:%s"),
("9999-12-31 23:59:59.999999", "%Y-%m-%d %H:%i:%s.%f"), ("9999-12-31
23:59:59.9999999", "%Y-%m-%d %H:%i:%s.%f"),
("1999-12-31 23:59:59.9999999", "%Y-%m-%d %H:%i:%s.%f"); """
- qt_sql_varchar1 """ select dt, fmt, unix_timestamp(dt, fmt) as k1 from
date_varchar order by k1; """
- qt_sql_varchar1 """ select dt, unix_timestamp(dt, "%Y-%m-%d") as k1 from
date_varchar order by k1; """
- qt_sql_varchar1 """ select fmt, unix_timestamp("1990-12-12", fmt) as k1
from date_varchar order by k1; """
+ qt_sql_varchar1 """ select dt, fmt, unix_timestamp(dt, fmt) as k1 from
date_varchar order by k1,dt,fmt; """
+ qt_sql_varchar1 """ select dt, unix_timestamp(dt, "%Y-%m-%d") as k1 from
date_varchar order by k1,dt,fmt; """
+ qt_sql_varchar1 """ select fmt, unix_timestamp("1990-12-12", fmt) as k1
from date_varchar order by k1,dt,fmt; """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]