-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostgres.go
59 lines (50 loc) · 1.46 KB
/
postgres.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import "encoding/json"
type FieldDescription struct {
Name []byte
TableOID uint32
TableAttributeNumber uint16
DataTypeOID uint32
DataTypeSize int16
TypeModifier int32
Format int16
}
type MessageType byte
const (
MessageTypeTerminate MessageType = 'X'
MessageTypeSimpleQuery MessageType = 'Q'
)
type StartupMessageType uint32
const (
SSLNegotiationStartupMessageType StartupMessageType = 80877103
StartupMessage StartupMessageType = 196608
)
// MarshalJSON implements encoding/json.Marshaler.
func (fd FieldDescription) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
Name string
TableOID uint32
TableAttributeNumber uint16
DataTypeOID uint32
DataTypeSize int16
TypeModifier int32
Format int16
}{
Name: string(fd.Name),
TableOID: fd.TableOID,
TableAttributeNumber: fd.TableAttributeNumber,
DataTypeOID: fd.DataTypeOID,
DataTypeSize: fd.DataTypeSize,
TypeModifier: fd.TypeModifier,
Format: fd.Format,
})
}
type QueryType string
const (
QueryTypeSelect QueryType = "select"
QueryTypeInsert QueryType = "insert"
QueryTypeUpdate QueryType = "update"
QueryTypeDelete QueryType = "delete"
QueryTypeCreateTable QueryType = "create table"
QueryTypeInvalid QueryType = "invalid"
)