Fix pgbench performance issue induced by commit af35fe501.
[pgsql.git] / src / bin / scripts / t / 050_dropdb.pl
blobd0bf4924ce48b9ccec9185e5830445404d19a7bd
2 # Copyright (c) 2021-2025, PostgreSQL Global Development Group
4 use strict;
5 use warnings FATAL => 'all';
7 use PostgreSQL::Test::Cluster;
8 use PostgreSQL::Test::Utils;
9 use Test::More;
11 program_help_ok('dropdb');
12 program_version_ok('dropdb');
13 program_options_handling_ok('dropdb');
15 my $node = PostgreSQL::Test::Cluster->new('main');
16 $node->init;
17 $node->start;
19 $node->safe_psql('postgres', 'CREATE DATABASE foobar1');
20 $node->issues_sql_like(
21 [ 'dropdb', 'foobar1' ],
22 qr/statement: DROP DATABASE foobar1/,
23 'SQL DROP DATABASE run');
25 $node->safe_psql('postgres', 'CREATE DATABASE foobar2');
26 $node->issues_sql_like(
27 [ 'dropdb', '--force', 'foobar2' ],
28 qr/statement: DROP DATABASE foobar2 WITH \(FORCE\);/,
29 'SQL DROP DATABASE (FORCE) run');
31 $node->command_fails_like(
32 [ 'dropdb', 'nonexistent' ],
33 qr/database "nonexistent" does not exist/,
34 'fails with nonexistent database');
36 # check that invalid database can be dropped with dropdb
37 $node->safe_psql(
38 'postgres', q(
39 CREATE DATABASE regression_invalid;
40 UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid';
41 ));
42 $node->command_ok([ 'dropdb', 'regression_invalid' ],
43 'invalid database can be dropped');
45 done_testing();