distal-attribute
distal-attribute
distal-attribute
distal-attribute

Restore last used database on startup

kalvaro posted 2 years ago in Running SQL scripts
Is the "Restore last used database on startup" setting still functional?

I get a "SQL Error (1046): No database selected" error every time that I start a new connection and I forget to click on the database node.
ansgar posted 2 years ago
Yes, still works here, although I must admit I was sceptical after reading your post.

Does HeidiSQL select a database in the tree or is the root node selected after connecting?
jfalch posted 2 years ago
works here, too.
kalvaro posted 2 years ago
The root node is selected.

I've made some tests and if I select a DB, disconnect and connect again, it remains selected. It only happens when I switch connections—perhaps it's the intended behaviour.
ansgar posted 2 years ago
Yes, when you disconnect, the last selected DB is remembered for the next connect. Isn't that what this setting should do?
kalvaro posted 2 years ago
Hmmm... Shouldn't it be a per-connection value? What's the point of storing a database name and trying to load it in any random server?
ansgar posted 2 years ago
Yes, it is a connection value. When I'm connecting to my "Local" session, and connect to a second one, let's say it's named "Live", both have their own "last database" stored and restored, anyway how I disconnect or reconnect. Or do you use one single session to connect to different servers, by modifying the hostname each time?
kalvaro posted 2 years ago
I have several stored sessions. I simply hit the "Disconnect" toolbar button and double click on another session to open it.

I've just checked the Windows registry and I can see a "lastUsedDB" key on every stored connection with the correct value. The value is stored just fine but it isn't restored :(

I've enabled debug logging in case it helps:

/* DBtreeFocusChanged without node. */
/* Connection to hera.mina.s closed at 2013-02-12 12:54:01 */
/* DBtreeFocusChanged without node. */
/* Connecting to gestion.XXXXXX.es via MySQL (TCP/IP), username XXXXXX, using password: Yes ... */
/* Ping server ... */
/* Connected. Thread-ID: 237338 */
/* Characterset: utf8 */
/* Ping server ... */
SHOW STATUS;
/* Result #1 fetched. */
/* Ping server ... */
SHOW VARIABLES;
/* Result #1 fetched. */
/* DBtreeFocusChanged without node. */
/* DBtreeFocusChanged, Node level: 0, FTreeRefreshInProgress: 0 */
/* SetDatabase(), FDatabase: */
/* Entering session "Producción\XXXXXX" */
/* Ping server ... */
-- UTF-8 sin BOM (€ÁÑ)

SET @@SESSION.sql_mode='TRADITIONAL';

ansgar posted 2 years ago
Hey, you're right, I can reproduce that now. Thanks for insisting here. It's only reproducible when you open a different session as you had just disconnected. That's why I failed to reproduce it earlier. Will check that.
ansgar posted 2 years ago
Fixed in r4328
kalvaro posted 2 years ago
No issues so far. Thanks a lot, Anse.

Please login to leave a reply, or register at first.