Re: Assert single row returning SQL-standard functions - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Assert single row returning SQL-standard functions
Date
Msg-id CAKFQuwZ6d8Btqs8k08c-pny-tPAwpRyHX9ChaVSMzVPEBYgogQ@mail.gmail.com
Whole thread Raw
In response to Assert single row returning SQL-standard functions  ("Joel Jacobson" <joel@compiler.org>)
List pgsql-hackers
On Friday, August 29, 2025, Joel Jacobson <joel@compiler.org> wrote:

These were just the two first ideas on the top of my head, please share
yours if you see a better way.

I’d love to just add a new clause to select.

Select …
Require {exactly|{more|less}than} row_count

e.g., exactly 1; more than 0, less than 2

No reason to limit this capability to function call outputs especially since we would like to retain inlining when possible.

For insert/delete/update either add it directly there too or at worse you get it via returning into a CTE and attaching “require” to the parent query.

David J.

pgsql-hackers by date:

Previous
From: Fabrice Chapuis
Date:
Subject: Re: Issue with logical replication slot during switchover
Next
From: Pavel Stehule
Date:
Subject: Re: Assert single row returning SQL-standard functions