_site/cover/msc_mm_stmt_close.COVER.html

1 %% Copyright (c) 2023 Peter Morgan <peter.james.morgan@gmail.com>
2 %%
3 %% Licensed under the Apache License, Version 2.0 (the "License");
4 %% you may not use this file except in compliance with the License.
5 %% You may obtain a copy of the License at
6 %%
7 %% http://www.apache.org/licenses/LICENSE-2.0
8 %%
9 %% Unless required by applicable law or agreed to in writing, software
10 %% distributed under the License is distributed on an "AS IS" BASIS,
11 %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 %% See the License for the specific language governing permissions and
13 %% limitations under the License.
14
15 %% @doc Middleman dealing with the query process.
16
17 -module(msc_mm_stmt_close).
18
19
20 -export([callback_mode/0]).
21 -export([handle_event/4]).
22 -import(msc_statem, [nei/1]).
23 -include_lib("kernel/include/logger.hrl").
24
25
26 callback_mode() ->
27 2 handle_event_function.
28
29
30 handle_event({call, From},
31 {request, #{action := stmt_close,
32 statement_id := StatementId} = Packet},
33 {stmt_close, From},
34 #{client_flags := ClientFlags,
35 prepared := Prepared} = Data)
36 when is_map_key(StatementId, Prepared) ->
37 2 {next_state,
38 authenticated,
39 Data#{decoder := msmp_codec:decode(
40 scran_branch:alt(
41 [msmp_packet_error:decode(ClientFlags)])),
42 prepared := maps:without([StatementId], Prepared),
43 encoder := msmp_codec:encode(
44 msmp_com_stmt_close:encode(ClientFlags))},
45 [pop_callback_module,
46 {reply, From, ok},
47 nei({send, #{packet => Packet, sequence => 0}})]};
48
49 handle_event(EventType, EventContent, State, Data) ->
50
:-(
msc_mm_common:handle_event(EventType,
51 EventContent,
52 State,
53 Data).
Line Hits Source