-
Notifications
You must be signed in to change notification settings - Fork 962
Open
Labels
📚 mysqlbugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentation
Description
Version
1.26.0
What happened?
https://docs.sqlc.dev/en/latest/howto/transactions.html
In the given example, the code tries to select a row from records and increase the counter by 1 (in a transaction). According to the official MySQL manual:
If you query data and then insert or update related data within the same transaction, the regular SELECT statement does not give enough protection. Other transactions can update or delete the same rows you just queried. InnoDB supports two types of locking reads that offer extra safety - https://dev.mysql.com/doc/refman/8.4/en/innodb-locking-reads.html
So, shouldn't
-- name: GetRecord :one
SELECT * FROM records
WHERE id = $1;
be
-- name: GetRecord :one
SELECT * FROM records
WHERE id = $1
FOR UPDATE;
in this case?
Kavantix
Metadata
Metadata
Assignees
Labels
📚 mysqlbugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentation