-
Notifications
You must be signed in to change notification settings - Fork 1
/
dump.c
45 lines (33 loc) · 839 Bytes
/
dump.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// dump.c ... display all tuples
// part of SIMC signature files
// Usage: ./dump RelName
#include "defs.h"
#include "tuple.h"
#include "reln.h"
#define USAGE "./dump RelName"
// Main ... process args, run query
int main(int argc, char **argv)
{
Reln r; // open relation info
char err[MAXERRMSG]; // buffer for error messages
// process command-line args
if (argc < 2) fatal(USAGE, "");
if ((r = openRelation(argv[1])) == NULL) {
sprintf(err, "Can't open relation: %s",argv[1]);
fatal("", err);
}
// scan data pages, printing each tuple
Page p; Tuple t; int pid, i;
for (pid = 0; pid < nPages(r); pid++) {
p = getPage(dataFile(r), pid);
for (i = 0; i < pageNitems(p); i++) {
t = getTupleFromPage(r, p, i);
showTuple(r, t);
free(t);
}
free(p);
}
// clean up
closeRelation(r);
return 0;
}