Re: PL/pgSQL: apply the too_many_rows extra check to EXECUTE ... INTO

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: PL/pgSQL: apply the too_many_rows extra check to EXECUTE ... INTO
Date: 2026-11-11 10:38:25
Message-ID: CAHGQGwGaef21E-cz9D=_Huz96yZZURERhndiBO8ZEzS=6-S5vA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 3, 2026 at 10:27 PM Jeevan Chalke
<jeevan(dot)chalke(at)enterprisedb(dot)com> wrote:
> If you think this is not needed, please feel free to ignore 0003.

Yes, let's leave 0003 out for now.

> 0002 removes "or use LIMIT 1" from the hint in both exec_stmt_execsql() and exec_stmt_dynexecute(), and updates the expected output accordingly.

On second thought, LIMIT 1 would be useful advice for many SELECT queries.
So, how about keeping it as a SELECT-specific example instead of removing it?

Make sure the query returns a single row, for example by using LIMIT
1 with SELECT.

> Attached is v3 with three patches:
> 0001: the too_many_rows check for EXECUTE ... INTO (same as v1)
> 0002: the hint change
> 0003: the documentation change

Thanks for updating the patches!

I think it's better to put the hint change first, so the too_many_rows patch
uses the revised hint from the start. So I revised the patches in that order.
Attached. 0001 updates the hint, and 0002 adds the too_many_rows check.

Barring any objections, I'm thinking to commit these to master.

> One more thing: I proposed this for master only, since it changes behavior for users who have too_many_rows in extra_errors, and I'd appreciate your view on that as well.

Agreed.

Regards,

--
Fujii Masao

Attachment Content-Type Size
v4-0002-plpgsql-Apply-the-too_many_rows-check-to-EXECUTE-.patch application/octet-stream 6.3 KB
v4-0001-plpgsql-Clarify-the-LIMIT-1-example-in-the-too-ma.patch application/octet-stream 5.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-11-11 10:51:47 Re: Fix resource leaks in pg_receivewal on LZ4 close failures
Previous Message Ilia Evdokimov 2026-11-11 10:06:10 Re: Fold NOT IN / <> ALL expressions containing NULL to FALSE