From: | "Joel Jacobson" <joel(at)compiler(dot)org> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, "Jan Behrens" <jbe-mlist(at)magnetkern(dot)de> |
Subject: | Re: Sanding down some edge cases for PL/pgSQL reserved words |
Date: | 2025-04-26 05:52:31 |
Message-ID: | e008f1ea-0700-4ed4-a2f0-4bfc9aac2418@app.fastmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, Apr 26, 2025, at 05:10, Tom Lane wrote:
> "Joel Jacobson" <joel(at)compiler(dot)org> writes:
>> For years, I've felt we could benefit from introducing convenience syntax to
>> explicitly require that exactly one row is affected by a query, something which
>> currently requires using a somewhat cumbersome workaround:
>
>> - Using `... INTO STRICT ...` for `SELECT`,
>> - Using `RETURNING ... INTO STRICT ...` for `DELETE/UPDATE/INSERT`, or
>> - Checking `ROW_COUNT` via `GET DIAGNOSTICS` and raising an error if not exactly one row.
>
>> I think it would be more convenient and intuitive if we could simply write:
>
>> ```
>> STRICT [SELECT | UPDATE | INSERT | DELETE] ...;
>> ```
>
> Meh. I don't really have an opinion on whether this is worth bespoke
> syntax, but if it is:
>
> (1) I don't see why we'd restrict it to plpgsql as opposed to
> implementing it in core SQL.
Good point, I agree, that would be much better.
>
> (2) Putting the keyword at the front seems fairly un-SQL-like.
> For SELECT, "SELECT STRICT ..." would seem more natural, as it calls
> back to SELECT DISTINCT; or you could imagine integrating it into the
> LIMIT clause. Not as sure what to do for the DML commands, but
> somewhere near where we put RETURNING seems saner.
>
> Also, even if we did do it in plpgsql exactly as you suggest, making
> it unreserved doesn't move the needle on whether that's possible.
> Most of plpgsql's statement-starting keywords are unreserved.
>
> But please, don't hijack this thread for that discussion ...
Understood, and thanks for clarifying this change doesn't affect the strictness idea.
/Joel
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2025-04-26 07:42:56 | Re: Avoid circular header file dependency |
Previous Message | Tom Lane | 2025-04-26 05:20:56 | Re: Avoid circular header file dependency |