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

ambiguous_parameter

SQLSTATE
42P08
Condition name
ambiguous_parameter
Class
Syntax Error or Access Rule Violation
Source macro
ERRCODE_AMBIGUOUS_PARAMETER
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>42P08 — Ambiguous parameter type</h1>

At a glance

42P08 (ambiguous_parameter) means a parameter marker exists, but parse analysis cannot make its type consistent or specific enough. The exact SQLSTATE and parser branch matter because similar primary text can be emitted by a different condition.

Meaning

The variable-parameter coercion hook first records a target type for an unknown parameter. If a later context requests a different type, it raises ERROR inconsistent types deduced for parameter $%d with DETAIL %s versus %s. A later parameter-resolution walk raises ERROR could not determine data type of parameter $%d when the resolved parameter type does not match the externally supplied type array. These are two selected 42P08 guards, not one generic “bind failed” message.

The primary could not determine data type of parameter $%d also appears in the var-parameter completion check in postgres.c with ERRCODE_INDETERMINATE_DATATYPE (42P18). Read the SQLSTATE and source path together: 42P08 is the selected mismatch during parameter resolution, while 42P18 is an unresolved type after analysis; an out-of-range marker is 42P02.

Diagnosis

Record the parameter number, every expression context, and DETAIL. For the inconsistent-types branch, compare the two type names in DETAIL and find the contexts that imposed them. For the unresolved-type branch, inspect the PREPARE/extended-query parameter type array and the final inferred type. Keep missing markers (42P02), Bind count violations (08P01), and alias/column ambiguity separate from this type-resolution failure.

Response

Declare the parameter type in PREPARE or cast it at a deliberate expression boundary. If two contexts genuinely need different types, split the parameters; otherwise make the contexts agree. Do not cast to an arbitrary broad type: verify operators, indexes, null semantics, and serialization. If the ERROR occurred inside an explicit transaction, roll back to a suitable savepoint or roll back the transaction before retrying.

Messages

The selected 42P08 variants are explicit ERRORs:

Guard Primary DETAIL
conflicting inferred target types inconsistent types deduced for parameter $%d %s versus %s
final parameter type mismatch could not determine data type of parameter $%d none

The same second primary can carry 42P18 when emitted by the separate unresolved-type completion guard; the SQLSTATE is part of the message identity.

Versions

From 7.4 through 18.6 and 19beta3; that catalogue range is not a precise introduction claim. The selected two 42P08 guards and the nearby 42P18 boundary are fixed 18.6 source paths; no runtime parameter case was run.

Sources

  • src.errcodes.42P08.18.6src/backend/utils/errcodes.txt line 388, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.42P08.c2cfa81ed9389a1bddf8ec41src/backend/parser/parse_param.c lines 220-227, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 4aab2ecc770fcda619b26ac12beaf7e527542b56f55eb45879b72e92442e8a28 (source).

  • src.call.42P08.18ba6576d169dfdf614df72dsrc/backend/parser/parse_param.c lines 308-312, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 4aab2ecc770fcda619b26ac12beaf7e527542b56f55eb45879b72e92442e8a28 (source).
  • src.call.42P08.unresolved-boundarysrc/backend/tcop/postgres.c lines 725-736, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061 (source).
  • src.calls.REL_18_6.42P08 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.
  • authored evidence — source claims, message roles, and runtime boundary.

Source evidence

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

42P08 is the ambiguous_parameter 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.42P08.18.6

The selected 42P08 guards are conflicting inferred types, reporting `inconsistent types deduced for parameter $%d` with DETAIL `%s versus %s`, and a later parameter-resolution mismatch, reporting `could not determine data type of parameter $%d`; both are ERRORs. The same second primary is emitted with 42P18 by the separate var-parameter completion guard when a type remains unknown after analysis, while an out-of-range marker is 42P02.

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

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

src.call.42P08.c2cfa81ed9389a1bddf8ec41 src.call.42P08.18ba6576d169dfdf614df72d src.call.42P08.unresolved-boundary

From 7.4 through 18.6 and 19beta3; this catalogue range is not a precise introduction claim. The selected two 42P08 guards and nearby 42P18 boundary are fixed 18.6 source paths and no runtime parameter case was run.

Method: Read locked catalogue facts and definition snapshots.

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

src.errcodes.42P08.18.6

Message templates

explicit ERROR · message.variant-1

Primary

inconsistent types deduced for parameter $%d

Detail

%s versus %s

Primary

%s versus %s

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

explicit 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:e37bd9ca9fd0622e415e1e1cc07… · English manual source