Bug #25584 multiple statements sharing a line mess up highlighting/greying of active query
Submitted: 12 Jan 2007 13:08 Modified: 17 Jan 2007 9:08
Reporter: Yahoo Serious (Silver Quality Contributor) Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Query Browser Severity:S3 (Non-critical)
Version:1.2.8 OS:Windows (Windows 2000 SP4, XP SP2)
Assigned to: Mike Lischke CPU Architecture:Any

[12 Jan 2007 13:08] Yahoo Serious
Description:
If there is some text after the last semicolon on a line, this will disable execution of the next lines from executing, and accordingly grey them out.  But it will not grey out the part after the last semicolon (which causes the error in the first place!).  It will even leave the line with multiple-statements white, when the cursor is in another line!

If there is a statement is spread overmultiple lines and there is some text after the last semicolon of a statement on the same line, this will disable execution from that last line, independent of the cursor-position on that line.
However this whole line is shown white when the cursor is in it (the preceding part is greyed out however).

And from Bug #25583 :
When multiple statements are (completely) on one line, only the first one is executed,
independent of the cursor-position.  But the whole line is shown white, in stead of greyed out after the first semicolon ";".

How to repeat:
* Create table with this statement

DROP TABLE IF EXISTS `test`.`t1`;
CREATE TABLE  `test`.`t1` (
  `a` tinyint(4) NOT NULL,
  `b` char(4) collate latin1_bin default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin;

* Copy this text to QueryBrowser

INSERT INTO test.t1 VALUES (1,'a'); INSERT INTO #line 1a
test.t1 VALUES (2,'b'); #line 1b

INSERT INTO test.t1 #line 2a
VALUES (3,'c'); INSERT INTO #line 2b
INSERT INTO test.t1 VALUES (4,'d'); #line 2c

* Put cursor in line 1a and execute
>> line 1a is completely highlighted
>> first query is executed
* Put cursor in line 1b and execute
>> line 1a is highlighted
>> nothing is executed

* Put cursor in line 2a and execute
>> line 2a&2b are both completely highlighted
>> first query is executed
* Put cursor in line 2b and execute
>> line 2b is completely highlighted
>> nothing is executed
* Put cursor in line 2c and execute
>> line 2b is completely highlighted
>> nothing is executed

Suggested fix:
Fix greying 
(Even if you completely disable all(!) queries which share a line.)
[12 Jan 2007 13:26] Valeriy Kravchuk
Thank you for a bug report. Verified just as described on Windows XP SP2.
[17 Jan 2007 8:13] Mike Lischke
What you see there is the result of an extension in the query area for which it wasn't made. The query area in its pure incarnation is designed to work like an address (e.g. similar to a web browser, that means only one query must be entered). While this design decision might be questionable it is what QB started with. 

Allowing multiple commands in this area complicates matters to a point where we cannot simply fix a little annoying thing to make it work. If you really need multiple commands, particularly, if they don't return a result set then please use the scripting area (Ctrl+Shift+T to open a script tab). There you can have any combination of commands and there is no concept of an "active command" as in the query area (which is what makes this so complicated). Note: you can execute commands step-by-step and also select one and execute only that.

Use the query area to develop complicated queries. This is what it is for.
[17 Jan 2007 9:08] Yahoo Serious
Actually, my trouble here started because of the incorrect undo (Bug #21069) which mangled my queries.  Not because I wanted to do something fancy (or just mess around).  I usually use the query area to develop (sometimes complicated) queries with a result set.  I often execute queries/commands step-by-step (select one and execute only that one), to check queries, commands, and database+table-design.  (And I like it this way!)

However, I think this is not only a greying problem, but also a query selection problem.  How would a user intuitively(!) know, which query gets executed (selected), when they have multiple queries on a line.  Right now they do not have an indication that only the first one gets executed (see Bug #25583).

I am not saying you should execute either one, not at all!  I am just saying that not greying suggests execution, sometimes where it should not.  So if you want to keep it simple, I would suggest disable any query which has something else than a comment on the line ending it.  So you would also disable the first query, which will probably make the greying a lot easier (since it can be line-based).
[17 Jan 2007 15:06] Mike Lischke
I perfectly understand you. The easiest solution is still not to have more than one query on a single line. A query can span several lines of course. Wait for the next release (which is planned yet this week) and see if it works out better for you. There is a warning if more than one query is found on a line and only the first one is executed (the first one which ends on the current line).

The marking process (line highlighting) still cannot be fixed, though, as it is a purely line-based indicator which requires a n:1 relationship (n lines for 1 query, with n >= 1) to work properly.

Anyway, I appreciate your patience and your bug reports. Don't let this problem keep you from reporting other odd things.
[30 Jan 2007 9:59] Sveta Smirnova
There is similar Bug #25747