SQLSTATE 03000 with condition name sql_statement_not_yet_complete is an informational status code in PostgreSQL, not a true error. It belongs to SQLSTATE class 03 ("SQL Statement Not Yet Complete") and indicates that an SQL statement has been initiated but has not finished executing yet. You are unlikely to encounter this as a runtime error in application logs; it is defined in the SQL standard primarily for use by SQL procedure language implementations.
What This Error Means
SQLSTATE class 03 is defined by the ISO/IEC 9075 SQL standard and covers the case where an SQL statement is still in the process of executing when a status check is performed. The single condition in this class, sql_statement_not_yet_complete (SQLSTATE 03000), is an informational return code rather than an exception condition.
In PostgreSQL's internal error classification, this code sits alongside warning codes (class 01) and the generic success code (00000). It is not in the error range and does not cause a transaction to abort or a connection to enter an error state.
In practice, PostgreSQL itself rarely — if ever — surfaces this SQLSTATE to application code during normal query execution. The code appears primarily in the context of embedded SQL (ECPG), the libpq C library, or certain JDBC/ODBC driver implementations that follow the SQL standard status-checking model. If you do see it, it means that at the moment a diagnostic area was interrogated, the statement had not yet produced a final status.
Common Causes
Embedded SQL (ECPG) diagnostic area checks — In C programs using PostgreSQL's ECPG preprocessor, a
GET DIAGNOSTICSorWHENEVERstatement evaluated before the previous SQL statement completed may return SQLSTATE03000. This is inherent to the synchronous statement execution model in ECPG and usually self-resolves.Driver or middleware status polling — Some JDBC, ODBC, or proprietary database middleware implementations poll the server status mid-execution and may temporarily receive
03000before the final result is available. This is transient and not indicative of a problem.Explicit SQLSTATE checking in PL/pgSQL or PL/SQL ports — If you are migrating code from Oracle or DB2 that explicitly checks for SQLSTATE
03000as a signal that a cursor or statement is still open/running, you may see this code referenced in ported code. PostgreSQL's PL/pgSQL does not raise this condition during normal cursor operations.
How to Fix sql_statement_not_yet_complete
Because 03000 is informational rather than an error, there is generally nothing to "fix." The appropriate response depends on the context:
In application code receiving this SQLSTATE unexpectedly — Check whether your driver or ORM is misclassifying the code as an error. The correct behavior is to treat SQLSTATE
03000as a non-terminal, informational status and continue waiting for the final result or next notification from the server.# Example: psycopg2 does not raise an exception for informational codes # If you see 03000 in exception handling, verify your exception filter try: cursor.execute("SELECT pg_sleep(5)") except psycopg2.DatabaseError as e: if e.pgcode == '03000': # This is informational, not a real error — log and continue passIn ECPG code — If your embedded SQL application triggers this status, ensure you are not interrogating the SQLSTATE diagnostic area before the statement has had a chance to complete. Use blocking execution calls rather than asynchronous status polling where possible.
/* ECPG: execute statement and only then check status */ EXEC SQL SELECT count(*) INTO :row_count FROM orders; /* SQLSTATE is now '00000' (success) or an actual error code, not '03000' */In ported Oracle/DB2 PL/SQL code — Remove or rewrite any logic that branches on SQLSTATE
03000, as PostgreSQL's PL/pgSQL uses different mechanisms (cursors,FOUND,ROW_COUNT) to communicate statement completion status.-- PostgreSQL: check cursor status with FOUND, not SQLSTATE 03000 FETCH my_cursor INTO my_record; IF NOT FOUND THEN -- cursor is exhausted END IF;
Additional Information
- SQLSTATE class
03contains only one condition:03000itself. There are no sibling sub-codes within this class. - This SQLSTATE originates in the ISO/IEC 9075-1 SQL standard and has been present since SQL-92. PostgreSQL has defined it in its SQLSTATE mapping since very early versions.
- Most high-level drivers (psycopg2, asyncpg, node-postgres, JDBC's PgJDBC) will never surface this code to application code because they use PostgreSQL's extended query protocol and receive complete responses before returning control to user code.
- There are no performance or transaction-isolation implications associated with this code. It does not indicate a lock wait, a long-running query, or any resource constraint.
- Related informational SQLSTATE class:
00000(successful completion),01000(general warning). Class03is distinct from warning and error classes.
Frequently Asked Questions
Is SQLSTATE 03000 an error I need to handle in my application?
No. 03000 is an informational status code, not an error condition. Applications built on standard PostgreSQL drivers do not need to handle it explicitly. If you encounter it in an exception handler, your driver may be incorrectly classifying non-error SQLSTATE codes — check the driver's documentation or upgrade to a current release.
Why does my log show sql_statement_not_yet_complete? PostgreSQL's own server logs do not emit this code during normal query processing. If you see it in a log, it is most likely being generated by a client-side driver, middleware layer, or an ECPG-based application, not by the PostgreSQL server itself.
Does SQLSTATE 03000 mean my query is hung or taking too long?
No. Despite the name "not yet complete," this code does not indicate a hung or slow query. It is a formal SQL standard status value for in-progress statement tracking, unrelated to query duration or lock waits. For long-running queries, check pg_stat_activity and use statement_timeout or lock_timeout settings instead.
How is this different from a warning (class 01) or a real error?
PostgreSQL SQLSTATE codes starting with 00 mean success, 01 mean a warning (statement completed with a non-fatal notice), 02 means no data found, 03 (this class) means in-progress, and codes starting with letters from 07 onward are actual errors. Class 03 never aborts a transaction or rolls back any work.