.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 2000-2004 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VBD08$
.tt 2 $$$$
.tt 3 $$filesysteminterface_8$2000-11-06$
***********************************************************
.nf
 
 
    ========== licence begin  GPL
    Copyright (c) 2000-2004 SAP AG
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end
 
.fo
.nf
.sp
Module  : filesysteminterface_8
=========
.sp
Purpose : base layer operations :
          - database backup and restore
          - diagnose facilities
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              b08bytestr_diagnose (VAR t : tgg00_TransContext;
                    VAR b : tsp00_Page);
 
        PROCEDURE
              b08tree_diagnose (VAR t : tgg00_TransContext;
                    VAR b: tsp00_Page);
 
        PROCEDURE
              b08tstart_treediagnose (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId);
              (* PTS 1111574 E.Z. *)
 
        FUNCTION
              b08was_last_page : boolean;
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              filesysteminterface_1 : VBD01;
 
        VAR
              b01niltree_id : tgg00_FileId;
 
      ------------------------------ 
 
        FROM
              nodehandling : VBD13;
 
        PROCEDURE
              bd13GetNode (VAR Current : tbd_current_tree;
                    Pno          : tsp00_PageNo;
                    PageLockMode : tbd00_PageLockMode;
                    NodeReq      : tbd_node_request;
                    VAR Nptrs    : tbd_node_ptrs);
 
        PROCEDURE
              b13r_release_node (VAR nptr : tbd_node_ptrs;
                    VAR current : tbd_current_tree;
                    lru_info    : tbd_lru_info);
 
      ------------------------------ 
 
        FROM
              filedirectory : VBD17;
 
        PROCEDURE
              b17state_fdir (VAR fn : tgg00_Filename;
                    VAR fi          : tbd_fileinfo;
                    concurrent_file : boolean;
                    VAR t           : tgg00_TransContext);
 
      ------------------------------ 
 
        FROM
              treehandling : VBD30;
 
        PROCEDURE
              bd30BuildCurrent (
                    VAR trans   : tgg00_TransContext;
                    VAR fileId  : tgg00_FileId;
                    VAR current : tbd_current_tree);
 
      ------------------------------ 
 
        FROM
              branchhandling : VBD52;
 
        FUNCTION
              bd52SubtreePno (VAR nptr : tbd_nodeptr;
                    RecIndex : tsp00_Int4) : tsp00_PageNo;
 
      ------------------------------ 
 
        FROM
              RTE-Extension-20 : VSP20;
 
        FUNCTION
              s20or4a (VAR n : tbd_node; pos : tsp00_Int4) : tsp00_Int4;
&       ifdef TRACE
 
      ------------------------------ 
 
        FROM
              Test_Procedures : VTA01;
 
        PROCEDURE
              t01basis_error (layer : tgg00_Debug;
                    nam   : tsp00_Sname;
                    b_err : tgg00_BasisError);
 
        PROCEDURE
              t01filename (layer : tgg00_Debug;
                    fn : tgg00_Filename);
 
        PROCEDURE
              t01int4 (layer : tgg00_Debug;
                    nam : tsp00_Sname;
                    int : tsp00_Int4);
 
        PROCEDURE
              t01page (debug : tgg00_Debug;
                    VAR buf  : tsp00_Page;
                    startpos : tsp00_Int4;
                    endpos   : tsp00_Int4);
 
        PROCEDURE
              t01name (layer : tgg00_Debug;
                    nam : tsp00_Name);
&       endif
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        FUNCTION
              s20or4a;
 
              tsp00_MoveObj tbd_node
&             ifdef TRACE
&             endif
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : JuergenP
.sp
.cp 3
Created : 1979-09-05
.sp
.cp 3
Version : 2002-10-31
.sp
.cp 3
Release :      Date : 2000-11-06
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
 
.sp 3
b08start_backup (t,only_incremental,last_backup_vers,is_cold)
.sp
Initializes the complete or partial (incremental) dump
of the database depending on the value of
the parameter only_incremental.
One of the following messages, among others, is sent to e:
.br
   - e_ok
   - e_disk_not_accessible
   - e_sysbuf_storage_exceeded
.sp 3
The following routines transfer pages of different data types
to be stored in an external file; the parameter "finished"
indicates that the last page of a particular data type has been
sent:
.in 3
- b08conf_outcopy(t,b,e)
.br
- b08data_outcopy(t,b,finished,max_outpno,e)
.in 0
One of the following messages, among others, is sent to e:
.br
   - e_ok
   - b_disk_not_accessible
.sp 3
b08stop_data_outcopy(t,e)
.sp
This procedure terminates the save procedure for pages of the type
"data".  It initiates the flush of both the log cache and the
data cache and makes it possible for the next save phase to be
initiated.
.sp 3
b08incopy(t,b,incremental,e)
.sp
Pages are recopied to the database from the save copy in an external
file.  A distinction is drawn as to whether only parts of the
database are written back or a copy of the entire database is made.
The configuration page must be the first page to be sent.
One of the following messages, among others, is sent to e:
.br
   - e_ok
   - b_init_missing
   - b_sysbuf_storage_exceeded
   - b_disk_not_accessible
.sp 3
br
   - e_ok
   - b_disk_not_accessible
.sp 3
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
 
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
 
 
VAR
 
      b08memory : RECORD
            mem_leftmost_bd08 : tsp00_PageNo;
            mem_next_pno_bd08 : tsp00_PageNo
      END;
 
      b08treeid : tgg00_FileId;
 
 
(*------------------------------*) 
 
PROCEDURE
      b08bytestr_diagnose (VAR t : tgg00_TransContext;
            VAR b : tsp00_Page);
 
VAR
      nptr     : tbd_univ_ptr;
      aux_nptr : tbd_node_ptrs;
      current  : tbd_current_tree;
 
BEGIN
&ifdef TRACE
t01name (bi, '====> bytestr diag');
&endif
t.trError_gg00 := e_ok;
WITH b08memory DO
    BEGIN
    bd30BuildCurrent (t, b08treeid, current);
    IF  mem_next_pno_bd08 <> NIL_PAGE_NO_GG00
    THEN
        bd13GetNode (current, mem_next_pno_bd08, plmLock_ebd00, nr_for_read, aux_nptr)
    ELSE
        t.trError_gg00 := e_no_next_record;
    (*ENDIF*) 
    IF  t.trError_gg00 = e_ok
    THEN
        BEGIN
        nptr.nodeaddr     := aux_nptr.np_ptr;
        b                 := nptr.bufaddr^;
        mem_next_pno_bd08 := nptr.nodeaddr^.nd_right;
        IF  mem_next_pno_bd08 = NIL_PAGE_NO_GG00
        THEN
            IF  nptr.nodeaddr^.nd_level <> LEAF_LEVEL_BD00
            THEN
                BEGIN
                IF  nptr.nodeaddr^.nd_id = current.curr_tree_id.fileRoot_gg00
                THEN
                    mem_next_pno_bd08 := s20or4a(nptr.nodeaddr^,BODY_BEG_BD00)
                ELSE
                    BEGIN
                    b13r_release_node (aux_nptr, current, lru_normal);
                    bd13GetNode (current, mem_leftmost_bd08, plmLock_ebd00, nr_for_read, aux_nptr);
                    nptr.nodeaddr := aux_nptr.np_ptr;
                    IF  t.trError_gg00 = e_ok
                    THEN
                        mem_next_pno_bd08 := s20or4a (nptr.nodeaddr^,BODY_BEG_BD00)
                    (*ENDIF*) 
                    END;
                (*ENDIF*) 
                mem_leftmost_bd08 := mem_next_pno_bd08
                END;
            (*ENDIF*) 
        (*ENDIF*) 
        b13r_release_node (aux_nptr, current, lru_normal)
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
t01page        (bi, b, 1, 20);
t01basis_error (bi, 'end bytestr ', t.trError_gg00);
&endif
END;
 
(*------------------------------*) 
 
PROCEDURE
      b08tree_diagnose (VAR t : tgg00_TransContext;
            VAR b : tsp00_Page);
 
VAR
      nptr     : tbd_univ_ptr;
      aux_nptr : tbd_node_ptrs;
      current  : tbd_current_tree;
 
BEGIN
&ifdef TRACE
t01name (bi, '====> tree diag   ');
&endif
t.trError_gg00 := e_ok;
WITH b08memory DO
    BEGIN
    bd30BuildCurrent (t, b08treeid, current);
    IF  mem_next_pno_bd08 <> NIL_PAGE_NO_GG00
    THEN
        bd13GetNode (current, mem_next_pno_bd08, plmLock_ebd00, nr_for_read, aux_nptr)
    ELSE
        t.trError_gg00 := e_no_next_record;
    (*ENDIF*) 
    IF  t.trError_gg00 = e_ok
    THEN
        BEGIN
        nptr.nodeaddr     := aux_nptr.np_ptr;
        b                 := nptr.bufaddr^;
        mem_next_pno_bd08 := nptr.nodeaddr^.nd_right;
        IF  mem_next_pno_bd08 = NIL_PAGE_NO_GG00
        THEN
            IF  nptr.nodeaddr^.nd_level <> LEAF_LEVEL_BD00
            THEN
                BEGIN
                IF  nptr.nodeaddr^.nd_id = current.curr_tree_id.fileRoot_gg00
                THEN
                    mem_next_pno_bd08 := bd52SubtreePno (nptr.nodeaddr, FIRST_REC_INDEX_BD00)
                ELSE
                    BEGIN
                    b13r_release_node (aux_nptr, current, lru_normal);
                    bd13GetNode (current, mem_leftmost_bd08, plmLock_ebd00, nr_for_read, aux_nptr);
                    nptr.nodeaddr := aux_nptr.np_ptr;
                    IF  t.trError_gg00 = e_ok
                    THEN
                        mem_next_pno_bd08 := bd52SubtreePno (nptr.nodeaddr, FIRST_REC_INDEX_BD00)
                    (*ENDIF*) 
                    END;
                (*ENDIF*) 
                mem_leftmost_bd08 := mem_next_pno_bd08
                END;
            (*ENDIF*) 
        (*ENDIF*) 
        b13r_release_node (aux_nptr, current, lru_normal)
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
t01page        (bi, b, 1, 20);
t01basis_error (bi, 'end tree dia', t.trError_gg00);
&endif
END;
 
(*------------------------------*) 
 
PROCEDURE
      b08tstart_treediagnose (VAR t : tgg00_TransContext;
            VAR file_id : tgg00_FileId);
 
VAR
      fi      : tbd_fileinfo;
 
BEGIN
&ifdef TRACE
t01name (bi, '====> st tree diag');
&endif
t.trError_gg00 := e_ok;
b08treeid := b01niltree_id;
IF  file_id.fileRoot_gg00 <> NIL_PAGE_NO_GG00
THEN
    BEGIN
&   ifdef TRACE
    t01int4 (bi, 'treeroot    ', file_id.fileRoot_gg00);
&   endif
    file_id.fileType_gg00   := [ ftsPerm_egg00 ];
    file_id.fileTfn_gg00    := tfnAux_egg00;
    b08treeid.fileRoot_gg00 := file_id.fileRoot_gg00;
    b08treeid.fileType_gg00 := [ ftsPerm_egg00 ];
    b08treeid.fileTfn_gg00  := tfnAux_egg00
    END
ELSE
    BEGIN
&   ifdef TRACE
    t01filename (bi, file_id.fileName_gg00);
&   endif
    b17state_fdir (file_id.fileName_gg00, fi, ftsShared_egg00 in file_id.fileType_gg00, t);
    IF  t.trError_gg00 = e_ok
    THEN
        BEGIN
        file_id.fileRoot_gg00   := fi.fi_root;
        file_id.fileType_gg00   := fi.fi_type;
        b08treeid.fileRoot_gg00 := fi.fi_root;
        b08treeid.fileType_gg00 := fi.fi_type;
        b08treeid.fileName_gg00 := file_id.fileName_gg00
        END
    (*ENDIF*) 
    END;
(*ENDIF*) 
IF  t.trError_gg00 = e_ok
THEN
    BEGIN
    b08memory.mem_leftmost_bd08 := b08treeid.fileRoot_gg00;
    b08memory.mem_next_pno_bd08 := b08treeid.fileRoot_gg00
    END;
&ifdef TRACE
(*ENDIF*) 
t01basis_error (bi, 'end s tree d', t.trError_gg00);
&endif
END;
 
(* PTS 1111574 E.Z. *)
(*------------------------------*) 
 
FUNCTION
      b08was_last_page : boolean;
 
BEGIN
b08was_last_page := ((b08memory.mem_leftmost_bd08 < b08memory.mem_next_pno_bd08) AND
      (b08memory.mem_next_pno_bd08 <> NIL_PAGE_NO_GG00));
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :         71
*-PRETTY-*  lines of code :        205        PRETTYX 3.10 
*-PRETTY-*  lines in file :        485         1997-12-10 
.PA 
