Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8b62b44

Browse files
committed
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.pgsqlAuthor: Alvaro Herrera, Alexander Korotkov
1 parentc6cf6d3 commit8b62b44

File tree

5 files changed

+77
-76
lines changed

5 files changed

+77
-76
lines changed

‎src/test/regress/expected/event_trigger.out

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -638,48 +638,3 @@ NOTICE: DROP POLICY dropped policy
638638
CREATE POLICY pguc ON event_trigger_test USING (FALSE);
639639
SET event_triggers = 'off';
640640
DROP POLICY pguc ON event_trigger_test;
641-
-- Login event triggers
642-
CREATE TABLE user_logins(id serial, who text);
643-
GRANT SELECT ON user_logins TO public;
644-
CREATE FUNCTION on_login_proc() RETURNS event_trigger AS $$
645-
BEGIN
646-
INSERT INTO user_logins (who) VALUES (SESSION_USER);
647-
RAISE NOTICE 'You are welcome!';
648-
END;
649-
$$ LANGUAGE plpgsql;
650-
CREATE EVENT TRIGGER on_login_trigger ON login EXECUTE PROCEDURE on_login_proc();
651-
ALTER EVENT TRIGGER on_login_trigger ENABLE ALWAYS;
652-
\c
653-
NOTICE: You are welcome!
654-
SELECT COUNT(*) FROM user_logins;
655-
count
656-
-------
657-
1
658-
(1 row)
659-
660-
\c
661-
NOTICE: You are welcome!
662-
SELECT COUNT(*) FROM user_logins;
663-
count
664-
-------
665-
2
666-
(1 row)
667-
668-
-- Check dathasloginevt in system catalog
669-
SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
670-
dathasloginevt
671-
----------------
672-
t
673-
(1 row)
674-
675-
-- Cleanup
676-
DROP TABLE user_logins;
677-
DROP EVENT TRIGGER on_login_trigger;
678-
DROP FUNCTION on_login_proc();
679-
\c
680-
SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
681-
dathasloginevt
682-
----------------
683-
f
684-
(1 row)
685-
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
-- Login event triggers
2+
CREATE TABLE user_logins(id serial, who text);
3+
GRANT SELECT ON user_logins TO public;
4+
CREATE FUNCTION on_login_proc() RETURNS event_trigger AS $$
5+
BEGIN
6+
INSERT INTO user_logins (who) VALUES (SESSION_USER);
7+
RAISE NOTICE 'You are welcome!';
8+
END;
9+
$$ LANGUAGE plpgsql;
10+
CREATE EVENT TRIGGER on_login_trigger ON login EXECUTE PROCEDURE on_login_proc();
11+
ALTER EVENT TRIGGER on_login_trigger ENABLE ALWAYS;
12+
\c
13+
NOTICE: You are welcome!
14+
SELECT COUNT(*) FROM user_logins;
15+
count
16+
-------
17+
1
18+
(1 row)
19+
20+
\c
21+
NOTICE: You are welcome!
22+
SELECT COUNT(*) FROM user_logins;
23+
count
24+
-------
25+
2
26+
(1 row)
27+
28+
-- Check dathasloginevt in system catalog
29+
SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
30+
dathasloginevt
31+
----------------
32+
t
33+
(1 row)
34+
35+
-- Cleanup
36+
DROP TABLE user_logins;
37+
DROP EVENT TRIGGER on_login_trigger;
38+
DROP FUNCTION on_login_proc();
39+
\c
40+
SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME';
41+
dathasloginevt
42+
----------------
43+
f
44+
(1 row)
45+

‎src/test/regress/parallel_schedule

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ test: plancache limit plpgsql copy2 temp domain rangefuncs prepare conversion tr
121121
# ----------
122122
test: partition_join partition_prune reloptions hash_part indexing partition_aggregate partition_info tuplesort explain compression memoize stats
123123

124-
# event_trigger cannot run concurrently with any other tests because
125-
# on-login event handling could catch connection of a concurrent test.
126-
test: event_trigger
124+
# event_trigger depends on create_am and cannot run concurrently with
125+
# any test that runs DDL
126+
# oidjoins is read-only, though, and should run late for best coverage
127+
test: oidjoins event_trigger
127128

128-
# oidjoins should run late for best coverage
129-
test: oidjoins
129+
# event_trigger_login cannot run concurrently with any other tests because
130+
# on-login event handling could catch connection of a concurrent test.
131+
test: event_trigger_login
130132

131133
# this test also uses event triggers, so likewise run it by itself
132134
test: fast_default

‎src/test/regress/sql/event_trigger.sql

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -495,29 +495,3 @@ DROP POLICY pguc ON event_trigger_test;
495495
CREATE POLICY pgucON event_trigger_test USING (FALSE);
496496
SET event_triggers='off';
497497
DROP POLICY pgucON event_trigger_test;
498-
499-
-- Login event triggers
500-
CREATETABLEuser_logins(idserial, whotext);
501-
GRANTSELECTON user_logins TO public;
502-
CREATEFUNCTIONon_login_proc() RETURNS event_triggerAS $$
503-
BEGIN
504-
INSERT INTO user_logins (who)VALUES (SESSION_USER);
505-
RAISE NOTICE'You are welcome!';
506-
END;
507-
$$ LANGUAGE plpgsql;
508-
CREATE EVENT TRIGGER on_login_triggerON login EXECUTE PROCEDURE on_login_proc();
509-
ALTER EVENT TRIGGER on_login_trigger ENABLE ALWAYS;
510-
\c
511-
SELECTCOUNT(*)FROM user_logins;
512-
\c
513-
SELECTCOUNT(*)FROM user_logins;
514-
515-
-- Check dathasloginevt in system catalog
516-
SELECT dathasloginevtFROM pg_databaseWHERE datname= :'DBNAME';
517-
518-
-- Cleanup
519-
DROPTABLE user_logins;
520-
DROP EVENT TRIGGER on_login_trigger;
521-
DROPFUNCTION on_login_proc();
522-
\c
523-
SELECT dathasloginevtFROM pg_databaseWHERE datname= :'DBNAME';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- Login event triggers
2+
CREATETABLEuser_logins(idserial, whotext);
3+
GRANTSELECTON user_logins TO public;
4+
CREATEFUNCTIONon_login_proc() RETURNS event_triggerAS $$
5+
BEGIN
6+
INSERT INTO user_logins (who)VALUES (SESSION_USER);
7+
RAISE NOTICE'You are welcome!';
8+
END;
9+
$$ LANGUAGE plpgsql;
10+
CREATE EVENT TRIGGER on_login_triggerON login EXECUTE PROCEDURE on_login_proc();
11+
ALTER EVENT TRIGGER on_login_trigger ENABLE ALWAYS;
12+
\c
13+
SELECTCOUNT(*)FROM user_logins;
14+
\c
15+
SELECTCOUNT(*)FROM user_logins;
16+
17+
-- Check dathasloginevt in system catalog
18+
SELECT dathasloginevtFROM pg_databaseWHERE datname= :'DBNAME';
19+
20+
-- Cleanup
21+
DROPTABLE user_logins;
22+
DROP EVENT TRIGGER on_login_trigger;
23+
DROPFUNCTION on_login_proc();
24+
\c
25+
SELECT dathasloginevtFROM pg_databaseWHERE datname= :'DBNAME';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp