/****************************************************************************
  module      : vkb33
  author      : JuergenA
  responsible : UweH
  special area: KB_index_handling
  see also    :
  description :
*****************************************************************************/
 
.tt 1 $SAP$LiveCache$VKB33$
.tt 3 $UweH$KB_index_handling$2000-07-21$
 
.nf
 
 
    ========== licence begin  GPL
    Copyright (c) 2000-2004 SAP AG
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end
 
.fo
 
Module  : KB_index_handling
 
Define  :
 
        PROCEDURE
              k33create_index (VAR m : tgg00_MessBlock);
 
        PROCEDURE
              k33inv_id (VAR part1 : tgg00_QualBuf;
                    VAR inv_id     : tgg00_FileId);
 
        PROCEDURE
              k33mult_inv_key (
                    VAR t         : tgg00_TransContext;
                    VAR prim_tree : tgg00_FileId;
                    VAR inv_tree  : tgg00_FileId;
                    init_inv_tree : boolean;
                    st_addr       : tgg00_StackListPtr;
                    rec_buf_ptr   : tgg00_RecPtr;
                    first_st      : integer;
                    last_st       : integer;
                    VAR inv_key   : tgg00_Lkey;
                    VAR bIsUndef  : boolean;
                    VAR move_err  : tgg00_BasisError);
 
        PROCEDURE
              k33p_create_index_participant (VAR m : tgg00_MessBlock);
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              KB_transaction : VKB53;
 
        PROCEDURE
              k53eot_excl_lock (VAR t : tgg00_TransContext;
                    VAR tree_id       : tgg00_FileId;
                    VAR k             : tgg00_Lkey;
                    wanted_mode       : tgg00_LockReqMode;
                    VAR GrantedMode   : tgg00_LockReqMode);
 
        PROCEDURE
              k53lock (VAR t         : tgg00_TransContext;
                    VAR lock_tabid   : tgg00_Surrogate;
                    VAR k            : tgg00_Lkey;
                    wanted_mode      : tgg00_LockReqMode;
                    wanted_state     : tgg00_LockReqState;
                    nowait           : boolean;
                    collision_test   : boolean;
                    VAR GrantedMode  : tgg00_LockReqMode);
 
      ------------------------------ 
 
        FROM
              KB_Logging : VKB560;
 
        PROCEDURE
              kb560StartSavepoint (VAR Trans : tgg00_TransContext;
                    MessType2 : tgg00_MessType2);
 
      ------------------------------ 
 
        FROM
              KB_InsDelUpd_interface : VKB611;
 
        PROCEDURE
              kb611IndexGetKey (
                    VAR TransContext      : tgg00_TransContext;
                    pStackList            : tgg00_StEntryAddr;
                    Entries               : tsp00_Int2;
                    VAR Rec               : tgg00_Rec           (*ptocConst*);
                    VAR InvDescId         : tsp00_Uint1;
                    VAR SecondaryKey      : tgg00_Lkey;
                    VAR allColumnsAreNull : boolean);
 
      ------------------------------ 
 
        FROM
              KB_file_table_handling : VKB64;
 
        PROCEDURE
              k64create_bd_file (VAR t : tgg00_TransContext;
                    VAR tree_id    : tgg00_FileId;
                    mess_type      : tgg00_MessType;
                    mess2_type     : tgg00_MessType2;
                    str_col_cnt    : tsp00_Int2);
 
      ------------------------------ 
 
        FROM
              KB_CreateDropFile_interface : VKB641;
 
        PROCEDURE
              kb641CreateIndex (
                    VAR TransContext : tgg00_TransContext;
                    VAR PrimFileId   : tgg00_FileId;
                    VAR InvFileId    : tgg00_FileId;
                    VAR StackDesc    : tgg00_StackDesc;
                    VAR IndexCounter : tgg00_IndexCounter);
 
      ------------------------------ 
 
        FROM
              filesysteminterface_1 : VBD01;
 
        VAR
              b01niltree_id : tgg00_FileId;
 
        PROCEDURE
              b01destroy_file (VAR t : tgg00_TransContext;
                    VAR file_id      : tgg00_FileId);
 
        PROCEDURE
              b01filestate (VAR t : tgg00_TransContext;
                    VAR file_id   : tgg00_FileId);
 
        PROCEDURE
              b01tcreate_file (VAR t : tgg00_TransContext;
                    VAR act_tree_id  : tgg00_FileId);
 
      ------------------------------ 
 
        FROM
              filesysteminterface_3 : VBD03;
 
        PROCEDURE
              bd03DiagnoseIndex (VAR t     : tgg00_TransContext;
                    VAR file_id         : tgg00_FileId;
                    VAR inv_id          : tgg00_FileId;
                    VAR temp_tree_id    : tgg00_FileId;
                    VAR b               : tgg00_Rec;
                    VAR prim_duplicates : tsp00_Int4;
                    VAR prim_missing    : tsp00_Int4);
 
        PROCEDURE
              b03create_index (VAR t  : tgg00_TransContext;
                    indexmode         : tgg00_IndexMode;
                    VAR file_id       : tgg00_FileId;
                    VAR inv_id        : tgg00_FileId;
                    VAR stack_desc    : tgg00_StackDesc;
                    VAR index_counter : tgg00_IndexCounter);
 
        PROCEDURE
              bd03ParticipantCreateIndex (
                    VAR Trans             : tgg00_TransContext;
                    VAR PrimFileId        : tgg00_FileId;
                    VAR InvFileId         : tgg00_FileId;
                    VAR StackDesc         : tgg00_StackDesc;
                    StartPrimKey          : tsp00_KeyPtr;
                    StopPrimKey           : tsp00_KeyPtr;
                    StartPrimKeyLen       : tsp00_Int4;
                    StopPrimKeyLen        : tsp00_Int4;
                    NumLeavesToScan       : tsp00_Int4;
                    AvgRecordsPerLeaf     : tsp00_Int4;
                    PrimQueuePno          : tsp00_PageNo;
                    SecQueuePno           : tsp00_PageNo;
                    bUseMemorySort        : boolean;
                    IndexMode             : tgg00_IndexMode;
                    VAR IndexCounter      : tgg00_IndexCounter;
                    VAR FirstLeafPno      : tsp00_PageNo;
                    VAR bEntriesExist     : boolean);
 
      ------------------------------ 
 
        FROM
              RTE-Extension-20 : VSP20;
 
        PROCEDURE
              s20ch4 (val    : tsp00_Int4;
                    VAR dest : tsp00_Buf;
                    di       : tsp00_Int4);
 
        FUNCTION
              s20or4b (VAR str : tsp00_Buf; si : tsp00_Int4) : tsp00_Int4;
 
      ------------------------------ 
 
        FROM
              PUT-Conversions : VSP41;
 
        PROCEDURE
              s41p4int (VAR buf : tsp00_Buf;
                    pos         : tsp00_Int4;
                    source      : tsp00_Int4;
                    VAR res     : tsp00_NumError);
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        FUNCTION
              s20ch4;
 
              tsp00_MoveObj tsp00_Buf
 
        FUNCTION
              s20or4b;
 
              tsp00_MoveObj tsp00_Buf
 
        PROCEDURE
              s41p4int;
 
              tsp00_MoveObj tsp00_Buf
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : JuergenA
.sp
.cp 3
Created : 1979-12-14
.sp
.cp 3
.sp
.cp 3
Release :      Date : 2000-11-28
.sp
***********************************************************
.sp
.cp 9
.fo
.oc _/1
Specification:
.sp
Procedure K33CREATE_INDEX
.sp
Depending on the message types the following inv file handling is done:
.sp
M_CREATE_INDEX/MM_NIL
.br
A new inv file is created and filled. To avoid the sys exclusive lock
and to allow the read access of the primary table by other transactions
the table is locked in share mode and a virtual index key is locked
in row exclusive mode.
.sp
M_CREATE_INDEX/MM_PARSE
.br
The table is locked in sys exclusive mode and
a new inv file is created via K64CREATE_TREE.
.sp
M_DIAGNOSE/MM_INDEX
.br
The table is locked in share and the already exiting index
is checked.
.sp 2;.cp 4
Procedure K33MULT_INV_KEY
.sp
Generates the key of a multiple inversion from the record and the
stack entries located between FIRST_ST and LAST_ST.
All but the last column have a fixed length (elen_var) and
UNDEF columns are filled with HEX '00'.  For ASCENDING, the last
column is truncated with the aid of the DEFINED byte and, for
DESCENDING, it is filled to the fixed length with the DEFINED byte.
A final UNDEF column is always represented simply as an UNDEF byte
with the length 1.
.sp 2;.cp 4
Procedure K33SINGLE_INV_KEY
.sp
Generates the inv key using the primary record and the
stack entry. For ASCENDING, the key is truncated with the aid of
the DEFINED byte and, for DESCENDING, it is filled with the
DEFINED byte to the fixed length (elen_var). An UNDEF column
is always represented simply as an UNDEF BYTE with the length 1.
.sp 2;.cp 5
Procedure KB33CHECK_INDEX
.sp
Checks the contents of the existing inv file and the result
(inv count, duplicate primary entries, missing primary entries)
to MB_PART1.
.sp 2;.cp 5
Procedure KB33NEW_INDEX
.sp
A log entry with the tableid and the inv stack entries is created and
forced to the log. Afterwards, the inv file is created and filled
via B03CREATE_INDEX. The numbers of inserted entries and the
number of undefined entries (not inserted) are assigned to MB_PART1.
.nf;.sp;.cp 4
create_index_logentry
+-------------------------------------+
| LG_CREATE_INDEX | inv stack entries |
+-------------------------------------+
.fo
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 7
.fo
.oc _/1
Description:
.sp
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 35
.nf
.oc _/1
.CM -lll-
Code    :
 
 
CONST
      c_collision_test = true;
      c_nowait         = true;
 
 
(*------------------------------*) 
 
PROCEDURE
      k33create_index (VAR m : tgg00_MessBlock);
 
VAR
      dummy_granted  : tgg00_LockReqMode;
      wanted_lock    : tgg00_LockReqMode;
      inv_id         : tgg00_FileId;
      index_lock_key : tgg00_Lkey;
 
BEGIN
m.mb_trns^.trError_gg00 := e_ok;
k33inv_id (m.mb_qual^, inv_id);
IF  m.mb_type = m_create_index
THEN
    BEGIN
    IF  m.mb_type2 = mm_parse
    THEN
        wanted_lock := lckSysExcl_egg00
    ELSE
        BEGIN
        index_lock_key.keyVal_gg00 [1] := chr (INDEX_LOCK_BYTE_KB00);
        index_lock_key.keyLen_gg00     := 1;
        wanted_lock                    := lckRowExcl_egg00
        END;
    (*ENDIF*) 
    k53eot_excl_lock (m.mb_trns^, inv_id, index_lock_key, wanted_lock, dummy_granted)
    END;
(*ENDIF*) 
IF  (m.mb_trns^.trError_gg00 = e_ok) AND
    (m.mb_type2 <> mm_parse  )
THEN
    k53lock (m.mb_trns^, inv_id.fileTabId_gg00, index_lock_key,
          lckTabShare_egg00, [ ], NOT c_nowait, NOT c_collision_test, dummy_granted);
(*ENDIF*) 
IF  (m.mb_trns^.trError_gg00 = e_ok)
THEN
    BEGIN
    b01filestate (m.mb_trns^, m.mb_qual^.mtree);
    IF  m.mb_trns^.trError_gg00 = e_file_read_only
    THEN
        m.mb_trns^.trError_gg00 := e_ok
    (*ENDIF*) 
    END;
(*ENDIF*) 
IF  m.mb_trns^.trError_gg00 = e_ok
THEN
    BEGIN
    IF  (m.mb_type  = m_create_index) AND
        (m.mb_type2 = mm_nil        )
    THEN
        kb33new_index (m, inv_id)
    ELSE
        IF  (m.mb_type  = m_create_index) AND
            (m.mb_type2 = mm_parse)
        THEN
            k64create_bd_file (m.mb_trns^, inv_id, m_create_table, mm_nil, 0)
        ELSE
            IF  (m.mb_type  = m_diagnose) AND
                (m.mb_type2 = mm_index  )
            THEN
                kb33check_index (m, inv_id)
            ELSE
                m.mb_trns^.trError_gg00 := e_not_implemented
            (*ENDIF*) 
        (*ENDIF*) 
    (*ENDIF*) 
    END
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      k33inv_id (VAR part1 : tgg00_QualBuf;
            VAR inv_id     : tgg00_FileId);
 
BEGIN
inv_id                    := part1.mtree;
inv_id.fileLeafNodes_gg00 := cgg_nil_leafnodes;
inv_id.fileRoot_gg00      := NIL_PAGE_NO_GG00;
inv_id.fileRootCheck_gg00 := ROOT_CHECK_GG00; (* PTS 1105022 TS 2000-01-03 *)
inv_id.fileBdUse_gg00     := [ ];
inv_id.fileVersion_gg00.ci2_gg00 := cgg_dummy_file_version;
inv_id.fileType_gg00      := inv_id.fileType_gg00 - [ftsDynamic_egg00];
inv_id.fileTfn_gg00       := tfnMulti_egg00;
inv_id.fileTfnNo_gg00 [1] := part1.mst_addr^[part1.mmult_pos].ecol_tab [1];
END;
 
(*------------------------------*) 
 
PROCEDURE
      k33mult_inv_key (
            VAR t         : tgg00_TransContext;
            VAR prim_tree : tgg00_FileId;
            VAR inv_tree  : tgg00_FileId;
            init_inv_tree : boolean;
            st_addr       : tgg00_StackListPtr;
            rec_buf_ptr   : tgg00_RecPtr;
            first_st      : integer;
            last_st       : integer;
            VAR inv_key   : tgg00_Lkey;
            VAR bIsUndef  : boolean;
            VAR move_err  : tgg00_BasisError);
 
VAR
      InvDescId : tsp00_Uint1;
 
BEGIN
kb611IndexGetKey (t,
      @st_addr^[first_st],
      last_st - first_st + 1,
      rec_buf_ptr^,
      InvDescId,
      inv_key,
      bIsUndef); (* PTS 1121337 UH 2003-03-27 *)
;
IF  init_inv_tree
THEN
    BEGIN
    inv_tree                    := prim_tree;
    inv_tree.fileRoot_gg00      := NIL_PAGE_NO_GG00;
    inv_tree.fileBdUse_gg00     := [ ];
    inv_tree.fileTfnNo_gg00 [1] := chr (InvDescId);
    inv_tree.fileTfn_gg00       := tfnMulti_egg00;
    inv_tree.fileTabId_gg00     := prim_tree.fileTabId_gg00;
    inv_tree.fileVersion_gg00.ci2_gg00 := cgg_dummy_file_version
    END
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      k33p_create_index_participant (VAR m : tgg00_MessBlock);
 
TYPE
 
      t_UnivIndexMode = RECORD
            CASE integer OF
                1:
                    (c : char);
                2:
                    (m : tgg00_IndexMode);
                END;
            (*ENDCASE*) 
 
 
VAR
      bEntriesExist     : boolean;
      bUseMemorySort    : boolean;
      IndexMode         : t_UnivIndexMode;
      AvgRecordsPerLeaf : tsp00_Int4;
      Pos               : tsp00_Int4;
      NumLeavesToScan   : tsp00_Int4;
      StartPrimKeyLen   : tsp00_Int4;
      StopPrimKeyLen    : tsp00_Int4;
      FirstLeafPno      : tsp00_PageNo;
      PrimQueuePno      : tsp00_PageNo;
      SecQueuePno       : tsp00_PageNo;
      IndexCounter      : tgg00_IndexCounter;
      pStartPrimKey     : tsp00_KeyPtr;
      pStopPrimKey      : tsp00_KeyPtr;
      pInvFileId        : tgg00_FileIdPtr;
      pPrimFileId       : tgg00_FileIdPtr;
      pStackDesc        : ^tgg00_StackDesc;
 
BEGIN
WITH m DO
    BEGIN
    mb_trns^.trError_gg00 := e_ok;
    (* *)
    IndexCounter.idc_prim_leafnodes := 0;
    IndexCounter.idc_sec_leafnodes  := 0;
    IndexCounter.idc_prim_keycount  := 0;
    IndexCounter.idc_sec_keycount   := 0;
    IndexCounter.idc_nullcount      := 0;
    (* *)
    Pos               := 0;
    PrimQueuePno      := s20or4b (mb_data^.mbp_4kbuf, Pos + 1);
    Pos               := Pos + sizeof (PrimQueuePno);
    SecQueuePno       := s20or4b (mb_data^.mbp_4kbuf, Pos + 1);
    Pos               := Pos + sizeof (SecQueuePno);
    NumLeavesToScan   := s20or4b (mb_data^.mbp_4kbuf, Pos + 1);
    Pos               := Pos + sizeof (NumLeavesToScan);
    AvgRecordsPerLeaf := s20or4b (mb_data^.mbp_4kbuf, Pos + 1);
    Pos               := Pos + sizeof (AvgRecordsPerLeaf);
    StartPrimKeyLen   := s20or4b (mb_data^.mbp_4kbuf, Pos + 1);
    Pos               := Pos + sizeof (StartPrimKeyLen);
    StopPrimKeyLen    := s20or4b (mb_data^.mbp_4kbuf, Pos + 1);
    Pos               := Pos + sizeof (StopPrimKeyLen);
    IndexMode.c       := mb_data^.mbp_4kbuf [Pos + 1];
    Pos               := Pos + sizeof (IndexMode);
    bUseMemorySort    := mb_data^.mbp_4kbuf[Pos + 1] = chr(ord(true));
    Pos               := Pos + sizeof (bUseMemorySort) + sizeof (tsp00_Int2) + sizeof (tsp00_Int4);
    (* *)
    (* Set Pointer on StartKey *)
    (* *)
    pStartPrimKey :=  @mb_data^.mbp_4kbuf [Pos + 1];
    Pos           := Pos + StartPrimKeyLen;
    (* *)
    (* Set Pointer on StopKey *)
    (* *)
    pStopPrimKey :=  @mb_data^.mbp_4kbuf [Pos + 1];
    Pos          := Pos + StopPrimKeyLen;
    (* *)
    (* Set Pointer on PrimFileId *)
    (* *)
    Pos         := 0;
    pPrimFileId :=  @mb_qual^.buf [Pos + 1];
    Pos         := Pos + sizeof (pPrimFileId^);
    (* *)
    (* Set Pointer on StackDesc *)
    (* *)
    pStackDesc :=  @mb_qual^.buf [Pos + 1];
    Pos        := Pos + sizeof (pStackDesc^);
    (* *)
    (* Set Pointer on InvFileId *)
    (* *)
    pInvFileId :=  @mb_qual^.buf [Pos + 1];
    Pos        := Pos + sizeof (pInvFileId^);
    (* *)
    IF  mb_trns^.trError_gg00 = e_ok
    THEN
        bd03ParticipantCreateIndex (mb_trns^,
              pPrimFileId^, pInvFileId^, pStackDesc^,
              pStartPrimKey, pStopPrimKey,
              StartPrimKeyLen, StopPrimKeyLen,
              NumLeavesToScan, AvgRecordsPerLeaf,
              PrimQueuePno, SecQueuePno, bUseMemorySort,
              IndexMode.m, IndexCounter, FirstLeafPno, bEntriesExist);
    (*ENDIF*) 
    IF  mb_trns^.trError_gg00 = e_ok
    THEN
        BEGIN
        mb_type                          := m_return_result;
        mb_type2                         := mm_nil;
        mb_struct                        := mbs_buf;
        mb_qual_len                      := 0;
        mb_data_len                      := sizeof (IndexCounter);
        mb_data^.mbp_index_cnt           := IndexCounter;
        mb_data_len                      := mb_data_len + 1;
        s20ch4 (FirstLeafPno, mb_data^.mbp_4kbuf, mb_data_len);
        mb_data_len                      := mb_data_len + sizeof (FirstLeafPno);
        mb_data^.mbp_4kbuf [mb_data_len] := chr (bEntriesExist)
        END
    ELSE
        BEGIN
        mb_type     := m_return_error;
        mb_type2    := mm_nil;
        mb_data_len := 0;
        mb_qual_len := 0
        END
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      kb33check_index (VAR m : tgg00_MessBlock;
            VAR inv_id       : tgg00_FileId);
 
VAR
      aux_error       : tgg00_BasisError;
      dummy_num_err   : tsp00_NumError;
      pos             : integer;
      prim_duplicates : tsp00_Int4;
      prim_missing    : tsp00_Int4;
      temp_id         : tgg00_FileId;
      index_counter   : tgg00_IndexCounter;
 
BEGIN
inv_id.fileBdUse_gg00 := [ ];
m.mb_qual^.mst_addr   := m.mb_st;
m.mb_qual^.mst_max    := m.mb_st_max;
WITH index_counter DO
    BEGIN
    idc_prim_keycount  := 0;
    idc_nullcount      := 0;
    idc_sec_keycount   := 0;
    idc_prim_leafnodes := 1;
    idc_sec_leafnodes  := 1
    END;
(*ENDWITH*) 
b03create_index (m.mb_trns^, test_index, m.mb_qual^.mtree, inv_id,
      m.mb_qual^.mstack_desc, index_counter);
IF  m.mb_trns^.trError_gg00 = e_ok
THEN
    BEGIN
    temp_id                    := b01niltree_id;
    temp_id.fileTfn_gg00       := tfnTemp_egg00;
    temp_id.fileTfnNo_gg00 [1] := chr(1);
    temp_id.fileSession_gg00   := m.mb_trns^.trSessionId_gg00;
    b01tcreate_file (m.mb_trns^, temp_id)
    END;
(*ENDIF*) 
IF  m.mb_trns^.trError_gg00 = e_ok
THEN
    BEGIN
    bd03DiagnoseIndex (m.mb_trns^, m.mb_qual^.mtree, inv_id,
          temp_id, m.mb_data^.mbp_rec, prim_duplicates, prim_missing);
    IF  m.mb_trns^.trError_gg00 = e_ok
    THEN
        BEGIN
        m.mb_type     := m_return_result;
        m.mb_type2    := mm_nil;
        m.mb_struct   := mbs_buf;
        m.mb_qual_len := 3 * RESNUM_MXSP00;
        m.mb_data_len := 0;
        pos           := 1;
        m.mb_qual^.buf [pos] := csp_defined_byte;
        s41p4int (m.mb_qual^.buf, pos+1,
              index_counter.idc_prim_keycount, dummy_num_err);
        pos := pos + RESNUM_MXSP00;
        m.mb_qual^.buf [pos] := csp_defined_byte;
        s41p4int (m.mb_qual^.buf, pos+1, prim_duplicates,
              dummy_num_err);
        pos := pos + RESNUM_MXSP00;
        m.mb_qual^.buf [pos] := csp_defined_byte;
        s41p4int (m.mb_qual^.buf, pos+1, prim_missing,
              dummy_num_err)
        END;
    (*ENDIF*) 
    aux_error               := m.mb_trns^.trError_gg00;
    m.mb_trns^.trError_gg00 := e_ok;
    b01destroy_file (m.mb_trns^, temp_id);
    IF  m.mb_trns^.trError_gg00 = e_ok
    THEN
        m.mb_trns^.trError_gg00 := aux_error
    (*ENDIF*) 
    END
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      kb33new_index (VAR m : tgg00_MessBlock;
            VAR inv_id     : tgg00_FileId);
 
VAR
      index_counter : tgg00_IndexCounter;
 
BEGIN
m.mb_trns^.trError_gg00 := e_ok;
inv_id.fileBdUse_gg00   := [ ];
m.mb_qual^.mst_addr     := m.mb_st;
m.mb_qual^.mst_max      := m.mb_st_max;
IF  m.mb_trns^.trError_gg00 = e_ok
THEN
    kb641CreateIndex (m.mb_trns^, m.mb_qual^.mtree,
          inv_id, m.mb_qual^.mstack_desc, index_counter);
(*ENDIF*) 
IF  m.mb_trns^.trError_gg00 = e_ok
THEN
    BEGIN
    WITH m.mb_data^.mbp_sample, index_counter DO
        BEGIN
        prim_key_cnt   := idc_prim_keycount;
        null_value_cnt := idc_nullcount;
        sec_key_cnt    := idc_sec_keycount;
        leafnodes      := idc_prim_leafnodes;
        indexnodes     := idc_sec_leafnodes
        END;
    (*ENDWITH*) 
    m.mb_type      := m_return_result;
    m.mb_type2     := mm_nil;
    m.mb_struct    := mbs_buf;
    m.mb_qual_len  := 0;
    m.mb_data_len  := sizeof (m.mb_data^.mbp_sample);
    IF  m.mb_data^.mbp_sample.prim_key_cnt > 0
    THEN
        kb560StartSavepoint (m.mb_trns^, mm_index);
    (*ENDIF*) 
    END
(*ENDIF*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
.PA 
