Re: Add --tablespace option to reindexdb

Mark Dilger <mark.dilger@enterprisedb.com>

From: Mark Dilger <mark.dilger@enterprisedb.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-03-01T18:12:54Z
Lists: pgsql-hackers

> On Feb 25, 2021, at 10:49 PM, Michael Paquier <michael@paquier.xyz> wrote:
> 
> Anyway, I would rather group the whole set of
> tests together, and using the --tablespace option introduced here
> within a TAP test does the job.

Your check verifies that reindexing a system table on a new tablespace fails, but does not verify what the failure was.  I wonder if you might want to make it more robust, something like:

diff --git a/src/bin/scripts/t/090_reindexdb.pl b/src/bin/scripts/t/090_reindexdb.pl
index 6946268209..8453acc817 100644
--- a/src/bin/scripts/t/090_reindexdb.pl
+++ b/src/bin/scripts/t/090_reindexdb.pl
@@ -3,7 +3,7 @@ use warnings;
 
 use PostgresNode;
 use TestLib;
-use Test::More tests => 54;
+use Test::More tests => 58;
 
 program_help_ok('reindexdb');
 program_version_ok('reindexdb');
@@ -108,23 +108,35 @@ $node->issues_sql_like(
 # names, and CONCURRENTLY cannot be used in transaction blocks, preventing
 # the use of TRY/CATCH blocks in a custom function to filter error
 # messages.
-$node->command_fails(
+$node->command_checks_all(
        [ 'reindexdb', '-t', $toast_table, '--tablespace', $tbspace, 'postgres' ],
+       1,
+       [ ],
+       [ qr/cannot move system relation/ ],
        'reindex toast table with tablespace');
-$node->command_fails(
+$node->command_checks_all(
        [
                'reindexdb',    '--concurrently', '-t', $toast_table,
                '--tablespace', $tbspace,         'postgres'
        ],
+       1,
+       [ ],
+       [ qr/cannot move system relation/ ],
        'reindex toast table concurrently with tablespace');
-$node->command_fails(
+$node->command_checks_all(
        [ 'reindexdb', '-i', $toast_index, '--tablespace', $tbspace, 'postgres' ],
+       1,
+       [ ],
+       [ qr/cannot move system relation/ ],
        'reindex toast index with tablespace');
-$node->command_fails(
+$node->command_checks_all(
        [
                'reindexdb',    '--concurrently', '-i', $toast_index,
                '--tablespace', $tbspace,         'postgres'
        ],
+       1,
+       [ ],
+       [ qr/cannot move system relation/ ],
        'reindex toast index concurrently with tablespace');
 
 # connection strings


—
Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company






Commits

  1. Add --tablespace option to reindexdb

  2. Fix duplicated test case in TAP tests of reindexdb