_site/cover/pgmp.COVER.html

1 %% Copyright (c) 2022 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(pgmp).
17
18
19 -export([get_env/1]).
20 -export([priv_consult/1]).
21 -export([priv_dir/0]).
22 -export([start/0]).
23 -export_type([bind_complete/0]).
24 -export_type([command_complete/0]).
25 -export_type([data_row/0]).
26 -export_type([describe_row_description/0]).
27 -export_type([error_response/0]).
28 -export_type([int/0]).
29 -export_type([int16/0]).
30 -export_type([int32/0]).
31 -export_type([int64/0]).
32 -export_type([int8/0]).
33 -export_type([int_bit_sizes/0]).
34 -export_type([oid/0]).
35 -export_type([parameter_description/0]).
36 -export_type([parameters/0]).
37 -export_type([parse_complete/0]).
38 -export_type([portal_suspended/0]).
39 -export_type([row_description/0]).
40 -export_type([uint16/0]).
41 -export_type([uint32/0]).
42 -export_type([uint64/0]).
43 -export_type([uint8/0]).
44
45 -type int_bit_sizes() :: 8 | 16 | 32 | 64.
46
47
48 -type int() :: {int, int_bit_sizes()}.
49
50 -type int8() :: -128..127.
51 -type int16() :: -32_768..32_767.
52 -type int32() :: -2_147_483_648..2_147_483_647.
53 -type int64() :: -9_223_372_036_854_775_808..9_223_372_036_854_775_807.
54
55
56 -type uint8() :: 0..255.
57 -type uint16() :: 0..65_535.
58 -type uint32() :: 0..4_294_967_295.
59 -type uint64() :: 0..18_446_744_073_709_551_615.
60
61 -type oid() :: uint32().
62
63 -type parameters() :: #{binary() => binary()}.
64
65
66 -type format() :: text | binary.
67
68 -type describe_row_description() :: {row_description,
69 [#{column_number => non_neg_integer(),
70 field_name => binary(),
71 format => format(),
72 table_oid => non_neg_integer(),
73 type_modifier => integer(),
74 type_oid => oid(),
75 type_size => integer()}]}.
76
77 -type parameter_description() :: {parameter_description, [oid()]}.
78
79 -type column_name() :: binary().
80 -type row_description() :: {row_description, [column_name()]}.
81 -type column_value() :: pgmp_data_row:decoded().
82 -type data_row() :: {data_row, [column_value()]}.
83 -type command_complete() :: {command_complete, atom() | {atom(), integer()}}.
84
85 -type parse_complete() :: {parse_complete, []}.
86 -type bind_complete() :: {bind_complete, []}.
87 -type portal_suspended() :: {portal_suspended, []}.
88
89 -type error_severity() :: error | fatal | panic.
90 -type error_response() :: {error, term()}
91 | {error_response,
92 #{code := binary(),
93 file_name := binary(),
94 line := integer(),
95 message := binary(),
96 position := integer(),
97 routine := binary(),
98 severity := error_severity(),
99 severity_localized := binary()}}.
100
101
102 start() ->
103 10 application:ensure_all_started(?MODULE).
104
105
106 priv_dir() ->
107 21 code:priv_dir(?MODULE).
108
109
110 get_env(Par) ->
111 61 application:get_env(?MODULE, Par).
112
113
114 priv_consult(Filename) ->
115 21 phrase_file:consult(filename:join(priv_dir(), Filename)).
Line Hits Source