sonar-openedge icon indicating copy to clipboard operation
sonar-openedge copied to clipboard

Detect GET FIRST/GET LAST without lock

Open movedoa opened this issue 3 years ago • 3 comments

A rule to detect GET-FIRST/GET-LAST without an explicit lock would be nice. Using this without a lock can lead to problems like error 2819 and other problems.

Quote from the doc:

The GET statement inherits its lock mode from the most recent OPEN QUERY statement, unless you give a lock-mode on the GET itself. So if you do an OPEN QUERY... EXCLUSIVE-LOCK, and then do a subsequent GET on that query, the GET will be EXCLUSIVE-LOCK too.

#880 is a related i guess.

movedoa avatar Nov 23 '21 10:11 movedoa

I'll have a look, I thought the problem was fixed as part of #880.

gquerret avatar Nov 23 '21 14:11 gquerret

The GET-FIRST and GET-LAST methods use NO-LOCK by default, so I assume you're talking about the GET statement with a modifier on a static query ? e.g.

define query qry for customer.
open query for each customer.
get first qry. // Missing lock as it's not specified in the open query statement
get next qry. // Ditto

gquerret avatar Nov 25 '21 09:11 gquerret

The GET-FIRST and GET-LAST methods use NO-LOCK by default, so I assume you're talking about the GET statement with a modifier on a static query ? e.g.

define query qry for customer.
open query for each customer.
get first qry. // Missing lock as it's not specified in the open query statement
get next qry. // Ditto

Yes, i typed the hyphen out of habit :D.

movedoa avatar Nov 25 '21 09:11 movedoa