From 539ecfdbf11a05fb3aeff6cd2643e03b6b9c5b7a Mon Sep 17 00:00:00 2001 From: Jeevan Chalke Date: Tue, 3 Nov 2026 18:23:34 +0530 Subject: [PATCH v3 2/3] Remove "or use LIMIT 1" from PL/pgSQL "more than one row" hint. The hint "Make sure the query returns a single row, or use LIMIT 1." is also attached to errors for commands such as UPDATE ... RETURNING INTO, where LIMIT 1 cannot be applied. Use the generic wording "Make sure the query returns a single row." in both exec_stmt_execsql() and exec_stmt_dynexecute(). --- src/pl/plpgsql/src/pl_exec.c | 4 ++-- src/test/regress/expected/plpgsql.out | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 62fbcc909dd..ac77b03464c 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -4522,7 +4522,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate, (errcode(ERRCODE_TOO_MANY_ROWS), errmsg("query returned more than one row"), errdetail ? errdetail_internal("parameters: %s", errdetail) : 0, - errhint("Make sure the query returns a single row, or use LIMIT 1."))); + errhint("Make sure the query returns a single row."))); } /* Put the first result row into the target */ exec_move_row(estate, target, tuptab->vals[0], tuptab->tupdesc); @@ -4719,7 +4719,7 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate, (errcode(ERRCODE_TOO_MANY_ROWS), errmsg("query returned more than one row"), errdetail ? errdetail_internal("parameters: %s", errdetail) : 0, - errhint("Make sure the query returns a single row, or use LIMIT 1."))); + errhint("Make sure the query returns a single row."))); } /* Put the first result row into the target */ diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index 21e597c014d..02ad82ad0b5 100644 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -2732,7 +2732,7 @@ begin end$$ language plpgsql; select stricttest(); ERROR: query returned more than one row -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. CONTEXT: PL/pgSQL function stricttest() line 5 at SQL statement create or replace function stricttest() returns void as $$ declare x record; @@ -2806,7 +2806,7 @@ begin end$$ language plpgsql; select stricttest(); ERROR: query returned more than one row -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. CONTEXT: PL/pgSQL function stricttest() line 5 at SQL statement create or replace function stricttest() returns void as $$ declare x record; @@ -2841,7 +2841,7 @@ begin end$$ language plpgsql; select stricttest(); ERROR: query returned more than one row -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. CONTEXT: PL/pgSQL function stricttest() line 5 at EXECUTE drop function stricttest(); -- test printing parameters after failure due to STRICT @@ -2887,7 +2887,7 @@ end$$ language plpgsql; select stricttest(); ERROR: query returned more than one row DETAIL: parameters: p1 = '2', p3 = 'foo' -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. CONTEXT: PL/pgSQL function stricttest() line 8 at SQL statement create or replace function stricttest() returns void as $$ declare x record; @@ -2898,7 +2898,7 @@ begin end$$ language plpgsql; select stricttest(); ERROR: query returned more than one row -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. CONTEXT: PL/pgSQL function stricttest() line 5 at SQL statement create or replace function stricttest() returns void as $$ declare x record; @@ -2921,7 +2921,7 @@ end$$ language plpgsql; select stricttest(); ERROR: query returned more than one row DETAIL: parameters: $1 = '1' -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. CONTEXT: PL/pgSQL function stricttest() line 5 at EXECUTE create or replace function stricttest() returns void as $$ declare x record; @@ -2932,7 +2932,7 @@ begin end$$ language plpgsql; select stricttest(); ERROR: query returned more than one row -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. CONTEXT: PL/pgSQL function stricttest() line 5 at EXECUTE create or replace function stricttest() returns void as $$ -- override the global @@ -2948,7 +2948,7 @@ begin end$$ language plpgsql; select stricttest(); ERROR: query returned more than one row -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. CONTEXT: PL/pgSQL function stricttest() line 10 at SQL statement reset plpgsql.print_strict_params; create or replace function stricttest() returns void as $$ @@ -2966,7 +2966,7 @@ end$$ language plpgsql; select stricttest(); ERROR: query returned more than one row DETAIL: parameters: p1 = '2', p3 = 'foo' -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. CONTEXT: PL/pgSQL function stricttest() line 10 at SQL statement -- test warnings and errors set plpgsql.extra_warnings to 'all'; @@ -3099,7 +3099,7 @@ begin end; $$; WARNING: query returned more than one row -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. do $$ declare x int; begin @@ -3107,7 +3107,7 @@ begin end; $$; WARNING: query returned more than one row -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. set plpgsql.extra_errors to 'too_many_rows'; do $$ declare x int; @@ -3116,7 +3116,7 @@ begin end; $$; ERROR: query returned more than one row -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. CONTEXT: PL/pgSQL function inline_code_block line 4 at SQL statement do $$ declare x int; @@ -3125,7 +3125,7 @@ begin end; $$; ERROR: query returned more than one row -HINT: Make sure the query returns a single row, or use LIMIT 1. +HINT: Make sure the query returns a single row. CONTEXT: PL/pgSQL function inline_code_block line 4 at EXECUTE reset plpgsql.extra_errors; reset plpgsql.extra_warnings; -- 2.43.0