home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / tarv314.zip / RESETLOG.CMD < prev    next >
OS/2 REXX Batch file  |  1992-12-04  |  111KB  |  2,347 lines

  1. /******************************************************************
  2. *  MODULE NAME:      RESETLOG                                     *
  3. *                                                                 *
  4. *  DESCRIPTIVE NAME: Reset the Log Control File                   *
  5. *                                                                 *
  6. *  LPP NAME:         Standalone Tool                              *
  7. *                                                                 *
  8. *  DESCRIPTION: This routine provides a mechanism for resetting   *
  9. *               or initializing the Log Control File to a state   *
  10. *               in which it appears that the database no longer   *
  11. *               needs recovery.                                   *
  12. *                                                                 *
  13. *               Caution should be exercised in using this tool    *
  14. *               because it will prevent any committed changes     *
  15. *               which did not make it to media from being         *
  16. *               recovered in the database.  As a result, there    *
  17. *               could be index and table mismatches and           *
  18. *               referential integrity violations.                 *
  19. *                                                                 *
  20. *  DEPENDENCIES:                                                  *
  21. *    SYSTEM CONFIRUATION:                                         *
  22. *      - OS/2 EE 1.2+                                             *
  23. *                                                                 *
  24. *    LANGUAGE INTERPRETER:                                        *
  25. *      - OS/2 Rexx Interpreter                                    *
  26. *                                                                 *
  27. *    PREREQUISTIES: None                                          *
  28. *                                                                 *
  29. *                                                                 *
  30. *  RESTRICTIONS: None                                             *
  31. *                                                                 *
  32. *  INPUT:  Database name                                          *
  33. *                                                                 *
  34. *                                                                 *
  35. *  OUTPUT: Log Control File reset.                                *
  36. *          Usable database.                                       *
  37. *                                                                 *
  38. *                                                                 *
  39. *  HOST LANGUAGE: OS/2 Rexx                                       *
  40. *                                                                 *
  41. *  LAST CHANGE DATE: Version 1.4 09/29/91                         *
  42. *                                                                 *
  43. *                                                                 *
  44. ******************************************************************/
  45.  
  46. parse upper arg  dbname rptname
  47.  
  48.  
  49. '@echo off'
  50.  
  51. TRACE OFF
  52.  
  53. numeric digits 15            /* Set precision for arithmetic operations */
  54. dbpath = ''                  /* Initialize database path specification  */
  55. logpath = ''                 /* Initialize log path specification       */
  56. cr_lf = d2c(13) || d2c(10)   /* Line End characters                     */
  57. report_open = 'NO'           /* Initialize Report Open Indicator        */
  58.  
  59.  
  60. /*********************************************
  61.    Check the Program Input Arguments
  62. *********************************************/
  63. if dbname = '?' then
  64.   do
  65.     call general_help
  66.     signal xit
  67.   end
  68.  
  69. else   /* No Help requested, so check the input parameters */
  70.   call chkargs
  71.  
  72.  
  73. 'cls'
  74. say '     '
  75. say ,
  76.     " ╔══════════════════════════════════════════════════════════════════════╗ "
  77. say ,
  78.     " ║    **  NOTICE  **  NOTICE  **  NOTICE  **  NOTICE  **  NOTICE  **    ║ "
  79. say ,
  80.     " ║                                                                      ║ "
  81. say ,
  82.     " ║        THE LOG CONTROL FILE IS ABOUT TO BE RESET !!                  ║ "
  83. say ,
  84.     " ║                                                                      ║ "
  85. say ,
  86.     " ║        Caution:  This should only be done as a very last resort.     ║ "
  87. say ,
  88.     " ║                  It will prevent all committed changes in the        ║ "
  89. say ,
  90.     " ║                  Write-Ahead Log from being applied to the database. ║ "
  91. say ,
  92.     " ║                                                                      ║ "
  93. say ,
  94.     " ║         ┌─────────────────────────────────────────────────┐          ║ "
  95. say ,
  96.     " ║         │      WARNING:  Data Integrity may be lost.      │          ║ "
  97. say ,
  98.     " ║         └─────────────────────────────────────────────────┘          ║ "
  99. say ,
  100.     " ║                                                                      ║ "
  101. say ,
  102.     " ║        Would you like to Reset the Log Control File now? (y/n)       ║ "
  103. say ,
  104.     " ║           If so, type 'y' and press ENTER;                           ║ "
  105. say ,
  106.     " ║           Otherwise, type 'n' and press ENTER.                       ║ "
  107. say ,
  108.     " ╚══════════════════════════════════════════════════════════════════════╝ "
  109. say "      "
  110. say "      "
  111. pull reset_decision
  112.  
  113. if reset_decision = 'Y' then
  114.   do
  115.  
  116.     /*********************************************
  117.        Determine the Database Subdirectory
  118.     *********************************************/
  119.     say '....Scanning the Database Directory'
  120.     call getddir
  121.     if dbpath = '' then
  122.       call errxit 'The database was not found on the file system.'
  123.  
  124.  
  125.     /*********************************************
  126.        Construct the Database Configuration File
  127.     *********************************************/
  128.     dbcon_name = dbpath || 'SQLDBCON'
  129.  
  130.  
  131.     /*********************************************
  132.        Check Existence of Configuration File
  133.     *********************************************/
  134.     rc = stream(dbcon_name, 'c', 'query exist')
  135.  
  136.     if rc = '' then
  137.       do
  138.         call errxit  'The Database Configuration File could not be found.'
  139.       end
  140.  
  141.  
  142.     /*********************************************
  143.        Open the Report File if specified
  144.     *********************************************/
  145.     if rptname \= '' then
  146.       do
  147.         rc = stream(rptname, 'c', 'open')
  148.  
  149.         if (rc \= 'READY:') & (rc \= 'READY') then
  150.           do
  151.             call errxit  'The Report File could not be opened.'
  152.           end
  153.  
  154.         report_open = 'YES'        /* Report is now Open Indicator */
  155.  
  156.         /*********************************************
  157.            Set the Write Cursor to Append to the Report File
  158.         *********************************************/
  159.         /* Locate the last byte in the file */
  160.         eofpos = stream(rptname, 'c', 'query size')
  161.  
  162.         /* Make sure the file is not empty before reading
  163.                the last byte */
  164.         if eofpos > 0 then
  165.           do
  166.  
  167.             /* Position the Write Cursor on the last byte
  168.                  of the file if it is an EOF control;
  169.                  otherwise leave the Write Cursor positioned
  170.                  after the last byte */
  171.             if charin(rptname, eofpos, 1) = x2c('1A') then
  172.               r = stream(rptname, 'c', 'seek -1')
  173.  
  174.           end
  175.  
  176.         /*********************************************
  177.            Write the Report File Header
  178.         *********************************************/
  179.  
  180.         call rpthdr
  181.  
  182.       end
  183.  
  184.     /*********************************************
  185.        Open the Database Configuration File
  186.     *********************************************/
  187.     rc = stream(dbcon_name, 'c', 'open')
  188.  
  189.     if (rc \= 'READY:') & (rc \= 'READY') then
  190.       do
  191.         call errxit  'The Database Configuration File could not be opened.'
  192.       end
  193.  
  194.     /*********************************************
  195.        Find the Path to the Log Files
  196.     *********************************************/
  197.     say '....Examining the Database Configuration'
  198.     call findlog
  199.  
  200.     /*********************************************
  201.        Close the Database Configuration File
  202.     *********************************************/
  203.     rc = stream(dbcon_name, 'c', 'close')
  204.  
  205.     /*********************************************
  206.        Construct Log Control File Name
  207.        Note: The Log Control File should exist in
  208.                the database subdirectory.
  209.     *********************************************/
  210.  
  211.     if stream(dbpath || 'SQLOGCTL.LFH', 'c', 'query exist') = '' then
  212.       call errxit  'The Log Control File could not be found.'
  213.     else
  214.       /* Construct the Log Control File Name */
  215.       logctl_name = dbpath || 'SQLOGCTL.LFH'
  216.  
  217.     /*********************************************
  218.        Open the Log Control File
  219.     *********************************************/
  220.     rc = stream(logctl_name, 'c', 'open')
  221.  
  222.     if (rc \= 'READY:') & (rc \= 'READY') then
  223.       do
  224.         call errxit  'The Log Control File could not be opened.'
  225.       end
  226.  
  227.     /*********************************************
  228.        Reset the Log Control File
  229.     *********************************************/
  230.     call reset
  231.  
  232.     /*********************************************
  233.        Close the Log Control File
  234.     *********************************************/
  235.       rc = stream(logctl_name, 'c', 'close')
  236.  
  237.     /*********************************************
  238.        Successful Program Completion
  239.     *********************************************/
  240.     say '     '
  241.     say 'The Reset Log Tool completed.'
  242.  
  243.     signal finish
  244.  
  245.   end
  246.  
  247. else  /* User chose not to reset the Log Control File */
  248.  
  249.   say 'Program terminated by user  --  Log Control File not reset.'
  250.  
  251.  
  252.  
  253. /*********************************************
  254.             PROGRAM  EXITS
  255. *********************************************/
  256.  
  257.  
  258. /*********************************************
  259.    Final Program Clean-Up
  260. *********************************************/
  261. finish:
  262.  
  263.   /*********************************************
  264.      Close the Report File if specified
  265.   *********************************************/
  266.   if report_open = 'YES' then
  267.     rc = stream(rptname, 'c', 'close')
  268.  
  269. xit:
  270.  
  271.   /* Exit the program */
  272.   exit
  273.  
  274.  
  275.  
  276. /*********************************************
  277.    RESETLOG Error Exit
  278. *********************************************/
  279. errxit:
  280.  
  281.   parse arg msg_text
  282.  
  283.   /* Display the Error Message */
  284.   say '     '
  285.   say msg_text
  286.  
  287.   /* Complete the Tool Cleanup */
  288.   signal finish
  289.  
  290.  
  291.   return
  292.  
  293. /*********************************************
  294.    SQL (Database Manager) Error Exit
  295. *********************************************/
  296. sqlxit:
  297.  
  298.   /* Get the formatted SQL message */
  299.   call SQLDBS 'GET MESSAGE INTO :sql_msg LINEWIDTH 70'
  300.   if result = 0 then
  301.     do
  302.       /* Formatting successful - Display formatted message */
  303.       say '     '
  304.       say sql_msg
  305.     end
  306.   else
  307.     do
  308.       /* Formatting unsuccessful - Display unformatted message */
  309.       say '     '
  310.       say SQLMSG
  311.     end
  312.  
  313.  
  314.   /* Complete the Tool Cleanup */
  315.   signal finish
  316.  
  317.  
  318.   return
  319.  
  320.  
  321. /*********************************************
  322.               SUBROUTINES
  323. *********************************************/
  324.  
  325.  
  326. /******************************************************************
  327. *  SUBROUTINE:   CHKARGS                                          *
  328. *                                                                 *
  329. *  DESCRIPTIVE NAME: Check the Program Input Arguments            *
  330. *                                                                 *
  331. *  DESCRIPTION: This routine checks the validity of the input     *
  332. *               arguments for the program.  If any arguments      *
  333. *               are not specified, then the user is prompted to   *
  334. *               type the required argument.                       *
  335. *                                                                 *
  336. *  INPUT: none                                                    *
  337. *                                                                 *
  338. *                                                                 *
  339. *  OUTPUT: none                                                   *
  340. *                                                                 *
  341. ******************************************************************/
  342.  
  343. chkargs:
  344.  
  345. if dbname = '' then      /* Prompt for the Database name if not input */
  346.   do
  347.     'cls'
  348.     say "     "
  349.     say ,
  350.     " ╔══════════════════════════════════════════════════════════════════════╗ "
  351.     say ,
  352.     " ║                                                                      ║ "
  353.     say ,
  354.     " ║  Please type the input Database Name and press ENTER:                ║ "
  355.     say ,
  356.     " ║                                                                      ║ "
  357.     say ,
  358.     " ╚══════════════════════════════════════════════════════════════════════╝ "
  359.     say "      "
  360.     say "      "
  361.     pull dbname
  362.   end
  363.  
  364.  
  365.  
  366.  
  367. return
  368.  
  369.  
  370.  
  371.  
  372. /******************************************************************
  373. *  SUBROUTINE:   GETDDIR                                          *
  374. *                                                                 *
  375. *  DESCRIPTIVE NAME: Get the Database Directory                   *
  376. *                                                                 *
  377. *  DESCRIPTION: This routine scans the System Database Directory  *
  378. *               to determine the Drive containing the specified   *
  379. *               database.  If it finds the database on a local    *
  380. *               volume, then it calls another routine to          *
  381. *               scan the Volume Database Directory to determine   *
  382. *               the subdirectory containing the database.         *
  383. *                                                                 *
  384. *                                                                 *
  385. *  INPUT: none                                                    *
  386. *                                                                 *
  387. *                                                                 *
  388. *  OUTPUT: none                                                   *
  389. *                                                                 *
  390. ******************************************************************/
  391.  
  392. getddir:
  393.  
  394. /*********************************************
  395.    Register SQLDBS with REXX
  396. *********************************************/
  397. /* Check if SQLDBS function is currently registered */
  398. if Rxfuncquery('SQLDBS') \= 0 then
  399.    do
  400.      /* Register SQLDBS function */
  401.      rcy = Rxfuncadd('SQLDBS','SQLAR','SQLDBS')
  402.  
  403.      if rcy \= 0 then
  404.         call errxit 'Database Manager registration error'
  405.    end  /* end if */
  406.  
  407. /*********************************************
  408.    Register SQLEXEC with REXX
  409. *********************************************/
  410. /* Check if SQLEXEC function is currently registered */
  411. if Rxfuncquery('SQLEXEC') \= 0 then
  412.    do
  413.      /* Register SQLEXEC function */
  414.      rcy = Rxfuncadd('SQLEXEC','SQLAR','SQLEXEC')
  415.  
  416.      if rcy \= 0 then
  417.         call errxit 'Database Manager registration error'
  418.    end  /* end if */
  419.  
  420.  
  421. /*********************************************
  422.    Scan System Directory for Database Name
  423. *********************************************/
  424. call SQLDBS 'open database directory on 0 using :dhandle'
  425. if sqlca.sqlcode < 0 then
  426.   signal sqlxit
  427.  
  428. do while sqlca.sqlcode = 0
  429.    call SQLDBS 'get database directory entry :dhandle.1'
  430.    if sqlca.sqlcode = 0 then
  431.      do
  432.        if SQLDINFO.1 = dbname then
  433.          do
  434.            db_drive = SQLDINFO.3
  435.            dbname = strip(dbname)
  436.            call scanvol
  437.            leave
  438.          end
  439.      end
  440. end
  441.  
  442. call SQLDBS 'close database directory :dhandle.1'
  443.  
  444. return
  445.  
  446.  
  447.  
  448.  
  449. /******************************************************************
  450. *  SUBROUTINE:   SCANVOL                                          *
  451. *                                                                 *
  452. *  DESCRIPTIVE NAME: Scan the Volume Database Directory           *
  453. *                                                                 *
  454. *  DESCRIPTION: This routine scans the Volume Database Directory  *
  455. *               to determine the Subdirectory containing the      *
  456. *               specified database.                               *
  457. *                                                                 *
  458. *                                                                 *
  459. *  INPUT: none                                                    *
  460. *                                                                 *
  461. *                                                                 *
  462. *  OUTPUT: none                                                   *
  463. *                                                                 *
  464. ******************************************************************/
  465.  
  466. scanvol:
  467.  
  468. /* Scan volume directory for name */
  469.  
  470. dbpath = ''
  471.  
  472. call SQLDBS 'open database directory on 'left(db_drive,1)' using :vhandle'
  473. if sqlca.sqlcode = 0 then
  474.  do
  475.  
  476.    do forever
  477.      call SQLDBS 'get database directory entry :vhandle.1'
  478.      if SQLCA.SQLCODE = 1014 then
  479.       do
  480.         say 'No entry found in volume directory for drive 'db_drive'...'
  481.         leave
  482.       end
  483.      if SQLDINFO.1 = dbname then
  484.       do
  485.         dbdir = SQLDINFO.4
  486.         leave
  487.       end
  488.    end
  489.  
  490.    call SQLDBS 'close database directory :vhandle.1'
  491.  
  492.    dbpath = db_drive'\'dbdir'\'
  493.  end
  494.  
  495. return
  496.  
  497.  
  498.  
  499. /******************************************************************
  500. *  SUBROUTINE:   RPTHDR                                           *
  501. *                                                                 *
  502. *  DESCRIPTIVE NAME: Write the Report File Header                 *
  503. *                                                                 *
  504. *  DESCRIPTION: This routine writes the information that appears  *
  505. *               at the beginning of the Report for a given        *
  506. *               execution of RESETLOG.                            *
  507. *                                                                 *
  508. *               Note: The Report File must already be opened.     *
  509. *                                                                 *
  510. *  INPUT: none                                                    *
  511. *                                                                 *
  512. *                                                                 *
  513. *  OUTPUT: none                                                   *
  514. *                                                                 *
  515. ******************************************************************/
  516.  
  517. rpthdr:
  518.  
  519.   /* Define Various text lines for the Report */
  520.   eqlines = '==================================================' || ,
  521.             '============================'
  522.   ttline = '       RESETLOG (V 3.1)  Report   -   ' || date('N') || '   ' || ,
  523.                                                   time('C')
  524.   dbline  = '                     Database:  ' || dbname
  525.   dbpline = '                Database Path:  ' || dbpath
  526.   seplines = '--------------------------------------------------' || ,
  527.              '----------------------------'
  528.  
  529.   /* Construct the Report Header text */
  530.   rpthdr_text = '     '  || cr_lf || ,
  531.                 '     '  || cr_lf || ,
  532.                 eqlines  || cr_lf || ,
  533.                 eqlines  || cr_lf || ,
  534.                 eqlines  || cr_lf || ,
  535.                 eqlines  || cr_lf || ,
  536.                 '     '  || cr_lf || ,
  537.                 '     '  || cr_lf || ,
  538.                 ttline   || cr_lf || ,
  539.                 '     '  || cr_lf || ,
  540.                 '     '  || cr_lf || ,
  541.                 dbline   || cr_lf || ,
  542.                 '     '  || cr_lf || ,
  543.                 '     '  || cr_lf || ,
  544.                 seplines || cr_lf || ,
  545.                 seplines || cr_lf || ,
  546.                 '     '  || cr_lf || ,
  547.                 '     '  || cr_lf
  548.  
  549.  
  550.   /* Write the Report Header to the Report File */
  551.   call wrt2rpt  rpthdr_text
  552.  
  553.  
  554. return
  555.  
  556.  
  557.  
  558. /******************************************************************
  559. *  SUBROUTINE:   WRT2RPT                                          *
  560. *                                                                 *
  561. *  DESCRIPTIVE NAME: Write to the Report File                     *
  562. *                                                                 *
  563. *  DESCRIPTION: This routine provides a common routine for        *
  564. *               writing information to the Report File.  This     *
  565. *               routine checks to verify that the Report File     *
  566. *               was specified as input to the tool and was        *
  567. *               subsequently opened before writing the data.      *
  568. *                                                                 *
  569. *  INPUT:  Text to be written to the Report File                  *
  570. *                                                                 *
  571. *                                                                 *
  572. *  OUTPUT: none                                                   *
  573. *                                                                 *
  574. ******************************************************************/
  575.  
  576. wrt2rpt:
  577.  
  578.   parse arg report_text
  579.  
  580.   if report_open = 'YES' then
  581.     do
  582.       rc = lineout(rptname, report_text)
  583.     end
  584.  
  585.  
  586. return
  587.  
  588.  
  589.  
  590. /******************************************************************
  591. *  SUBROUTINE:   FINDLOG                                          *
  592. *                                                                 *
  593. *  DESCRIPTIVE NAME: Find the Path to the Log Files               *
  594. *                                                                 *
  595. *  DESCRIPTION: This routine determines the path containing the   *
  596. *               Log files for the database.                       *
  597. *                                                                 *
  598. *                                                                 *
  599. *  INPUT: none                                                    *
  600. *                                                                 *
  601. *                                                                 *
  602. *  OUTPUT: none                                                   *
  603. *                                                                 *
  604. ******************************************************************/
  605.  
  606. findlog:
  607.  
  608.  
  609. /*********************************************
  610.    Define Offsets to Fields in the Database
  611.            Configuration File
  612. *********************************************/
  613. call defoff_dbcon
  614.  
  615. /*********************************************
  616.    Get Data in the Database Configuration File
  617. *********************************************/
  618. call getdata_dbcon
  619.  
  620. /*********************************************
  621.    Determine the Path to the Log Files
  622. *********************************************/
  623. say '....Determining Log File Location'
  624. call getlogpath
  625.  
  626.  
  627. return
  628.  
  629.  
  630. /******************************************************************
  631. *  SUBROUTINE:   DEFOFF_DBCON                                     *
  632. *                                                                 *
  633. *  DESCRIPTIVE NAME: Define Offsets to Fields in Database Config  *
  634. *                                                                 *
  635. *  DESCRIPTION: This routine defines the offsets for the fields   *
  636. *               in the Database Configuration File.               *
  637. *                                                                 *
  638. *  INPUT: none                                                    *
  639. *                                                                 *
  640. *                                                                 *
  641. *  OUTPUT: none                                                   *
  642. *                                                                 *
  643. ******************************************************************/
  644.  
  645. defoff_dbcon:
  646.  
  647. /*********************************************
  648.    Define Page Offset Constants
  649.       (Note: These offsets are 1-origin from the Start of the Page)
  650.       (Note: The length values are in terms of character bytes.)
  651. *********************************************/
  652. dbcon  =  1            /* Offset to the Database Configuration */
  653.  
  654. /*********************************************
  655.    Define Offsets within the Database Configuration Description
  656.       (Note: These offsets are 0-origin from the Start of the
  657.                     Database Configuration File.)
  658. *********************************************/
  659. dbc_chksumo =  0               /* Checksum field offset                      */
  660. dbc_chksuml =  4               /*                length                      */
  661.  
  662. dbc_titleo =  4                /* Title field offset                         */
  663. dbc_titlel =  12               /*             length                         */
  664.  
  665. dbc_relo  =  16                /* Release field offset                       */
  666. dbc_rell  =  2                 /*               length                       */
  667.  
  668. dbc_pad1o =  18                /* Pad for Long Boundary field offset         */
  669. dbc_pad1l =  2                 /*                             length         */
  670.  
  671. dbc_logsizo =  20              /* Log File Size (4K Pages) field offset      */
  672. dbc_logsizl =  4               /*                                length      */
  673.  
  674. dbc_logexto =  24              /* Log File Extent Size field offset          */
  675. dbc_logextl =  4               /*                            length          */
  676.  
  677. dbc_maxexto =  28              /* Max Extents field offset                   */
  678. dbc_maxextl =  4               /*                   length                   */
  679.  
  680. dbc_dlchko =  32               /* Deadlock Check Interval field offset       */
  681. dbc_dlchkl =  4                /*                               length       */
  682.  
  683. dbc_mseedo =  36               /* Database Seed (masked) field offset        */
  684. dbc_mseedl =  4                /*                              length        */
  685.  
  686. dbc_pad2o =  40                /* Pad field offset                           */
  687. dbc_pad2l =  4                 /*           length                           */
  688.  
  689. dbc_unseedo =  44              /* Unmasked Database Seed field offset        */
  690. dbc_unseedl =  4               /*                              length        */
  691.  
  692. dbc_stmpo =  48                /* Timestamp field offset                     */
  693. dbc_stmpl =  10                /*                 length                     */
  694.  
  695. dbc_lcklsto =  58              /* Maximum Storage for LockList offset        */
  696. dbc_lcklstl =  2               /*                              length        */
  697.  
  698. dbc_buffo =  60                /* Size of buffer pool offset                 */
  699. dbc_buffl =  2                 /*                     length                 */
  700.  
  701. dbc_maxfilo =  62              /* Max Db Files Open per appl offset          */
  702. dbc_maxfill =  2               /*                            length          */
  703.  
  704. dbc_softo =  64                /* No. records before Soft Chkpt offset       */
  705. dbc_softl =  2                 /*                               length       */
  706.  
  707. dbc_maxappo =  66              /* Max active applications offset             */
  708. dbc_maxappl =  2               /*                         length             */
  709.  
  710. dbc_apheapo =  68              /* Application Heap Size offset               */
  711. dbc_apheapl =  2               /*                       length               */
  712.  
  713. dbc_dbheapo =  70              /* Database Heap Size offset                  */
  714. dbc_dbheapl =  2               /*                    length                  */
  715.  
  716. dbc_cntryo =  72               /* Country Code of Application offset         */
  717. dbc_cntryl =  2                /*                             length         */
  718.  
  719. dbc_cpago =  74                /* Code Page of Application offset            */
  720. dbc_cpagl =  2                 /*                          length            */
  721.  
  722. dbc_agheapo =  76              /* Application Agent Heap Size offset         */
  723. dbc_agheapl =  2               /*                             length         */
  724.  
  725. dbc_maxtoto =  78              /* Max Total Files Open offset                */
  726. dbc_maxtotl =  2               /*                      length                */
  727.  
  728. dbc_slheapo =  80              /* Sort List Heap Size offset                 */
  729. dbc_slheapl =  2               /*                     length                 */
  730.  
  731. dbc_rdso  =  82                /* RDS Version Indicator offset               */
  732. dbc_rdsl  =  2                 /*                       length               */
  733.  
  734. dbc_pctlckso =  84             /* % of Total LockList per appl offset        */
  735. dbc_pctlcksl =  2              /*                              length        */
  736.  
  737. dbc_stheapo =  86              /* Statement Heap Size offset                 */
  738. dbc_stheapl =  2               /*                     length                 */
  739.  
  740. dbc_plogo =  88                /* Number of Primary Log Files offset         */
  741. dbc_plogl =  2                 /*                             length         */
  742.  
  743. dbc_slogo =  90                /* Number of Secondary Log Files offset       */
  744. dbc_slogl =  2                 /*                               length       */
  745.  
  746. dbc_lfsizo =  92               /* Log File Size offset                       */
  747. dbc_lfsizl =  2                /*               length                       */
  748.  
  749. dbc_logpatho =  94             /* Log File Path offset                       */
  750. dbc_logpathl =  248            /*               length                       */
  751.  
  752. dbc_newpatho =  342            /* Path to the Log File offset                */
  753. dbc_newpathl =  248            /*                      length                */
  754.  
  755. dbc_inflgo =  590              /* Internal Indicator/Status Flag offset      */
  756. dbc_inflgl =  2                /*                                length      */
  757.  
  758. dbc_exflgo =  592              /* External Indicator/Status Flag offset      */
  759. dbc_exflgl =  2                /*                                length      */
  760.  
  761. dbc_collseqo = 594             /* User-defined collating sequence offset     */
  762. dbc_collseql = 260             /*                                 length     */
  763.  
  764. dbc_pad3o =  854               /* Pad for Spare Bytes offset                 */
  765. dbc_pad3l =  8                 /*                     length                 */
  766.  
  767.  
  768. return
  769.  
  770.  
  771. /******************************************************************
  772. *  SUBROUTINE:   GETDATA_DBCON                                    *
  773. *                                                                 *
  774. *  DESCRIPTIVE NAME: Get Data from the Db Config File             *
  775. *                                                                 *
  776. *  DESCRIPTION: This routine retrieves the data from the          *
  777. *               Database Configuration File and stores the        *
  778. *               Database Configuration fields in variables.       *
  779. *                                                                 *
  780. *  INPUT: none                                                    *
  781. *                                                                 *
  782. *                                                                 *
  783. *  OUTPUT: none                                                   *
  784. *                                                                 *
  785. ******************************************************************/
  786.  
  787. getdata_dbcon:
  788.  
  789.  
  790. /*********************************************
  791.    Read the Database Configuration File
  792. *********************************************/
  793.  
  794.                                  /* Checksum                */
  795. dbc_chksum = c2d(reverse(charin(dbcon_name, dbcon+dbc_chksumo+2, 2)) || ,
  796.               reverse(charin(dbcon_name, dbcon+dbc_chksumo, 2)), 5)
  797.  
  798.                                  /* Title                   */
  799. dbc_title = charin(dbcon_name, dbcon+dbc_titleo, dbc_titlel)
  800.  
  801.                                  /* Release                 */
  802. dbc_rel = c2x(reverse(charin(dbcon_name, dbcon+dbc_relo, dbc_rell)))
  803.  
  804.                                  /* Log File Size           */
  805. dbc_logsiz = c2d(reverse(charin(dbcon_name, dbcon+dbc_logsizo+2, 2)) || ,
  806.               reverse(charin(dbcon_name, dbcon+dbc_logsizo, 2)), 5)
  807.  
  808.                                  /* Log File Extent Size    */
  809. dbc_logext = c2d(reverse(charin(dbcon_name, dbcon+dbc_logexto+2, 2)) || ,
  810.               reverse(charin(dbcon_name, dbcon+dbc_logexto, 2)), 5)
  811.  
  812.                                  /* Max No. of Extents      */
  813. dbc_maxext = c2d(reverse(charin(dbcon_name, dbcon+dbc_maxexto+2, 2)) || ,
  814.               reverse(charin(dbcon_name, dbcon+dbc_maxexto, 2)), 5)
  815.  
  816.                                  /* Deadlock Check Interval */
  817. dbc_dlchk = c2d(reverse(charin(dbcon_name, dbcon+dbc_dlchko+2, 2)) || ,
  818.               reverse(charin(dbcon_name, dbcon+dbc_dlchko, 2)), 5)
  819.  
  820.                                  /* Masked Database Seed    */
  821. dbc_mseed = c2d(reverse(charin(dbcon_name, dbcon+dbc_mseedo+2, 2)) || ,
  822.               reverse(charin(dbcon_name, dbcon+dbc_mseedo, 2)), 5)
  823.  
  824.                                  /* UnMasked Database Seed  */
  825. dbc_unseed = c2d(reverse(charin(dbcon_name, dbcon+dbc_unseedo+2, 2)) || ,
  826.               reverse(charin(dbcon_name, dbcon+dbc_unseedo, 2)), 5)
  827.  
  828.                                  /* Timestamp               */
  829. dbc_stmp = c2x(charin(dbcon_name, dbcon+dbc_stmpo, dbc_stmpl))
  830.  
  831.                                  /* Maximum Storage for Lock List  */
  832. dbc_lcklst = c2d(reverse(charin(dbcon_name, dbcon+dbc_lcklsto, dbc_lcklstl)))
  833.  
  834.                                  /* Size of Buffer Pool     */
  835. dbc_buff = c2d(reverse(charin(dbcon_name, dbcon+dbc_buffo, dbc_buffl)))
  836.  
  837.                                  /* Max Db Files Open per Appl     */
  838. dbc_maxfil = c2d(reverse(charin(dbcon_name, dbcon+dbc_maxfilo, dbc_maxfill)))
  839.  
  840.                                  /* No. Records before Soft Chkpt  */
  841. dbc_soft = c2d(reverse(charin(dbcon_name, dbcon+dbc_softo, dbc_softl)))
  842.  
  843.                                  /* Max Active Applications        */
  844. dbc_maxapp = c2d(reverse(charin(dbcon_name, dbcon+dbc_maxappo, dbc_maxappl)))
  845.  
  846.                                  /* Application Heap Size          */
  847. dbc_apheap = c2d(reverse(charin(dbcon_name, dbcon+dbc_apheapo, dbc_apheapl)))
  848.  
  849.                                  /* Database Heap Size             */
  850. dbc_dbheap = c2d(reverse(charin(dbcon_name, dbcon+dbc_dbheapo, dbc_dbheapl)))
  851.  
  852.                                  /* Country Code                   */
  853. dbc_cntry = c2d(reverse(charin(dbcon_name, dbcon+dbc_cntryo, dbc_cntryl)))
  854.  
  855.                                  /* Code Page                      */
  856. dbc_cpag = c2d(reverse(charin(dbcon_name, dbcon+dbc_cpago, dbc_cpagl)))
  857.  
  858.                                  /* Application Agent Heap Size    */
  859. dbc_agheap = c2d(reverse(charin(dbcon_name, dbcon+dbc_agheapo, dbc_agheapl)))
  860.  
  861.                                  /* Max Total Files Open           */
  862. dbc_maxtot = c2d(reverse(charin(dbcon_name, dbcon+dbc_maxtoto, dbc_maxtotl)))
  863.  
  864.                                  /* Sort List Heap Size            */
  865. dbc_slheap = c2d(reverse(charin(dbcon_name, dbcon+dbc_slheapo, dbc_slheapl)))
  866.  
  867.                                  /* RDS Version Indicator          */
  868. dbc_rds  = c2d(reverse(charin(dbcon_name, dbcon+dbc_rdso, dbc_rdsl)))
  869.  
  870.                                  /* %  of Total LockList per Appl  */
  871. dbc_pctlcks = c2d(reverse(charin(dbcon_name, dbcon+dbc_pctlckso, dbc_pctlcksl)))
  872.  
  873.                                  /* Statement Heap Size            */
  874. dbc_stheap = c2d(reverse(charin(dbcon_name, dbcon+dbc_stheapo, dbc_stheapl)))
  875.  
  876.                                  /* Number of Primary Log Files    */
  877. dbc_plog = c2d(reverse(charin(dbcon_name, dbcon+dbc_plogo, dbc_plogl)))
  878.  
  879.                                  /* Number of Secondary Log Files  */
  880. dbc_slog = c2d(reverse(charin(dbcon_name, dbcon+dbc_slogo, dbc_slogl)))
  881.  
  882.                                  /* Log File Size                  */
  883. dbc_lfsiz = c2d(reverse(charin(dbcon_name, dbcon+dbc_lfsizo, dbc_lfsizl)))
  884.  
  885.                                  /* Log File Path           */
  886. dbc_logpath = charin(dbcon_name, dbcon+dbc_logpatho, dbc_logpathl)
  887.  
  888.                                  /* New Log File Path       */
  889. dbc_newpath = charin(dbcon_name, dbcon+dbc_newpatho, dbc_newpathl)
  890.  
  891.                                  /* Internal Indicator/Status Flag */
  892. dbc_inflg = c2x(reverse(charin(dbcon_name, dbcon+dbc_inflgo, dbc_inflgl)))
  893.  
  894.                                  /* External Indicator/Status Flag */
  895. dbc_exflg = c2x(reverse(charin(dbcon_name, dbcon+dbc_exflgo, dbc_exflgl)))
  896.  
  897.  
  898.  
  899.  
  900. /*********************************************
  901.    Report the Contents of the Database
  902.      Configuration File
  903. *********************************************/
  904.  
  905. /* Get Binary representations of the Internal Indicators                     */
  906. dbc_inflg_mo = x2b(c2x(bitand(x2c(dbc_inflg), '0001'x)))   /* Log File Move  */
  907. dbc_inflg_lc = x2b(c2x(bitand(x2c(dbc_inflg), '0002'x)))   /* L -> C Xlate   */
  908. dbc_inflg_cl = x2b(c2x(bitand(x2c(dbc_inflg), '0004'x)))   /* C -> L Xlate   */
  909. dbc_inflg_sv = x2b(c2x(bitand(x2c(dbc_inflg), '0008'x)))   /* Svr Def Install*/
  910.  
  911. /* Get Binary representations of the External Indicators                     */
  912. dbc_exflg_cp = x2b(c2x(bitand(x2c(dbc_exflg), '0001'x)))   /* Copy Protect   */
  913. dbc_exflg_lr = x2b(c2x(bitand(x2c(dbc_exflg), '0002'x)))   /* Log Retain     */
  914. dbc_exflg_le = x2b(c2x(bitand(x2c(dbc_exflg), '0004'x)))   /* Log Exit       */
  915. dbc_exflg_ar = x2b(c2x(bitand(x2c(dbc_exflg), '0008'x)))   /* Auto Restart   */
  916.  
  917.  
  918. dbcon_text = ,
  919.    '     ' || cr_lf || ,
  920.    '                     Database Configuration File  ' || cr_lf || ,
  921.    '     ' || cr_lf || ,
  922.    '     ' || cr_lf || ,
  923.    '                        Checksum:  ' || dbc_chksum  || cr_lf || ,
  924.    '                           Title:  ' || dbc_title   || cr_lf || ,
  925.    '                         Release:  ' || dbc_rel     || cr_lf || ,
  926.    '           RDS Version Indicator:  ' || dbc_rds     || cr_lf || ,
  927.    '            Masked Database Seed:  ' || dbc_mseed   || cr_lf || ,
  928.    '          UnMasked Database Seed:  ' || dbc_unseed  || cr_lf || ,
  929.    '     Database Creation Timestamp:  ' || substr(dbc_stmp,1,4) || '-' || ,
  930.                                             substr(dbc_stmp,5,2) || '-' || ,
  931.                                             substr(dbc_stmp,7,2) || '-' || ,
  932.                                             substr(dbc_stmp,9,2) || '.' || ,
  933.                                             substr(dbc_stmp,11,2) || '.' || ,
  934.                                             substr(dbc_stmp,13,2) || '.' || ,
  935.                                             substr(dbc_stmp,15,6) || ,
  936.                                             cr_lf || ,
  937.    '     ' || cr_lf || ,
  938.    '      Log File Size (Linear Log):  ' || dbc_logsiz || cr_lf || ,
  939.    '        Extent Size (Linear Log):  ' || dbc_logext || cr_lf || ,
  940.    ' Max No. of Extents (Linear Log):  ' || dbc_maxext || cr_lf || ,
  941.    '     Number of Primary Log Files:  ' || dbc_plog   || cr_lf || ,
  942.    '   Number of Secondary Log Files:  ' || dbc_slog   || cr_lf || ,
  943.    '           Size of Each Log File:  ' || dbc_lfsiz  || cr_lf || ,
  944.    '                   Log File Path:  ' || ,
  945.                          strip(translate(dbc_logpath, ' ', '00'x )) || ,
  946.                          cr_lf || ,
  947.    '               New Log File Path:  ' || ,
  948.                          strip(translate(dbc_newpath, ' ', '00'x )) || ,
  949.                          cr_lf || ,
  950.    '     ' || cr_lf || ,
  951.    ' Interval for DeadLock Detection:  ' || dbc_dlchk   || cr_lf || ,
  952.    '   Maximum Storage for Lock List:  ' || dbc_lcklst  || cr_lf || ,
  953.    '   % of Total Lock List per Appl:  ' || dbc_pctlcks || cr_lf || ,
  954.    '     Maximum Active Applications:  ' || dbc_maxapp  || cr_lf || ,
  955.    '  Maximum Db Files Open per Appl:  ' || dbc_maxfil  || cr_lf || ,
  956.    '     Max Tot Files Open per Appl:  ' || dbc_maxtot  || cr_lf || ,
  957.    'Records Written before SoftChkpt:  ' || dbc_soft    || cr_lf || ,
  958.    '             Size of Buffer Pool:  ' || dbc_buff    || cr_lf || ,
  959.    '     '  || cr_lf || ,
  960.    '           Application Heap Size:  ' || dbc_apheap  || cr_lf || ,
  961.    '     Application Agent Heap Size:  ' || dbc_agheap  || cr_lf || ,
  962.    '              Database Heap Size:  ' || dbc_dbheap  || cr_lf || ,
  963.    '             Statement Heap Size:  ' || dbc_stheap  || cr_lf || ,
  964.    '             Sort List Heap Size:  ' || dbc_slheap  || cr_lf || ,
  965.    '     '  || cr_lf || ,
  966.    '                    Country Code:  ' || dbc_cntry   || cr_lf || ,
  967.    '                       Code Page:  ' || dbc_cpag    || cr_lf || ,
  968.    '     ' || cr_lf || ,
  969.    '     ' || cr_lf || ,
  970.    '     ' || cr_lf || ,
  971.    '                  -----Internal Indicators----- '  || cr_lf || ,
  972.    '     ' || cr_lf || ,
  973.    '         Log File Move Indicator:  ' || ,
  974.                                          copies('x', 4) || ' ' || ,
  975.                                          copies('x', 4) || ' ' || ,
  976.                                          copies('x', 4) || ' ' || ,
  977.                                          copies('x', 3) || ,
  978.                                          substr(dbc_inflg_mo,16, 1) || ,
  979.                                          copies('x', 0) || ,
  980.                                          cr_lf || ,
  981.    '    Linear to Circular Log Xlate:  ' || ,
  982.                                          copies('x', 4) || ' ' || ,
  983.                                          copies('x', 4) || ' ' || ,
  984.                                          copies('x', 4) || ' ' || ,
  985.                                          copies('x', 2) || ,
  986.                                          substr(dbc_inflg_lc,15, 1) || ,
  987.                                          copies('x', 1) || ,
  988.                                          cr_lf || ,
  989.    '    Circular to Linear Log Xlate:  ' || ,
  990.                                          copies('x', 4) || ' ' || ,
  991.                                          copies('x', 4) || ' ' || ,
  992.                                          copies('x', 4) || ' ' || ,
  993.                                          copies('x', 1) || ,
  994.                                          substr(dbc_inflg_cl,14, 1) || ,
  995.                                          copies('x', 2) || ,
  996.                                          cr_lf || ,
  997.    '       Server Defaults Installed:  ' || ,
  998.                                          copies('x', 4) || ' ' || ,
  999.                                          copies('x', 4) || ' ' || ,
  1000.                                          copies('x', 4) || ' ' || ,
  1001.                                          copies('x', 0) || ,
  1002.                                          substr(dbc_inflg_cl,13, 1) || ,
  1003.                                          copies('x', 3) || ,
  1004.                                          cr_lf || ,
  1005.    '     ' || cr_lf || ,
  1006.    '     ' || cr_lf || ,
  1007.    '                  -----External Indicators----- ' || cr_lf || ,
  1008.    '     ' || cr_lf || ,
  1009.    '          Copy Protect Indicator:  ' || ,
  1010.                                          copies('x', 4) || ' ' || ,
  1011.                                          copies('x', 4) || ' ' || ,
  1012.                                          copies('x', 4) || ' ' || ,
  1013.                                          copies('x', 3) || ,
  1014.                                          substr(dbc_exflg_cp,16, 1) || ,
  1015.                                          copies('x', 0) || ,
  1016.                                          cr_lf || ,
  1017.    '               Enable Log Retain:  ' || ,
  1018.                                          copies('x', 4) || ' ' || ,
  1019.                                          copies('x', 4) || ' ' || ,
  1020.                                          copies('x', 4) || ' ' || ,
  1021.                                          copies('x', 2) || ,
  1022.                                          substr(dbc_exflg_lr,15, 1) || ,
  1023.                                          copies('x', 1) || ,
  1024.                                          cr_lf || ,
  1025.    '                 Enable Log Exit:  ' || ,
  1026.                                          copies('x', 4) || ' ' || ,
  1027.                                          copies('x', 4) || ' ' || ,
  1028.                                          copies('x', 4) || ' ' || ,
  1029.                                          copies('x', 1) || ,
  1030.                                          substr(dbc_exflg_le,14, 1) || ,
  1031.                                          copies('x', 2) || ,
  1032.                                          cr_lf || ,
  1033.    '               Automatic Restart:  ' || ,
  1034.                                          copies('x', 4) || ' ' || ,
  1035.                                          copies('x', 4) || ' ' || ,
  1036.                                          copies('x', 4) || ' ' || ,
  1037.                                          copies('x', 0) || ,
  1038.                                          substr(dbc_exflg_ar,13, 1) || ,
  1039.                                          copies('x', 3) || ,
  1040.                                          cr_lf
  1041.  
  1042. call wrt2rpt  dbcon_text
  1043.  
  1044.  
  1045.  
  1046.  
  1047. return
  1048.  
  1049.  
  1050.  
  1051.  
  1052. /******************************************************************
  1053. *  SUBROUTINE:   GETLOGPATH                                       *
  1054. *                                                                 *
  1055. *  DESCRIPTIVE NAME: Get the Path Containing Log Files            *
  1056. *                                                                 *
  1057. *  DESCRIPTION: This routine determines the SubDirectory that     *
  1058. *               contains the Log Files from the LOGPATH and       *
  1059. *               NEWPATH fields in the Db Config file.  If both    *
  1060. *               fields are NULL, then the Log Files are           *
  1061. *               supposed to be in the Database Subdirectory.      *
  1062. *               The Log Control File exists in the Database       *
  1063. *               Subdirectory regardless of the location of the    *
  1064. *               other Log Files.  This routine checks to see if   *
  1065. *               the Log Files really exist in the location        *
  1066. *               that is described by the LOGPATH or the NEWPATH   *
  1067. *               fields.  Upon exit from this routine, the         *
  1068. *               shared variable LOGPATH should contain the log    *
  1069. *               file subdirectory.  If no subdirectory is found   *
  1070. *               to contain the Log Files, then LOGPATH remains    *
  1071. *               a NULL value.                                     *
  1072. *                                                                 *
  1073. *  INPUT: LOGPATH = NULL                                          *
  1074. *                                                                 *
  1075. *                                                                 *
  1076. *  OUTPUT: LOGPATH = Log File Subdirectory                        *
  1077. *                 or                                              *
  1078. *          LOGPATH = NULL                                         *
  1079. *                                                                 *
  1080. ******************************************************************/
  1081.  
  1082. getlogpath:
  1083.  
  1084. /* Construct normalized LogPath character string */
  1085. norm_logpath = strip(translate(dbc_logpath, ' ', '00'x ))
  1086.  
  1087. /* Construct normalized NewLogPath character string */
  1088. norm_newpath = strip(translate(dbc_newpath, ' ', '00'x ))
  1089.  
  1090. if norm_logpath = '' & norm_newpath = '' then
  1091.   do
  1092.     /* Log Files are supposedly in the database subdirectory */
  1093.     if stream(dbpath || 'S0000000.LOG', 'c', 'query exist') \= '' then
  1094.        logpath = dbpath      /* Log File in database subdirectory */
  1095.   end
  1096. else   /* Log Path is specified in the Db Configuration */
  1097.   do
  1098.     /* Check if Log Control File is specified and found in LOGPATH */
  1099.     if norm_logpath \= '' & ,
  1100.        stream(norm_logpath || 'S0000000.LOG', 'c', 'query exist') \= '' then
  1101.        /* Log Control File found in LOGPATH */
  1102.       logpath = norm_logpath
  1103.     else
  1104.       do
  1105.         if norm_newpath \= '' & ,
  1106.           stream(norm_newpath || 'S0000000.LOG', 'c', 'query exist') \= '' then
  1107.           /* Log Control File found in NEWPATH */
  1108.           logpath = norm_newpath
  1109.       end
  1110.   end
  1111.  
  1112.  
  1113.  
  1114. return
  1115.  
  1116.  
  1117.  
  1118. /******************************************************************
  1119. *  SUBROUTINE:   RESET                                            *
  1120. *                                                                 *
  1121. *  DESCRIPTIVE NAME: Reset the Log Control File                   *
  1122. *                                                                 *
  1123. *  DESCRIPTION: This routine controls the resetting of the Log    *
  1124. *               Control File.  It calls a routine to set up the   *
  1125. *               offsets to fields in the Log Control File and     *
  1126. *               then it calls the routine to update the Base      *
  1127. *               LSN in the file.                                  *
  1128. *                                                                 *
  1129. *                                                                 *
  1130. *  INPUT: none                                                    *
  1131. *                                                                 *
  1132. *                                                                 *
  1133. *  OUTPUT: none                                                   *
  1134. *                                                                 *
  1135. ******************************************************************/
  1136.  
  1137. reset:
  1138.  
  1139. say '....Examining the Log Control File'
  1140.  
  1141. /*********************************************
  1142.    Define Offsets to Fields in the Log Control File
  1143. *********************************************/
  1144. call defoff_log
  1145.  
  1146.  
  1147. /*********************************************
  1148.    Write Report File Separator Lines
  1149. *********************************************/
  1150. rptsep_text = '     '  || cr_lf || ,
  1151.               '     '  || cr_lf || ,
  1152.               seplines || cr_lf || ,
  1153.               seplines || cr_lf || ,
  1154.               '     '  || cr_lf || ,
  1155.               '     '  || cr_lf
  1156.  
  1157. call wrt2rpt  rptsep_text
  1158.  
  1159.  
  1160. /*********************************************
  1161.    Get Data in the Log Control File
  1162. *********************************************/
  1163. call getdata_logctl
  1164.  
  1165.  
  1166. /*********************************************
  1167.    Write Report File Separator Lines
  1168. *********************************************/
  1169. call wrt2rpt  rptsep_text
  1170.  
  1171.  
  1172. /*********************************************
  1173.    Update the Base LSN
  1174. *********************************************/
  1175.  
  1176. say '....Comparing LSN Values'
  1177. call updlsn
  1178.  
  1179.  
  1180. /*********************************************
  1181.    Write the Report File Tail
  1182. *********************************************/
  1183. rptail_text = '     '  || cr_lf || ,
  1184.               '     '  || cr_lf || ,
  1185.               eqlines  || cr_lf || ,
  1186.               eqlines  || cr_lf || ,
  1187.               '     '  || cr_lf || ,
  1188.               '     '  || cr_lf
  1189.  
  1190. call wrt2rpt  rptail_text
  1191.  
  1192.  
  1193.  
  1194. return
  1195.  
  1196.  
  1197. /******************************************************************
  1198. *  SUBROUTINE:   DEFOFF_LOG                                       *
  1199. *                                                                 *
  1200. *  DESCRIPTIVE NAME: Define Offsets to Fields in Log Control File *
  1201. *                                                                 *
  1202. *  DESCRIPTION: This routine defines the offsets for the fields   *
  1203. *               in the Log Control File.                          *
  1204. *                                                                 *
  1205. *  INPUT: none                                                    *
  1206. *                                                                 *
  1207. *                                                                 *
  1208. *  OUTPUT: none                                                   *
  1209. *                                                                 *
  1210. ******************************************************************/
  1211.  
  1212. defoff_log:
  1213.  
  1214. /*********************************************
  1215.    Define Page Offset Constants
  1216.       (Note: These offsets are 1-origin from the Start of the Page)
  1217.       (Note: The length values are in terms of character bytes.)
  1218. *********************************************/
  1219. lfhdr1  =  1            /* Offset to the Primary Log File Header */
  1220. lfhdr2  =  2049         /* Offset to the Secondary Log File Header */
  1221.  
  1222.  
  1223. /*********************************************
  1224.    Define Offsets for Log File Header in Log Control File
  1225.       (Note: These offsets are 0-origin from the Start of LFH)
  1226. *********************************************/
  1227. lfh_cnt1o =  0               /* Consistency Counter 1 field offset           */
  1228. lfh_cnt1l =  2               /*                       field length           */
  1229.  
  1230. lfh_fmtvo  =  2              /* Format Version field offset                  */
  1231. lfh_fmtvl  =  2              /*                field length                  */
  1232.  
  1233. lfh_logtypo  =  4            /* Log File Type field offset                   */
  1234. lfh_logtypl  =  2            /*               field length                   */
  1235.  
  1236. lfh_logacto  =  6            /* Number of Primary Log Files field offset     */
  1237. lfh_logactl  =  2            /*                             field length     */
  1238.  
  1239. lfh_loginao  =  8            /* Number of Secondary Log Files field offset   */
  1240. lfh_loginal  =  2            /*                               field length   */
  1241.  
  1242. lfh_logsizo  =  10           /* Number of Pages in each Log File field offset*/
  1243. lfh_logsizl  =  2            /*                                  field length*/
  1244.  
  1245. lfh_ttblsizo  =  12          /* Current Size of Trans Table field offset     */
  1246. lfh_ttblsizl  =  2           /*                             field length     */
  1247.  
  1248. lfh_softmaxo =  14           /* Log Records written before Soft Chkpt   off  */
  1249. lfh_softmaxl =  2            /*                                   field len  */
  1250.  
  1251. lfh_baselsno =  16           /* First LSN after final Stop Using field off   */
  1252. lfh_baselsnl =  6            /*                                  field len   */
  1253.  
  1254. lfh_nextlsno =  22           /* Next LSN prior to final Stop Using field off */
  1255. lfh_nextlsnl =  6            /*                                    field len */
  1256.  
  1257. lfh_lowlsno  =  28           /* First LSN of Oldest In-Flight Trans field off*/
  1258. lfh_lowlsnl  =  6            /*                                     field len*/
  1259.  
  1260. lfh_minblsno =  34           /* First LSN of Oldest Pg in Buff Pool field off*/
  1261. lfh_minblsnl =  6            /*                                     field len*/
  1262.  
  1263. lfh_basetido =  40           /* First Transaction ID field offset            */
  1264. lfh_basetidl =  6            /*                      field length            */
  1265.  
  1266. lfh_headlsno =  46           /* LSN at Head of Log File field offset         */
  1267. lfh_headlsnl =  6            /*                         field length         */
  1268.  
  1269. lfh_taillsno =  52           /* Last LSN of Log File field offset            */
  1270. lfh_taillsnl =  6            /*                      field length            */
  1271.  
  1272. lfh_logpatho =  58           /* Log File Path field offset                   */
  1273. lfh_logpathl =  260          /*               field length                   */
  1274.  
  1275. lfh_hflago   =  318          /* HFLAG field offset                           */
  1276. lfh_hflagl   =  2            /*       field length                           */
  1277.  
  1278. lfh_headexto =  320          /* Head Extent ID field offset                  */
  1279. lfh_headextl =  4            /*                field length                  */
  1280.  
  1281. lfh_lastexto =  324          /* Last Extent ID field offset                  */
  1282. lfh_lastextl =  4            /*                field length                  */
  1283.  
  1284. lfh_dbexto   =  328          /* Db Creation Extent ID field offset           */
  1285. lfh_dbextl   =  4            /*                       field length           */
  1286.  
  1287. lfh_cmitexto =  332          /* Last Commit Extent ID field offset           */
  1288. lfh_cmitextl =  4            /*                       field length           */
  1289.  
  1290. lfh_frstarco =  336          /* First Archived Extent ID field offset        */
  1291. lfh_frstarcl =  4            /*                          field length        */
  1292.  
  1293. lfh_lastarco =  340          /* Last Archived Extent ID field offset         */
  1294. lfh_lastarcl =  4            /*                         field length         */
  1295.  
  1296. lfh_nextreco =  344          /* Next Media Recovery Extent ID field offset   */
  1297. lfh_nextrecl =  4            /*                               field length   */
  1298.  
  1299. lfh_frstreco =  348          /* First Media Recovery Extent ID field offset  */
  1300. lfh_frstrecl =  4            /*                               field length   */
  1301.  
  1302. lfh_frstdelo =  352          /* First M-Rcvry Deleted Extent ID field offset */
  1303. lfh_frstdell =  4            /*                                 field length */
  1304.  
  1305. lfh_lastdelo =  356          /* Last M-Rcvry Deleted Extent ID field offset  */
  1306. lfh_lastdell =  4            /*                                field length  */
  1307.  
  1308. lfh_headreco =  360          /* Head Media Recovery Extent ID field offset   */
  1309. lfh_headrecl =  4            /*                               field length   */
  1310.  
  1311. lfh_filecnto =  364          /* Count of Files in Array field offset         */
  1312. lfh_filecntl =  2            /*                         field length         */
  1313.  
  1314. lfh_filarryo =  366          /* File Handle Array field offset               */
  1315. lfh_filarryl =  512          /*                   field length               */
  1316.  
  1317. lfh_trnclsno =  878          /* Truncation LSN field offset                  */
  1318. lfh_trnclsnl =  6            /*                field length                  */
  1319.  
  1320. lfh_trncexto =  884          /* Truncation Extent ID field offset            */
  1321. lfh_trncextl =  4            /*                      field length            */
  1322.  
  1323. lfh_resrvo   =  888          /* Unused                                       */
  1324. lfh_resrvl   =  2            /*                                              */
  1325.  
  1326. lfh_lastcido =  890          /* Last CId field offset                        */
  1327. lfh_lastcidl =  4            /*          field length                        */
  1328.  
  1329. lfh_lrdlsno  =  894          /* Last Record Read LSN during RFR field offset */
  1330. lfh_lrdlsnl  =  6            /*                                 field length */
  1331.  
  1332. lfh_resrv2o  =  900          /* Unused                                       */
  1333. lfh_resrv2l  =  18           /*                                              */
  1334.  
  1335. lfh_cnt2o    =  918          /* Consistency counter 2 offset                 */
  1336. lfh_cnt2l    =  2            /*                       length                 */
  1337.  
  1338.  
  1339.  
  1340. return
  1341.  
  1342.  
  1343.  
  1344. /******************************************************************
  1345. *  SUBROUTINE:   GETDATA_LOGCTL                                   *
  1346. *                                                                 *
  1347. *  DESCRIPTIVE NAME: Get Data from the Log Control File           *
  1348. *                                                                 *
  1349. *  DESCRIPTION: This routine determines the most recent Log File  *
  1350. *               Header (either the Primary or the Secondary) and  *
  1351. *               retrieves the data from the Log Control File      *
  1352. *               and stores the Log File Header fields in          *
  1353. *               variables.                                        *
  1354. *                                                                 *
  1355. *  INPUT: none                                                    *
  1356. *                                                                 *
  1357. *                                                                 *
  1358. *  OUTPUT: none                                                   *
  1359. *                                                                 *
  1360. ******************************************************************/
  1361.  
  1362. getdata_logctl:
  1363.  
  1364. /*********************************************
  1365.    Read the Log Control File (Primary LFH)
  1366. *********************************************/
  1367.  
  1368. lfhdr = lfhdr1          /* Set offset for reading Primary Log File Header */
  1369. lfh_i = 1               /* Set Primary LFH indicator                      */
  1370. call getlfh_fields      /* Get the LFH fields from the Primary LFH        */
  1371.  
  1372. /*********************************************
  1373.    Read the Log Control File (Secondary LFH)
  1374. *********************************************/
  1375.  
  1376. lfhdr = lfhdr2          /* Set offset for reading Secondary Log File Header */
  1377. lfh_i = 2               /* Set Secondary LFH indicator                      */
  1378. call getlfh_fields      /* Get the LFH fields from the Secondary LFH        */
  1379.  
  1380. /*********************************************
  1381.    Report the Contents of the Primary Log File
  1382.      Header in the Log Control File
  1383. *********************************************/
  1384.  
  1385. /* Get Binary representations of the HFLAG                                   */
  1386. lfh_hflg_b00.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0001'x))) /* Db Consistent*/
  1387. lfh_hflg_b01.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0002'x))) /*              */
  1388. lfh_hflg_b02.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0004'x))) /* Bckup Pending*/
  1389. lfh_hflg_b03.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0008'x))) /* RFR Pending  */
  1390. lfh_hflg_b04.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0010'x))) /* Rec w/ Retain*/
  1391. lfh_hflg_b05.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0020'x))) /* Rec w/ U Xit */
  1392. lfh_hflg_b06.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0040'x))) /* Tst Consistnt*/
  1393. lfh_hflg_b07.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0080'x))) /* RFR,not Crash*/
  1394. lfh_hflg_b08.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0100'x))) /* Alloc Logs   */
  1395. lfh_hflg_b09.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0200'x))) /* Rec Complete */
  1396. lfh_hflg_b10.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0400'x))) /* RFR in Prog  */
  1397. lfh_hflg_b11.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '0800'x))) /* Trunc in Prog*/
  1398. lfh_hflg_b12.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '1000'x))) /* No Retry     */
  1399. lfh_hflg_b13.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '2000'x))) /*              */
  1400. lfh_hflg_b14.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '4000'x))) /*              */
  1401. lfh_hflg_b15.1 = x2b(c2x(bitand(x2c(lfh_hflag.1), '8000'x))) /* Create Logs  */
  1402.  
  1403. hflag_text = ,
  1404.    '                  -----HFLAG  Indicators----- ' || cr_lf || ,
  1405.    '     ' || cr_lf || ,
  1406.    '            Database is Consistent:  ' || ,
  1407.                                          copies('x', 4) || ' ' || ,
  1408.                                          copies('x', 4) || ' ' || ,
  1409.                                          copies('x', 4) || ' ' || ,
  1410.                                          copies('x', 3) || ,
  1411.                                          substr(lfh_hflg_b00.1,16, 1) || ,
  1412.                                          copies('x', 0) || ,
  1413.                                          cr_lf || ,
  1414.    '                          (Unused):  ' || ,
  1415.                                          copies('x', 4) || ' ' || ,
  1416.                                          copies('x', 4) || ' ' || ,
  1417.                                          copies('x', 4) || ' ' || ,
  1418.                                          copies('x', 2) || ,
  1419.                                          substr(lfh_hflg_b01.1,15, 1) || ,
  1420.                                          copies('x', 1) || ,
  1421.                                          cr_lf || ,
  1422.    '                 Backup is Pending:  ' || ,
  1423.                                          copies('x', 4) || ' ' || ,
  1424.                                          copies('x', 4) || ' ' || ,
  1425.                                          copies('x', 4) || ' ' || ,
  1426.                                          copies('x', 1) || ,
  1427.                                          substr(lfh_hflg_b02.1,14, 1) || ,
  1428.                                          copies('x', 2) || ,
  1429.                                          cr_lf || ,
  1430.    '  Roll-Forward Recovery is Pending:  ' || ,
  1431.                                          copies('x', 4) || ' ' || ,
  1432.                                          copies('x', 4) || ' ' || ,
  1433.                                          copies('x', 4) || ' ' || ,
  1434.                                          copies('x', 0) || ,
  1435.                                          substr(lfh_hflg_b03.1,13, 1) || ,
  1436.                                          copies('x', 3) || ,
  1437.                                          cr_lf || ,
  1438.    '   Db is recoverable - Retain Logs:  ' || ,
  1439.                                          copies('x', 4) || ' ' || ,
  1440.                                          copies('x', 4) || ' ' || ,
  1441.                                          copies('x', 3) || ,
  1442.                                          substr(lfh_hflg_b04.1,12, 1) || ,
  1443.                                          copies('x', 0) || ' ' || ,
  1444.                                          copies('x', 4) || ,
  1445.                                          cr_lf || ,
  1446.    '   Db rcvrble - Retain & User Exit:  ' || ,
  1447.                                          copies('x', 4) || ' ' || ,
  1448.                                          copies('x', 4) || ' ' || ,
  1449.                                          copies('x', 2) || ,
  1450.                                          substr(lfh_hflg_b05.1,11, 1) || ,
  1451.                                          copies('x', 1) || ' ' || ,
  1452.                                          copies('x', 4) || ,
  1453.                                          cr_lf || ,
  1454.    '                Test is Consistent:  ' || ,
  1455.                                          copies('x', 4) || ' ' || ,
  1456.                                          copies('x', 4) || ' ' || ,
  1457.                                          copies('x', 1) || ,
  1458.                                          substr(lfh_hflg_b06.1,10, 1) || ,
  1459.                                          copies('x', 2) || ' ' || ,
  1460.                                          copies('x', 4) || ,
  1461.                                          cr_lf || ,
  1462.    '     RFR vs Crash Rcvry (1 => RFR):  ' || ,
  1463.                                          copies('x', 4) || ' ' || ,
  1464.                                          copies('x', 4) || ' ' || ,
  1465.                                          copies('x', 0) || ,
  1466.                                          substr(lfh_hflg_b07.1, 9, 1) || ,
  1467.                                          copies('x', 3) || ' ' || ,
  1468.                                          copies('x', 4) || ,
  1469.                                          cr_lf || ,
  1470.    'ReAllocate Logs for Crash Recovery:  ' || ,
  1471.                                          copies('x', 4) || ' ' || ,
  1472.                                          copies('x', 3) || ,
  1473.                                          substr(lfh_hflg_b08.1, 8, 1) || ,
  1474.                                          copies('x', 0) || ' ' || ,
  1475.                                          copies('x', 4) || ' ' || ,
  1476.                                          copies('x', 4) || ,
  1477.                                          cr_lf || ,
  1478.    'Restore Force or Recovery Complete:  ' || ,
  1479.                                          copies('x', 4) || ' ' || ,
  1480.                                          copies('x', 2) || ,
  1481.                                          substr(lfh_hflg_b09.1, 7, 1) || ,
  1482.                                          copies('x', 1) || ' ' || ,
  1483.                                          copies('x', 4) || ' ' || ,
  1484.                                          copies('x', 4) || ,
  1485.                                          cr_lf || ,
  1486.    'RFR Utility started & not Complete:  ' || ,
  1487.                                          copies('x', 4) || ' ' || ,
  1488.                                          copies('x', 1) || ,
  1489.                                          substr(lfh_hflg_b10.1, 6, 1) || ,
  1490.                                          copies('x', 2) || ' ' || ,
  1491.                                          copies('x', 4) || ' ' || ,
  1492.                                          copies('x', 4) || ,
  1493.                                          cr_lf || ,
  1494.    '  RFR Trunc started & not Complete:  ' || ,
  1495.                                          copies('x', 4) || ' ' || ,
  1496.                                          copies('x', 0) || ,
  1497.                                          substr(lfh_hflg_b11.1, 5, 1) || ,
  1498.                                          copies('x', 3) || ' ' || ,
  1499.                                          copies('x', 4) || ' ' || ,
  1500.                                          copies('x', 4) || ,
  1501.                                          cr_lf || ,
  1502.    '            Do not Invoke SQLUEXIT:  ' || ,
  1503.                                          copies('x', 3) || ,
  1504.                                          substr(lfh_hflg_b12.1, 4, 1) || ,
  1505.                                          copies('x', 0) || ' ' || ,
  1506.                                          copies('x', 4) || ' ' || ,
  1507.                                          copies('x', 4) || ' ' || ,
  1508.                                          copies('x', 4) || ,
  1509.                                          cr_lf || ,
  1510.    '                          (unused):  ' || ,
  1511.                                          copies('x', 2) || ,
  1512.                                          substr(lfh_hflg_b13.1, 3, 1) || ,
  1513.                                          copies('x', 1) || ' ' || ,
  1514.                                          copies('x', 4) || ' ' || ,
  1515.                                          copies('x', 4) || ' ' || ,
  1516.                                          copies('x', 4) || ,
  1517.                                          cr_lf || ,
  1518.    '                          (unused):  ' || ,
  1519.                                          copies('x', 1) || ,
  1520.                                          substr(lfh_hflg_b14.1, 2, 1) || ,
  1521.                                          copies('x', 2) || ' ' || ,
  1522.                                          copies('x', 4) || ' ' || ,
  1523.                                          copies('x', 4) || ' ' || ,
  1524.                                          copies('x', 4) || ,
  1525.                                          cr_lf || ,
  1526.    '     Database Logs are being Built:  ' || ,
  1527.                                          copies('x', 0) || ,
  1528.                                          substr(lfh_hflg_b15.1, 1, 1) || ,
  1529.                                          copies('x', 3) || ' ' || ,
  1530.                                          copies('x', 4) || ' ' || ,
  1531.                                          copies('x', 4) || ' ' || ,
  1532.                                          copies('x', 4) || ,
  1533.                                          cr_lf
  1534.  
  1535.  
  1536. lfh_text = ,
  1537.     '     ' || cr_lf || ,
  1538.     '                        Log Control File ' || cr_lf || ,
  1539.     '                    Primary Log File Header:' || cr_lf || ,
  1540.     '     ' || cr_lf || ,
  1541.     '     ' || cr_lf || ,
  1542.     '           Consistency Counter 1:  ' || lfh_cnt1.1 || cr_lf || ,
  1543.     '           Consistency Counter 2:  ' || lfh_cnt2.1 || cr_lf || ,
  1544.     '                  Format Version:  ' || lfh_fmtv.1 || cr_lf || ,
  1545.     '                        Log Type:  ' || lfh_logtyp.1  || cr_lf || ,
  1546.     '     ' || cr_lf || ,
  1547.     '                   Log File Path:  ' || ,
  1548.                            strip(translate(lfh_logpath.1, ' ', '00'x )) || ,
  1549.                            cr_lf || ,
  1550.     '     ' || cr_lf || ,
  1551.     '     ' || cr_lf || ,
  1552.     '     ' || cr_lf || ,
  1553.     '     Number of Primary Log Files:  ' || lfh_logact.1  || cr_lf || ,
  1554.     '   Number of Secondary Log Files:  ' || lfh_logina.1  || cr_lf || ,
  1555.     'Number of Pages in each Log File:  ' || lfh_logsiz.1  || cr_lf || ,
  1556.     '     ' || cr_lf || ,
  1557.     '     ' || cr_lf || ,
  1558.     '     ' || cr_lf || ,
  1559.     hflag_text || ,
  1560.     '     ' || cr_lf || ,
  1561.     '     ' || cr_lf || ,
  1562.     '     ' || cr_lf || ,
  1563.     '                        Base LSN:  ' || lfh_baselsn.1  || cr_lf || ,
  1564.     '                        Next LSN:  ' || lfh_nextlsn.1  || cr_lf || ,
  1565.     '             Low Transaction LSN:  ' || lfh_lowlsn.1   || cr_lf || ,
  1566.     '              Minimum Buffer LSN:  ' || lfh_minblsn.1  || cr_lf || ,
  1567.     '                        Head LSN:  ' || lfh_headlsn.1  || cr_lf || ,
  1568.     '                        Tail LSN:  ' || lfh_taillsn.1  || cr_lf || ,
  1569.     '                  Truncation LSN:  ' || lfh_trnclsn.1  || cr_lf || ,
  1570.     '            Last Record Read LSN:  ' || lfh_lrdlsn.1   || cr_lf || ,
  1571.     '     ' || cr_lf || ,
  1572.     '     ' || cr_lf || ,
  1573.     '     ' || cr_lf || ,
  1574.     '            First Transaction ID:  ' || lfh_basetid.1  || cr_lf || ,
  1575.     '       Size of Transaction Table:  ' || lfh_ttblsiz.1  || cr_lf || ,
  1576.     '    Log Recs prior to Soft Chkpt:  ' || lfh_softmax.1  || cr_lf || ,
  1577.     '     ' || cr_lf || ,
  1578.     '     ' || cr_lf || ,
  1579.     '     ' || cr_lf || ,
  1580.     '                  Head Extent ID:  ' || lfh_headext.1  || cr_lf || ,
  1581.     '                  Last Extent ID:  ' || lfh_lastext.1  || cr_lf || ,
  1582.     '     Database Creation Extent ID:  ' || lfh_dbext.1    || cr_lf || ,
  1583.     '           Last Commit Extent ID:  ' || lfh_cmitext.1  || cr_lf || ,
  1584.     '        First Archived Extent ID:  ' || lfh_frstarc.1  || cr_lf || ,
  1585.     '         Last Archived Extent ID:  ' || lfh_lastarc.1  || cr_lf || ,
  1586.     '  First Media Recovery Extent ID:  ' || lfh_frstrec.1  || cr_lf || ,
  1587.     '   Next Media Recovery Extent ID:  ' || lfh_nextrec.1  || cr_lf || ,
  1588.     ' First M-Rcvry Deleted Extent ID:  ' || lfh_frstdel.1  || cr_lf || ,
  1589.     '  Last M-Rcvry Deleted Extent ID:  ' || lfh_lastdel.1  || cr_lf || ,
  1590.     '   Head Media Recovery Extent ID:  ' || lfh_headrec.1  || cr_lf || ,
  1591.     '            Truncation Extent ID:  ' || lfh_trncext.1  || cr_lf || ,
  1592.     '                        Last CID:  ' || lfh_lastcid.1  || cr_lf || ,
  1593.     '     '  || cr_lf || ,
  1594.     '     '  || cr_lf
  1595.  
  1596. call wrt2rpt  lfh_text
  1597.  
  1598.  
  1599. /*   Write the report separator lines  */
  1600. call wrt2rpt  rptsep_text
  1601.  
  1602. /*********************************************
  1603.    Report the Contents of the Secondary Log File
  1604.      Header in the Log Control File
  1605. *********************************************/
  1606.  
  1607. /* Get Binary representations of the HFLAG                                   */
  1608. lfh_hflg_b00.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0001'x))) /* Db Consistent*/
  1609. lfh_hflg_b01.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0002'x))) /*              */
  1610. lfh_hflg_b02.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0004'x))) /* Bckup Pending*/
  1611. lfh_hflg_b03.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0008'x))) /* RFR Pending  */
  1612. lfh_hflg_b04.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0010'x))) /* Rec w/ Retain*/
  1613. lfh_hflg_b05.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0020'x))) /* Rec w/ U Xit */
  1614. lfh_hflg_b06.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0040'x))) /* Tst Consistnt*/
  1615. lfh_hflg_b07.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0080'x))) /* RFR,not Crash*/
  1616. lfh_hflg_b08.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0100'x))) /* Alloc Logs   */
  1617. lfh_hflg_b09.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0200'x))) /* Rec Complete */
  1618. lfh_hflg_b10.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0400'x))) /* RFR in Prog  */
  1619. lfh_hflg_b11.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '0800'x))) /* Trunc in Prog*/
  1620. lfh_hflg_b12.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '1000'x))) /* No Retry     */
  1621. lfh_hflg_b13.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '2000'x))) /*              */
  1622. lfh_hflg_b14.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '4000'x))) /*              */
  1623. lfh_hflg_b15.2 = x2b(c2x(bitand(x2c(lfh_hflag.2), '8000'x))) /* Create Logs  */
  1624.  
  1625. hflag_text = ,
  1626.    '                  -----HFLAG  Indicators----- ' || cr_lf || ,
  1627.    '     ' || cr_lf || ,
  1628.    '            Database is Consistent:  ' || ,
  1629.                                          copies('x', 4) || ' ' || ,
  1630.                                          copies('x', 4) || ' ' || ,
  1631.                                          copies('x', 4) || ' ' || ,
  1632.                                          copies('x', 3) || ,
  1633.                                          substr(lfh_hflg_b00.2,16, 1) || ,
  1634.                                          copies('x', 0) || ,
  1635.                                          cr_lf || ,
  1636.    '                          (Unused):  ' || ,
  1637.                                          copies('x', 4) || ' ' || ,
  1638.                                          copies('x', 4) || ' ' || ,
  1639.                                          copies('x', 4) || ' ' || ,
  1640.                                          copies('x', 2) || ,
  1641.                                          substr(lfh_hflg_b01.2,15, 1) || ,
  1642.                                          copies('x', 1) || ,
  1643.                                          cr_lf || ,
  1644.    '                 Backup is Pending:  ' || ,
  1645.                                          copies('x', 4) || ' ' || ,
  1646.                                          copies('x', 4) || ' ' || ,
  1647.                                          copies('x', 4) || ' ' || ,
  1648.                                          copies('x', 1) || ,
  1649.                                          substr(lfh_hflg_b02.2,14, 1) || ,
  1650.                                          copies('x', 2) || ,
  1651.                                          cr_lf || ,
  1652.    '  Roll-Forward Recovery is Pending:  ' || ,
  1653.                                          copies('x', 4) || ' ' || ,
  1654.                                          copies('x', 4) || ' ' || ,
  1655.                                          copies('x', 4) || ' ' || ,
  1656.                                          copies('x', 0) || ,
  1657.                                          substr(lfh_hflg_b03.2,13, 1) || ,
  1658.                                          copies('x', 3) || ,
  1659.                                          cr_lf || ,
  1660.    '   Db is recoverable - Retain Logs:  ' || ,
  1661.                                          copies('x', 4) || ' ' || ,
  1662.                                          copies('x', 4) || ' ' || ,
  1663.                                          copies('x', 3) || ,
  1664.                                          substr(lfh_hflg_b04.2,12, 1) || ,
  1665.                                          copies('x', 0) || ' ' || ,
  1666.                                          copies('x', 4) || ,
  1667.                                          cr_lf || ,
  1668.    '   Db rcvrble - Retain & User Exit:  ' || ,
  1669.                                          copies('x', 4) || ' ' || ,
  1670.                                          copies('x', 4) || ' ' || ,
  1671.                                          copies('x', 2) || ,
  1672.                                          substr(lfh_hflg_b05.2,11, 1) || ,
  1673.                                          copies('x', 1) || ' ' || ,
  1674.                                          copies('x', 4) || ,
  1675.                                          cr_lf || ,
  1676.    '                Test is Consistent:  ' || ,
  1677.                                          copies('x', 4) || ' ' || ,
  1678.                                          copies('x', 4) || ' ' || ,
  1679.                                          copies('x', 1) || ,
  1680.                                          substr(lfh_hflg_b06.2,10, 1) || ,
  1681.                                          copies('x', 2) || ' ' || ,
  1682.                                          copies('x', 4) || ,
  1683.                                          cr_lf || ,
  1684.    '     RFR vs Crash Rcvry (1 => RFR):  ' || ,
  1685.                                          copies('x', 4) || ' ' || ,
  1686.                                          copies('x', 4) || ' ' || ,
  1687.                                          copies('x', 0) || ,
  1688.                                          substr(lfh_hflg_b07.2, 9, 1) || ,
  1689.                                          copies('x', 3) || ' ' || ,
  1690.                                          copies('x', 4) || ,
  1691.                                          cr_lf || ,
  1692.    'ReAllocate Logs for Crash Recovery:  ' || ,
  1693.                                          copies('x', 4) || ' ' || ,
  1694.                                          copies('x', 3) || ,
  1695.                                          substr(lfh_hflg_b08.2, 8, 1) || ,
  1696.                                          copies('x', 0) || ' ' || ,
  1697.                                          copies('x', 4) || ' ' || ,
  1698.                                          copies('x', 4) || ,
  1699.                                          cr_lf || ,
  1700.    'Restore Force or Recovery Complete:  ' || ,
  1701.                                          copies('x', 4) || ' ' || ,
  1702.                                          copies('x', 2) || ,
  1703.                                          substr(lfh_hflg_b09.2, 7, 1) || ,
  1704.                                          copies('x', 1) || ' ' || ,
  1705.                                          copies('x', 4) || ' ' || ,
  1706.                                          copies('x', 4) || ,
  1707.                                          cr_lf || ,
  1708.    'RFR Utility started & not Complete:  ' || ,
  1709.                                          copies('x', 4) || ' ' || ,
  1710.                                          copies('x', 1) || ,
  1711.                                          substr(lfh_hflg_b10.2, 6, 1) || ,
  1712.                                          copies('x', 2) || ' ' || ,
  1713.                                          copies('x', 4) || ' ' || ,
  1714.                                          copies('x', 4) || ,
  1715.                                          cr_lf || ,
  1716.    '  RFR Trunc started & not Complete:  ' || ,
  1717.                                          copies('x', 4) || ' ' || ,
  1718.                                          copies('x', 0) || ,
  1719.                                          substr(lfh_hflg_b11.2, 5, 1) || ,
  1720.                                          copies('x', 3) || ' ' || ,
  1721.                                          copies('x', 4) || ' ' || ,
  1722.                                          copies('x', 4) || ,
  1723.                                          cr_lf || ,
  1724.    '            Do not Invoke SQLUEXIT:  ' || ,
  1725.                                          copies('x', 3) || ,
  1726.                                          substr(lfh_hflg_b12.2, 4, 1) || ,
  1727.                                          copies('x', 0) || ' ' || ,
  1728.                                          copies('x', 4) || ' ' || ,
  1729.                                          copies('x', 4) || ' ' || ,
  1730.                                          copies('x', 4) || ,
  1731.                                          cr_lf || ,
  1732.    '                          (unused):  ' || ,
  1733.                                          copies('x', 2) || ,
  1734.                                          substr(lfh_hflg_b13.2, 3, 1) || ,
  1735.                                          copies('x', 1) || ' ' || ,
  1736.                                          copies('x', 4) || ' ' || ,
  1737.                                          copies('x', 4) || ' ' || ,
  1738.                                          copies('x', 4) || ,
  1739.                                          cr_lf || ,
  1740.    '                          (unused):  ' || ,
  1741.                                          copies('x', 1) || ,
  1742.                                          substr(lfh_hflg_b14.2, 2, 1) || ,
  1743.                                          copies('x', 2) || ' ' || ,
  1744.                                          copies('x', 4) || ' ' || ,
  1745.                                          copies('x', 4) || ' ' || ,
  1746.                                          copies('x', 4) || ,
  1747.                                          cr_lf || ,
  1748.    '     Database Logs are being Built:  ' || ,
  1749.                                          copies('x', 0) || ,
  1750.                                          substr(lfh_hflg_b15.2, 1, 1) || ,
  1751.                                          copies('x', 3) || ' ' || ,
  1752.                                          copies('x', 4) || ' ' || ,
  1753.                                          copies('x', 4) || ' ' || ,
  1754.                                          copies('x', 4) || ,
  1755.                                          cr_lf
  1756.  
  1757.  
  1758. lfh_text = ,
  1759.     '     ' || cr_lf || ,
  1760.     '                        Log Control File ' || cr_lf || ,
  1761.     '                  Secondary Log File Header:' || cr_lf || ,
  1762.     '     ' || cr_lf || ,
  1763.     '     ' || cr_lf || ,
  1764.     '           Consistency Counter 1:  ' || lfh_cnt1.2 || cr_lf || ,
  1765.     '           Consistency Counter 2:  ' || lfh_cnt2.2 || cr_lf || ,
  1766.     '                  Format Version:  ' || lfh_fmtv.2 || cr_lf || ,
  1767.     '                        Log Type:  ' || lfh_logtyp.2  || cr_lf || ,
  1768.     '     ' || cr_lf || ,
  1769.     '                   Log File Path:  ' || ,
  1770.                            strip(translate(lfh_logpath.2, ' ', '00'x )) || ,
  1771.                            cr_lf || ,
  1772.     '     ' || cr_lf || ,
  1773.     '     ' || cr_lf || ,
  1774.     '     ' || cr_lf || ,
  1775.     '     Number of Primary Log Files:  ' || lfh_logact.2  || cr_lf || ,
  1776.     '   Number of Secondary Log Files:  ' || lfh_logina.2  || cr_lf || ,
  1777.     'Number of Pages in each Log File:  ' || lfh_logsiz.2  || cr_lf || ,
  1778.     '     ' || cr_lf || ,
  1779.     '     ' || cr_lf || ,
  1780.     '     ' || cr_lf || ,
  1781.     hflag_text || ,
  1782.     '     ' || cr_lf || ,
  1783.     '     ' || cr_lf || ,
  1784.     '     ' || cr_lf || ,
  1785.     '                        Base LSN:  ' || lfh_baselsn.2  || cr_lf || ,
  1786.     '                        Next LSN:  ' || lfh_nextlsn.2  || cr_lf || ,
  1787.     '             Low Transaction LSN:  ' || lfh_lowlsn.2   || cr_lf || ,
  1788.     '              Minimum Buffer LSN:  ' || lfh_minblsn.2  || cr_lf || ,
  1789.     '                        Head LSN:  ' || lfh_headlsn.2  || cr_lf || ,
  1790.     '                        Tail LSN:  ' || lfh_taillsn.2  || cr_lf || ,
  1791.     '                  Truncation LSN:  ' || lfh_trnclsn.2  || cr_lf || ,
  1792.     '            Last Record Read LSN:  ' || lfh_lrdlsn.2   || cr_lf || ,
  1793.     '     ' || cr_lf || ,
  1794.     '     ' || cr_lf || ,
  1795.     '     ' || cr_lf || ,
  1796.     '            First Transaction ID:  ' || lfh_basetid.2  || cr_lf || ,
  1797.     '       Size of Transaction Table:  ' || lfh_ttblsiz.2  || cr_lf || ,
  1798.     '    Log Recs prior to Soft Chkpt:  ' || lfh_softmax.2  || cr_lf || ,
  1799.     '     ' || cr_lf || ,
  1800.     '     ' || cr_lf || ,
  1801.     '     ' || cr_lf || ,
  1802.     '                  Head Extent ID:  ' || lfh_headext.2  || cr_lf || ,
  1803.     '                  Last Extent ID:  ' || lfh_lastext.2  || cr_lf || ,
  1804.     '     Database Creation Extent ID:  ' || lfh_dbext.2    || cr_lf || ,
  1805.     '           Last Commit Extent ID:  ' || lfh_cmitext.2  || cr_lf || ,
  1806.     '        First Archived Extent ID:  ' || lfh_frstarc.2  || cr_lf || ,
  1807.     '         Last Archived Extent ID:  ' || lfh_lastarc.2  || cr_lf || ,
  1808.     '  First Media Recovery Extent ID:  ' || lfh_frstrec.2  || cr_lf || ,
  1809.     '   Next Media Recovery Extent ID:  ' || lfh_nextrec.2  || cr_lf || ,
  1810.     ' First M-Rcvry Deleted Extent ID:  ' || lfh_frstdel.2  || cr_lf || ,
  1811.     '  Last M-Rcvry Deleted Extent ID:  ' || lfh_lastdel.2  || cr_lf || ,
  1812.     '   Head Media Recovery Extent ID:  ' || lfh_headrec.2  || cr_lf || ,
  1813.     '            Truncation Extent ID:  ' || lfh_trncext.2  || cr_lf || ,
  1814.     '                        Last CID:  ' || lfh_lastcid.2  || cr_lf || ,
  1815.     '     '  || cr_lf || ,
  1816.     '     '  || cr_lf
  1817.  
  1818. call wrt2rpt  lfh_text
  1819.  
  1820.  
  1821.  
  1822. return
  1823.  
  1824.  
  1825.  
  1826. /******************************************************************
  1827. *  SUBROUTINE:   GETLFH_FIELDS                                    *
  1828. *                                                                 *
  1829. *  DESCRIPTIVE NAME: Get Data from the fields in the LFH          *
  1830. *                                                                 *
  1831. *  DESCRIPTION: This routine gets the data from the Log File      *
  1832. *               Header of the Log Control File.  This routine     *
  1833. *               retrieves the data from the primary LFH as well   *
  1834. *               as the secondary LFH depending upon the value     *
  1835. *               of the shared variable "lfhdr".  It stores the    *
  1836. *               values of the fields in the Primary LFH in a      *
  1837. *               compound variable "lfh_xxxxxx.1" and the values   *
  1838. *               of the fields in the Secondary LFH in another     *
  1839. *               compound variable "lfh_xxxxxx.2".                 *
  1840. *                                                                 *
  1841. *  INPUT: lfhdr - Offset to start of Primary or Secondary LFH.    *
  1842. *         lfh_i - Log File Header index                           *
  1843. *                     1 -> Primary LFH                            *
  1844. *                     2 -> Secondary LFH                          *
  1845. *                                                                 *
  1846. *  OUTPUT: none                                                   *
  1847. *                                                                 *
  1848. ******************************************************************/
  1849.  
  1850. getlfh_fields:
  1851.  
  1852.                                  /* Consistency Counter 1              */
  1853. lfh_cnt1.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_cnt1o, lfh_cnt1l)))
  1854.                                  /* Format Version                     */
  1855. lfh_fmtv.lfh_i = c2x(reverse(charin(logctl_name, lfhdr+lfh_fmtvo, lfh_fmtvl)))
  1856.                                  /* Log File Type */
  1857. lfh_logtyp.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_logtypo, lfh_logtypl)))
  1858.                                  /* Number of Primary Log Files */
  1859. lfh_logact.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_logacto, lfh_logactl)))
  1860.                                  /* Number of Secondary Log Files */
  1861. lfh_logina.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_loginao, lfh_loginal)))
  1862.                                  /* Total pages in Log Files */
  1863. lfh_logsiz.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_logsizo, lfh_logsizl)))
  1864.                                  /* Size of Transaction Table */
  1865. lfh_ttblsiz.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_ttblsizo, lfh_ttblsizl)))
  1866.                                  /* Records Written before Soft Checkpoint */
  1867. lfh_softmax.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_softmaxo, lfh_softmaxl)))
  1868.                                  /* First LSN after final Stop Using */
  1869. lfh_baselsn.lfh_i = c2x(charin(logctl_name, lfhdr+lfh_baselsno, lfh_baselsnl))
  1870.                                  /* Next LSN prior to final Stop Using */
  1871. lfh_nextlsn.lfh_i = c2x(charin(logctl_name, lfhdr+lfh_nextlsno, lfh_nextlsnl))
  1872.                                  /* First LSN of oldest in-flight trans */
  1873. lfh_lowlsn.lfh_i = c2x(charin(logctl_name, lfhdr+lfh_lowlsno, lfh_lowlsnl))
  1874.                                  /* First LSN of oldest page in buff pool */
  1875. lfh_minblsn.lfh_i = c2x(charin(logctl_name, lfhdr+lfh_minblsno, lfh_minblsnl))
  1876.                                  /* First TID after hard checkpoint */
  1877. lfh_basetid.lfh_i = c2x(charin(logctl_name, lfhdr+lfh_basetido, lfh_basetidl))
  1878.                                  /* LSN of Head of the Log File */
  1879. lfh_headlsn.lfh_i = c2x(charin(logctl_name, lfhdr+lfh_headlsno, lfh_headlsnl))
  1880.                                  /* Last LSN of the Log File */
  1881. lfh_taillsn.lfh_i = c2x(charin(logctl_name, lfhdr+lfh_taillsno, lfh_taillsnl))
  1882.                                  /* Log File Path */
  1883. lfh_logpath.lfh_i = charin(logctl_name, lfhdr+lfh_logpatho, lfh_logpathl)
  1884.                                  /* HFLAG */
  1885. lfh_hflag.lfh_i   = c2x(reverse(charin(logctl_name, lfhdr+lfh_hflago, lfh_hflagl)))
  1886.                                  /* Head Extent ID */
  1887. lfh_headext.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_headexto+2, 2)) || ,
  1888.                     reverse(charin(logctl_name, lfhdr+lfh_headexto, 2)), 5)
  1889.                                  /* Last Extent ID */
  1890. lfh_lastext.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_lastexto+2, 2)) || ,
  1891.                     reverse(charin(logctl_name, lfhdr+lfh_lastexto, 2)), 5)
  1892.                                  /* Database Creation Extent ID */
  1893. lfh_dbext.lfh_i   = c2d(reverse(charin(logctl_name, lfhdr+lfh_dbexto+2, 2)) || ,
  1894.                     reverse(charin(logctl_name, lfhdr+lfh_dbexto, 2)), 5)
  1895.                                  /* Last Commit Extent ID */
  1896. lfh_cmitext.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_cmitexto+2, 2)) || ,
  1897.                     reverse(charin(logctl_name, lfhdr+lfh_cmitexto, 2)), 5)
  1898.                                  /* First Archived Extent ID */
  1899. lfh_frstarc.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_frstarco+2, 2)) || ,
  1900.                     reverse(charin(logctl_name, lfhdr+lfh_frstarco, 2)), 5)
  1901.                                  /* Last Archived Extent ID */
  1902. lfh_lastarc.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_lastarco+2, 2)) || ,
  1903.                     reverse(charin(logctl_name, lfhdr+lfh_lastarco, 2)), 5)
  1904.                                  /* Next Media Recovery Extent ID */
  1905. lfh_nextrec.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_nextreco+2, 2)) || ,
  1906.                     reverse(charin(logctl_name, lfhdr+lfh_nextreco, 2)), 5)
  1907.                                  /* First Media Recovery Extent ID */
  1908. lfh_frstrec.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_frstreco+2, 2)) || ,
  1909.                     reverse(charin(logctl_name, lfhdr+lfh_frstreco, 2)), 5)
  1910.                                  /* First Media Recovery Deleted Extent ID */
  1911. lfh_frstdel.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_frstdelo+2, 2)) || ,
  1912.                     reverse(charin(logctl_name, lfhdr+lfh_frstdelo, 2)), 5)
  1913.                                  /* Last Media Recovery Deleted Extent ID */
  1914. lfh_lastdel.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_lastdelo+2, 2)) || ,
  1915.                     reverse(charin(logctl_name, lfhdr+lfh_lastdelo, 2)), 5)
  1916.                                  /* Head Media Recovery Extent ID */
  1917. lfh_headrec.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_headreco+2, 2)) || ,
  1918.                     reverse(charin(logctl_name, lfhdr+lfh_headreco, 2)), 5)
  1919.                                  /* Number of File in File Array */
  1920. lfh_filecnt.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_filecnto, lfh_filecntl)))
  1921.                                  /* Truncation LSN */
  1922. lfh_trnclsn.lfh_i = c2x(charin(logctl_name, lfhdr+lfh_trnclsno, lfh_trnclsnl))
  1923.                                  /* Truncation Extent ID */
  1924. lfh_trncext.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_trncexto+2, 2)) || ,
  1925.                     reverse(charin(logctl_name, lfhdr+lfh_trncexto, 2)), 5)
  1926.                                  /* Last CID */
  1927. lfh_lastcid.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_lastcido+2, 2)) || ,
  1928.                     reverse(charin(logctl_name, lfhdr+lfh_lastcido, 2)), 5)
  1929.                                  /* Last Record Read LSN */
  1930. lfh_lrdlsn.lfh_i  = c2x(charin(logctl_name, lfhdr+lfh_lrdlsno, lfh_lrdlsnl))
  1931.                                  /* Consistency Counter 2              */
  1932. lfh_cnt2.lfh_i = c2d(reverse(charin(logctl_name, lfhdr+lfh_cnt2o, lfh_cnt2l)))
  1933.  
  1934.  
  1935. return
  1936.  
  1937.  
  1938.  
  1939. /******************************************************************
  1940. *  SUBROUTINE:   UPDLSN                                           *
  1941. *                                                                 *
  1942. *  DESCRIPTIVE NAME: Update Base LSN                              *
  1943. *                                                                 *
  1944. *  DESCRIPTION: This routine updates the Base LSN fields in the   *
  1945. *               Log Control File to effectively reset the Log.    *
  1946. *               It sets the Base LSN to the highest LSN value     *
  1947. *               between the Base LSN itself, and the Page LSNs    *
  1948. *               from the Partial Page 1 of the Log Control File,  *
  1949. *               the Partial Page 2 of the Log Control File,       *
  1950. *               the LOGFILEHEAD, and the LOGFILETAIL.             *
  1951. *                                                                 *
  1952. *  INPUT: none                                                    *
  1953. *                                                                 *
  1954. *                                                                 *
  1955. *  OUTPUT: none                                                   *
  1956. *                                                                 *
  1957. ******************************************************************/
  1958.  
  1959. updlsn:
  1960.  
  1961.  
  1962. /*********************************************
  1963.    Determine the Currently Active Log File Header
  1964. *********************************************/
  1965. /* Compare the Consistency Count fields from both Log File Headers */
  1966. if lfh_cnt1.1 >= lfh_cnt1.2 then     /* Primary LFH is most recent */
  1967.   do
  1968.     active_lfh = lfhdr1      /* Set offset for using Primary Log File Header */
  1969.     act_i = 1                /* Index of active LFH                          */
  1970.  
  1971.     active_lfh_text = ,
  1972.           '     ' || cr_lf || ,
  1973.           '     ' || cr_lf || ,
  1974.           'Active Log File Header:  Primary' || cr_lf
  1975.   end
  1976. else                                 /* Secondary LFH is most recent */
  1977.   do
  1978.     active_lfh = lfhdr2      /* Set offset for using Secondary Log File Hdr  */
  1979.     act_i = 2                /* Index of active LFH                          */
  1980.  
  1981.     active_lfh_text = ,
  1982.           '     ' || cr_lf || ,
  1983.           '     ' || cr_lf || ,
  1984.           'Active Log File Header:  Secondary' || cr_lf
  1985.   end
  1986.  
  1987. call wrt2rpt  active_lfh_text
  1988.  
  1989.  
  1990.  
  1991. baselsn_reset = 'NO'      /* Initialize Base LSN reset indicator */
  1992. consist_cnt_reset = 'NO'  /* Initialize Consistency Count reset indicator */
  1993. hflag_reset = 'NO'        /* Initialize HFLAG reset indicator */
  1994.  
  1995. updlsn_text = ,
  1996.       '     ' || cr_lf || ,
  1997.       '     ' || cr_lf || ,
  1998.       'Base LSN Comparison: ' || cr_lf || ,
  1999.       '     ' || cr_lf || ,
  2000.       '.........Base LSN from Active Log Control File Header:  ' || ,
  2001.                                 lfh_baselsn.act_i || ,
  2002.                                 cr_lf || ,
  2003.       '.........Next LSN from Active Log Control File Header:  ' || ,
  2004.                                 lfh_nextlsn.act_i || ,
  2005.                                 cr_lf || ,
  2006.       '..........Low LSN from Active Log Control File Header:  ' || ,
  2007.                                 lfh_lowlsn.act_i || ,
  2008.                                 cr_lf || ,
  2009.       '.....Min Buff LSN from Active Log Control File Header:  ' || ,
  2010.                                 lfh_minblsn.act_i || ,
  2011.                                 cr_lf || ,
  2012.       '.........Head LSN from Active Log Control File Header:  ' || ,
  2013.                                 lfh_headlsn.act_i || ,
  2014.                                 cr_lf || ,
  2015.       '.........Tail LSN from Active Log Control File Header:  ' || ,
  2016.                                 lfh_taillsn.act_i || ,
  2017.                                 cr_lf || ,
  2018.       '...Truncation LSN from Active Log Control File Header:  ' || ,
  2019.                                 lfh_trnclsn.act_i || ,
  2020.                                 cr_lf || ,
  2021.       '....Last Read LSN from Active Log Control File Header:  ' || ,
  2022.                                 lfh_lrdlsn.act_i || ,
  2023.                                 cr_lf || ,
  2024.       '     ' || cr_lf || ,
  2025.       '     ' || cr_lf
  2026.  
  2027. call wrt2rpt  updlsn_text
  2028.  
  2029.  
  2030. /* Reset Base LSN to Next LSN if larger */
  2031. if lfh_baselsn.act_i < lfh_nextlsn.act_i then
  2032.   do
  2033.     lfh_baselsn.act_i = lfh_nextlsn.act_i
  2034.     baselsn_reset = 'YES'
  2035.    end
  2036.  
  2037. /* Reset Base LSN to Low LSN if larger */
  2038. if lfh_baselsn.act_i < lfh_lowlsn.act_i then
  2039.   do
  2040.     lfh_baselsn.act_i = lfh_lowlsn.act_i
  2041.     baselsn_reset = 'YES'
  2042.    end
  2043.  
  2044. /* Reset Base LSN to Min Buff LSN if larger */
  2045. if lfh_baselsn.act_i < lfh_minblsn.act_i then
  2046.   do
  2047.     lfh_baselsn.act_i = lfh_minblsn.act_i
  2048.     baselsn_reset = 'YES'
  2049.    end
  2050.  
  2051. /* Reset Base LSN to Head LSN if larger */
  2052. if lfh_baselsn.act_i < lfh_headlsn.act_i then
  2053.   do
  2054.     lfh_baselsn.act_i = lfh_headlsn.act_i
  2055.     baselsn_reset = 'YES'
  2056.    end
  2057.  
  2058. /* Reset Base LSN to Tail LSN if larger */
  2059. if lfh_baselsn.act_i < lfh_taillsn.act_i then
  2060.   do
  2061.     lfh_baselsn.act_i = lfh_taillsn.act_i
  2062.     baselsn_reset = 'YES'
  2063.    end
  2064.  
  2065. /* Reset Base LSN to Truncation LSN if larger */
  2066. if lfh_baselsn.act_i < lfh_trnclsn.act_i then
  2067.   do
  2068.     lfh_baselsn.act_i = lfh_trnclsn.act_i
  2069.     baselsn_reset = 'YES'
  2070.    end
  2071.  
  2072. /* Reset Base LSN to Last Read LSN if larger */
  2073. if lfh_baselsn.act_i < lfh_lrdlsn.act_i then
  2074.   do
  2075.     lfh_baselsn.act_i = lfh_lrdlsn.act_i
  2076.     baselsn_reset = 'YES'
  2077.    end
  2078.  
  2079.  
  2080. /* Update the Consistency Count in the Active Log File Header if necessary */
  2081. if lfh_cnt1.act_i \= lfh_cnt2.act_i then
  2082.   do
  2083.     lfh_cnt1.act_i = max(lfh_cnt1.act_i, lfh_cnt2.act_i)
  2084.     lfh_cnt2.act_i = lfh_cnt1.act_i
  2085.     consist_cnt_reset = 'YES'
  2086.   end
  2087.  
  2088.  
  2089. /* Update the HFLAG indicators in the Active Log File Header if necessary */
  2090. if lfh_hflag.act_i \= 1 then
  2091.   do
  2092.     lfh_hflag.act_i = 1            /* Mark database as consistent  */
  2093.     hflag_reset = 'YES'
  2094.   end
  2095.  
  2096.  
  2097. if baselsn_reset = 'NO' then
  2098.   do
  2099.     /* Increment Base LSN by Log File Size Factor if desired */
  2100.     /* Note: This routine may cause the Base LSN to be reset */
  2101.     /*         even though it has not been reset yet.        */
  2102.     call quantum_leap
  2103.   end
  2104.  
  2105. if ((baselsn_reset = 'NO') & ,
  2106.     (consist_cnt_reset = 'NO') & ,
  2107.     (hflag_reset = 'NO')) then
  2108.   do
  2109.     say 'The Log File Header appears to be in a reset state and has not been changed.'
  2110.     error_text = '     ' || cr_lf || ,
  2111.                  'The Log File Header appears to be in a reset state ' || ,
  2112.                  'and has not been changed.' || cr_lf || ,
  2113.                  '     ' || cr_lf
  2114.     call wrt2rpt  error_text
  2115.   end
  2116. else
  2117.   do
  2118.     if baselsn_reset = 'YES' then
  2119.       do
  2120.         /* Write the new Base LSN to the Log Control File */
  2121.         rc = charout(logctl_name, x2c(lfh_baselsn.act_i), active_lfh+lfh_baselsno)
  2122.  
  2123.         rst_text = 'The LFH has been reset with a new Base LSN of:  ' || ,
  2124.                            lfh_baselsn.act_i  || cr_lf
  2125.         say rst_text
  2126.         call wrt2rpt  rst_text
  2127.       end
  2128.  
  2129.     if consist_cnt_reset = 'YES' then
  2130.       do
  2131.         /* Write the two Consistency Count Values */
  2132.         rc = charout(logctl_name, d2c(lfh_cnt1.act_i), active_lfh+lfh_cnt1o)
  2133.         rc = charout(logctl_name, d2c(lfh_cnt2.act_i), active_lfh+lfh_cnt2o)
  2134.  
  2135.         rst_text = 'The LFH has been updated with a Consistency Count of:  ' || ,
  2136.                            lfh_cnt1.act_i  || cr_lf
  2137.         say rst_text
  2138.         call wrt2rpt  rst_text
  2139.       end
  2140.  
  2141.  
  2142.     if hflag_reset = 'YES' then
  2143.       do
  2144.         /* Write the new HFLAG value */
  2145.         rc = charout(logctl_name, x2c(lfh_hflag.act_i), active_lfh+lfh_hflago)
  2146.  
  2147.         rst_text = 'The LFH has been reset with an HFLAG value of:  ' || ,
  2148.                            lfh_hflag.act_i  || cr_lf
  2149.         say rst_text
  2150.         call wrt2rpt  rst_text
  2151.       end
  2152.  
  2153.   end
  2154.  
  2155.  
  2156. return
  2157.  
  2158.  
  2159.  
  2160.  
  2161. /******************************************************************
  2162. *  SUBROUTINE:   QUANTUM_LEAP                                     *
  2163. *                                                                 *
  2164. *  DESCRIPTIVE NAME: Increment the Base LSN by Log File Size      *
  2165. *                                                                 *
  2166. *  DESCRIPTION: This routine prompts the user to determine        *
  2167. *               if they would like to make a Quantum Leap by      *
  2168. *               incrementing the Base LSN by the size of a single *
  2169. *               Log File.  This may be necessary in some cases    *
  2170. *               (in which there has not been a previous soft      *
  2171. *               checkpoint) because the Log Control File will     *
  2172. *               not have the most current LSN information.        *
  2173. *                                                                 *
  2174. *               By incrementing the Base LSN by the size of a     *
  2175. *               single Log File, it is fairly certain that the    *
  2176. *               Base LSN will be incremented to a value which     *
  2177. *               will truly put it in a reset state.               *
  2178. *                                                                 *
  2179. *                                                                 *
  2180. *  INPUT: act_i - Shared variable containing the index number of  *
  2181. *                   Primary or Secondary Log File Header that is  *
  2182. *                   currently the active LFH.                     *
  2183. *                                                                 *
  2184. *                                                                 *
  2185. *  OUTPUT: none                                                   *
  2186. *                                                                 *
  2187. ******************************************************************/
  2188.  
  2189. quantum_leap:
  2190.  
  2191. say "     "
  2192. say ,
  2193.     " ╔══════════════════════════════════════════════════════════════════════╗ "
  2194. say ,
  2195.     " ║                                                                      ║ "
  2196. say ,
  2197.     " ║  From the information in the Log Control File, the Log already       ║ "
  2198. say ,
  2199.     " ║     appears to be in a Reset State.  In certain cases, this may      ║ "
  2200. say ,
  2201.     " ║     be misleading.                                                   ║ "
  2202. say ,
  2203.     " ║  Therefore, would you like to increase the Base LSN in order to      ║ "
  2204. say ,
  2205.     " ║     enhance the probability that the Log has actually been           ║ "
  2206. say ,
  2207.     " ║     reset?  (y/n)                                                    ║ "
  2208. say ,
  2209.     " ║           If so, type 'y' and press ENTER;                           ║ "
  2210. say ,
  2211.     " ║           Otherwise, type 'n' and press ENTER.                       ║ "
  2212. say ,
  2213.     " ║                                                                      ║ "
  2214. say ,
  2215.     " ╚══════════════════════════════════════════════════════════════════════╝ "
  2216. say "      "
  2217. say "      "
  2218. pull quantum_leap_answer
  2219.  
  2220.  
  2221. if quantum_leap_answer = 'Y' then
  2222.   do
  2223.  
  2224.     /* Increase the Base LSN by a factor equal to the size of a Log File */
  2225.     lfh_baselsn.act_i = d2x(x2d(lfh_baselsn.act_i) + (dbc_logsiz * 4096), (lfh_baselsnl*2))
  2226.  
  2227.     /* Report the Quantum Leap in the Report File */
  2228.     leap_text = '     ' || cr_lf || ,
  2229.                'A Quantum Leap of the Base LSN was requested.  ' || ,
  2230.                '     ' || cr_lf || ,
  2231.                '     ' || cr_lf
  2232.     call wrt2rpt  leap_text
  2233.  
  2234.     /* Set this flag so the new Base LSN will be written to the Log */
  2235.     baselsn_reset = 'YES'
  2236.  
  2237.   end
  2238.  
  2239.  
  2240.  
  2241. return
  2242.  
  2243.  
  2244.  
  2245. /******************************************************************
  2246. *  SUBROUTINE:   GENERAL_HELP                                     *
  2247. *                                                                 *
  2248. *  DESCRIPTIVE NAME: RESETLOG General Help                        *
  2249. *                                                                 *
  2250. *  DESCRIPTION: This routine displays the Help panels for the     *
  2251. *               Reset Log Control File tool.  This routine        *
  2252. *               receives control when the input parameter is      *
  2253. *               a "?" instead of the database name.  A brief      *
  2254. *               description of the RESETLOG Tool and its          *
  2255. *               syntax is included in the Help panels.            *
  2256. *                                                                 *
  2257. *  INPUT: none                                                    *
  2258. *                                                                 *
  2259. *                                                                 *
  2260. *  OUTPUT: none                                                   *
  2261. *                                                                 *
  2262. ******************************************************************/
  2263.  
  2264. general_help:
  2265.  
  2266.   /* Display help panel */
  2267.   say "      "
  2268.   say ,
  2269.   "     ┌────────────────────────────────────────────────────────────┐       "
  2270.   say ,
  2271.   "     │         ┌────────────────────────────────────────┐         │       "
  2272.   say ,
  2273.   "     │         │        ***  R E S E T L O G  ***       │         │       "
  2274.   say ,
  2275.   "     │         │        Reset the Log Control File      │         │       "
  2276.   say ,
  2277.   "     │         │               Version 3.1              │         │       "
  2278.   say ,
  2279.   "     │         └────────────────────────────────────────┘         │       "
  2280.   say ,
  2281.   "     │      ▀▀▀▀▀▀▀▀▀▀      ▀▀▀▀▀▀▀▀▀▀       ▀▀▀▀▀     ▀▀▀▀▀      │       "
  2282.   say ,
  2283.   "     │      ▀▀▀▀▀▀▀▀▀▀      ▀▀▀▀▀▀▀▀▀▀▀      ▀▀▀▀▀     ▀▀▀▀▀      │       "
  2284.   say ,
  2285.   "     │         ▀▀▀▀          ▀▀▀   ▀▀▀▀       ▀▀▀▀▀   ▀▀▀▀▀       │       "
  2286.   say ,
  2287.   "     │         ▀▀▀▀          ▀▀▀▀▀▀▀▀▀        ▀▀▀▀▀▀ ▀▀▀▀▀▀       │       "
  2288.   say ,
  2289.   "     │         ▀▀▀▀          ▀▀▀▀▀▀▀▀▀        ▀▀▀ ▀▀▀▀▀ ▀▀▀       │       "
  2290.   say ,
  2291.   "     │         ▀▀▀▀          ▀▀▀   ▀▀▀▀       ▀▀▀  ▀▀▀  ▀▀▀       │       "
  2292.   say ,
  2293.   "     │      ▀▀▀▀▀▀▀▀▀▀      ▀▀▀▀▀▀▀▀▀▀▀      ▀▀▀▀   ▀   ▀▀▀▀      │       "
  2294.   say ,
  2295.   "     │      ▀▀▀▀▀▀▀▀▀▀      ▀▀▀▀▀▀▀▀▀▀       ▀▀▀▀       ▀▀▀▀      │       "
  2296.   say ,
  2297.   "     └────────────────────────────────────────────────────────────┘       "
  2298.   say ,
  2299.   " ╔══════════════════════════════════════════════════════════════════════╗ "
  2300.   say ,
  2301.   " ║  The RESETLOG Tool is a mechanism for resetting the Log Control      ║ "
  2302.   say ,
  2303.   " ║  File which governs the recovery of the database from the            ║ "
  2304.   say ,
  2305.   " ║  Write-Ahead Log.  By reseting  the Log Control File,  the database  ║ "
  2306.   say ,
  2307.   " ║  will appear to be usable and not need recovery.                     ║ "
  2308.   say ,
  2309.   " ║  CAUTION:  The use of this tool will prevent committed changes       ║ "
  2310.   say ,
  2311.   " ║  which did not make it to media from being recovered and data        ║ "
  2312.   say ,
  2313.   " ║  integrity could be lost.                                            ║ "
  2314.   say ,
  2315.   " ╚══════════════════════════════════════════════════════════════════════╝ "
  2316.   say "      "
  2317.   'pause'
  2318.   say "      "
  2319.   say "      "
  2320.   say "      "
  2321.   say "      "
  2322.   say ,
  2323.   "      Syntax:   RESETLOG  [dbname]  [rptname]                             "
  2324.   say "      "
  2325.   say "      "
  2326.   say ,
  2327.   "       where:   [dbname]   is the alias name of the database.             "
  2328.   say "                       If no database name is specified , the user    "
  2329.   say "                          will be prompted for the database name.     "
  2330.   say "      "
  2331.   say "      "
  2332.   say ,
  2333.   "                [rptname]  is the report file name.                       "
  2334.   say "                       If no report file name is specified, then no   "
  2335.   say "                          report will be generated.                   "
  2336.   say "      "
  2337.   say "      "
  2338.   say "      "
  2339.   say "      "
  2340.   say "      "
  2341.   say "      "
  2342.   say "      "
  2343.   say "      "
  2344.  
  2345.  
  2346.   return
  2347.