| 370 | } |
| 371 | |
| 372 | func GetXLogRecordData() (walparser.XLogRecord, []byte) { |
| 373 | imageData := []byte{ |
| 374 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, |
| 375 | } |
| 376 | blockData := []byte{ |
| 377 | 0x0a, 0x0b, 0x0c, |
| 378 | } |
| 379 | mainData := []byte{ |
| 380 | 0x0d, 0x0e, 0x0f, 0x10, |
| 381 | } |
| 382 | data := []byte{ // block header data |
| 383 | 0xfd, 0x01, 0xfe, |
| 384 | 0x00, 0x30, 0x03, 0x00, 0x0a, 0x00, 0xd4, 0x05, 0x05, 0x7f, 0x06, 0x00, 0x00, 0x00, 0x40, |
| 385 | 0x00, 0x00, 0x15, 0x40, 0x00, 0x00, 0xe4, 0x18, 0x00, 0x00, |
| 386 | 0xff, 0x04, |
| 387 | } |
| 388 | data = utility.ConcatByteSlices(data, imageData, blockData, mainData) |
| 389 | recordHeader := walparser.XLogRecordHeader{ |
| 390 | TotalRecordLength: uint32(walparser.XLogRecordHeaderSize + len(data)), |
| 391 | XactID: 0x00000243, |
| 392 | PrevRecordPtr: 0x000000002affedc8, |
| 393 | Info: 0xb0, |
| 394 | ResourceManagerID: 0x00, |
| 395 | Crc32Hash: 0xecf5203c, |
| 396 | } |
| 397 | var recordHeaderData bytes.Buffer |
| 398 | recordHeaderData.Write(utility.ToBytes(&recordHeader.TotalRecordLength)) |
| 399 | recordHeaderData.Write(utility.ToBytes(&recordHeader.XactID)) |
| 400 | recordHeaderData.Write(utility.ToBytes(&recordHeader.PrevRecordPtr)) |
| 401 | recordHeaderData.Write(utility.ToBytes(&recordHeader.Info)) |
| 402 | recordHeaderData.Write(utility.ToBytes(&recordHeader.ResourceManagerID)) |
| 403 | recordHeaderData.Write([]byte{0, 0}) |
| 404 | recordHeaderData.Write(utility.ToBytes(&recordHeader.Crc32Hash)) |
| 405 | recordData := utility.ConcatByteSlices(recordHeaderData.Bytes(), data) |
| 406 | record, _ := walparser.ParseXLogRecordFromBytes(recordData) |
| 407 | return *record, recordData |
| 408 | } |
| 409 | |
| 410 | func serializeXLogPageHeader(pageHeader walparser.XLogPageHeader) []byte { |
| 411 | buf := new(bytes.Buffer) |