Re: pgsql: Add 'basebackup_to_shell' contrib module.

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Magnus Hagander <magnus(at)hagander(dot)net>
Subject: Re: pgsql: Add 'basebackup_to_shell' contrib module.
Date: 2022-03-31 16:08:20
Message-ID: CA+TgmoasOhqLR=TSYmHd4TyX-qnfwtde_u19ZphKunpSCkh_iw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Thu, Mar 31, 2022 at 11:32 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I'm not volunteering to fix that, but this comment in pg_regress.c
> is probably adequately illuminating:
>
> * Rewrite pg_hba.conf and pg_ident.conf to use SSPI authentication. Permit
> * the current OS user to authenticate as the bootstrap superuser and as any
> * user named in a --create-role option.
>
> This script is creating users manually rather than letting the TAP
> infrastructure do it, which is an antipattern.

Well, first, I don't really think it's great if you have to try to
figure out what a tool does by reading the comments in the source
code. I grant that it's a step above trying to interpret the source
code itself, but it's still not great. Second, I think your diagnosis
of the problem is slightly incorrect, because your comment seems to
imply that this change ought to work:

diff --git a/contrib/basebackup_to_shell/t/001_basic.pl
b/contrib/basebackup_to_shell/t/001_basic.pl
index 57534b62c8..1fc0d9ab15 100644
--- a/contrib/basebackup_to_shell/t/001_basic.pl
+++ b/contrib/basebackup_to_shell/t/001_basic.pl
@@ -17,11 +17,11 @@ if (!defined $gzip || $gzip eq '')
}

my $node = PostgreSQL::Test::Cluster->new('primary');
-$node->init('allows_streaming' => 1);
+$node->init('allows_streaming' => 1, auth_extra => [ '--create-role',
'backupuser' ]);
$node->append_conf('postgresql.conf',
"shared_preload_libraries = 'basebackup_to_shell'");
$node->start;
-$node->safe_psql('postgres', 'CREATE USER backupuser REPLICATION');
+#$node->safe_psql('postgres', 'CREATE USER backupuser REPLICATION');
$node->safe_psql('postgres', 'CREATE ROLE trustworthy');

# For nearly all pg_basebackup invocations some options should be specified,

But it doesn't -- with that change, the test fails on Linux,
complaining that the backupuser user does not exist. That's because
--create-role doesn't actually create a role at all, and in fact
absolutely couldn't, because the server isn't even started at the
point where we're running pg_regress. I think we need to both tell
pg_regress to "create the role" and also actually create it. Which is
maybe not a great sign that everything here is totally clear and
comprehensible...

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2022-03-31 16:10:02 Re: pgsql: Add 'basebackup_to_shell' contrib module.
Previous Message Alvaro Herrera 2022-03-31 15:32:23 Re: pgsql: Add 'basebackup_to_shell' contrib module.

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-03-31 16:10:02 Re: pgsql: Add 'basebackup_to_shell' contrib module.
Previous Message Julien Rouhaud 2022-03-31 16:00:36 Re: Possible fails in pg_stat_statements test