Index: trunk/tools/trainwreck/trainwreck.c |
— | — | @@ -666,14 +666,20 @@ |
667 | 667 | |
668 | 668 | case ET_INTVAR: |
669 | 669 | /* |
| 670 | + * 1: id type |
670 | 671 | * 8 bytes: next INSERT_ID |
671 | 672 | */ |
672 | | - if (len < 8) { |
| 673 | + if (len < 9) { |
673 | 674 | logmsg("binlog is truncated"); |
674 | 675 | goto err; |
675 | 676 | } |
676 | 677 | |
| 678 | + ADVANCE(1); |
677 | 679 | ent->le_insert_id = uint8korr(buf); |
| 680 | + |
| 681 | + if (debug) |
| 682 | + printf("got intvar: %llu (%llx)\n", (unsigned long long) ent->le_insert_id, |
| 683 | + (unsigned long long) ent->le_insert_id); |
678 | 684 | return ent; |
679 | 685 | |
680 | 686 | default: |
— | — | @@ -998,6 +1004,15 @@ |
999 | 1005 | if ((rstat = open(sname, O_RDONLY)) == -1) { |
1000 | 1006 | logmsg("cannot open state file \"%s\": %s", |
1001 | 1007 | sname, strerror(errno)); |
| 1008 | + /* |
| 1009 | + * Use the binlog position specified on command line. |
| 1010 | + */ |
| 1011 | + writer->wr_last_executed_pos = binlog_pos; |
| 1012 | + strdup_free(&writer->wr_last_executed_file, binlog_file); |
| 1013 | + pthread_mutex_lock(&rst_mtx); |
| 1014 | + if (lowest_log_pos == 0 || writer->wr_last_executed_pos < lowest_log_pos) |
| 1015 | + lowest_log_pos = writer->wr_last_executed_pos; |
| 1016 | + pthread_mutex_unlock(&rst_mtx); |
1002 | 1017 | if (errno == ENOENT) |
1003 | 1018 | return 1; |
1004 | 1019 | exit(1); |