.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$VAK91$
.tt 2 $$$
.TT 3 $ElkeZ$Main-Procedure$2001-03-16$
***********************************************************
.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  : Main-Procedure
=========
.sp
Purpose : This module contains the main procedure of a
          SQL-DB process
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              a91mainprogram;
 
        PROCEDURE
              a91mainprogam_with_allocator (VAR TransContext : tgg00_TransContext);
 
.CM *-END-* define --------------------------------------
***********************************************************
 
Use     :
 
        FROM
              Scanner : VAK01;
 
        VAR
              a01_il_b_identifier   : tsp_knl_identifier;
 
        PROCEDURE
              a01_parser_init;
 
      ------------------------------ 
 
        FROM
              Systeminfo_cache : VAK10;
 
        PROCEDURE
              a10ak_cache_init;
 
      ------------------------------ 
 
        FROM
              AKDump : VAK102;
 
        FUNCTION
              a102akdump (VAR acv : tak_all_command_glob) : boolean;
 
      ------------------------------ 
 
        FROM
              AK_dialog_tools : VAK260;
 
        PROCEDURE
              a260init;
 
      ------------------------------ 
 
        FROM
              Catalog_Migration_2 : VAK362;
 
        VAR
              a362in_migration : boolean; (* PTS 1117498 M.Ki. *)
 
      ------------------------------ 
 
        FROM
              AK_universal_show_tools : VAK40;
 
        PROCEDURE
              a40glob_init;
 
      ------------------------------ 
 
        FROM
              AK_show_syntax : VAK41;
 
        PROCEDURE
              a41glob_init;
 
      ------------------------------ 
 
        FROM
              AK_Connect : VAK51;
 
        PROCEDURE
              a51init_cache_sizes;
 
      ------------------------------ 
 
        FROM
              DML_Help_Procedures : VAK54;
 
        PROCEDURE
              a54_init;
 
      ------------------------------ 
 
        FROM
              Execute_factor_constants : VAK642;
 
        PROCEDURE
              a642colinfo_init;
 
      ------------------------------ 
 
        FROM
              Part2_Select_Expression : VAK67;
 
        PROCEDURE
              a67_init_strat_texts;
 
      ------------------------------ 
 
        FROM
              Build_Strategy_2 : VAK71;
 
        PROCEDURE
              a71glob_init_accesspath_info;
 
      ------------------------------ 
 
        FROM
              Build_Strategy_Decision : VAK720;
 
        PROCEDURE
              a720glob_init_eval_stat;
 
      ------------------------------ 
 
        FROM
              Deal-With-User-Commands : VAK92;
 
        PROCEDURE
              a92next_pcount (VAR acv : tak_all_command_glob;
                    VAR parsk : tak_parskey);
 
      ------------------------------ 
 
        FROM
              DBS_Commands : VAK93;
 
        PROCEDURE
              a93_user_commands (
                    VAR acv        : tak_all_command_glob;
                    VAR alloc_ok   : boolean;
                    VAR do_release : boolean);
 
      ------------------------------ 
 
        FROM
              Utilityprocess : VAK94;
 
        VAR
              a94mode : tgg_usemode;
 
        PROCEDURE
              a94_implicit_commands (
                    VAR acv         : tak_all_command_glob;
                    utility_startup : tsp1_utility_startup);
 
        PROCEDURE
              a94_service_commands (
                    VAR acv      : tak_all_command_glob;
                    VAR alloc_ok : boolean);
 
      ------------------------------ 
 
        FROM
              Timeoutprocess : VAK95;
 
        PROCEDURE
              a95_timeout_process (VAR t : tgg00_TransContext);
 
      ------------------------------ 
 
        FROM
              Event-Task : VAK96;
 
        PROCEDURE
              a96eventtask (VAR t : tgg00_TransContext);
&       ifdef SLOW
 
      ------------------------------ 
 
        FROM
              Syntax-Tree-Printer : VAK99;
 
        PROCEDURE
              a99init;
&       endif
 
      ------------------------------ 
 
        FROM
              KB_functions         : VKB05;
 
        PROCEDURE
              k05init;
 
      ------------------------------ 
 
        FROM
              KB_get : vkb71;
 
        PROCEDURE
              k71init;
 
      ------------------------------ 
 
        FROM
              KB_headmaster : VKB38;
 
        PROCEDURE
              k38allocate (
                    pid        : tsp00_TaskId;
                    VAR b_err  : tgg00_BasisError);
 
      ------------------------------ 
 
        FROM
              KB_Logging : VKB560;
 
        PROCEDURE
              kb560AllocateArchiveLogManager (TaskId : tsp00_TaskId);
 
        PROCEDURE
              kb560LogWriter (TaskId : tsp00_TaskId);
 
      ------------------------------ 
 
        FROM
              KB_restart_record : VKB57;
 
        PROCEDURE
              k57allocate (VAR t : tgg00_TransContext);
 
      ------------------------------ 
 
        FROM
              KB_sender_receiver : VKB90;
 
        FUNCTION
              k90all_server_ready (pid : tsp00_TaskId) : boolean;
 
        PROCEDURE
              k90allocate_netserver (VAR t : tgg00_TransContext);
 
      ------------------------------ 
 
        FROM
              KB_server_task : VKB92;
 
        PROCEDURE
              k92server_process (VAR t : tgg00_TransContext);
 
      ------------------------------ 
 
        FROM
              filesysteminterface_1 : VBD01;
 
        VAR
              b01niltree_id : tgg00_FileId;
 
        PROCEDURE
              b01setto_zero_full_and_null;
&       ifdef TRACE
 
      ------------------------------ 
 
        FROM
              error_text_handling : VBD06;
 
        VAR
              b06check_rec : boolean;
&       endif
 
      ------------------------------ 
 
        FROM
              pagestore : vbd10;
 
        PROCEDURE
              bd10CreateConverterSingleton;
 
      ------------------------------ 
 
        FROM
              object_garbage_collection : VBD91;
 
        PROCEDURE
              bd91InitOMSGarbageCollection;
 
        PROCEDURE
              bd91StartOMSGarbageCollector (VAR Trans : tgg00_TransContext);
 
      ------------------------------ 
 
        FROM
              Trace : VBD120;
 
        PROCEDURE
              b120CreateTrace( TaskId : tsp00_TaskId );
 
        PROCEDURE
              b120TraceWriter( askId : tsp00_TaskId );
 
      ------------------------------ 
 
        FROM
              IndexMemoryManagementUnit : VBD499;
 
        PROCEDURE
              bd499InitIndexMemory (VAR Trans : tgg00_TransContext);
 
      ------------------------------ 
 
        FROM
              BD_Wrapper : VBD999;
 
        PROCEDURE
              bd999CreatePagerController;
 
        PROCEDURE
              bd999CreatePagerWriter (VAR t : tgg00_TransContext);
 
        PROCEDURE
              bd999CreateFrameControl;
 
        PROCEDURE
              bd999CreateIOManager( TaskId : tsp00_TaskId );
 
      ------------------------------ 
 
        FROM
              RTE_kernel : VEN101;
 
        PROCEDURE
              vbegexcl (
                    pid     : tsp_process_id;
                    region  : tsp_region_id);
 
        PROCEDURE
              vconnect (
                    pid                : tsp_process_id;
                    VAR net_packet_len : tsp_int4;
                    VAR sql_comm_err   : tsp1_comm_error);
 
        PROCEDURE
              vdcom_init_sink (VAR sink_info : tsp_dcom_init_sink_parms);
 
        PROCEDURE
              vendexcl (
                    pid     : tsp_process_id;
                    region  : tsp_region_id);
 
        PROCEDURE
              vfinish;
 
        PROCEDURE
              vgetuktid (VAR uktId : tsp00_Int4);
 
        PROCEDURE
              vinit (
                    VAR rte_comm : tsp_rte_comm_addr;
                    len : tsp_int2);
 
        PROCEDURE
              vinitok;
 
        PROCEDURE
              vptype (
                    pid           : tsp_process_id;
                    VAR proc_type : tsp2_process_type);
 
        PROCEDURE
              vrelease (pid : tsp_process_id);
 
        PROCEDURE
              vsleep (
                    pid   : tsp_process_id;
                    limit : tsp_int2);
 
        FUNCTION
              vutil_startup : tsp1_utility_startup;
 
        PROCEDURE
              vversion (
                    VAR kernelversion  : tsp_version;
                    VAR runtimeversion : tsp_version);
 
        PROCEDURE
              vinit_akdump_ptr(
                    acv_pointer : tsp00_MoveObjPtr;
                    ak_dump_proc: tsp00_MoveObjPtr );
 
      ------------------------------ 
 
        FROM
              Configuration_Parameter : VGG01;
 
        VAR
              g01code        : tgg_code_globals;
              g01pid         : tgg_pid_globals;
              g01timeout     : tgg00_TimeoutGlobals;
 
        PROCEDURE
              g01abort (
                    msg_no     : tsp_int4;
                    msg_label  : tsp_c8;
                    msg_text   : tsp_c24;
                    bad_value  : tsp_int4);
 
        PROCEDURE
              g01default_configuration;
 
        PROCEDURE
              g01inittabid;
 
        FUNCTION
              g01kb_work_st_size : tsp_int4;
 
        FUNCTION
              g01kb_workbuf_size : tsp_int4;
 
        FUNCTION
              g01kbfunction_tasks : tsp_int4;
 
        FUNCTION
              g01mb_data_size : tsp_int4;
 
        FUNCTION
              g01mb_qual_size : tsp_int4;
 
        FUNCTION
              g01mb_stack_size : tsp_int4;
 
        PROCEDURE
              g01transid_init (VAR t : tgg00_TransContext);
 
      ------------------------------ 
 
        FROM
              Codetransformation_and_Coding : VGG02;
 
        PROCEDURE
              g02inittranslate_tables;
 
      ------------------------------ 
 
        FROM
              Check-Date-Time : VGG03;
 
        PROCEDURE
              g03init;
 
      ------------------------------ 
 
        FROM
              GG_cpp_auxiliary_functions : VGG06;
 
        PROCEDURE
              gg06BuildTaskSession (
                    VAR Session : tgg91_SessionNo;
                    TaskType : tsp2_process_type);
 
      ------------------------------ 
 
        FROM
              Regions_and_Longwaits : VGG08;
 
        VAR
              g08config : tsp00_RegionId;
 
        PROCEDURE
              g08region_ids;
 
      ------------------------------ 
 
        FROM
              Kernel-Version : VGG11;
 
        PROCEDURE
              g11kernel_version  (VAR vers : tsp_version);
 
      ------------------------------ 
 
        FROM
              GG_allocator_interface : VGG941;
 
        FUNCTION
              gg941Allocate(VAR TransContext : tgg00_TransContext;
                    wantedBytes : integer) : tsp00_Addr;
 
        PROCEDURE
              gg941CreateAllocatorAndCallMainprog (VAR TransContext : tgg00_TransContext);
 
        PROCEDURE
              gg941Deallocate(VAR TransContext : tgg00_TransContext;
                    VAR p : tsp00_Addr);
 
        PROCEDURE
              Kernel_InitTrace;
 
      ------------------------------ 
 
        FROM
              GG_TaskWaitStack_Interface : VGG943;
 
        PROCEDURE
              gg943AllocateTaskWaitStacks (
                    CallingTaskId : tsp00_TaskId;
                    MaxTask       : tsp00_Int4);
 
      ------------------------------ 
 
        FROM
              RTE-Extension-10 : VSP10;
 
        PROCEDURE
              s10fil (
                    size     : tsp_int4;
                    VAR m    : tak_all_command_glob;
                    pos      : tsp_int4;
                    len      : tsp_int4;
                    fillchar : char);
 
      ------------------------------ 
 
        FROM
              link_check_msg : VSP99;
 
        FUNCTION
              s99check_copyright (
                    cpr1  : tsp_copyright;
                    cpr2  : tsp_copyright) : boolean;
&       ifdef SLOW
 
      ------------------------------ 
 
        FROM
              Test_Procedures : VTA01;
 
        PROCEDURE
              t01sinit;
&       endif
 
.CM *-END-* use -----------------------------------------
***********************************************************
 
Synonym :
 
        PROCEDURE
              gg06BuildTaskSession;
 
              tsp00_Uint1 tsp2_process_type
 
        PROCEDURE
              s10fil;
 
              tsp_moveobj tak_all_command_glob;
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : ElkeZ
.sp
.cp 3
Created : 1983-07-29
.sp
.cp 3
Version : 2002-08-30
.sp
.cp 3
Release :      Date : 2000-11-08
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
 
 
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
SET_COPYRIGHT
------------------------
 
This is the procedure that has been included in the main program only so that a
copyright entry is contained at the beginning in the executable module.
 
A91MAINPROGRAM
------------------------
 
This is the main procedure of the kernel of SQL-DB.
It is called each time a kernel process is started.
Likewise it is
also used if, after the stack relocation of a user process (e.g. VAX), work is
to be continued after the VRECEIVE.
The RTE procedure VRELOCAT is called, which makes an entry in the pointer
(relocate_info) to a record containing information for the relocation. This
process-specific record contains the information as to whether A91MAINPROGRAM
was called because of the new start of a process or after a stack relocation.
If the stack of the process if relocated, only the ACV_POINTER has the
correct entry in it; all other pointers (Cache, Cachedirectory, Cancel_Byte)
must be altered in A10_STACK_SWAP by the relocation value that has been passed.
Then, it is possible to continue with the processing of user commands
(relocation can happen only to normal user processes).
If, on the other hand, it is the first call of A91MAINPROGRAM,
NOT_RELOCATED_MAIN_PROGRAM is used.
 
NOT_RELOCATED_MAIN_PROGRAM
------------------------
 
The RTE procedure for initialization (VINIT) is called, which, in CANCEL (part
of the Trans_no), returns the address of the boolean to_cancel and stores it
itself. This boolean is set to true by the operator-console command Cancel and
is frequently interrogated in the kernel, so that, if necessary, the processing
of commands can be quickly stopped if so desired by the user.
The Trans_No required by the user processes and by the service process is
completely initialized (the procid is needed for the VPTYPE) and it is asked
from the run-time environment what sort of role this process has to play:
Timeout-, Bufwriter-, Logwriter-, Service- or normal user process (VPTYPE).
If it is a command-processing process (service- or user process),
initializations are performed in RUN_USER_PROCESS, otherwise in
RUN_NON_USER_PROCESS.
 
RUN_USER_PROCESS
------------------------
 
The process-specific variable ACV, which exists through all commands, and the
CACHE are anchored here.
After A91MAINPROGRAM has been first called, the ACV_POINTER must be
initialized with the current address of the ACV. It must have been recorded in
the process that no user has yet connected (current_auth_id); a
default timeout is set, and the cache is initialized.
If it is the service process, it is given an invalid Cancel_Byte, since the
service process must not be cancelled and this is the simplest method of
preventing that. In A94_SERVICE_COMMANDS, the service process waits in an
endless loop for a command, executes it, waits for the next one etc.
If it is a user process, A93_USER_COMMANDS is called in a loop; it executes
a command or is interrupted by the stack relocation and has to be re-started by
A91MAINPROGRAM.
 
RUN_NON_USER_PROCESS
------------------------
 
The 4 different types of processes that do not process commands (2 Logwriter-,
1 Bufwriter-, 1 Timeout processes) are subdivided here and, in VKB55
(Logwriter), VBD999/Pager_Controller ( NOCCPRINT (Bufwriter) and
VAK95 (Timeout), call procedures that
consist of endless loops within which the process is continually re-awoken,
does something and is then sent to sleep again by run-time-environment
mechanisms.
Worthy of particular emphasis is the timeout process, which is the first
process to be created and which starts all initializations that are necessary
for the entire kernel of the SQL-DB system. Only after VINITOK has been called
are other processes also allowed to continue and to process commands.
 
.CM *-END-* description ---------------------------------
***********************************************************
.CM -lll-
Code    :
 
 
CONST
      c_free_packets          = true;
      c_without_communication = true;
 
 
(*------------------------------*) 
 
PROCEDURE
      ak91set_copyright;
 
VAR
      cpr1, cpr2 : tsp_copyright;
 
BEGIN
cpr1 := csp_cop1;
cpr2 := csp_cop2;
IF  NOT s99check_copyright (cpr1, cpr2)
THEN
    g01abort (csp3_a91_no_copyright, csp3_n_restart,
          'COPYRIGHT CHECK FAILED  ', 0)
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak91connect (
            VAR acv               : tak_all_command_glob;
            without_communication : boolean;
            VAR alloc_ok          : boolean;
            VAR sql_comm_err : tsp1_comm_error);
 
VAR
      _net_packet_size : tsp_int4;
      _aux_addr        : tsp00_Addr;
 
BEGIN
WITH acv.a_transinf.tri_trans DO
    BEGIN
    (* PTS 1117012 E.Z. *)
    alloc_ok     := true;
    sql_comm_err := sp1ce_ok;
    IF  without_communication
    THEN
        BEGIN
        (* the utility session will not be supplied with a packet,    *)
        (* if an implicit RESTART or SHUTDOWN is requested by the RTE *)
        _aux_addr := gg941Allocate (acv.a_transinf.tri_trans, 4 * sizeof (tsp_buf));
        IF  _aux_addr = NIL
        THEN
            alloc_ok := false
        ELSE
            BEGIN
            acv.a_in_packet := @_aux_addr^;
            WITH acv.a_in_packet^, sp1_header DO
                sp1h_varpart_size := 4 * sizeof (tsp_buf) - sizeof (sp1_header)
            (*ENDWITH*) 
            END
        (*ENDIF*) 
        END
    ELSE
        vconnect (trTaskId_gg00, _net_packet_size, sql_comm_err);
    (*ENDIF*) 
    IF  sql_comm_err = sp1ce_ok
    THEN
        BEGIN
        IF  alloc_ok AND (acv.a_mb_data_addr = NIL)
        THEN
            BEGIN
            acv.a_mb_data_size := g01mb_data_size;
            _aux_addr := gg941Allocate (acv.a_transinf.tri_trans, acv.a_mb_data_size);
            IF  _aux_addr = NIL
            THEN
                alloc_ok := false
            ELSE
                acv.a_mb_data_addr := @_aux_addr^
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  alloc_ok
        THEN
            BEGIN
            IF  acv.a_mb_qual_addr = NIL
            THEN
                BEGIN
                acv.a_mb_qual_size := g01mb_qual_size;
                _aux_addr := gg941Allocate (acv.a_transinf.tri_trans,
                      acv.a_mb_qual_size);
                IF  _aux_addr = NIL
                THEN
                    alloc_ok := false
                ELSE
                    acv.a_mb_qual_addr := @_aux_addr^
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            IF  alloc_ok
            THEN
                BEGIN
                IF  acv.a_stack_addr = NIL
                THEN
                    BEGIN
                    acv.a_stack_size := g01mb_stack_size;
                    _aux_addr := gg941Allocate (acv.a_transinf.tri_trans,
                          acv.a_stack_size);
                    IF  _aux_addr = NIL
                    THEN
                        alloc_ok := false
                    ELSE
                        acv.a_stack_addr := @_aux_addr^
                    (*ENDIF*) 
                    END;
                (*ENDIF*) 
                IF  alloc_ok
                THEN
                    BEGIN
                    IF  acv.a_work_st_addr = NIL
                    THEN
                        BEGIN
                        acv.a_work_st_max := g01kb_work_st_size DIV
                              sizeof (tgg_stack_entry);
                        _aux_addr := gg941Allocate (acv.a_transinf.tri_trans,
                              g01kb_work_st_size);
                        IF  _aux_addr = NIL
                        THEN
                            alloc_ok := false
                        ELSE
                            acv.a_work_st_addr := @_aux_addr^
                        (*ENDIF*) 
                        END;
                    (*ENDIF*) 
                    IF  alloc_ok
                    THEN
                        BEGIN
                        IF  acv.a_work_buf_addr = NIL
                        THEN
                            BEGIN
                            acv.a_work_buf_size := g01kb_workbuf_size;
                            _aux_addr := gg941Allocate (acv.a_transinf.tri_trans,
                                  acv.a_work_buf_size);
                            IF  _aux_addr = NIL
                            THEN
                                acv.a_work_buf_size := 0
                            ELSE
                                acv.a_work_buf_addr := @_aux_addr^;
                            (*ENDIF*) 
                            END;
                        (*ENDIF*) 
                        IF  alloc_ok
                        THEN
                            BEGIN
                            IF  acv.a_mb_strat_addr = NIL
                            THEN
                                BEGIN
                                acv.a_mb_strat_size := MB_STRAT_SIZE_MXGG00;
                                _aux_addr := gg941Allocate (acv.a_transinf.tri_trans,
                                      acv.a_mb_strat_size);
                                IF  _aux_addr = NIL
                                THEN
                                    acv.a_work_buf_size := 0
                                ELSE
                                    acv.a_mb_strat_addr := @_aux_addr^
                                (*ENDIF*) 
                                END;
                            (*ENDIF*) 
                            END
                        ELSE
                            acv.a_mb_strat_size := 0;
                        (*ENDIF*) 
                        END
                    ELSE
                        acv.a_work_st_max := 0
                    (*ENDIF*) 
                    END
                ELSE
                    acv.a_stack_size := 0
                (*ENDIF*) 
                END
            ELSE
                acv.a_mb_qual_size := 0
            (*ENDIF*) 
            END
        ELSE
            acv.a_mb_data_size := 0
        (*ENDIF*) 
        END;
    (*ENDIF*) 
    IF  alloc_ok
    THEN
        BEGIN
        acv.a_mblock.mb_data       := acv.a_mb_data_addr;
        acv.a_mblock.mb_data_size  := acv.a_mb_data_size;
        acv.a_mblock.mb_qual       := acv.a_mb_qual_addr;
        acv.a_mblock.mb_qual_size  := acv.a_mb_qual_size;
        acv.a_mblock.mb_strat      := acv.a_mb_strat_addr;
        acv.a_mblock.mb_strat_size := acv.a_mb_strat_size;
        END
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak91free_mem (
            VAR acv      : tak_all_command_glob;
            free_packets : boolean);
 
VAR
      _aux_addr        : tsp00_Addr;
 
BEGIN
WITH acv.a_transinf.tri_trans DO
    BEGIN
    IF  acv.a_mb_data_addr <> NIL
    THEN
        BEGIN
        _aux_addr := @acv.a_mb_data_addr^;
        gg941Deallocate  (acv.a_transinf.tri_trans, _aux_addr);
        acv.a_mb_data_addr := NIL
        END;
    (*ENDIF*) 
    IF  acv.a_mb_strat_addr <> NIL
    THEN
        BEGIN
        _aux_addr := @acv.a_mb_strat_addr^;
        gg941Deallocate  (acv.a_transinf.tri_trans, _aux_addr);
        acv.a_mb_strat_addr := NIL
        END;
    (*ENDIF*) 
    IF  acv.a_mb_qual_addr <> NIL
    THEN
        BEGIN
        _aux_addr := @acv.a_mb_qual_addr^;
        gg941Deallocate  (acv.a_transinf.tri_trans, _aux_addr);
        acv.a_mb_qual_addr := NIL
        END;
    (*ENDIF*) 
    IF  acv.a_stack_addr <> NIL
    THEN
        BEGIN
        _aux_addr := @acv.a_stack_addr^;
        gg941Deallocate  (acv.a_transinf.tri_trans, _aux_addr);
        acv.a_stack_addr := NIL
        END;
    (*ENDIF*) 
    IF  acv.a_work_st_addr <> NIL
    THEN
        BEGIN
        _aux_addr := @acv.a_work_st_addr^;
        gg941Deallocate  (acv.a_transinf.tri_trans, _aux_addr);
        acv.a_work_st_addr := NIL
        END;
    (*ENDIF*) 
    IF  acv.a_work_buf_addr <> NIL
    THEN
        BEGIN
        _aux_addr := @acv.a_work_buf_addr^;
        gg941Deallocate  (acv.a_transinf.tri_trans, _aux_addr);
        acv.a_work_buf_addr := NIL
        END;
    (*ENDIF*) 
    IF  acv.a_old_packet_p <> NIL
    THEN
        BEGIN
        _aux_addr := @acv.a_old_packet_p^;
        gg941Deallocate  (acv.a_transinf.tri_trans, _aux_addr);
        acv.a_old_packet_p := NIL
        END;
    (*ENDIF*) 
    IF  free_packets
    THEN
        IF  acv.a_in_packet <> NIL
        THEN
            BEGIN
            _aux_addr := @acv.a_in_packet^;
            gg941Deallocate  (acv.a_transinf.tri_trans, _aux_addr);
            acv.a_in_packet := NIL
            END
        (*ENDIF*) 
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak91init_acv (
            VAR acv : tak_all_command_glob;
            VAR t : tgg00_TransContext);
 
VAR
      ix        : integer;
      sink_info : tsp_dcom_init_sink_parms;
      parsk     : tak_parskey;
 
BEGIN
WITH acv DO
    BEGIN
    s10fil (sizeof(acv), acv, 1, sizeof(acv), chr (ord (false)));
    a_in_packet             := NIL;
    a_out_packet            := NIL;
    a_cmd_segm              := NIL;
    a_cmd_part              := NIL;
    a_data_part             := NIL;
    a_data_ptr              := NIL;
    a_data_length           := 0;
    a_resname_part          := NIL;
    a_rescount_part         := NIL;
    a_return_segm           := NIL;
    a_ap_tree               := NIL;
    a_drop_serverdb_ptr     := NIL;
    a_mb_data_addr          := NIL;
    a_mb_strat_addr         := NIL;
    a_mb_qual_addr          := NIL;
    a_stack_addr            := NIL;
    a_work_st_addr          := NIL;
    a_work_buf_addr         := NIL;
    a_err_parm_cnt          := 0;
    a_rollback_info         := [];
    a_viewname              := a01_il_b_identifier;
    a_result_name           := a01_il_b_identifier;
    a_init_ex_kind          := only_syntax;
    a_drda_info_ptr         := NIL;
    FOR ix := 1 TO sizeof (a_modul_name) DO
        a_modul_name[ix] := bsp_c1;
    (*ENDFOR*) 
    (* bsp_identifier is correct for modul_name *)
    a_comp_type             := at_unknown;
    a_connected_name        := a01_il_b_identifier;
    a_curr_user_name        := a01_il_b_identifier;
    a_is_exclusive          := true;
    (* PTS 1115978 E.Z. *)
    a_acc_user              := a01_il_b_identifier;
    a_acc_groupname         := a01_il_b_identifier;
    a_acc_dbaname           := a01_il_b_identifier;
    a_trigger_tree          := b01niltree_id;
    a_dialog_area           := NIL;
    a_proc_user             := a01_il_b_identifier;
    FOR ix := cak_extern_pos TO cak_aux_pos DO
        a_resname_addr[ix] := NIL;
    (*ENDFOR*) 
    a_expl_resname          := a01_il_b_identifier;
    a_show_curr             := b01niltree_id;
    a_pars_curr             := b01niltree_id;
    a_pars_file             := b01niltree_id;
    a_usage_curr            := b01niltree_id;
    a_into_tree             := b01niltree_id;
    a_intern_tree           := b01niltree_id;
    a_intern_res_tree       := b01niltree_id;
    a_intern_cmd_tree       := b01niltree_id;
    a_transinf.tri_trans  := t;
    a_proc_appl             := a01_il_b_identifier;
    a_proc_routine          := a01_il_b_identifier;
    (* PTS 1111797 E.Z. *)
    a_sqlmode               := sqlm_adabas;
    a_user_timeout          := g01timeout.timeCmd_gg00;
    a_use_timeout           := true;
    a_dt_format             := g01code.date_time;
    a_sysdir.ci_cache_p     := NIL;
    a_visual_basic_area     := NIL;
    a_scv.sc_missing_kw_pos := cak_is_undefined;
    a_len_row_not_found_text:= 0;
    a_old_packet_p          := NIL;
    a_max_codewidth         := 1;
    a_session_max_codewidth := 1;
    a_mess_code             := csp_ascii;
    a_session_mess_code     := csp_ascii;
    a_ak_language           := cak_nls_date_language;
    a_cmd_stack.cst_top     := 0;
    a_explain_kind          := ex_default;
    (* PTS 1114071 E.Z. *)
    a_max_used_pcount[1]    := csp_defined_byte;
    a_max_used_pcount[2]    := csp_defined_byte;
    a_max_used_pcount[3]    := csp_defined_byte;
    a_first_free_pcount     := 0;
    a_last_free_pcount      := cak_max_pcounts;
    FOR ix := 1 TO cak_max_pcounts DO
        BEGIN
        a92next_pcount (acv, parsk);
        a_free_pcounts[ix] := parsk.p_count;
        END;
    (*ENDFOR*) 
    a_first_free_pcount     := 1;
    sink_info.acv_addr      := @acv;
    sink_info.sink_addr     := @acv.a_kernel_sink;
    sink_info.sink_size     := sizeof (acv.a_kernel_sink);
    vdcom_init_sink (sink_info);
    a_isInCppDBProcedure    := false; (* PTS 1110148 *)
    vgetuktid(a_allocatorInfo.ai_uktId);
    a_allocatorInfo.ai_alloc_sys.ami_Allocated := 0;
    a_allocatorInfo.ai_alloc_usr.ami_Allocated := 0;
    END;
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak91run_non_user_process (
            VAR t     : tgg00_TransContext;
            proc_type : tsp2_process_type);
 
VAR
      hn : tsp_version;
      ln : tsp_version;
 
BEGIN
gg06BuildTaskSession (t.trSessionId_gg00, proc_type);
CASE proc_type OF
    sp2pt_log_writer:
        BEGIN
        g01pid.taskLogWriter_gg00 := t.trTaskId_gg00;
        kb560AllocateArchiveLogManager(t.trTaskId_gg00);
        kb560LogWriter(t.trTaskId_gg00);
        END;
    sp2pt_trace_writer  :
        BEGIN
        vbegexcl (t.trTaskId_gg00, g08config);
        g01pid.taskTraceWriter_gg00 := t.trTaskId_gg00;
        vendexcl (t.trTaskId_gg00, g08config);
        b120TraceWriter( t.trTaskId_gg00 )
        END;
    sp2pt_timeout :
        BEGIN
&       ifdef trace
        b06check_rec := true;
&       endif
&       ifdef SLOW
        a99init;
        t01sinit;
&       endif
        g01default_configuration;
        g08region_ids;
        b120CreateTrace( t.trTaskId_gg00 );
        bd999CreatePagerController;
        Kernel_InitTrace;
        a01_parser_init;
        a10ak_cache_init;
        (* PTS 1104572 E.Z. *)
        a40glob_init;
        a41glob_init;
        a260init;
        a51init_cache_sizes;
        k05init;
        k71init;
        b01setto_zero_full_and_null;
        bd999CreateFrameControl;
        bd999CreateIOManager(t.trTaskId_gg00);
        bd10CreateConverterSingleton;
        bd91InitOMSGarbageCollection;
        bd499InitIndexMemory (t);
        g02inittranslate_tables;
        g03init;
        g01inittabid;
        a642colinfo_init;
        a54_init;
        a67_init_strat_texts;
        a71glob_init_accesspath_info;
        a720glob_init_eval_stat;
        a94mode := umUtility_egg00;
        a362in_migration := false; (* PTS 1117498 M.Ki. *)
        g11kernel_version(hn);
        vversion (hn, ln);
        gg943AllocateTaskWaitStacks (t.trTaskId_gg00, g01kbfunction_tasks);
        k57allocate (t);
        k38allocate (t.trTaskId_gg00, t.trError_gg00);
        k90allocate_netserver (t);
        (* PTS 1003033 E.Z. *)
        (* PTS 1105614 E.Z. *)
        (**********)
        vinitok;
        (**********)
        a95_timeout_process (t)
        END;
    sp2pt_server :
        k92server_process (t);
    sp2pt_data_writer  :
        bd999CreatePagerWriter (t);
    (* PTS 1102365 E.Z. *)
    sp2pt_event :
        a96eventtask (t);
    sp2pt_garbage_collector :
        bd91StartOMSGarbageCollector (t);
    END
(*ENDCASE*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak91run_non_sql_process (VAR acv : tak_all_command_glob);
 
VAR
      alloc_ok        : boolean;
      utility_startup : tsp1_utility_startup;
      sql_comm_err    : tsp1_comm_error;
 
BEGIN
utility_startup := vutil_startup;
ak91connect (acv, utility_startup <> sp1us_connect, alloc_ok,
      sql_comm_err);
IF  sql_comm_err = sp1ce_ok
THEN
    BEGIN
    IF  utility_startup = sp1us_connect
    THEN
        BEGIN
        a94_service_commands (acv, alloc_ok);
        vrelease (acv.a_transinf.tri_trans.trTaskId_gg00);
        END
    ELSE
        a94_implicit_commands (acv, utility_startup);
    (*ENDIF*) 
    ak91free_mem (acv, utility_startup <> sp1us_connect)
    END
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak91run_sql_process (VAR acv : tak_all_command_glob);
 
VAR
      do_release   : boolean;
      alloc_ok     : boolean;
      sql_comm_err : tsp1_comm_error;
      seq_info     : tgg00_CurrSeqInfo;
 
BEGIN
WITH acv, a_transinf, tri_trans DO
    BEGIN
    do_release := false;
    ak91connect (acv, NOT c_without_communication, alloc_ok, sql_comm_err);
    (* PTS 1110096 E.Z. *)
    seq_info.csi_cnt  := 0;
    trSeqInfoPtr_gg00 := @seq_info;
    IF  sql_comm_err = sp1ce_ok
    THEN
        BEGIN
        WHILE NOT do_release DO
            a93_user_commands (acv, alloc_ok, do_release);
        (*ENDWHILE*) 
        vrelease (trTaskId_gg00);
        ak91free_mem (acv, NOT c_free_packets)
        END
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak91run_user_process (
            VAR t     : tgg00_TransContext;
            proc_type : tsp2_process_type);
 
VAR
      all_server_ready : boolean;
      startup_finished : boolean;
      acv              : tak_all_command_glob;
 
BEGIN
WITH acv, a_transinf, tri_trans DO
    BEGIN
    (* h.b. CR 1103950 *)
    vinit_akdump_ptr (@acv, @a102akdump(acv));
    ak91init_acv (acv, t);
    IF  proc_type = sp2pt_utility
    THEN
        BEGIN
        g01pid.taskUtility_gg00 := trTaskId_gg00;
        startup_finished        := false;
        WHILE NOT startup_finished DO
            BEGIN
            all_server_ready := k90all_server_ready (t.trTaskId_gg00);
            vbegexcl (trTaskId_gg00, g08config);
            WITH g01pid DO
                startup_finished :=
                      (taskLogWriter_gg00    <> cgg_nil_pid)
                      AND
                      (taskTraceWriter_gg00  <> cgg_nil_pid)
                      AND
                      all_server_ready;
            (*ENDWITH*) 
            vendexcl (trTaskId_gg00, g08config);
            IF  NOT startup_finished
            THEN
                vsleep (trTaskId_gg00, 1)
            (*ENDIF*) 
            END;
        (*ENDWHILE*) 
        ak91run_non_sql_process (acv);
        END
    ELSE
        BEGIN
        a_in_session := false;
        ak91run_sql_process (acv);
        END
    (*ENDIF*) 
    END;
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      a91mainprogram;
 
VAR
      TransContext : tgg00_TransContext;
 
BEGIN
(* PTS 1108234 JA 2000-11-08 *)
ak91set_copyright;
g01transid_init (TransContext);
vinit (TransContext.trRteCommPtr_gg00, mxsp_rte_comm);
gg941CreateAllocatorAndCallMainprog (TransContext);
ak91call_vfinish_if_necessary (TransContext.trTaskId_gg00)
END;
 
(*------------------------------*) 
 
PROCEDURE
      a91mainprogam_with_allocator (VAR TransContext : tgg00_TransContext);
 
VAR
      proc_type : tsp2_process_type;
 
BEGIN
(* PTS 1108234 JA 2000-11-08 *)
vptype (TransContext.trTaskId_gg00, proc_type);
IF  proc_type in [ sp2pt_utility, sp2pt_user ]
THEN
    ak91run_user_process (TransContext, proc_type)
ELSE
    ak91run_non_user_process (TransContext, proc_type)
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak91call_vfinish_if_necessary (task_id : tsp00_TaskId);
 
VAR
      proc_type : tsp2_process_type;
 
BEGIN
vptype (task_id, proc_type);
IF  proc_type in [ sp2pt_user, sp2pt_event ]
THEN
    vfinish
(*ENDIF*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :        288
*-PRETTY-*  lines of code :        659        PRETTYX 3.10 
*-PRETTY-*  lines in file :       1372         1997-12-10 
.PA 
