[Bug-SQBPRO]: DB4S crash on attempt to open SQBPRO and deletes SQL on exit.
What did you do?
Attempt to open a sqbpro with populated SQL tabs and/or a last known database file that is missing. If database exists, the clearing of SQL tabs still happens.
What did you expect to see?
DB4S prompts user to browse for a database.
What did you see instead?
Upon cancelling file open dialog, DB4S crashes.
DB4S Version
3.12.99 (nightly)
What OS are you seeing the problem on?
Windows
OS version
Windows 10 Pro
Relevant log output
Crash does not allow log viewing.
Prevention against duplicate issues
- [X] I have searched for similar issues
I am still crashing on project loads with nightly v220326. I am forced to cut and paste precious SQL queries stored within sqbpro files. Is there any way to import sqbpro files without crashing?
and a last known database file that is missing
Put the database back? 😁😂
Tried with latest nightly and verified the db exists. On opening a sqbpro file directly, DB4S appears and then crashes with no dialogs. :( SQBPRO is super inefficient now since I have to cut and paste stored sql's into new versions of themselves. Aaaaarrrrrrggggg.
I also tried opening a db 1st, then loading an old sqbpro file and same crash.
Is there a document describing the format of sqbpro files?
Why is the xml content storing sql inequalities as url or html ready?
WHERE (Gd >= -1.6 AND Gd <= 0.5));
Instead of:
WHERE (Gd >= -1.6 AND Gd <= 0.5));
Why is the xml content storing sql inequalities as url or html ready?
Because this is what the XML standard requires (section 2.4):
The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they MUST be escaped using either numeric character references or the strings
" & "and" < "respectively. The right angle bracket (>) may be represented using the string" > ", and MUST, for compatibility, be escaped using either" > "or a character reference when it appears in the string" ]]> "in content, when that string is not marking the end of a CDATA section.
Double arrrggggg! That is why I suggested using json for the sqbpro files. Or just use a sqlite db. 💭 xml is garbage in this application. I am a bit testy, since even cut and pasting is now a fail given the additional step of backing out the xml alterations of sql queries.
Can you also answer what/where the format of sqbpro format is defined? I will write a utility to convert my queries to whatever will work. But given I cannot get older versions of DB4S to read newer versions of sqbpro files, I'd like to know what is wrong.
Project loading and saving happens in https://github.com/sqlitebrowser/sqlitebrowser/blob/master/src/MainWindow.cpp#L2504-L3182. There is no corresponding schema definition as far as I know.
The line you marked is just the initial condition to start loading the SQL tab data. As far as I understand the code, you do not have to use openSqlTab() at all - this is just some GUI stuff; nevertheless, you can find the corresponding implementation in https://github.com/sqlitebrowser/sqlitebrowser/blob/master/src/MainWindow.cpp#L2095-L2121 (Ctrl + F is your friend).
If I am not mistaken, the corresponding XML will look like this, although you should be able to see this by having a simple look at your project file without your favourite plaintext editor as well:
<tab_sql> <!-- SQL tab container -->
<sql name="Tab name"> <!-- Direct SQL tab -->
SELECT * FROM my_table;
</sql>
<sql name="Another tab name" filename="queries.sql"> <!-- File-based SQL tab -->
-- Reference to file "queries.sql" (not supported by this version) --
</sql>
<current_tab id="1" /> <!-- Index of currently selected tab -->
</tab_sql>
Yes yes, of course I have looked at sqbpro files in ascii text, which is why I asked for its design? You are only showing the SQL tab portion in your paste. I am trying to compare a working sqbpro file with a crasher.
It seems like there has been some misunderstanding here. I assumed that you were only interested in extracting the SQL tab stuff for your own needs, as the project files have been crashing without a solution in sight. While I am a DB4S contributor, I am not familiar with the project file code and have never actually used this feature - I just did a quick look into the code as it appeared like you were having trouble with it.
I was already reading xml files in a text editor to pull out my SQL contents, but still needing to edit the xml special character swaps. This is not ideal.
I asked for the sqbpro format so I could modify my supposedly broken files and use them straight away in DB4S.
Sounds like we need someone to attach a debugger and work out where the crash is happening.
@MKleusberg Any interest? :smile:
Ok, my simple minded workaround is to make a new sqbpro file with the latest nightly and copy its header(up to <tab_sql>) to the older sqbpro files that crash. I cannot make sense of the header diff's without a sqbpro schema. So, full copy pasta strikes again!
Ok, I found a glaring diff with a crashing sqbpro file:
schema="main" appears 3 times in the file. 😱
There are still many other small diff's I cannot resolve.
Continuing to paste a fresh sqbpro header in front of corrupted sections before my
Do you have a project file that is OK vs a project file that crashes? I can use winDiff to look at the differences. From your initial post, this only occurs if the database is missing, yes?
Yes, I was using WinMerge to see the differences. That's how I noticed the schema="main"...
Is the schema='main' part of the XML, or part of your queries? It's not in my XML, but I've only created a database then saved the project, so it's as minimalistic as you can get.

Aah, its OK. I had to fiddle with it.

Why is having a schema bad for you?
No, the sqbpro files have individual xml sections including:
<tab_sql> . . . <table schema="main" . . .
It is not bad for me, I am just guessing what might create the corrupt sqbpro file?
The tab sql don't have a schema do they .... they don't on mine. Just a 'name' and 'text' entries.

Ergh.
When you say 'DB4S crashes' does it crash to the desktop, or just spin in a 'not responding' way?

Trying to make an sqbpro now... The crash is just DB4S thinking, then quit. The DB4S window is open but empty contents.
Ok, I stumbled onto some heinous errors trying to make smallish example sqbpro and db's.
Rename the files and place in a folder: BAD-sqbpro-db.csv --> BAD-sqbpro.db OPENS-BUT-DELETES-SQL-ON-EXIT-PROMPT-sqbpro.csv --> OPENS-BUT-DELETES-SQL-ON-EXIT-PROMPT.sqbpro DOES-NOT-OPEN-sqbpro.csv --> DOES-NOT-OPEN.sqbpro
Confirm the sqbpro files do not work.
- Double click on each sqbpro file.
- Goto EXECUTE SQL tab.
- Try to exit DB4S.
- Notice all SQL tabs are cleared.
- Hit discard changes to preserve SQL content.
- Or Save Project.
BAD-sqbpro-db.csv OPENS-BUT-DELETES-SQL-ON-EXIT-PROMPT-sqbpro.csv DOES-NOT-OPEN-sqbpro.csv
Just downloaded latest nightly and same errors even on a working sqbpro file.
- Run a query.
- Hit exit
- Prompt to save project but all SQL tabs are CLEARED!
- Must discard changes to avoid losing stored SQL queries.
Can someone confirm my error cases?
Think I had similar when I played with project files testing out your main issue above - just loading a normal project file died. I haven't seen if it's related to newer nightlies - previous versions might work better.
This behavior has followed me through many months of nightlies. I must reconsider the utility of sqbpro files. Whenever I upgrade a nightly, the sqbpro files become faulty and trigger crashes or lost SQL tab content.