mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 03:51:50 +01:00
New logformat code can now dump our base test. Addresses #11.
git-svn-id: file:///svn/tokudb@725 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
adba557e9f
commit
e50a0fb140
6 changed files with 55 additions and 18 deletions
|
@ -40,6 +40,10 @@ struct tokutxn {
|
|||
|
||||
int tokulogger_finish (TOKULOGGER logger, struct wbuf *wbuf);
|
||||
|
||||
static inline int toku_logsizeof_u_int8_t (u_int32_t v __attribute__((__unused__))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int toku_logsizeof_u_int32_t (u_int32_t v __attribute__((__unused__))) {
|
||||
return 4;
|
||||
}
|
||||
|
|
13
newbrt/log.c
13
newbrt/log.c
|
@ -512,6 +512,19 @@ int toku_logprint_TXNID (FILE *outf, FILE *inf, const char *fieldname, u_int32_t
|
|||
fprintf(outf, " %s=%lld", fieldname, v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int toku_logprint_u_int8_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len) {
|
||||
u_int8_t v;
|
||||
int r = toku_fread_u_int8_t(inf, &v, crc, len);
|
||||
if (r!=0) return r;
|
||||
fprintf(outf, " %s=%d", fieldname, v);
|
||||
if (v=='\'') fprintf(outf, "('\'')");
|
||||
else if (isprint(v)) fprintf(outf, "('%c')", v);
|
||||
else {}/*nothing*/
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len) {
|
||||
u_int32_t v;
|
||||
int r = toku_fread_u_int32_t(inf, &v, crc, len);
|
||||
|
|
|
@ -28,6 +28,8 @@ int tokulogger_log_newbrtnode (TOKUTXN txn, FILENUM filenum, DISKOFF offset, u_i
|
|||
|
||||
int tokulogger_fsync (TOKULOGGER logger);
|
||||
|
||||
int toku_fread_u_int8_t (FILE *f, u_int8_t *v, u_int32_t *crc, u_int32_t *len);
|
||||
|
||||
int toku_fread_u_int32_t_nocrclen (FILE *f, u_int32_t *v);
|
||||
int toku_fread_u_int32_t (FILE *f, u_int32_t *v, u_int32_t *crc, u_int32_t *len);
|
||||
int toku_fread_LSN (FILE *f, LSN *lsn, u_int32_t *crc, u_int32_t *len);
|
||||
|
@ -43,6 +45,7 @@ int toku_logprint_TXNID (FILE *outf, FILE *inf, const char *fieldname,
|
|||
int toku_logprint_BYTESTRING (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
|
||||
int toku_logprint_FILENUM (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
|
||||
int toku_logprint_DISKOFF (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
|
||||
int toku_logprint_u_int8_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
|
||||
int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
|
||||
int toku_logprint_LOGGEDBRTHEADER (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
|
||||
|
||||
|
|
|
@ -141,33 +141,23 @@ void read_and_print_magic (void) {
|
|||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
int main (int argc, char *argv[]) {
|
||||
int count=-1;
|
||||
static void newmain (int count) {
|
||||
int i;
|
||||
if (argc>1) {
|
||||
count = atoi(argv[1]);
|
||||
}
|
||||
read_and_print_magic();
|
||||
for (i=0; i!=count; i++) {
|
||||
int r = toku_logprint_one_record(stdout, stdin);
|
||||
if (r==EOF) break;
|
||||
if (r!=0) {
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "Problem in log err=%d\n", r);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
int main (int argc, char *argv[]) {
|
||||
static void oldmain (int count) {
|
||||
int cmd;
|
||||
int count=-1;
|
||||
int i;
|
||||
if (argc>1) {
|
||||
count = atoi(argv[1]);
|
||||
}
|
||||
read_and_print_magic();
|
||||
for (i=0;
|
||||
i!=count && (crc=0,actual_len=0,cmd=get_char())!=EOF;
|
||||
|
@ -268,6 +258,21 @@ int main (int argc, char *argv[]) {
|
|||
assert(0);
|
||||
next: ; /*nothing*/
|
||||
}
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int count=-1;
|
||||
int oldcode=0;
|
||||
while (argc>1) {
|
||||
if (strcmp(argv[1], "--oldcode")==0) {
|
||||
oldcode=1;
|
||||
} else {
|
||||
count = atoi(argv[1]);
|
||||
}
|
||||
argc--; argv++;
|
||||
}
|
||||
if (oldcode) oldmain(count);
|
||||
else newmain(count);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -42,10 +42,18 @@ const struct logtype logtypes[] = {
|
|||
{"BYTESTRING", "fname"},
|
||||
{"u_int32_t", "mode"},
|
||||
NULLFIELD}},
|
||||
{"fheader", 'H', FA{{"TXNID", "txnid"},
|
||||
{"FILENUM", "filenum"},
|
||||
{"LOGGEDBRTHEADER", "header"},
|
||||
NULLFIELD}},
|
||||
{"fheader", 'H', FA{{"TXNID", "txnid"},
|
||||
{"FILENUM", "filenum"},
|
||||
{"LOGGEDBRTHEADER", "header"},
|
||||
NULLFIELD}},
|
||||
{"newbrtnode", 'N', FA{{"TXNID", "txnid"},
|
||||
{"FILENUM", "filenum"},
|
||||
{"DISKOFF", "diskoff"},
|
||||
{"u_int32_t", "height"},
|
||||
{"u_int32_t", "nodesize"},
|
||||
{"u_int8_t", "is_dup_sort"},
|
||||
{"u_int32_t", "rand4fingerprint"},
|
||||
NULLFIELD}},
|
||||
{"fopen", 'O', FA{{"TXNID", "txnid"},
|
||||
{"BYTESTRING", "fname"},
|
||||
{"FILENUM", "filenum"},
|
||||
|
|
|
@ -93,6 +93,10 @@ static inline void wbuf_BYTESTRING (struct wbuf *w, BYTESTRING v) {
|
|||
wbuf_bytes(w, v.data, v.len);
|
||||
}
|
||||
|
||||
static inline void wbuf_u_int8_t (struct wbuf *w, u_int8_t v) {
|
||||
wbuf_char(w, v);
|
||||
}
|
||||
|
||||
static inline void wbuf_u_int32_t (struct wbuf *w, u_int32_t v) {
|
||||
wbuf_int(w, v);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue