|
| 1 | +module Database.PostgreSQL.Protocol.Types where |
| 2 | + |
| 3 | +import Data.Word |
| 4 | +import qualified Data.ByteString as B |
| 5 | +import qualified Data.Vector as V |
| 6 | + |
| 7 | +type PortalName = B.ByteString |
| 8 | +type StatementName = B.ByteString |
| 9 | +type Oid = Word32 |
| 10 | +type TransactionStatus = Word8 |
| 11 | + |
| 12 | +data Format = Text | Binary |
| 13 | + |
| 14 | +data AuthResponse |
| 15 | + = AuthenticationOk |
| 16 | + | AuthenticationKerberosV5 |
| 17 | + | AuthenticationCleartextPassword |
| 18 | + | AuthenticationMD5Password Word32 |
| 19 | + | AuthenticationSCMCredential |
| 20 | + | AuthenticationGSS |
| 21 | + | AuthenticationSSPI |
| 22 | + | AuthenticationGSSContinue B.ByteString |
| 23 | + |
| 24 | +data ClientMessage |
| 25 | + = Bind PortalName StatementName (V.Vector Format) (V.Vector B.ByteString) |
| 26 | + (V.Vector Format) |
| 27 | + -- TODO |
| 28 | + -- | CancelRequest |
| 29 | + | Close B.ByteString |
| 30 | + | Describe B.ByteString |
| 31 | + | Execute PortalName Word32 |
| 32 | + | Flush |
| 33 | + | Parse StatementName B.ByteString (V.Vector Oid) |
| 34 | + | PasswordMessage B.ByteString |
| 35 | + | Query B.ByteString |
| 36 | + | Sync |
| 37 | + | Terminate |
| 38 | + -- TODO function call |
| 39 | + |
| 40 | +data StartMessage |
| 41 | + = StartupMessage ProtocolVersion B.ByteString |
| 42 | + | SSLRequest |
| 43 | + |
| 44 | + |
| 45 | +-- TODO COPY subprotocol commands |
| 46 | + |
| 47 | +data ServerMessage |
| 48 | + = BackendKeyData Word32 |
| 49 | + | BindComplete |
| 50 | + | CloseComplete |
| 51 | + | CommandComplete B.ByteString |
| 52 | + | DataRow B.ByteString |
| 53 | + | EmptyQueryResponse |
| 54 | + | ErrorResponse (Maybe B.ByteString) |
| 55 | + | NoData |
| 56 | + | NoticeResponse (Maybe B.ByteString) |
| 57 | + | NotificationResponse Word32 B.ByteString B.ByteString |
| 58 | + | ParameterDescription (V.Vector Oid) |
| 59 | + | ParameterStatus B.ByteString B.ByteString |
| 60 | + | ParseComplete |
| 61 | + | PortalSuspended |
| 62 | + | ReadForQuery TransactionStatus |
| 63 | + | RowDescription (V.Vector FieldDescription) |
| 64 | + deriving (Show) |
| 65 | + |
| 66 | +data FieldDescription = FieldDescription |
| 67 | + { fieldName :: B.ByteString |
| 68 | + , fieldTableOid :: Oid |
| 69 | + , fieldColumnNumber :: Word16 |
| 70 | + , fieldTypeOid :: Oid |
| 71 | + , fieldSize :: Word16 |
| 72 | + , fieldMode :: Word32 |
| 73 | + , fieldFormat :: Format |
| 74 | + } deriving (Show) |
| 75 | + |
0 commit comments