diff --git a/src/test/regress/expected/temp.out b/src/test/regress/expected/temp.out
index e677d6b86fcd48b5c2fc67aee1b5a7da5bc6972e..bba4a7ae5657a776a9d3bce2608c12e7eeb49e02 100644
--- a/src/test/regress/expected/temp.out
+++ b/src/test/regress/expected/temp.out
@@ -360,8 +360,11 @@ prepare transaction 'twophase_tab';
 ERROR:  cannot PREPARE a transaction that has operated on temporary tables
 -- Corner case: current_schema may create a temporary schema if namespace
 -- creation is pending, so check after that.  First reset the connection
--- to remove the temporary namespace.
+-- to remove the temporary namespace, and make sure that non-parallel plans
+-- are used.
 \c -
+SET max_parallel_workers = 0;
+SET max_parallel_workers_per_gather = 0;
 SET search_path TO 'pg_temp';
 BEGIN;
 SELECT current_schema() ~ 'pg_temp' AS is_temp_schema;
diff --git a/src/test/regress/sql/temp.sql b/src/test/regress/sql/temp.sql
index df7edd9410392af8ef472d1b3df9eef046da00cd..d69a243fe7479094ba12660b8c7635ddced87df7 100644
--- a/src/test/regress/sql/temp.sql
+++ b/src/test/regress/sql/temp.sql
@@ -274,8 +274,11 @@ prepare transaction 'twophase_tab';
 
 -- Corner case: current_schema may create a temporary schema if namespace
 -- creation is pending, so check after that.  First reset the connection
--- to remove the temporary namespace.
+-- to remove the temporary namespace, and make sure that non-parallel plans
+-- are used.
 \c -
+SET max_parallel_workers = 0;
+SET max_parallel_workers_per_gather = 0;
 SET search_path TO 'pg_temp';
 BEGIN;
 SELECT current_schema() ~ 'pg_temp' AS is_temp_schema;