pgsql: Avoid duplicates in ALTER ... DEPENDS ON EXTENSION

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid duplicates in ALTER ... DEPENDS ON EXTENSION
Date: 2020-03-11 14:06:42
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid duplicates in ALTER ... DEPENDS ON EXTENSION

If the command is attempted for an extension that the object already
depends on, silently do nothing.

In particular, this means that if a database containing multiple such
entries is dumped, the restore will silently do the right thing and
record just the first one. (At least, in a world where pg_dump does
dump such entries -- which it doesn't currently, but it will.)

Backpatch to 9.6, where this kind of dependency was introduced.

Reviewed-by: Ibrar Ahmed, Tom Lane (offlist)
Discussion: https://postgr.es/m/[email protected]

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b7739ebecdcc157be2fee348912ae3197383895f

Modified Files
--------------
src/backend/catalog/pg_depend.c | 43 ++++++++++++++++++++++
src/backend/commands/alter.c | 7 +++-
src/include/catalog/dependency.h | 1 +
.../test_extensions/expected/test_extdepend.out | 2 +
.../modules/test_extensions/sql/test_extdepend.sql | 2 +
5 files changed, 54 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2020-03-11 14:13:59 Re: pgsql: Avoid duplicates in ALTER ... DEPENDS ON EXTENSION
Previous Message Peter Eisentraut 2020-03-11 13:00:36 pgsql: Clean up order in miscinit.c a bit