mirror of
https://github.com/isar/libmdbx.git
synced 2025-08-25 09:44:27 +08:00
mdbx: использование термина "таблица" вместо "sub-database".
This commit is contained in:
@@ -55,7 +55,7 @@ MDBX_env *env;
|
||||
MDBX_txn *txn;
|
||||
unsigned verbose = 0;
|
||||
bool quiet;
|
||||
MDBX_val only_subdb;
|
||||
MDBX_val only_table;
|
||||
int stuck_meta = -1;
|
||||
MDBX_chk_context_t chk;
|
||||
bool turn_meta = false;
|
||||
@@ -95,7 +95,7 @@ static bool silently(enum MDBX_chk_severity severity) {
|
||||
chk.scope ? chk.scope->verbosity >> MDBX_chk_severity_prio_shift
|
||||
: verbose + (MDBX_chk_result >> MDBX_chk_severity_prio_shift);
|
||||
int prio = (severity >> MDBX_chk_severity_prio_shift);
|
||||
if (chk.scope && chk.scope->stage == MDBX_chk_subdbs && verbose < 2)
|
||||
if (chk.scope && chk.scope->stage == MDBX_chk_tables && verbose < 2)
|
||||
prio += 1;
|
||||
return quiet || cutoff < ((prio > 0) ? prio : 0);
|
||||
}
|
||||
@@ -270,14 +270,14 @@ static void scope_pop(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *scope,
|
||||
flush();
|
||||
}
|
||||
|
||||
static MDBX_chk_user_subdb_cookie_t *subdb_filter(MDBX_chk_context_t *ctx,
|
||||
static MDBX_chk_user_table_cookie_t *table_filter(MDBX_chk_context_t *ctx,
|
||||
const MDBX_val *name,
|
||||
MDBX_db_flags_t flags) {
|
||||
(void)ctx;
|
||||
(void)flags;
|
||||
return (!only_subdb.iov_base ||
|
||||
(only_subdb.iov_len == name->iov_len &&
|
||||
memcmp(only_subdb.iov_base, name->iov_base, name->iov_len) == 0))
|
||||
return (!only_table.iov_base ||
|
||||
(only_table.iov_len == name->iov_len &&
|
||||
memcmp(only_table.iov_base, name->iov_base, name->iov_len) == 0))
|
||||
? (void *)(intptr_t)-1
|
||||
: nullptr;
|
||||
}
|
||||
@@ -344,7 +344,7 @@ static void print_format(MDBX_chk_line_t *line, const char *fmt, va_list args) {
|
||||
static const MDBX_chk_callbacks_t cb = {.check_break = check_break,
|
||||
.scope_push = scope_push,
|
||||
.scope_pop = scope_pop,
|
||||
.subdb_filter = subdb_filter,
|
||||
.table_filter = table_filter,
|
||||
.stage_begin = stage_begin,
|
||||
.stage_end = stage_end,
|
||||
.print_begin = print_begin,
|
||||
@@ -357,7 +357,7 @@ static void usage(char *prog) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"usage: %s "
|
||||
"[-V] [-v] [-q] [-c] [-0|1|2] [-w] [-d] [-i] [-s subdb] [-u|U] dbpath\n"
|
||||
"[-V] [-v] [-q] [-c] [-0|1|2] [-w] [-d] [-i] [-s table] [-u|U] dbpath\n"
|
||||
" -V\t\tprint version and exit\n"
|
||||
" -v\t\tmore verbose, could be repeated upto 9 times for extra details\n"
|
||||
" -q\t\tbe quiet\n"
|
||||
@@ -365,7 +365,7 @@ static void usage(char *prog) {
|
||||
" -w\t\twrite-mode checking\n"
|
||||
" -d\t\tdisable page-by-page traversal of B-tree\n"
|
||||
" -i\t\tignore wrong order errors (for custom comparators case)\n"
|
||||
" -s subdb\tprocess a specific subdatabase only\n"
|
||||
" -s table\tprocess a specific subdatabase only\n"
|
||||
" -u\t\twarmup database before checking\n"
|
||||
" -U\t\twarmup and try lock database pages in memory before checking\n"
|
||||
" -0|1|2\tforce using specific meta-page 0, or 2 for checking\n"
|
||||
@@ -380,7 +380,7 @@ static int conclude(MDBX_chk_context_t *ctx) {
|
||||
if (ctx->result.total_problems == 1 && ctx->result.problems_meta == 1 &&
|
||||
(chk_flags &
|
||||
(MDBX_CHK_SKIP_BTREE_TRAVERSAL | MDBX_CHK_SKIP_KV_TRAVERSAL)) == 0 &&
|
||||
(env_flags & MDBX_RDONLY) == 0 && !only_subdb.iov_base &&
|
||||
(env_flags & MDBX_RDONLY) == 0 && !only_table.iov_base &&
|
||||
stuck_meta < 0 && ctx->result.steady_txnid < ctx->result.recent_txnid) {
|
||||
const size_t step_lineno =
|
||||
print(MDBX_chk_resolution,
|
||||
@@ -399,7 +399,7 @@ static int conclude(MDBX_chk_context_t *ctx) {
|
||||
if (turn_meta && stuck_meta >= 0 &&
|
||||
(chk_flags &
|
||||
(MDBX_CHK_SKIP_BTREE_TRAVERSAL | MDBX_CHK_SKIP_KV_TRAVERSAL)) == 0 &&
|
||||
!only_subdb.iov_base &&
|
||||
!only_table.iov_base &&
|
||||
(env_flags & (MDBX_RDONLY | MDBX_EXCLUSIVE)) == MDBX_EXCLUSIVE) {
|
||||
const bool successful_check =
|
||||
(err | ctx->result.total_problems | ctx->result.problems_meta) == 0;
|
||||
@@ -529,11 +529,11 @@ int main(int argc, char *argv[]) {
|
||||
chk_flags |= MDBX_CHK_SKIP_BTREE_TRAVERSAL;
|
||||
break;
|
||||
case 's':
|
||||
if (only_subdb.iov_base && strcmp(only_subdb.iov_base, optarg))
|
||||
if (only_table.iov_base && strcmp(only_table.iov_base, optarg))
|
||||
usage(prog);
|
||||
else {
|
||||
only_subdb.iov_base = optarg;
|
||||
only_subdb.iov_len = strlen(optarg);
|
||||
only_table.iov_base = optarg;
|
||||
only_table.iov_len = strlen(optarg);
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
@@ -574,7 +574,7 @@ int main(int argc, char *argv[]) {
|
||||
"write-mode must be enabled to turn to the specified meta-page.");
|
||||
rc = EXIT_INTERRUPTED;
|
||||
}
|
||||
if (only_subdb.iov_base || (chk_flags & (MDBX_CHK_SKIP_BTREE_TRAVERSAL |
|
||||
if (only_table.iov_base || (chk_flags & (MDBX_CHK_SKIP_BTREE_TRAVERSAL |
|
||||
MDBX_CHK_SKIP_KV_TRAVERSAL))) {
|
||||
error_fmt(
|
||||
"whole database checking with b-tree traversal are required to turn "
|
||||
|
@@ -46,7 +46,7 @@ static void usage(void) {
|
||||
" -V\t\tprint version and exit\n"
|
||||
" -q\t\tbe quiet\n"
|
||||
" -d\t\tdelete the specified database, don't just empty it\n"
|
||||
" -s name\tdrop the specified named subDB\n"
|
||||
" -s name\tdrop the specified named table\n"
|
||||
" \t\tby default empty the main DB\n",
|
||||
prog);
|
||||
exit(EXIT_FAILURE);
|
||||
|
@@ -215,16 +215,16 @@ static void usage(void) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"usage: %s "
|
||||
"[-V] [-q] [-f file] [-l] [-p] [-r] [-a|-s subdb] [-u|U] "
|
||||
"[-V] [-q] [-f file] [-l] [-p] [-r] [-a|-s table] [-u|U] "
|
||||
"dbpath\n"
|
||||
" -V\t\tprint version and exit\n"
|
||||
" -q\t\tbe quiet\n"
|
||||
" -f\t\twrite to file instead of stdout\n"
|
||||
" -l\t\tlist subDBs and exit\n"
|
||||
" -l\t\tlist tables and exit\n"
|
||||
" -p\t\tuse printable characters\n"
|
||||
" -r\t\trescue mode (ignore errors to dump corrupted DB)\n"
|
||||
" -a\t\tdump main DB and all subDBs\n"
|
||||
" -s name\tdump only the specified named subDB\n"
|
||||
" -a\t\tdump main DB and all tables\n"
|
||||
" -s name\tdump only the specified named table\n"
|
||||
" -u\t\twarmup database before dumping\n"
|
||||
" -U\t\twarmup and try lock database pages in memory before dumping\n"
|
||||
" \t\tby default dump only the main DB\n",
|
||||
|
@@ -477,10 +477,10 @@ static void usage(void) {
|
||||
" -a\t\tappend records in input order (required for custom "
|
||||
"comparators)\n"
|
||||
" -f file\tread from file instead of stdin\n"
|
||||
" -s name\tload into specified named subDB\n"
|
||||
" -s name\tload into specified named table\n"
|
||||
" -N\t\tdon't overwrite existing records when loading, just skip "
|
||||
"ones\n"
|
||||
" -p\t\tpurge subDB before loading\n"
|
||||
" -p\t\tpurge table before loading\n"
|
||||
" -T\t\tread plaintext\n"
|
||||
" -r\t\trescue mode (ignore errors to load corrupted DB dump)\n"
|
||||
" -n\t\tdon't use subdirectory for newly created database "
|
||||
|
@@ -47,15 +47,15 @@ static void print_stat(MDBX_stat *ms) {
|
||||
|
||||
static void usage(const char *prog) {
|
||||
fprintf(stderr,
|
||||
"usage: %s [-V] [-q] [-e] [-f[f[f]]] [-r[r]] [-a|-s name] dbpath\n"
|
||||
"usage: %s [-V] [-q] [-e] [-f[f[f]]] [-r[r]] [-a|-s table] dbpath\n"
|
||||
" -V\t\tprint version and exit\n"
|
||||
" -q\t\tbe quiet\n"
|
||||
" -p\t\tshow statistics of page operations for current session\n"
|
||||
" -e\t\tshow whole DB info\n"
|
||||
" -f\t\tshow GC info\n"
|
||||
" -r\t\tshow readers\n"
|
||||
" -a\t\tprint stat of main DB and all subDBs\n"
|
||||
" -s name\tprint stat of only the specified named subDB\n"
|
||||
" -a\t\tprint stat of main DB and all tables\n"
|
||||
" -s table\tprint stat of only the specified named table\n"
|
||||
" \t\tby default print stat of only the main DB\n",
|
||||
prog);
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -104,7 +104,7 @@ int main(int argc, char *argv[]) {
|
||||
MDBX_envinfo mei;
|
||||
prog = argv[0];
|
||||
char *envname;
|
||||
char *subname = nullptr;
|
||||
char *table = nullptr;
|
||||
bool alldbs = false, envinfo = false, pgop = false;
|
||||
int freinfo = 0, rdrinfo = 0;
|
||||
|
||||
@@ -143,7 +143,7 @@ int main(int argc, char *argv[]) {
|
||||
pgop = true;
|
||||
break;
|
||||
case 'a':
|
||||
if (subname)
|
||||
if (table)
|
||||
usage(prog);
|
||||
alldbs = true;
|
||||
break;
|
||||
@@ -161,7 +161,7 @@ int main(int argc, char *argv[]) {
|
||||
case 's':
|
||||
if (alldbs)
|
||||
usage(prog);
|
||||
subname = optarg;
|
||||
table = optarg;
|
||||
break;
|
||||
default:
|
||||
usage(prog);
|
||||
@@ -199,7 +199,7 @@ int main(int argc, char *argv[]) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (alldbs || subname) {
|
||||
if (alldbs || table) {
|
||||
rc = mdbx_env_set_maxdbs(env, 2);
|
||||
if (unlikely(rc != MDBX_SUCCESS)) {
|
||||
error("mdbx_env_set_maxdbs", rc);
|
||||
@@ -327,7 +327,7 @@ int main(int argc, char *argv[]) {
|
||||
} else
|
||||
printf(" No stale readers.\n");
|
||||
}
|
||||
if (!(subname || alldbs || freinfo))
|
||||
if (!(table || alldbs || freinfo))
|
||||
goto txn_abort;
|
||||
}
|
||||
|
||||
@@ -450,7 +450,7 @@ int main(int argc, char *argv[]) {
|
||||
printf(" GC: %" PRIaPGNO " pages\n", pages);
|
||||
}
|
||||
|
||||
rc = mdbx_dbi_open(txn, subname, MDBX_DB_ACCEDE, &dbi);
|
||||
rc = mdbx_dbi_open(txn, table, MDBX_DB_ACCEDE, &dbi);
|
||||
if (unlikely(rc != MDBX_SUCCESS)) {
|
||||
error("mdbx_dbi_open", rc);
|
||||
goto txn_abort;
|
||||
@@ -462,7 +462,7 @@ int main(int argc, char *argv[]) {
|
||||
error("mdbx_dbi_stat", rc);
|
||||
goto txn_abort;
|
||||
}
|
||||
printf("Status of %s\n", subname ? subname : "Main DB");
|
||||
printf("Status of %s\n", table ? table : "Main DB");
|
||||
print_stat(&mst);
|
||||
|
||||
if (alldbs) {
|
||||
@@ -476,16 +476,16 @@ int main(int argc, char *argv[]) {
|
||||
MDBX_val key;
|
||||
while (MDBX_SUCCESS ==
|
||||
(rc = mdbx_cursor_get(cursor, &key, nullptr, MDBX_NEXT_NODUP))) {
|
||||
MDBX_dbi subdbi;
|
||||
MDBX_dbi xdbi;
|
||||
if (memchr(key.iov_base, '\0', key.iov_len))
|
||||
continue;
|
||||
subname = osal_malloc(key.iov_len + 1);
|
||||
memcpy(subname, key.iov_base, key.iov_len);
|
||||
subname[key.iov_len] = '\0';
|
||||
rc = mdbx_dbi_open(txn, subname, MDBX_DB_ACCEDE, &subdbi);
|
||||
table = osal_malloc(key.iov_len + 1);
|
||||
memcpy(table, key.iov_base, key.iov_len);
|
||||
table[key.iov_len] = '\0';
|
||||
rc = mdbx_dbi_open(txn, table, MDBX_DB_ACCEDE, &xdbi);
|
||||
if (rc == MDBX_SUCCESS)
|
||||
printf("Status of %s\n", subname);
|
||||
osal_free(subname);
|
||||
printf("Status of %s\n", table);
|
||||
osal_free(table);
|
||||
if (unlikely(rc != MDBX_SUCCESS)) {
|
||||
if (rc == MDBX_INCOMPATIBLE)
|
||||
continue;
|
||||
@@ -493,14 +493,14 @@ int main(int argc, char *argv[]) {
|
||||
goto txn_abort;
|
||||
}
|
||||
|
||||
rc = mdbx_dbi_stat(txn, subdbi, &mst, sizeof(mst));
|
||||
rc = mdbx_dbi_stat(txn, xdbi, &mst, sizeof(mst));
|
||||
if (unlikely(rc != MDBX_SUCCESS)) {
|
||||
error("mdbx_dbi_stat", rc);
|
||||
goto txn_abort;
|
||||
}
|
||||
print_stat(&mst);
|
||||
|
||||
rc = mdbx_dbi_close(env, subdbi);
|
||||
rc = mdbx_dbi_close(env, xdbi);
|
||||
if (unlikely(rc != MDBX_SUCCESS)) {
|
||||
error("mdbx_dbi_close", rc);
|
||||
goto txn_abort;
|
||||
|
Reference in New Issue
Block a user