/*MAIN
 Overview
 
 UNLOAD is executed at the beginning of all reconstructions to copy and save away
    information from critical tables into their undo counterparts so as to enable
    a rollback of all sessions to the state just prior to their running, should 
    a rollback ever be needed.
MAIN*/

/*ARGUMENTS
  Arguments
 
  Procedure UNLOAD takes no arguments.
ARGUMENTS*/

/*DEPENDENCIES
 Dependencies
 
 The following are the procedures called by UNLOAD (listed in their
 order of call):
   - SWITCH.  This is the package that manipulates the switches for all
     the reconstruction rules.

   - OPEN_AND_PARSE.  This function combines what would otherwise have
     been separate calls to the native Oracle DBMS_SQL.OPEN_CURSOR and
     DBMS_SQL.PARSE procedures, into a single function.

   - DBMS_UTILITY.GET_TIME.  The GET_TIME function of the native oracle package
     DBMS_UTILITY returns the elapsed time since an arbitrary time in 100ths of 
     seconds

   - EXECUTE_AND_CLOSE.  This function combines what would otherwise have
     been separate calls to the native Oracle DBMS_SQL.EXECUTE and
     DBMS_SQL.CLOSE procedures, into a single function.

   - TRUNCATE_OBJECT.  This procedure truncates the specified object.

   - LOG_FILE.  This is a package of procedures which handle the tasks of
     creating the file in which reconstruction output messages will be written
     to, writing to the latter file, and closing it at the end of
     reconstruction.

   - DBMS_SQL.  This the native Oracle dynamic SQL package.
DEPENDENCIES*/

/*VARIABLES
 Variables

 The following are variables used in the procedure:
   - C (INTEGER). Cursor handle.

   - EXECUTE1 (INTEGER).  The number of rows processed by the SQL statement
     if that statement is an UPDATE, INSERT, or DELETE.  If the SQL statement is
     not an UPDATE, INSERT, or DELETE, this value should be ignored.
VARIABLES*/

/*EXAMPLES
  Examples
 
  Here is a call to UNLOAD:
 
   BEGIN
       UNLOAD;
   END;
   /

 Note that this procedure takes no arguments.
EXAMPLES*/

/*EXCEPTIONS
 Exceptions

 There are no named exceptions for this procedure, except for the generic one
   WHEN OTHERS.  When the latter is triggered, the error message is outputted
   along with the name of the module that erred, and any cursors that may still
   be opened are closed.  
EXCEPTIONS*/

/*ERRORS
 Errors

 There are no errors that this procedure is known to generate.  Should an
   error occur, take action based on the description of the error. 
ERRORS*/

/*TABLES
 Tables
 
 The following tables are referenced in this procedure:
   - LOGT.  This is the log table in which the states of all rules are dynamically
     posted and computed before being written to the system_state table.

   - AFST.  This is the accumulated frames statistics table, which stores statistic
     information for all major frames.

   - AFST_UNDO.  This is the undo version of the AFST used during a rollback.

   - IFST.  This is the Inverted frames statistics table, which stores information
     on all inverted minor frames in the BFST.

   - IFST_UNDO.  This is the undo version of the IFST used during a rollback.

   - MNFLT1, MNFLT2, MNFLT3, MNFLT4, and MNFLT5.  These are the five minor frames
     location tables, each one of which stores the location of a range of minor 
     frames for reconstructed major frames.

   - MNFLT1_UNDO, MNFLT2_UNDO, MNFLT3_UNDO, MNFLT4_UNDO, and MNFLT5_UNDO.  These
     are the undo versions of the minor frames location tables used during a 
     rollback.

   - MNFFPT.  This is the minor frame file pointer table used to keep statistic 
     information on at most one thousand sessions.

   - MNFFPT_UNDO.  This is the undo version of the MNFFPT used during a rollback.

   - SYSTEM_STATE.  This is the system state table used to keep track of all rules'
     states dynamically.

   - SYSTEM_STATE_UNDO.  This is the undo version of the SYSTEM_STATE table.

   - CS_STATE_REPORT.  This is the conseq state report table used to keep track of
     the state of conseqs in the BFST.

   - CS_STATE_REPORT_UNDO.  This is the undo version of the CS_STATE_REPORT table
     used during a rollback.

 For more information on these and other tables, see the documentation on tables.
TABLES*/

/*OTHERS
 Others
 
 It should be noted that with this procedure one may only rollback by one session.
   To rollback further one should import from tape the tables of interest from the
   time desired.  

 Also note that in this procedure table LOGT is updated through INSERT and UPDATE
   statements whereas in other procedures (except INITIALIZE and UPDATE_MNFFPT, 
   RECONSTRUCTION1, RECONSTRUCTION2, and RECONSTRUCTION3), table LOGT is updated 
   through the RULES_STATES package.  The reason for the latter is because the
   session's pointer has not been assigned through procedure UPDATE_MNFFPT, and 
   the events count has not been initialized through procedure POST_STATE.INIT_EVENT.

 For more details on this procedure or on rolling back to previous states, see the 
 reconstruction documentation.
OTHERS*/
