Re: BUG #18016: REINDEX TABLE failure

Gurjeet Singh <gurjeet@singh.im>

From: Gurjeet Singh <gurjeet@singh.im>
To: Tom Lane <tgl@sss.pgh.pa.us>, Postgres Hackers <pgsql-hackers@postgresql.org>
Cc: Michael Paquier <michael@paquier.xyz>, richard.vesely@softea.sk, pgsql-bugs@lists.postgresql.org
Date: 2023-07-10T16:35:05Z
Lists: pgsql-bugs, pgsql-hackers

Attachments

On Sun, Jul 9, 2023 at 7:18 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Michael Paquier <michael@paquier.xyz> writes:
> > That should be OK, I assume.  However, if this is improved and
> > something we want to support in the long-run I guess that a TAP test
> > may be appropriate.
>
> I do not see the point of a TAP test.  It's not like the code isn't
> covered perfectly well.

Please find attached the patch that makes REINDEX TABLE perform
reindex on toast table before reindexing the main table's indexes.

The code block movement involved slightly more thought and care than I
had previously imagined. As explained in comments in the patch, the
enumeration and suppression of indexes on the main table must happen
before any CommandCounterIncrement() call, hence the
reindex-the-toast-table-if-any code had to be placed after that
enumeration.

In support of the argument above, the patch does not include any TAP
tests. Reliably reproducing the original error message involves
restarting the database, and since that can't be done via SQL
commands, no sql tests are included, either.

The patch also includes minor wordsmithing, and benign whitespace
changes in neighboring code.

Best regards,
Gurjeet
http://Gurje.et

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Reindex toast before its main relation in reindex_relation()

  2. Fix comment in index.c

  3. Clean up a bug in sql/json items commit 66ea94e8e6

  4. Create a "relation mapping" infrastructure to support changing the relfilenodes