@@ -5,16 +5,25 @@ import Data.Int
5
5
import qualified Data.ByteString as B
6
6
import qualified Data.Vector as V
7
7
8
- type PortalName = B. ByteString
9
- type StatementName = B. ByteString
10
- type Oid = Int32
11
- -- maybe distinguish sql for extended query and simple query
12
- type StatementSQL = B. ByteString
13
- type PasswordText = B. ByteString
14
- type ServerProccessId = Int32
15
- type ServerSecretKey = Int32
8
+ -- Common
9
+ newtype Oid = Oid Int32 deriving (Show )
10
+ newtype StatementName = StatementName B. ByteString deriving (Show )
11
+ newtype StatementSQL = StatementSQL B. ByteString deriving (Show )
12
+ newtype PortalName = PortalName B. ByteString deriving (Show )
13
+ newtype ChannelName = ChannelName B. ByteString deriving (Show )
14
+
15
+ -- Startup phase
16
+ newtype Username = Username B. ByteString deriving (Show )
17
+ newtype DatabaseName = DatabaseName B. ByteString deriving (Show )
18
+ newtype PasswordText = PasswordText B. ByteString deriving (Show )
19
+ newtype MD5Salt = MD5Salt Word32 deriving (Show )
20
+
21
+ newtype ServerProccessId = ServerProcessId Int32 deriving (Show )
22
+ newtype ServerSecretKey = ServerSecrecKey Int32 deriving (Show )
23
+
16
24
-- String that identifies which SQL command was completed.
17
25
-- should be more complex in future
26
+ -- TODO
18
27
type CommandTag = B. ByteString
19
28
20
29
data TransactionStatus
@@ -32,7 +41,7 @@ data Format = Text | Binary
32
41
data AuthResponse
33
42
= AuthenticationOk
34
43
| AuthenticationCleartextPassword
35
- | AuthenticationMD5Password Word32
44
+ | AuthenticationMD5Password MD5Salt
36
45
| AuthenticationGSS
37
46
| AuthenticationSSPI
38
47
| AuthenticationGSSContinue B. ByteString
@@ -56,21 +65,15 @@ data ClientMessage
56
65
| Parse StatementName StatementSQL (V. Vector Oid )
57
66
-- TODO maybe distinguish plain passwords and encrypted
58
67
| PasswordMessage PasswordText
59
- | Query StatementSQL
60
68
| Sync
61
69
| Terminate
62
70
deriving (Show )
63
71
64
- type Username = B. ByteString
65
- type DatabaseName = B. ByteString
66
-
67
72
data StartMessage
68
73
= StartupMessage Username DatabaseName
69
74
| SSLRequest
70
75
deriving (Show )
71
76
72
-
73
-
74
77
data ServerMessage
75
78
= BackendKeyData ServerProccessId ServerSecretKey
76
79
| BindComplete
@@ -85,23 +88,26 @@ data ServerMessage
85
88
| NoticeResponse (Maybe B. ByteString )
86
89
| NotificationResponse
87
90
ServerProccessId
88
- B. ByteString -- the name of the channel
91
+ ChannelName
89
92
B. ByteString -- payload - does not have structure
90
93
| ParameterDescription (V. Vector Oid )
91
94
-- parameter name and its value
95
+ -- TODO improve
92
96
| ParameterStatus B. ByteString B. ByteString
93
97
| ParseComplete
94
98
| PortalSuspended
95
99
| ReadForQuery TransactionStatus
96
100
| RowDescription (V. Vector FieldDescription )
97
101
deriving (Show )
98
102
99
- data FieldDescription = FieldDescription
100
- { fieldName :: B. ByteString
103
+ data FieldDescription = FieldDescription {
104
+ -- the name
105
+ fieldName :: B. ByteString
101
106
-- the object ID of the table
102
107
, fieldTableOid :: Oid
103
108
-- the attribute number of the column;
104
109
, fieldColumnNumber :: Int16
110
+ -- Oid type
105
111
, fieldTypeOid :: Oid
106
112
-- The data type size (see pg_type.typlen). Note that negative
107
113
-- values denote variable-width types.
@@ -124,4 +130,5 @@ data FieldDescription = FieldDescription
124
130
-- * NOTICE bind command can have different formats for parameters and results
125
131
-- but we assume that there will be one format for all. Maybe extend it in
126
132
-- the future.
133
+ -- * Simple query protocol is not supported
127
134
0 commit comments