diff --git a/src/test/regress/expected/join_hash.out b/src/test/regress/expected/join_hash.out index 75009e29720..a4689363200 100644 --- a/src/test/regress/expected/join_hash.out +++ b/src/test/regress/expected/join_hash.out @@ -49,6 +49,23 @@ begin end loop; end; $$; +create or replace function hash_actual_rows(query text) +returns int language plpgsql +as +$$ +declare + whole_plan json; + hash_node json; +begin + for whole_plan in + execute 'explain (analyze, format ''json'') ' || query + loop + hash_node := find_hash(json_extract_path(whole_plan, '0', 'Plan')); + return (hash_node->>'Actual Rows')::float::int; + end loop; + return null; +end; +$$; -- Make a simple relation with well distributed keys and correctly -- estimated size. create table simple as @@ -312,6 +329,18 @@ select count(*) from simple r full outer join simple s using (id); 20002 (1 row) +-- Hash node's rowcount should include null-key rows that are kept for full join +savepoint settings; +set local max_parallel_workers_per_gather = 0; +set local enable_parallel_hash = off; +select hash_actual_rows($$ + select count(*) from simple r full outer join simple s using (id); +$$); + hash_actual_rows +------------------ + 20001 +(1 row) + rollback to settings; -- The "bad" case: during execution we need to increase number of -- batches; in this case we plan for 1 batch, and increase at least a diff --git a/src/test/regress/sql/join_hash.sql b/src/test/regress/sql/join_hash.sql index 989390e6864..4b951310b4e 100644 --- a/src/test/regress/sql/join_hash.sql +++ b/src/test/regress/sql/join_hash.sql @@ -53,6 +53,24 @@ begin end; $$; +create or replace function hash_actual_rows(query text) +returns int language plpgsql +as +$$ +declare + whole_plan json; + hash_node json; +begin + for whole_plan in + execute 'explain (analyze, format ''json'') ' || query + loop + hash_node := find_hash(json_extract_path(whole_plan, '0', 'Plan')); + return (hash_node->>'Actual Rows')::float::int; + end loop; + return null; +end; +$$; + -- Make a simple relation with well distributed keys and correctly -- estimated size. create table simple as @@ -190,6 +208,14 @@ $$ $$); -- parallel full multi-batch hash join select count(*) from simple r full outer join simple s using (id); + +-- Hash node's rowcount should include null-key rows that are kept for full join +savepoint settings; +set local max_parallel_workers_per_gather = 0; +set local enable_parallel_hash = off; +select hash_actual_rows($$ + select count(*) from simple r full outer join simple s using (id); +$$); rollback to settings; -- The "bad" case: during execution we need to increase number of