From a3b071bbe050252b35c589a7f1a2ee2f7ee3e9d4 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 22 Mar 2022 16:18:06 -0400 Subject: [PATCH] Tidy up Object Access hooks tests per gripelet from Tom Lane. --- src/test/modules/test_oat_hooks/Makefile | 5 +---- src/test/modules/test_oat_hooks/expected/test_oat_hooks.out | 2 +- src/test/modules/test_oat_hooks/sql/test_oat_hooks.sql | 2 +- src/test/modules/test_oat_hooks/test_oat_hooks.c | 5 +++++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/modules/test_oat_hooks/Makefile b/src/test/modules/test_oat_hooks/Makefile index d03ef2caf1..ba068acc53 100644 --- a/src/test/modules/test_oat_hooks/Makefile +++ b/src/test/modules/test_oat_hooks/Makefile @@ -1,13 +1,10 @@ # src/test/modules/test_oat_hooks/Makefile MODULE_big = test_oat_hooks -OBJS = \ - $(WIN32RES) \ - test_oat_hooks.o +OBJS = test_oat_hooks.o $(WIN32RES) PGFILEDESC = "test_oat_hooks - example use of object access hooks" REGRESS = test_oat_hooks -NO_INSTALLCHECK = 1 ifdef USE_PGXS PG_CONFIG = pg_config diff --git a/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out b/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out index 4192a2fb49..45ff276f7e 100644 --- a/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out +++ b/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out @@ -155,7 +155,7 @@ NOTICE: in process utility: superuser attempting set NOTICE: in object_access_hook_str: superuser attempting alter (set) [test_oat_hooks.deny_utility_commands] NOTICE: in object_access_hook_str: superuser finished alter (set) [test_oat_hooks.deny_utility_commands] NOTICE: in process utility: superuser finished set --- Try again as non-superuser with permisisons denied +-- Try again as non-superuser with permissions denied SET SESSION AUTHORIZATION regress_test_user; NOTICE: in process utility: superuser attempting set NOTICE: in object_access_hook_str: non-superuser attempting alter (set) [session_authorization] diff --git a/src/test/modules/test_oat_hooks/sql/test_oat_hooks.sql b/src/test/modules/test_oat_hooks/sql/test_oat_hooks.sql index 7c38202782..09e61864ee 100644 --- a/src/test/modules/test_oat_hooks/sql/test_oat_hooks.sql +++ b/src/test/modules/test_oat_hooks/sql/test_oat_hooks.sql @@ -39,7 +39,7 @@ SET test_oat_hooks.deny_object_access = true; SET test_oat_hooks.deny_exec_perms = true; SET test_oat_hooks.deny_utility_commands = true; --- Try again as non-superuser with permisisons denied +-- Try again as non-superuser with permissions denied SET SESSION AUTHORIZATION regress_test_user; SELECT * FROM regress_test_table; SELECT regress_test_func('arg'); diff --git a/src/test/modules/test_oat_hooks/test_oat_hooks.c b/src/test/modules/test_oat_hooks/test_oat_hooks.c index b50567749c..eb7564ce22 100644 --- a/src/test/modules/test_oat_hooks/test_oat_hooks.c +++ b/src/test/modules/test_oat_hooks/test_oat_hooks.c @@ -192,6 +192,11 @@ _PG_fini(void) static void emit_audit_message(const char *type, const char *hook, char *action, char *objName) { + /* + * Ensure that audit messages are not duplicated by only emitting them from + * a leader process, not a worker process. This makes the test results + * deterministic even if run with force_parallel_mode = regress. + */ if (REGRESS_audit && !IsParallelWorker()) { const char *who = superuser_arg(GetUserId()) ? "superuser" : "non-superuser";