PostgreSQL SQLSTATE 0F000 maps to the condition name locator_exception. This is a class-level error code representing the SQL standard "Locator Exception" error class. In practice, you are unlikely to encounter this error in day-to-day PostgreSQL usage; it surfaces primarily in SQL standard compliance scenarios, certain JDBC driver interactions, or when applications explicitly reference SQL locator semantics defined in the SQL/CLI and SQL/OLB standards.
What This Error Means
SQLSTATE codes are grouped into classes using the first two characters. Class 0F is defined by the SQL standard as the "Locator Exception" class. A locator in SQL standard terminology is a handle or reference to a large object (LOB) — such as a BLOB or CLOB — that lives server-side and is referenced by a client-side token rather than transmitted in full.
PostgreSQL does not implement the SQL standard locator mechanism. Its large object support uses a different model: pg_largeobject with OID-based access via functions like lo_open, lo_read, and lo_write, rather than the locator construct defined in SQL/CLI. As a result, PostgreSQL rarely raises any error in class 0F during normal operation.
The one child code defined within this class is 0F001 (invalid_locator_specification), which would be raised if an application presented an invalid or expired locator handle. Because PostgreSQL does not use the locator mechanism natively, even 0F001 is effectively unreachable through standard SQL or PL/pgSQL. When 0F000 appears, it almost always originates from a JDBC driver, an ORM abstraction layer, or a middleware component that is itself raising a synthetic SQL state to signal a protocol or handle error.
Common Causes
JDBC or driver-level locator handling: Some JDBC drivers map internal LOB handle errors to SQLSTATE
0F000when aBloborClobobject becomes invalid after the originating transaction has closed or the result set has been consumed.SQL standard compliance testing tools: Conformance test suites (e.g., those validating SQL/CLI compliance) explicitly probe for class
0Ferror handling and may trigger or expect this state.Third-party middleware generating synthetic states: Connection pools, proxies, or middleware layers that translate their own internal error conditions to SQL states occasionally emit
0F000when they cannot map an error more precisely.PL/pgSQL exception blocks catching all states: Code that uses a broad
WHEN OTHERS THENor inspectsSQLSTATEdynamically might encounter this value if it is propagated from an external source.
How to Fix locator_exception
Trace the actual origin of the error. Because PostgreSQL does not raise this internally, start by identifying which layer is generating it. Check whether the exception originates in application code, a JDBC
Blob/Clobcall, or a connection pool:-- In psql, enable verbose error reporting to see more detail \set VERBOSITY verboseIn application logs, look for the stack trace above the SQLSTATE — the frame that constructs or throws the exception will identify the real source.
Fix JDBC LOB usage patterns. If the error comes from a JDBC
BloborClobobject being accessed after theResultSetorConnectionis closed, restructure your code to read LOB data while the result set is still open:// Read the Blob data before closing the ResultSet ResultSet rs = stmt.executeQuery("SELECT data FROM documents WHERE id = ?"); if (rs.next()) { Blob blob = rs.getBlob("data"); byte[] bytes = blob.getBytes(1, (int) blob.length()); // read before close blob.free(); } rs.close();Use PostgreSQL's native large object API instead of SQL/CLI locators. If your application relies on SQL standard locator semantics for large object work, consider switching to PostgreSQL's
lo_*functions or thebyteatype for objects that fit in memory:-- Store large data using bytea (for moderate sizes) CREATE TABLE documents (id serial PRIMARY KEY, data bytea); -- Or use the large object API for streaming access SELECT lo_create(0); -- returns a new OIDUpdate your JDBC driver. Older PostgreSQL JDBC driver versions have known issues with LOB handling. Ensure you are on a recent release of
org.postgresql:postgresql.
Additional Information
- SQLSTATE class
0Fis defined in the SQL:1999 standard and carried forward in subsequent revisions. PostgreSQL includes the class in its error code table for completeness and standard compliance, but does not raise it through any built-in server-side path. - The only child code in class
0Fis0F001(invalid_locator_specification). PostgreSQL defines this code but no server-side condition raises it. - If you catch this error in a PL/pgSQL
EXCEPTIONblock, it almost certainly means the state was set by a client library or injected viaRAISE SQLSTATE '0F000'in custom code. - PostgreSQL's large object subsystem uses OID references internally; these are not SQL/CLI locators and do not participate in the
0Fclass error semantics. - Related SQLSTATE classes for large object and data handling errors include class
22(data exception) and class58(system error / external error).
Frequently Asked Questions
Why does PostgreSQL even define SQLSTATE 0F000 if it never raises it? PostgreSQL maintains a complete SQLSTATE table aligned with the SQL standard so that drivers, tools, and client code have a consistent set of symbolic names and values. Defining a code does not mean the server raises it — it ensures the code is available if custom code or a wrapper layer needs to use it.
Can I raise SQLSTATE 0F000 manually in PL/pgSQL?
Yes. You can use RAISE SQLSTATE '0F000' in a PL/pgSQL function to emit this state explicitly. This is occasionally useful when building middleware or stored procedure wrappers that need to signal a locator-related condition to a calling application that inspects SQLSTATE.
DO $$
BEGIN
RAISE SQLSTATE '0F000' USING MESSAGE = 'locator is no longer valid';
END;
$$;
Is SQLSTATE 0F000 the same as a large object error in PostgreSQL?
No. PostgreSQL large object errors (from lo_open, lo_read, etc.) map to other SQLSTATE classes, typically class 58 (system error) or class 42 (syntax/access errors). Class 0F is specifically the SQL standard locator mechanism, which PostgreSQL does not implement natively.
What should I do if my monitoring tool alerts on SQLSTATE 0F000? Identify the source: it is not coming from the PostgreSQL server itself. Check your JDBC driver version, any ORM framework LOB handling, and any middleware that sits between your application and the database. The server-side PostgreSQL logs will not contain this error because the server is not raising it.