Fix the ".lint fkey-indexes" shell command so that it works with WITHOUT ROWID
[sqlite.git] / ext / lsm1 / lsm-test / lsmtest_bt.c
blob5135dd0559d96827a94e445a7bf6bd42c160aae1
2 #include "lsmtest.h"
3 #include "bt.h"
5 int do_bt(int nArg, char **azArg){
6 struct Option {
7 const char *zName;
8 int bPgno;
9 int eOpt;
10 } aOpt [] = {
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 },
19 { 0, 0 }
21 int iOpt;
22 int rc;
23 bt_info buf;
24 char *zOpt;
25 char *zFile;
27 bt_db *db = 0;
29 if( nArg<2 ){
30 testPrintUsage("FILENAME OPTION ...");
31 return -1;
33 zFile = azArg[0];
34 zOpt = azArg[1];
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" : "");
40 return -4;
43 rc = sqlite4BtNew(sqlite4_env_default(), 0, &db);
44 if( rc!=SQLITE4_OK ){
45 testPrintError("sqlite4BtNew() failed: %d", rc);
46 return -2;
48 rc = sqlite4BtOpen(db, zFile);
49 if( rc!=SQLITE4_OK ){
50 testPrintError("sqlite4BtOpen() failed: %d", rc);
51 return -3;
54 buf.eType = aOpt[iOpt].eOpt;
55 buf.pgno = 0;
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);
63 if( rc!=SQLITE4_OK ){
64 testPrintError("sqlite4BtControl() failed: %d\n", rc);
65 return -4;
68 printf("%s\n", (char*)buf.output.p);
69 sqlite4_buffer_clear(&buf.output);
70 return 0;