Diagnostic Queries
Symptoms
A statement referenced an extension that is not installed in the current database. PostgreSQL raises SQLSTATE 42704 (undefined_object).
- The named extension isn’t installed here.
- Common in
ALTER EXTENSION/DROP EXTENSION. - Extensions are per-database.
What the server log shows
ERROR: extension "pg_trgm" does not exist
Why PostgreSQL raises this — what the manual says
the DROP EXTENSION reference (Description):
“DROP EXTENSION removes extensions from the database.”
Extensions are installed per database via CREATE EXTENSION. Referencing one that was never installed (or installed in a different database) cannot be resolved, so PostgreSQL reports 42704.
Common causes
- The extension was never installed in this database.
- A typo in the extension name.
- Connected to the wrong database.
How to fix it
- Install it:
CREATE EXTENSION pg_trgm;(if the contrib package is present). - List installed extensions:
\dxor querypg_extension. - Use
DROP EXTENSION IF EXISTSfor idempotency; verify the database.
Related & next steps
Reference: PostgreSQL 18 — DROP EXTENSION.
Thanks — noted. This helps keep the database accurate.