summaryrefslogtreecommitdiff
path: root/src/test/modules/injection_points/sql
diff options
context:
space:
mode:
authorJeff Davis <jdavis@postgresql.org>2025-02-11 11:26:25 -0800
committerJeff Davis <jdavis@postgresql.org>2025-02-11 11:26:25 -0800
commit38172d1856b34792a5ee60eaa0d883166e90d33d (patch)
treed04e08a60d98233b35d915f1f770b4013a45ae52 /src/test/modules/injection_points/sql
parent052026c9b903380b428a4c9ba2ec90726db81288 (diff)
Injection points for hash aggregation.
Requires adding a guard against shift-by-32. Previously, that was impossible because the number of partitions was always greater than 1, but a new injection point can force the number of partitions to 1. Discussion: https://postgr.es/m/ff4e59305e5d689e03cd256a736348d3e7958f8f.camel@j-davis.com
Diffstat (limited to 'src/test/modules/injection_points/sql')
-rw-r--r--src/test/modules/injection_points/sql/hashagg.sql26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/modules/injection_points/sql/hashagg.sql b/src/test/modules/injection_points/sql/hashagg.sql
new file mode 100644
index 00000000000..51d814623fc
--- /dev/null
+++ b/src/test/modules/injection_points/sql/hashagg.sql
@@ -0,0 +1,26 @@
+-- Test for hash aggregation
+CREATE EXTENSION injection_points;
+
+SELECT injection_points_set_local();
+
+SELECT injection_points_attach('hash-aggregate-enter-spill-mode', 'notice');
+SELECT injection_points_attach('hash-aggregate-process-batch', 'notice');
+
+-- force partition fan-out to 1
+SELECT injection_points_attach('hash-aggregate-single-partition', 'notice');
+
+-- force spilling after 1000 groups
+SELECT injection_points_attach('hash-aggregate-spill-1000', 'notice');
+
+CREATE TABLE hashagg_ij(x INTEGER);
+INSERT INTO hashagg_ij SELECT g FROM generate_series(1,5100) g;
+
+SET max_parallel_workers=0;
+SET max_parallel_workers_per_gather=0;
+SET enable_sort=FALSE;
+SET work_mem='4MB';
+
+SELECT COUNT(*) FROM (SELECT DISTINCT x FROM hashagg_ij) s;
+
+DROP TABLE hashagg_ij;
+DROP EXTENSION injection_points;