# P0003 — too_many_rows

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

# P0003

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

P0003 is PL/pgSQL `too_many_rows`. Fixed paths preserve the message, optional parameter detail, hint, and the source-selected severity boundary.

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

| Field | Value |
| --- | --- |
| SQLSTATE | `P0003` |
| Condition | `too_many_rows` |
| Status | `active` |
| Known present by | `8.2.0` |
| 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_TOO_MANY_ROWS` |
| Aliases | `—` |

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

## Meaning {#meaning}

A fixed PL/pgSQL path reports `query returned more than one row`; the strict path may attach `parameters: %s` detail and the source-provided hint `Make sure the query returns a single row, or use LIMIT 1.`. The actual severity is branch-dependent.

## Diagnosis {#diagnosis}

Check the strict or modifying-statement path and preserve the actual severity: `plpgsql.extra_errors` selecting `too_many_rows` takes precedence and makes the extra check ERROR; otherwise `plpgsql.extra_warnings` selecting it makes the extra check WARNING. Strict or modifying-statement paths use ERROR regardless of those settings. Ordinary multi-row SELECT behavior is not automatically P0003.

## Response {#response}

Make the query satisfy the single-row contract or deliberately choose a multi-row structure; do not blindly replay business work.

## Versions {#versions}

The locked catalogue records this condition from 8.2.0 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

## Related {#related}

[`P0002`](../p0002/), [`P0004`](../p0004/), [`02000`](../02000/)

## Sources {#sources}

See the fixed [pl_exec.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/pl/plpgsql/src/pl_exec.c#L4215-L4220) GUC branch and [report paths](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/pl/plpgsql/src/pl_exec.c#L4394-L4410) alongside the structured [evidence record](../data/evidence/p0003.json).
