You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried searching for similar issues but everything I could find was marked 'Closed' and considered fixed in previous versions. Sorry if I have missed something
Seeing some weird behaviour with the 'Execute current line' and 'Shift-F5' commands that I'm hoping you can help me figure out.
In 3.10.1 if I had multiple statements on separate lines with semi-colons I could put the cursor on query 1 and 'Execute current line' to only run that statement.
In 3.11.0-beta1 I'm getting two different behaviours depending on the structure of query 1
Query 1 is only a single line with semi-colon (example: select * from table;) executes that query but then proceeds to execute next statement as well
Query 1 is split into multiple lines results in an error unless cursor is on first line of statement. Considering that I'm likely to be on the last line of the query (as that is what I have just typed) when I'm executing the line it seems weird that I have to move the cursor back to the first line before executing. Previous versions were able to find the start of the query properly.
Just tested this, and its rather weird. So I entered this into a 'Execute SQL' tab.
select *
from
symptomsAssigned;
select *
from
symptoms;
select *
from
symptomsAssigned;
select *
from
symptoms;
If the cursor is placed on line 1, 'Execute current line' works. If the cursor is placed on line 2 or line 3, an error occurs.
This error does not occur on any other line. All works fine.
If lines 1-3 are removed, then the error now occurs on the NEW line 3 and 4
with all following lines working fine. So its the first query it has issues with.
@maklyn - it errors for you on line 2. If you duplicated that query after line 5, and try running it on line 6/7 and see if it works for you? Just to confirm....
ie, so you'd have this:
select count(*) from catalogEntry where partnumber in
(select partNumber from salesCatalogEntry);
select partNumber from salesCatalogEntry where partNumber in
(select partNumber from catalogEntryAttributeDictionaryAttributeRelationship);
select count(*) from catalogEntry where partnumber in
(select partNumber from salesCatalogEntry);
Ignoring the first query, 'execute current line' should work on the third query (lines 7 and 8)
Spoke too soon. No it doesn't. Using the above 'hack', if the cursor is on line 4, then query 2 is executed, not query 1. This is still the case if a blank line is inserted between lines 1 and 2.
@chrisjlocke
Duplicated the query as you mentioned and I can run the query from lines 7 and 8.
It does look like it is only the first query that cannot be split into multiple lines. Doesn't seem to matter how many lines the first query spans
But if the cursor is on the last line of a query it will execute both the current query and the following.
Example:
1 select * from table1;
2 select *
3 from table2;
4 select * from table3;
Cursor on line 1 executes query 1 and then query 2
Cursor on line 2 executes only query 2
Cursor on line 3 executes query 2 and then query 3
Working with large databases that take some time to process you actually get the result of the first query then it updates to show results of the next
I somehow didn't manage to reproduce your first issue (executing all statements), @maklyn. Is there anything I need to keep in mind in order to trigger it?
As for the other issues, I hope I can add a bit of clarity by explaining how the Execute Current Line button proceeds. In a first step we're assuming the statement to execute starts at the beginning of the currently selected line. However, in a second step we check if there is any semicolon before that position. If so, we move the start position to just after this semicolon. That's why this works:
SELECT*FROM test1;
SELECT*FROM test2; -- Cursor on this line
However, if we don't find a semicolon, we don't adjust the start position. That's why this doesn't work:
SELECT*FROM test1; -- Cursor on this lineSELECT*FROM test2;
As far as I know we do that for a single reason: Some users don't use semicolons, and by accidentally clicking the Execute Current Line button they would execute the first statement. Not sure if that's a good reason, so we might want to change that.
However, that behaviour is highly problematic in general because the code to find the last semicolon doesn't work very well. It doesn't take quotes or comments into account and so leads to even more confusing results in these cases. So we might want to drop the adjusting code entirely. That doesn't solve your exact issue, but at least makes this far more consistent and easier to understand.
When executing a single line, we set the end position to the end of the current line. So if a line contains multiple statements, all of them are executed:
SELECT1;SELECT2; -- Cursor here. Two statements executed.SELECT3;
If the last statement of that line consists of multiple lines, it is fully executed anyway. This time we can use SQLite to determine the end of the statement. So no problems with quotes or comments here.
SELECT1;SELECT-- Cursor here. Does same as above.2;
SELECT3;
@justinclift The multi-threading shouldn't really affect this. The code to determine the start and the end position of the statements to execute didn't change in there. Also, we didn't merge it yet 😉
@MKleusberg
OK, that does explain why the first query can't be split into multiple lines. Has this been changed recently for 3.11? Don't seem to get this limitation when using 3.10
select * from artists; select * from <-- cursor here returns artists + albums
albums; <-- cursor here returns artists + albums + customers
select * from customers; <-- cursor here returns customers
Using Win 10 Pro, not sure if that should affect anything though
@MKleusberg
OK, that does explain why the first query can't be split into multiple lines. Has this been changed recently for 3.11? Don't seem to get this limitation when using 3.10
select * from artists; select * from <-- cursor here returns artists + albums
albums; <-- cursor here returns artists + albums + customers
select * from customers; <-- cursor here returns customers
Using Win 10 Pro, not sure if that should affect anything though
Apart from the points to take into account when using the "Execute Current Line" function, as @MKleusberg pointed out, this particular case was indeed a bug in 3.11, and one that we weren't aware of (in spite of more than one report, sorry) because in Linux or MacOS is not reproduced.
@maklyn We have just released version 3.12.0 which includes the fix for this issue, so I'll close it now. If you think there is still some problem, you are free to reopen it or open a new one.
Activity
justinclift commentedon Nov 28, 2018
Oops, that does sound like a bug. We've been adjusting the query parser in the Execute SQL tab, trying to improve it. Guess it still needs more work!
@mgrojo This sounds like your kind of thing?
chrisjlocke commentedon Nov 28, 2018
Just tested this, and its rather weird. So I entered this into a 'Execute SQL' tab.
If the cursor is placed on line 1, 'Execute current line' works. If the cursor is placed on line 2 or line 3, an error occurs.
This error does not occur on any other line. All works fine.
If lines 1-3 are removed, then the error now occurs on the NEW line 3 and 4
with all following lines working fine. So its the first query it has issues with.
@maklyn - it errors for you on line 2. If you duplicated that query after line 5, and try running it on line 6/7 and see if it works for you? Just to confirm....
ie, so you'd have this:
Ignoring the first query, 'execute current line' should work on the third query (lines 7 and 8)
chrisjlocke commentedon Nov 28, 2018
Setting line 1 to be just ; (ie, an empty query) seems to resolve this issue - all queries now work... :confusedFace: ....
chrisjlocke commentedon Nov 28, 2018
Spoke too soon. No it doesn't. Using the above 'hack', if the cursor is on line 4, then query 2 is executed, not query 1. This is still the case if a blank line is inserted between lines 1 and 2.
maklyn commentedon Nov 28, 2018
@chrisjlocke
Duplicated the query as you mentioned and I can run the query from lines 7 and 8.
It does look like it is only the first query that cannot be split into multiple lines. Doesn't seem to matter how many lines the first query spans
But if the cursor is on the last line of a query it will execute both the current query and the following.
Example:
Cursor on line 1 executes query 1 and then query 2
Cursor on line 2 executes only query 2
Cursor on line 3 executes query 2 and then query 3
Working with large databases that take some time to process you actually get the result of the first query then it updates to show results of the next
justinclift commentedon Nov 28, 2018
Heh Heh Heh. It's probably some weird side effect from our new-fangled multi-threaded query handling code then. Oops.
MKleusberg commentedon Nov 28, 2018
I somehow didn't manage to reproduce your first issue (executing all statements), @maklyn. Is there anything I need to keep in mind in order to trigger it?
As for the other issues, I hope I can add a bit of clarity by explaining how the Execute Current Line button proceeds. In a first step we're assuming the statement to execute starts at the beginning of the currently selected line. However, in a second step we check if there is any semicolon before that position. If so, we move the start position to just after this semicolon. That's why this works:
However, if we don't find a semicolon, we don't adjust the start position. That's why this doesn't work:
As far as I know we do that for a single reason: Some users don't use semicolons, and by accidentally clicking the Execute Current Line button they would execute the first statement. Not sure if that's a good reason, so we might want to change that.
However, that behaviour is highly problematic in general because the code to find the last semicolon doesn't work very well. It doesn't take quotes or comments into account and so leads to even more confusing results in these cases. So we might want to drop the adjusting code entirely. That doesn't solve your exact issue, but at least makes this far more consistent and easier to understand.
When executing a single line, we set the end position to the end of the current line. So if a line contains multiple statements, all of them are executed:
If the last statement of that line consists of multiple lines, it is fully executed anyway. This time we can use SQLite to determine the end of the statement. So no problems with quotes or comments here.
@justinclift The multi-threading shouldn't really affect this. The code to determine the start and the end position of the statements to execute didn't change in there. Also, we didn't merge it yet 😉
maklyn commentedon Nov 30, 2018
@MKleusberg
OK, that does explain why the first query can't be split into multiple lines. Has this been changed recently for 3.11? Don't seem to get this limitation when using 3.10
Can't figure out if I'm doing anything special to execute multiple statements. I've tried it again with the sample 'chinook.db' at http://www.sqlitetutorial.net/sqlite-sample-database/
Using Win 10 Pro, not sure if that should affect anything though
T1mL3arn commentedon Nov 19, 2019
Found the same bug, wanted to make an issue, and it is already here. Thanks @MKleusberg for clarification how the
Execute current lineworks.What if meaning of
execute current linewill be changed to execute current query ?Take into account Windows line separator in Execute SQL
mgrojo commentedon Jan 4, 2020
Apart from the points to take into account when using the "Execute Current Line" function, as @MKleusberg pointed out, this particular case was indeed a bug in 3.11, and one that we weren't aware of (in spite of more than one report, sorry) because in Linux or MacOS is not reproduced.
Could you confirm that it is working as expected in the tomorrow's nightly build?
mgrojo commentedon Jun 21, 2020
@maklyn We have just released version 3.12.0 which includes the fix for this issue, so I'll close it now. If you think there is still some problem, you are free to reopen it or open a new one.