8000 More precise base types · postgres-haskell/postgres-wire@a299877 · GitHub
[go: up one dir, main page]

Skip to content

Commit a299877

Browse files
More precise base types
1 parent 2ee5703 commit a299877

File tree

1 file changed

+25
-18
lines changed
  • src/Database/PostgreSQL/Protocol

1 file changed

+25
-18
lines changed

src/Database/PostgreSQL/Protocol/Types.hs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,25 @@ import Data.Int
55
import qualified Data.ByteString as B
66
import qualified Data.Vector as V
77

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+
1624
-- String that identifies which SQL command was completed.
1725
-- should be more complex in future
26+
-- TODO
1827
type CommandTag = B.ByteString
1928

2029
data TransactionStatus
@@ -32,7 +41,7 @@ data Format = Text | Binary
3241
data AuthResponse
3342
= AuthenticationOk
3443
| AuthenticationCleartextPassword
35-
| AuthenticationMD5Password Word32
44+
| AuthenticationMD5Password MD5Salt
3645
| AuthenticationGSS
3746
| AuthenticationSSPI
3847
| AuthenticationGSSContinue B.ByteString
@@ -56,21 +65,15 @@ data ClientMessage
5665
| Parse StatementName StatementSQL (V.Vector Oid)
5766
-- TODO maybe distinguish plain passwords and encrypted
5867
| PasswordMessage PasswordText
59-
| Query StatementSQL
6068
| Sync
6169
| Terminate
6270
deriving (Show)
6371

64-
type Username = B.ByteString
65-
type DatabaseName = B.ByteString
66-
6772
data StartMessage
6873
= StartupMessage Username DatabaseName
6974
| SSLRequest
7075
deriving (Show)
7176

72-
73-
7477
data ServerMessage
7578
= BackendKeyData ServerProccessId ServerSecretKey
7679
| BindComplete
@@ -85,23 +88,26 @@ data ServerMessage
8588
| NoticeResponse (Maybe B.ByteString)
8689
| NotificationResponse
8790
ServerProccessId
88-
B.ByteString -- the name of the channel
91+
ChannelName
8992
B.ByteString -- payload - does not have structure
9093
| ParameterDescription (V.Vector Oid)
9194
-- parameter name and its value
95+
-- TODO improve
9296
| ParameterStatus B.ByteString B.ByteString
9397
| ParseComplete
9498
| PortalSuspended
9599
| ReadForQuery TransactionStatus
96100
| RowDescription (V.Vector FieldDescription)
97101
deriving (Show)
98102

99-
data FieldDescription = FieldDescription
100-
{ fieldName :: B.ByteString
103+
data FieldDescription = FieldDescription {
104+
-- the name
105+
fieldName :: B.ByteString
101106
-- the object ID of the table
102107
, fieldTableOid :: Oid
103108
-- the attribute number of the column;
104109
, fieldColumnNumber :: Int16
110+
-- Oid type
105111
, fieldTypeOid :: Oid
106112
-- The data type size (see pg_type.typlen). Note that negative
107113
-- values denote variable-width types.
@@ -124,4 +130,5 @@ data FieldDescription = FieldDescription
124130
-- * NOTICE bind command can have different formats for parameters and results
125131
-- but we assume that there will be one format for all. Maybe extend it in
126132
-- the future.
133+
-- * Simple query protocol is not supported
127134

0 commit comments

Comments
 (0)
0