DROP TABLE of table marked as dumpable in extension - Mailing list pgsql-hackers

From Julien Rouhaud
Subject DROP TABLE of table marked as dumpable in extension
Date
Msg-id CAOBaU_YZYq=gGhuN34+U4WRjjabauVT9akqpeeRi+dEgLZk0-g@mail.gmail.com
Whole thread
List 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

pgsql-hackers by date:

Previous
From: JoongHyuk Shin
Date:
Subject: Re: [PATCH] Don't call ereport(ERROR) from recovery target GUC assign hooks
Next
From: Tatsuo Ishii
Date:
Subject: Re: Row pattern recognition