5 int do_work(int nArg
, char **azArg
){
21 if( nArg
==0 ) goto usage
;
23 for(i
=0; i
<(nArg
-1); i
++){
25 rc
= testArgSelect(aOpt
, "option", azArg
[i
], &iSel
);
30 if( i
==(nArg
-1) ) goto usage
;
31 nMerge
= atoi(azArg
[i
]);
35 if( i
==(nArg
-1) ) goto usage
;
41 rc
= lsm_new(0, &pDb
);
43 testPrintError("lsm_open(): rc=%d\n", rc
);
45 rc
= lsm_open(pDb
, zDb
);
47 testPrintError("lsm_open(): rc=%d\n", rc
);
50 lsm_config(pDb
, LSM_CONFIG_BLOCK_SIZE
, &n
);
52 lsm_config(pDb
, LSM_CONFIG_AUTOCHECKPOINT
, &n
);
54 rc
= lsm_work(pDb
, nMerge
, nKB
, 0);
56 testPrintError("lsm_work(): rc=%d\n", rc
);
61 rc
= lsm_checkpoint(pDb
, 0);
68 testPrintUsage("?-optimize? ?-n N? DATABASE");
74 ** lsmtest show ?-config LSM-CONFIG? DATABASE ?COMMAND ?PGNO??
76 int do_show(int nArg
, char **azArg
){
81 int eOpt
= LSM_INFO_DB_STRUCTURE
;
84 const char *zConfig
= "";
91 { "array", 0, LSM_INFO_ARRAY_STRUCTURE
},
92 { "array-pages", 0, LSM_INFO_ARRAY_PAGES
},
93 { "blocksize", 1, LSM_CONFIG_BLOCK_SIZE
},
94 { "pagesize", 1, LSM_CONFIG_PAGE_SIZE
},
95 { "freelist", 0, LSM_INFO_FREELIST
},
96 { "page-ascii", 0, LSM_INFO_PAGE_ASCII_DUMP
},
97 { "page-hex", 0, LSM_INFO_PAGE_HEX_DUMP
},
102 int iDb
= 0; /* Index of DATABASE in azArg[] */
104 /* Check if there is a "-config" option: */
105 if( nArg
>2 && strlen(azArg
[0])>1
106 && memcmp(azArg
[0], "-config", strlen(azArg
[0]))==0
111 if( nArg
<(iDb
+1) ) goto usage
;
114 rc
= testArgSelect(aOpt
, "option", azArg
[iDb
+1], &eOpt
);
115 if( rc
!=0 ) return rc
;
116 bConfig
= aOpt
[eOpt
].bConfig
;
117 eOpt
= aOpt
[eOpt
].eOpt
;
118 if( (bConfig
==0 && eOpt
==LSM_INFO_FREELIST
)
119 || (bConfig
==1 && eOpt
==LSM_CONFIG_BLOCK_SIZE
)
120 || (bConfig
==1 && eOpt
==LSM_CONFIG_PAGE_SIZE
)
122 if( nArg
!=(iDb
+2) ) goto usage
;
124 if( nArg
!=(iDb
+3) ) goto usage
;
125 iPg
= atoi(azArg
[iDb
+2]);
130 rc
= lsm_new(0, &pDb
);
131 tdb_lsm_configure(pDb
, zConfig
);
133 testPrintError("lsm_new(): rc=%d\n", rc
);
135 rc
= lsm_open(pDb
, zDb
);
137 testPrintError("lsm_open(): rc=%d\n", rc
);
144 case LSM_INFO_DB_STRUCTURE
:
145 case LSM_INFO_FREELIST
:
146 rc
= lsm_info(pDb
, eOpt
, &z
);
148 case LSM_INFO_ARRAY_STRUCTURE
:
149 case LSM_INFO_ARRAY_PAGES
:
150 case LSM_INFO_PAGE_ASCII_DUMP
:
151 case LSM_INFO_PAGE_HEX_DUMP
:
152 rc
= lsm_info(pDb
, eOpt
, iPg
, &z
);
155 assert( !"no chance" );
159 printf("%s\n", z
? z
: "");
162 lsm_free(lsm_get_env(pDb
), z
);
165 lsm_config(pDb
, eOpt
, &iRes
);
166 printf("%d\n", iRes
);
175 testPrintUsage("DATABASE ?array|page-ascii|page-hex PGNO?");