stasis-aries-wal/utilities/logfile_dump.c

86 lines
1.9 KiB
C
Raw Normal View History

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stasis/logger/logHandle.h>
#include <stasis/logger/logWriter.h>
static char * logEntryToString(const LogEntry * le) {
char * ret = NULL;
2008-11-11 01:15:25 +00:00
int err;
switch(le->type) {
case UPDATELOG:
{
2008-11-11 01:15:25 +00:00
err = asprintf(&ret, "UPDATE\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\tpage={%8lld}\tfuncId=%3d\targSize=%9lld\n", le->LSN, le->prevLSN, le->xid,
le->update.page, le->update.funcID, (long long)le->update.arg_size );
}
break;
case XBEGIN:
{
2008-11-11 01:15:25 +00:00
err = asprintf(&ret, "BEGIN\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid);
}
break;
case XCOMMIT:
{
2008-11-11 01:15:25 +00:00
err = asprintf(&ret, "COMMIT\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid);
}
break;
case XABORT:
{
2008-11-11 01:15:25 +00:00
err = asprintf(&ret, "ABORT\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid);
2008-09-24 03:10:49 +00:00
}
break;
case XPREPARE:
{
2008-11-11 01:15:25 +00:00
err = asprintf(&ret, "PREPARE\tlsn=%9lld\tprevlsn=%9lld\txid=%4d,reclsn=%9lld\n", le->LSN, le->prevLSN, le->xid, getPrepareRecLSN(le));
2008-09-24 03:10:49 +00:00
}
break;
case XEND:
{
2008-11-11 01:15:25 +00:00
err = asprintf(&ret, "END \tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid);
}
break;
case CLRLOG:
{
2008-11-11 01:15:25 +00:00
err = asprintf(&ret, "CLR \tlsn=%9lld\tprevlsn=%9lld\txid=%4d\tcompensates={%8lld}\n", le->LSN, le->prevLSN, le->xid,
((CLRLogEntry*)le)->clr.compensated_lsn);
}
break;
}
2008-11-11 01:15:25 +00:00
assert(err != -1);
return ret;
}
void setupOperationsTable();
int main() {
LogHandle lh;
const LogEntry * le;
setupOperationsTable();
if(openLogWriter()) {
printf("Couldn't open log.\n");
}
lh = getLogHandle(); /*LSNHandle(0); */
while((le = nextInLog(&lh))) {
char * s = logEntryToString(le);
if(s) {
printf("%s", s);
free(s);
}
FreeLogEntry(le);
}
}