diff options
author | Michael Paquier <michael@paquier.xyz> | 2025-01-22 14:47:13 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2025-01-22 14:47:13 +0900 |
commit | ce1b0f9da03e1cebc293f60b378079b22bd7cc0f (patch) | |
tree | 78c3030de2cc9d201168e8297b5754bf35e37fd2 /src/bin/scripts/t | |
parent | 4a0e7314f11ee03adfe9df945598c068b4179314 (diff) | |
download | postgresql-ce1b0f9da03e1cebc293f60b378079b22bd7cc0f.tar.gz postgresql-ce1b0f9da03e1cebc293f60b378079b22bd7cc0f.zip |
Improve grammar of options for command arrays in TAP tests
This commit rewrites a good chunk of the command arrays in TAP tests
with a grammar based on the following rules:
- Fat commas are used between option names and their values, making it
clear to both humans and perltidy that values and names are bound
together. This is particularly useful for the readability of multi-line
command arrays, and there are plenty of them in the TAP tests. Most of
the test code is updated to use this style. Some commands used
parenthesis to show the link, or attached values and options in a single
string. These are updated to use fat commas instead.
- Option names are switched to use their long names, making them more
self-documented. Based on a suggestion by Andrew Dunstan.
- Add some trailing commas after the last item in multi-line arrays,
which is a common perl style.
Not all the places are taken care of, but this covers a very good chunk
of them.
Author: Dagfinn Ilmari Mannsåker
Reviewed-by: Michael Paquier, Peter Smith, Euler Taveira
Discussion: https://postgr.es/m/87jzc46d8u.fsf@wibble.ilmari.org
Diffstat (limited to 'src/bin/scripts/t')
-rw-r--r-- | src/bin/scripts/t/010_clusterdb.pl | 4 | ||||
-rw-r--r-- | src/bin/scripts/t/011_clusterdb_all.pl | 8 | ||||
-rw-r--r-- | src/bin/scripts/t/020_createdb.pl | 216 | ||||
-rw-r--r-- | src/bin/scripts/t/040_createuser.pl | 36 | ||||
-rw-r--r-- | src/bin/scripts/t/080_pg_isready.pl | 5 | ||||
-rw-r--r-- | src/bin/scripts/t/090_reindexdb.pl | 107 | ||||
-rw-r--r-- | src/bin/scripts/t/091_reindexdb_all.pl | 16 | ||||
-rw-r--r-- | src/bin/scripts/t/100_vacuumdb.pl | 95 | ||||
-rw-r--r-- | src/bin/scripts/t/101_vacuumdb_all.pl | 6 |
9 files changed, 325 insertions, 168 deletions
diff --git a/src/bin/scripts/t/010_clusterdb.pl b/src/bin/scripts/t/010_clusterdb.pl index f42a26b22de..a4e4d468578 100644 --- a/src/bin/scripts/t/010_clusterdb.pl +++ b/src/bin/scripts/t/010_clusterdb.pl @@ -21,14 +21,14 @@ $node->issues_sql_like( qr/statement: CLUSTER;/, 'SQL CLUSTER run'); -$node->command_fails([ 'clusterdb', '-t', 'nonexistent' ], +$node->command_fails([ 'clusterdb', '--table' => 'nonexistent' ], 'fails with nonexistent table'); $node->safe_psql('postgres', 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a); CLUSTER test1 USING test1x' ); $node->issues_sql_like( - [ 'clusterdb', '-t', 'test1' ], + [ 'clusterdb', '--table' => 'test1' ], qr/statement: CLUSTER public\.test1;/, 'cluster specific table'); diff --git a/src/bin/scripts/t/011_clusterdb_all.pl b/src/bin/scripts/t/011_clusterdb_all.pl index beaf2930f0e..cf06c8c1f8e 100644 --- a/src/bin/scripts/t/011_clusterdb_all.pl +++ b/src/bin/scripts/t/011_clusterdb_all.pl @@ -15,7 +15,7 @@ $node->start; # clusterdb -a is not compatible with -d. This relies on PGDATABASE to be # set, something PostgreSQL::Test::Cluster does. $node->issues_sql_like( - [ 'clusterdb', '-a' ], + [ 'clusterdb', '--all' ], qr/statement: CLUSTER.*statement: CLUSTER/s, 'cluster all databases'); @@ -24,13 +24,13 @@ $node->safe_psql( CREATE DATABASE regression_invalid; UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid'; )); -$node->command_ok([ 'clusterdb', '-a' ], +$node->command_ok([ 'clusterdb', '--all' ], 'invalid database not targeted by clusterdb -a'); # Doesn't quite belong here, but don't want to waste time by creating an # invalid database in 010_clusterdb.pl as well. $node->command_fails_like( - [ 'clusterdb', '-d', 'regression_invalid' ], + [ 'clusterdb', '--dbname' => 'regression_invalid' ], qr/FATAL: cannot connect to invalid database "regression_invalid"/, 'clusterdb cannot target invalid database'); @@ -41,7 +41,7 @@ $node->safe_psql('template1', 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a); CLUSTER test1 USING test1x' ); $node->issues_sql_like( - [ 'clusterdb', '-a', '-t', 'test1' ], + [ 'clusterdb', '--all', '--table' => 'test1' ], qr/statement: CLUSTER public\.test1/s, 'cluster specific table in all databases'); diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl index 191c7885a8d..a8293390ede 100644 --- a/src/bin/scripts/t/020_createdb.pl +++ b/src/bin/scripts/t/020_createdb.pl @@ -21,7 +21,13 @@ $node->issues_sql_like( qr/statement: CREATE DATABASE foobar1/, 'SQL CREATE DATABASE run'); $node->issues_sql_like( - [ 'createdb', '-l', 'C', '-E', 'LATIN1', '-T', 'template0', 'foobar2' ], + [ + 'createdb', + '--locale' => 'C', + '--encoding' => 'LATIN1', + '--template' => 'template0', + 'foobar2', + ], qr/statement: CREATE DATABASE foobar2 ENCODING 'LATIN1'/, 'create database with encoding'); @@ -32,35 +38,45 @@ if ($ENV{with_icu} eq 'yes') # provider. XXX Maybe split into multiple tests? $node->command_fails( [ - 'createdb', '-T', 'template0', '-E', 'UTF8', - '--locale-provider=icu', 'foobar4' + 'createdb', + '--template' => 'template0', + '--encoding' => 'UTF8', + '--locale-provider' => 'icu', + 'foobar4', ], 'create database with ICU fails without ICU locale specified'); $node->issues_sql_like( [ - 'createdb', '-T', - 'template0', '-E', - 'UTF8', '--locale-provider=icu', - '--locale=C', '--icu-locale=en', - 'foobar5' + 'createdb', + '--template' => 'template0', + '--encoding' => 'UTF8', + '--locale-provider' => 'icu', + '--locale' => 'C', + '--icu-locale' => 'en', + 'foobar5', ], qr/statement: CREATE DATABASE foobar5 .* LOCALE_PROVIDER icu ICU_LOCALE 'en'/, 'create database with ICU locale specified'); $node->command_fails( [ - 'createdb', '-T', 'template0', '-E', 'UTF8', - '--locale-provider=icu', - '--icu-locale=@colNumeric=lower', 'foobarX' + 'createdb', + '--template' => 'template0', + '--encoding' => 'UTF8', + '--locale-provider' => 'icu', + '--icu-locale' => '@colNumeric=lower', + 'foobarX', ], 'fails for invalid ICU locale'); $node->command_fails_like( [ - 'createdb', '-T', - 'template0', '--locale-provider=icu', - '--encoding=SQL_ASCII', 'foobarX' + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'icu', + '--encoding' => 'SQL_ASCII', + 'foobarX', ], qr/ERROR: encoding "SQL_ASCII" is not supported with ICU provider/, 'fails for encoding not supported by ICU'); @@ -72,116 +88,144 @@ if ($ENV{with_icu} eq 'yes') $node2->command_ok( [ - 'createdb', '-T', - 'template0', '--locale-provider=libc', - 'foobar55' + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'libc', + 'foobar55', ], 'create database with libc provider from template database with icu provider' ); $node2->command_ok( [ - 'createdb', '-T', 'template0', '--icu-locale', 'en-US', - 'foobar56' + 'createdb', + '--template' => 'template0', + '--icu-locale' => 'en-US', + 'foobar56', ], 'create database with icu locale from template database with icu provider' ); $node2->command_ok( [ - 'createdb', '-T', - 'template0', '--locale-provider', - 'icu', '--locale', - 'en', '--lc-collate', - 'C', '--lc-ctype', - 'C', 'foobar57' + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'icu', + '--locale' => 'en', + '--lc-collate' => 'C', + '--lc-ctype' => 'C', + 'foobar57', ], 'create database with locale as ICU locale'); } else { $node->command_fails( - [ 'createdb', '-T', 'template0', '--locale-provider=icu', 'foobar4' ], + [ + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'icu', + 'foobar4', + ], 'create database with ICU fails since no ICU support'); } $node->command_fails( [ - 'createdb', '-T', - 'template0', '--locale-provider=builtin', - 'tbuiltin1' + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'builtin', + 'tbuiltin1', ], 'create database with provider "builtin" fails without --locale'); $node->command_ok( [ - 'createdb', '-T', - 'template0', '--locale-provider=builtin', - '--locale=C', 'tbuiltin2' + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'builtin', + '--locale' => 'C', + 'tbuiltin2', ], 'create database with provider "builtin" and locale "C"'); $node->command_ok( [ - 'createdb', '-T', - 'template0', '--locale-provider=builtin', - '--locale=C', '--lc-collate=C', - 'tbuiltin3' + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'builtin', + '--locale' => 'C', + '--lc-collate' => 'C', + 'tbuiltin3', ], 'create database with provider "builtin" and LC_COLLATE=C'); $node->command_ok( [ - 'createdb', '-T', - 'template0', '--locale-provider=builtin', - '--locale=C', '--lc-ctype=C', - 'tbuiltin4' + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'builtin', + '--locale' => 'C', + '--lc-ctype' => 'C', + 'tbuiltin4', ], 'create database with provider "builtin" and LC_CTYPE=C'); $node->command_ok( [ - 'createdb', '-T', - 'template0', '--locale-provider=builtin', - '--lc-collate=C', '--lc-ctype=C', - '-E UTF-8', '--builtin-locale=C.UTF8', - 'tbuiltin5' + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'builtin', + '--lc-collate' => 'C', + '--lc-ctype' => 'C', + '--encoding' => 'UTF-8', + '--builtin-locale' => 'C.UTF8', + 'tbuiltin5', ], 'create database with --builtin-locale C.UTF-8 and -E UTF-8'); $node->command_fails( [ - 'createdb', '-T', - 'template0', '--locale-provider=builtin', - '--lc-collate=C', '--lc-ctype=C', - '-E LATIN1', '--builtin-locale=C.UTF-8', - 'tbuiltin6' + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'builtin', + '--lc-collate' => 'C', + '--lc-ctype' => 'C', + '--encoding' => 'LATIN1', + '--builtin-locale' => 'C.UTF-8', + 'tbuiltin6', ], 'create database with --builtin-locale C.UTF-8 and -E LATIN1'); $node->command_fails( [ - 'createdb', '-T', - 'template0', '--locale-provider=builtin', - '--locale=C', '--icu-locale=en', - 'tbuiltin7' + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'builtin', + '--locale' => 'C', + '--icu-locale' => 'en', + 'tbuiltin7', ], 'create database with provider "builtin" and ICU_LOCALE="en"'); $node->command_fails( [ - 'createdb', '-T', - 'template0', '--locale-provider=builtin', - '--locale=C', '--icu-rules=""', - 'tbuiltin8' + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'builtin', + '--locale' => 'C', + '--icu-rules' => '""', + 'tbuiltin8', ], 'create database with provider "builtin" and ICU_RULES=""'); $node->command_fails( [ - 'createdb', '-T', - 'template1', '--locale-provider=builtin', - '--locale=C', 'tbuiltin9' + 'createdb', + '--template' => 'template1', + '--locale-provider' => 'builtin', + '--locale' => 'C', + 'tbuiltin9', ], 'create database with provider "builtin" not matching template'); @@ -189,7 +233,12 @@ $node->command_fails([ 'createdb', 'foobar1' ], 'fails if database already exists'); $node->command_fails( - [ 'createdb', '-T', 'template0', '--locale-provider=xyz', 'foobarX' ], + [ + 'createdb', + '--template' => 'template0', + '--locale-provider' => 'xyz', + 'foobarX', + ], 'fails for invalid locale provider'); # Check use of templates with shared dependencies copied from the template. @@ -200,7 +249,7 @@ CREATE TABLE tab_foobar (id int); ALTER TABLE tab_foobar owner to role_foobar; CREATE POLICY pol_foobar ON tab_foobar FOR ALL TO role_foobar;'); $node->issues_sql_like( - [ 'createdb', '-l', 'C', '-T', 'foobar2', 'foobar3' ], + [ 'createdb', '--locale' => 'C', '--template' => 'foobar2', 'foobar3' ], qr/statement: CREATE DATABASE foobar3 TEMPLATE foobar2 LOCALE 'C'/, 'create database with template'); ($ret, $stdout, $stderr) = $node->psql( @@ -228,7 +277,7 @@ $node->command_checks_all( 1, [qr/^$/], [ - qr/^createdb: error: database creation failed: ERROR: invalid LC_COLLATE locale name|^createdb: error: database creation failed: ERROR: new collation \(foo'; SELECT '1\) is incompatible with the collation of the template database/s + qr/^createdb: error: database creation failed: ERROR: invalid LC_COLLATE locale name|^createdb: error: database creation failed: ERROR: new collation \(foo'; SELECT '1\) is incompatible with the collation of the template database/s, ], 'createdb with incorrect --lc-collate'); $node->command_checks_all( @@ -236,7 +285,7 @@ $node->command_checks_all( 1, [qr/^$/], [ - qr/^createdb: error: database creation failed: ERROR: invalid LC_CTYPE locale name|^createdb: error: database creation failed: ERROR: new LC_CTYPE \(foo'; SELECT '1\) is incompatible with the LC_CTYPE of the template database/s + qr/^createdb: error: database creation failed: ERROR: invalid LC_CTYPE locale name|^createdb: error: database creation failed: ERROR: new LC_CTYPE \(foo'; SELECT '1\) is incompatible with the LC_CTYPE of the template database/s, ], 'createdb with incorrect --lc-ctype'); @@ -245,34 +294,59 @@ $node->command_checks_all( 1, [qr/^$/], [ - qr/^createdb: error: database creation failed: ERROR: invalid create database strategy "foo"/s + qr/^createdb: error: database creation failed: ERROR: invalid create database strategy "foo"/s, ], 'createdb with incorrect --strategy'); # Check database creation strategy $node->issues_sql_like( - [ 'createdb', '-T', 'foobar2', '-S', 'wal_log', 'foobar6' ], + [ + 'createdb', + '--template' => 'foobar2', + '--strategy' => 'wal_log', + 'foobar6', + ], qr/statement: CREATE DATABASE foobar6 STRATEGY wal_log TEMPLATE foobar2/, 'create database with WAL_LOG strategy'); $node->issues_sql_like( - [ 'createdb', '-T', 'foobar2', '-S', 'WAL_LOG', 'foobar6s' ], + [ + 'createdb', + '--template' => 'foobar2', + '--strategy' => 'WAL_LOG', + 'foobar6s', + ], qr/statement: CREATE DATABASE foobar6s STRATEGY "WAL_LOG" TEMPLATE foobar2/, 'create database with WAL_LOG strategy'); $node->issues_sql_like( - [ 'createdb', '-T', 'foobar2', '-S', 'file_copy', 'foobar7' ], + [ + 'createdb', + '--template' => 'foobar2', + '--strategy' => 'file_copy', + 'foobar7', + ], qr/statement: CREATE DATABASE foobar7 STRATEGY file_copy TEMPLATE foobar2/, 'create database with FILE_COPY strategy'); $node->issues_sql_like( - [ 'createdb', '-T', 'foobar2', '-S', 'FILE_COPY', 'foobar7s' ], + [ + 'createdb', + '--template' => 'foobar2', + '--strategy' => 'FILE_COPY', + 'foobar7s', + ], qr/statement: CREATE DATABASE foobar7s STRATEGY "FILE_COPY" TEMPLATE foobar2/, 'create database with FILE_COPY strategy'); # Create database owned by role_foobar. $node->issues_sql_like( - [ 'createdb', '-T', 'foobar2', '-O', 'role_foobar', 'foobar8' ], + [ + 'createdb', + '--template' => 'foobar2', + '--owner' => 'role_foobar', + 'foobar8', + ], qr/statement: CREATE DATABASE foobar8 OWNER role_foobar TEMPLATE foobar2/, 'create database with owner role_foobar'); ($ret, $stdout, $stderr) = diff --git a/src/bin/scripts/t/040_createuser.pl b/src/bin/scripts/t/040_createuser.pl index 2783ef8b0fc..54af43401bb 100644 --- a/src/bin/scripts/t/040_createuser.pl +++ b/src/bin/scripts/t/040_createuser.pl @@ -21,34 +21,37 @@ $node->issues_sql_like( qr/statement: CREATE ROLE regress_user1 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS;/, 'SQL CREATE USER run'); $node->issues_sql_like( - [ 'createuser', '-L', 'regress_role1' ], + [ 'createuser', '--no-login', 'regress_role1' ], qr/statement: CREATE ROLE regress_role1 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT NOLOGIN NOREPLICATION NOBYPASSRLS;/, 'create a non-login role'); $node->issues_sql_like( - [ 'createuser', '-r', 'regress user2' ], + [ 'createuser', '--createrole', 'regress user2' ], qr/statement: CREATE ROLE "regress user2" NOSUPERUSER NOCREATEDB CREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS;/, 'create a CREATEROLE user'); $node->issues_sql_like( - [ 'createuser', '-s', 'regress_user3' ], + [ 'createuser', '--superuser', 'regress_user3' ], qr/statement: CREATE ROLE regress_user3 SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS;/, 'create a superuser'); $node->issues_sql_like( [ - 'createuser', '-a', - 'regress_user1', '-a', - 'regress user2', 'regress user #4' + 'createuser', + '--with-admin' => 'regress_user1', + '--with-admin' => 'regress user2', + 'regress user #4' ], qr/statement: CREATE ROLE "regress user #4" NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS ADMIN regress_user1,"regress user2";/, 'add a role as a member with admin option of the newly created role'); $node->issues_sql_like( [ - 'createuser', 'REGRESS_USER5', '-m', 'regress_user3', - '-m', 'regress user #4' + 'createuser', + 'REGRESS_USER5', + '--with-member' => 'regress_user3', + '--with-member' => 'regress user #4' ], qr/statement: CREATE ROLE "REGRESS_USER5" NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS ROLE regress_user3,"regress user #4";/, 'add a role as a member of the newly created role'); $node->issues_sql_like( - [ 'createuser', '-v', '2029 12 31', 'regress_user6' ], + [ 'createuser', '--valid-until' => '2029 12 31', 'regress_user6' ], qr/statement: CREATE ROLE regress_user6 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS VALID UNTIL \'2029 12 31\';/, 'create a role with a password expiration date'); $node->issues_sql_like( @@ -60,26 +63,31 @@ $node->issues_sql_like( qr/statement: CREATE ROLE regress_user8 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS;/, 'create a role without BYPASSRLS'); $node->issues_sql_like( - [ 'createuser', '--with-admin', 'regress_user1', 'regress_user9' ], + [ 'createuser', '--with-admin' => 'regress_user1', 'regress_user9' ], qr/statement: CREATE ROLE regress_user9 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS ADMIN regress_user1;/, '--with-admin'); $node->issues_sql_like( - [ 'createuser', '--with-member', 'regress_user1', 'regress_user10' ], + [ 'createuser', '--with-member' => 'regress_user1', 'regress_user10' ], qr/statement: CREATE ROLE regress_user10 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS ROLE regress_user1;/, '--with-member'); $node->issues_sql_like( - [ 'createuser', '--role', 'regress_user1', 'regress_user11' ], + [ 'createuser', '--role' => 'regress_user1', 'regress_user11' ], qr/statement: CREATE ROLE regress_user11 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS IN ROLE regress_user1;/, '--role'); $node->issues_sql_like( - [ 'createuser', 'regress_user12', '--member-of', 'regress_user1' ], + [ 'createuser', 'regress_user12', '--member-of' => 'regress_user1' ], qr/statement: CREATE ROLE regress_user12 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS IN ROLE regress_user1;/, '--member-of'); $node->command_fails([ 'createuser', 'regress_user1' ], 'fails if role already exists'); $node->command_fails( - [ 'createuser', 'regress_user1', '-m', 'regress_user2', 'regress_user3' ], + [ + 'createuser', + 'regress_user1', + '--with-member' => 'regress_user2', + 'regress_user3' + ], 'fails for too many non-options'); done_testing(); diff --git a/src/bin/scripts/t/080_pg_isready.pl b/src/bin/scripts/t/080_pg_isready.pl index 8bb9f38f501..f184bd77388 100644 --- a/src/bin/scripts/t/080_pg_isready.pl +++ b/src/bin/scripts/t/080_pg_isready.pl @@ -20,7 +20,10 @@ $node->command_fails(['pg_isready'], 'fails with no server running'); $node->start; $node->command_ok( - [ 'pg_isready', "--timeout=$PostgreSQL::Test::Utils::timeout_default" ], + [ + 'pg_isready', + '--timeout' => $PostgreSQL::Test::Utils::timeout_default, + ], 'succeeds with server running'); done_testing(); diff --git a/src/bin/scripts/t/090_reindexdb.pl b/src/bin/scripts/t/090_reindexdb.pl index 9110974e8a7..378f8ad7a58 100644 --- a/src/bin/scripts/t/090_reindexdb.pl +++ b/src/bin/scripts/t/090_reindexdb.pl @@ -96,7 +96,7 @@ test1|test1x|OID is unchanged|relfilenode has changed), $node->safe_psql('postgres', "TRUNCATE index_relfilenodes; $save_relfilenodes"); $node->issues_sql_like( - [ 'reindexdb', '-s', 'postgres' ], + [ 'reindexdb', '--system', 'postgres' ], qr/statement: REINDEX SYSTEM postgres;/, 'reindex system tables'); $relnode_info = $node->safe_psql('postgres', $compare_relfilenodes); @@ -108,29 +108,37 @@ test1|test1x|OID is unchanged|relfilenode is unchanged), 'relfilenode change after REINDEX SYSTEM'); $node->issues_sql_like( - [ 'reindexdb', '-t', 'test1', 'postgres' ], + [ 'reindexdb', '--table' => 'test1', 'postgres' ], qr/statement: REINDEX TABLE public\.test1;/, 'reindex specific table'); $node->issues_sql_like( - [ 'reindexdb', '-t', 'test1', '--tablespace', $tbspace_name, 'postgres' ], + [ + 'reindexdb', + '--table' => 'test1', + '--tablespace' => $tbspace_name, + 'postgres', + ], qr/statement: REINDEX \(TABLESPACE $tbspace_name\) TABLE public\.test1;/, 'reindex specific table on tablespace'); $node->issues_sql_like( - [ 'reindexdb', '-i', 'test1x', 'postgres' ], + [ 'reindexdb', '--index' => 'test1x', 'postgres' ], qr/statement: REINDEX INDEX public\.test1x;/, 'reindex specific index'); $node->issues_sql_like( - [ 'reindexdb', '-S', 'pg_catalog', 'postgres' ], + [ 'reindexdb', '--schema' => 'pg_catalog', 'postgres' ], qr/statement: REINDEX SCHEMA pg_catalog;/, 'reindex specific schema'); $node->issues_sql_like( - [ 'reindexdb', '-v', '-t', 'test1', 'postgres' ], + [ 'reindexdb', '--verbose', '--table' => 'test1', 'postgres' ], qr/statement: REINDEX \(VERBOSE\) TABLE public\.test1;/, 'reindex with verbose output'); $node->issues_sql_like( [ - 'reindexdb', '-v', '-t', 'test1', - '--tablespace', $tbspace_name, 'postgres' + 'reindexdb', + '--verbose', + '--table' => 'test1', + '--tablespace' => $tbspace_name, + 'postgres', ], qr/statement: REINDEX \(VERBOSE, TABLESPACE $tbspace_name\) TABLE public\.test1;/, 'reindex with verbose output and tablespace'); @@ -153,27 +161,36 @@ test1|test1x|OID has changed|relfilenode has changed), 'OID change after REINDEX DATABASE CONCURRENTLY'); $node->issues_sql_like( - [ 'reindexdb', '--concurrently', '-t', 'test1', 'postgres' ], + [ 'reindexdb', '--concurrently', '--table' => 'test1', 'postgres' ], qr/statement: REINDEX TABLE CONCURRENTLY public\.test1;/, 'reindex specific table concurrently'); $node->issues_sql_like( - [ 'reindexdb', '--concurrently', '-i', 'test1x', 'postgres' ], + [ 'reindexdb', '--concurrently', '--index' => 'test1x', 'postgres' ], qr/statement: REINDEX INDEX CONCURRENTLY public\.test1x;/, 'reindex specific index concurrently'); $node->issues_sql_like( - [ 'reindexdb', '--concurrently', '-S', 'public', 'postgres' ], + [ 'reindexdb', '--concurrently', '--schema' => 'public', 'postgres' ], qr/statement: REINDEX SCHEMA CONCURRENTLY public;/, 'reindex specific schema concurrently'); -$node->command_fails([ 'reindexdb', '--concurrently', '-s', 'postgres' ], +$node->command_fails( + [ 'reindexdb', '--concurrently', '--system', 'postgres' ], 'reindex system tables concurrently'); $node->issues_sql_like( - [ 'reindexdb', '--concurrently', '-v', '-t', 'test1', 'postgres' ], + [ + 'reindexdb', '--concurrently', '--verbose', + '--table' => 'test1', + 'postgres', + ], qr/statement: REINDEX \(VERBOSE\) TABLE CONCURRENTLY public\.test1;/, 'reindex with verbose output concurrently'); $node->issues_sql_like( [ - 'reindexdb', '--concurrently', '-v', '-t', - 'test1', '--tablespace', $tbspace_name, 'postgres' + 'reindexdb', + '--concurrently', + '--verbose', + '--table' => 'test1', + '--tablespace' => $tbspace_name, + 'postgres', ], qr/statement: REINDEX \(VERBOSE, TABLESPACE $tbspace_name\) TABLE CONCURRENTLY public\.test1;/, 'reindex concurrently with verbose output and tablespace'); @@ -185,8 +202,10 @@ $node->issues_sql_like( # messages. $node->command_checks_all( [ - 'reindexdb', '-t', $toast_table, '--tablespace', - $tbspace_name, 'postgres' + 'reindexdb', + '--table' => $toast_table, + '--tablespace' => $tbspace_name, + 'postgres', ], 1, [], @@ -194,8 +213,11 @@ $node->command_checks_all( 'reindex toast table with tablespace'); $node->command_checks_all( [ - 'reindexdb', '--concurrently', '-t', $toast_table, - '--tablespace', $tbspace_name, 'postgres' + 'reindexdb', + '--concurrently', + '--table' => $toast_table, + '--tablespace' => $tbspace_name, + 'postgres', ], 1, [], @@ -203,8 +225,10 @@ $node->command_checks_all( 'reindex toast table concurrently with tablespace'); $node->command_checks_all( [ - 'reindexdb', '-i', $toast_index, '--tablespace', - $tbspace_name, 'postgres' + 'reindexdb', + '--index' => $toast_index, + '--tablespace' => $tbspace_name, + 'postgres', ], 1, [], @@ -212,8 +236,11 @@ $node->command_checks_all( 'reindex toast index with tablespace'); $node->command_checks_all( [ - 'reindexdb', '--concurrently', '-i', $toast_index, - '--tablespace', $tbspace_name, 'postgres' + 'reindexdb', + '--concurrently', + '--index' => $toast_index, + '--tablespace' => $tbspace_name, + 'postgres', ], 1, [], @@ -246,35 +273,51 @@ $node->safe_psql( |); $node->command_fails( - [ 'reindexdb', '-j', '2', '-s', 'postgres' ], + [ 'reindexdb', '--jobs' => '2', '--system', 'postgres' ], 'parallel reindexdb cannot process system catalogs'); $node->command_ok( - [ 'reindexdb', '-j', '2', '-i', 's1.i1', '-i', 's2.i2', 'postgres' ], + [ + 'reindexdb', + '--jobs' => '2', + '--index' => 's1.i1', + '--index' => 's2.i2', + 'postgres', + ], 'parallel reindexdb for indices'); # Note that the ordering of the commands is not stable, so the second # command for s2.t2 is not checked after. $node->issues_sql_like( - [ 'reindexdb', '-j', '2', '-S', 's1', '-S', 's2', 'postgres' ], + [ + 'reindexdb', + '--jobs' => '2', + '--schema' => 's1', + '--schema' => 's2', + 'postgres', + ], qr/statement:\ REINDEX TABLE s1.t1;/, 'parallel reindexdb for schemas does a per-table REINDEX'); -$node->command_ok( - [ 'reindexdb', '-j', '2', '-S', 's3' ], +$node->command_ok([ 'reindexdb', '--jobs' => '2', '--schema' => 's3' ], 'parallel reindexdb with empty schema'); $node->command_ok( - [ 'reindexdb', '-j', '2', '--concurrently', '-d', 'postgres' ], + [ + 'reindexdb', + '--jobs' => '2', + '--concurrently', + '--dbname' => 'postgres', + ], 'parallel reindexdb on database, concurrently'); # combinations of objects $node->issues_sql_like( - [ 'reindexdb', '-s', '-t', 'test1', 'postgres' ], + [ 'reindexdb', '--system', '--table' => 'test1', 'postgres' ], qr/statement:\ REINDEX SYSTEM postgres;/, 'specify both --system and --table'); $node->issues_sql_like( - [ 'reindexdb', '-s', '-i', 'test1x', 'postgres' ], + [ 'reindexdb', '--system', '--index' => 'test1x', 'postgres' ], qr/statement:\ REINDEX INDEX public.test1x;/, 'specify both --system and --index'); $node->issues_sql_like( - [ 'reindexdb', '-s', '-S', 'pg_catalog', 'postgres' ], + [ 'reindexdb', '--system', '--schema' => 'pg_catalog', 'postgres' ], qr/statement:\ REINDEX SCHEMA pg_catalog;/, 'specify both --system and --schema'); diff --git a/src/bin/scripts/t/091_reindexdb_all.pl b/src/bin/scripts/t/091_reindexdb_all.pl index 3da5f3a9ef8..6a75946b2b9 100644 --- a/src/bin/scripts/t/091_reindexdb_all.pl +++ b/src/bin/scripts/t/091_reindexdb_all.pl @@ -18,23 +18,23 @@ $node->safe_psql('postgres', $node->safe_psql('template1', 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a);'); $node->issues_sql_like( - [ 'reindexdb', '-a' ], + [ 'reindexdb', '--all' ], qr/statement: REINDEX.*statement: REINDEX/s, 'reindex all databases'); $node->issues_sql_like( - [ 'reindexdb', '-a', '-s' ], + [ 'reindexdb', '--all', '--system' ], qr/statement: REINDEX SYSTEM postgres/s, 'reindex system catalogs in all databases'); $node->issues_sql_like( - [ 'reindexdb', '-a', '-S', 'public' ], + [ 'reindexdb', '--all', '--schema' => 'public' ], qr/statement: REINDEX SCHEMA public/s, 'reindex schema in all databases'); $node->issues_sql_like( - [ 'reindexdb', '-a', '-i', 'test1x' ], + [ 'reindexdb', '--all', '--index' => 'test1x' ], qr/statement: REINDEX INDEX public\.test1x/s, 'reindex index in all databases'); $node->issues_sql_like( - [ 'reindexdb', '-a', '-t', 'test1' ], + [ 'reindexdb', '--all', '--table' => 'test1' ], qr/statement: REINDEX TABLE public\.test1/s, 'reindex table in all databases'); @@ -43,13 +43,13 @@ $node->safe_psql( CREATE DATABASE regression_invalid; UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid'; )); -$node->command_ok([ 'reindexdb', '-a' ], - 'invalid database not targeted by reindexdb -a'); +$node->command_ok([ 'reindexdb', '--all' ], + 'invalid database not targeted by reindexdb --all'); # Doesn't quite belong here, but don't want to waste time by creating an # invalid database in 090_reindexdb.pl as well. $node->command_fails_like( - [ 'reindexdb', '-d', 'regression_invalid' ], + [ 'reindexdb', '--dbname' => 'regression_invalid' ], qr/FATAL: cannot connect to invalid database "regression_invalid"/, 'reindexdb cannot target invalid database'); diff --git a/src/bin/scripts/t/100_vacuumdb.pl b/src/bin/scripts/t/100_vacuumdb.pl index ccb7711af43..2d174df9aae 100644 --- a/src/bin/scripts/t/100_vacuumdb.pl +++ b/src/bin/scripts/t/100_vacuumdb.pl @@ -80,11 +80,11 @@ $node->command_fails( [ 'vacuumdb', '--analyze-only', '--no-process-toast', 'postgres' ], '--analyze-only and --no-process-toast specified together'); $node->issues_sql_like( - [ 'vacuumdb', '-P', 2, 'postgres' ], + [ 'vacuumdb', '--parallel' => 2, 'postgres' ], qr/statement: VACUUM \(SKIP_DATABASE_STATS, PARALLEL 2\).*;/, 'vacuumdb -P 2'); $node->issues_sql_like( - [ 'vacuumdb', '-P', 0, 'postgres' ], + [ 'vacuumdb', '--parallel' => 0, 'postgres' ], qr/statement: VACUUM \(SKIP_DATABASE_STATS, PARALLEL 0\).*;/, 'vacuumdb -P 0'); $node->command_ok([qw(vacuumdb -Z --table=pg_am dbname=template1)], @@ -118,94 +118,123 @@ $node->command_ok([qw|vacuumdb -Z --table="need""q(uot"(")x") postgres|], 'column list'); $node->command_fails( - [ 'vacuumdb', '--analyze', '--table', 'vactable(c)', 'postgres' ], + [ 'vacuumdb', '--analyze', '--table' => 'vactable(c)', 'postgres' ], 'incorrect column name with ANALYZE'); -$node->command_fails([ 'vacuumdb', '-P', -1, 'postgres' ], +$node->command_fails([ 'vacuumdb', '--parallel' => -1, 'postgres' ], 'negative parallel degree'); $node->issues_sql_like( - [ 'vacuumdb', '--analyze', '--table', 'vactable(a, b)', 'postgres' ], + [ 'vacuumdb', '--analyze', '--table' => 'vactable(a, b)', 'postgres' ], qr/statement: VACUUM \(SKIP_DATABASE_STATS, ANALYZE\) public.vactable\(a, b\);/, 'vacuumdb --analyze with complete column list'); $node->issues_sql_like( - [ 'vacuumdb', '--analyze-only', '--table', 'vactable(b)', 'postgres' ], + [ 'vacuumdb', '--analyze-only', '--table' => 'vactable(b)', 'postgres' ], qr/statement: ANALYZE public.vactable\(b\);/, 'vacuumdb --analyze-only with partial column list'); $node->command_checks_all( - [ 'vacuumdb', '--analyze', '--table', 'vacview', 'postgres' ], + [ 'vacuumdb', '--analyze', '--table' => 'vacview', 'postgres' ], 0, [qr/^.*vacuuming database "postgres"/], [qr/^WARNING.*cannot vacuum non-tables or special system tables/s], 'vacuumdb with view'); $node->command_fails( - [ 'vacuumdb', '--table', 'vactable', '--min-mxid-age', '0', 'postgres' ], + [ + 'vacuumdb', + '--table' => 'vactable', + '--min-mxid-age' => '0', + 'postgres' + ], 'vacuumdb --min-mxid-age with incorrect value'); $node->command_fails( - [ 'vacuumdb', '--table', 'vactable', '--min-xid-age', '0', 'postgres' ], + [ + 'vacuumdb', + '--table' => 'vactable', + '--min-xid-age' => '0', + 'postgres' + ], 'vacuumdb --min-xid-age with incorrect value'); $node->issues_sql_like( [ - 'vacuumdb', '--table', 'vactable', '--min-mxid-age', - '2147483000', 'postgres' + 'vacuumdb', + '--table' => 'vactable', + '--min-mxid-age' => '2147483000', + 'postgres' ], qr/GREATEST.*relminmxid.*2147483000/, 'vacuumdb --table --min-mxid-age'); $node->issues_sql_like( - [ 'vacuumdb', '--min-xid-age', '2147483001', 'postgres' ], + [ 'vacuumdb', '--min-xid-age' => '2147483001', 'postgres' ], qr/GREATEST.*relfrozenxid.*2147483001/, 'vacuumdb --table --min-xid-age'); $node->issues_sql_like( - [ 'vacuumdb', '--schema', '"Foo"', 'postgres' ], + [ 'vacuumdb', '--schema' => '"Foo"', 'postgres' ], qr/VACUUM \(SKIP_DATABASE_STATS\) "Foo".bar/, 'vacuumdb --schema'); $node->issues_sql_like( - [ 'vacuumdb', '--schema', '"Foo"', '--schema', '"Bar"', 'postgres' ], + [ 'vacuumdb', '--schema' => '"Foo"', '--schema' => '"Bar"', 'postgres' ], qr/VACUUM\ \(SKIP_DATABASE_STATS\)\ "Foo".bar .*VACUUM\ \(SKIP_DATABASE_STATS\)\ "Bar".baz /sx, 'vacuumdb multiple --schema switches'); $node->issues_sql_like( - [ 'vacuumdb', '--exclude-schema', '"Foo"', 'postgres' ], + [ 'vacuumdb', '--exclude-schema' => '"Foo"', 'postgres' ], qr/^(?!.*VACUUM \(SKIP_DATABASE_STATS\) "Foo".bar).*$/s, 'vacuumdb --exclude-schema'); $node->issues_sql_like( [ - 'vacuumdb', '--exclude-schema', '"Foo"', '--exclude-schema', - '"Bar"', 'postgres' + 'vacuumdb', + '--exclude-schema' => '"Foo"', + '--exclude-schema' => '"Bar"', + 'postgres' ], qr/^(?!.*VACUUM\ \(SKIP_DATABASE_STATS\)\ "Foo".bar | VACUUM\ \(SKIP_DATABASE_STATS\)\ "Bar".baz).*$/sx, 'vacuumdb multiple --exclude-schema switches'); $node->command_fails_like( - [ 'vacuumdb', '-N', 'pg_catalog', '-t', 'pg_class', 'postgres', ], + [ + 'vacuumdb', + '--exclude-schema' => 'pg_catalog', + '--table' => 'pg_class', + 'postgres', + ], qr/cannot vacuum specific table\(s\) and exclude schema\(s\) at the same time/, - 'cannot use options -N and -t at the same time'); + 'cannot use options --excludes-chema and ---table at the same time'); $node->command_fails_like( - [ 'vacuumdb', '-n', 'pg_catalog', '-t', 'pg_class', 'postgres' ], + [ + 'vacuumdb', + '--schema' => 'pg_catalog', + '--table' => 'pg_class', + 'postgres' + ], qr/cannot vacuum all tables in schema\(s\) and specific table\(s\) at the same time/, - 'cannot use options -n and -t at the same time'); + 'cannot use options --schema and ---table at the same time'); $node->command_fails_like( - [ 'vacuumdb', '-n', 'pg_catalog', '-N', '"Foo"', 'postgres' ], + [ + 'vacuumdb', + '--schema' => 'pg_catalog', + '--exclude-schema' => '"Foo"', + 'postgres' + ], qr/cannot vacuum all tables in schema\(s\) and exclude schema\(s\) at the same time/, - 'cannot use options -n and -N at the same time'); + 'cannot use options --schema and --exclude-schema at the same time'); $node->issues_sql_like( - [ 'vacuumdb', '-a', '-N', 'pg_catalog' ], + [ 'vacuumdb', '--all', '--exclude-schema' => 'pg_catalog' ], qr/(?:(?!VACUUM \(SKIP_DATABASE_STATS\) pg_catalog.pg_class).)*/, - 'vacuumdb -a -N'); + 'vacuumdb --all --exclude-schema'); $node->issues_sql_like( - [ 'vacuumdb', '-a', '-n', 'pg_catalog' ], + [ 'vacuumdb', '--all', '--schema' => 'pg_catalog' ], qr/VACUUM \(SKIP_DATABASE_STATS\) pg_catalog.pg_class/, - 'vacuumdb -a -n'); + 'vacuumdb --all ---schema'); $node->issues_sql_like( - [ 'vacuumdb', '-a', '-t', 'pg_class' ], + [ 'vacuumdb', '--all', '--table' => 'pg_class' ], qr/VACUUM \(SKIP_DATABASE_STATS\) pg_catalog.pg_class/, - 'vacuumdb -a -t'); + 'vacuumdb --all --table'); $node->command_fails_like( - [ 'vacuumdb', '-a', '-d', 'postgres' ], + [ 'vacuumdb', '--all', '-d' => 'postgres' ], qr/cannot vacuum all databases and a specific one at the same time/, - 'cannot use options -a and -d at the same time'); + 'cannot use options --all and --dbname at the same time'); $node->command_fails_like( - [ 'vacuumdb', '-a', 'postgres' ], + [ 'vacuumdb', '--all', 'postgres' ], qr/cannot vacuum all databases and a specific one at the same time/, - 'cannot use option -a and a dbname as argument at the same time'); + 'cannot use option --all and a dbname as argument at the same time'); done_testing(); diff --git a/src/bin/scripts/t/101_vacuumdb_all.pl b/src/bin/scripts/t/101_vacuumdb_all.pl index cfdf00c323c..74cb22dc341 100644 --- a/src/bin/scripts/t/101_vacuumdb_all.pl +++ b/src/bin/scripts/t/101_vacuumdb_all.pl @@ -12,7 +12,7 @@ $node->init; $node->start; $node->issues_sql_like( - [ 'vacuumdb', '-a' ], + [ 'vacuumdb', '--all' ], qr/statement: VACUUM.*statement: VACUUM/s, 'vacuum all databases'); @@ -21,13 +21,13 @@ $node->safe_psql( CREATE DATABASE regression_invalid; UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid'; )); -$node->command_ok([ 'vacuumdb', '-a' ], +$node->command_ok([ 'vacuumdb', '--all' ], 'invalid database not targeted by vacuumdb -a'); # Doesn't quite belong here, but don't want to waste time by creating an # invalid database in 010_vacuumdb.pl as well. $node->command_fails_like( - [ 'vacuumdb', '-d', 'regression_invalid' ], + [ 'vacuumdb', '--dbname' => 'regression_invalid' ], qr/FATAL: cannot connect to invalid database "regression_invalid"/, 'vacuumdb cannot target invalid database'); |