2

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 Feb 6, 2024 at 8:49

1 Answer 1

0

At one point, a very long time ago, I think it was necessary to do things this way.

Continuing to include that code could be called defensive programming, or just cargo cult.

answered Feb 6, 2024 at 18:44

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.