From 8e425fe929139d6aeee4878cda5fa97b589cde85 Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Fri, 27 Oct 2023 10:54:47 +0200
Subject: [PATCH] paralelize stuff

---
 src/test/regress/expected/event_trigger.out   | 45 -------------------
 .../regress/expected/event_trigger_login.out  | 45 +++++++++++++++++++
 src/test/regress/parallel_schedule            | 10 ++---
 src/test/regress/sql/event_trigger.sql        | 26 -----------
 src/test/regress/sql/event_trigger_login.sql  | 25 +++++++++++
 5 files changed, 75 insertions(+), 76 deletions(-)
 create mode 100644 src/test/regress/expected/event_trigger_login.out
 create mode 100644 src/test/regress/sql/event_trigger_login.sql

diff --git a/src/test/regress/expected/event_trigger.out b/src/test/regress/expected/event_trigger.out
index eaaff6ba6f..0b87a42d0a 100644
--- a/src/test/regress/expected/event_trigger.out
+++ b/src/test/regress/expected/event_trigger.out
@@ -638,48 +638,3 @@ NOTICE:  DROP POLICY dropped policy
 CREATE POLICY pguc ON event_trigger_test USING (FALSE);
 SET event_triggers = 'off';
 DROP POLICY pguc ON event_trigger_test;
--- Login event triggers
-CREATE TABLE user_logins(id serial, who text);
-GRANT SELECT ON user_logins TO public;
-CREATE FUNCTION on_login_proc() RETURNS event_trigger AS $$
-BEGIN
-  INSERT INTO user_logins (who) VALUES (SESSION_USER);
-  RAISE NOTICE 'You are welcome!';
-END;
-$$ LANGUAGE plpgsql;
-CREATE EVENT TRIGGER on_login_trigger ON login EXECUTE PROCEDURE on_login_proc();
-ALTER EVENT TRIGGER on_login_trigger ENABLE ALWAYS;
-\c
-NOTICE:  You are welcome!
-SELECT COUNT(*) FROM user_logins;
- count 
--------
-     1
-(1 row)
-
-\c
-NOTICE:  You are welcome!
-SELECT COUNT(*) FROM user_logins;
- count 
--------
-     2
-(1 row)
-
--- Check dathasloginevt in system catalog
-SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
- dathasloginevt 
-----------------
- t
-(1 row)
-
--- Cleanup
-DROP TABLE user_logins;
-DROP EVENT TRIGGER on_login_trigger;
-DROP FUNCTION on_login_proc();
-\c
-SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
- dathasloginevt 
-----------------
- f
-(1 row)
-
diff --git a/src/test/regress/expected/event_trigger_login.out b/src/test/regress/expected/event_trigger_login.out
new file mode 100644
index 0000000000..174879578b
--- /dev/null
+++ b/src/test/regress/expected/event_trigger_login.out
@@ -0,0 +1,45 @@
+-- Login event triggers
+CREATE TABLE user_logins(id serial, who text);
+GRANT SELECT ON user_logins TO public;
+CREATE FUNCTION on_login_proc() RETURNS event_trigger AS $$
+BEGIN
+  INSERT INTO user_logins (who) VALUES (SESSION_USER);
+  RAISE NOTICE 'You are welcome!';
+END;
+$$ LANGUAGE plpgsql;
+CREATE EVENT TRIGGER on_login_trigger ON login EXECUTE PROCEDURE on_login_proc();
+ALTER EVENT TRIGGER on_login_trigger ENABLE ALWAYS;
+\c
+NOTICE:  You are welcome!
+SELECT COUNT(*) FROM user_logins;
+ count 
+-------
+     1
+(1 row)
+
+\c
+NOTICE:  You are welcome!
+SELECT COUNT(*) FROM user_logins;
+ count 
+-------
+     2
+(1 row)
+
+-- Check dathasloginevt in system catalog
+SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
+ dathasloginevt 
+----------------
+ t
+(1 row)
+
+-- Cleanup
+DROP TABLE user_logins;
+DROP EVENT TRIGGER on_login_trigger;
+DROP FUNCTION on_login_proc();
+\c
+SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
+ dathasloginevt 
+----------------
+ f
+(1 row)
+
diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule
index 512cb97dfd..eabe94b5d0 100644
--- a/src/test/regress/parallel_schedule
+++ b/src/test/regress/parallel_schedule
@@ -121,12 +121,12 @@ test: plancache limit plpgsql copy2 temp domain rangefuncs prepare conversion tr
 # ----------
 test: partition_join partition_prune reloptions hash_part indexing partition_aggregate partition_info tuplesort explain compression memoize stats
 
-# event_trigger cannot run concurrently with any other tests because
-# on-login event handling could catch connection of a concurrent test.
-test: event_trigger
-
 # oidjoins should run late for best coverage
-test: oidjoins
+test: oidjoins event_trigger
+
+# event_trigger_login cannot run concurrently with any other tests because
+# on-login event handling could catch connection of a concurrent test.
+test: event_trigger_login
 
 # this test also uses event triggers, so likewise run it by itself
 test: fast_default
diff --git a/src/test/regress/sql/event_trigger.sql b/src/test/regress/sql/event_trigger.sql
index 9c2b7903fb..6f0933b9e8 100644
--- a/src/test/regress/sql/event_trigger.sql
+++ b/src/test/regress/sql/event_trigger.sql
@@ -495,29 +495,3 @@ DROP POLICY pguc ON event_trigger_test;
 CREATE POLICY pguc ON event_trigger_test USING (FALSE);
 SET event_triggers = 'off';
 DROP POLICY pguc ON event_trigger_test;
-
--- Login event triggers
-CREATE TABLE user_logins(id serial, who text);
-GRANT SELECT ON user_logins TO public;
-CREATE FUNCTION on_login_proc() RETURNS event_trigger AS $$
-BEGIN
-  INSERT INTO user_logins (who) VALUES (SESSION_USER);
-  RAISE NOTICE 'You are welcome!';
-END;
-$$ LANGUAGE plpgsql;
-CREATE EVENT TRIGGER on_login_trigger ON login EXECUTE PROCEDURE on_login_proc();
-ALTER EVENT TRIGGER on_login_trigger ENABLE ALWAYS;
-\c
-SELECT COUNT(*) FROM user_logins;
-\c
-SELECT COUNT(*) FROM user_logins;
-
--- Check dathasloginevt in system catalog
-SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
-
--- Cleanup
-DROP TABLE user_logins;
-DROP EVENT TRIGGER on_login_trigger;
-DROP FUNCTION on_login_proc();
-\c
-SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
diff --git a/src/test/regress/sql/event_trigger_login.sql b/src/test/regress/sql/event_trigger_login.sql
new file mode 100644
index 0000000000..b8e39f7526
--- /dev/null
+++ b/src/test/regress/sql/event_trigger_login.sql
@@ -0,0 +1,25 @@
+-- Login event triggers
+CREATE TABLE user_logins(id serial, who text);
+GRANT SELECT ON user_logins TO public;
+CREATE FUNCTION on_login_proc() RETURNS event_trigger AS $$
+BEGIN
+  INSERT INTO user_logins (who) VALUES (SESSION_USER);
+  RAISE NOTICE 'You are welcome!';
+END;
+$$ LANGUAGE plpgsql;
+CREATE EVENT TRIGGER on_login_trigger ON login EXECUTE PROCEDURE on_login_proc();
+ALTER EVENT TRIGGER on_login_trigger ENABLE ALWAYS;
+\c
+SELECT COUNT(*) FROM user_logins;
+\c
+SELECT COUNT(*) FROM user_logins;
+
+-- Check dathasloginevt in system catalog
+SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
+
+-- Cleanup
+DROP TABLE user_logins;
+DROP EVENT TRIGGER on_login_trigger;
+DROP FUNCTION on_login_proc();
+\c
+SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
-- 
2.39.2

