Drop extension doesn't drop the ag_catalog schema
Describe the bug
When the extension is uninstalled, the ag_catalog schema remains.
How are you accessing AGE (Command line, driver, etc.)?
Command line.
What data setup do we need to do?
create extension age;
What is the necessary configuration info needed?
Default installation using Debian packages from PGDG repositories.
What is the command that caused the error?
test=# drop extension age;
DROP EXTENSION
test=# \dn ag_catalog
List of schemas
Name | Owner
------------+----------
ag_catalog | postgres
(1 row)
Expected behavior
The ag_catalog schema should be removed by the drop extension command directly instead of manually run drop schema:
test=# drop schema ag_catalog;
DROP SCHEMA
test=# \dn ag_catalog
List of schemas
Name | Owner
------+-------
(0 rows)
Environment (please complete the following information):
- Version: 1.5.0
- PostgreSQL version: 14.11
- Debian 11
I confirm that dropping the extension does not drop the ag_catalog schema. Whatever that is causing this problem is actually causing a much bigger problem for my entire Postgres instance. After the AGE was used once, it seems to leave a permanent dependency somewhere that's causing me to unable to delete any schemas.
The steps to recreate the problem in psql
create extension age;
drop extension age;
create database test;
\c test
drop schema public;
The drop schema public statement will fail with
ERROR: schema "ag_catalog" does not exist
basically your error comes up when PostgreSQL is trying to access a schema that does not exist in your current database. try double-checking the schema name in your query, or your schema is missing, and ensure that you've got the necessary permissions required to access the schema.
If you are encountering the issue where the ag_catalog schema remains even after uninstalling the AGE extension (age), You can fix it by manually dropping thw ag_catalog schema. Below is how you can fix it: // -- Uninstall AGE extension DROP EXTENSION IF EXISTS age CASCADE;
// -- Drop ag_catalog schema DROP SCHEMA IF EXISTS ag_catalog CASCADE;
Manually drop the "ag_catalog" schema using the drop schema ag_catalog; command after uninstalling the extension. This bug disrupts the expected behavior of the extension uninstallation process and requires extra steps for cleanup. It would be ideal to have the extension removal process also remove any associated schemas automatically to streamline the uninstallation process.
@jriouovh I will try to look into why this is happening. As others have mentioned, for now, the workaround is to manually drop it.
I believe it is normal for Postgres to NOT drop any schemas when dropping extensions; Schemas are not part of an extension's dependency.
https://github.com/2ndQuadrant/pglogical/issues/189#issuecomment-825887246
@jriouovh After looking into this, it does appear that schema for an extension is not dropped due to PostgreSQL. Please see the link above provided by @mingfang. As this appears to be out of the scope of an extension itself, you will need to drop the schema yourself, if desired. Hopefully, this is helpful.
Hello folks,
Indeed, as the schema is defined in the control file, PostgreSQL will not remove the schema with the extension because it may hold data and not only schema objects. So, this is not a bug.
We need to drop the schema manually when dropping the extension.
Thank you all! I'm closing this issue.
Awesome, thanks for the update!
On Tue, Apr 9, 2024 at 9:41 AM Julien Riou @.***> wrote:
Closed #1626 https://github.com/apache/age/issues/1626 as completed.
— Reply to this email directly, view it on GitHub https://github.com/apache/age/issues/1626#event-12401884423, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFO2YCBGKB4QE64M7FEGLTTY4OETNAVCNFSM6AAAAABDQ3HMSKVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSGQYDCOBYGQ2DEMY . You are receiving this because you commented.Message ID: @.***>