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 |
|
|
16 |
|
-module(msmp_column_definition). |
17 |
|
|
18 |
|
|
19 |
|
-feature(maybe_expr, enable). |
20 |
|
|
21 |
|
|
22 |
|
-export([decode/0]). |
23 |
|
-include_lib("kernel/include/logger.hrl"). |
24 |
|
|
25 |
|
|
26 |
|
decode() -> |
27 |
3 |
fun |
28 |
|
(Input) -> |
29 |
3 |
?LOG_DEBUG(#{input => Input}), |
30 |
|
|
31 |
3 |
(scran_result:into_map( |
32 |
|
scran_sequence:sequence( |
33 |
|
[scran_result:kv( |
34 |
|
catalog, |
35 |
|
msmp_string_length_encoded:decode()), |
36 |
|
scran_result:kv( |
37 |
|
schema, |
38 |
|
msmp_string_length_encoded:decode()), |
39 |
|
scran_result:kv( |
40 |
|
table, |
41 |
|
msmp_string_length_encoded:decode()), |
42 |
|
scran_result:kv( |
43 |
|
org_table, |
44 |
|
msmp_string_length_encoded:decode()), |
45 |
|
scran_result:kv( |
46 |
|
name, |
47 |
|
msmp_string_length_encoded:decode()), |
48 |
|
scran_result:kv( |
49 |
|
org_name, |
50 |
|
msmp_string_length_encoded:decode()), |
51 |
|
scran_result:kv( |
52 |
|
length_of_fixed_length_fields, |
53 |
|
msmp_integer_variable:decode()), |
54 |
|
scran_result:kv( |
55 |
|
character_set, |
56 |
|
msmp_integer_fixed:decode(2)), |
57 |
|
scran_result:kv( |
58 |
|
column_length, |
59 |
|
msmp_integer_fixed:decode(4)), |
60 |
|
scran_result:kv( |
61 |
|
type, |
62 |
|
scran_combinator:map_result( |
63 |
|
msmp_integer_fixed:decode(1), |
64 |
|
fun msmp_field:lookup/1)), |
65 |
|
scran_result:kv( |
66 |
|
flags, |
67 |
|
scran_combinator:map_result( |
68 |
|
msmp_integer_fixed:decode(2), |
69 |
|
fun msmp_column_definition_flags:decode/1)), |
70 |
|
scran_result:kv( |
71 |
|
decimals, |
72 |
|
msmp_integer_fixed:decode(1)), |
73 |
|
scran_result:kv( |
74 |
|
reserved0, |
75 |
|
scran_bytes:take(2)), |
76 |
|
scran_result:kv( |
77 |
|
action, |
78 |
|
scran_combinator:value( |
79 |
|
column_definition, |
80 |
|
scran_combinator:eof()))])))(Input) |
81 |
|
end. |