morphismtech / squeal

Squeal, a deep embedding of SQL in Haskell
350 stars 32 forks source link

lockRows should only be applied to Ungrouped TableExpression #287

Closed adamwespiser closed 3 years ago

adamwespiser commented 3 years ago

lockRows should only by applied to TableExpression 'Ungrouped)lat with db params from.

You can demonstrate this issue on a postgresql repl, although I cannot find supporting information in the documentation:

[db] # select * from table FOR UPDATE;
(0 rows)
[db] # select * from table group by id FOR UPDATE;
ERROR:  0A000: FOR UPDATE is not allowed with GROUP BY clause
LOCATION:  CheckSelectLocking, analyze.c:2688

The same 0A000 error will happen if you replace FOR UPDATE with FOR NO KEY UPDATE, FOR SHARE, or FOR KEY SHARE. Therefore the issue is systematic and would justify changing the signature of lockRows to exclude Grouped table expressions.

Let me know and I'll put the PR in.

echatav commented 3 years ago

Good find! PR would be great.

echatav commented 3 years ago

resolved by #288