.ad 8
.bm 8
.fm 4
.bt $Copyright by SAP AG, 2002$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VBD02$
.tt 2 $$$$
.tt 3 $JuergenP$filesysteminterface_2$$2001-03-12$
***********************************************************
.nf
 
 
    ========== licence begin  GPL
    Copyright (C) 2000 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_2
=========
.sp
Purpose : base layer operations :
            - processing primary trees
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              b02add_record (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    VAR b       : tgg00_Rec                (*ptocConst*));
 
        PROCEDURE
              b02calculate_page_count (VAR t : tgg00_TransContext;
                    VAR file_id      : tgg00_FileId;
                    VAR startkey     : tgg00_Lkey;
                    VAR stopkey      : tgg00_Lkey;
                    VAR page_count   : tsp00_Int4);
 
        PROCEDURE
              b02col_next_stringcol (VAR t : tgg00_TransContext;
                    VAR file_id       : tgg00_FileId;
                    string_col_cnt    : integer;
                    VAR rk            : tgg00_Lkey;
                    VAR string_col_no : integer;
                    VAR col_id        : tgg00_FileId;
                    VAR file_pos      : tgg00_FilePos);
 
        PROCEDURE
              b02del_record (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    VAR rk      : tgg00_Lkey               (*ptocConst*));
 
        PROCEDURE
              b02eval_page_count (VAR t : tgg00_TransContext;
                    VAR file_id      : tgg00_FileId;
                    VAR startkey     : tgg00_Lkey;
                    VAR stopkey      : tgg00_Lkey;
                    count_records    : boolean;
                    VAR page_count   : tsp00_Int4;
                    VAR all_page_cnt : tsp00_Int4;
                    VAR record_cnt   : tsp00_Int4);
 
        PROCEDURE
              b02exists_record (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    VAR rk      : tgg00_Lkey);
 
        PROCEDURE
              b02file_outcopy (VAR mbuf : tgg00_MessBlock);
 
        PROCEDURE
              b02find_leaf (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    VAR key     : tgg00_Lkey);
 
        PROCEDURE
              b02finish_load (VAR t : tgg00_TransContext;
                    VAR file_id    : tgg00_FileId;
                    rightmost_leaf : tsp00_PageNo);
 
        PROCEDURE
              b02get_lock_record (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    VAR rk      : tgg00_Lkey;
                    VAR b       : tgg00_Rec);
 
        PROCEDURE
              b02get_record (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    VAR rk      : tgg00_Lkey               (*ptocConst*);
                    VAR b       : tgg00_Rec);
 
        PROCEDURE
              b02init_load (VAR t : tgg00_TransContext;
                    VAR file_id        : tgg00_FileId;
                    set_read_only      : boolean;
                    VAR rightmost_leaf : tsp00_PageNo);
 
        PROCEDURE
              b02kb_del_rec (VAR m  : tgg00_MessBlock;
                    pDeleteCmd      : tsp00_Addr;
                    VAR rk          : tgg00_Lkey;
                    VAR old_recbuf  : tgg00_Rec;
                    granted_lock    : tgg00_LockReqMode);
 
        PROCEDURE
              b02kb_ins_record (VAR m : tgg00_MessBlock;
                    pInsertCmd        : tsp00_Addr;
                    VAR b             : tgg00_Rec;
                    granted_lock      : tgg00_LockReqMode);
 
        PROCEDURE
              b02kb_select_rec (VAR t : tgg00_TransContext;
                    VAR file_id      : tgg00_FileId;
                    VAR RecKey       : tsp00_Key (* ptocSynonym tsp00_KeyPtr *);
                    VAR RecKeyLen    : tsp00_Int2;
                    VAR StopKey      : tsp00_Key (* ptocSynonym tsp00_KeyPtr *);
                    StopKeyLen       : tsp00_Int4;
                    recbuf_size      : tsp00_Int4;
                    recbuf_ptr       : tsp00_MoveObjPtr;
                    ignore_vwait     : boolean;
                    VAR sel          : tgg00_SelectFieldsParam;
                    VAR stack_desc   : tgg00_StackDesc;
                    VAR unqualified  : boolean;
                    VAR granted_lock : tgg00_LockReqMode);
 
        PROCEDURE
              b02kb_upd_rec (VAR m : tgg00_MessBlock;
                    pUpdateCmd     : tsp00_Addr;
                    VAR rk         : tgg00_Lkey;
                    VAR old_recbuf : tgg00_Rec;
                    VAR new_recbuf : tgg00_Rec;
                    granted_lock   : tgg00_LockReqMode);
 
        PROCEDURE
              b02load_table (VAR t : tgg00_TransContext;
                    VAR tree_id        : tgg00_FileId;
                    VAR rightmost_leaf : tsp00_PageNo;
                    VAR check_leaf     : tsp00_PageNo;
                    load_buf_len       : tsp00_Int4;
                    VAR load_buf       : tsp00_MoveObj);
 
        PROCEDURE
              b02next_record (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    VAR rk      : tgg00_Lkey;
                    inclusive   : boolean;
                    VAR b       : tgg00_Rec);
 
        PROCEDURE
              b02prefetch (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    pno         : tsp00_PageNo);
 
        PROCEDURE
              b02prev_record (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    VAR rk      : tgg00_Lkey;
                    inclusive   : boolean;
                    VAR b       : tgg00_Rec);
 
        PROCEDURE
              b02range_exi_rec (VAR t : tgg00_TransContext;
                    VAR file_id      : tgg00_FileId;
                    VAR left___pages : tsp00_Int4;
                    VAR middle_pages : tsp00_Int4;
                    VAR right__pages : tsp00_Int4;
                    VAR rk_the_one   : tgg00_Lkey;
                    VAR rk_another   : tgg00_Lkey);
 
        PROCEDURE
              b02reorg_treeindex (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    VAR rk      : tgg00_Lkey);
 
        PROCEDURE
              b02repl_record (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    VAR b       : tgg00_Rec                (*ptocConst*));
 
        PROCEDURE
              b02select_record (VAR t : tgg00_TransContext;
                    VAR file_id     : tgg00_FileId;
                    VAR RecKey      : tsp00_Key;
                    VAR RecKeyLen   : tsp00_Int2;
                    VAR StopKey     : tsp00_Key;
                    StopKeyLen      : tsp00_Int4;
                    recbuf_size     : tsp00_Int4;
                    recbuf_ptr      : tsp00_MoveObjPtr;
                    VAR sel         : tgg00_SelectFieldsParam;
                    VAR stack_desc  : tgg00_StackDesc;
                    VAR unqualified : boolean);
 
        PROCEDURE
              b02u_init_unload (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId);
 
        PROCEDURE
              b02unload_table (VAR t : tgg00_TransContext;
                    VAR tree_id     : tgg00_FileId;
                    VAR pno         : tsp00_PageNo;
                    VAR pno_x       : tsp00_PageNo;
                    ret_buf_size    : tsp00_Int4;
                    VAR ret_buf     : tsp00_MoveObj;
                    VAR ret_buf_len : tsp00_Int4);
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              filesysteminterface_1 :  VBD01;
 
        VAR
              b01downfilesystem : boolean;
 
        PROCEDURE
              b01bcreate_bytestr (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId);
 
        PROCEDURE
              b01destroy_file (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId);
 
      ------------------------------ 
 
        FROM
              filesysteminterface_5 : VBD05;
 
        PROCEDURE
              b05finish_load (rightmost_leaf : tsp00_PageNo;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              b05init_load (VAR rightmost_leaf : tsp00_PageNo;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              b05load_string (VAR lnptr : tbd_node_ptrs;
                    VAR nptr     : tbd_node_ptrs;
                    VAR left_pno : tsp00_PageNo;
                    VAR current  : tbd_current_tree);
 
        PROCEDURE
              b05save_quick (VAR pno : tsp00_PageNo;
                    VAR nptr    : tbd_node_ptrs;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              b05trunc_bytestr (VAR t : tgg00_TransContext;
                    VAR file_id    : tgg00_FileId;
                    new_filelength : tsp00_Int4;
                    str_vers       : tsp00_Int4);
 
      ------------------------------ 
 
        FROM
              error_text_handling : VBD06;
 
        PROCEDURE
              b06illegal_root_access (VAR current : tbd_current_tree);
&       ifdef vers80
 
        PROCEDURE
              b06record_check (
                    VAR rec    : tgg00_Rec;
                    VAR fileId : tgg00_FileId;
                    VAR b_err  : tgg00_BasisError);
&       endif
 
      ------------------------------ 
 
        FROM
              Trace : VBD120;
 
        PROCEDURE
              b120InsertTrace (VAR t   : tgg00_TransContext;
                    trace_layer  : tgg00_Debug;
                    trace_object : tgg00_VtraceType;
                    body_len     : tsp00_Int2;
                    trace_body   : tgg11_VtraceBodyPtr);
 
      ------------------------------ 
 
        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
              b13init_default_data_page (
                    VAR Trans   : tgg00_TransContext;
                    VAR FileId  : tgg00_FileId;
                    Level       : tsp00_Int2;
                    NewPno      : tsp00_PageNo;
                    VAR Nptrs   : tbd_node_ptrs);
 
        PROCEDURE
              b13new_node (lno : tsp00_Int2;
                    VAR nptr    : tbd_node_ptrs;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              b13r_release_node (VAR nptr : tbd_node_ptrs;
                    VAR current : tbd_current_tree;
                    lru_info    : tbd_lru_info);
 
        PROCEDURE
              b13w_release_node (VAR nptr : tbd_node_ptrs;
                    VAR current : tbd_current_tree);
 
      ------------------------------ 
 
        FROM
              filedirectory        : VBD17;
 
        PROCEDURE
              b17set_filestate (VAR fn : tgg00_Filename;
                    VAR t      : tgg00_TransContext;
                    new_fstate : tbd_file_state_set;
                    reset      : boolean);
 
        PROCEDURE
              b17state_fdir (VAR fn : tgg00_Filename;
                    VAR fi          : tbd_fileinfo;
                    concurrent_file : boolean;
                    VAR t           : tgg00_TransContext);
 
      ------------------------------ 
 
        FROM
              treehandling : VBD30;
 
        PROCEDURE
              b30add_filestate (VAR current : tbd_current_tree;
                    new_file_state : tbd_file_state_set);
 
        PROCEDURE
              b30add_to_tree (VAR rk : tgg00_Lkey;
                    VAR b           : tgg00_Rec;
                    page_fill_limit : integer;
                    VAR current     : tbd_current_tree);
 
        PROCEDURE
              b30cinit_current (VAR t : tgg00_TransContext;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              b30col_next_stringcol (VAR rk : tgg00_Lkey;
                    string_col_cnt    : integer;
                    VAR string_col_no : integer;
                    VAR col_id        : tgg00_FileId;
                    VAR tree_pos      : tgg00_FilePos;
                    VAR current       : tbd_current_tree);
 
        PROCEDURE
              b30current (VAR t : tgg00_TransContext;
                    VAR file_id : tgg00_FileId;
                    m_type      : tgg00_MessType;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              b30del_from_tree (VAR rk : tgg00_Lkey;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              b30fdir_to_treeid (VAR fi : tbd_fileinfo;
                    VAR file_id : tgg00_FileId);
 
        PROCEDURE
              b30exists_rec (VAR rk : tgg00_Lkey;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              b30find_leaf (VAR key : tgg00_Lkey;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              b30get_from_tree (VAR rk : tgg00_Lkey;
                    VAR b       : tgg00_Rec;
                    VAR current : tbd_current_tree;
                    wanted_lock : tgg00_LockReqMode);
 
        PROCEDURE
              b30init_load (VAR rightmost_leaf : tsp00_PageNo;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              bd30CreateBeforeImageForDelete (
                    VAR m           : tgg00_MessBlock;
                    pDeleteCmd      : tsp00_Addr;
                    VAR rk          : tgg00_Lkey;
                    VAR old_recbuf  : tgg00_Rec;
                    granted_lock    : tgg00_LockReqMode;
                    VAR current     : tbd_current_tree);
 
        PROCEDURE
              bd30CreateBeforeImageForInsert (
                    VAR rk          : tgg00_Lkey;
                    VAR b           : tgg00_Rec;
                    VAR m           : tgg00_MessBlock;
                    pInsertCmd      : tsp00_Addr;
                    granted_lock    : tgg00_LockReqMode;
                    VAR current     : tbd_current_tree);
 
        PROCEDURE
              bd30CreateBeforeImageForUpdate (
                    VAR m           : tgg00_MessBlock;
                    pUpdateCmd      : tsp00_Addr;
                    VAR rk          : tgg00_Lkey;
                    VAR old_recbuf  : tgg00_Rec;
                    VAR new_recbuf  : tgg00_Rec;
                    granted_lock    : tgg00_LockReqMode;
                    VAR current     : tbd_current_tree);
 
        PROCEDURE
              b30load_table (VAR lnptr : tbd_node_ptrs;
                    VAR nptr           : tbd_node_ptrs;
                    only_left          : boolean;
                    VAR current        : tbd_current_tree);
 
        PROCEDURE
              b30next_from_tree (VAR rk : tgg00_Lkey;
                    inclusive    : boolean;
                    VAR tree_pos : tgg00_FilePos;
                    VAR b        : tgg00_Rec;
                    VAR current  : tbd_current_tree);
 
        PROCEDURE
              b30prev_from_tree (VAR rk : tgg00_Lkey;
                    inclusive    : boolean;
                    VAR tree_pos : tgg00_FilePos;
                    VAR b        : tgg00_Rec;
                    VAR current  : tbd_current_tree);
 
        PROCEDURE
              b30range_exi_rec  (VAR rk_the_one : tgg00_Lkey;
                    VAR rk_another   : tgg00_Lkey;
                    VAR left___pages : tsp00_Int4;
                    VAR middle_pages : tsp00_Int4;
                    VAR right__pages : tsp00_Int4;
                    VAR current      : tbd_current_tree);
 
        PROCEDURE
              b30repl_in_tree (VAR rk : tgg00_Lkey;
                    VAR b       : tgg00_Rec;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              b30save_quick (VAR pno : tsp00_PageNo;
                    VAR nptr    : tbd_node_ptrs;
                    VAR current : tbd_current_tree);
 
        PROCEDURE
              b30set_read_only (VAR current : tbd_current_tree);
 
      ------------------------------ 
 
        FROM
              qualified_records : VBD36;
 
        PROCEDURE
              b36pqual_from_tree (VAR RecKey : tsp00_Key;
                    VAR RecKeyLen    : tsp00_Int2;
                    VAR StopKey      : tsp00_Key;
                    StopKeyLen       : tsp00_Int4;
                    recbuf_size      : tsp00_Int4;
                    recbuf_ptr       : tsp00_MoveObjPtr;
                    VAR recbuf_pos   : tsp00_Int4;
                    VAR sel          : tgg00_SelectFieldsParam;
                    VAR stack_desc   : tgg00_StackDesc;
                    VAR current      : tbd_current_tree;
                    VAR cur_res_cnt  : integer;
                    VAR unqualified  : boolean;
                    VAR granted_lock : tgg00_LockReqMode;
                    VAR NodeUnlocked : tsp00_PageNo);
 
        PROCEDURE
              b36nqual_from_tree (VAR RecKey : tsp00_Key;
                    VAR RecKeyLen    : tsp00_Int2;
                    VAR StopKey      : tsp00_Key;
                    StopKeyLen       : tsp00_Int4;
                    recbuf_size      : tsp00_Int4;
                    recbuf_ptr       : tsp00_MoveObjPtr;
                    VAR recbuf_pos   : tsp00_Int4;
                    VAR sel          : tgg00_SelectFieldsParam;
                    VAR stack_desc   : tgg00_StackDesc;
                    VAR current      : tbd_current_tree;
                    VAR cur_res_cnt  : integer;
                    VAR unqualified  : boolean;
                    VAR granted_lock : tgg00_LockReqMode;
                    VAR NodeUnlocked : tsp00_PageNo);
 
      ------------------------------ 
 
        FROM
              indexhandling : VBD50;
 
        PROCEDURE
              b50reorg_treeindex (VAR rk : tgg00_Lkey;
                    stringcol_cnt  : integer;
                    varcol_cnt_off : integer;
                    VAR current    : tbd_current_tree);
 
        PROCEDURE
              b50calculate_pagecount (
                    VAR current           : tbd_current_tree;
                    VAR is_tree_requested : boolean;
                    VAR start_sep         : tgg00_Lkey;
                    VAR stop_sep          : tgg00_Lkey;
                    VAR page_count        : tsp00_Int4);
 
        PROCEDURE
              b50eval_pagecount (VAR start_key : tgg00_Lkey;
                    VAR stop_key     : tgg00_Lkey;
                    count_records    : boolean;
                    VAR page_count   : tsp00_Int4;
                    VAR all_page_cnt : tsp00_Int4;
                    VAR record_cnt   : tsp00_Int4;
                    VAR current      : tbd_current_tree);
 
      ------------------------------ 
 
        FROM
              ref_statistic : VBD73;
 
        PROCEDURE
              b73cmd_count (statement_kind : tgg00_RefInfoIndex);
 
      ------------------------------ 
 
        FROM
              concurrency : VBD75;
 
        PROCEDURE
              b75tldelete_lock_tree (VAR current : tbd_current_tree;
                    ignore_svp     : boolean;
                    suspend_reason : tsp00_Int2);
 
        PROCEDURE
              b75tlread_lock_tree (VAR current : tbd_current_tree;
                    suspend_reason : tsp00_Int2);
 
        PROCEDURE
              b75tudelete_unlock_tree (VAR current : tbd_current_tree);
 
        PROCEDURE
              b75turead_unlock_tree (VAR current : tbd_current_tree);
 
      ------------------------------ 
 
        FROM
              BD_Wrapper : VBD999;
 
        PROCEDURE
              bd999CheckSpace(
                    VAR Trans         : tgg00_TransContext;
                    NumPagesRequestes : tsp00_Int4);
 
      ------------------------------ 
 
        FROM
              KB_transaction : VKB53;
 
        PROCEDURE
              k53key_unlock2 (VAR t : tgg00_TransContext;
                    UnlockMode      : tgg00_LockReqMode;
                    TabId           : tgg00_Surrogate;
                    VAR Key         : tsp00_Key;
                    VAR KeyLen      : tsp00_Int2);
 
        PROCEDURE
              k53wait (VAR t  : tgg00_TransContext;
                    MessType  : tgg00_MessType;
                    MessType2 : tgg00_MessType2);
 
      ------------------------------ 
 
        FROM
              Configuration_Parameter : VGG01;
 
        VAR
              g01vtrace : tgg_vtrace_state;
 
      ------------------------------ 
 
        FROM
              Select_Help_Procedures : VGG04;
 
        FUNCTION
              g04inv_tfn (tfn : tgg00_Tfn) : boolean;
 
      ------------------------------ 
 
        FROM
              GG_cpp_auxiliary_functions : VGG06;
 
        FUNCTION
              gg06Min (
                    value1 : tsp00_Int4;
                    value2 : tsp00_Int4 ) : tsp00_Int4;
 
      ------------------------------ 
 
        FROM
              Kernel_move_and_fill : VGG10;
 
        PROCEDURE
              g10mv   (mod_id      : tsp_c6;
                    mod_intern_num : tsp_int4;
                    source_upb     : tsp_int4;    destin_upb : tsp_int4;
                    VAR source     : tsp_moveobj; source_pos : tsp_int4;
                    VAR destin     : tbd_node;    destin_pos : tsp_int4;
                    length         : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv1  (mod_id      : tsp_c6;
                    mod_intern_num : tsp_int4;
                    source_upb     : tsp_int4;    destin_upb : tsp_int4;
                    VAR source     : tbd_node;    source_pos : tsp_int4;
                    VAR destin     : tsp_moveobj; destin_pos : tsp_int4;
                    length         : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv2  (mod_id      : tsp_c6;
                    mod_intern_num : tsp_int4;
                    source_upb     : tsp_int4;        destin_upb : tsp_int4;
                    VAR source     : tsp00_Key;       source_pos : tsp_int4;
                    VAR destin     : tgg00_VtraceKey; destin_pos : tsp_int4;
                    length         : tsp_int4;
                    VAR e          : tgg_basis_error);
 
      ------------------------------ 
 
        FROM
              RTE_kernel : VEN101;
 
        PROCEDURE
              vsleep (pid : tsp_process_id;
                    limit : tsp_int2);
&       ifdef TRACE
 
      ------------------------------ 
 
        FROM
              Test_Procedures : VTA01;
 
        PROCEDURE
              t01basis_error (debug : tgg00_Debug;
                    nam   : tsp00_Sname;
                    b_err : tgg00_BasisError);
 
        PROCEDURE
              t01bool (debug : tgg00_Debug;
                    nam      : tsp00_Sname;
                    curr_bool: boolean);
 
        PROCEDURE
              t01buf (debug  : tgg00_Debug;
                    VAR buf  : tsp00_Buf;
                    startpos : integer;
                    endpos   : integer);
 
        PROCEDURE
              t01buf1 (debug  : tgg00_Debug;
                    VAR buf  : tsp00_Key;
                    startpos : integer;
                    endpos   : integer);
 
        PROCEDURE
              t01int4 (debug : tgg00_Debug;
                    nam      : tsp00_Sname;
                    int4     : tsp00_Int4);
 
        PROCEDURE
              t01lkey (debug : tgg00_Debug;
                    VAR k : tgg00_Lkey);
 
        PROCEDURE
              t01name (debug : tgg00_Debug; nam  : tsp00_Name);
 
        PROCEDURE
              t01moveobj (debug : tgg00_Debug;
                    VAR moveobj : tsp00_MoveObj;
                    startpos    : tsp00_Int4;
                    endpos      : tsp00_Int4);
 
        PROCEDURE
              t01page (debug : tgg00_Debug;
                    VAR buf  : tbd_node;
                    startpos : tsp00_Int4;
                    endpos   : tsp00_Int4);
 
        PROCEDURE
              t01p2int4 (debug : tgg00_Debug;
                    nam_1 : tsp00_Sname;
                    int_1 : tsp00_Int4;
                    nam_2 : tsp00_Sname;
                    int_2 : tsp00_Int4);
 
        PROCEDURE
              t01sname (layer : tgg00_Debug;
                    nam : tsp00_Sname);
 
        PROCEDURE
              t01treeid (debug : tgg00_Debug;
                    nam        : tsp00_Sname;
                    VAR treeid : tgg00_FileId);
&       endif
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              g10mv;
 
              tsp_moveobj tbd_node
 
        PROCEDURE
              g10mv1;
 
              tsp_moveobj tbd_node
 
        PROCEDURE
              g10mv2;
 
              tsp_moveobj tsp00_Key
              tsp_moveobj tgg00_VtraceKey
&             ifdef trace
 
        PROCEDURE
              t01buf1;
 
              tsp00_Buf tsp00_Key
 
        PROCEDURE
              t01page;
 
              tsp00_Page tbd_node
&             endif
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : JuergenP
.sp
.cp 3
Created : 1979-09-05
.sp
.cp 3
Version : 2002-10-17
.sp
.cp 3
Release :      Date : 2000-10-26
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
 
.sp 2;.cp 4
.oc _/1;1._Processing_Primary_Trees
.sp 3
Primary tree entries are records that have the following
structure when they are transferred to a record buffer:
.nf
.sp 2
       2   2    kl bytes      v bytes
     --------------------------------------
     |rl |kl |   key   |  nonkeyfields    |
     --------------------------------------
 
     |rl| = 2 + 2 + kl + v <= maxrecordlength
 
.fo
.sp 2
Records are always left-justified (i.e. they start in position 1) when
they are entered in record buffers.
Each record has a record header that contains its record length
(rl <= MAX_RECLEN_GG00) and its record key length (kl <= MAX_KEYLEN_GG00).
.sp 3;.cp 6
b02add_record (t,file_id,b)
.sp
The record from record buffer b is inserted in tree file_id, given the
tree exists and does not yet contain a record with the same key.
The meaning of parameter file_id can be found in the
b02get_(lock_)record specification.
.br
One of the following messages, among others, is sent to t.trError_gg00:
   - e_ok
   - b_file_not_found
   - b_duplicate_key
   - b_illegal_entrypos
   - b_invalid_entrypos
   - b_no_more_space
   - b_no_more_tempspace
   - b_shutdown
   - b_disk_not_accessible
.sp 3;.cp 6
b02col_next_stringcol
       (t, file_id, string_col_cnt, rk, string_col_no, col_id, file_pos)
.sp
.sp 3;.cp 6
b02del_record (t,file_id,rk)
.sp
The record in tree file_id whose key matches the key entered in the key
buffer rk is deleted.
The meaning of parameter file_id can be found in the
b02get_(lock_)record specification.
.br
One of the following messages, among others, is sent to t.trError_gg00:
   - e_ok
   - b_file_not_found
   - b_illegal_key
   - b_illegal_entrypos
   - b_invalid_entrypos
   - b_key_not_found
   - b_shutdown
   - b_disk_not_accessible
.sp 3;.cp 6
b02exists_record (t,fileid,rk)
.sp
In the file identified by fileid a search is carried out for the record
whose key matches the key entered in rk.
.br
One of the following messages, among others, is sent to t.trError_gg00:
   - e_ok
   - b_file_not_found
   - b_illegal_key
   - b_illegal_entrypos
   - b_invalid_entrypos
   - b_key_not_found
   - b_shutdown
   - b_disk_not_accessible
.sp 3;.cp 6
b02file_outcopy (mbuf)
.sp
.sp 3;.cp 6
b02finish_load (t, file_id, rightmost_leaf)
.sp
.sp 3;.cp 6
b02get_(lock_)record (t,file_id,rk,b)
.sp
A search is carried out in tree file_id for the record whose key
matches the key entered in rk.
If this record exists, it is transferred to record buffer b.
The number file_id.fileversion indicates wether page number file_id.root
can be used in the following.
The set file_id.fileBdUse_gg00 contains information on
whether altered pages must be copied unbuffered to the secondary storage
(bd_unbuffered).
If the record variable file_id is identified as valid, it contains the
identification of the primary tree belonging to tree file_id.fn.
Otherwise the primary tree identification is assigned after the file
directory has been accessed and is then sent to the calling procedure.
.br
One of the following messages, among others, is sent to t.trError_gg00:
   - e_ok
   - b_file_not_found
   - b_illegal_key
   - b_illegal_entrypos
   - b_invalid_entrypos
   - b_key_not_found
   - b_shutdown
   - b_disk_not_accessible
.sp 3;.cp 6
b02init_load (t, file_id, set_read_only, rightmost_leaf)
.sp
.sp 3;.cp 6
b02kb_del_rec (m, rk, old_recbuf, granted_lock)
.sp
The record in tree file_id whose key matches the key entered in the key
buffer rk is deleted.
The remaining parameters are passed to the KB layer due to logging
reasons.
.br
This procedure is called each time a key qualified delete is processed.
.br;One of the following messages, among others, is sent to
m.mb_trns^.trError_gg00:
   - e_ok
   - e_shutdown
   - e_illegal_key
.sp 3;.cp 6
b02kb_ins_record (m, b, granted_lock)
.sp
The record from record buffer b is inserted in tree m.mb_qual^.mtree,
given the tree exists and does not yet contain a record with the same
key.
The remaining parameters are passed to the KB layer due to logging and
optimization reasons.
.br
This procedure is called each time an insert is processed,
which has been issued by the user.
.br
One of the following messages, among others, is sent to
m.mb_trns^.trError_gg00:
   - e_ok
   - b_file_not_found
   - b_duplicate_key
   - b_illegal_entrypos
   - b_invalid_entrypos
   - b_no_more_space
   - b_no_more_tempspace
   - b_shutdown
   - b_disk_not_accessible
.sp 3;.cp 6
b02kb_select_rec (t, file_id, rk, stopkey, b, sel, stack_desc,
 result_buf, unqualified, granted_lock)
.sp 3;.cp 6
b02kb_upd_rec (m, rk, old_recbuf, new_recbuf, log_part1, granted_lock)
.sp
The record from record buffer new_recbuf with key rk replaces the record
with the same key in tree file_id, given the tree contains such a
record.
The remaining parameters are passed to the KB layer due to logging and
optimization reasons.
.br
This procedure is called each time a key qualified update
is processed.
.br
One of the following messages, among others, is sent to
m.mb_trns^.trError_gg00:
   - e_ok
   - b_file_not_found
   - b_illegal_key
   - b_illegal_entrypos
   - b_invalid_entrypos
   - b_key_not_found
   - b_shutdown
   - b_disk_not_accessible
.sp 3;.cp 6
b02load_table (t, tree_id, rightmost_leaf, check_leaf, load_buf_len, load_buf)
.sp
.sp 3;.cp 6
b02next_record (t,file_id,rk,inclusive,b)
.sp
A search is carried out in tree file_id for the record with the key rk.
If inclusive=true and the record was found,
the record is copied to record buffer b.
.br;Otherwise, the record whose key follows the key rk (with
the records arranged in ascending order by keys) is copied to b.
If the tree contains no record with a key smaller than rk,
b_no_next_record is sent to t.trError_gg00.
If a record with key rk is not present, b_key_not_found is sent to
t.trError_gg00.
.br
The meaning of parameter file_id can be found in the
b02get_(lock_)record specification.
.br
One of the following messages, among others, is sent to t.trError_gg00:
   - e_ok
   - b_file_not_found
   - b_illegal_key
   - b_illegal_entrypos
   - b_invalid_entrypos
   - b_no_next_record
   - b_key_not_found
   - b_shutdown
   - b_disk_not_accessible
.sp 3;.cp 6
b02prev_record (t,file_id,rk,inclusive,b)
.sp
A search is carried out in tree file_id for the record with the key rk.
If inclusive=true and the record was found,
the record is copied to record buffer b.
.br;Otherwise, the record whose key preceeds the key rk (with
the records arranged in ascending order by keys) is copied to b.
If the tree contains no record with a key smaller than rk,
b_no_prev_record is sent to t.trError_gg00.
If a record with key rk is not present, b_key_not_found is sent to
t.trError_gg00.
.br
The meaning of parameter file_id can be found in the
b02get_(lock_)record specification.
.br
One of the following messages, among others, is sent to t.trError_gg00:
   - e_ok
   - b_file_not_found
   - b_illegal_key
   - b_illegal_entrypos
   - b_invalid_entrypos
   - b_no_prev_record
   - b_key_not_found
   - b_shutdown
   - b_disk_not_accessible
.sp 3;.cp 6
b02range_exi_rec (t, file_id, left___pages, middle_pages, right__pages,
              rk_the_one, rk_another)
.sp
In the tree identified by file_id a search is carried out for a record
whose key rk satisfies the following condition:
.nf
    (     rk_the_one <= rk <= rk_another     ) OR
    (rk > rk_the_one    >     rk_another     ) OR
    (     rk_the_one    >     rk_another > rk)
.br;.fo
If rk_the_one < rk <= rk_another, rk_the_one is overwritten with the
first key rk.
.br;One of the following messages, among others, is sent to t.trError_gg00:
   - e_ok
   - e_shutdown
   - e_illegal_key
   - b_file_not_found
   - b_illegal_entrypos
   - b_invalid_entrypos
   - b_key_not_found
   - b_disk_not_accessible
.sp 3;.cp 6
b02reorg_treeindex (t, file_id, rk)
.sp
.sp 3;.cp 6
b02repl_record (t,file_id,b)
.sp
The record from record buffer b replaces the record with the same key in
tree file_id, given the tree contains such a record.
The meaning of parameter file_id can be found in the
b02get_(lock_)record specification.
.br
One of the following messages, among others, is sent to t.trError_gg00:
   - e_ok
   - b_file_not_found
   - b_key_not_found
   - b_illegal_entrypos
   - b_invalid_entrypos
   - b_no_more_space
   - b_no_more_tempspace
   - b_shutdown
   - b_disk_not_accessible
.sp 3;.cp 6
b02select_record (t, file_id, rk, stopkey, b, sel, stack_desc,
.in 18
result_buf, unqualified)
.in 0
.sp
Supplies b with a record from tree file_id that fulfills a
qualification specified by the parameters sel and stack_desc.
The parameter rk specifies the position (record key) from where the
search starts and parameter sel.bd_mess2_type determines the type of
search carried out in the tree.
.br
bd_mess2_type can be assigned the following values:
.pb '~'
.in 1
.of 10
-~mm_next~: Searches for an entry with a key that is greater
than the key entered in rk and that fulfills the qualification.
If an entry is found, e_ok is returned; otherwise, e_no_next_record
is returned.
.in 1
.of 10
-~mm_prev~: Searches for an entry with a key that is smaller
than the key entered in rk and that fulfills the qualification.
If an entry is found, e_ok is returned; otherwise, e_no_prev_record
is returned.
.in 1
.of 10
-~mm_first~: Searches for an entry with a key that is greater
than or equal to the key entered in rk and that fulfills the
qualification.  If an entry is found, e_ok is returned; otherwise,
e_no_next_record is returned.
.in 1
.of 10
-~mm_last~: Searches for an entry with a key that is smaller than
or equal to the key entered in rk and that fulfills the
qualification.  If an entry is found, e_ok is returned;
otherwise, e_no_prev_record is returned.
.in 1
.of 10
-~mm_direct~: Searches for an entry with the record key rk
and checks whether it fulfills the qualification.
If the operation was successful, 'e_ok' is sent to "e".
If the specified key was not found, 'e_key_not_found'
is returned.
If the qualification is not fulfilled, "unqualified" is set to
TRUE and 'kb_qual_violation', 'kb_range_violation',
'kb_view_violatior' or 'kb_upd_view_violation' is sent to "t.trError_gg00".
.in 0
The following acknowledgements might also be sent:
   - b_file_not_found
   - b_illegal_key
   - b_illegal_entrypos
   - b_invalid_entrypos
   - b_shutdown
   - b_disk_not_accessible
.sp 3;.cp 6
b02u_init_unload (t, file_id)
.sp
.sp 3;.cp 6
b02unload_table (t, tree_id, pno, pno_x, ret_buf_size, ret_buf,
                 ret_buf_len)
.sp
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
A global variable 'database_state' indicates by means of
'e_ok' that the file system has been generated and is
not shut down; otherwise it contains the message 'b_shutdown'.
The existence of a tree can generally be detected by accessing
the file directory.  In addition, the 'add' and 'repl' operations
are used to determine whether enough space is still available
in the secondary storage.
.sp
When a new tree is being created, a tree root is requested and an
entry identifying the tree is included in the file directory.
.sp
Entries in a tree are stored in the leaves of a B tree.
File routines are thus referred back to the appropriate
tree routine.  Before each tree routine is called, the operation
b30adjust_tree identifies which tree is being processed;
this means that, later on, certain information does not always
have to be carried along as a parameter.
.sp
When a checkpoint is set, only the system buffer
(as necessary) is written to the secondary storage.
.sp
If a file routine sends the message b_disk_not_accessible
to e, the physical integrity of the file system is no
longer secure!
.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    :
 
 
CONST
      c_ignore_svp         = true; (* PTS 1106058 TS 2000-03-28 *)
      c_only_left          = true; (*local only*)
      c_reset              = true; (*local only*)
      c_number_of_retries  = 2;
 
 
(*------------------------------*) 
 
PROCEDURE
      b02add_record (VAR t : tgg00_TransContext;
            VAR file_id    : tgg00_FileId;
            VAR b          : tgg00_Rec);
 
VAR
      auxError   : tgg00_BasisError;
      key_trace  : tgg11_BdKeyTrace;
      root_trace : tgg11_BdRootTrace;
      current    : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    auxError                 := e_ok;
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := b.recKeyLen_gg00;
    g10mv2 ('VBD02 ',   1,    
          b.recKeyLen_gg00, sizeof (key_trace.bdkKey_gg11),
          b.recKey_gg00.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( b.recKeyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b02add, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd add rec  ');
t01treeid (bi, 'treeid      ', file_id);
t01buf    (bi, b.recBuf_gg00, 1, b.recLen_gg00);
&endif
IF  ftsTemp_egg00 in file_id.fileType_gg00
THEN
    b73cmd_count (icadd_rec)
ELSE
    b73cmd_count (iadd_rec);
(*ENDIF*) 
b30cinit_current (t, current);
WITH current, t DO
    BEGIN
    IF  b01downfilesystem
    THEN
        trError_gg00 := e_shutdown
    ELSE
        IF  (b.recLen_gg00 > MAX_RECLEN_GG00) OR (b.recLen_gg00 < MIN_RECORD_LEN_BD00)
        THEN
            trError_gg00 := e_illegal_record
        ELSE
            IF  (b.recKeyLen_gg00 > MAX_KEYLEN_GG00) OR (b.recKeyLen_gg00 < 0)
            THEN
                trError_gg00 := e_illegal_key
            ELSE
                trError_gg00 := e_ok;
            (*ENDIF*) 
        (*ENDIF*) 
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        bd999CheckSpace( t, 1);
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        BEGIN
        file_id.fileBdUse_gg00 := file_id.fileBdUse_gg00 + [bd_write_acc];
        b30current (t, file_id, m_insert, current);
&       ifdef vers80
        IF  trError_gg00 = e_ok
        THEN
            b06record_check (b, file_id, trError_gg00);
&       endif
        (*ENDIF*) 
        IF  trError_gg00 = e_ok
        THEN
            BEGIN
            root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
            b30add_to_tree (b.mkey, b, NINETY_PERCENT_COV_BD00, current);
            IF  trError_gg00 = e_file_must_be_read_only
            THEN
                BEGIN
                IF  curr_lockstate = r_lock_tree
                THEN
                    b75turead_unlock_tree (current);
                (*ENDIF*) 
                b30set_read_only (current);
                IF  trError_gg00 = e_ok
                THEN
                    BEGIN
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 150);
                    (*ENDIF*) 
                    b30add_to_tree (b.mkey, b, NINETY_PERCENT_COV_BD00, current);
                    END
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  curr_lockstate = r_lock_tree
        THEN
            b75turead_unlock_tree (current);
        (*ENDIF*) 
        IF  trError_gg00 = e_ok
        THEN
            file_id := curr_tree_id
        ELSE
            b06illegal_root_access (current);
        (*ENDIF*) 
        file_id.fileBdUse_gg00 := file_id.fileBdUse_gg00 - [bd_write_acc];
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
t01basis_error (bi, 'add rec err ', t.trError_gg00);
&endif
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := t.trError_gg00;
    b120InsertTrace (t, bd, b02add, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02calculate_page_count (VAR t : tgg00_TransContext;
            VAR file_id      : tgg00_FileId;
            VAR startkey     : tgg00_Lkey;
            VAR stopkey      : tgg00_Lkey;
            VAR page_count   : tsp00_Int4);
 
VAR
      auxError          : tgg00_BasisError;
      first_time        : boolean;
      is_tree_requested : boolean;
      eval_trace        : tgg11_BdEvalPagesTrace;
      key_trace         : tgg11_BdTwoKeysTrace;
      current           : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00  OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    eval_trace.bdeRootTrace_gg11.bdrRoot_gg11 := NIL_PAGE_NO_GG00;
    key_trace.bdtkTrType_gg11     := bdtrTwoKeys_egg11;
    key_trace.bdtkKeyLen_gg11 [0] := startkey.keyLen_gg00;
    key_trace.bdtkKeyLen_gg11 [1] := stopkey.keyLen_gg00;
    auxError                      := e_ok;
    g10mv2 ('VBD02 ',   2,    
          startkey.keyLen_gg00, sizeof (key_trace.bdtkKey_gg11[0]),
          startkey.keyVal_gg00, 1, key_trace.bdtkKey_gg11[0], 1,
          gg06Min( startkey.keyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    auxError := e_ok;
    g10mv2 ('VBD02 ',   3,    
          stopkey.keyLen_gg00, sizeof (key_trace.bdtkKey_gg11[1]),
          stopkey.keyVal_gg00, 1, key_trace.bdtkKey_gg11[1], 1,
          gg06Min( stopkey.keyLen_gg00,  sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b03eval, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01sname  (bi, 'bd calc pcnt');
t01treeid (bi, 'treeid      ', file_id);
t01lkey   (bi, startkey);
t01lkey   (bi, stopkey);
&endif
b30cinit_current (t, current);
first_time   := true;
page_count   := 0;
WITH t, current DO
    BEGIN
    IF  g04inv_tfn (file_id.fileTfn_gg00)
    THEN
        trError_gg00 := e_invalid_filetype
    ELSE
        BEGIN
        IF  (startkey.keyLen_gg00 > MAX_KEYLEN_GG00) OR (startkey.keyLen_gg00 < 0) OR
            (stopkey.keyLen_gg00  > MAX_KEYLEN_GG00) OR (stopkey.keyLen_gg00  < 0)
        THEN
            trError_gg00 := e_illegal_keylength
        ELSE
            BEGIN
            REPEAT
                IF  b01downfilesystem
                THEN
                    trError_gg00 := e_shutdown
                ELSE
                    BEGIN
                    trError_gg00      := e_ok;
                    is_tree_requested := false;
                    IF  first_time
                    THEN
                        b30current (t, file_id, m_eval, current)
                    ELSE
                        IF  ftsConcurrent_egg00 in current.curr_tree_id.fileType_gg00
                        THEN
                            b75tlread_lock_tree (current, 6);
                        (*ENDIF*) 
                    (*ENDIF*) 
                    IF  trError_gg00 = e_ok
                    THEN
                        BEGIN
                        eval_trace.bdeRootTrace_gg11.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
                        b50calculate_pagecount (current, is_tree_requested,
                              startkey, stopkey, page_count);
&                       ifdef TRACE
                        IF  is_tree_requested
                        THEN
                            t01lkey   (bi, startkey);
&                       endif
                        (*ENDIF*) 
                        first_time := false;
                        file_id    := curr_tree_id;
                        IF  trError_gg00 <> e_ok
                        THEN
                            b06illegal_root_access (current);
                        (*ENDIF*) 
                        END;
                    (*ENDIF*) 
                    IF  curr_lockstate = r_lock_tree
                    THEN
                        b75turead_unlock_tree (current);
                    (*ENDIF*) 
                    IF  is_tree_requested AND (trError_gg00 = e_ok)
                    THEN
                        trError_gg00 := e_bd_leaf_unlocked
                    (*ENDIF*) 
                    END
                (*ENDIF*) 
            UNTIL
                trError_gg00 <> e_bd_leaf_unlocked;
            (*ENDREPEAT*) 
            END;
        (*ENDIF*) 
        END;
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
t01int4        (bi, 'page count  ', page_count);
t01basis_error (bi, 'calc pc err ', t.trError_gg00);
&endif
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    eval_trace.bdeRootTrace_gg11.bdrTrType_gg11 := bdtrEvalPages_egg11;
    eval_trace.bdeRootTrace_gg11.bdrError_gg11  := t.trError_gg00;
    eval_trace.bdePageCnt_gg11    := page_count;
    eval_trace.bdeRecordCnt_gg11  := 0;
    eval_trace.bdeAllPageCnt_gg11 := 0;
    b120InsertTrace (t, bd, b03eval, sizeof (eval_trace), @eval_trace)
    END
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02col_next_stringcol (VAR t : tgg00_TransContext;
            VAR file_id       : tgg00_FileId;
            string_col_cnt    : integer;
            VAR rk            : tgg00_Lkey;
            VAR string_col_no : integer;
            VAR col_id        : tgg00_FileId;
            VAR file_pos      : tgg00_FilePos);
 
VAR
      current : tbd_current_tree;
 
BEGIN
&ifdef TRACE
t01name   (bi, '====> bd next col ');
t01treeid (bi, 'treeid      ', file_id);
t01int4   (bi, 'tab leaf    ', file_pos.tpsPno_gg00);
t01int4   (bi, 'tab index   ', file_pos.tpsIndex_gg00);
t01int4   (bi, 'str col cnt ', string_col_cnt);
t01lkey   (bi, rk);
&endif
b30cinit_current (t, current);
WITH t DO
    IF  b01downfilesystem
    THEN
        trError_gg00 := e_shutdown
    ELSE
        BEGIN
        trError_gg00 := e_ok;
        file_id.fileType_gg00 := file_id.fileType_gg00 - [ ftsConcurrent_egg00 ];
        b30current (t, file_id, m_select, current);
        IF  trError_gg00 = e_ok
        THEN
            BEGIN
            IF  rk.len = 0
            THEN
                file_pos.tpsPno_gg00 := NIL_PAGE_NO_GG00;
            (*ENDIF*) 
            b30col_next_stringcol (rk, string_col_cnt, string_col_no,
                  col_id, file_pos, current);
            IF  trError_gg00 <> e_ok
            THEN
                b06illegal_root_access (current)
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        END;
    (*ENDIF*) 
(*ENDWITH*) 
&ifdef TRACE
t01treeid      (bi, 'col id      ', col_id);
t01int4        (bi, 'tab leaf    ', file_pos.tpsPno_gg00);
t01int4        (bi, 'tab index   ', file_pos.tpsIndex_gg00);
t01int4        (bi, 'str col no  ', string_col_no);
t01lkey        (bi, rk);
t01basis_error (bi, 'next col  e ', t.trError_gg00);
&endif
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02del_record (VAR t : tgg00_TransContext;
            VAR file_id    : tgg00_FileId;
            VAR rk         : tgg00_Lkey);
 
VAR
      auxError   : tgg00_BasisError;
      key_trace  : tgg11_BdKeyTrace;
      root_trace : tgg11_BdRootTrace;
      current    : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    auxError                 := e_ok;
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := rk.keyLen_gg00;
    g10mv2 ('VBD02 ',   4,    
          rk.keyLen_gg00, sizeof (key_trace.bdkKey_gg11),
          rk.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( rk.keyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b02del, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd del rec  ');
t01treeid (bi, 'treeid      ', file_id);
t01lkey   (bi, rk);
&endif
IF  ftsTemp_egg00 in file_id.fileType_gg00
THEN
    b73cmd_count (icdel_rec)
ELSE
    b73cmd_count (idel_rec);
(*ENDIF*) 
b30cinit_current (t, current);
WITH current, t DO
    BEGIN
    IF  b01downfilesystem
    THEN
        trError_gg00 := e_shutdown
    ELSE
        IF  (rk.keyLen_gg00 > MAX_KEYLEN_GG00) OR (rk.keyLen_gg00 < 0)
        THEN
            trError_gg00 := e_illegal_key
        ELSE
            trError_gg00 := e_ok;
        (*ENDIF*) 
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        BEGIN
        file_id.fileBdUse_gg00 := file_id.fileBdUse_gg00 + [bd_write_acc];
        b30current (t, file_id, m_delete, current);
        IF  trError_gg00 = e_ok
        THEN
            BEGIN
&           ifdef TRACE
            t01int4 (bi, 'root        ', curr_tree_id.fileRoot_gg00);
&           endif
            root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
            b30del_from_tree (rk, current);
            IF  trError_gg00 = e_file_must_be_read_only
            THEN
                BEGIN
                IF  curr_lockstate = r_lock_tree
                THEN
                    b75turead_unlock_tree (current);
                (*ENDIF*) 
                b30set_read_only (current);
                IF  trError_gg00 = e_ok
                THEN
                    BEGIN
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 153);
                    (*ENDIF*) 
                    b30del_from_tree (rk, current);
                    END
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  curr_lockstate = r_lock_tree
        THEN
            b75turead_unlock_tree (current);
        (*ENDIF*) 
        IF  trError_gg00 = e_ok
        THEN
            file_id := curr_tree_id
        ELSE
            b06illegal_root_access (current);
        (*ENDIF*) 
        file_id.fileBdUse_gg00 := file_id.fileBdUse_gg00 - [bd_write_acc];
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
t01basis_error (bi, 'del rec err ', t.trError_gg00);
&endif
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := t.trError_gg00;
    b120InsertTrace (t, bd, b02del, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02eval_page_count (VAR t : tgg00_TransContext;
            VAR file_id      : tgg00_FileId;
            VAR startkey     : tgg00_Lkey;
            VAR stopkey      : tgg00_Lkey;
            count_records    : boolean;
            VAR page_count   : tsp00_Int4;
            VAR all_page_cnt : tsp00_Int4;
            VAR record_cnt   : tsp00_Int4);
 
VAR
      auxError    : tgg00_BasisError;
      eval_trace  : tgg11_BdEvalPagesTrace;
      key_trace   : tgg11_BdTwoKeysTrace;
      current     : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR  g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    eval_trace.bdeRootTrace_gg11.bdrRoot_gg11 := NIL_PAGE_NO_GG00;
    key_trace.bdtkTrType_gg11     := bdtrTwoKeys_egg11;
    key_trace.bdtkKeyLen_gg11 [0] := startkey.keyLen_gg00;
    key_trace.bdtkKeyLen_gg11 [1] := stopkey.keyLen_gg00;
    auxError                      := e_ok;
    g10mv2 ('VBD02 ',   5,    
          startkey.keyLen_gg00, sizeof (key_trace.bdtkKey_gg11[0]),
          startkey.keyVal_gg00, 1, key_trace.bdtkKey_gg11[0], 1,
          gg06Min( startkey.keyLen_gg00,  sizeof( tgg00_VtraceKey )), auxError);
    auxError := e_ok;
    g10mv2 ('VBD02 ',   6,    
          stopkey.keyLen_gg00, sizeof (key_trace.bdtkKey_gg11[1]),
          stopkey.keyVal_gg00, 1, key_trace.bdtkKey_gg11[1], 1,
          gg06Min( stopkey.keyLen_gg00,  sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b03eval, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01sname  (bi, 'bd eval pcnt');
t01treeid (bi, 'treeid      ', file_id);
t01lkey   (bi, startkey);
t01lkey   (bi, stopkey);
t01int4   (bi, 'limitcount :', page_count);
t01bool   (bi, 'count recs  ', count_records);
&endif
all_page_cnt := 0;
record_cnt   := -1;
b30cinit_current (t, current);
WITH t, current DO
    BEGIN
    IF  b01downfilesystem
    THEN
        trError_gg00 := e_shutdown
    ELSE
        IF  (startkey.keyLen_gg00 > MAX_KEYLEN_GG00) OR (startkey.keyLen_gg00 < 0) OR
            (stopkey.keyLen_gg00  > MAX_KEYLEN_GG00) OR (stopkey.keyLen_gg00  < 0)
        THEN
            trError_gg00 := e_illegal_keylength
        ELSE
            trError_gg00 := e_ok;
        (*ENDIF*) 
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        BEGIN
        b30current (t, file_id, m_eval, current);
        IF  g04inv_tfn (file_id.fileTfn_gg00)
        THEN
            trError_gg00 := e_invalid_filetype;
        (*ENDIF*) 
        IF  trError_gg00 = e_ok
        THEN
            BEGIN
            b50eval_pagecount (startkey, stopkey,
                  count_records, page_count, all_page_cnt,
                  record_cnt, current);
            eval_trace.bdeRootTrace_gg11.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
            file_id := curr_tree_id;
            IF  trError_gg00 <> e_ok
            THEN
                b06illegal_root_access (current);
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  curr_lockstate = r_lock_tree
        THEN
            b75turead_unlock_tree (current);
        (*ENDIF*) 
        END;
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
t01p2int4      (bi, 'page count  ', page_count
      ,             'all page cnt', all_page_cnt);
t01int4        (bi, 'record count', record_cnt);
t01basis_error (bi, 'eval pc err ', t.trError_gg00);
&endif
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    eval_trace.bdeRootTrace_gg11.bdrTrType_gg11 := bdtrEvalPages_egg11;
    eval_trace.bdeRootTrace_gg11.bdrError_gg11  := t.trError_gg00;
    eval_trace.bdePageCnt_gg11    := page_count;
    eval_trace.bdeRecordCnt_gg11  := record_cnt;
    eval_trace.bdeAllPageCnt_gg11 := all_page_cnt;
    b120InsertTrace (t, bd, b03eval, sizeof (eval_trace), @eval_trace)
    END
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02exists_record (VAR t : tgg00_TransContext;
            VAR file_id       : tgg00_FileId;
            VAR rk            : tgg00_Lkey);
 
VAR
      auxError    : tgg00_BasisError;
      first_time  : boolean;
      retry_count : integer;
      key_trace   : tgg11_BdKeyTrace;
      root_trace  : tgg11_BdRootTrace;
      current     : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    auxError                 := e_ok;
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := rk.keyLen_gg00;
    g10mv2 ('VBD02 ',   7,    
          rk.keyLen_gg00, sizeof (key_trace.bdkKey_gg11),
          rk.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( rk.keyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b02exists, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd exists re');
t01treeid (bi, 'treeid      ', file_id);
t01lkey   (bi, rk);
&endif
first_time  := true;
retry_count := 1;
b30cinit_current (t, current);
WITH current, t DO
    BEGIN
    IF  (rk.keyLen_gg00 > MAX_KEYLEN_GG00) OR (rk.keyLen_gg00 < 0)
    THEN
        trError_gg00 := e_illegal_key
    ELSE
        BEGIN
        REPEAT
            trError_gg00 := e_ok;
            IF  b01downfilesystem
            THEN
                trError_gg00 := e_shutdown
            ELSE
                IF  first_time
                THEN
                    BEGIN
                    b30current (t, file_id, m_select, current);
                    currUnlockAllowed_bd00 := true
                    END
                ELSE
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 154);
                    (*ENDIF*) 
                (*ENDIF*) 
            (*ENDIF*) 
            IF  trError_gg00 = e_ok
            THEN
                BEGIN
&               ifdef TRACE
                t01int4 (bi, 'root        ', curr_tree_id.fileRoot_gg00);
&               endif
                root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
                b30exists_rec (rk, current);
                first_time := false
                END;
            (*ENDIF*) 
            IF  curr_lockstate = r_lock_tree
            THEN
                b75turead_unlock_tree (current);
            (*ENDIF*) 
            IF  trError_gg00 = e_bd_leaf_unlocked
            THEN
                BEGIN
                retry_count := retry_count + 1;
                IF  retry_count > c_number_of_retries
                THEN
                    vsleep (t.trTaskId_gg00, 0)
                (*ENDIF*) 
                END;
            (*ENDIF*) 
        UNTIL
            trError_gg00 <> e_bd_leaf_unlocked;
        (*ENDREPEAT*) 
        IF  trError_gg00 <> e_ok
        THEN
            b06illegal_root_access (current)
        (*ENDIF*) 
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
t01basis_error (bi, 'exists rec e', t.trError_gg00);
&endif
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := t.trError_gg00;
    b120InsertTrace (t, bd, b02exists, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02file_outcopy (VAR mbuf : tgg00_MessBlock);
 
VAR
      finished : boolean;
      nptr     : tbd_node_ptrs;
      current  : tbd_current_tree;
 
BEGIN
&ifdef TRACE
t01name   (bi, '====> bd file outc');
t01treeid (bi, 'treeid      ', mbuf.mb_qual^.mtree);
&endif
b30cinit_current (mbuf.mb_trns^, current);
WITH mbuf, mb_trns^ DO
    BEGIN
    IF  b01downfilesystem
    THEN
        trError_gg00 := e_shutdown
    ELSE
        BEGIN
        trError_gg00  := e_ok;
        current.curr_tree_id := mbuf.mb_qual^.mcfc_tree;
        nptr.np_ptr   := NIL;
        nptr.np_cbptr := NIL;
        mb_data_len   := 0;
        finished      := false;
        WHILE (trError_gg00 = e_ok) AND (NOT finished) DO
            BEGIN
            IF  ftsByteStr_egg00 in current.curr_tree_id.fileType_gg00
            THEN
                b05save_quick (mb_qual^.mcfc_pno, nptr, current)
            ELSE
                b30save_quick (mb_qual^.mcfc_pno, nptr, current);
            (*ENDIF*) 
            IF  (trError_gg00 = e_ok) AND (nptr.np_ptr <> NIL)
            THEN
                BEGIN
&               ifdef TRACE
                t01page (bi, nptr.np_ptr^, 1, 60);
&               endif
                g10mv1 ('VBD02 ',   8,    
                      sizeof (tbd_node), mb_data_size,
                      nptr.np_ptr^, 1,
                      mb_data^.mbp_buf, mb_data_len + 1,
                      sizeof (tbd_node), trError_gg00);
                mb_data_len := mb_data_len + sizeof (tbd_node)
                END;
            (*ENDIF*) 
            finished := ((mb_data_len + sizeof (tbd_node)) > mb_data_size)
                  OR (mb_qual^.mcfc_pno = NIL_PAGE_NO_GG00);
            END;
        (*ENDWHILE*) 
        IF  nptr.np_ptr <> NIL
        THEN
            b13r_release_node (nptr, current, lru_normal);
        (*ENDIF*) 
        IF  (mb_qual^.mcfc_pno = NIL_PAGE_NO_GG00) AND
            (ftsTemp_egg00 in current.curr_tree_id.fileType_gg00) AND
            ((trError_gg00 = e_ok) OR (trError_gg00 = e_bad_datapage))
        THEN
            BEGIN
            trError_gg00 := e_ok;
            IF  mb_type2 = mm_destroy_temp
            THEN
                b01destroy_file (mb_trns^, current.curr_tree_id)
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  (trError_gg00 = e_ok)
        THEN
            mb_qual_len := sizeof (mb_qual^.mcfc_tree) +
                  sizeof (mb_qual^.mcfc_pno);
&       ifdef TRACE
        (*ENDIF*) 
        t01basis_error (bi, 'file out err', trError_gg00);
&       endif
        END;
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02find_leaf (VAR t : tgg00_TransContext;
            VAR file_id   : tgg00_FileId;
            VAR key       : tgg00_Lkey);
 
VAR
      auxError    : tgg00_BasisError;
      first_time  : boolean;
      retry_count : integer;
      key_trace   : tgg11_BdKeyTrace;
      root_trace  : tgg11_BdRootTrace;
      current     : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    auxError                 := e_ok;
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := key.keyLen_gg00;
    g10mv2 ('VBD02 ',   9,    
          key.keyLen_gg00, sizeof (key_trace.bdkKey_gg11),
          key.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( key.keyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b02get, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd find leaf');
t01treeid (bi, 'treeid      ', file_id);
t01lkey   (bi, key);
&endif
IF  ftsTemp_egg00 in file_id.fileType_gg00
THEN
    b73cmd_count (icget_rec)
ELSE
    b73cmd_count (iget_rec);
(*ENDIF*) 
first_time  := true;
retry_count := 1;
b30cinit_current (t, current);
WITH current, t DO
    BEGIN
    IF  (key.keyLen_gg00 > MAX_KEYLEN_GG00) OR (key.keyLen_gg00 < 0)
    THEN
        trError_gg00 := e_illegal_key
    ELSE
        BEGIN
        REPEAT
            trError_gg00 := e_ok;
            IF  b01downfilesystem
            THEN
                trError_gg00 := e_shutdown
            ELSE
                IF  first_time
                THEN
                    BEGIN
                    b30current (t, file_id, m_get, current);
                    currUnlockAllowed_bd00 := true
                    END
                ELSE
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 155);
                    (*ENDIF*) 
                (*ENDIF*) 
            (*ENDIF*) 
            IF  t.trError_gg00 = e_ok
            THEN
                BEGIN
&               ifdef TRACE
                t01int4 (bi, 'root        ', curr_tree_id.fileRoot_gg00);
&               endif
                root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
                b30find_leaf (key, current);
                first_time := false
                END;
            (*ENDIF*) 
            IF  curr_lockstate = r_lock_tree
            THEN
                b75turead_unlock_tree (current);
            (*ENDIF*) 
            IF  trError_gg00 = e_bd_leaf_unlocked
            THEN
                BEGIN
                retry_count := retry_count + 1;
                IF  retry_count > c_number_of_retries
                THEN
                    vsleep (t.trTaskId_gg00, 0)
                (*ENDIF*) 
                END
            (*ENDIF*) 
        UNTIL
            trError_gg00 <> e_bd_leaf_unlocked;
        (*ENDREPEAT*) 
        IF  trError_gg00 <> e_ok
        THEN
            b06illegal_root_access (current)
        (*ENDIF*) 
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
t01basis_error (bi, 'bd find leaf', t.trError_gg00);
&endif
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := t.trError_gg00;
    b120InsertTrace (t, bd, b02get, sizeof (root_trace), @root_trace)
    END
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02finish_load (VAR t : tgg00_TransContext;
            VAR file_id    : tgg00_FileId;
            rightmost_leaf : tsp00_PageNo);
 
VAR
      current : tbd_current_tree;
 
BEGIN
&ifdef TRACE
t01name (bi, '====> bd finish lo');
t01int4 (bi, 'root        ', file_id.fileRoot_gg00);
t01int4 (bi, 'rightmost lf', rightmost_leaf);
&endif
b30cinit_current (t, current);
IF  b01downfilesystem
THEN
    t.trError_gg00 := e_shutdown
ELSE
    WITH current, t DO
        BEGIN
        trError_gg00 := e_ok;
        curr_tree_id := file_id;
        IF  (ftsByteStr_egg00 in file_id.fileType_gg00) AND
            (rightmost_leaf <> NIL_PAGE_NO_GG00)
        THEN
            b05finish_load (rightmost_leaf, current);
        (*ENDIF*) 
        IF  trError_gg00 = e_ok
        THEN
            file_id := curr_tree_id
        (*ENDIF*) 
        END;
    (*ENDWITH*) 
(*ENDIF*) 
&ifdef TRACE
t01basis_error (bi, 'fini load e ', t.trError_gg00);
&endif
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02get_lock_record (VAR t : tgg00_TransContext;
            VAR file_id : tgg00_FileId;
            VAR rk      : tgg00_Lkey;
            VAR b       : tgg00_Rec);
 
VAR
      auxError    : tgg00_BasisError;
      first_time  : boolean;
      retry_count : integer;
      key_trace   : tgg11_BdKeyTrace;
      root_trace  : tgg11_BdRootTrace;
      current     : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    auxError                 := e_ok;
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := rk.keyLen_gg00;
    g10mv2 ('VBD02 ',  10,    
          rk.keyLen_gg00, sizeof (key_trace.bdkKey_gg11),
          rk.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( rk.keyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b02get, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd get lock ');
t01treeid (bi, 'treeid      ', file_id);
t01lkey   (bi, rk);
&endif
IF  ftsTemp_egg00 in file_id.fileType_gg00
THEN
    b73cmd_count (icget_rec)
ELSE
    b73cmd_count (iget_rec);
(*ENDIF*) 
first_time  := true;
retry_count := 1;
b30cinit_current (t, current);
WITH current, t DO
    BEGIN
    IF  (rk.keyLen_gg00 > MAX_KEYLEN_GG00) OR (rk.keyLen_gg00 < 0)
    THEN
        trError_gg00 := e_illegal_key
    ELSE
        BEGIN
        REPEAT
            trError_gg00 := e_ok;
            IF  b01downfilesystem
            THEN
                trError_gg00 := e_shutdown
            ELSE
                IF  first_time
                THEN
                    BEGIN
                    b30current (t, file_id, m_get, current);
                    currUnlockAllowed_bd00 := true
                    END
                ELSE
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 155);
                    (*ENDIF*) 
                (*ENDIF*) 
            (*ENDIF*) 
            IF  t.trError_gg00 = e_ok
            THEN
                BEGIN
&               ifdef TRACE
                t01int4 (bi, 'root        ', curr_tree_id.fileRoot_gg00);
&               endif
                root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
                b30get_from_tree (rk, b, current, lckRowShare_egg00);
                first_time := false
                END;
            (*ENDIF*) 
            IF  curr_lockstate = r_lock_tree
            THEN
                b75turead_unlock_tree (current);
            (*ENDIF*) 
            IF  trError_gg00 = e_bd_leaf_unlocked
            THEN
                BEGIN
                retry_count := retry_count + 1;
                IF  retry_count > c_number_of_retries
                THEN
                    vsleep (t.trTaskId_gg00, 0)
                (*ENDIF*) 
                END
            (*ENDIF*) 
        UNTIL
            trError_gg00 <> e_bd_leaf_unlocked;
        (*ENDREPEAT*) 
        IF  trError_gg00 <> e_ok
        THEN
            b06illegal_root_access (current)
        (*ENDIF*) 
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
IF  t.trError_gg00 = e_ok
THEN
    BEGIN
    t01buf (bi, b.buf, 1, b.len);
&   ifdef vers80
    b06record_check (b, file_id, t.trError_gg00);
&   endif
    END;
(*ENDIF*) 
t01basis_error (bi, 'get lock rec', t.trError_gg00);
&endif
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := t.trError_gg00;
    b120InsertTrace (t, bd, b02get, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02get_record (VAR t : tgg00_TransContext;
            VAR file_id : tgg00_FileId;
            VAR rk      : tgg00_Lkey;
            VAR b       : tgg00_Rec);
 
VAR
      auxError    : tgg00_BasisError;
      first_time  : boolean;
      retry_count : integer;
      key_trace   : tgg11_BdKeyTrace;
      root_trace  : tgg11_BdRootTrace;
      current     : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    auxError                 := e_ok;
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := rk.keyLen_gg00;
    g10mv2 ('VBD02 ',  11,    
          rk.keyLen_gg00, sizeof (key_trace.bdkKey_gg11),
          rk.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( rk.keyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b02get, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd get rec  ');
t01treeid (bi, 'treeid      ', file_id);
t01lkey   (bi, rk);
&endif
IF  ftsTemp_egg00 in file_id.fileType_gg00
THEN
    b73cmd_count (icget_rec)
ELSE
    b73cmd_count (iget_rec);
(*ENDIF*) 
first_time  := true;
retry_count := 1;
b30cinit_current (t, current);
WITH current, t DO
    BEGIN
    IF  (rk.keyLen_gg00 > MAX_KEYLEN_GG00) OR (rk.keyLen_gg00 < 0)
    THEN
        trError_gg00 := e_illegal_key
    ELSE
        BEGIN
        REPEAT
            trError_gg00 := e_ok;
            IF  b01downfilesystem
            THEN
                trError_gg00 := e_shutdown
            ELSE
                IF  first_time
                THEN
                    BEGIN
                    b30current (t, file_id, m_get, current);
                    currUnlockAllowed_bd00 := true
                    END
                ELSE
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 156);
                    (*ENDIF*) 
                (*ENDIF*) 
            (*ENDIF*) 
            IF  t.trError_gg00 = e_ok
            THEN
                BEGIN
&               ifdef TRACE
                t01int4 (bi, 'root        ', curr_tree_id.fileRoot_gg00);
&               endif
                root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
                b30get_from_tree (rk, b, current, lckFree_egg00);
                first_time := false
                END;
            (*ENDIF*) 
            IF  curr_lockstate = r_lock_tree
            THEN
                b75turead_unlock_tree (current);
            (*ENDIF*) 
            IF  trError_gg00 = e_bd_leaf_unlocked
            THEN
                BEGIN
                retry_count := retry_count + 1;
                IF  retry_count > c_number_of_retries
                THEN
                    vsleep (t.trTaskId_gg00, 0)
                (*ENDIF*) 
                END;
            (*ENDIF*) 
        UNTIL
            trError_gg00 <> e_bd_leaf_unlocked;
        (*ENDREPEAT*) 
        IF  trError_gg00 <> e_ok
        THEN
            b06illegal_root_access (current)
        (*ENDIF*) 
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
IF  t.trError_gg00 = e_ok
THEN
    BEGIN
    t01buf (bi, b.buf, 1, b.len);
&   ifdef vers80
    b06record_check (b, file_id, t.trError_gg00);
&   endif
    END;
(*ENDIF*) 
t01basis_error (bi, 'get rec err ', t.trError_gg00);
&endif
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := t.trError_gg00;
    b120InsertTrace (t, bd, b02get, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02init_load (VAR t      : tgg00_TransContext;
            VAR file_id        : tgg00_FileId;
            set_read_only      : boolean;
            VAR rightmost_leaf : tsp00_PageNo);
 
VAR
      fi      : tbd_fileinfo;
      current : tbd_current_tree;
 
BEGIN
&ifdef TRACE
t01name   (bi, '====> bd init load');
t01treeid (bi, 'treeid      ', file_id);
&endif
rightmost_leaf := NIL_PAGE_NO_GG00;
b30cinit_current (t, current);
IF  b01downfilesystem
THEN
    t.trError_gg00 := e_shutdown
ELSE
    WITH current, t DO
        BEGIN
        trError_gg00 := e_ok;
        IF  ftsByteStr_egg00 in file_id.fileType_gg00
        THEN
            BEGIN
            file_id.fileRoot_gg00 := NIL_PAGE_NO_GG00;
            b01bcreate_bytestr (t, file_id);
            IF  trError_gg00 = e_duplicate_filename
            THEN
                b05trunc_bytestr (t, file_id, 0, NIL_STR_VERSION_GG00);
            (*ENDIF*) 
            IF  trError_gg00 = e_ok
            THEN
                BEGIN
                curr_tree_id := file_id;
                IF  set_read_only
                THEN
                    BEGIN
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tldelete_lock_tree (current, c_ignore_svp, 157); (* PTS 1106058 TS 2000-03-28 *)
                    (*ENDIF*) 
                    b30add_filestate (current, [ f_read_only ]);
                    IF  trError_gg00 = e_ok
                    THEN
                        b17set_filestate (file_id.fileName_gg00, t,
                              [ f_read_only ], NOT c_reset);
                    (*ENDIF*) 
                    IF  curr_lockstate = d_lock_tree
                    THEN
                        b75tudelete_unlock_tree (current)
                    (*ENDIF*) 
                    END;
                (*ENDIF*) 
                IF  trError_gg00 = e_ok
                THEN
                    b05init_load (rightmost_leaf, current);
                (*ENDIF*) 
                IF  trError_gg00 = e_ok
                THEN
                    file_id := curr_tree_id
                (*ENDIF*) 
                END
            (*ENDIF*) 
            END
        ELSE
            BEGIN
            b17state_fdir (file_id.fileName_gg00, fi, ftsShared_egg00 in
                  file_id.fileType_gg00, t);
&           ifdef TRACE
            t01basis_error (bi, 'e =         ', trError_gg00);
&           endif
            IF  trError_gg00 = e_ok
            THEN
                BEGIN
                b30fdir_to_treeid (fi, file_id);
                curr_tree_id := file_id;
                IF  (file_id.fileVersion_gg00.ci2_gg00 <> cgg_dummy_file_version)
                    AND (fi.fi_vers <> file_id.fileVersion_gg00)
                THEN
                    trError_gg00 := e_old_fileversion
                ELSE
                    IF  f_bad in fi.fi_state
                    THEN
                        trError_gg00 := e_bad_file
                    (*ENDIF*) 
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            IF  (trError_gg00 = e_ok) AND
                set_read_only  AND
                (NOT (ftsTemp_egg00 in file_id.fileType_gg00)) AND
                (NOT g04inv_tfn (file_id.fileTfn_gg00))
            THEN
                BEGIN
                IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                THEN
                    b75tldelete_lock_tree (current, c_ignore_svp, 158); (* PTS 1106058 TS 2000-03-28 *)
                (*ENDIF*) 
                b30add_filestate (current, [ f_read_only ]);
                IF  trError_gg00 = e_ok
                THEN
                    b17set_filestate (file_id.fileName_gg00, t,
                          [ f_read_only ], NOT c_reset);
                (*ENDIF*) 
                IF  curr_lockstate = d_lock_tree
                THEN
                    b75tudelete_unlock_tree (current)
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            IF  trError_gg00 = e_ok
            THEN
                BEGIN
                b30init_load (rightmost_leaf, current);
                IF  trError_gg00 = e_ok
                THEN
                    file_id := curr_tree_id
                (*ENDIF*) 
                END
            (*ENDIF*) 
            END
        (*ENDIF*) 
        END;
    (*ENDWITH*) 
(*ENDIF*) 
&ifdef TRACE
t01int4        (bi, 'rightmost lf', rightmost_leaf);
t01basis_error (bi, 'init load e ', t.trError_gg00);
&endif
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02kb_del_rec (VAR m  : tgg00_MessBlock;
            pDeleteCmd      : tsp00_Addr;
            VAR rk          : tgg00_Lkey;
            VAR old_recbuf  : tgg00_Rec;
            granted_lock    : tgg00_LockReqMode);
 
VAR
      auxError   : tgg00_BasisError;
      key_trace  : tgg11_BdKeyTrace;
      root_trace : tgg11_BdRootTrace;
      current    : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    auxError                 := e_ok;
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := rk.keyLen_gg00;
    g10mv2 ('VBD02 ',  12,    
          rk.keyLen_gg00, sizeof (key_trace.bdkKey_gg11),
          rk.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( rk.keyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (m.mb_trns^, bd, b02kb_del, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd kbdel rec');
t01treeid (bi, 'treeid      ', m.mb_qual^.mtree);
t01lkey   (bi, rk);
&endif
IF  ftsTemp_egg00 in m.mb_qual^.mtree.fileType_gg00
THEN
    b73cmd_count (icdel_rec)
ELSE
    b73cmd_count (idel_rec);
(*ENDIF*) 
b30cinit_current (m.mb_trns^, current);
WITH current, m.mb_trns^, m.mb_qual^ DO
    BEGIN
    IF  b01downfilesystem
    THEN
        trError_gg00 := e_shutdown
    ELSE
        IF  (rk.keyLen_gg00 > MAX_KEYLEN_GG00) OR (rk.keyLen_gg00 < 0)
        THEN
            trError_gg00 := e_illegal_key
        ELSE
            trError_gg00 := e_ok;
        (*ENDIF*) 
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        bd999CheckSpace( m.mb_trns^, 1);
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        BEGIN
        mtree.fileBdUse_gg00 := mtree.fileBdUse_gg00 + [bd_write_acc];
        trState_gg00         := trState_gg00 + [tsBdLocked_egg00];
        b30current (m.mb_trns^, mtree, m.mb_type, current);
        IF  trError_gg00 = e_ok
        THEN
            BEGIN
            root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
            bd30CreateBeforeImageForDelete (m, pDeleteCmd, rk, old_recbuf,
                  granted_lock, current);
            IF  trError_gg00 = e_file_must_be_read_only
            THEN
                BEGIN
                IF  curr_lockstate = r_lock_tree
                THEN
                    b75turead_unlock_tree (current);
                (*ENDIF*) 
                b30set_read_only (current);
                IF  trError_gg00 = e_ok
                THEN
                    BEGIN
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 159);
                    (*ENDIF*) 
                    bd30CreateBeforeImageForDelete (m, pDeleteCmd, rk,
                          old_recbuf, granted_lock, current)
                    END
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            IF  trError_gg00 = e_ok
            THEN
                BEGIN
                IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                THEN
                    b75tlread_lock_tree (current, 159);
                (*ENDIF*) 
                b30del_from_tree (rk, current)
                END
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  curr_lockstate = r_lock_tree
        THEN
            b75turead_unlock_tree (current);
        (*ENDIF*) 
        IF  trError_gg00 = e_ok
        THEN
            mtree := curr_tree_id
        ELSE
            b06illegal_root_access (current);
        (*ENDIF*) 
        trState_gg00         := trState_gg00 - [tsBdLocked_egg00];
        mtree.fileBdUse_gg00 := mtree.fileBdUse_gg00 - [bd_write_acc];
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := m.mb_trns^.trError_gg00;
    b120InsertTrace (m.mb_trns^, bd, b02kb_del, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02kb_ins_record (VAR m : tgg00_MessBlock;
            pInsertCmd        : tsp00_Addr;
            VAR b             : tgg00_Rec;
            granted_lock      : tgg00_LockReqMode);
 
VAR
      auxError   : tgg00_BasisError;
      key_trace  : tgg11_BdKeyTrace;
      root_trace : tgg11_BdRootTrace;
      current    : tbd_current_tree;
 
BEGIN
IF  (g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00)
THEN
    BEGIN
    root_trace.bdrRoot_gg11 := NIL_PAGE_NO_GG00;
    IF  m.mb_type2 <> mm_nokey
    THEN
        BEGIN
        auxError                 := e_ok;
        key_trace.bdkTrType_gg11 := bdtrKey_egg11;
        key_trace.bdkKeyLen_gg11 := b.recKeyLen_gg00;
        g10mv2 ('VBD02 ',  13,    
              b.recKeyLen_gg00, sizeof (key_trace.bdkKey_gg11),
              b.recKey_gg00.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
              gg06Min( b.recKeyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
        b120InsertTrace (m.mb_trns^, bd, b02logadd, sizeof (key_trace), @key_trace)
        END
    (*ENDIF*) 
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd kbins rec');
t01treeid (bi, 'treeid      ', m.mb_qual^.mtree);
t01buf    (bi, b.recBuf_gg00, 1, b.recLen_gg00);
&endif
IF  ftsTemp_egg00 in m.mb_qual^.mtree.fileType_gg00
THEN
    b73cmd_count (icadd_rec)
ELSE
    b73cmd_count (iadd_rec);
(*ENDIF*) 
b30cinit_current (m.mb_trns^, current);
WITH current, m.mb_trns^, m.mb_qual^ DO
    BEGIN
    IF  b01downfilesystem
    THEN
        trError_gg00 := e_shutdown
    ELSE
        IF  (b.recLen_gg00 > MAX_RECLEN_GG00) OR (b.recLen_gg00 < MIN_RECORD_LEN_BD00)
        THEN
            trError_gg00 := e_illegal_record
        ELSE
            BEGIN
            IF  (b.recKeyLen_gg00 > MAX_KEYLEN_GG00) OR (b.recKeyLen_gg00 < 0)
            THEN
                trError_gg00 := e_illegal_key
            ELSE
                trError_gg00 := e_ok;
            (*ENDIF*) 
            END;
        (*ENDIF*) 
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        bd999CheckSpace( m.mb_trns^, 1);
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        BEGIN
        mtree.fileBdUse_gg00 := mtree.fileBdUse_gg00 + [bd_write_acc];
        trState_gg00         := trState_gg00 + [tsBdLocked_egg00];
        b30current (m.mb_trns^, mtree, m.mb_type, current);
&       ifdef vers80
        IF  trError_gg00 = e_ok
        THEN
            b06record_check (b, mtree, trError_gg00);
&       endif
        (*ENDIF*) 
        IF  trError_gg00 = e_ok
        THEN
            BEGIN
            root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
            bd30CreateBeforeImageForInsert (b.recKey_gg00, b, m, pInsertCmd,
                  granted_lock, current);
            IF  trError_gg00 = e_file_must_be_read_only
            THEN
                BEGIN
                IF  curr_lockstate = r_lock_tree
                THEN
                    b75turead_unlock_tree (current);
                (*ENDIF*) 
                b30set_read_only (current);
                IF  trError_gg00 = e_ok
                THEN
                    BEGIN
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 161);
                    (*ENDIF*) 
                    bd30CreateBeforeImageForInsert (b.recKey_gg00, b, m, pInsertCmd,
                          granted_lock, current);
                    END
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            IF  trError_gg00 = e_ok
            THEN
                BEGIN
                IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                THEN
                    b75tlread_lock_tree (current, 161);
                (*ENDIF*) 
                b30add_to_tree (b.recKey_gg00, b, NINETY_PERCENT_COV_BD00, current);
                END
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  curr_lockstate = r_lock_tree
        THEN
            b75turead_unlock_tree (current);
        (*ENDIF*) 
        IF  trError_gg00 = e_ok
        THEN
            mtree := curr_tree_id
        ELSE
            b06illegal_root_access (current);
        (*ENDIF*) 
        trState_gg00         := trState_gg00 - [tsBdLocked_egg00];
        mtree.fileBdUse_gg00 := mtree.fileBdUse_gg00 - [bd_write_acc];
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := m.mb_trns^.trError_gg00;
    b120InsertTrace (m.mb_trns^, bd, b02logadd, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02kb_upd_rec (VAR m : tgg00_MessBlock;
            pUpdateCmd     : tsp00_Addr;
            VAR rk         : tgg00_Lkey;
            VAR old_recbuf : tgg00_Rec;
            VAR new_recbuf : tgg00_Rec;
            granted_lock   : tgg00_LockReqMode);
 
VAR
      auxError   : tgg00_BasisError;
      key_trace  : tgg11_BdKeyTrace;
      root_trace : tgg11_BdRootTrace;
      current    : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    auxError                 := e_ok;
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := rk.keyLen_gg00;
    g10mv2 ('VBD02 ',  14,    
          rk.keyLen_gg00, sizeof (key_trace.bdkKey_gg11),
          rk.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( rk.keyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (m.mb_trns^, bd, b02kb_repl, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd kbupd rec');
t01treeid (bi, 'treeid      ', m.mb_qual^.mtree);
t01lkey   (bi, rk);
&endif
IF  ftsTemp_egg00 in m.mb_qual^.mtree.fileType_gg00
THEN
    b73cmd_count (icrepl_rec)
ELSE
    b73cmd_count (irepl_rec);
(*ENDIF*) 
b30cinit_current (m.mb_trns^, current);
WITH current, m.mb_trns^, m.mb_qual^ DO
    BEGIN
    IF  b01downfilesystem
    THEN
        trError_gg00 := e_shutdown
    ELSE
        IF  (rk.keyLen_gg00 > MAX_KEYLEN_GG00) OR (rk.keyLen_gg00 < 0)
        THEN
            trError_gg00 := e_illegal_key
        ELSE
            trError_gg00 := e_ok;
        (*ENDIF*) 
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        bd999CheckSpace( m.mb_trns^, 1);
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        BEGIN
        mtree.fileBdUse_gg00 := mtree.fileBdUse_gg00 + [bd_write_acc];
        trState_gg00         := trState_gg00 + [tsBdLocked_egg00];
        b30current (m.mb_trns^, mtree, m.mb_type, current);
        IF  trError_gg00 = e_ok
        THEN
            BEGIN
            root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
            bd30CreateBeforeImageForUpdate (m, pUpdateCmd, rk,
                  old_recbuf, new_recbuf, granted_lock, current);
            IF  trError_gg00 = e_file_must_be_read_only
            THEN
                BEGIN
                IF  curr_lockstate = r_lock_tree
                THEN
                    b75turead_unlock_tree (current);
                (*ENDIF*) 
                b30set_read_only (current);
                IF  trError_gg00 = e_ok
                THEN
                    BEGIN
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 164);
                    (*ENDIF*) 
                    bd30CreateBeforeImageForUpdate (m, pUpdateCmd, rk,
                          old_recbuf, new_recbuf, granted_lock, current)
                    END
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            IF  trError_gg00 = e_ok
            THEN
                BEGIN
                IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                THEN
                    b75tlread_lock_tree (current, 164);
                (*ENDIF*) 
                b30repl_in_tree (rk, new_recbuf, current)
                END
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  curr_lockstate = r_lock_tree
        THEN
            b75turead_unlock_tree (current);
        (*ENDIF*) 
        IF  trError_gg00 = e_ok
        THEN
            mtree := curr_tree_id
        ELSE
            b06illegal_root_access (current);
        (*ENDIF*) 
        mtree.fileBdUse_gg00 := mtree.fileBdUse_gg00 - [bd_write_acc];
        trState_gg00         := trState_gg00 - [tsBdLocked_egg00];
        END;
&   ifdef vers80
    (*ENDIF*) 
    IF  m.mb_trns^.trError_gg00 = e_ok
    THEN
        BEGIN
        b06record_check (old_recbuf, mtree, m.mb_trns^.trError_gg00);
        b06record_check (new_recbuf, mtree, m.mb_trns^.trError_gg00);
        END;
&   endif
    (*ENDIF*) 
    END;
(*ENDWITH*) 
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := m.mb_trns^.trError_gg00;
    b120InsertTrace (m.mb_trns^, bd, b02kb_repl, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02load_table (VAR t     : tgg00_TransContext;
            VAR tree_id        : tgg00_FileId;
            VAR rightmost_leaf : tsp00_PageNo;
            VAR check_leaf     : tsp00_PageNo;
            load_buf_len       : tsp00_Int4;
            VAR load_buf       : tsp00_MoveObj);
 
VAR
      only_left         : boolean;
      data_pos          : tsp00_Int4;
      left_pno          : tsp00_PageNo;
      lnptr             : tbd_node_ptrs;
      nptr              : tbd_node_ptrs;
      current           : tbd_current_tree;
      save_bottom       : tgg00_PagePos;
      save_conv_version : tsp00_Int4;
      save_rec_cnt      : tsp00_Int4;
      save_file_state   : tbd_file_state_set;
 
BEGIN
&ifdef TRACE
t01name (bi, '====> bd load tab ');
t01treeid (bi, 'treeid      ', tree_id); (* PTS XXXX TS 2000-12-27 *)
t01int4   (bi, 'rightmost   ', rightmost_leaf);
t01int4   (bi, 'buffer len  ', load_buf_len);
&endif
b30cinit_current (t, current);
IF  b01downfilesystem
THEN
    t.trError_gg00 := e_shutdown
ELSE
    WITH current, curr_tree_id, t DO
        BEGIN
        trError_gg00   := e_ok;
        lnptr.np_ptr   := NIL;
        lnptr.np_cbptr := NIL;
        nptr           := lnptr;
        left_pno       := NIL_PAGE_NO_GG00;
        curr_tree_id   := tree_id;
        bd999CheckSpace(t, 2);
        IF  t.trError_gg00 = e_ok
        THEN
            BEGIN
            IF  ftsConcurrent_egg00 in fileType_gg00
            THEN
                b75tldelete_lock_tree (current, ftsTemp_egg00 in fileType_gg00, 168);
            (*ENDIF*) 
            data_pos := 1;
            IF  rightmost_leaf <> check_leaf
            THEN
                trError_gg00 := e_invalid
            ELSE
                bd13GetNode (current, rightmost_leaf, plmNoLock_ebd00,
                      nr_for_update, lnptr);
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        WHILE (trError_gg00 = e_ok) AND (data_pos < load_buf_len) DO
            BEGIN
            IF  lnptr.np_ptr^.nd_bottom = BODY_BEG_BD00
            THEN
                IF  rightmost_leaf <> fileRoot_gg00
                THEN
                    trError_gg00 := e_invalid
                ELSE
                    WITH lnptr, np_ptr^ DO
                        BEGIN
                        (* *)
                        (* rightmost_leaf = root *)
                        (* *)
                        save_file_state   := nd_file_state;(* PTS 1116857 TS 2002-07-24 *)
                        save_conv_version := nd_conv_version;
                        (* *)
                        g10mv ('VBD02 ',  15,    
                              load_buf_len, sizeof (np_ptr^),
                              load_buf, sizeof (nd_id) + data_pos,
                              np_ptr^, sizeof (nd_id) + 1,
                              sizeof (np_ptr^) - sizeof (nd_id),
                              trError_gg00);
                        IF  trError_gg00 = e_ok
                        THEN
                            BEGIN
                            data_pos         :=
                                  sizeof (np_ptr^) + data_pos;
                            (* h.b. 19.02.99                          *)
                            (* changed initialisation for FASTLOAD:   *)
                            (* list_top and bottom are already filled *)
                            (* by FASTLOAD                            *)
                            save_bottom     := nd_bottom;
                            save_rec_cnt    := nd_record_cnt;
                            b13init_default_data_page (t, curr_tree_id, LEAF_LEVEL_BD00, nd_id, lnptr);
                            nd_bottom       := save_bottom;
                            nd_record_cnt   := save_rec_cnt;
                            nd_file_version := fileVersion_gg00;
                            nd_file_state   := save_file_state; (* PTS 1116857 TS 2002-07-24 *)
                            nd_conv_version := save_conv_version;
&                           ifdef TRACE
                            t01page (bi, np_ptr^, 1, 80);
&                           endif
                            IF  load_buf_len <= sizeof (lnptr.np_ptr^)
                            THEN
                                only_left := true
                            ELSE
                                BEGIN
                                b13new_node (LEAF_LEVEL_BD00, nptr,
                                      current);
                                IF  trError_gg00 = e_ok
                                THEN
                                    WITH nptr, np_ptr^ DO
                                        BEGIN
                                        only_left := false;
                                        g10mv ('VBD02 ',  16,    
                                              load_buf_len,
                                              sizeof (np_ptr^),
                                              load_buf,
                                              sizeof (nd_id) + data_pos,
                                              np_ptr^, sizeof (nd_id)+1,
                                              sizeof (np_ptr^) -
                                              sizeof (nd_id),
                                              trError_gg00);
                                        data_pos := data_pos +
                                              sizeof (np_ptr^);
&                                       ifdef TRACE
                                        t01page (bi, np_ptr^, 1, 80);
&                                       endif
                                        END
                                    (*ENDWITH*) 
                                (*ENDIF*) 
                                END
                            (*ENDIF*) 
                            END;
                        (*ENDIF*) 
                        IF  trError_gg00 = e_ok
                        THEN
                            IF  ftsByteStr_egg00 in fileType_gg00
                            THEN
                                b05load_string (lnptr, nptr, left_pno,
                                      current)
                            ELSE
                                b30load_table (lnptr, nptr, only_left, current)
                            (*ENDIF*) 
                        (*ENDIF*) 
                        END
                    (*ENDWITH*) 
                (*ENDIF*) 
            ELSE
                BEGIN
                b13new_node (LEAF_LEVEL_BD00, nptr, current);
                IF  trError_gg00 = e_ok
                THEN
                    WITH nptr, np_ptr^ DO
                        BEGIN
                        g10mv ('VBD02 ',  17,    
                              load_buf_len, sizeof (np_ptr^),
                              load_buf, sizeof (nd_id) + data_pos,
                              np_ptr^, sizeof (nd_id) + 1,
                              sizeof (np_ptr^) - sizeof (nd_id),
                              t.trError_gg00);
                        data_pos := data_pos + sizeof (np_ptr^);
&                       ifdef TRACE
                        t01int4 (bi, 'root        ', fileRoot_gg00);
                        t01page (bi, np_ptr^, 1, 80);
&                       endif
                        IF  trError_gg00 = e_ok
                        THEN
                            IF  ftsByteStr_egg00 in fileType_gg00
                            THEN
                                b05load_string (lnptr, nptr, left_pno,
                                      current)
                            ELSE
                                b30load_table (lnptr, nptr, NOT c_only_left, current)
                            (*ENDIF*) 
                        (*ENDIF*) 
                        END
                    (*ENDWITH*) 
                (*ENDIF*) 
                END
            (*ENDIF*) 
            END;
        (*ENDWHILE*) 
        IF  (ftsByteStr_egg00 in fileType_gg00    ) AND
            (trError_gg00 = e_ok              ) AND
            (left_pno <> NIL_PAGE_NO_GG00)
        THEN
            BEGIN
            (* b61add_bstrindex must be executed *)
            nptr.np_ptr := NIL;
            b05load_string (lnptr, nptr, left_pno, current)
            END;
        (*ENDIF*) 
        IF  lnptr.np_ptr = NIL
        THEN
            rightmost_leaf := NIL_PAGE_NO_GG00
        ELSE
            BEGIN
            rightmost_leaf := lnptr.np_ptr^.nd_id;
            IF  trError_gg00 = e_ok
            THEN
                b13w_release_node (lnptr, current)
            ELSE
                b13r_release_node (lnptr, current, lru_normal)
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  nptr.np_ptr <> NIL
        THEN
            b13r_release_node (nptr, current, lru_normal);
        (*ENDIF*) 
        check_leaf := rightmost_leaf;
        IF  curr_lockstate = d_lock_tree
        THEN
            b75tudelete_unlock_tree (current)
        (*ENDIF*) 
        END;
    (*ENDWITH*) 
(*ENDIF*) 
&ifdef TRACE
t01basis_error (bi, 'load tab  e ', t.trError_gg00);
&endif
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02next_record (VAR t : tgg00_TransContext;
            VAR file_id : tgg00_FileId;
            VAR rk      : tgg00_Lkey;
            inclusive   : boolean;
            VAR b       : tgg00_Rec);
 
VAR
      auxError   : tgg00_BasisError;
      first_time  : boolean;
      retry_count : integer;
      tree_pos    : tgg00_FilePos;
      key_trace   : tgg11_BdKeyTrace;
      root_trace  : tgg11_BdRootTrace;
      current     : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    auxError                 := e_ok;
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := rk.keyLen_gg00;
    g10mv2 ('VBD02 ',  18,    
          rk.keyLen_gg00, sizeof (key_trace.bdkKey_gg11),
          rk.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( rk.keyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b02next, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd next rec ');
t01treeid (bi, 'treeid      ', file_id);
t01lkey   (bi, rk);
&endif
IF  ftsTemp_egg00 in file_id.fileType_gg00
THEN
    b73cmd_count (icnext_rec)
ELSE
    b73cmd_count (inext_rec);
(*ENDIF*) 
first_time  := true;
retry_count := 1;
b30cinit_current (t, current);
WITH current, t DO
    BEGIN
    IF  (rk.keyLen_gg00 > MAX_KEYLEN_GG00) OR (rk.keyLen_gg00 < 0)
    THEN
        trError_gg00 := e_illegal_key
    ELSE
        BEGIN
        REPEAT
            trError_gg00 := e_ok;
            IF  b01downfilesystem
            THEN
                trError_gg00 := e_shutdown
            ELSE
                IF  first_time
                THEN
                    BEGIN
                    b30current (t, file_id, m_select, current);
                    currUnlockAllowed_bd00 := true
                    END
                ELSE
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 170);
                    (*ENDIF*) 
                (*ENDIF*) 
            (*ENDIF*) 
            IF  t.trError_gg00 = e_ok
            THEN
                BEGIN
                root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
                tree_pos.tpsPno_gg00 := NIL_PAGE_NO_GG00;
                b30next_from_tree (rk, inclusive, tree_pos, b, current);
                first_time := false
                END;
            (*ENDIF*) 
            IF  curr_lockstate = r_lock_tree
            THEN
                b75turead_unlock_tree (current);
            (*ENDIF*) 
            IF  trError_gg00 = e_bd_leaf_unlocked
            THEN
                BEGIN
                retry_count := retry_count + 1;
                IF  retry_count > c_number_of_retries
                THEN
                    vsleep (t.trTaskId_gg00, 0)
                (*ENDIF*) 
                END;
            (*ENDIF*) 
        UNTIL
            trError_gg00 <> e_bd_leaf_unlocked;
        (*ENDREPEAT*) 
        IF  trError_gg00 <> e_ok
        THEN
            b06illegal_root_access (current)
        (*ENDIF*) 
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
IF  (t.trError_gg00 = e_ok) OR (t.trError_gg00 = e_key_not_found)
THEN
    BEGIN
    t01buf (bi, b.buf, 1, b.len);
&   ifdef vers80
    b06record_check (b, file_id, t.trError_gg00);
&   endif
    END;
&endif
(*ENDIF*) 
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := t.trError_gg00;
    b120InsertTrace (t, bd, b02next, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02prefetch (VAR t : tgg00_TransContext;
            VAR file_id : tgg00_FileId;
            pno         : tsp00_PageNo);
 
VAR
      aux_nptr : tbd_node_ptrs;
      current  : tbd_current_tree;
 
BEGIN
&ifdef TRACE
t01name   (bi, '====> bd prefetch ');
t01treeid (bi, 'treeid      ', file_id);
t01int4   (bi, 'pno         ', pno);
&endif
WITH t DO
    IF  b01downfilesystem
    THEN
        trError_gg00 := e_shutdown
    ELSE
        BEGIN
        b30cinit_current (t, current);
        current.curr_tree_id := file_id;
        bd13GetNode (current, pno, plmNoLock_ebd00,
              nr_for_upd_ret_if_blocked, aux_nptr);
        IF  trError_gg00 <> e_ok
        THEN
            trError_gg00 := e_ok (* ignore errors *)
        (*ENDIF*) 
        END;
    (*ENDIF*) 
(*ENDWITH*) 
&ifdef TRACE
t01basis_error (bi, 'bd prefetch ', t.trError_gg00);
&endif
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02prev_record (VAR t : tgg00_TransContext;
            VAR file_id : tgg00_FileId;
            VAR rk      : tgg00_Lkey;
            inclusive   : boolean;
            VAR b       : tgg00_Rec);
 
VAR
      auxError   : tgg00_BasisError;
      first_time  : boolean;
      retry_count : integer;
      tree_pos    : tgg00_FilePos;
      key_trace   : tgg11_BdKeyTrace;
      root_trace  : tgg11_BdRootTrace;
      current     : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    auxError                 := e_ok;
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := rk.keyLen_gg00;
    g10mv2 ('VBD02 ',  19,    
          rk.keyLen_gg00, sizeof (key_trace.bdkKey_gg11),
          rk.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( rk.keyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b02prev, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd prev rec ');
t01treeid (bi, 'treeid      ', file_id);
t01lkey   (bi, rk);
&endif
IF  ftsTemp_egg00 in file_id.fileType_gg00
THEN
    b73cmd_count (icprev_rec)
ELSE
    b73cmd_count (iprev_rec);
(*ENDIF*) 
first_time  := true;
retry_count := 1;
b30cinit_current (t, current);
WITH current, t DO
    BEGIN
    IF  (rk.keyLen_gg00 > MAX_KEYLEN_GG00) OR (rk.keyLen_gg00 < 0)
    THEN
        trError_gg00 := e_illegal_key
    ELSE
        BEGIN
        REPEAT
            trError_gg00 := e_ok;
            IF  b01downfilesystem
            THEN
                trError_gg00 := e_shutdown
            ELSE
                IF  first_time
                THEN
                    BEGIN
                    b30current (t, file_id, m_select, current);
                    currUnlockAllowed_bd00 := true
                    END
                ELSE
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 171);
                    (*ENDIF*) 
                (*ENDIF*) 
            (*ENDIF*) 
            IF  t.trError_gg00 = e_ok
            THEN
                BEGIN
                root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
                tree_pos.tpsPno_gg00 := NIL_PAGE_NO_GG00;
                b30prev_from_tree (rk, inclusive, tree_pos, b, current);
                first_time := false;
                END;
            (*ENDIF*) 
            IF  curr_lockstate = r_lock_tree
            THEN
                b75turead_unlock_tree (current);
            (*ENDIF*) 
            IF  trError_gg00 = e_bd_leaf_unlocked
            THEN
                BEGIN
                retry_count := retry_count + 1;
                IF  retry_count > c_number_of_retries
                THEN
                    vsleep (t.trTaskId_gg00, 0)
                (*ENDIF*) 
                END;
            (*ENDIF*) 
        UNTIL
            trError_gg00 <> e_bd_leaf_unlocked;
        (*ENDREPEAT*) 
        IF  trError_gg00 <> e_ok
        THEN
            b06illegal_root_access (current)
        (*ENDIF*) 
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
IF  (t.trError_gg00 = e_ok) OR (t.trError_gg00 = e_key_not_found)
THEN
    BEGIN
    t01buf (bi, b.buf, 1, b.len);
&   ifdef vers80
    b06record_check (b, file_id, t.trError_gg00);
&   endif
    END;
&endif
(*ENDIF*) 
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := t.trError_gg00;
    b120InsertTrace (t, bd, b02prev, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02range_exi_rec (VAR t : tgg00_TransContext;
            VAR file_id       : tgg00_FileId;
            VAR left___pages  : tsp00_Int4;
            VAR middle_pages : tsp00_Int4;
            VAR right__pages : tsp00_Int4;
            VAR rk_the_one    : tgg00_Lkey;
            VAR rk_another    : tgg00_Lkey);
 
VAR
      auxError    : tgg00_BasisError;
      first_time  : boolean;
      retry_count : integer;
      key_trace   : tgg11_BdTwoKeysTrace;
      root_trace  : tgg11_BdRootTrace;
      current     : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrRoot_gg11       := NIL_PAGE_NO_GG00;
    key_trace.bdtkTrType_gg11     := bdtrTwoKeys_egg11;
    key_trace.bdtkKeyLen_gg11 [0] := rk_the_one.keyLen_gg00;
    key_trace.bdtkKeyLen_gg11 [1] := rk_another.keyLen_gg00;
    auxError                      := e_ok;
    g10mv2 ('VBD02 ',  20,    
          rk_the_one.keyLen_gg00, sizeof (key_trace.bdtkKey_gg11[0]),
          rk_the_one.keyVal_gg00, 1, key_trace.bdtkKey_gg11[0], 1,
          gg06Min( rk_the_one.keyLen_gg00,  sizeof( tgg00_VtraceKey )), auxError);
    auxError := e_ok;
    g10mv2 ('VBD02 ',  21,    
          rk_another.keyLen_gg00, sizeof (key_trace.bdtkKey_gg11[1]),
          rk_another.keyVal_gg00, 1, key_trace.bdtkKey_gg11[1], 1,
          gg06Min( rk_another.keyLen_gg00,  sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b02exists, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd range exi');
t01treeid (bi, 'treeid      ', file_id);
t01lkey   (bi, rk_the_one);
t01lkey   (bi, rk_another);
&endif
b30cinit_current (t, current);
WITH current, t DO
    BEGIN
    IF  (rk_the_one.keyLen_gg00 > MAX_KEYLEN_GG00) OR (rk_the_one.keyLen_gg00 < 0) OR
        (rk_another.keyLen_gg00 > MAX_KEYLEN_GG00) OR (rk_another.keyLen_gg00 < 0)
    THEN
        trError_gg00 := e_illegal_key;
    (*ENDIF*) 
    first_time  := true;
    retry_count := 1;
    IF  trError_gg00 = e_ok
    THEN
        BEGIN
        REPEAT
            trError_gg00 := e_ok;
            IF  b01downfilesystem
            THEN
                trError_gg00 := e_shutdown
            ELSE
                IF  first_time
                THEN
                    BEGIN
                    b30current (t, file_id, m_select, current);
                    currUnlockAllowed_bd00 := true
                    END
                ELSE
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 174);
                    (*ENDIF*) 
                (*ENDIF*) 
            (*ENDIF*) 
            IF  trError_gg00 = e_ok
            THEN
                BEGIN
&               ifdef TRACE
                t01int4 (bi, 'root        ', curr_tree_id.fileRoot_gg00);
&               endif
                root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
                b30range_exi_rec (rk_the_one, rk_another,
                      left___pages, middle_pages, right__pages, current);
                first_time := false;
                END;
            (*ENDIF*) 
            IF  curr_lockstate = r_lock_tree
            THEN
                b75turead_unlock_tree (current);
            (*ENDIF*) 
            IF  trError_gg00 = e_bd_leaf_unlocked
            THEN
                BEGIN
                retry_count := retry_count + 1;
                IF  retry_count > c_number_of_retries
                THEN
                    vsleep (t.trTaskId_gg00, 0)
                (*ENDIF*) 
                END;
            (*ENDIF*) 
        UNTIL
            trError_gg00 <> e_bd_leaf_unlocked;
        (*ENDREPEAT*) 
        IF  trError_gg00 <> e_ok
        THEN
            b06illegal_root_access (current)
        (*ENDIF*) 
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := t.trError_gg00;
    b120InsertTrace (t, bd, b02exists, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02reorg_treeindex (VAR t : tgg00_TransContext;
            VAR file_id : tgg00_FileId;
            VAR rk      : tgg00_Lkey);
 
VAR
      fi      : tbd_fileinfo;
      current : tbd_current_tree;
 
BEGIN
&ifdef TRACE
t01name   (bi, '====> bd reorg tre');
t01treeid (bi, 'treeid      ', file_id);
t01lkey   (bi, rk);
&endif
b30cinit_current (t, current);
IF  b01downfilesystem
THEN
    t.trError_gg00 := e_shutdown
ELSE
    WITH current DO
        BEGIN
        t.trError_gg00 := e_ok;
        b17state_fdir (file_id.fileName_gg00, fi, ftsShared_egg00 in
              file_id.fileType_gg00, t);
        IF  t.trError_gg00 = e_ok
        THEN
            BEGIN
            b30fdir_to_treeid (fi, file_id);
            curr_tree_id := file_id;
            IF  fid_new_long_col in fi.fi_descr
            THEN
                b50reorg_treeindex (rk, fi.fi_col_cnt,
                      fi.fi_var_col_cnt_pos, current)
            ELSE
                b50reorg_treeindex (rk, fi.fi_col_cnt,
                      cgg_nil_varcol_cnt_off, current);
            (*ENDIF*) 
            IF  t.trError_gg00 = e_ok
            THEN
                file_id := curr_tree_id
            (*ENDIF*) 
            END
        (*ENDIF*) 
        END;
    (*ENDWITH*) 
(*ENDIF*) 
&ifdef TRACE
t01basis_error (bi, 'reorg tree e', t.trError_gg00);
&endif
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02repl_record (VAR t : tgg00_TransContext;
            VAR file_id     : tgg00_FileId;
            VAR b           : tgg00_Rec);
 
VAR
      auxError   : tgg00_BasisError;
      key_trace  : tgg11_BdKeyTrace;
      root_trace : tgg11_BdRootTrace;
      current    : tbd_current_tree;
 
BEGIN
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    auxError                 := e_ok;
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := b.recKeyLen_gg00;
    g10mv2 ('VBD02 ',  22,    
          b.recKeyLen_gg00, sizeof (key_trace.bdkKey_gg11),
          b.recKey_gg00.keyVal_gg00, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( b.recKeyLen_gg00, sizeof( tgg00_VtraceKey )), auxError);
    b120InsertTrace (t, bd, b02repl, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
t01name   (bi, '====> bd repl rec ');
t01treeid (bi, 'treeid      ', file_id);
t01buf    (bi, b.recBuf_gg00, 1, b.recLen_gg00);
&endif
IF  ftsTemp_egg00 in file_id.fileType_gg00
THEN
    b73cmd_count (icrepl_rec)
ELSE
    b73cmd_count (irepl_rec);
(*ENDIF*) 
b30cinit_current (t, current);
WITH current, t DO
    BEGIN
    IF  b01downfilesystem
    THEN
        trError_gg00 := e_shutdown
    ELSE
        IF  (b.recLen_gg00 > MAX_RECLEN_GG00) OR (b.recLen_gg00 < MIN_RECORD_LEN_BD00)
        THEN
            trError_gg00 := e_illegal_record
        ELSE
            IF  (b.recKeyLen_gg00 > MAX_KEYLEN_GG00) OR (b.recKeyLen_gg00 < 0)
            THEN
                trError_gg00 := e_illegal_key
            ELSE
                trError_gg00 := e_ok;
            (*ENDIF*) 
        (*ENDIF*) 
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        bd999CheckSpace( t, 1);
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        BEGIN
        file_id.fileBdUse_gg00 := file_id.fileBdUse_gg00 + [bd_write_acc];
        b30current (t, file_id, m_update, current);
&       ifdef vers80
        IF  trError_gg00 = e_ok
        THEN
            b06record_check (b, file_id, trError_gg00);
&       endif
        (*ENDIF*) 
        IF  trError_gg00 = e_ok
        THEN
            BEGIN
            root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
            b30repl_in_tree (b.mkey, b, current);
            IF  trError_gg00 = e_file_must_be_read_only
            THEN
                BEGIN
                IF  curr_lockstate = r_lock_tree
                THEN
                    b75turead_unlock_tree (current);
                (*ENDIF*) 
                b30set_read_only (current);
                IF  trError_gg00 = e_ok
                THEN
                    BEGIN
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 175);
                    (*ENDIF*) 
                    b30repl_in_tree (b.mkey, b, current)
                    END
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  curr_lockstate = r_lock_tree
        THEN
            b75turead_unlock_tree (current);
        (*ENDIF*) 
        IF  trError_gg00 = e_ok
        THEN
            file_id := curr_tree_id
        ELSE
            b06illegal_root_access (current);
        (*ENDIF*) 
        file_id.fileBdUse_gg00 := file_id.fileBdUse_gg00 - [bd_write_acc];
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
t01basis_error (bi, 'repl rec err', t.trError_gg00);
&endif
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := t.trError_gg00;
    b120InsertTrace (t, bd, b02repl, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02select_record (VAR t : tgg00_TransContext;
            VAR file_id       : tgg00_FileId;
            VAR RecKey        : tsp00_Key;
            VAR RecKeyLen     : tsp00_Int2;
            VAR StopKey       : tsp00_Key;
            StopKeyLen        : tsp00_Int4;
            recbuf_size       : tsp00_Int4;
            recbuf_ptr        : tsp00_MoveObjPtr;
            VAR sel           : tgg00_SelectFieldsParam;
            VAR stack_desc    : tgg00_StackDesc;
            VAR unqualified   : boolean);
 
CONST
      c_ignore_vwait = true;
 
VAR
      dummy_granted : tgg00_LockReqMode;
 
BEGIN
b02kb_select_rec (t, file_id, RecKey, RecKeyLen, StopKey, StopKeyLen, recbuf_size, recbuf_ptr,
      NOT c_ignore_vwait, sel, stack_desc, unqualified, dummy_granted)
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02kb_select_rec (VAR t : tgg00_TransContext;
            VAR file_id       : tgg00_FileId;
            VAR RecKey        : tsp00_Key;
            VAR RecKeyLen     : tsp00_Int2;
            VAR StopKey       : tsp00_Key;
            StopKeyLen        : tsp00_Int4;
            recbuf_size       : tsp00_Int4;
            recbuf_ptr        : tsp00_MoveObjPtr;
            ignore_vwait      : boolean;
            VAR sel           : tgg00_SelectFieldsParam;
            VAR stack_desc    : tgg00_StackDesc;
            VAR unqualified   : boolean;
            VAR granted_lock  : tgg00_LockReqMode);
 
VAR
      first_time         : boolean;
      aux_error          : tgg00_BasisError;
      loop_mess2_type    : tgg00_MessType2;
      trace_object       : tgg00_VtraceType;
      cur_res_cnt        : integer;
      init_result_len    : integer;
      recbuf_pos         : tsp00_Int4;
      NodeUnlocked       : tsp00_PageNo;
      old_error_leaf     : tsp00_PageNo;
&     ifdef TRACE
      init_m_result_addr : tsp00_MoveObjPtr;
&     endif
      current            : tbd_current_tree;
      key_trace          : tgg11_BdKeyTrace;
      root_trace         : tgg11_BdRootTrace;
      unlock_committed_read_lock : boolean; (* PTS 1117878 UH 2002-10-17 *)
 
BEGIN
unlock_committed_read_lock := false; (* PTS 1117878 UH 2002-10-17 *)
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    CASE sel.sfp_bd_mess2_type OF
        mm_first  :
            trace_object := b02first_qual;
        mm_next   :
            trace_object := b02next_qual;
        mm_direct :
            trace_object := b02direct_qual;
        mm_prev   :
            trace_object := b02prev_qual;
        mm_last   :
            trace_object := b02last_qual;
        OTHERWISE
        END;
    (*ENDCASE*) 
    root_trace.bdrRoot_gg11  := NIL_PAGE_NO_GG00;
    key_trace.bdkTrType_gg11 := bdtrKey_egg11;
    key_trace.bdkKeyLen_gg11 := RecKeyLen;
    aux_error                := e_ok;
    g10mv2 ('VBD02 ',  23,    
          RecKeyLen, sizeof (key_trace.bdkKey_gg11),
          RecKey, 1, key_trace.bdkKey_gg11, 1,
          gg06Min( RecKeyLen, sizeof( tgg00_VtraceKey )), aux_error);
    b120InsertTrace (t, bd, trace_object, sizeof (key_trace), @key_trace)
    END;
&ifdef TRACE
(*ENDIF*) 
WITH sel DO
    IF  (sfp_bd_mess2_type = mm_last) OR (sfp_bd_mess2_type = mm_prev)
    THEN
        t01name (bi, '====> bd prev qual')
    ELSE
        IF  sfp_bd_mess2_type = mm_direct
        THEN
            t01name (bi, '====> bd direcqual')
        ELSE
            t01name (bi, '====> bd next qual');
        (*ENDIF*) 
    (*ENDIF*) 
(*ENDWITH*) 
t01treeid (bi, 'treeid      ', file_id);
t01int4   (bi, 'page cnt    ', t.trRteCommPtr_gg00^.file_record_cnt);
t01buf1   (bi, RecKey, 1, RecKeyLen);
IF  sel.sfp_bd_use_stopkey
THEN
    t01buf1   (bi, StopKey, 1, StopKeyLen);
(*ENDIF*) 
t01bool (bi, 'ignore vwait', ignore_vwait);
&endif
CASE sel.sfp_bd_mess2_type OF
    mm_first, mm_next :
        loop_mess2_type := mm_next;
    mm_direct :
        loop_mess2_type := mm_direct;
    mm_prev, mm_last :
        loop_mess2_type := mm_prev;
    OTHERWISE
        loop_mess2_type := sel.sfp_bd_mess2_type
    END;
(*ENDCASE*) 
b30cinit_current (t, current);
unqualified        := false;
first_time         := true;
old_error_leaf     := NIL_PAGE_NO_GG00;
NodeUnlocked       := NIL_PAGE_NO_GG00;
recbuf_pos         := 1;
cur_res_cnt        := 0;
init_result_len    := sel.sfp_result_length;
IF  sel.sfp_m_result_cnt <= 0
THEN
    sel.sfp_m_result_cnt := 1;
&ifdef TRACE
(*ENDIF*) 
init_m_result_addr := sel.sfp_m_result_addr;
&endif
WITH t, current DO
    BEGIN
    IF  (RecKeyLen > MAX_KEYLEN_GG00) OR (RecKeyLen < 0)
    THEN
        trError_gg00 := e_illegal_key
    ELSE
        IF  (trRteCommPtr_gg00^.to_cancel) AND (trError_gg00 = e_ok)
        THEN
            trError_gg00 := e_cancelled;
        (*ENDIF*) 
    (*ENDIF*) 
    IF  trError_gg00 = e_ok
    THEN
        BEGIN
        IF  sel.sfp_bd_mess2_type = mm_direct
        THEN
            b73cmd_count (isel_direc)
        ELSE
            IF  (sel.sfp_bd_mess2_type = mm_last) OR
                (sel.sfp_bd_mess2_type = mm_prev)
            THEN
                b73cmd_count (isel_prev)
            ELSE
                b73cmd_count (isel_next);
            (*ENDIF*) 
        (*ENDIF*) 
        REPEAT
            trError_gg00 := e_ok;
            IF  b01downfilesystem
            THEN
                trError_gg00 := e_shutdown
            ELSE
                BEGIN
                IF  first_time
                THEN
                    BEGIN
                    b30current (t, file_id, sel.sfp_bd_mess_type, current);
                    currUnlockAllowed_bd00 := true
                    END
                ELSE
                    IF  ftsConcurrent_egg00 in curr_tree_id.fileType_gg00
                    THEN
                        b75tlread_lock_tree (current, 176);
                    (*ENDIF*) 
                (*ENDIF*) 
                IF  trError_gg00 = e_ok
                THEN
                    BEGIN
                    sel.sfp_result_length := init_result_len;
                    root_trace.bdrRoot_gg11 := curr_tree_id.fileRoot_gg00;
                    IF  (sel.sfp_bd_mess2_type = mm_last) OR
                        (sel.sfp_bd_mess2_type = mm_prev)
                    THEN
                        b36pqual_from_tree (RecKey, RecKeyLen, StopKey, StopKeyLen, recbuf_size,
                              recbuf_ptr, recbuf_pos, sel, stack_desc, current, cur_res_cnt,
                              unqualified, granted_lock, NodeUnlocked)
                    ELSE
                        b36nqual_from_tree (RecKey, RecKeyLen, StopKey, StopKeyLen, recbuf_size,
                              recbuf_ptr, recbuf_pos, sel, stack_desc, current, cur_res_cnt,
                              unqualified, granted_lock, NodeUnlocked);
                    (*ENDIF*) 
                    first_time := false
                    END;
                (*ENDIF*) 
                IF  curr_lockstate = r_lock_tree
                THEN
                    b75turead_unlock_tree (current);
                (*ENDIF*) 
                IF  trError_gg00 = e_bd_leaf_unlocked
                THEN
                    BEGIN
                    IF  old_error_leaf = NodeUnlocked
                    THEN
                        vsleep (trTaskId_gg00, 0)
                    ELSE
                        old_error_leaf := NodeUnlocked
                    (*ENDIF*) 
                    END
                ELSE
                    IF  trError_gg00 = e_wait_for_lock_release
                    THEN
                        BEGIN
                        IF  NOT ignore_vwait
                        THEN
                            BEGIN
                            k53wait (t, sel.sfp_bd_mess_type, sel.sfp_bd_mess2_type);
                            IF  trError_gg00 = e_ok
                            THEN
                                BEGIN
                                (* PTS 1117878 UH 2002-10-17 *)
                                unlock_committed_read_lock :=
                                      hsCollisionTest_egg00 in file_id.fileHandling_gg00;
                                trError_gg00 := e_bd_leaf_unlocked;
                                END;
                            (*ENDIF*) 
                            END;
                        (*ENDIF*) 
                        CASE loop_mess2_type OF
                            mm_next   :
                                sel.sfp_bd_mess2_type := mm_first;
                            mm_direct :
                                sel.sfp_bd_mess2_type := mm_direct;
                            mm_prev   :
                                sel.sfp_bd_mess2_type := mm_last;
                            OTHERWISE
                            END;
                        (*ENDCASE*) 
                        END
                    ELSE
                        sel.sfp_bd_mess2_type := loop_mess2_type;
                    (*ENDIF*) 
                (*ENDIF*) 
                IF  unlock_committed_read_lock
                    AND
                    (granted_lock = lckRowShare_egg00)
                THEN
                    (* PTS 1117878 UH 2002-10-17 *)
                    BEGIN
                    aux_error    := trError_gg00;
                    trError_gg00 := e_ok;
                    unlock_committed_read_lock := false;
                    k53key_unlock2 (t, granted_lock, file_id.fileTabId_gg00,
                          RecKey, RecKeyLen);
                    trError_gg00 := aux_error;
                    END;
                (*ENDIF*) 
                END
            (*ENDIF*) 
        UNTIL
            ((trError_gg00 <> e_ok) OR (NOT unqualified) OR
            (sel.sfp_bd_mess2_type = mm_direct))
            AND
            (trError_gg00 <> e_bd_leaf_unlocked);
        (*ENDREPEAT*) 
        IF  cur_res_cnt < sel.sfp_m_result_cnt
        THEN
            sel.sfp_m_result_cnt := cur_res_cnt;
        (*ENDIF*) 
        IF  (trError_gg00 = e_buffer_limit) AND
            (sel.sfp_bd_mess2_type <> mm_direct)
        THEN
            trError_gg00 := e_ok;
        (*ENDIF*) 
        IF  trError_gg00 <> e_ok
        THEN
            b06illegal_root_access (current)
        (*ENDIF*) 
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
&ifdef TRACE
IF  (sel.sfp_bd_mess2_type = mm_last) OR (sel.sfp_bd_mess2_type =
    mm_prev)
THEN
    t01basis_error (bi, 'qual prev er', t.trError_gg00)
ELSE
    t01basis_error (bi, 'qual next er', t.trError_gg00);
(*ENDIF*) 
t01int4 (bi, 'new page cnt', t.trRteCommPtr_gg00^.file_record_cnt);
WITH sel DO
    BEGIN
    t01p2int4 (bi, 'sfp_m_res_cn', sfp_m_result_cnt
          ,        'sfp_m_res_le', sfp_m_result_len);
    t01int4   (bi, 'sfp_res_len ', sfp_result_length);
    t01name   (bi, 'sfp_m_result:     ');
    IF  sfp_result_length < 80
    THEN
        t01moveobj (bi, init_m_result_addr^, 1, sfp_result_length)
    ELSE
        t01moveobj (bi, init_m_result_addr^, 1, 80);
    (*ENDIF*) 
    END;
(*ENDWITH*) 
IF  (t.trError_gg00 = e_ok) AND (recbuf_ptr <> NIL)
THEN
    t01moveobj (bi, recbuf_ptr^, 1, 80);
&endif
(*ENDIF*) 
IF  g01vtrace.vtrAll_gg00 OR g01vtrace.vtrBdPrim_gg00
THEN
    BEGIN
    root_trace.bdrTrType_gg11 := bdtrRoot_egg11;
    root_trace.bdrError_gg11  := t.trError_gg00;
    b120InsertTrace (t, bd, trace_object, sizeof (root_trace), @root_trace)
    END;
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02u_init_unload (VAR t : tgg00_TransContext;
            VAR file_id : tgg00_FileId);
 
VAR
      fi : tbd_fileinfo;
 
BEGIN
&ifdef TRACE
t01name   (bi, '====> bd init unlo');
t01treeid (bi, 'treeid      ', file_id);
&endif
IF  b01downfilesystem
THEN
    t.trError_gg00 := e_shutdown
ELSE
    BEGIN
    t.trError_gg00 := e_ok;
    b17state_fdir (file_id.fileName_gg00, fi, ftsShared_egg00 in file_id.fileType_gg00,
          t);
    IF  t.trError_gg00 = e_ok
    THEN
        BEGIN
        b30fdir_to_treeid (fi, file_id);
        IF  (file_id.fileVersion_gg00.ci2_gg00 <> cgg_dummy_file_version)
            AND (fi.fi_vers <> file_id.fileVersion_gg00)
        THEN
            t.trError_gg00 := e_old_fileversion
        ELSE
            IF  f_bad in fi.fi_state
            THEN
                t.trError_gg00 := e_bad_file
            (*ENDIF*) 
        (*ENDIF*) 
        END;
    (*ENDIF*) 
    END;
(*ENDIF*) 
&ifdef TRACE
t01basis_error (bi, 'init unlo e ', t.trError_gg00);
&endif
END;
 
(*------------------------------*) 
 
PROCEDURE
      b02unload_table (VAR t : tgg00_TransContext;
            VAR tree_id      : tgg00_FileId;
            VAR pno          : tsp00_PageNo;
            VAR pno_x        : tsp00_PageNo;
            ret_buf_size     : tsp00_Int4;
            VAR ret_buf      : tsp00_MoveObj;
            VAR ret_buf_len  : tsp00_Int4);
 
VAR
      finished : boolean;
      nptr     : tbd_node_ptrs;
      current  : tbd_current_tree;
 
BEGIN
&ifdef TRACE
t01name   (bi, '====> bd load tab ');
t01treeid (bi, 'treeid      ', tree_id);
t01int4   (bi, 'pno         ', pno);
t01int4   (bi, 'pno_x       ', pno_x);
&endif
b30cinit_current (t, current);
IF  b01downfilesystem
THEN
    t.trError_gg00 := e_shutdown
ELSE
    WITH current, t DO
        BEGIN
        trError_gg00  := e_ok;
        curr_tree_id  := tree_id;
        nptr.np_ptr   := NIL;
        nptr.np_cbptr := NIL;
        ret_buf_len   := 0;
        finished      := false;
        IF  pno <> pno_x
        THEN
            trError_gg00 := e_invalid
        ELSE
            WHILE (trError_gg00 = e_ok) AND (NOT finished) DO
                BEGIN
                IF  ftsByteStr_egg00 in curr_tree_id.fileType_gg00
                THEN
                    b05save_quick (pno, nptr, current)
                ELSE
                    b30save_quick (pno, nptr, current);
                (*ENDIF*) 
                IF  (trError_gg00 = e_ok) AND (nptr.np_ptr <> NIL)
                THEN
                    BEGIN
                    g10mv1 ('VBD02 ',  24,    
                          sizeof (tbd_node), ret_buf_size,
                          nptr.np_ptr^, 1,
                          ret_buf, ret_buf_len + 1,
                          sizeof (tbd_node), trError_gg00);
                    ret_buf_len := ret_buf_len + sizeof (tbd_node);
                    END;
                (*ENDIF*) 
                finished := (ret_buf_len + sizeof (tbd_node)) > ret_buf_size;
                IF  (pno = NIL_PAGE_NO_GG00) AND (trError_gg00 = e_ok)
                THEN
                    trError_gg00 := e_no_next_record;
                (*ENDIF*) 
                END;
            (*ENDWHILE*) 
        (*ENDIF*) 
        pno_x := pno;
        IF  nptr.np_ptr <> NIL
        THEN
            b13r_release_node (nptr, current, lru_normal);
        (*ENDIF*) 
        END;
    (*ENDWITH*) 
(*ENDIF*) 
&ifdef TRACE
t01basis_error (bi, 'unload ta e ', t.trError_gg00);
&endif
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :       1130
*-PRETTY-*  lines of code :       3007        PRETTYX 3.10 
*-PRETTY-*  lines in file :       4187         1997-12-10 
.PA 
