EXTRACT not locking?

Started by James Zukowski, April 18, 2024, 02:32:03 PM

Previous topic - Next topic

James Zukowski

We encountered an interesting situation and could use some clarity and/or confirmation.

Using a Linux server (RHEL 7.9) with PxPlus v15.1 via WindX we open a test file and EXTRACT a record. In another session, open the same file and READ the record. No Error 0.

Upon closer examination, we noticed the Linux file permissions were "-rw-r--r--" and the file was "owned" by a different username. When we changed the permissions to "-rw-rw-rw-", the EXTRACT/READ above worked as expected.

So, it seems that an EXTRACT on a file where a WRITE cannot actually happen is treated as a READ, even though everything, including FIN(ch,"Extract"), suggests the EXTRACT really happened. Except it didn't.

Is this proper? Or is there something missing along the way?

Any guidance would be greatly appreciated.

Thanks!
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

Mike King

This is actually a Linux issue.  Record locking is done by placing a Write lock against the file however Linux doesn't allow us to add a write lock to a read only file.

Also, since the EXTRACT directive can be used to position the file PxPlus could not return the error. A fairly common coding technique looking to read records starting with a known record key is to use an EXTRACT to the desired starting record then create a loop doing a standard READ next.  The EXTRACT positions the file such that a subsequent read next will return the extracted record making the coding cleaner.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com