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

Restore last used database on startup

User, date Message
Written by kalvaro
2 years ago
Category: Running SQL scripts
594 posts since Thu, 29 Nov 07
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.
Written by ansgar
2 years ago
4988 posts since Fri, 07 Apr 06
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?
Written by jfalchMoney, Euro
2 years ago
388 posts since Sat, 17 Oct 09
works here, too.
Written by kalvaro
2 years ago
594 posts since Thu, 29 Nov 07
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.
Written by ansgar
2 years ago
4988 posts since Fri, 07 Apr 06
Yes, when you disconnect, the last selected DB is remembered for the next connect. Isn't that what this setting should do?
Written by kalvaro
2 years ago
594 posts since Thu, 29 Nov 07
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?
Written by ansgar
2 years ago
4988 posts since Fri, 07 Apr 06
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?
Written by kalvaro
2 years ago
594 posts since Thu, 29 Nov 07
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';

Written by ansgar
2 years ago
4988 posts since Fri, 07 Apr 06
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.
Written by ansgar
2 years ago
4988 posts since Fri, 07 Apr 06
Fixed in r4328
Written by kalvaro
2 years ago
594 posts since Thu, 29 Nov 07
No issues so far. Thanks a lot, Anse.
 

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