This is an automated email from the ASF dual-hosted git repository.
lihaopeng 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 de1337511c [Bug](Datetime) Fix date time function mem use after free
(#16814)
de1337511c is described below
commit de1337511ce11bdb284ff7aa99174696963e0263
Author: HappenLee <[email protected]>
AuthorDate: Thu Feb 16 16:15:58 2023 +0800
[Bug](Datetime) Fix date time function mem use after free (#16814)
---
.../vec/functions/function_date_or_datetime_computation.h | 15 ++++++++-------
.../datetime_functions/test_date_function.out | 3 +++
.../datetime_functions/test_date_function.groovy | 2 ++
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/be/src/vec/functions/function_date_or_datetime_computation.h
b/be/src/vec/functions/function_date_or_datetime_computation.h
index b45333b89d..dd25e0fca9 100644
--- a/be/src/vec/functions/function_date_or_datetime_computation.h
+++ b/be/src/vec/functions/function_date_or_datetime_computation.h
@@ -452,8 +452,8 @@ struct DateTimeAddIntervalImpl {
const auto is_nullable =
block.get_by_position(result).type->is_nullable();
if (const auto* sources =
check_and_get_column<ColumnVector<FromType1>>(source_col.get())) {
auto col_to = ColumnVector<ToType>::create();
- const IColumn& delta_column =
-
*remove_nullable(block.get_by_position(arguments[1]).column);
+ auto delta_column_ptr =
remove_nullable(block.get_by_position(arguments[1]).column);
+ const IColumn& delta_column = *delta_column_ptr;
if (is_nullable) {
auto null_map = ColumnUInt8::create(input_rows_count, 0);
@@ -545,16 +545,17 @@ struct DateTimeAddIntervalImpl {
auto col_to = ColumnVector<ToType>::create();
if (is_nullable) {
auto null_map = ColumnUInt8::create(input_rows_count, 0);
+ auto not_nullable_column_ptr_arg1 =
+
remove_nullable(block.get_by_position(arguments[1]).column);
if (const auto* delta_vec_column =
check_and_get_column<ColumnVector<FromType2>>(
-
*remove_nullable(block.get_by_position(arguments[1]).column))) {
+ *not_nullable_column_ptr_arg1)) {
Op::constant_vector(sources_const->template
get_value<FromType1>(),
col_to->get_data(),
null_map->get_data(),
delta_vec_column->get_data());
} else {
- Op::constant_vector(
- sources_const->template get_value<FromType2>(),
col_to->get_data(),
- null_map->get_data(),
-
*remove_nullable(block.get_by_position(arguments[1]).column));
+ Op::constant_vector(sources_const->template
get_value<FromType2>(),
+ col_to->get_data(),
null_map->get_data(),
+ *not_nullable_column_ptr_arg1);
}
if (const auto* nullable_col =
check_and_get_column<ColumnNullable>(
block.get_by_position(arguments[0]).column.get()))
{
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 a08ba6294f..fe55f5432e 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
@@ -590,6 +590,9 @@ true
-- !sql --
2019-08-01T13:21:02.111111
+-- !sql --
+-1096
+
-- !sql --
\N \N \N \N
2000-02-29 2000-02-29 2000-02-29 2000-02-29
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 83f99991a8..c88de59acc 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
@@ -548,6 +548,8 @@ suite("test_date_function") {
qt_sql """ select minutes_sub(test_time2,1) result from ${tableName}; """
//seconds_sub
qt_sql """ select seconds_sub(test_time2,1) result from ${tableName}; """
+ //datediff
+ qt_sql """ select datediff(test_time2, STR_TO_DATE('2022-08-01
00:00:00','%Y-%m-%d')) from ${tableName}; """
// test last_day for vec
sql """ DROP TABLE IF EXISTS ${tableName}; """
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]