8000 Connection parameters · postgres-haskell/postgres-wire@f35b7b7 · GitHub
[go: up one dir, main page]

Skip to content

Commit f35b7b7

Browse files
Connection parameters
1 parent a299877 commit f35b7b7

File tree

1 file changed

+21
-5
lines changed
  • src/Database/PostgreSQL/Protocol

1 file changed

+21
-5
lines changed

src/Database/PostgreSQL/Protocol/Types.hs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Database.PostgreSQL.Protocol.Types where
22

3-
import Data.Word
4-
import Data.Int
3+
import Data.Word (Word32, Word8)
4+
import Data.Int (Int32)
55
import qualified Data.ByteString as B
66
import qualified Data.Vector as V
77

@@ -26,6 +26,22 @@ newtype ServerSecretKey = ServerSecrecKey Int32 deriving (Show)
2626
-- TODO
2727
type CommandTag = B.ByteString
2828

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+
2945
data TransactionStatus
3046
= TransactionIdle
3147
| TransactionInProgress
@@ -37,13 +53,13 @@ data Format = Text | Binary
3753

3854
-- All the commands have the same names as presented in the official
3955
-- postgres documentation except explicit exclusions
40-
-- TODO improve
4156
data AuthResponse
4257
= AuthenticationOk
4358
| AuthenticationCleartextPassword
4459
| AuthenticationMD5Password MD5Salt
4560
| AuthenticationGSS
4661
| AuthenticationSSPI
62+
-- TODO improve
4763
| AuthenticationGSSContinue B.ByteString
4864
deriving (Show)
4965

@@ -128,7 +144,7 @@ data FieldDescription = FieldDescription {
128144
-- * NOTICE execute command can have number of rows to receive, but we
129145
-- dont support this feature
130146
-- * 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.
133148
-- * Simple query protocol is not supported
149+
-- * We dont store parameters of connection that may change after startup
134150

0 commit comments

Comments
 (0)
0