Crash in Engine Merge if Row Policy does not have expression (#61971)

This commit is contained in:
Ilya Golshtein 2024-03-30 21:34:01 +03:00 committed by GitHub
parent 975f0187d4
commit 6b9b597051
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 32 additions and 1 deletions

View File

@ -583,7 +583,7 @@ std::vector<ReadFromMerge::ChildPlan> ReadFromMerge::createChildrenPlans(SelectQ
database_name,
table_name,
RowPolicyFilterType::SELECT_FILTER);
if (row_policy_filter_ptr)
if (row_policy_filter_ptr && !row_policy_filter_ptr->empty())
{
row_policy_data_opt = RowPolicyData(row_policy_filter_ptr, storage, modified_context);
row_policy_data_opt->extendNames(real_column_names);

View File

@ -166,6 +166,10 @@ SELECT x, y from merge(currentDatabase(), 02763_merge
4 14
4 14
4 14
USING 0
USING 1
zzz
====
SETTINGS optimize_move_to_prewhere= 1
SELECT * FROM 02763_merge_log_1
3 13
@ -312,3 +316,7 @@ SELECT x, y from merge(currentDatabase(), 02763_merge
4 14
4 14
4 14
USING 0
USING 1
zzz
====

View File

@ -129,6 +129,27 @@ SELECT x, lc, cnst from merge(currentDatabase(), '02763_merge_fancycols') ORDER
SELECT 'SELECT x, y from merge(currentDatabase(), 02763_merge';
SELECT x, y from merge(currentDatabase(), '02763_merge') ORDER BY x SETTINGS optimize_move_to_prewhere= {{prew}};
CREATE TABLE 02763_t1 ( b String ) ENGINE = MergeTree() ORDER BY tuple();
INSERT INTO 02763_t1 VALUES('zzz');
CREATE TABLE 02763_t2 AS 02763_t1 ENGINE = Merge(currentDatabase(), '02763_t1');
SELECT 'USING 0';
CREATE ROW POLICY OR REPLACE 02763_filter_t1 ON 02763_t1 USING 0 TO ALL;
SELECT * FROM 02763_t2 SETTINGS optimize_move_to_prewhere= {{prew}};
SELECT 'USING 1';
CREATE ROW POLICY OR REPLACE 02763_filter_t1 ON 02763_t1 USING 1 TO ALL;
SELECT * FROM 02763_t2 SETTINGS optimize_move_to_prewhere= {{prew}};
DROP TABLE 02763_t1;
DROP TABLE 02763_t2;
SELECT '====';
DROP TABLE 02763_merge_fancycols;
DROP ROW POLICY 02763_filter_1 ON 02763_merge_log_1;
@ -140,4 +161,6 @@ DROP ROW POLICY 02763_filter_4 ON 02763_merge_merge_1;
DROP ROW POLICY 02763_filter_5 ON 02763_merge_fancycols;
DROP ROW POLICY 02763_filter_6 ON 02763_merge_fancycols;
DROP ROW POLICY 02763_filter_t1 ON 02763_t1;
{% endfor %}