Re: Sanding down some edge cases for PL/pgSQL reserved words
От | Joel Jacobson |
---|---|
Тема | Re: Sanding down some edge cases for PL/pgSQL reserved words |
Дата | |
Msg-id | e008f1ea-0700-4ed4-a2f0-4bfc9aac2418@app.fastmail.com обсуждение исходный текст |
Ответ на | Re: Sanding down some edge cases for PL/pgSQL reserved words (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-hackers |
On Sat, Apr 26, 2025, at 05:10, Tom Lane wrote: > "Joel Jacobson" <joel@compiler.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
В списке pgsql-hackers по дате отправления: