This is an automated email from the ASF dual-hosted git repository.

chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit f6f0ade564179efb552dd42ad31af58abefdad84
Author: Jinbao Chen <[email protected]>
AuthorDate: Wed Jan 14 20:46:11 2026 +0800

    Add hashagg_spill_temp_files fault injector
---
 src/backend/executor/nodeAgg.c            | 15 +++++++++++++++
 src/test/regress/sql/temp_tablespaces.sql | 23 ++++++++++++++++-------
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 46ac1416aa2..e63f21c43ab 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -1960,6 +1960,21 @@ hash_agg_enter_spill_mode(AggState *aggstate)
 
                aggstate->hash_spills = palloc(sizeof(HashAggSpill) * 
aggstate->num_hashes);
 
+#ifdef FAULT_INJECTOR
+               if (SIMPLE_FAULT_INJECTOR("hashagg_spill_temp_files") == 
FaultInjectorTypeSkip) {
+                       const char *filename = 
LogicalTapeGetBufFilename(aggstate->hash_tapeset);
+                       if (!filename)
+                               ereport(NOTICE, (errmsg("hashagg: buffilename 
is null")));
+                       else if (strstr(filename, "base/" PG_TEMP_FILES_DIR) == 
filename)
+                               ereport(NOTICE, (errmsg("hashagg: Use default 
tablespace")));
+                       else if (strstr(filename, "pg_tblspc/") == filename)
+                               ereport(NOTICE, (errmsg("hashagg: Use temp 
tablespace")));
+                       else
+                               ereport(NOTICE, (errmsg("hashagg: Unexpected 
prefix of the tablespace path")));
+
+               }
+#endif
+
                for (int setno = 0; setno < aggstate->num_hashes; setno++)
                {
                        AggStatePerHash perhash = &aggstate->perhash[setno];
diff --git a/src/test/regress/sql/temp_tablespaces.sql 
b/src/test/regress/sql/temp_tablespaces.sql
index 1130658f9da..111094b93e5 100644
--- a/src/test/regress/sql/temp_tablespaces.sql
+++ b/src/test/regress/sql/temp_tablespaces.sql
@@ -1,5 +1,9 @@
-create tablespace some_temp_tablespace location 
'@testtablespace@_temp_tablespace';
-create tablespace some_default_tablespace location 
'@testtablespace@_default_tablespace';
+\getenv abs_builddir PG_ABS_BUILDDIR
+\set temp_tablespace :abs_builddir '/testtablespace_temp_tablespace'
+\set dddefault_tablepace :abs_builddir '/testtablespace_default_tablespace'
+
+create tablespace some_temp_tablespace location :'temp_tablespace';
+create tablespace some_default_tablespace location :'dddefault_tablepace';
 
 -- Given I've set up GUCS for how to use tablespaces
 set temp_tablespaces to some_temp_tablespace;
@@ -31,11 +35,16 @@ reset temp_tablespaces;
 -- When the GUC temp_tablespaces is set, one of the temp tablespaces is used 
instead of the default tablespace.
 -- create several tablespaces and use them as temp tablespaces
 -- all QD/QEs in one session should have the same temp tablespace
-create tablespace mytempsp0 location '@testtablespace@_mytempsp0';
-create tablespace mytempsp1 location '@testtablespace@_mytempsp1';
-create tablespace mytempsp2 location '@testtablespace@_mytempsp2';
-create tablespace mytempsp3 location '@testtablespace@_mytempsp3';
-create tablespace mytempsp4 location '@testtablespace@_mytempsp4';
+\set mytempsp0 :abs_builddir '/testtablespace_mytempsp0'
+\set mytempsp1 :abs_builddir '/testtablespace_mytempsp1'
+\set mytempsp2 :abs_builddir '/testtablespace_mytempsp2'
+\set mytempsp3 :abs_builddir '/testtablespace_mytempsp3'
+\set mytempsp4 :abs_builddir '/testtablespace_mytempsp4'
+create tablespace mytempsp0 location :'mytempsp0';
+create tablespace mytempsp1 location :'mytempsp1';
+create tablespace mytempsp2 location :'mytempsp2';
+create tablespace mytempsp3 location :'mytempsp3';
+create tablespace mytempsp4 location :'mytempsp4';
 
 CREATE TABLE tts_foo (i int, j int) distributed by(i);
 insert into tts_foo select i, i from generate_series(1,80000)i;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to