Skip to content

Commit f0206d9

Browse files
committed
Fix new Object Access hooks test
Commit 90efa2f caused some issues with EXEC_BACKEND builds and with force_parallel_mode = regress setups. For the first issue we no longer test if the module has been preloaded, and in fact we don't preload it, but simply LOAD it in the test script. For the second issue we suppress error messages emanating from parallel workers. Mark Dilger Discussion: https://postgr.es/m/7f6d54a1-4024-3b6e-e3ec-26cd394aac9e@dunslane.net
1 parent 097786f commit f0206d9

File tree

5 files changed

+4
-14
lines changed

5 files changed

+4
-14
lines changed

src/test/modules/test_oat_hooks/Makefile

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ OBJS = \
77
PGFILEDESC = "test_oat_hooks - example use of object access hooks"
88

99
REGRESS = test_oat_hooks
10-
REGRESS_OPTS = --temp-config=$(top_srcdir)/src/test/modules/test_oat_hooks/test_oat_hooks.conf
11-
# Disabled because these tests require "shared_preload_libraries=test_oat_hooks",
12-
# which typical installcheck users do not have (e.g. buildfarm clients).
1310
NO_INSTALLCHECK = 1
1411

1512
ifdef USE_PGXS

src/test/modules/test_oat_hooks/expected/test_oat_hooks.out

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
-- object_access_hook_str. Since the auditing GUC starts out false, we miss the
33
-- initial "attempting" audit message from the ProcessUtility_hook, but we
44
-- should thereafter see the audit messages
5+
LOAD 'test_oat_hooks';
56
SET test_oat_hooks.audit = true;
67
NOTICE: in object_access_hook_str: superuser attempting alter (set) [test_oat_hooks.audit]
78
NOTICE: in object_access_hook_str: superuser finished alter (set) [test_oat_hooks.audit]

src/test/modules/test_oat_hooks/sql/test_oat_hooks.sql

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
-- object_access_hook_str. Since the auditing GUC starts out false, we miss the
33
-- initial "attempting" audit message from the ProcessUtility_hook, but we
44
-- should thereafter see the audit messages
5+
LOAD 'test_oat_hooks';
56
SET test_oat_hooks.audit = true;
67

78
-- Create objects for use in the test

src/test/modules/test_oat_hooks/test_oat_hooks.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "postgres.h"
1515

16+
#include "access/parallel.h"
1617
#include "catalog/dependency.h"
1718
#include "catalog/objectaccess.h"
1819
#include "catalog/pg_proc.h"
@@ -68,15 +69,6 @@ void _PG_fini(void);
6869
void
6970
_PG_init(void)
7071
{
71-
/*
72-
* We allow to load the Object Access Type test module on single-user-mode
73-
* or shared_preload_libraries settings only.
74-
*/
75-
if (IsUnderPostmaster)
76-
ereport(ERROR,
77-
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
78-
errmsg("test_oat_hooks must be loaded via shared_preload_libraries")));
79-
8072
/*
8173
* test_oat_hooks.deny_set_variable = (on|off)
8274
*/
@@ -200,7 +192,7 @@ _PG_fini(void)
200192
static void
201193
emit_audit_message(const char *type, const char *hook, char *action, char *objName)
202194
{
203-
if (REGRESS_audit)
195+
if (REGRESS_audit && !IsParallelWorker())
204196
{
205197
const char *who = superuser_arg(GetUserId()) ? "superuser" : "non-superuser";
206198

src/test/modules/test_oat_hooks/test_oat_hooks.conf

-1
This file was deleted.

0 commit comments

Comments
 (0)