# Create temporary roles and log table
psql_command(
- $node, 'CREATE ROLE alice WITH LOGIN;
-CREATE ROLE mallory WITH LOGIN;
+ $node, 'CREATE ROLE regress_alice WITH LOGIN;
+CREATE ROLE regress_mallory WITH LOGIN;
CREATE TABLE user_logins(id serial, who text);
GRANT SELECT ON user_logins TO public;
', 0, 'create tmp objects',
'CREATE FUNCTION on_login_proc() RETURNS event_trigger AS $$
BEGIN
INSERT INTO user_logins (who) VALUES (SESSION_USER);
- IF SESSION_USER = \'mallory\' THEN
+ IF SESSION_USER = \'regress_mallory\' THEN
RAISE EXCEPTION \'Hello %! You are NOT welcome here!\', SESSION_USER;
END IF;
RAISE NOTICE \'Hello %! You are welcome!\', SESSION_USER;
# Try to log as allowed Alice and disallowed Mallory (two times)
psql_command(
- $node, 'SELECT 1;', 0, 'try alice',
- connstr => 'user=alice',
+ $node, 'SELECT 1;', 0, 'try regress_alice',
+ connstr => 'user=regress_alice',
log_exact => '1',
err_like => [qr/You are welcome/],
err_unlike => [qr/You are NOT welcome/]);
psql_command(
- $node, 'SELECT 1;', 2, 'try mallory',
- connstr => 'user=mallory',
+ $node, 'SELECT 1;', 2, 'try regress_mallory',
+ connstr => 'user=regress_mallory',
log_exact => '',
err_like => [qr/You are NOT welcome/],
err_unlike => [qr/You are welcome/]);
psql_command(
- $node, 'SELECT 1;', 2, 'try mallory',
- connstr => 'user=mallory',
+ $node, 'SELECT 1;', 2, 'try regress_mallory',
+ connstr => 'user=regress_mallory',
log_exact => '',
err_like => [qr/You are NOT welcome/],
err_unlike => [qr/You are welcome/]);
# Check that Alice's login record is here, while the Mallory's one is not
psql_command(
$node, 'SELECT * FROM user_logins;', 0, 'select *',
- log_like => [qr/3\|alice/],
- log_unlike => [qr/mallory/],
+ log_like => [qr/3\|regress_alice/],
+ log_unlike => [qr/regress_mallory/],
err_like => [qr/You are welcome/]);
# Check total number of successful logins so far
psql_command(
$node, 'DROP TABLE user_logins;
DROP FUNCTION on_login_proc;
-DROP ROLE mallory;
-DROP ROLE alice;
+DROP ROLE regress_mallory;
+DROP ROLE regress_alice;
', 0, 'cleanup',
log_exact => '',
err_exact => '');