42P18 — Indeterminate datatype
42P18 (indeterminate_datatype) Type inference fails when an expression or protocol parameter has no determinate type.
English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- aliases
- Unknown
- class name
- Syntax Error or Access Rule Violation
- condition name
- indeterminate_datatype
- lang
- en
- sqlstate
- 42P18
Definition PG 18
42P18 — Indeterminate datatype
At a glance {#at-a-glance}
42P18 (indeterminate_datatype) Type inference fails when an expression or protocol parameter has no determinate type.
Meaning {#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 {#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 {#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 {#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 {#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.
Related {#related}
Sources {#sources}
Source messages, line anchors, and evidence limits are recorded in authored evidence.
src/backend/parser/parse_expr.c:2102-2107(fixed source)src/backend/tcop/postgres.c:733-736(fixed source)
Compare versions
SQLSTATE evidence and recorded runtime versions
claims · identity.class-and-condition
{
"claim_id": "identity.class-and-condition",
"limits": "Identity does not enumerate all source branches or client failures.",
"method": "Read fixed REL_18_6 errcodes.txt and locked facts.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.42P18.18.6"
],
"statement": "42P18 is the indeterminate_datatype condition in Class 42."
}claims · mechanism.selected-source-path
{
"claim_id": "mechanism.selected-source-path",
"limits": "Representative confirmed core paths only; not exhaustive historical or extension coverage.",
"method": "Read selected resolved REL_18_6 report groups and message roles.",
"position": 1,
"runtime": [],
"sources": [
"src.call.42P18.24454306029f6c5a510a8800",
"src.call.42P18.8fe85a04bb8a03d1fe617f46"
],
"statement": "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."
}claims · versions.catalogue-boundary
{
"claim_id": "versions.catalogue-boundary",
"limits": "First observed release is a lower bound, not precise behavioral introduction.",
"method": "Read locked catalogue facts and definition snapshot.",
"position": 2,
"runtime": [],
"sources": [
"src.errcodes.42P18.18.6"
],
"statement": "Locked catalogue snapshots show this condition by PostgreSQL 7.4; source behavior here is fixed at PostgreSQL 18.6."
}messages · message.variant-1
{
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"message_id": "message.variant-1",
"path": "",
"position": 0,
"raw": {
"detail_templates": [],
"hint_templates": [
"Explicitly cast to the desired type, for example ARRAY[]::integer[]."
],
"id": "message.variant-1",
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"primary_template": "cannot determine type of empty array",
"roles": [
{
"role": "errmsg",
"template": "cannot determine type of empty array"
},
{
"role": "errhint",
"template": "Explicitly cast to the desired type, for example ARRAY[]::integer[]."
}
],
"severity_source": "ERROR",
"sources": [
"src.call.42P18.24454306029f6c5a510a8800"
],
"sqlstate": "42P18"
},
"severity": "ERROR",
"sources": [
"src.call.42P18.24454306029f6c5a510a8800"
],
"templates": [
{
"kind": "primary",
"literal": "cannot determine type of empty array",
"position": 0,
"role": "",
"template": "cannot determine type of empty array"
},
{
"kind": "hint",
"literal": "Explicitly cast to the desired type, for example ARRAY[]::integer[].",
"position": 1,
"role": "",
"template": "Explicitly cast to the desired type, for example ARRAY[]::integer[]."
},
{
"kind": "primary",
"literal": "Explicitly cast to the desired type, for example ARRAY[]::integer[].",
"position": 2,
"role": "errhint",
"template": "Explicitly cast to the desired type, for example ARRAY[]::integer[]."
}
]
}messages · message.variant-2
{
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"message_id": "message.variant-2",
"path": "",
"position": 1,
"raw": {
"detail_templates": [],
"hint_templates": [],
"id": "message.variant-2",
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"primary_template": "could not determine data type of parameter $%d",
"roles": [
{
"role": "errmsg",
"template": "could not determine data type of parameter $%d"
}
],
"severity_source": "ERROR",
"sources": [
"src.call.42P18.8fe85a04bb8a03d1fe617f46"
],
"sqlstate": "42P18"
},
"severity": "ERROR",
"sources": [
"src.call.42P18.8fe85a04bb8a03d1fe617f46"
],
"templates": [
{
"kind": "primary",
"literal": "could not determine data type of parameter $",
"position": 0,
"role": "",
"template": "could not determine data type of parameter $%d"
}
]
}sources · src.errcodes.42P18.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "line 351",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.42P18.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L351"
}sources · src.call.42P18.24454306029f6c5a510a8800
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 2102-2107",
"path": "src/backend/parser/parse_expr.c",
"position": 1,
"sha256": "63c37770872a08978f931c31f801666a08e3bc8e51c2c65ff60151a1d139d55b",
"source_id": "src.call.42P18.24454306029f6c5a510a8800",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/parse_expr.c#L2102-L2107"
}sources · src.call.42P18.8fe85a04bb8a03d1fe617f46
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 733-736",
"path": "src/backend/tcop/postgres.c",
"position": 2,
"sha256": "9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061",
"source_id": "src.call.42P18.8fe85a04bb8a03d1fe617f46",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L733-L736"
}sources · src.calls.REL_18_6.42P18
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "raw/calls/REL_18_6.jsonl",
"position": 3,
"sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
"source_id": "src.calls.REL_18_6.42P18",
"tag": "",
"url": ""
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:99603a59d4f54c191b6d3cb3c7ab3e70f2c04ed103302979c8f3a66b9b4e9020
Text language: en · english-manuals:99603a59d4f54c191b6d3cb3c7ab3e70f2c04ed103302979c8f3a66b9b4e9020