select open change scope Open full search

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

SQLSTATE / CLASS P0 · PL/PGSQL ERROR

too_many_rows

SQLSTATE
P0003
Condition name
too_many_rows
Class
PL/pgSQL Error
Source macro
ERRCODE_TOO_MANY_ROWS
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>P0003</h1>

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.

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

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

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

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.

Sources

See the fixed pl_exec.c GUC branch and report paths alongside the structured evidence record.

Source evidence

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

P0003 is too_many_rows in PostgreSQL-specific Class P0.

Method: Read the fixed definition row.

src.errcodes.18.6

PL/pgSQL fixed paths report `query returned more than one row`; the strict path may include `parameters: %s` and the source provides the hint `Make sure the query returns a single row, or use LIMIT 1.`.

Method: Read both report groups, their conditional detail, hint, and errlevel.

src.path.plpgsql

For SELECT INTO-style checked queries, plpgsql.extra_errors selecting too_many_rows takes precedence and sets the extra check to ERROR; if it is not selected, plpgsql.extra_warnings selecting too_many_rows sets WARNING. Strict or modifying-statement paths use ERROR regardless, and print_strict_params controls the optional parameters detail.

Method: Read the fixed too_many_rows_level assignment, row-count branch, errlevel selection, and detail condition.

Limits: The hint is present on the SELECT INTO-style branch; the dynamic-execute path has the same primary/detail but no hint in the cited report group.

src.path.plpgsql

Message templates

ERROR or source-selected errlevel · message.too-many-rows

Primary

query returned more than one row

Detail

parameters: %s

Hint

Make sure the query returns a single row, or use LIMIT 1.

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:2dc12ce6f4c8d6de2949be600e0… · English manual source