1
1
module Database.PostgreSQL.Protocol.Types where
2
2
3
- import Data.Word
4
- import Data.Int
3
+ import Data.Word ( Word32 , Word8 )
4
+ import Data.Int ( Int32 )
5
5
import qualified Data.ByteString as B
6
6
import qualified Data.Vector as V
7
7
@@ -26,6 +26,22 @@ newtype ServerSecretKey = ServerSecrecKey Int32 deriving (Show)
26
26
-- TODO
27
27
type CommandTag = B. ByteString
28
28
29
+ -- | Parameters of the current connection.
30
+ -- We store only the parameters that cannot change after startup.
31
+ -- For more information about additional parameters see documentation.
32
+ data ConnectionParameters = ConnectionParameters
33
+ { paramServerVersion :: ServerVersion
34
+ , paramServerEncoding :: B. ByteString -- ^ character set name
35
+ , paramIntegerDatetimes :: Bool -- ^ True if integer datetimes used
36
+ } deriving (Show )
37
+
38
+ -- | Server version contains major, minor, revision numbers.
39
+ data ServerVersion = ServerVersion Word8 Word8 Word8
40
+
41
+ instance Show ServerVersion where
42
+ show (ServerVersion major minor revision) =
43
+ show major ++ " ." ++ show minor ++ " ." ++ show revision
44
+
29
45
data TransactionStatus
30
46
= TransactionIdle
31
47
| TransactionInProgress
@@ -37,13 +53,13 @@ data Format = Text | Binary
37
53
38
54
-- All the commands have the same names as presented in the official
39
55
-- postgres documentation except explicit exclusions
40
- -- TODO improve
41
56
data AuthResponse
42
57
= AuthenticationOk
43
58
| AuthenticationCleartextPassword
44
59
| AuthenticationMD5Password MD5Salt
45
60
| AuthenticationGSS
46
61
| AuthenticationSSPI
62
+ -- TODO improve
47
63
| AuthenticationGSSContinue B. ByteString
48
64
deriving (Show )
49
65
@@ -128,7 +144,7 @@ data FieldDescription = FieldDescription {
128
144
-- * NOTICE execute command can have number of rows to receive, but we
129
145
-- dont support this feature
130
146
-- * NOTICE bind command can have different formats for parameters and results
131
- -- but we assume that there will be one format for all. Maybe extend it in
132
- -- the future.
147
+ -- but we assume that there will be one format for all.
133
148
-- * Simple query protocol is not supported
149
+ -- * We dont store parameters of connection that may change after startup
134
150
0 commit comments