Bug #6982 SET CHARACTER SET from QBrowser starts a new session
Submitted: 3 Dec 2004 10:38 Modified: 3 Dec 2004 11:09
Reporter: Viktor Kostadinov Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Query Browser Severity:S2 (Serious)
Version:1.1.2 OS:Windows (WinXP)
Assigned to: CPU Architecture:Any

[3 Dec 2004 10:38] Viktor Kostadinov
Description:
SERVER: 4.1.7
PLATFORM: WinXP Pro
QueryBrowser: 1.1.2
MyODBC: 3.51.09 (although this seems irrelevant to me)

SUMMARY: Query Browser starts a new session on every issued SET CHARACTER SET command, and immediately quits it, while the original session remains active and works under default charset value (UTF8 for some reason...)

Had a lot of problems with character sets when converting from 4.0 to 4.1. This made me test new features from QueryBrowser, just to see how things work. Now comes the problem:

1. I start the QueryBrowser, and check the log (general log, option --log).
2. The log shows usual stuff, like

041203 10:51:44	      3 Connect     root@localhost on 
		      3 Query       SET SESSION interactive_timeout=1000000
		      3 Query       SET SESSION sql_mode=''
		      3 Query       SET CHARACTER SET utf8
		      3 Init DB     bohor
		      3 Init DB     bohor 
                                ...
                                ...
		      3 Query       SHOW PROCEDURE STATUS
		      3 Init DB     bohor 

3. The I issue SET CHARACTER SET cp1250 from QueryBrowser, and again check the log. It says:

041203 10:53:35	      4 Connect     root@localhost on bohor
		      4 Query       SET SESSION interactive_timeout=1000000
		      4 Query       SET SESSION sql_mode=''
		      4 Query       SET CHARACTER SET utf8
		      4 Query       SET CHARACTER SET cp1250
		      4 Quit  

4. If I try to issue more commands like previous one (same charset or different one, no difference), the log shows the same:

041203 10:54:20	      5 Connect     root@localhost on bohor
		      5 Query       SET SESSION interactive_timeout=1000000
		      5 Query       SET SESSION sql_mode=''
		      5 Query       SET CHARACTER SET utf8
		      5 Query       SET CHARACTER SET latin2
		      5 Quit

5. This can be repeated as many times as you like, always with the same result. Note that session No.3 remains active, eg. the Query Browser will send all usual SQL through session 3. This is why I could not use the command to change active session vars.

Regards,
Viktor Kostadinov
developer

How to repeat:
1. Start Query Browser
2. Check the log to see the session number that just started
3. Issue SET CHARACTER SET cp1250 from Query Browser
4. Check the log to see what actually happened after the command

Try this several times.

Before this, turn on logging, of course:). Option --log.
[3 Dec 2004 11:09] Michael G. Zinner
Victor,

QB opens a new connection for every query you execute, except when you start a transaction.

The reason for this is, that we want to allow parallel execution of selects that take a long time or return a lot of data.

Another reason is, that we allow the user to stop the execution of a query while fetching rows. The only way to do this a the moment is, to close the connection, because the server expects the client to read all data that has been requested. This will change when we introduce client side cursers, because then we will only fetch the data you can currently see on the screen.

Example: You execute a query that will return 1,000,000 rows. On a second tab you do a different select while the first result set is still fetching. By looking at the result from the 2nd query you realize that your first query was wrong. Only 270,000 rows have been fetched yet and you press stop to halt the execution.

The second issue is about charsets. QB works with UTF8 internally. So every string that comes from the server hast to be in UTF8. Therefore we execute SET CHARACTER SET utf8 to make sure the server returns UTF8 strings.

Because of a limitation in the server, we cannot use SET NAMES utf8; currently. This has been fixed and will be in 4.1.8 / 5.0.2. So at the moment, your default database (the one you specify in the connection dialog under schema) has to be in the same charset/collation that your tables are. 

If you use cp1250, make sure your database is in the same charset. If your default database is still latin1, all cp120 characters that are not in latin1 will be converted to ?. This is quite a limitation yet, but like I said before, this has already been addressed.

Please state if this helps you solve your problem.
[3 Dec 2004 13:17] Viktor Kostadinov
TRUE. I'm very sorry that i bothered you, but I never noticed that each query executes as a new connection. It seemed logical that it works through one connection until I specifically request new thread. Hence my error. Once more, I apologise for my ignorance.

Victor

PS thank you for a quick response
[3 Dec 2004 14:28] Viktor Kostadinov
TRUE. I'm very sorry that i bothered you, but I never noticed that each query executes as a new connection. It seemed logical that it works through one connection until I specifically request new thread. Hence my error. Once more, I apologise for my ignorance.

Victor

PS thank you for a quick response