@@ -17,56 +17,59 @@ currentVersion = 3 * 256 * 256
17
17
18
18
encodeStartMessage :: StartMessage -> Builder
19
19
-- Options except user and database are not supported
20
- encodeStartMessage (StartupMessage uname dbname) =
20
+ encodeStartMessage (StartupMessage ( Username uname) ( DatabaseName dbname) ) =
21
21
int32BE (len + 4 ) <> payload
22
22
where
23
23
len = fromIntegral $ BL. length $ toLazyByteString payload
24
24
payload = int32BE currentVersion <>
25
25
pgString " user" <> pgString uname <>
26
26
pgString " database" <> pgString dbname <> word8 0
27
+ -- TODO
27
28
encodeStartMessage SSLRequest = undefined
28
29
29
30
encodeClientMessage :: ClientMessage -> Builder
30
- encodeClientMessage (Bind portalName stmtName paramFormat values resultFormat)
31
+ encodeClientMessage (Bind (PortalName portalName) (StatementName stmtName)
32
+ paramFormat values resultFormat)
31
33
= prependHeader ' B' $
32
34
pgString portalName <>
33
35
pgString stmtName <>
34
- -- the specified format code is applied to all parameters
36
+ -- `1` means that the specified format code is applied to all parameters
35
37
int16BE 1 <>
36
38
encodeFormat paramFormat <>
37
39
int16BE (fromIntegral $ V. length values) <>
38
40
-- TODO -1 indicates a NULL parameter value. No value bytes
39
41
-- follow in the NULL case.
40
42
fold ((\ v -> int32BE (fromIntegral $ B. length v) <> byteString v)
41
43
<$> values) <>
42
- -- the specified format code is applied to all result columns (if any)
44
+ -- `1` means that the specified format code is applied to all
45
+ -- result columns (if any)
43
46
int16BE 1 <>
44
47
encodeFormat resultFormat
45
- encodeClientMessage (CloseStatement stmtName)
48
+ encodeClientMessage (CloseStatement ( StatementName stmtName) )
46
49
= prependHeader ' C' $ char8 ' S' <> pgString stmtName
47
- encodeClientMessage (ClosePortal portalName)
50
+ encodeClientMessage (ClosePortal ( PortalName portalName) )
48
51
= prependHeader ' C' $ char8 ' P' <> pgString portalName
49
- encodeClientMessage (DescribeStatement stmtName)
52
+ encodeClientMessage (DescribeStatement ( StatementName stmtName) )
50
53
= prependHeader ' D' $ char8 ' S' <> pgString stmtName
51
- encodeClientMessage (DescribePortal portalName)
54
+ encodeClientMessage (DescribePortal ( PortalName portalName) )
52
55
= prependHeader ' D' $ char8 ' P' <> pgString portalName
53
- encodeClientMessage (Execute portalName)
56
+ encodeClientMessage (Execute ( PortalName portalName) )
54
57
= prependHeader ' E' $
55
58
pgString portalName <>
56
59
-- Maximum number of rows to return, if portal contains a query that
57
60
-- returns rows (ignored otherwise). Zero denotes "no limit".
58
61
int32BE 0
59
62
encodeClientMessa
8000
ge Flush
60
63
= prependHeader ' H' mempty
61
- encodeClientMessage (Parse stmtName stmt oids)
64
+ encodeClientMessage (Parse ( StatementName stmtName) ( StatementSQL stmt) oids)
62
65
= prependHeader ' P' $
63
66
pgString stmtName <>
64
67
pgString stmt <>
65
68
int16BE (fromIntegral $ V. length oids) <>
66
- fold (int32BE <$> oids)
67
- encodeClientMessage (PasswordMessage passText)
69
+ fold (int32BE . unOid <$> oids)
70
+ encodeClientMessage (PasswordMessage ( PasswordText passText) )
68
71
= prependHeader ' p' $ pgString passText
69
- encodeClientMessage (Query stmt)
72
+ encodeClientMessage (SimpleQuery ( StatementSQL stmt) )
70
73
= prependHeader ' Q' $ pgString stmt
71
74
encodeClientMessage Sync
72
75
= prependHeader ' S' mempty
0 commit comments