mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 12:01:42 +01:00
More logformatting stuff. Addresses #11
git-svn-id: file:///svn/tokudb@712 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
28d927af59
commit
ac01e9e825
1 changed files with 26 additions and 21 deletions
|
@ -27,6 +27,10 @@ struct logtype {
|
|||
// In the fields, don't mention the command, the LSN, the CRC or the trailing LEN.
|
||||
|
||||
const struct logtype logtypes[] = {
|
||||
{"fcreate", 'F', FA{{"TXNID", "txnid"},
|
||||
{"BYTESTRING", "fname"},
|
||||
{"uint32", "mode"},
|
||||
NULLFIELD}},
|
||||
{"delete", 'D', FA{{"FILENUM", "filenum"},
|
||||
{"DISKOFF", "diskoff"},
|
||||
{"BYTESTRING", "key"},
|
||||
|
@ -145,9 +149,10 @@ void generate_log_reader (void) {
|
|||
}
|
||||
|
||||
void generate_logprint (void) {
|
||||
fprintf(cf, "int logprint(FILE *outf, FILE *f, int n_records_limit) {\n");
|
||||
fprintf(cf, " int i, cmd, r;\n");
|
||||
fprintf(cf, " for (i=0; i!=count && (cmd=fgetc(f))!=EOF; i++) {\n");
|
||||
fprintf(cf, "int toku_logprint_one_record(FILE *outf, FILE *f) {\n");
|
||||
fprintf(cf, " int cmd, r;\n");
|
||||
fprintf(cf, " cmd=fgetc(f);\n");
|
||||
fprintf(cf, " if (cmd==EOF) return EOF;\n");
|
||||
fprintf(cf, " u_int32_t len_in_file, len=1;\n");
|
||||
fprintf(cf, " char charcmd = cmd;\n");
|
||||
fprintf(cf, " u_int32_t crc_in_file, crc = toku_crc32(0, &char_cmd, 1);\n");
|
||||
|
@ -165,20 +170,20 @@ void generate_logprint (void) {
|
|||
fprintf(cf, " fprintf(outf, \" len=%%d\", len_in_file);\n");
|
||||
fprintf(cf, " if (len_in_file!=len) fprintf(\" actual_len=%%d\", actual_len);\n");
|
||||
fprintf(cf, " if (len_in_file!=len || crc_in_file!=crc) return DB_BADFORMAT;\n");
|
||||
fprintf(cf, " goto next;\n\n");
|
||||
fprintf(cf, " return 0;;\n\n");
|
||||
}));
|
||||
fprintf(cf, " }\n");
|
||||
fprintf(cf, " fprintf(outf, \"Unknown command %%d ('%%c')\", cmd, cmd);\n");
|
||||
fprintf(cf, " return DB_BADFORMAT;\n");
|
||||
fprintf(cf, " next: ;\n");
|
||||
fprintf(cf, " }\n");
|
||||
fprintf(cf, " return 0;\n");
|
||||
fprintf(cf, "}\n\n");
|
||||
}
|
||||
|
||||
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
|
||||
cf = fopen("log_code.c", "w"); assert(cf!=0);
|
||||
hf = fopen("log_header.h", "w"); assert(hf!=0);
|
||||
fprintf(cf, "#include <stdio.h>\n");
|
||||
fprintf(hf, "#include \"brt-internal.h\"\n");
|
||||
fprintf(cf, "#include \"log_header.h\"\n");
|
||||
generate_log_struct();
|
||||
generate_log_writer();
|
||||
generate_log_reader();
|
||||
|
|
Loading…
Add table
Reference in a new issue