Diagnostic Queries
Symptoms
A statement referenced a data type, domain, enum, or composite type that does not exist in any schema on the search_path. PostgreSQL raises SQLSTATE 42704 (undefined_object) while parsing the type name.
- Common in
CREATE TABLE,CAST(… AS …), or function signatures. - The caret points at the unknown type name.
- Frequently caused by a missing extension or a type defined in another schema.
What the server log shows
ERROR: type "citext" does not exist
LINE 1: CREATE TABLE t (email citext);
^
Why PostgreSQL raises this — what the manual says
As the CREATE TYPE reference (Description) explains:
A statement referenced a data type, domain, or enum that is not defined in the current search path; the type must be created (or schema-qualified) before it can be used in a column definition or cast.
Type names resolve through pg_type using the same search_path rules as relations. If the type lives in an unlisted schema, was never created, or is supplied by an extension that is not installed, resolution fails with 42704.
Common causes
- An extension type (
citext,hstore,uuidhelpers,vector) whose extension is not installed. - A custom type/enum/domain created in a schema not on the search_path.
- A typo or wrong case in the type name.
- Restoring a dump before its extensions/types were created.
How to fix it
- Install the extension that provides the type:
CREATE EXTENSION IF NOT EXISTS citext;. - Schema-qualify the type (
app.status_enum) or add its schema tosearch_path. - Create the missing type/enum/domain before the object that uses it.
- Check spelling and case against
\dTin psql.
Diagnostic query
-- Find every schema that defines a type by this name
SELECT n.nspname AS schema, t.typname, t.typtype
FROM pg_type t JOIN pg_namespace n ON n.oid = t.typnamespace
WHERE t.typname = 'citext';
typtype: b=base, c=composite, d=domain, e=enum, r=range.
Related & next steps
Reference: PostgreSQL 18 — CREATE TYPE.
Thanks — noted. This helps keep the database accurate.