.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$VBD52$
.tt 2 $$$
.tt 3 $JuergenP$branchhandling$1999-03-31$
***********************************************************
.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  : branchhandling
=========
.sp
Purpose : operations on separators within index nodes
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              bd52GetSepKey (VAR nptr : tbd_nodeptr;
                    RecIndex   : tsp00_Int4;
                    VAR SepKey : tgg00_Lkey;
                    t          : tgg00_TransContextPtr);
 
        PROCEDURE
              bd52PutSeparatorIntoNode (VAR nptr : tbd_nodeptr;
                    RecIndex      : tsp00_Int4;
                    VAR Separator : tbd00_Separator;
                    t             : tgg00_TransContextPtr);
 
        PROCEDURE
              bd52PutSepLeafCount (pRec : tgg00_RecPtr;
                    LeafCount     : tsp00_Int4);
 
        FUNCTION
              bd52SubtreePno (VAR nptr : tbd_nodeptr;
                    RecIndex : tsp00_Int4) : tsp00_PageNo;
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              error_text_handling : VBD06;
 
        PROCEDURE
              b06dump_bad_page (pid : tsp00_TaskId;
                    page_type_flag : char;
                    file_ext       : tsp00_C4;
                    bad_pno        : tsp00_Int4;
                    buf_ptr        : tbd_nodeptr;
                    curr_buf_cnt   : integer);
 
      ------------------------------ 
 
        FROM
              Configuration_Parameter : VGG01;
 
        PROCEDURE
              g01key_assign (VAR source_key : tgg00_Lkey;
                    VAR target_key : tgg00_Lkey;
                    VAR e          : tgg00_BasisError);
 
      ------------------------------ 
 
        FROM
              GG_cpp_auxiliary_functions : VGG06;
 
        FUNCTION
              gg06PnoGet (VAR Cint4 : tgg90_Cint4): tsp00_Int4;
 
        PROCEDURE
              gg06PnoPut (VAR Cint4 : tgg90_Cint4; int4 : tsp00_Int4);
 
      ------------------------------ 
 
        FROM
              Kernel_move_and_fill : VGG101;
 
        PROCEDURE
              SAPDB_PascalMove (
                    mod_id      : tsp00_C6;
                    mod_num     : tsp00_Int4;
                    source_upb  : tsp00_Int4;
                    dest_upb    : tsp00_Int4;
                    source      : tsp00_MoveObjPtr;
                    src_pos     : tsp00_Int4;
                    destin      : tsp00_MoveObjPtr;
                    dest_pos    : tsp00_Int4;
                    length      : tsp00_Int4;
                    VAR e       : tgg00_BasisError);
 
        PROCEDURE
              g10mv (
                    mod_id      : tsp00_C6;            
                    mod_num     : tsp00_Int4;
                    source_upb  : tsp00_Int4;          
                    dest_upb    : tsp00_Int4;
                    source      : tsp00_MoveObjPtr;       
                    src_pos     : tsp00_Int4;
                    destin      : tsp00_MoveObjPtr;       
                    dest_pos    : tsp00_Int4;
                    length      : tsp00_Int4;
                    VAR e       : tgg00_BasisError);
 
        PROCEDURE
              s10mv (
                    source_upb  : tsp00_Int4;       
                    destin_upb  : tsp00_Int4;
                    source      : tsp00_MoveObjPtr;    
                    source_pos  : tsp00_Int4;
                    destin      : tsp00_MoveObjPtr;    
                    destin_pos  : tsp00_Int4;
                    length      : tsp00_Int4);
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              b06dump_bad_page;
 
              tbd_univ_ptr tbd_nodeptr
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : JuergenP
.sp
.cp 3
Created : 1980-02-28
.sp
.cp 3
Version : 2002-07-29
.sp
.cp 3
Release :      Date : 1999-03-31
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
 
The routines described below operate on the entries of the nodes of
current B* index, which are called branch entries.  A branch entry is
made up of a key (called a separator) and a pointer to the root of a subtree.
The current B* index is the index section of the B* tree, which is
determined by the last call of the routine 30adjust_tree to have been
called; if there is no such call, the effect of the routines remains
undefined.
.sp 2
   b52pseparator_put (nptr,bothkeys,index,sep)
.sp
This routine forms a new branch entry with the separator 'sep'
and an undefined pointer and inserts it in the
node addressed by 'nptr' beginning at a position referenced by 'index'.
'bothkeys' indicates whether the separator consists of one or two keys.
.sp 2
   b52gseparator_get (nptr,bothkeys,index,sep)
.sp
Supplies in sep the separator from the branch entry that
resides in the node addressed by 'nptr' beginning at a position
referenced by index.
'bothkeys' indicates whether the separator consists of one or two keys.
.sp 2
   b52put_subtree (subroot,nptr,index)
.sp
Inserts a pointer to the subtree with the page number 'subroot'
in the branch entry beginning in the node addressed by 'nptr'
at a position referenced by 'index'.
.sp 2
   b52get_subtree(nptr,index,subroot)
.sp
Supplies in 'subroot' the page number of the subtree that is
referenced by a pointer contained in the branch entry beginning
in the node addressed by 'nptr' at a position referenced by 'index'.
.sp 2
   b52branchlength(nptr,index) : branch_length
.sp
Supplies the length of the branch entry beginning in the node addressed
by 'nptr' at a position referenced by 'index'.
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
The separators contained in the B* index of the current tree
either all have the same fixed length or are of variable length.
This information is supplied as follows when b30adjust_tree is called;
in the former case, current.st contains the length and in the second
case, it is set to 'varying'.
.sp
A branch is formed by the concatenation of the separator with
the subtree pointer.  When separator length is variable, the
length of the entire branch entry is indicated in a 1-byte
length prefix (itself belonging to the branch entry).  The separator
is always entered in the current length without (its own) length prefix.
The subtree pointer consists of the last 3 bytes
(ptrfieldsize) of the relevant page number; this means that the
first byte of the page number must not be significant!
.sp
The maximum length of a branch entry (maxbranchlength) is reached
in the case of variable separator length if there is a separator of
the maximum length (1+maxkeylength+ptrfieldsize).
.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    :
 
 
(*------------------------------*) 
 
PROCEDURE
      bd52GetSepKey (VAR nptr : tbd_nodeptr;
            RecIndex   : tsp00_Int4;
            VAR SepKey : tgg00_Lkey;
            t          : tgg00_TransContextPtr);
 
VAR
      pRec : tgg00_RecPtr;
 
BEGIN
WITH t^, nptr^ DO
    IF  trError_gg00 <> e_data_page_corrupted
    THEN
        BEGIN
        pRec := @nd_body [nd_pointer_list [MAX_POINTERINDEX_BD00 - RecIndex]];
        g01key_assign (pRec^.recKey_gg00, SepKey, trError_gg00);
        IF  trError_gg00 = e_move_error
        THEN
            BEGIN
            trError_gg00 := e_data_page_corrupted;
            b06dump_bad_page (trTaskId_gg00, 'd', FILE_EXT_COR_BD00,
                  nd_id, nptr, 1);
            END
        (*ENDIF*) 
        END
    (*ENDIF*) 
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      bd52PutSeparatorIntoNode (VAR nptr : tbd_nodeptr;
            RecIndex      : tsp00_Int4;
            VAR Separator : tbd00_Separator;
            t             : tgg00_TransContextPtr);
 
VAR
      RecPos : tsp00_Int4;
      pRec   : tgg00_RecPtr;
 
BEGIN
WITH t^, nptr^ DO
    IF  trError_gg00 <> e_data_page_corrupted
    THEN
        BEGIN
        RecPos := nd_pointer_list [MAX_POINTERINDEX_BD00 - RecIndex];
        pRec   := @nd_body [RecPos];
        g10mv ('VBD52 ',   1,    
              sizeof (Separator), sizeof (nptr^) - RecPos + 1,
              @Separator, 1, @pRec^, 1,
              Separator.sepHead_bd00.hrecLen_gg00, trError_gg00);
        IF  trError_gg00 = e_move_error
        THEN
            BEGIN
            trError_gg00 := e_data_page_corrupted;
            b06dump_bad_page (trTaskId_gg00, 'd', FILE_EXT_COR_BD00,
                  nd_id, nptr, 1);
            END
        (*ENDIF*) 
        END
    (*ENDIF*) 
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      bd52PutSepLeafCount (pRec : tgg00_RecPtr;
            LeafCount : tsp00_Int4);
 
VAR
      pSepLeafCount : ^tbd00_SepLeafCount;
 
BEGIN
pSepLeafCount := @pRec^.recBody_gg00 [pRec^.recKeyLen_gg00+1];
gg06PnoPut (pSepLeafCount^, LeafCount);
END;
 
(*------------------------------*) 
 
FUNCTION
      bd52SubtreePno (VAR nptr : tbd_nodeptr;
            RecIndex : tsp00_Int4) : tsp00_PageNo;
 
VAR
      pRec : tgg00_RecPtr;
 
BEGIN
pRec           := @nptr^.nd_body [nptr^.nd_pointer_list [MAX_POINTERINDEX_BD00 - RecIndex]];
bd52SubtreePno := gg06PnoGet (pRec^.recPno_gg00)
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :         19
*-PRETTY-*  lines of code :         94        PRETTYX 3.10 
*-PRETTY-*  lines in file :        336         1997-12-10 
.PA 
