Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

libmdbx CLI front-end improvement ideas #218

Open
debrouxl opened this issue Jul 7, 2021 · 0 comments
Open

libmdbx CLI front-end improvement ideas #218

debrouxl opened this issue Jul 7, 2021 · 0 comments

Comments

@debrouxl
Copy link

debrouxl commented Jul 7, 2021

I have a couple suggestions for libmdbx's CLI front-ends, inspired by functionality provided by Berkeley DB or other DBM-type databases:

  • making it possible to pass configuration options, such as the page size, to mdbx_load - effectively an equivalent to Berkeley DB's db_load -c .... Maybe mdbx_copy between different database files could benefit from that as well.
  • in order to provide CLI scriptability (and indirectly better fuzzing support) without having to use one of the language bindings for libmdbx, creating a generic mdbxtool front-end, similar to TDB's tdbtool and GDBM's gdbmtool, with the ability to read arguments from stdin, from a file, from command-line arguments, or interactively.

FWIW, I sent the suggestion of creating similar tools to both Oracle for BDB and Howard Chu for LMDB, and years ago, Sergey Poznyakoff improved gdbmtool to follow tdbtool's lead.

$ gdbmtool

Welcome to the gdbm tool.  Type ? for help.

gdbmtool> ?
 avail                         print avail list
 bucket NUMBER                 print a bucket
 cache                         print the bucket cache
 close                         close the database
 count                         count (number of entries)
 current                       print current bucket
 debug                         query/set debug level
 define key|content { FIELD-LIST } define datum structure
 delete KEY                    delete a record
 dir                           print hash directory
 export FILE [truncate] [binary|ascii] export
 fetch KEY                     fetch record
 first                         firstkey
 hash KEY                      hash value of key
 header                        print database file header
 help                          print this help list
 history [FROM] [COUNT]        show input history
 import FILE [replace] [nometa] import
 list                          list
 next [KEY]                    nextkey
 open FILE                     open new database
 quit                          quit the program
 recover [verbose] [summary] [backup] [force] [max-failed-keys=N] [max-failed-buckets=N] [max-failures=N] recover the database
 reorganize                    reorganize
 set [VAR=VALUE...]            set or list variables
 source FILE                   source command script
 status                        print current program status
 store KEY DATA                store
 unset VAR...                  unset variables
 version                       print version of gdbm
gdbmtool> 
$ tdbtool 
tdb> ?
database not open

tdbtool: 
  create    dbname     : create a database
  open      dbname     : open an existing database
  transaction_start    : start a transaction
  transaction_commit   : commit a transaction
  transaction_cancel   : cancel a transaction
  erase                : erase the database
  dump                 : dump the database as strings
  keys                 : dump the database keys as strings
  hexkeys              : dump the database keys as hex values
  info                 : print summary info about the database
  insert    key  data  : insert a record
  move      key  file  : move a record to a destination tdb
  storehex  key  data  : store a record (replace), key/value in hex format
  store     key  data  : store a record (replace)
  show      key        : show a record by key
  delete    key        : delete a record by key
  list                 : print the database hash table and freelist
  free                 : print the database freelist
  freelist_size        : print the number of records in the freelist
  check                : check the integrity of an opened database
  repack               : repack the database
  speed                : perform speed tests on the database
  ! command            : execute system command
  1 | first            : print the first record
  n | next             : print the next record
  q | quit             : terminate
  \n                   : repeat 'next' command

tdb>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants