branch-2.1 [Fix](ShortCircuite) fix point query crash with prepared statement when encounter delete sign (#47227)

cherry-pick from #47178
This commit is contained in:
lihangyu
2025-01-25 08:33:06 +08:00
committed by GitHub
parent 92db307697
commit dd7affb8f9
3 changed files with 30 additions and 8 deletions

View File

@ -361,14 +361,23 @@ Status PointQueryExecutor::_lookup_row_data() {
}
// filter rows by delete sign
if (_result_block->rows() > 0 && _reusable->delete_sign_idx() != -1) {
vectorized::ColumnPtr delete_filter_columns =
_result_block->get_columns()[_reusable->delete_sign_idx()];
const auto& filter =
assert_cast<const vectorized::ColumnInt8*>(delete_filter_columns.get())->get_data();
size_t count = filter.size() - simd::count_zero_num((int8_t*)filter.data(), filter.size());
if (count == filter.size()) {
_result_block->clear();
} else if (count > 0) {
size_t filtered = 0;
size_t total = 0;
{
// clear_column_data will check reference of ColumnPtr, so we need to release
// reference before clear_column_data
vectorized::ColumnPtr delete_filter_columns =
_result_block->get_columns()[_reusable->delete_sign_idx()];
const auto& filter =
assert_cast<const vectorized::ColumnInt8*>(delete_filter_columns.get())
->get_data();
filtered = filter.size() - simd::count_zero_num((int8_t*)filter.data(), filter.size());
total = filter.size();
}
if (filtered == total) {
_result_block->clear_column_data();
} else if (filtered > 0) {
return Status::NotSupported("Not implemented since only single row at present");
}
}

View File

@ -193,3 +193,9 @@ user_guid feature sk feature_value 2021-01-01T00:00
-- !point_select --
user_guid feature sk feature_value 2021-01-01T00:00
-- !point_select --
-- !point_select --
-- !point_select --

View File

@ -396,6 +396,13 @@ suite("test_point_query", "nonConcurrent") {
qe_point_select partial_prepared_stmt
qe_point_select partial_prepared_stmt
partial_prepared_stmt = prepareStatement " select * from regression_test_point_query_p0.table_3821461 where col1 = ? and col2 = ? and loc3 = 'aabc'"
partial_prepared_stmt.setInt(1, 10)
partial_prepared_stmt.setInt(2, 20)
qe_point_select partial_prepared_stmt
qe_point_select partial_prepared_stmt
qe_point_select partial_prepared_stmt
// test prepared statement should not be short-circuited plan which use nondeterministic function
try (PreparedStatement pstmt = prepareStatement("select now(3) data_time from regression_test_point_query_p0.test_partial_prepared_statement where sk = 'sk' and user_guid = 'user_guid' and feature = 'feature'")) {
def result1 = ""