summaryrefslogtreecommitdiff
path: root/src/bin/scripts
diff options
context:
space:
mode:
authorMichael Paquier2022-07-19 02:45:06 +0000
committerMichael Paquier2022-07-19 02:45:06 +0000
commit2cbc3c17a5c11d13c0ac92fe7557c56408f8f3d0 (patch)
tree835b1a5f656c1bb7ec6439e9ef66532b1f1670e8 /src/bin/scripts
parent5fb5b6c4c176d873bd8405ec40f7002daf242a36 (diff)
Rework logic and simplify syntax of REINDEX DATABASE/SYSTEM
Per discussion, this commit includes a couple of changes to these two flavors of REINDEX: * The grammar is changed to make the name of the object optional, hence one can rebuild all the indexes of the wanted area by specifying only "REINDEX DATABASE;" or "REINDEX SYSTEM;". Previously, the object name was mandatory and had to match the name of the database on which the command is issued. * REINDEX DATABASE is changed to ignore catalogs, making this task only possible with REINDEX SYSTEM. This is a historical change, but there was no way to work only on the indexes of a database without touching the catalogs. We have discussed more approaches here, like the addition of an option to skip the catalogs without changing the original behavior, but concluded that what we have here is for the best. This builds on top of the TAP tests introduced in 5fb5b6c, showing the change in behavior for REINDEX SYSTEM. reindexdb is updated so as we do not issue an extra REINDEX SYSTEM when working on a database in the non-concurrent case, something that was confusing when --concurrently got introduced, so this simplifies the code. Author: Simon Riggs Reviewed-by: Ashutosh Bapat, Bernd Helmle, Álvaro Herrera, Cary Huang, Michael Paquier Discussion: https://postgr.es/m/CANbhV-H=NH6Om4-X6cRjDWfH_Mu1usqwkuYVp-hwdB_PSHWRfg@mail.gmail.com
Diffstat (limited to 'src/bin/scripts')
-rw-r--r--src/bin/scripts/reindexdb.c12
-rw-r--r--src/bin/scripts/t/090_reindexdb.pl18
2 files changed, 4 insertions, 26 deletions
diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c
index f3b03ec325..0e93a4eeff 100644
--- a/src/bin/scripts/reindexdb.c
+++ b/src/bin/scripts/reindexdb.c
@@ -360,18 +360,6 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
{
case REINDEX_DATABASE:
- /*
- * Database-wide parallel reindex requires special processing.
- * If multiple jobs were asked, we have to reindex system
- * catalogs first as they cannot be processed in parallel.
- */
- if (concurrently)
- pg_log_warning("cannot reindex system catalogs concurrently, skipping all");
- else
- run_reindex_command(conn, REINDEX_SYSTEM, PQdb(conn), echo,
- verbose, concurrently, false,
- tablespace);
-
/* Build a list of relations from the database */
process_list = get_parallel_object_list(conn, process_type,
user_list, echo);
diff --git a/src/bin/scripts/t/090_reindexdb.pl b/src/bin/scripts/t/090_reindexdb.pl
index 41af8554cd..864707ff92 100644
--- a/src/bin/scripts/t/090_reindexdb.pl
+++ b/src/bin/scripts/t/090_reindexdb.pl
@@ -83,8 +83,8 @@ $node->issues_sql_like(
'SQL REINDEX run');
my $relnode_info = $node->safe_psql('postgres', $compare_relfilenodes);
is( $relnode_info,
- qq(pg_constraint|pg_constraint_oid_index|relfilenode has changed
-pg_constraint|pg_toast.pg_toast_<oid>_index|relfilenode has changed
+ qq(pg_constraint|pg_constraint_oid_index|relfilenode is unchanged
+pg_constraint|pg_toast.pg_toast_<oid>_index|relfilenode is unchanged
test1|pg_toast.pg_toast_<oid>_index|relfilenode has changed
test1|test1x|relfilenode has changed),
'relfilenode change after REINDEX DATABASE');
@@ -235,11 +235,6 @@ $node->command_fails(
$node->command_fails(
[ 'reindexdb', '-j', '2', '-i', 'i1', 'postgres' ],
'parallel reindexdb cannot process indexes');
-$node->issues_sql_like(
- [ 'reindexdb', '-j', '2', 'postgres' ],
- qr/statement:\ REINDEX SYSTEM postgres;
-.*statement:\ REINDEX TABLE public\.test1/s,
- 'parallel reindexdb for database issues REINDEX SYSTEM first');
# 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(
@@ -249,13 +244,8 @@ $node->issues_sql_like(
$node->command_ok(
[ 'reindexdb', '-j', '2', '-S', 's3' ],
'parallel reindexdb with empty schema');
-$node->command_checks_all(
+$node->command_ok(
[ 'reindexdb', '-j', '2', '--concurrently', '-d', 'postgres' ],
- 0,
- [qr/^$/],
- [
- qr/^reindexdb: warning: cannot reindex system catalogs concurrently, skipping all/s
- ],
- 'parallel reindexdb for system with --concurrently skips catalogs');
+ 'parallel reindexdb on database, concurrently');
done_testing();