MCPcopy
hub / github.com/dropbox/godropbox / parseRowsHeader

Method parseRowsHeader

database/binlog/rows_event.go:205–262  ·  view source on GitHub ↗
(raw *RawV4Event)

Source from the content-addressed store, hash-verified

203}
204
205func (p *baseRowsEventParser) parseRowsHeader(raw *RawV4Event) (
206 id uint64,
207 flags uint16,
208 extraInfo []byte,
209 width int,
210 remaining []byte,
211 err error) {
212
213 if p.context == nil {
214 return 0, 0, nil, 0, nil, &TableContextNotSetError{
215 errors.New("Table context not set"),
216 }
217 }
218
219 data := raw.FixedLengthData()
220
221 id = LittleEndian.Uint48(data)
222
223 if id != p.context.TableId() {
224 return 0, 0, nil, 0, nil, errors.Newf(
225 "mismatch table id (event: %d; context: %d name: %s)",
226 id,
227 p.context.TableId(),
228 p.context.TableName())
229 }
230
231 flags = LittleEndian.Uint16(data[6:])
232
233 remaining = raw.VariableLengthData()
234
235 if p.version == mysql_proto.RowsEventVersion_V1 {
236 extraInfo = nil
237 } else {
238 extraInfoBlobLen := LittleEndian.Uint16(data[8:])
239 extraInfo, remaining, err = p.parseExtraInfoBlob(
240 extraInfoBlobLen,
241 remaining)
242 if err != nil {
243 return 0, 0, nil, 0, nil, err
244 }
245 }
246
247 w, remaining, err := readFieldLength(remaining)
248 if err != nil {
249 return 0, 0, nil, 0, nil, err
250 }
251
252 if w > uint64(p.context.NumColumns()) {
253 return 0, 0, nil, 0, nil, errors.Newf(
254 "row width (%d / %d) greater than # of columns (%d) in table %s",
255 w,
256 width,
257 p.context.NumColumns(),
258 string(p.context.TableName()))
259 }
260
261 return id, flags, extraInfo, int(w), remaining, nil
262}

Callers 3

ParseMethod · 0.80
ParseMethod · 0.80
ParseMethod · 0.80

Calls 10

parseExtraInfoBlobMethod · 0.95
NewFunction · 0.92
NewfFunction · 0.92
readFieldLengthFunction · 0.85
FixedLengthDataMethod · 0.65
TableIdMethod · 0.65
TableNameMethod · 0.65
VariableLengthDataMethod · 0.65
NumColumnsMethod · 0.65
Uint48Method · 0.45

Tested by

no test coverage detected