We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
query.empty() check adds LIMIT 1 to query, so information about row locking is lost (only 1 pseudo-random row will be locked). For example,
val query = Securities.select { Securities.lot eq 2 }.forUpdate() if (!query.empty()) { Securities.update({ query.where!! }) { it[lot] = 1 } }
produces
SELECT securities.id, securities."class", securities.ticker, securities.lot, securities.up_limit, securities.low_limit, securities.step FROM securities WHERE securities.lot = 2 LIMIT 1 FOR UPDATE UPDATE securities SET lot=1 WHERE securities.lot = 2
So, we can expect that server will lock only 1 row, while it is possible that query affects more that one. https://www.postgresql.org/docs/12/sql-select.html#SQL-FOR-UPDATE-SHARE
If a LIMIT is used, locking stops once enough rows have been returned to satisfy the limit
This can lead to hardly reproducible errors.
Suggestion: check if query has forUpdate() flag and leave query unaltered.
The text was updated successfully, but these errors were encountered:
query.empty() shouldn't add LIMIT 1 if query is marked as forUpdate() #…
593cd3f
…684
b7e6111
No branches or pull requests
query.empty() check adds LIMIT 1 to query, so information about row locking is lost (only 1 pseudo-random row will be locked).
For example,
produces
So, we can expect that server will lock only 1 row, while it is possible that query affects more that one.
https://www.postgresql.org/docs/12/sql-select.html#SQL-FOR-UPDATE-SHARE
This can lead to hardly reproducible errors.
Suggestion: check if query has forUpdate() flag and leave query unaltered.
The text was updated successfully, but these errors were encountered: