# 10608 — invalid_argument_for_xquery

> Source-backed reference for PostgreSQL SQLSTATE 10608.
---

# 10608

## At a glance {#at-a-glance}

SQLSTATE 10608 is an ERROR-level XQuery-class condition for an invalid argument. PostgreSQL 18.6 has resolved backend XML paths for an empty XPath expression, an empty row path filter, and an empty column path filter. The `contrib/xml2` sources also reference the macro, but those references alone do not establish an additional report message.

<!-- BEGIN SQLSTATE FACTS: generated by scripts/generate.py; do not edit -->

| Field | Value |
| --- | --- |
| SQLSTATE | `10608` |
| Condition | `invalid_argument_for_xquery` |
| Status | `active` |
| Known present by | `18.0` |
| Locked snapshots | `18.6, 19beta3` |
| Macros | `ERRCODE_INVALID_ARGUMENT_FOR_XQUERY` |
| Aliases | `—` |

<!-- source facts: data/errcodes/10608.json -->
<!-- END SQLSTATE FACTS -->

## Meaning {#meaning}

The fixed backend calls report exactly `empty XPath expression`, `row path filter must not be empty string`, and `column path filter must not be empty string` in `src/backend/utils/adt/xml.c`. These are argument-validation failures in XML/XPath processing. The core report does not imply that every XPath/XSLT or extension argument error uses 10608.

## Messages {#messages}

The fixed backend calls report exactly `empty XPath expression`, `row path filter must not be empty string`, and `column path filter must not be empty string` in `src/backend/utils/adt/xml.c`. These are argument-validation failures in XML/XPath processing. The core report does not imply that every XPath/XSLT or extension argument error uses 10608.

## Diagnosis {#diagnosis}

Identify which XML operation supplied the argument and whether the empty value was the XPath expression, row path filter, or column path filter. Preserve the exact message and input shape; for `xml2` or another extension, inspect that extension's call path separately because the macro reference is not a report group. Check server version when comparing behavior: the locked catalogue first places 10608 at PostgreSQL 18.0.

## Response {#response}

Supply a non-empty expression or filter appropriate to the XML function, then validate the corrected input before repeating the statement. If the operation is extension-owned, use the extension's documented argument rules. This is input repair; a retry without changing the empty argument cannot address the confirmed path.

## Versions {#versions}

The locked catalogue places this condition at least by PostgreSQL 18.0. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

## Related {#related}

[`22023`](../22023/), [`0A000`](../0a000/)

## Sources {#sources}

The fixed backend [xml.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L4388-L4390) reports the empty XPath variant and [the row/column filter checks](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L4825-L4861) report the other variants. [contrib/xml2/xpath.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/xml2/xpath.c#L400-L400) and [xslt_proc.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/xml2/xslt_proc.c#L106-L141) contain macro references. See the [XML functions documentation](https://www.postgresql.org/docs/18/functions-xml.html). See the structured [evidence record](../data/evidence/10608.json) for fixed source paths, scan scope, and unresolved runtime boundaries.
