question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enumerating all dbs in an environment

See original GitHub issue

I need to open an environment and discover all of the databases. From what I understand, the database names are stored in the default, nameless db. But what encoding? Creating a db ends in a native method stub passing a String… UTF-8?

    Txn<ByteBuffer> txn = env.txn(null);
    env.openDbi(null).iterate(txn).forEachRemaining(kv -> {
      ByteBuffer keybytes = kv.key();
      String key = ??? 
    });

It would probably be useful to add both the ability to retrieve all dbi names to Env, as well as the ability to return all Dbis in an Env as a Map<String, Dbi>. The LMDB docs suggest that it is good practice to retrieve and re-use these anyway.

So I suppose this is mostly a question, but also a minor feature request.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
scottcareycommented, Jan 11, 2017

Ah, and lastly, the changes now on master have one thing I don’t like:

getDbiNames returns null rather than an empty list when there are no names.

One other comment is that there should be some javadoc that indicates that this returns the keys from the default / null name Dbi, so that for users that are not using named databases it will return all of the keys in that Dbi which might cause OOM.

1reaction
benalexaucommented, Jan 10, 2017

I have implemented the changes suggested by @krisskross. Hope this helps with your use case, @scottcarey.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Searching all databases in environment [duplicate]
1 Answer 1 ... You can use SQL Power doc for this . SQL Power Doc was written by Kendal VanDyke. It is...
Read more >
How to Show List of All Databases in MySQL [Explained]
Run the following query to show list of databases: SHOW DATABASES;. You can run this statement from MySQL Command Line Client, MySQL Shell,...
Read more >
How to list all databases in MySQL - SQLS*Plus
To list all databases in MySQL, execute the following command: ... mysql> show databases;. This command will work for you whether you have...
Read more >
Get list of databases from SQL Server - Stack Overflow
Use the query below to get all the databases: select * from sys ...
Read more >
How to Show a List of All Databases in MySQL - Linuxize
When administering MySQL database servers, one of the most common tasks you'll have to do is to get familiar with the environment.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found