Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

Restore last used database on startup

kalvaro's profile image kalvaro posted 7 years ago in Running SQL scripts Permalink
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's profile image ansgar posted 7 years ago Permalink
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's profile image jfalch posted 7 years ago Permalink
works here, too.
Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.
kalvaro's profile image kalvaro posted 7 years ago Permalink
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's profile image ansgar posted 7 years ago Permalink
Yes, when you disconnect, the last selected DB is remembered for the next connect. Isn't that what this setting should do?
kalvaro's profile image kalvaro posted 7 years ago Permalink
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's profile image ansgar posted 7 years ago Permalink
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's profile image kalvaro posted 7 years ago Permalink
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's profile image ansgar posted 7 years ago Permalink
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.
Code modification/commit from ansgar.becker@gmail.com, 7 years ago, revision 4328
Fix setting for name of selected database, which must be a session setting, not a global one. See http://www.heidisql.com/forum.php?t=12101
Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.
ansgar's profile image ansgar posted 7 years ago Permalink
Fixed in r4328
kalvaro's profile image kalvaro posted 7 years ago Permalink
No issues so far. Thanks a lot, Anse.

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