// PostgreSQL error reference

PostgreSQL 0A000: feature not supported

The statement asks for something PostgreSQL doesn't support in that form, such as a cross-database reference or an unsupported combination of options.

SQLSTATE
0A000
Name
feature_not_supported
Category
Feature Not Supported
Error message
cross-database references are not implemented: "otherdb.public.orders"

What it means

0A000 is a catch-all for valid-looking SQL that PostgreSQL doesn't implement. The message says what isn't supported. Common ones are a three-part name referring to another database, FOR UPDATE combined with GROUP BY, DISTINCT or aggregates (FOR UPDATE is not allowed with aggregate functions), and altering a column type used by a view or rule.

The fix is to express the same thing another way; there is no setting that enables the feature.

Common causes

  • A name like otherdb.public.orders: each connection can only see its own database.
  • Row locking (FOR UPDATE) on a query with GROUP BY, DISTINCT, aggregates or window functions.
  • ALTER TABLE ... ALTER COLUMN TYPE on a column a view depends on.
  • Syntax from another database or a newer PostgreSQL version than the server.

How to fix it

  1. For cross-database queries, use the postgres_fdw extension (or dblink), or keep the data in schemas of one database.

    CREATE EXTENSION postgres_fdw;
    CREATE SERVER otherdb FOREIGN DATA WRAPPER postgres_fdw OPTIONS (dbname 'otherdb');
    CREATE USER MAPPING FOR CURRENT_USER SERVER otherdb OPTIONS (user 'app', password 'secret');
    IMPORT FOREIGN SCHEMA public LIMIT TO (orders) FROM SERVER otherdb INTO public;
  2. Lock rows in a subquery, then aggregate outside it.

    SELECT customer_id, count(*)
    FROM (SELECT * FROM orders WHERE status = 'new' FOR UPDATE) o
    GROUP BY customer_id;
  3. To change the type of a column a view uses, drop the view, alter the column, and recreate the view, in one transaction.

Reproduce it safely

SELECT * FROM otherdb.public.t;  -- ERROR: cross-database references are not implemented

Related errors

The code and message text are from the PostgreSQL documentation, Appendix A: PostgreSQL Error Codes. Browse the full PostgreSQL error list or search every database error.

// fewer errors, faster fixes

Work on PostgreSQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for PostgreSQL and the other databases you use.