DROP TABLE of table marked as dumpable in extension

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: DROP TABLE of table marked as dumpable in extension
Date: 2026-07-19 04:48:05
Message-ID: CAOBaU_YZYq=gGhuN34+U4WRjjabauVT9akqpeeRi+dEgLZk0-g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While working on changing the pg_stat_lock.wait_time datatype in powa after
commit c776550e466, I ran some tests to check the database state after the powa
extension is updated and found an unexpected difference.

If an extension marks a table as needing to be dumped with
pg_extension_config_dump() and then drops that table, the dropped table oid
will stay in pg_extension.extconfig. It seems problematic as obviously that
oid could eventually be reused for any unrelated relation, which could lead to
wrong behavior in pg_dump.

The documentation says:

> The only way to mark a table as no longer a configuration table is to
> dissociate it from the extension with ALTER EXTENSION ... DROP TABLE.

However I think that here it means an existing table, and dropping a table in
the extension script should do the same cleanup automatically.

Before spending too much time on that, is it a bug that should be fixed or
should the documentation be updated to say that if your extension drops a table
it needs to do an ALTER EXTENSION ... DROP TABLE or similar first?

AS a simple reproducer I attach a diff to show the problem in test_pg_dump
extension, with a new 1.1 version that drops and recreate the exact same table
and a then checks that all relations referenced in extconfig do exist.

Attachment Content-Type Size
extension_drop_table_leak.diff text/x-patch 2.8 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2026-07-19 05:11:19 Re: Row pattern recognition
Previous Message JoongHyuk Shin 2026-07-19 04:38:10 Re: [PATCH] Don't call ereport(ERROR) from recovery target GUC assign hooks