mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 23:24:14 +08:00
mdbx-load: add -r
(rescue) and -q
(quiet) options.
Change-Id: I6dd8003a6f1c8b3fe7a25ce1f6cac3735a2c9734
This commit is contained in:
parent
e25daab399
commit
7d74aa6ae8
@ -327,6 +327,8 @@ int main(int argc, char *argv[]) {
|
|||||||
char *envname = NULL;
|
char *envname = NULL;
|
||||||
int envflags = MDBX_UTTERLY_NOSYNC, putflags = 0;
|
int envflags = MDBX_UTTERLY_NOSYNC, putflags = 0;
|
||||||
int append = 0;
|
int append = 0;
|
||||||
|
int quiet = 0;
|
||||||
|
int rescue = 0;
|
||||||
MDBX_val prevk;
|
MDBX_val prevk;
|
||||||
|
|
||||||
prog = argv[0];
|
prog = argv[0];
|
||||||
@ -341,7 +343,7 @@ int main(int argc, char *argv[]) {
|
|||||||
* -T: read plaintext
|
* -T: read plaintext
|
||||||
* -V: print version and exit
|
* -V: print version and exit
|
||||||
*/
|
*/
|
||||||
while ((i = getopt(argc, argv, "af:ns:NTV")) != EOF) {
|
while ((i = getopt(argc, argv, "af:ns:NTVrq")) != EOF) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'V':
|
case 'V':
|
||||||
printf("mdbx_load version %d.%d.%d.%d\n"
|
printf("mdbx_load version %d.%d.%d.%d\n"
|
||||||
@ -379,6 +381,12 @@ int main(int argc, char *argv[]) {
|
|||||||
case 'T':
|
case 'T':
|
||||||
mode |= NOHDR | PRINT;
|
mode |= NOHDR | PRINT;
|
||||||
break;
|
break;
|
||||||
|
case 'q':
|
||||||
|
quiet = 1;
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
rescue = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@ -401,9 +409,10 @@ int main(int argc, char *argv[]) {
|
|||||||
#endif /* !WINDOWS */
|
#endif /* !WINDOWS */
|
||||||
|
|
||||||
envname = argv[optind];
|
envname = argv[optind];
|
||||||
printf("mdbx_load %s (%s, T-%s)\nRunning for %s...\n",
|
if (!quiet)
|
||||||
mdbx_version.git.describe, mdbx_version.git.datetime,
|
printf("mdbx_load %s (%s, T-%s)\nRunning for %s...\n",
|
||||||
mdbx_version.git.tree, envname);
|
mdbx_version.git.describe, mdbx_version.git.datetime,
|
||||||
|
mdbx_version.git.tree, envname);
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
|
|
||||||
dbuf.iov_len = 4096;
|
dbuf.iov_len = 4096;
|
||||||
@ -516,6 +525,11 @@ int main(int argc, char *argv[]) {
|
|||||||
rc = mdbx_cursor_put(mc, &key, &data, putflags | appflag);
|
rc = mdbx_cursor_put(mc, &key, &data, putflags | appflag);
|
||||||
if (rc == MDBX_KEYEXIST && putflags)
|
if (rc == MDBX_KEYEXIST && putflags)
|
||||||
continue;
|
continue;
|
||||||
|
if (rc == MDBX_BAD_VALSIZE && rescue) {
|
||||||
|
fprintf(stderr, "%s: skip line %" PRIiSIZE ": due %s\n", prog, lineno,
|
||||||
|
mdbx_strerror(rc));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fprintf(stderr, "mdbx_cursor_put failed, error %d %s\n", rc,
|
fprintf(stderr, "mdbx_cursor_put failed, error %d %s\n", rc,
|
||||||
mdbx_strerror(rc));
|
mdbx_strerror(rc));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user