#50 Line sequential record length wrong

unclassified
open
None
1
2015-01-14
2013-06-17
Luke Smith
No

The wrong length is returned when a line sequential file is read back in.

A program is attached that shows the problem. Using 1.1 CE and compiled as cobc -xW slb.cob.

The program opens a line sequential file output, writes variable length records and closes the file. At this point, opening the output file with an editor shows that the records are correct. Here is the file:

----+---10----+---20----+---30----+---40----+---50
----+---10----+---20----+---30----+
----+---10----+---20----+

Then, it opens the file input and reads the records, within the same run. All of the records return a length of 25. Here is a screen:

./slb 
slb * Show Length Bug  
   A = Output records and read back in.  
   B = Read records.
Selection: a
Write record length: 50
Write record length: 35
Write record length: 25
Read record length: 25 fail.
Read record length: 25 fail.
Read record length: 25 pass.

If the program does a goback, and is restarted, then the records read correctly. Here is the screen:

./slb 
slb * Show Length Bug
   A = Output records and read back in.  
   B = Read records.
Selection: b
Read record length: 50 pass.
Read record length: 35 pass.
Read record length: 25 pass.

The error happens on any line sequential file that it reads back in, not just on the file it wrote out. So the path name could be changed in the open input, and it will still get the error.

The workaround is to write out all line sequential files with the maximum record size for all records.

1 Attachments

Related

Bugs: #50

Discussion

  • Luke Smith

    Luke Smith - 2013-10-05

    This is fixed in version 2.0.

     
  • Brian Tiffin

    Brian Tiffin - 2013-11-19
    • status: open --> closed
    • assigned_to: Brian Tiffin
     
    • Simon Sobisch

      Simon Sobisch - 2013-11-19

      As it's now your ticket Brian... ;-) It's still open for me.

      I think it is necessary to add an entry in the test suite for that, if it's not in already (which likely isn't the case).
      Add it to 2.0, 'svn merge' it to 2.0 C++ (as it should work) and 1.1 (either as expected to fail or together with a retrofix from 2.0 into 1.1).

      The same test can be nearly copied for ISAM with variable record length (only tested when configured for ISAM, of course).

      Simon

       
  • Simon Sobisch

    Simon Sobisch - 2014-07-29
    • status: closed --> open
     
  • Joe Robbins

    Joe Robbins - 2014-08-04

    Is this really a fault? Or is it expected behaviour?

    In Test A :: length-TestFile-record = 25 ON EACH READ. fileio will truncate the data (record) read to 25 bytes. This explains the Test A READ results. (In each case the client is specifying a maximum of 25 bytes and that is what is delivered.)

    In Test B :: length-TestFile-record = 0 ON 1st READ and is therefore ignored. fileio sets it to 50 (to reflect the length of the 1st record). ON 2nd READ length-TestFile-record = 50, fileio sets it to 25. ON 3rd READ length-TestFile-record = 25, fileio sets it to 25.

    The rule this program-code ignores is that:
    if you use "... depending on w-rsz" then you must set w-rsz before each READ, either to 0 to read up to FD max record-size bytes, or to a value that will truncate unwanted bytes.

    ANS85: I can't find explicit definition of interaction between READ and "... depending on w-rsz" (in MF manual).

     
    Last edit: Joe Robbins 2014-08-04
  • Simon Sobisch

    Simon Sobisch - 2014-08-04

    It is not expected behaviour, see 13.18.42 RECORD clause, Format 2. In summary:
    Before WRITE w-rsz is inspected to see how much to write, w-rsz is changed after READ is done to reflect the number of Bytes read. The value is not changed after WRITE and is not checked before READ.

    Simon

     
    • Joe Robbins

      Joe Robbins - 2014-08-06

      Having re-read the manual: I agree. Nothing is said to indicate the record read will be limited to the value specified in data-name-1 in RECORD .. VARYING FROM.. TO .. DEPENDENDING data-name-1. In fact (in the version of fileio I work with) only ORGANIZATION LINE SEQUENTIAL was doing this anyway.

      I have committed corrected fileio-sequential.c. Also made BDB handle variable length records properly.

      Relevant test cases for all 4 ORGANIZATION submitted in run_fileio.at


      From: Simon Sobisch sf-mensch@users.sf.net
      Sent: 04 August 2014 18:31
      To: [open-cobol:bugs]
      Subject: [open-cobol:bugs] #50 Line sequential record length wrong

      It is not expected behaviour, see 13.18.42 RECORD clause, Format 2. In summary:
      Before WRITE w-rsz is inspected to see how much to write, w-rsz is changed after READ is done to reflect the number of Bytes read. The value is not changed after WRITE and is not checked before READ.

      Simon


      [bugs:#50] Line sequential record length wrong

      Status: open
      Group: unclassified
      Created: Mon Jun 17, 2013 11:41 PM UTC by Luke Smith
      Last Updated: Mon Aug 04, 2014 09:32 AM UTC
      Owner: Brian Tiffin

      The wrong length is returned when a line sequential file is read back in.

      A program is attached that shows the problem. Using 1.1 CE and compiled as cobc -xW slb.cob.

      The program opens a line sequential file output, writes variable length records and closes the file. At this point, opening the output file with an editor shows that the records are correct. Here is the file:

      ----+---10----+---20----+---30----+---40----+---50
      ----+---10----+---20----+---30----+
      ----+---10----+---20----+
      

      Then, it opens the file input and reads the records, within the same run. All of the records return a length of 25. Here is a screen:

      ./slb
      slb * Show Length Bug
         A = Output records and read back in.
         B = Read records.
      Selection: a
      Write record length: 50
      Write record length: 35
      Write record length: 25
      Read record length: 25 fail.
      Read record length: 25 fail.
      Read record length: 25 pass.
      

      If the program does a goback, and is restarted, then the records read correctly. Here is the screen:

      ./slb
      slb * Show Length Bug
         A = Output records and read back in.
         B = Read records.
      Selection: b
      Read record length: 50 pass.
      Read record length: 35 pass.
      Read record length: 25 pass.
      

      The error happens on any line sequential file that it reads back in, not just on the file it wrote out. So the path name could be changed in the open input, and it will still get the error.

      The workaround is to write out all line sequential files with the maximum record size for all records.


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/open-cobol/bugs/50/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #50


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks