5 int do_bt(int nArg
, char **azArg
){
11 { "dbhdr", 0, BT_INFO_HDRDUMP
},
12 { "filename", 0, BT_INFO_FILENAME
},
13 { "block_freelist", 0, BT_INFO_BLOCK_FREELIST
},
14 { "page_freelist", 0, BT_INFO_PAGE_FREELIST
},
15 { "filename", 0, BT_INFO_FILENAME
},
16 { "page", 1, BT_INFO_PAGEDUMP
},
17 { "page_ascii", 1, BT_INFO_PAGEDUMP_ASCII
},
18 { "leaks", 0, BT_INFO_PAGE_LEAKS
},
30 testPrintUsage("FILENAME OPTION ...");
36 rc
= testArgSelect(aOpt
, "option", zOpt
, &iOpt
);
37 if( rc
!=0 ) return rc
;
38 if( nArg
!=2+aOpt
[iOpt
].bPgno
){
39 testPrintFUsage("FILENAME %s %s", zOpt
, aOpt
[iOpt
].bPgno
? "PGNO" : "");
43 rc
= sqlite4BtNew(sqlite4_env_default(), 0, &db
);
45 testPrintError("sqlite4BtNew() failed: %d", rc
);
48 rc
= sqlite4BtOpen(db
, zFile
);
50 testPrintError("sqlite4BtOpen() failed: %d", rc
);
54 buf
.eType
= aOpt
[iOpt
].eOpt
;
56 sqlite4_buffer_init(&buf
.output
, 0);
58 if( aOpt
[iOpt
].bPgno
){
59 buf
.pgno
= (u32
)atoi(azArg
[2]);
62 rc
= sqlite4BtControl(db
, BT_CONTROL_INFO
, &buf
);
64 testPrintError("sqlite4BtControl() failed: %d\n", rc
);
68 printf("%s\n", (char*)buf
.output
.p
);
69 sqlite4_buffer_clear(&buf
.output
);