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
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?