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

Transaction scope too large

Open stefandrissen opened this issue 4 years ago • 1 comments

Recently I discovered some transaction scopes that had become larger than intended:

procedure example2:

   define buffer customer for customer.
   
   def var lquery as logical initial true. 
   
   message 'example2' transaction.   
   
   do while lquery: // in reality this is do while hq:get-next():
   
      lquery = false.

      do for customer:   
         find customer exclusive-lock no-wait no-error.         
         if available customer then    
            /* do something */
        end.

   end.
   
end procedure.   

The transaction required for find exclusive-lock is lifted to the nearest undoable block, which is the procedure. As a result the entire procedure had unintendedly become a single transaction.

stefandrissen avatar Mar 20 '20 07:03 stefandrissen

Transaction scope is read from the listing file (if they're generated with PCT), and there's currently only one rule which just raise an issue if the entire .p is starting a transaction. Additional information should be attached to the AST to be able to do what you describe. Can be done, but I'll have to think about exactly what should be reported.

gquerret avatar Mar 20 '20 10:03 gquerret