[MDEV-25338] add SKIP LOCKED to UPDATE syntax Created: 2021-04-05 Updated: 2023-08-31 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Olaf Buitelaar | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
As being discussed in
Which would update all records in tableX which rows aren't currently locked. |
| Comments |
| Comment by Daniel Black [ 2021-04-06 ] |
|
Thanks for the use case in MDEV-13115. I've had a bit of a look at Oracle, Postgres, SQLite and have yet to see this supported feature on any UPDATE sql syntax. Can you see anything? Anything similar in other syntaxes like MERGE/UPSERT? Sqlite has https://www.sqlite.org/lang_update.html which has a on-conflict ignore (https://www.sqlite.org/lang_conflict.html) which I don't think is the same thing because AFAIK sqlite is table level locks. |
| Comment by Olaf Buitelaar [ 2021-04-06 ] |
|
I've unfortunately not found another database implementing this, while the adaptation of the SELECT ... FOR UPDATE SKIP LOCKED syntax seems to be pretty wide. I did find however that MS-SQL implements a table hint: READPAST (https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-table?view=sql-server-ver15) which seems to achieve the same goal. |
| Comment by Daniel Black [ 2021-04-07 ] |
|
Thanks for looking. It wasn't a prerequisite, just something to syntax model if it did exist. Significant aspects of SELECT ... FOR UPDATE SKIP LOCKED are going to be reusable with this feature. |
| Comment by Daniel Black [ 2022-02-11 ] |
|
monty, serg do you have a syntax preference or objection to this feature? |
| Comment by Sergei Golubchik [ 2022-02-11 ] |
|
what are the use cases? |
| Comment by Olaf Buitelaar [ 2022-02-11 ] |
|
see; https://jira.mariadb.org/browse/MDEV-13115?focusedCommentId=184792&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-184792 |
| Comment by Pavel Cibulka [ 2023-08-31 ] |
|
DELETE SKIP LOCKED - would be nice for cleaning old rows. (Remove all rows not modified in last year etc) |