Split event_trigger_login test from event_trigger test

That allows to still run event_trigger test in parallel with oidjoins test,
and save ~50ms of tests runtime.

Discussion: https://postgr.es/m/202310271047.mnwkql6nhbwi%40alvherre.pgsql
Author: Alvaro Herrera, Alexander Korotkov
This commit is contained in:
Alexander Korotkov 2023-10-27 23:50:07 +03:00
parent c6cf6d353c
commit 8b62b441ff
5 changed files with 77 additions and 76 deletions

View File

@ -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)

View File

@ -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)

View File

@ -121,12 +121,14 @@ 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
# event_trigger depends on create_am and cannot run concurrently with
# any test that runs DDL
# oidjoins is read-only, though, and should run late for best coverage
test: oidjoins event_trigger
# oidjoins should run late for best coverage
test: oidjoins
# 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

View File

@ -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';

View File

@ -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';