select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQLSTATE / CLASS 42 · SYNTAX ERROR OR ACCESS RULE VIOLATION

indeterminate_datatype

SQLSTATE
42P18
Condition name
indeterminate_datatype
Class
Syntax Error or Access Rule Violation
Source macro
ERRCODE_INDETERMINATE_DATATYPE
Evidence
Source path confirmed
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

<h1>42P18 — Indeterminate datatype</h1>

At a glance

42P18 (indeterminate_datatype) Type inference fails when an expression or protocol parameter has no determinate type.

Meaning

The parser cannot assign a determinate type to an expression or protocol parameter. Core 18.6 explicitly reports empty ARRAY[], and pg_analyze_and_rewrite_varparams performs a final pass that rejects every parameter still InvalidOid or UNKNOWNOID, such as $1 with no constraining context. These are different from 42P08, where inputs imply incompatible types, and 42P02, where the parameter reference itself is missing.

Diagnosis

Use the exact location or parameter number in the response. For ARRAY[], inspect the surrounding expression and cast it to the intended element type; for $n, inspect the Parse/extended-query parameter types and every context that should constrain it, then confirm the final parameter-type pass can resolve the OID. A client that sends no type OID may leave this decision to the server. A conflicting deduction is 42P08; a reference to a parameter that was not declared is 42P02.

Response

Add an explicit, semantically correct cast or supply parameter type information, then verify operators and result columns still have the intended types. Do not silence the error by casting everything to text; that can change index use and function/operator selection. Retry the parse or statement only after the corrected definition is known. If the ERROR was raised inside an explicit transaction, ROLLBACK or ROLLBACK TO a pre-error savepoint before sending the corrected statement.

Messages

Representative source messages include: message: cannot determine type of empty array; HINT: Explicitly cast to the desired type, for example ARRAY[]::integer[].; message: could not determine data type of parameter $%d. Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

Source evidence

Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.

42P18 is the indeterminate_datatype condition in Class 42.

Method: Read fixed REL_18_6 errcodes.txt and locked facts.

Limits: Identity does not enumerate all source branches or client failures.

src.errcodes.42P18.18.6

Core 18.6 reports empty ARRAY[] and, in pg_analyze_and_rewrite_varparams, rejects every parameter left InvalidOid or UNKNOWNOID after parse analysis, such as $1 with no constraining context. This is distinct from 42P08 conflicting deductions and 42P02 missing parameter references.

Method: Read selected resolved REL_18_6 report groups and message roles.

Limits: Representative confirmed core paths only; not exhaustive historical or extension coverage.

src.call.42P18.24454306029f6c5a510a8800 src.call.42P18.8fe85a04bb8a03d1fe617f46

Locked catalogue snapshots show this condition by PostgreSQL 7.4; source behavior here is fixed at PostgreSQL 18.6.

Method: Read locked catalogue facts and definition snapshot.

Limits: First observed release is a lower bound, not precise behavioral introduction.

src.errcodes.42P18.18.6

Message templates

ERROR · message.variant-1

Primary

cannot determine type of empty array

Hint

Explicitly cast to the desired type, for example ARRAY[]::integer[].

Primary

Explicitly cast to the desired type, for example ARRAY[]::integer[].

Placeholders remain dynamic source fields; no concrete runtime value is claimed.

ERROR · message.variant-2

Primary

could not determine data type of parameter $%d

Placeholders remain dynamic source fields; no concrete runtime value is claimed.

Reproduction & repair cases

No reproduction case is attached to this condition.

Recorded runtime evidence

No runtime observation is attached to this entry.

Definition snapshot: english-manuals:f42630c61fe3a1e910628d4aa2d… · English manual source