ALTER EXTENSION .. ADD/DROP weirdness

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: pgsql-hackers@postgresql.org
Date: 2011-10-10T14:01:51Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Rethink behavior of CREATE OR REPLACE during CREATE EXTENSION.

OK, I'm stumped:

rhaas=# create extension pg_stat_statements;
CREATE EXTENSION
rhaas=# drop view pg_stat_statements;
ERROR:  cannot drop view pg_stat_statements because extension
pg_stat_statements requires it
HINT:  You can drop extension pg_stat_statements instead.
rhaas=# alter extension pg_stat_statements drop view pg_stat_statements;
ALTER EXTENSION
rhaas=# drop view pg_stat_statements;
ERROR:  cannot drop view pg_stat_statements because other objects depend on it
DETAIL:  extension pg_stat_statements depends on view pg_stat_statements
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

At the very last, the error message is totally confusing, because the
point is that I just removed that object from the extension, and I'm
being told that I can't remove it because it's part of the extension.
A little snooping around with \dx+ reveals a possible cause: the view
itself has been removed from the extension, but the associated types
are still connected to it:

rhaas=# \dx+ pg_stat_statements
Objects in extension "pg_stat_statements"
         Object Description
-------------------------------------
 function pg_stat_statements()
 function pg_stat_statements_reset()
 type pg_stat_statements
 type pg_stat_statements[]
(4 rows)

OK, no problem, I'll just disconnect those, too:

rhaas=# alter extension pg_stat_statements drop type pg_stat_statements;
ALTER EXTENSION
rhaas=# alter extension pg_stat_statements drop type pg_stat_statements[];
ERROR:  syntax error at or near "["
LINE 1: ...extension pg_stat_statements drop type pg_stat_statements[];
                                                                    ^

Hmm.  So just how do I do this?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company