Menu

split key and with duplicates : error 22

2024-05-21
2024-05-22
  • Alain Reymond

    Alain Reymond - 2024-05-21

    Hello,

    I want to create a file containing a split key defined as

    alternate record key split-invoice = invoice-year invoice-number with duplicates
    

    Under Windows Gnucobol 3.3, there is no problem.
    Under Redhat Linux 9.4 or Centos 7 and Gnucobol 3.2.0, the program compiles but returns a file status error 22 each time the program tries to write a record in the file.

    For information , our configuration under Centos 7:

    cobc (GnuCOBOL) 3.2.0
    Copyright (C) 2023 Free Software Foundation, Inc.
    Licence GPLv3+á: GNU GPL version 3 ou ultÚrieure <https://gnu.org/licenses/gpl.h                                         tml>
    Ceci est un logiciel libre; consultez les sources pour les conditions de copie.
    Il n'y a AUCUNE garantie; pas mŕme pour la COMMERCIALISATION ou l'ADQUATION  U                                         N
    BESOIN PARTICULIER.
    crit par Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
    CompilÚ   Aug 15 2023 14:32:31
    EmpaquetÚ Jul 28 2023 17:02:56 UTC
    Version C "4.8.5 20150623 (Red Hat 4.8.5-44)"
    
    information de compilation
    environnement de compila : x86_64-redhat-linux-gnu
    CC                       : gcc
    Version C                : "4.8.5 20150623 (Red Hat 4.8.5-44)"
    CPPFLAGS                 :  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
    CFLAGS                   : -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
                               -fexceptions -fstack-protector-strong
                               --param=ssp-buffer-size=4
                               -grecord-gcc-switches -m64 -mtune=generic
                               -fstack-protector-strong -pipe
                               -finline-functions -fsigned-char -Wall
                               -Wwrite-strings -Wmissing-prototypes
                               -Wno-format-y2k
    LD                       : /usr/bin/ld -m elf_x86_64
    LDFLAGS                  : -Wl,-z,relro  -Wl,-z,relro,-z,now,-O1
    
    information GnuCOBOL
    COB_CC                   : gcc
    COB_CFLAGS               : -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
                               -fexceptions -fstack-protector-strong
                               --param=ssp-buffer-size=4
                               -grecord-gcc-switches -m64 -mtune=generic
                               -fstack-protector-strong -pipe
                               -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
                               -I/usr/include -Wno-unused -fsigned-char
                               -Wno-pointer-sign -O
    COB_DEBUG_FLAGS          : -ggdb3 -fasynchronous-unwind-tables
    COB_LDFLAGS              : -Wl,-z,relro -fstack-protector-strong
    COB_LIBS                 : -L/usr/lib64 -lcob
    COB_CONFIG_DIR           : /usr/share/gnucobol/config
    COB_COPY_DIR             : /usr/share/gnucobol/copy
    COB_MSG_FORMAT           : GCC
    COB_OBJECT_EXT           : o
    COB_MODULE_EXT           : so
    COB_EXE_EXT              :
    64bit-mode               : oui
    BINARY-C-LONG            : 8 octets
    boutisme                 : petit-boutiste
    EBCDIC natif             : non
    E/S Úcran Útendue        : ncursesw
    fichier de format variab : 0
    gestionnaire de fichier  : integre
    gestionnaire de fichier  : BDB
    bibliothŔque mathÚmatiqu : GMP
    bibliothŔque XML         : libxml2
    bibliothŔque JSON        : json-c
    

    For information , our configuration under RHEL9.4:

    cobc (GnuCOBOL) 3.2.0
    Copyright (C) 2023 Free Software Foundation, Inc.
    Licence GPLv3+ : GNU GPL version 3 ou ultérieure <https://gnu.org/licenses/gpl.html>
    Ceci est un logiciel libre; consultez les sources pour les conditions de copie.
    Il n'y a AUCUNE garantie; pas même pour la COMMERCIALISATION ou l'ADÉQUATION À UN
    BESOIN PARTICULIER.
    Écrit par Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
    Compilé   Jul 28 2023 00:00:00
    Empaqueté Jul 28 2023 17:02:56 UTC
    Version C "11.3.1 20221121 (Red Hat 11.3.1-4)"
    
    information de compilation
    environnement de compila : x86_64-redhat-linux-gnu
    CC                       : gcc
    Version C                : "11.3.1 20221121 (Red Hat 11.3.1-4)"
    CPPFLAGS                 :  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
    CFLAGS                   : -O2 -fexceptions -g -grecord-gcc-switches
                               -pipe -Wall -Werror=format-security
                               -Wp,-D_FORTIFY_SOURCE=2
                               -Wp,-D_GLIBCXX_ASSERTIONS
                               -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
                               -fstack-protector-strong
                               -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
                               -m64 -march=x86-64-v2 -mtune=generic
                               -fasynchronous-unwind-tables
                               -fstack-clash-protection -fcf-protection
                               -fstack-protector-strong -pipe
                               -finline-functions -fsigned-char -Wall
                               -Wwrite-strings -Wmissing-prototypes
                               -Wno-format-y2k
    LD                       : /usr/bin/ld -m elf_x86_64
    LDFLAGS                  : -Wl,-z,relro -Wl,--as-needed -Wl,-z,now
                               -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
                               -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
                               -Wl,-z,relro,-z,now,-O1
    
    information GnuCOBOL
    COB_CC                   : gcc
    COB_CFLAGS               : -fexceptions -grecord-gcc-switches -pipe
                               -Wall -Werror=format-security
                               -Wp,-D_FORTIFY_SOURCE=2
                               -Wp,-D_GLIBCXX_ASSERTIONS
                               -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
                               -fstack-protector-strong
                               -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
                               -m64 -march=x86-64-v2 -mtune=generic
                               -fstack-clash-protection -fcf-protection
                               -fstack-protector-strong -pipe
                               -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
                               -I/usr/include -Wno-unused -fsigned-char
                               -Wno-pointer-sign -O
    COB_DEBUG_FLAGS          : -ggdb3 -fasynchronous-unwind-tables
    COB_LDFLAGS              : -Wl,-z,relro -Wl,--as-needed -Wl,-z,now
                               -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
                               -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
                               -fstack-protector-strong
    COB_LIBS                 : -L/usr/lib64 -lcob
    COB_CONFIG_DIR           : /usr/share/gnucobol/config
    COB_COPY_DIR             : /usr/share/gnucobol/copy
    COB_MSG_FORMAT           : GCC
    COB_OBJECT_EXT           : o
    COB_MODULE_EXT           : so
    COB_EXE_EXT              : 
    64bit-mode               : oui
    BINARY-C-LONG            : 8 octets
    boutisme                 : petit-boutiste
    EBCDIC natif             : non
    E/S écran étendue      : ncursesw
    fichier de format variab : 0
    gestionnaire de fichier  : intégré
    gestionnaire de fichier  : BDB
    bibliothèque mathémati : GMP
    bibliothèque XML        : libxml2
    bibliothèque JSON       : json-c
    

    and under Windows 11-64 (installled from Superbol binaries):

    cobc (GnuCOBOL) 3.3-dev.0
    Copyright (C) 2023 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
    Built     Mar 06 2024 10:59:48
    Packaged  Mar 06 2024 09:58:52 UTC
    C version (MinGW) "13.2.0"
    
    build information
    build environment        : x86_64-pc-mingw64
    CC                       : gcc
    C version                : (MinGW) "13.2.0"
    CPPFLAGS                 :
    CFLAGS                   : -O2 -pipe -finline-functions -fsigned-char
                               -Wall -Wwrite-strings -Wmissing-prototypes
                               -Wno-format-y2k
    LD                       : ld.exe
    LDFLAGS                  :
    
    GnuCOBOL information
    COB_CC                   : gcc
      env: COB_CC            : C:\Users\alain\AppData\Local\GnuCOBOL\mingw64\bin\gcc.exe
    COB_CFLAGS               : -pipe -Wno-unused -fsigned-char
                               -Wno-pointer-sign
      env: COB_CFLAGS        : -I
                               "C:\Users\alain\AppData\Local\GnuCOBOL\include"
                               -pipe -Wno-unused -fsigned-char
                               -Wno-pointer-sign
    COB_DEBUG_FLAGS          : -ggdb3 -fasynchronous-unwind-tables
    COB_LDFLAGS              :
      env: COB_LDFLAGS       : -L "C:\Users\alain\AppData\Local\GnuCOBOL\lib"
    COB_LIBS                 : -lcob
    COB_CONFIG_DIR           : config
      env: COB_CONFIG_DIR    : C:\Users\alain\AppData\Local\GnuCOBOL\config
    COB_COPY_DIR             : copy
      env: COB_COPY_DIR      : C:\Users\alain\AppData\Local\GnuCOBOL\copy
    COB_MSG_FORMAT           : GCC
    COB_OBJECT_EXT           : o
    COB_MODULE_EXT           : dll
    COB_EXE_EXT              : exe
    64bit-mode               : yes
    BINARY-C-LONG            : 4 bytes
    endianness               : little-endian
    native EBCDIC            : no
    extended screen I/O      : ncursesw
    variable file format     : 0
    sequential file handler  : built-in
    indexed file handler     : BDB
    mathematical library     : GMP
    XML library              : libxml2
    JSON library             : cjson
    

    I thought that from version 3, split keys where implemented.
    They all are under BDB as file handler.

    Best regards,

    Alain

     
    • Simon Sobisch

      Simon Sobisch - 2024-05-21

      Yes, split keys are implemented and should work fine with BDB as well.

      I assume that the Linux builds were done from source of the release tarball?
      If yes, what is the result of "make checkall" - any reported failures?

       
  • Alain Reymond

    Alain Reymond - 2024-05-21

    The Linux versions were not built from the tarball but come from the EPEL repo : EPEL 9 for x86_64, EPEL 8 for x86_64 and EPEL 7 for x86_64.
    They were install from the rpm files : gnucobol-3.2-1.el9.x86_64.rpm (el8, e7 respectively) and worked out of the box ... or almost!

     
  • Alain Reymond

    Alain Reymond - 2024-05-22

    I think that I found the problem!
    A file is declared so :

               select bilans assign to "bilans"
                   organization indexed
                   access dynamic
                   record key b-clefbil9
                   alternate record key b-idp with duplicates
                   alternate record key b-med with duplicates
                   alternate record key split-facture = b-aaaa b-numfacture with duplicates
                   file status bilans-status.
    

    When the program is compiled so:

    cobc -x convertfiles.cbl
    

    no compilation error is returned although the line " alternate record key split-facture = b-aaaa b-numfacture with duplicates" is longer than 78 chars. The executable is generated but the program returns an error 22 when trying to write data in the indexed file because many the values of "split-facture" field are not unique.
    It seems that the "with duplicates" clause in simply ignored.

    When compiled:

    cobc -x --free convertfiles.cbl
    

    the program runs correctly and does not return any error when adding records to the indexed file.

    The same is reproduced under gnucobol 3.2 for Linux, 3.3 for Windows.

    Attached : a small program and a text file with values.

    Can you reproduce that ?

    Regards,

    Alain

     
    • Mickey White

      Mickey White - 2024-05-22

      It is as you say. I would think? that it would at least issue a warning if you are Not useing -free and there is text past column 80. I know documentation says this:

      -ftext-column=72..255  right margin column number for fixed-form reference-format
      

      But still a warning would be nice?

       

      Last edit: Mickey White 2024-05-22
      • Alain Reymond

        Alain Reymond - 2024-05-22

        Ok, so I was not the only one!
        This should raise an error during compilation.
        @sf-mensch : is it a problem that should be reported as a bug ?
        Regards,
        Alain

         
  • Ralph Linkletter

    . . .
    alternate record key split-facture =
    b-aaaa b-numfacture with duplicates
    file status bilans-status.

    I presume the above restructure, into REAL Cobol, would obviate the need for --free

     
    • Mickey White

      Mickey White - 2024-05-22

      yes that is the fix.

       
    • Alain Reymond

      Alain Reymond - 2024-05-22

      Yes of course. But a compilation error or at least a warning should be raised. No error is reported, so you think the generated executable is correct although its behaviour does not match the program specification concerning the duplicates in the split key.
      Anyway, it is good to know what happens!

       
      👍
      1
      • Vincent (Bryan) Coen

        On 22/05/2024 15:44, Alain REYMOND wrote:

        Yes of course. But a compilation error or at least a warning should be
        raised. No error is reported, so you think the generated executable is
        correct although its behaviour does not match the program
        specification concerning the duplicates in the split key.
        Anyway, it is good to know what happens!

        If you use FIXED format but without any text in cc 72 - 80 I would
        recommend the first line of code in source contains :

        source variable  starting cc8.  I migrated over a system using fixed
        where some lines went over cc72 but none used cc72 -80 normally and that
        fixed it.

         
        👍
        1

Anonymous
Anonymous

Add attachments
Cancel