↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / SQLSTATE

P0003 — too_many_rows

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

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
PL/pgSQL Error
condition name
too_many_rows
lang
en
sqlstate
P0003

Definition PG 18

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.

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, P0004, 02000

Sources {#sources}

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

Compare versions

SQLSTATE evidence and recorded runtime versions

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read the fixed definition row.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "P0003 is too_many_rows in PostgreSQL-specific Class P0."
}
claims · strict-query
{
  "claim_id": "strict-query",
  "limits": "",
  "method": "Read both report groups, their conditional detail, hint, and errlevel.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.plpgsql"
  ],
  "statement": "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.`."
}
claims · severity-boundary
{
  "claim_id": "severity-boundary",
  "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.",
  "method": "Read the fixed too_many_rows_level assignment, row-count branch, errlevel selection, and detail condition.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.path.plpgsql"
  ],
  "statement": "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."
}
messages · message.too-many-rows
{
  "limits": "",
  "message_id": "message.too-many-rows",
  "path": "",
  "position": 0,
  "raw": {
    "detail_template": "parameters: %s",
    "hint_template": "Make sure the query returns a single row, or use LIMIT 1.",
    "id": "message.too-many-rows",
    "primary_template": "query returned more than one row",
    "severity_source": "ERROR or source-selected errlevel",
    "sources": [
      "src.path.plpgsql"
    ],
    "sqlstate": "P0003"
  },
  "severity": "ERROR or source-selected errlevel",
  "sources": [
    "src.path.plpgsql"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "query returned more than one row",
      "position": 0,
      "role": "",
      "template": "query returned more than one row"
    },
    {
      "kind": "detail",
      "literal": "parameters:",
      "position": 1,
      "role": "",
      "template": "parameters: %s"
    },
    {
      "kind": "hint",
      "literal": "Make sure the query returns a single row, or use LIMIT 1.",
      "position": 2,
      "role": "",
      "template": "Make sure the query returns a single row, or use LIMIT 1."
    }
  ]
}
sources · src.errcodes.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L493"
}
sources · src.calls.REL_18_6
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/calls/REL_18_6.jsonl",
  "position": 1,
  "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
  "source_id": "src.calls.REL_18_6",
  "tag": "",
  "url": ""
}
sources · src.path.plpgsql
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/pl/plpgsql/src/pl_exec.c",
  "position": 2,
  "sha256": "0df3c70a6bccf6dddf443fb99e152a16a67009827c44a820597e98e585cb8b20",
  "source_id": "src.path.plpgsql",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/pl/plpgsql/src/pl_exec.c#L4215-L4220"
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:ffa6714eaaab0bfb91e2ef5ea7ae767021dbcf4dcc0fd2d9ba9157cae26e3814

Text language: en · english-manuals:ffa6714eaaab0bfb91e2ef5ea7ae767021dbcf4dcc0fd2d9ba9157cae26e3814