Skip to content

39000 — external_routine_invocation_exception

Source-backed reference for PostgreSQL SQLSTATE 39000.

39000

At a glance

Fixed PostgreSQL 18.6 paths in contrib/pgcrypto report this ERROR for cryptographic library failures and invalid input lengths. The category can also carry other external routine invocation errors, so the exact library function and dynamic error text matter.

Field Value
SQLSTATE 39000
Condition external_routine_invocation_exception
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION
Aliases

Meaning

Representative messages are crypt(3) returned NULL, encrypt error: %s, decrypt error: %s, encrypt_iv error: %s, decrypt_iv error: %s, and Length not in range. Several primary messages interpolate the dynamic library text returned by px_strerror(err); it is part of the primary message, not a separate DETAIL field.

Messages

Representative messages include crypt(3) returned NULL, encrypt error: %s, decrypt error: %s, encrypt_iv error: %s, decrypt_iv error: %s, and Length not in range. Several variants put the dynamic library text from px_strerror(err) directly in the primary message; it is not a separate DETAIL field.

Diagnosis

Identify the pgcrypto function and operation (crypt, encrypt/decrypt, IV form, or length validation). Preserve the dynamic error string and check input lengths, key/IV parameters, and library boundary; do not merge a library error with a SQLSTATE from a remote routine.

Response

Correct the named input or library/configuration problem and validate the same pgcrypto operation. Retry only when the operation is safe and no externally visible work was completed; a failed encryption call does not justify replaying a surrounding write.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

39001, 2F000

Sources

Read the fixed pgcrypto.c, pgp-cfb.c, and px.c paths alongside the structured evidence record.