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

Add proper routine with users over --config-auth#67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sokolcati merged 3 commits intomasterfromPGPRO-14861
Sep 4, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 104 additions & 40 deletionst/001_bad_progress_bar.pl
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,30 +13,8 @@
# 2) extracting the state of the process itself

my $node;
my $dbh_status;
my $pid_status;

sub bad_pid
{
note('Extracting from bad pid');
my $stderr;
$node->psql('postgres', 'SELECT * from pg_progress_bar(-1)', stderr => \$stderr);
is ($stderr, 'psql:<stdin>:1: ERROR: backend with pid=-1 not found', "appealing to a bad pid for pg_progress_bar");
$node->psql('postgres', 'SELECT * from pg_progress_bar(-1)_visual', stderr => \$stderr);
is ($stderr, 'psql:<stdin>:1: ERROR: backend with pid=-1 not found', "appealing to a bad pid for pg_progress_bar_visual");
}

sub self_status
{
note('Extracting your own status');
$dbh_status->do('SELECT * from pg_progress_bar(' . $pid_status . ')');
is($dbh_status->errstr, 'ERROR: attempt to extract state of current process', "extracting the state of the process itself for pg_progress_bar");
$dbh_status->do('SELECT * from pg_progress_bar_visual(' . $pid_status . ')');
is($dbh_status->errstr, 'ERROR: attempt to extract state of current process', "extracting the state of the process itself for pg_progress_bar_visual");
}

# start backend for function pg_progress_bar

# modules depend on the PostgreSQL version
my $pg_15_modules;

BEGIN
Expand DownExpand Up@@ -68,11 +46,95 @@ BEGIN
$node = PostgresNode->get_new_node("master");
}

$node->init;
# start backend for function pg_progress_bar
my $dbh_status;
my $pid_status;

# this code exists only because of problems
# with authentification in Windows
#
# in a friendlier system it would be enough to do:
#
# $node->init;
# $node->start;
# $node->append_conf('postgresql.conf', "shared_preload_libraries = 'pg_query_state'");
# $node->restart;
# $node->psql('postgres', 'CREATE EXTENSION pg_query_state;');
#
# but now we will carefully configure the work
# for specific users and databases
# -----------------------------------------------------------
$ENV{LC_ALL} = 'C';
$ENV{PGCLIENTENCODING} = 'LATIN1';

my $dbname1 = 'regression_bad_progress_bar';
my $username1 = $dbname1;
my $src_bootstrap_super = 'regress_postgres';

$node->init(
extra => [
'--username' => $src_bootstrap_super,
'--locale' => 'C',
'--encoding' => 'LATIN1',
]);

# update pg_hba.conf and pg_ident.conf
# for sppi-authentification in Windows
$node->run_log(
[
$ENV{PG_REGRESS},
'--config-auth' => $node->data_dir,
'--user' => $src_bootstrap_super,
'--create-role' => "$username1",
]);

$node->start;

# create test user and test database
$node->run_log(
[ 'createdb', '--username' => $src_bootstrap_super, $dbname1 ]);
$node->run_log(
[
'createuser',
'--username' => $src_bootstrap_super,
'--superuser',
$username1,
]);

$node->append_conf('postgresql.conf', "shared_preload_libraries = 'pg_query_state'");
$node->restart;
$node->psql('postgres', 'CREATE EXTENSION pg_query_state;');

# now we are ready to create extension pg_query_state
# we perform this and following actions under the
# created test user and on the test database
$node->psql($dbname1, 'CREATE EXTENSION pg_query_state;',
extra_params => ['-U', $username1]);
# -----------------------------------------------------------

sub bad_pid
{
note('Extracting from bad pid');
my $stderr;
$node->psql($dbname1, 'SELECT * from pg_progress_bar(-1)',
stderr => \$stderr, extra_params => ['-U', $username1]);
is ($stderr, 'psql:<stdin>:1: ERROR: backend with pid=-1 not found',
"appealing to a bad pid for pg_progress_bar");
$node->psql($dbname1, 'SELECT * from pg_progress_bar(-1)_visual',
stderr => \$stderr, extra_params => ['-U', $username1]);
is ($stderr, 'psql:<stdin>:1: ERROR: backend with pid=-1 not found',
"appealing to a bad pid for pg_progress_bar_visual");
}

sub self_status
{
note('Extracting your own status');
$dbh_status->do('SELECT * from pg_progress_bar(' . $pid_status . ')');
is($dbh_status->errstr, 'ERROR: attempt to extract state of current process',
"extracting the state of the process itself for pg_progress_bar");
$dbh_status->do('SELECT * from pg_progress_bar_visual(' . $pid_status . ')');
is($dbh_status->errstr, 'ERROR: attempt to extract state of current process',
"extracting the state of the process itself for pg_progress_bar_visual");
}

# 2 tests for 1 case
bad_pid();
Expand All@@ -81,34 +143,36 @@ BEGIN

my $dbdpg_rc = eval
{
require DBI;
require DBD::Pg;
1;
require DBI;
require DBD::Pg;
1;
};

$dbdpg_rc = 0 unless defined $dbdpg_rc;

if ($dbdpg_rc != 1)
{
diag('DBI and DBD::Pg are not available, skip 2/4 tests');
diag('DBI and DBD::Pg are not available, skip 2/4 tests');
}

SKIP: {
skip "DBI and DBD::Pg are not available", 2 if ($dbdpg_rc != 1);
skip "DBI and DBD::Pg are not available", 2 if ($dbdpg_rc != 1);

DBD::Pg->import(':async');

DBD::Pg->import(':async');
$dbh_status = DBI->connect('DBI:Pg:' . $node->connstr('postgres'));
if ( !defined $dbh_status )
{
die "Cannot connect to database for dbh with pg_progress_bar\n";
}
# connect to test database under the test user
$dbh_status = DBI->connect('DBI:Pg:' . $node->connstr() . " user=$username1" . " dbname=$dbname1");
if ( !defined $dbh_status )
{
die "Cannot connect to database for dbh with pg_progress_bar\n";
}

$pid_status = $dbh_status->{pg_pid};
$pid_status = $dbh_status->{pg_pid};

# 2 tests for 2 case
self_status();
# 2 tests for 2 case
self_status();

$dbh_status->disconnect;
$dbh_status->disconnect;
}

$node->stop('fast');
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp