File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,13 @@ type Relation struct {
129129 Columns []Column
130130}
131131
132+ type Type struct {
133+ // ID of the data type
134+ ID uint32
135+ Namespace string
136+ Name string
137+ }
138+
132139type Insert struct {
133140 /// ID of the relation corresponding to the ID in the relation message.
134141 RelationID uint32
@@ -189,7 +196,10 @@ func (Insert) msg() {}
189196func (Delete ) msg () {}
190197func (Commit ) msg () {}
191198func (Origin ) msg () {}
199+ func (Type ) msg () {}
192200
201+ // Parse a logical replication message.
202+ // See https://www.postgresql.org/docs/current/static/protocol-logicalrep-message-formats.html
193203func Parse (src []byte ) (Message , error ) {
194204 msgType := src [0 ]
195205 d := & decoder {order : binary .BigEndian , buf : bytes .NewBuffer (src [1 :])}
@@ -220,6 +230,12 @@ func Parse(src []byte) (Message, error) {
220230 r .Replica = d .uint8 ()
221231 r .Columns = d .columns ()
222232 return r , nil
233+ case 'Y' :
234+ t := Type {}
235+ t .ID = d .uint32 ()
236+ t .Namespace = d .string ()
237+ t .Name = d .string ()
238+ return t , nil
223239 case 'I' :
224240 i := Insert {}
225241 i .RelationID = d .uint32 ()
Original file line number Diff line number Diff line change @@ -88,6 +88,16 @@ func TestParseWalData(t *testing.T) {
8888 t .Errorf ("val: %s" , diff )
8989 }
9090 })
91+ case Type :
92+ if v .ID != 35756 {
93+ t .Errorf ("Type OID: %d" , v .ID )
94+ }
95+ if v .Namespace != "public" {
96+ t .Errorf ("Type namespace: %s" , v .Namespace )
97+ }
98+ if v .Name != "ticket_state" {
99+ t .Errorf ("Type name: %s" , v .Name )
100+ }
91101 }
92102 }
93103}
You can’t perform that action at this time.
0 commit comments