Sample Header Ad - 728x90

Use case of ALTER EXTENSION ADD/DROP in upgrade script of extensions

2 votes
1 answer
238 views
I am recently looking at the pg_stat_statements upgrade script and found out these set of commands here
/* First we have to remove them from the extension */
ALTER EXTENSION pg_stat_statements DROP VIEW pg_stat_statements;
ALTER EXTENSION pg_stat_statements DROP FUNCTION pg_stat_statements(boolean);

/* Then we can drop them */
DROP VIEW pg_stat_statements;
DROP FUNCTION pg_stat_statements(boolean);
I didn't understand the use case of ALTER EXTENSION ADD/DROP here as even after removing those lines the extension is working fine. Can someone explain why do we need those commands if there is no strict requirement? Here is what I found from sql-alterextension.html > DROP member_object This form removes a member object from the extension. This is mainly useful in extension update scripts. The object is not dropped, only disassociated from the extension. I understand that it is disassociating the object from extension but again what's the need if we are going to drop it anyway?
Asked by Ayush Vatsa (55 rep)
Feb 6, 2024, 08:49 AM
Last activity: Jun 8, 2025, 04:05 AM