.ad 8
.bm 3
.fm 2
.bt $Copyright by SAP AG, 2002$$Page %$
.tm 5
.hm 2
.hs 3
.tt 1 $SQL$Project Distributed Database System$VAK94$
.tt 2 $$$
.tt 3 $ElkeZ$Utilityprocess$2000-11-21$
***********************************************************
.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  : Utilityprocess
=========
.sp
Purpose : This module represents the main part of the service process.
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        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);
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              Scanner : VAK01;
 
        VAR
              a01controluser       : tsp_knl_identifier;
              a01_il_b_identifier  : tsp_knl_identifier;
 
        PROCEDURE
              a01_get_keyword (VAR acv : tak_all_command_glob;
                    VAR index : integer; VAR reserved : boolean);
 
        PROCEDURE
              a01_init_command (VAR acv : tak_all_command_glob);
 
        PROCEDURE
              a01_next_symbol (VAR acv : tak_all_command_glob);
 
        FUNCTION
              a01aligned_cmd_len (len : tsp_int4) : tsp_int4;
 
      ------------------------------ 
 
        FROM
              AK_universal_semantic_tools : VAK06;
 
        PROCEDURE
              a06char_retpart_move (VAR acv : tak_all_command_glob;
                    moveobj_ptr : tsp_moveobj_ptr;
                    move_len    : tsp_int4);
 
        PROCEDURE
              a06retpart_move (VAR acv : tak_all_command_glob;
                    moveobj_ptr : tsp_moveobj_ptr;
                    move_len    : tsp_int4);
 
        PROCEDURE
              a06finish_curr_retpart (VAR acv : tak_all_command_glob;
                    part_kind : tsp1_part_kind;
                    arg_count : tsp_int2);
 
      ------------------------------ 
 
        FROM
              AK_error_handling : VAK07;
 
        PROCEDURE
              a07_b_put_error (VAR acv : tak_all_command_glob;
                    b_err   : tgg_basis_error;
                    err_code : tsp_int4);
 
        FUNCTION
              a07_return_code (b_err : tgg_basis_error;
                    sqlmode : tsp_sqlmode) : tsp_int2;
 
        PROCEDURE
              a07_intern_error_put (VAR acv : tak_all_command_glob);
 
      ------------------------------ 
 
        FROM
              AK_BD_procedure_interface : VAK09;
 
        PROCEDURE
              a09rollback (VAR acv : tak_all_command_glob;
                    VAR e : tgg_basis_error);
 
      ------------------------------ 
 
        FROM
              Systeminfo_cache : VAK10;
 
        PROCEDURE
              a10_cache_delete  (VAR acv : tak_all_command_glob;
                    is_rollback : boolean);
 
        PROCEDURE
              a10dispose (VAR acv : tak_all_command_glob;
                    VAR p : tsp1_part_ptr);
 
      ------------------------------ 
 
        FROM
              AK_Syntax_utility : VAK30;
 
        PROCEDURE
              a30_init_utility (VAR acv : tak_all_command_glob;
                    VAR implicit_restart : boolean);
 
        PROCEDURE
              a30_dbs_utility (VAR acv : tak_all_command_glob;
                    VAR syntax_error      : boolean);
 
        PROCEDURE
              a30_standby_utility (VAR acv : tak_all_command_glob);
 
      ------------------------------ 
 
        FROM
              AK_distributor : VAK35;
 
        PROCEDURE
              a35state (VAR acv : tak_all_command_glob);
 
      ------------------------------ 
 
        FROM
              AK_cold_utility_functions : VAK36;
 
        PROCEDURE
              a36abort (VAR acv : tak_all_command_glob);
 
        PROCEDURE
              a36diag_outcopy (VAR acv : tak_all_command_glob);
 
      ------------------------------ 
 
        FROM
              AK_Lock_Commit_Rollback : VAK52;
 
        PROCEDURE
              a52end_rollback_subtrans (VAR acv : tak_all_command_glob;
                    VAR subtrans_name : tsp_knl_identifier;
                    m_type            : tgg_message_type);
 
        PROCEDURE
              a52free_caches (VAR acv : tak_all_command_glob);
 
        PROCEDURE
              a52_ex_commit_rollback (VAR acv : tak_all_command_glob;
                    m_type         : tgg_message_type;
                    n_rel          : boolean;
                    normal_release : boolean);
 
      ------------------------------ 
 
        FROM
              Deal-With-User-Commands : VAK92;
 
        PROCEDURE
              a92_reject (VAR acv : tak_all_command_glob;
                    s : boolean);
 
        PROCEDURE
              a92_map_into_upper (VAR acv : tak_all_command_glob;
                    VAR buf  : tsp_moveobj;
                    startpos : tsp_int4;
                    endpos   : tsp_int4;
                    uni_map  : boolean);
 
        PROCEDURE
              a92_mode_analyzer (VAR acv : tak_all_command_glob;
                    ddl         : tak_ddl_descriptor;
                    corr_select : boolean);
&       ifdef TRACE
 
        PROCEDURE
              a92_special_mess_types (VAR acv : tak_all_command_glob);
&       endif
 
      ------------------------------ 
 
        FROM
              DBS_Commands : VAK93;
 
        PROCEDURE
              a93_sending (VAR acv : tak_all_command_glob;
                    start_time_sec  : tsp_int4;
                    start_time_msec : tsp_int4;
                    VAR retcode     : tsp1_comm_error);
 
        PROCEDURE
              a93init_caches (VAR acv : tak_all_command_glob);
 
        PROCEDURE
              a93packet_vtrace (VAR t : tgg00_TransContext;
                    trace_object      : tgg_vtrace_type;
                    packet_ptr        : tsp1_packet_ptr);
 
        PROCEDURE
              a93vreceive (VAR acv   : tak_all_command_glob;
                    timeout          : tsp_int4;
                    VAR alloc_ok     : boolean;
                    VAR sql_comm_err : tsp1_comm_error);
 
      ------------------------------ 
 
        FROM
              Trace : VBD120;
 
        PROCEDURE
              b120InsertTrace (VAR t   : tgg00_TransContext;
                    trace_layer  : tgg00_Debug;
                    trace_object : tgg00_VtraceType;
                    body_len     : tsp00_Int2;
                    trace_body   : tsp00_Addr);
 
      ------------------------------ 
 
        FROM
              Configuration_Parameter : VGG01;
 
        VAR
              g01code           : tgg_code_globals;
              g01controluser    : tgg_controluser;
              g01serverdb_ident : tgg_serverdb_ident;
              g01timeout        : tgg00_TimeoutGlobals;
              g01vtrace         : tgg_vtrace_state;
 
        PROCEDURE
              g01opmsg (msg_prio : tsp3_priority;
                    msg_type  : tsp3_msg_type;
                    msg_no    : tsp_int4;
                    msg_label : tsp_c8;
                    msg_text  : tsp_c24;
                    msg_value : tsp_int4);
 
        FUNCTION
              g01is_livecache : boolean;
 
      ------------------------------ 
 
        FROM
              Codetransformation_and_Coding : VGG02;
 
        PROCEDURE
              g02decrypt (VAR clearname : tsp_name;
                    VAR crypt : tsp_cryptpw);
 
        PROCEDURE
              g02gettermsetdesc (VAR termset_name : tsp_knl_identifier;
                    VAR messcode : tsp_code_type;
                    VAR code     : tsp_code_type;
                    VAR found    : boolean);
 
      ------------------------------ 
 
        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_name;    source_pos : tsp_int4;
                    VAR destin     : tsp_moveobj; 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     : tsp_knl_identifier; 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     : tsp_cryptpw; source_pos : tsp_int4;
                    VAR destin     : tsp_moveobj; destin_pos : tsp_int4;
                    length         : tsp_int4;
                    VAR e          : tgg_basis_error);
 
      ------------------------------ 
 
        FROM
              RTE_kernel : VEN101;
 
        PROCEDURE
              vclock (VAR sec    : tsp_int4;
                    VAR microsec : tsp_int4);
 
        PROCEDURE
              vrestart (pid : tsp_process_id;
                    VAR sysdevspace : tsp_devname);
 
      ------------------------------ 
 
        FROM
              Encrypting : VSP02;
 
        PROCEDURE
              s02applencrypt (pw_clear : tsp_name;
                    VAR pw_crypt : tsp_cryptpw);
 
      ------------------------------ 
 
        FROM
              Packet_handling : VSP26;
 
        PROCEDURE
              s26finish_part (packet_ptr : tsp1_packet_ptr;
                    VAR finish_part : tsp1_part);
 
        PROCEDURE
              s26first_segment_init (packet_ptr : tsp1_packet_ptr;
                    segm_kind          : tsp1_segment_kind;
                    VAR first_segm_ptr : tsp1_segment_ptr);
 
        PROCEDURE
              s26init_cmd_packet (packet_ptr : tsp1_packet_ptr;
                    VAR first_segm_ptr : tsp1_segment_ptr);
 
        PROCEDURE
              s26new_part_init (packet_ptr : tsp1_packet_ptr;
                    VAR segm         : tsp1_segment;
                    VAR new_part_ptr : tsp1_part_ptr);
 
        FUNCTION
              s26packet_len (packet_ptr : tsp1_packet_ptr) : tsp_int4;
 
      ------------------------------ 
 
        FROM
              RTE-Extension-30 : VSP30;
 
        FUNCTION
              s30klen (VAR str : tsp_knl_identifier;
                    val : char; cnt : integer) : integer;
&       ifdef TRACE
 
      ------------------------------ 
 
        FROM
              Test_Procedures : VTA01;
 
        PROCEDURE
              t01int4 (level : tgg00_Debug;
                    nam : tsp00_Sname;
                    val : tsp00_Int4);
 
        PROCEDURE
              t01packet (debug : tgg00_Debug;
                    nam        : tsp00_Sname;
                    packet_ptr : tsp1_packet_ptr);
&       endif
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              a10dispose;
 
              tak_sysbufferaddress tsp1_part_ptr
 
        PROCEDURE
              b120InsertTrace;
 
              tgg11_VtraceBodyPtr tsp00_Addr
 
        PROCEDURE
              g10mv;
 
              tsp_moveobj tsp_name
 
        PROCEDURE
              g10mv1;
 
              tsp_moveobj tsp_knl_identifier
 
        PROCEDURE
              g10mv2;
 
              tsp_moveobj tsp_cryptpw
 
        PROCEDURE
              s30klen;
 
              tsp_moveobj tsp_knl_identifier
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : ElkeZ
.sp
.cp 3
Created : 1983-07-29
.sp
.cp 3
Version : 2002-08-29
.sp
.cp 3
Release :      Date : 2000-11-21
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
.sp 2
SHUTDOWN_INSPECT
.sp
If the command SHUTDOWN has been detected, it is not clear whether this is a
quick shutdown or not and whether a non-quick shutdown can be executed
immediately, i.e. whether the user can receive his answer immediately.
.br;Before the command is processed, therefore, it is checked whether there is
already a shutdown request (keep_modus <> null_modus). After the command has
been processed, it is checked in BD whether there is only a shutdown request
(non-quick shutdown) or whether the shutdown was performed immediately. In the
latter case, the mode is re-initialized and the database kernel status is
set to cold (A94_MODE).
.sp 2;UTILITY
.sp
In this procedure, all commands are processed that have been sent to the
utility process with the message type m_autility.
.br;The command STATE used by the interactive components inquires whether the
kernel is warm (1st byte = chr(2)) or cold. Likewise it inquires
whether the current user (the
command is not used until after the CONNECT) is allowed to make all possible
commands when the kernel is cold, incl. INIT CONFIG (1st byte = chr(0)) or only
RESTART (1st byte = chr(1)). In addition, when the kernel is warm, the database
name (when cold = blank) is returned to the components in bytes 2 to 19 in part
1 of the SQL_PACKET.
.br;The Restart command, which makes the database warm, may be performed by a
connected user only when the kernel is cold.
.br;If it has been possible for the command to be executed correctly, it
is known, which
values are to be translated in the function ALPHA in which way.
This information can be moved from the Config record in AK structures.
.br;The user is then implicitly released
with COMMIT WORK RELEASE, so that he
must re-connect in order to be able to use utility commands while the kernel is
warm.
.br;The run-time environment is informed by VRESTART that warm operation has
started and this is likewise made known internally (A94_MODE).
.br;
SHUTDOWN may be made only in warm operation by a connected user (NOT is_all).
.br;By means of SHUTDOWN_INSPECT, the command is executed and it is determined
whether this is a shutdown that can be executed immediately or not.
.br;If it was possible for the shutdown to be executed immediately, the
run-time
environment is informed that warm operation is finished and the user is
released implicitly from the service process with a COMMIT WORK RELEASE, so
that he must re-connect if he wishes to issue utility commands in cold
operation.
.br;All other commands are, depending on the state of the database, passed to
A30_INIT_UTILITY (cold operation) or A30_DBS_UTILITY (warm operation) for
processing.
.br;It is then inquired whether the session is to be terminated (is_all), i.e.
whether the process must be released.
.sp 2;MESS_TYPE_ANALYSIS
.sp
In this procedure, the message types are checked for their legality. Of course,
the message type m_autility is allowed and is further processed in UTILITY. The
message types m_aincopy, m_aendincopy, m_aoutcopy, m_aendoutcopy that are
required SAVE etc. and
RESTORE etc. are handled in VAK36.
.br;In addition, the message types m_adbs and m_adbsinfo are also allowed in
warm operation for support purposes in order to be able to make SELECTs or SHOWs
also without a special interactive component. The output then appears
on the screen unformatted.
.br;For test purposes, there are also special message types (500-504), which
are processed in A92_SPECIAL_MESS_TYPES and lead to the outputting of
Testoutput.
.sp 2;AK94ONE_COMMAND
.sp
This procedure is called by A94_SERVICE_COMMANDS, and also from VAK96, which is
needed only for a single-user system (application and kernel in one process).
.br;The procedure rejects certain combinations of database
state (warm/cold) and message type. Only those commands that have been
recognized as being possibly allowable are passed on to the procedure
MESS_TYPE_ANALYSIS.
.br;The message type ahello, which is intended only to state whether the kernel
is still available and whether the user has not yet been released from the
kernel process by an implicit RELEASE, is processed directly.
.sp 2;A94_SERVICE_COMMANDS
.sp
The procedure a94_service_commands waits a defined length of time for a command
input. This time depends on whether the process belongs to a user or not
(is_all).
.br
If there is a command, the number of commands is increased for Accounting and,
if necessary, the low and high bytes of the integers are swapped.
.br;If the lengths and also the entries in the message code are allowable,
for the message types that indicate the presence of a command
(e.g. not m_aincopy), the command is code-converted and converted from lower-
case to upper-case letters in order to facilitate the accessing of keywords and
names. (Strings, of course, are only code-converted).
.br;A Vtrace entry is built, if necessary, which, depending on which Vtrace is
activated, comprises the entire command or only the first approximately 130
characters.
.br;AK94ONE_COMMAND is called for the further analysis and, if necessary,
processing of the command.
.br;If there need be no wait for the execution of a shutdown, it may be that,
for a SAVE, there has to be a wait for the checkpoint in order to be able to
output the remaining pages. In this case, this is done in a loop in
which there is a one-second sleep each time before an attempt is again made to
fetch the next page. This ensures the other processes get the CPU in between
and, thus, that the checkpoint is reached some time or other.
.br;If there has to be a wait for the execution of a non-quick shutdown, this
must be done until there is no longer a write transaction that is open (empty;
if it is only read transactions that are open, the shutdown is executed) or
until KB has set the state of the database to cold because, for example, an
emergency shutdown occurred.
.br;When the shutdown has been executed, this is told to the run-time
environment by VSHUTDOWN and it is ensured by sending = true that the user gets
the response of the SHUTDOWN command.
.br;If the shutdown has not yet been executed, the process again goes to sleep
for one second.
.br;So that this loop does not become endless (and thus block the service
process and the application
process), the loop terminates when the Command-Timeout
value has elapsed as processing time for this shutdown.
.br;The shutdown request is then revoked
(B01REVOKE_SHUTDOWN) and the user is informed that it has not yet been possible
for his non-quick shutdown to be executed. He then has the option of issuing a
quick shutdown or of allowing warm operation to continue without himself being
blocked.
.br;By means of A93_SENDING, the answer to a request is sent back to the user;
the process can, if applicable, be identified to the run-time environment as
being freely available again (3rd parameter = true).
.br;If problems occur in communication (ret_code <> sp1ce_ok) or if the Timeout
has taken effect for a connected user (ret_code = sp1ce_notok), further working is
no longer practical. The user is implicitly released; the process is released.
.br;Release also means that the cache is deleted.
.br;If the process has not already been marked as free to the
run-time environment by
A93_SENDING and by the run-time environment routine used therein, this is done
by the routine VSRELEASE.
.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
      nil_start_time         = 0;
      c_n_rel          = true (* a52_ex_commit_rollback *);
      c_normal_release = true (* a52_ex_commit_rollback *);
      c_utilityprocess = true (* a92_reject *);
      c_uni_map        = true (* a92_map_into_upper *);
      c_corr_select    = true (* a92_mode_analyzer *);
      c_is_rollback    = true;
 
 
(*------------------------------*) 
 
PROCEDURE
      ak94build_connect_cmd (VAR acv : tak_all_command_glob);
 
VAR
      e            : tgg_basis_error;
      len          : tsp_int4;
      datapart_ptr : tsp1_part_ptr;
      n            : tsp_name;
      pw_crypt     : tsp_cryptpw;
 
BEGIN
WITH acv DO
    BEGIN
    e := e_ok;
    ak94packet_init (a_in_packet);
    WITH g01controluser DO
        BEGIN
        WITH a_in_packet^.sp1_segm.sp1p_part DO
            BEGIN
            n := 'CONNECT "         ';
            g10mv ('VAK94 ',   1,    
                  sizeof (n), sp1p_buf_size, n, 1,
                  sp1p_buf, sp1p_buf_len + 1, 9, e);
            sp1p_buf_len := sp1p_buf_len + 9;
            len := s30klen (ggcu_user, bsp_c1, sizeof (ggcu_user));
            g10mv1 ('VAK94 ',   2,    
                  sizeof (ggcu_user), sp1p_buf_size, ggcu_user, 1,
                  sp1p_buf, sp1p_buf_len + 1, len, e);
            sp1p_buf_len := sp1p_buf_len + len;
            n := '" IDENTIFIED BY :X';
            g10mv ('VAK94 ',   3,    
                  sizeof (n), sp1p_buf_size, n, 1,
                  sp1p_buf, sp1p_buf_len + 1, 18, e);
            sp1p_buf_len := sp1p_buf_len + 18;
            END;
        (*ENDWITH*) 
        s26finish_part (a_in_packet, a_in_packet^.sp1_segm.sp1p_part);
        s26new_part_init (a_in_packet, a_in_packet^.sp1_segm,
              datapart_ptr);
        WITH datapart_ptr^ DO
            BEGIN
            sp1p_buf [sp1p_buf_len+1] := csp_defined_byte;
            g02decrypt (n, ggcu_password);
            s02applencrypt (n, pw_crypt);
            g10mv2 ('VAK94 ',   4,    
                  sizeof (pw_crypt), sp1p_buf_size, pw_crypt, 1,
                  sp1p_buf, sp1p_buf_len + 2, sizeof (pw_crypt), e);
            sp1p_buf_len := sp1p_buf_len + 1 + sizeof (pw_crypt);
            sp1p_buf [sp1p_buf_len+1] := bsp_c1;
            n := bsp_name;
            g10mv ('VAK94 ',   5,    
                  sizeof (n), sp1p_buf_size,
                  n, 1, sp1p_buf,
                  sp1p_buf_len + 2, sizeof (tsp_termid), e);
            sp1p_buf_len := sp1p_buf_len + 1 + sizeof (tsp_termid)
            END;
        (*ENDWITH*) 
        s26finish_part (a_in_packet, datapart_ptr^);
        ak94outpacket_init (acv);
        END
    (*ENDWITH*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak94build_release_cmd (VAR acv : tak_all_command_glob);
 
VAR
      e : tgg_basis_error;
      n : tsp_name;
 
BEGIN
WITH acv DO
    BEGIN
    e := e_ok;
    ak94packet_init (a_in_packet);
    WITH a_in_packet^.sp1_segm.sp1p_part DO
        BEGIN
        n := 'COMMIT RELEASE    ';
        g10mv ('VAK94 ',   6,    
              sizeof (n), sp1p_buf_size, n, 1,
              sp1p_buf, sp1p_buf_len + 1, 14, e);
        sp1p_buf_len := sp1p_buf_len + 14;
        END;
    (*ENDWITH*) 
    s26finish_part (a_in_packet, a_in_packet^.sp1_segm.sp1p_part);
    ak94outpacket_init (acv);
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak94build_restart_cmd (VAR acv : tak_all_command_glob);
 
VAR
      e : tgg_basis_error;
      n : tsp_name;
 
BEGIN
WITH acv DO
    BEGIN
    e := e_ok;
    ak94packet_init (a_in_packet);
    WITH a_in_packet^.sp1_segm.sp1p_part DO
        BEGIN
        n := 'RESTART           ';
        g10mv ('VAK94 ',   7,    
              sizeof (n), sp1p_buf_size, n, 1,
              sp1p_buf, sp1p_buf_len + 1, 7, e);
        sp1p_buf_len := sp1p_buf_len + 7;
        END;
    (*ENDWITH*) 
    s26finish_part (a_in_packet, a_in_packet^.sp1_segm.sp1p_part);
    ak94outpacket_init (acv);
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak94build_shutdown_cmd (VAR acv : tak_all_command_glob);
 
VAR
      e : tgg_basis_error;
      n : tsp_name;
 
BEGIN
WITH acv DO
    BEGIN
    e := e_ok;
    ak94packet_init (a_in_packet);
    WITH a_in_packet^.sp1_segm.sp1p_part DO
        BEGIN
        n := 'SHUTDOWN QUICK    ';
        g10mv ('VAK94 ',   8,    
              sizeof (n), sp1p_buf_size, n, 1,
              sp1p_buf, sp1p_buf_len + 1, 14, e);
        sp1p_buf_len := sp1p_buf_len + 14;
        END;
    (*ENDWITH*) 
    s26finish_part (a_in_packet, a_in_packet^.sp1_segm.sp1p_part);
    ak94outpacket_init (acv);
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak94clear (VAR acv : tak_all_command_glob;
            ret_code  : tsp1_comm_error);
 
VAR
      intern_command : tsp_page; (* ++++++ *)
 
BEGIN
WITH acv DO
    BEGIN
    a_in_packet := @intern_command;
    s26first_segment_init (a_in_packet, sp1sk_cmd, a_cmd_segm);
    WITH a_in_packet^, sp1_header DO
        BEGIN
        sp1h_mess_code := g01code.ctype;
        sp1h_mess_swap := g01code.kernel_swap;
        sp1h_varpart_size := sizeof (intern_command) -
              sizeof (sp1_header)
        END;
    (*ENDWITH*) 
    a_data_part    := NIL;
    a_curr_retpart := NIL;
    IF  a_out_packet = NIL
    THEN
        a_out_packet := @a_in_packet^.sp1_varpart[ 1 ];
    (*ENDIF*) 
    s26first_segment_init (a_out_packet, sp1sk_return, a_return_segm);
    ak94iclear (acv, ret_code);
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak94iclear (VAR acv : tak_all_command_glob;
            ret_code  : tsp1_comm_error);
 
BEGIN
WITH acv DO
    IF  a_in_session
    THEN
        BEGIN
        a_return_segm^.sp1r_returncode := 0;
        a36abort (acv);
        IF  a94mode = umUser_egg00
        THEN
            a52_ex_commit_rollback (acv, m_rollback,
                  c_n_rel, NOT c_normal_release);
        (*ENDIF*) 
        a_in_session := false;
        IF  ret_code = sp1ce_timeout
        THEN
            BEGIN
            a_return_segm^.sp1r_returncode := 0;
            a07_b_put_error (acv, e_command_timeout, 1);
            a93_sending (acv, nil_start_time, nil_start_time, ret_code);
            END
        (*ENDIF*) 
        END
    (*ENDIF*) 
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak94implicit_command (VAR acv : tak_all_command_glob);
 
VAR
      found      : boolean;
      e          : tgg_basis_error;
      blank_name : tsp_knl_identifier;
 
BEGIN
(* the next initializations are necessary for migrate with *)
(* create view or things like that. Otherwise crashes      *)
WITH acv DO
    BEGIN
    a_in_internal_subtr    := false;
    a_rollback_info        := [  ];
    a_long_desc_pos        := 0;
    a_errpos_offset        := 0;
    a_user_defined_error   := false;
    a_statement_kind       := isql_commands;
    a_transinf.tri_trans.trRteCommPtr_gg00^.to_cancel := false;
    WITH a_in_packet^.sp1_header DO
        BEGIN
        IF  a_sysdir.ci_cache_p = NIL
        THEN
            a93init_caches (acv);
        (*ENDIF*) 
        IF  a_return_segm^.sp1r_returncode = 0
        THEN
            BEGIN
            a_mess_code := sp1h_mess_code;
            (* PTS 1113268 E.Z. *)
            IF  a_mess_code <> a_session_mess_code
            THEN
                BEGIN
                IF  a_mess_code < csp_unicode_swap
                THEN
                    a_max_codewidth := 1
                ELSE
                    IF  a_mess_code <= csp_unicode
                    THEN
                        a_max_codewidth := 2
                    (*ENDIF*) 
                (*ENDIF*) 
                END
            ELSE
                a_max_codewidth := a_session_max_codewidth;
            (*ENDIF*) 
            found       := true;
            IF  (a_mess_code >= cgg_begin_termsets) AND
                (a_mess_code <= cgg_end_termsets)
            THEN
                BEGIN
                blank_name := a01_il_b_identifier;
                g02gettermsetdesc (blank_name, a_mess_code,
                      a_basic_code, found);
                END
            ELSE
                a_basic_code := a_mess_code;
            (*ENDIF*) 
            IF  NOT found
            THEN
                a07_b_put_error (acv, e_invalid_messcodetype, 1);
            (*ENDIF*) 
            IF  g01vtrace.vtrAny_gg00
            THEN
                a93packet_vtrace (a_transinf.tri_trans,
                      ak_receive, a_in_packet);
&           ifdef TRACE
            (*ENDIF*) 
            t01packet (ak_syn, 'UTIL-TO-KERN', a_in_packet);
&           endif
            (* PTS 1107617 E.Z. *)
            ak94one_command (acv);
            IF  a_rollback_info <> []
            THEN
                a09rollback (acv, e);
            (*ENDIF*) 
            END
        (*ENDIF*) 
        END;
    (*ENDWITH*) 
    IF  NOT a_in_session
    THEN
        BEGIN
        a_curr_user_name  := a01_il_b_identifier;
        a52free_caches (acv);
        a_acc_user        := a01_il_b_identifier;
        (* PTS 1115978 E.Z. *)
        a_transinf.tri_trans.trTransId_gg00.ci6_gg00 := cgg_zero_trans;
        END
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak94mess_type_analysis (VAR acv : tak_all_command_glob);
 
BEGIN
WITH acv, a_cmd_segm^ DO
    IF  (sp1c_mess_type = sp1m_syntax) OR (sp1c_commit_immediately)
    THEN
        a92_reject (acv, c_utilityprocess)
    ELSE
        IF  sp1c_mess_type in
            [sp1m_utility, sp1m_dbs, sp1m_parse, sp1m_execute]
        THEN
            BEGIN
            ak94utility (acv);
            IF  a_return_segm^.sp1r_returncode = cak_e_released
            THEN
                a_return_segm^.sp1r_returncode := 0
            (*ENDIF*) 
            END
        ELSE
&           ifdef TRACE
            IF  (sp1c_mess_type > sp1m_specials_lower_bound)
            THEN
                a92_special_mess_types (acv)
            ELSE
&               endif
                IF  NOT a_in_session
                THEN
                    a92_reject (acv, c_utilityprocess)
                ELSE
                    CASE sp1c_mess_type OF
                        sp1m_diag_outcopy:
                            a36diag_outcopy (acv);
                        OTHERWISE
                            a92_reject (acv, c_utilityprocess)
                        END
                    (*ENDCASE*) 
                (*ENDIF*) 
            (*ENDIF*) 
        (*ENDIF*) 
    (*ENDIF*) 
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak94outpacket_init (VAR acv : tak_all_command_glob);
 
BEGIN
WITH acv DO
    BEGIN
    WITH a_in_packet^ DO
        BEGIN
        sp1_header.sp1h_varpart_len := s26packet_len (a_in_packet) -
              sizeof (sp1_header);
        a_cmd_segm   := @sp1_segm;
        a_data_part  := NIL;
        a_out_packet := @sp1_varpart [sp1_header.sp1h_varpart_len + 1]
        END;
    (*ENDWITH*) 
    WITH a_out_packet^ DO
        BEGIN
        sp1_header := a_in_packet^.sp1_header;
        sp1_header.sp1h_varpart_size := 4 * sizeof (tsp_buf) -
              a_in_packet^.sp1_header.sp1h_varpart_len -
              2 * sizeof (sp1_header);
        sp1_header.sp1h_varpart_size := (sp1_header.sp1h_varpart_size DIV
              csp1_part_align_length) * csp1_part_align_length;
        END;
    (*ENDWITH*) 
    s26first_segment_init (a_out_packet, sp1sk_return, a_return_segm);
    a_curr_retpart   := NIL;
    a_retpart_locked := false
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak94packet_init (in_packet : tsp1_packet_ptr);
 
VAR
      first_segm_ptr : tsp1_segment_ptr;
      first_part_ptr : tsp1_part_ptr;
 
BEGIN
s26init_cmd_packet (in_packet, first_segm_ptr);
s26new_part_init (in_packet, first_segm_ptr^, first_part_ptr);
WITH in_packet^.sp1_header DO
    BEGIN
    sp1h_application  := 'UTI';
    sp1h_appl_version := '62081'
    END;
(*ENDWITH*) 
WITH first_segm_ptr^ DO
    BEGIN
    sp1c_mess_type := sp1m_utility;
    sp1c_producer  := sp1pr_internal_cmd
    END;
(*ENDWITH*) 
WITH first_part_ptr^ DO
    sp1p_part_kind := sp1pk_command
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak94utility (VAR acv : tak_all_command_glob);
 
VAR
      dummy            : boolean;
      parse_or_ex      : boolean;
      syntax_error     : boolean;
      implicit_restart : boolean;
      flag             : char;
      kw               : integer;
      rc               : integer;
      part_count       : integer;
      aux_scv          : tak_scanner_glob;
      part_desc_ptr    : tsp1_part_ptr;
      interndbname     : tsp_dbname;
      hostn            : tsp_devname;
 
BEGIN
WITH acv, a_scv DO
    BEGIN
    part_count    := 0;
    part_desc_ptr := @a_in_packet^.sp1_segm.sp1p_part_header;
    parse_or_ex   :=
          a_cmd_segm^.sp1c_mess_type in [sp1m_parse, sp1m_execute];
    IF  (a_return_segm^.sp1r_returncode = 0) AND
        (part_desc_ptr^.sp1p_part_kind = sp1pk_command)
    THEN
        BEGIN
        part_count   := succ (part_count);
        a_cmd_part   := part_desc_ptr;
        a92_map_into_upper (acv, a_cmd_part^.sp1p_buf, 1,
              a_cmd_part^.sp1p_buf_len, c_uni_map);
        END
    ELSE
        a_cmd_part   := NIL;
    (*ENDIF*) 
    a_data_ptr    := NIL;
    a_data_length := 0;
    IF  part_count < a_cmd_segm^.sp1s_no_of_parts
    THEN
        BEGIN
        part_desc_ptr := @a_cmd_segm^.sp1p_buf[ 1 +
              a01aligned_cmd_len (a_cmd_segm^.sp1p_buf_len)];
        IF  ((a_return_segm^.sp1r_returncode = 0)
            AND (part_desc_ptr^.sp1p_part_kind = sp1pk_data))
        THEN
            BEGIN
            part_count    := succ(part_count);
            a_data_ptr    := @part_desc_ptr^.sp1p_buf[ 1 ];
            a_data_length := part_desc_ptr^.sp1p_buf_len
            END
        (*ENDIF*) 
        END;
    (*ENDIF*) 
    IF  a_cmd_segm^.sp1c_mess_type = sp1m_execute
    THEN
        a_ex_kind := only_executing
    ELSE
        a_ex_kind := parsing_executing;
    (*ENDIF*) 
    a_init_ex_kind    := a_ex_kind;
    a_is_ddl          := no_ddl;
    a_init_ddl        := no_ddl;
    a01_init_command (acv);
    a_intern_explain := false;
    a_len_row_not_found_text := 0;
    (* PTS 1117498 E.Z. *)
    implicit_restart         := false;
    a01_get_keyword (acv, kw, dummy);
    IF  (kw = cak_i_state) AND NOT parse_or_ex
    THEN
        BEGIN
        a_return_segm^.sp1r_returncode  := 0;
        interndbname := bsp_dbname;
        aux_scv := a_scv;
        a01_next_symbol (acv);
        IF  sc_symb = s_eof
        THEN
            BEGIN
            IF  a94mode = umUser_egg00
            THEN
                BEGIN
                interndbname  := g01serverdb_ident.svServerdb_gg00;
                flag          := chr(2)
                END
            ELSE
                IF  a_curr_user_name = a01controluser
                THEN
                    flag := chr(0)
                ELSE
                    flag := chr(1);
                (*ENDIF*) 
            (*ENDIF*) 
            a06retpart_move (acv,
                  @flag, sizeof (flag));
            a06char_retpart_move (acv,
                  @interndbname, sizeof (interndbname));
            a06finish_curr_retpart (acv, sp1pk_data, 1)
            END
        ELSE
            BEGIN
            a_scv := aux_scv;
            a35state (acv)
            END;
        (*ENDIF*) 
        END
    ELSE
        IF  ((kw = cak_i_restart) OR (kw = cak_i_activate)) AND
            NOT parse_or_ex
        THEN
            IF  a94mode = umUtility_egg00
            THEN
                IF  a_in_session
                THEN
                    BEGIN
                    (* PTS 1117498 E.Z. *)
                    a30_init_utility (acv, implicit_restart);
                    IF  a_return_segm^.sp1r_returncode = cak_e_released
                    THEN
                        BEGIN
                        (* PTS 1115978 E.Z. *)
                        a_in_session      := false;
                        vrestart (a_transinf.tri_trans.trTaskId_gg00,
                              hostn);
                        a_use_timeout    := true;
                        a94mode          := umUser_egg00;
                        END;
                    (*ENDIF*) 
                    END
                ELSE
                    BEGIN
                    a07_b_put_error (acv, e_user_not_connected, 1)
                    END
                (*ENDIF*) 
            ELSE
                IF  a94mode = umStandby_egg00
                THEN
                    BEGIN
                    a30_standby_utility(acv);
                    rc := a_return_segm^.sp1r_returncode;
                    a_in_session := NOT((rc = cak_e_released) OR
                          (rc = cak_e_roll_released) OR
                          (NOT a_in_session AND (rc <> 0)))
                    END
                ELSE
                    a92_reject (acv, c_utilityprocess)
                (*ENDIF*) 
            (*ENDIF*) 
        ELSE
            IF  (kw = cak_i_shutdown) AND NOT parse_or_ex
            THEN
                IF  a94mode = umUser_egg00
                THEN
                    IF  a_in_session
                    THEN
                        BEGIN
                        a01_init_command (acv);
                        a30_dbs_utility (acv, dummy);
                        (* PTS 1113359 UH 2001-01-14 *)
                        (* ++++++++++++++++++++++++++++++++++++++++++++++ *)
                        (* +++ The database is OFFLINE at this moment +++ *)
                        (* ++++++++++++++++++++++++++++++++++++++++++++++ *)
                        END
                    ELSE
                        BEGIN
                        a07_b_put_error (acv, e_user_not_connected, 1)
                        END
                    (*ENDIF*) 
                ELSE
                    a92_reject (acv, c_utilityprocess)
                (*ENDIF*) 
            ELSE
                IF  (a94mode = umUtility_egg00) AND NOT parse_or_ex
                THEN
                    BEGIN
                    (* PTS 1117498 E.Z. *)
                    a30_init_utility(acv, implicit_restart);
                    rc := a_return_segm^.sp1r_returncode;
                    IF  ((rc = cak_e_released) AND (kw = cak_i_restore))
                        OR
                        implicit_restart
                    THEN
                        BEGIN
                        (* PTS 1115978 E.Z. *)
                        a_in_session      := false;
                        vrestart (a_transinf.tri_trans.trTaskId_gg00,
                              hostn);
                        a_use_timeout    := true;
                        a94mode          := umUser_egg00;
                        END
                    ELSE
                        a_in_session := NOT((rc = cak_e_released) OR
                              (rc = cak_e_roll_released) OR
                              (NOT a_in_session AND (rc <> 0)))
                    (*ENDIF*) 
                    END
                ELSE
                    IF  a94mode = umUser_egg00
                    THEN
                        BEGIN
                        IF  NOT parse_or_ex
                        THEN
                            BEGIN
                            a30_dbs_utility (acv, syntax_error);
                            rc           := a_return_segm^.sp1r_returncode;
                            a_in_session := NOT
                                  (
                                  (rc = cak_e_released)            OR
                                  (rc = cak_e_roll_released)       OR
                                  (NOT a_in_session AND (rc <> 0)) OR
                                  (* PTS 1109783 E.Z. *)
                                  (
                                  ((a_return_segm^.sp1r_function_code = csp1_commit_release_fc) OR
                                  ( a_return_segm^.sp1r_function_code = csp1_rollback_release_fc))
                                  AND
                                  (a_cmd_segm^.sp1c_mess_type in [ sp1m_dbs, sp1m_execute ])
                                  )
                                  )
                            END
                        ELSE
                            syntax_error := true;
                        (*ENDIF*) 
                        IF  syntax_error AND
                            (a_cmd_segm^.sp1c_mess_type <> sp1m_utility)
                        THEN
                            BEGIN
                            a_restarted := true;
                            a_sysdir.ci_cmd_rollback_tree.fileRoot_gg00 :=
                                  NIL_PAGE_NO_GG00;
                            a_return_segm^.sp1r_returncode := 0;
                            (* PTS 1108254 E.Z. *)
                            a_uni_cmd_part := a_cmd_part;
                            a92_mode_analyzer (acv, no_ddl, NOT c_corr_select);
                            a_uni_cmd_part := NIL;
                            IF  a_in_internal_subtr
                            THEN
                                a52end_rollback_subtrans (acv,
                                      a01_il_b_identifier, m_end)
                            (*ENDIF*) 
                            END;
                        (*ENDIF*) 
                        END
                    (* PTS 1111229 E.Z. *)
                    ELSE
                        IF  (a94mode = umStandby_egg00) AND NOT parse_or_ex
                        THEN
                            BEGIN
                            a30_standby_utility(acv);
                            rc := a_return_segm^.sp1r_returncode;
                            a_in_session := NOT((rc = cak_e_released) OR
                                  (rc = cak_e_roll_released) OR
                                  (NOT a_in_session AND (rc <> 0)))
                            END
                        ELSE
                            a92_reject (acv, c_utilityprocess)
                        (*ENDIF*) 
                    (*ENDIF*) 
                (*ENDIF*) 
            (*ENDIF*) 
        (*ENDIF*) 
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak94one_command (VAR acv : tak_all_command_glob);
 
VAR
      mode : tgg_usemode;
 
BEGIN
WITH acv DO
    BEGIN
    IF  a_command_count < csp_maxint4
    THEN
        a_command_count := succ (a_command_count)
    ELSE
        BEGIN
        a10_cache_delete (acv, NOT c_is_rollback);
        a_command_count := 1
        END;
    (*ENDIF*) 
    IF  ((NOT a_restarted) AND (a94mode = umUser_egg00))
    THEN
        a_restarted := true;
    (*ENDIF*) 
    mode := a94mode;
    IF  a_cmd_segm^.sp1c_mess_type = sp1m_hello
    THEN
        BEGIN
        IF  NOT a_in_session
        THEN
            a_return_segm^.sp1r_returncode :=
                  a07_return_code (e_user_not_connected,
                  a_sqlmode)
        (*ENDIF*) 
        END
    ELSE
        IF  (mode = umUtility_egg00) OR
            (mode = umUser_egg00   ) OR
            (mode = umStandby_egg00)
        THEN
            BEGIN
            acv.a_uni_cmd_part := NIL;
            ak94mess_type_analysis (acv);
            IF  acv.a_uni_cmd_part <> NIL
            THEN
                BEGIN
                (* release unicode part *)
                a10dispose (acv, acv.a_uni_cmd_part);
                acv.a_cmd_part := @acv.a_cmd_segm^.sp1p_part
                END;
            (*ENDIF*) 
            END
        ELSE
            a92_reject (acv, c_utilityprocess);
        (*ENDIF*) 
    (*ENDIF*) 
&   ifdef TRACE
    t01int4 (ak_sem, 'a94_mode    ', ord(a94mode));
&   endif
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      a94_implicit_commands (VAR acv : tak_all_command_glob;
            utility_startup : tsp1_utility_startup);
 
VAR
      msg_label : tsp_c8;
 
BEGIN
WITH acv DO
    BEGIN
    a_in_session    := false;
    a_shared_result := false;
    a_union_append  := false;
    CASE utility_startup OF
        sp1us_restart :
            BEGIN
            msg_label := csp3_n_restart;
            ak94build_connect_cmd (acv);
            ak94implicit_command (acv);
            IF  a_out_packet^.sp1_segm.sp1r_returncode = 0
            THEN
                BEGIN
                ak94build_restart_cmd (acv);
                ak94implicit_command (acv)
                END;
            (*ENDIF*) 
            IF  a_out_packet^.sp1_segm.sp1r_returncode <> 0
            THEN
                g01opmsg (sp3p_syscon, sp3m_error,
                      csp3_a94_restart_failed,
                      msg_label, 'RESTART FAILED          ',
                      a_out_packet^.sp1_segm.sp1r_returncode);
            (*ENDIF*) 
            END;
        sp1us_shutdown :
            (* PTS 1106472 E.Z. *)
            IF  NOT g01is_livecache
            THEN
                BEGIN
                msg_label := csp3_n_shutdown;
                ak94build_connect_cmd (acv);
                ak94implicit_command (acv);
                IF  a_out_packet^.sp1_segm.sp1r_returncode = 0
                THEN
                    BEGIN
                    ak94build_shutdown_cmd (acv);
                    ak94implicit_command (acv)
                    END;
                (*ENDIF*) 
                IF  a_out_packet^.sp1_segm.sp1r_returncode <> 0
                THEN
                    g01opmsg (sp3p_syscon, sp3m_error,
                          csp3_a94_shutdown_failed,
                          msg_label, 'SHUTDOWN FAILED         ',
                          a_out_packet^.sp1_segm.sp1r_returncode);
                (*ENDIF*) 
                END;
            (*ENDIF*) 
        OTHERWISE
        END;
    (*ENDCASE*) 
    IF  a_in_session
    THEN
        BEGIN
        ak94build_release_cmd (acv);
        ak94implicit_command (acv);
        IF  a_out_packet^.sp1_segm.sp1r_returncode <> 0
        THEN
            g01opmsg (sp3p_syscon, sp3m_error,
                  csp3_a94_release_failed,
                  msg_label, 'RELEASE FAILED          ',
                  a_out_packet^.sp1_segm.sp1r_returncode);
        (*ENDIF*) 
        END;
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      a94_service_commands (VAR acv : tak_all_command_glob;
            VAR alloc_ok : boolean);
 
VAR
      found          : boolean;
      sending        : boolean;
      do_release     : boolean;
      e              : tgg_basis_error;
      timeout_value  : tsp_int4;
      microsec       : tsp_int4;
      last_command   : tsp_int4;
      blank_name     : tsp_knl_identifier;
      tr             : tsp_c1;
      ret_code       : tsp1_comm_error;
      retcode        : tsp1_comm_error;
 
BEGIN
vclock(last_command, microsec);
acv.a_in_session    := false;
(* the next initializations are necessary for migrate with *)
(* create view or things like that. Otherwise crashes      *)
acv.a_shared_result := false;
acv.a_union_append  := false;
sending    := false;
do_release := false;
WHILE NOT do_release DO
    WITH acv DO
        BEGIN
        IF  (NOT a_in_session
            OR (NOT a_use_timeout) OR (a94mode = umUtility_egg00))
        THEN
            timeout_value := 0
        ELSE
            timeout_value := g01timeout.timeCmd_gg00;
        (*ENDIF*) 
        a93vreceive (acv, timeout_value, alloc_ok, retcode);
        ret_code               := sp1ce_ok;
        a_in_internal_subtr    := false;
        a_rollback_info        := [  ];
        a_long_desc_pos        := 0;
        a_errpos_offset        := 0;
        a_user_defined_error   := false;
        a_statement_kind       := isql_commands;
        a_transinf.tri_trans.trRteCommPtr_gg00^.to_cancel := false;
        IF  retcode = sp1ce_ok
        THEN
            IF  a_return_segm^.sp1r_returncode <> 0
            THEN
                BEGIN
                do_release := true;
                a93_sending (acv, nil_start_time, nil_start_time, ret_code);
                a52free_caches (acv);
                END
            ELSE
                WITH a_in_packet^.sp1_header DO
                    BEGIN
                    IF  a_sysdir.ci_cache_p = NIL
                    THEN
                        a93init_caches (acv);
                    (*ENDIF*) 
                    IF  a_return_segm^.sp1r_returncode <> 0
                    THEN
                        retcode := sp1ce_notok
                    ELSE
                        IF  (sp1h_no_of_segm < 1)
                            OR
                            (NOT (sp1h_mess_code in [ csp_ascii, csp_ebcdic,
                            cgg_begin_termsets..cgg_end_termsets ]) AND
                            ((sp1h_mess_code <  csp_unicode_swap) OR
                            ( sp1h_mess_code >= csp_unicode + csp8_encodings)))
                        THEN
                            a92_reject (acv, NOT c_utilityprocess)
                        ELSE
                            BEGIN
                            a_mess_code := sp1h_mess_code;
                            (* PTS 1113268 E.Z. *)
                            IF  a_mess_code <> a_session_mess_code
                            THEN
                                BEGIN
                                IF  a_mess_code < csp_unicode_swap
                                THEN
                                    a_max_codewidth := 1
                                ELSE
                                    IF  a_mess_code <= csp_unicode
                                    THEN
                                        a_max_codewidth := 2
                                    (*ENDIF*) 
                                (*ENDIF*) 
                                END
                            ELSE
                                a_max_codewidth := a_session_max_codewidth;
                            (*ENDIF*) 
                            found       := true;
                            IF  (a_mess_code >= cgg_begin_termsets) AND
                                (a_mess_code <= cgg_end_termsets)
                            THEN
                                BEGIN
                                blank_name := a01_il_b_identifier;
                                g02gettermsetdesc (blank_name, a_mess_code,
                                      a_basic_code, found);
                                END
                            ELSE
                                a_basic_code := a_mess_code;
                            (*ENDIF*) 
                            IF  NOT found
                            THEN
                                a07_b_put_error (acv, e_invalid_messcodetype, 1);
                            (*ENDIF*) 
                            IF  g01vtrace.vtrAny_gg00
                            THEN
                                a93packet_vtrace (a_transinf.tri_trans,
                                      ak_receive, a_in_packet);
&                           ifdef TRACE
                            (*ENDIF*) 
                            t01packet (ak_syn, 'UTIL-TO-KERN', a_in_packet);
&                           endif
                            (* PTS 1107617 E.Z. *)
                            ak94one_command (acv);
                            IF  a_rollback_info <> []
                            THEN
                                a09rollback (acv, e);
                            (*ENDIF*) 
                            WITH a_return_segm^ DO
                                IF  (sp1r_returncode <> 0) AND
                                    (sp1r_returncode <> cak_e_released) AND
                                    (sp1r_returncode <> cak_e_roll_released)
                                    AND NOT a_user_defined_error
                                THEN
                                    a07_intern_error_put (acv);
                                (*ENDIF*) 
                            (*ENDWITH*) 
                            sending := true
                            END
                        (*ENDIF*) 
                    (*ENDIF*) 
                    END
                (*ENDWITH*) 
            (*ENDIF*) 
        ELSE
            IF  retcode = sp1ce_timeout
            THEN
                BEGIN
                IF  a_in_session
                THEN
                    ret_code := sp1ce_notok;
                (*ENDIF*) 
                END
            ELSE
                IF  g01vtrace.vtrAny_gg00
                THEN
                    BEGIN
                    tr[ 1 ] := chr(ord(retcode));
                    b120InsertTrace (a_transinf.tri_trans,
                          ak_receive_error, td_none, 1, @tr);
                    END;
                (*ENDIF*) 
            (*ENDIF*) 
        (*ENDIF*) 
        IF  sending
        THEN
            BEGIN
&           ifdef TRACE
            t01packet (ak_syn, 'KERN-TO-UTIL', a_out_packet);
&           endif
            a93_sending (acv, nil_start_time, nil_start_time, ret_code);
            IF  NOT a_in_session
            THEN
                BEGIN
                a_curr_user_name  := a01_il_b_identifier;
                a52free_caches (acv);
                a_acc_user        := a01_il_b_identifier;
                (* PTS 1115978 E.Z. *)
                a_transinf.tri_trans.trTransId_gg00.ci6_gg00 := cgg_zero_trans;
                do_release := true;
                END;
            (*ENDIF*) 
            sending := false
            END;
        (*ENDIF*) 
        IF  ((ret_code <> sp1ce_ok) OR
            (retcode = sp1ce_notok))
        THEN
            BEGIN
            do_release := true;
&           ifdef TRACE
            t01int4 (ak_sem, 'ret_code    ', ord(ret_code));
            t01int4 (ak_sem, 'retcode     ', ord(retcode));
&           endif
            IF  a_in_packet = NIL
            THEN
                ak94clear (acv, ret_code)
            ELSE
                ak94iclear (acv, ret_code);
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  ((NOT a_in_session) AND
            (((retcode <> sp1ce_timeout) AND
            (retcode <> sp1ce_ok)) OR (ret_code <> sp1ce_ok) OR
            ((retcode = sp1ce_timeout) AND
            (ret_code = sp1ce_notok))))
        THEN
            BEGIN
            a_curr_user_name := a01_il_b_identifier;
            a52free_caches (acv);
            a_acc_user := a01_il_b_identifier;
            (* PTS 1115978 E.Z. *)
            a_transinf.tri_trans.trTransId_gg00.ci6_gg00 := cgg_zero_trans;
            do_release := true
            END
        (*ENDIF*) 
        END
    (*ENDWITH*) 
(*ENDWHILE*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :        380
*-PRETTY-*  lines of code :       1065        PRETTYX 3.10 
*-PRETTY-*  lines in file :       1683         1997-12-10 
.PA 
