sqlitebrowser icon indicating copy to clipboard operation
sqlitebrowser copied to clipboard

[Bug-SQBPRO]: DB4S crash on attempt to open SQBPRO and deletes SQL on exit.

Open sky5walk opened this issue 4 years ago • 37 comments

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

sky5walk avatar Apr 05 '22 16:04 sky5walk

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?

sky5walk avatar Apr 22 '22 16:04 sky5walk

and a last known database file that is missing

Put the database back? 😁😂

chrisjlocke avatar Apr 22 '22 16:04 chrisjlocke

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.

sky5walk avatar May 20 '22 13:05 sky5walk

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 &gt;= -1.6 AND Gd &lt;= 0.5)); Instead of: WHERE (Gd >= -1.6 AND Gd <= 0.5));

sky5walk avatar May 20 '22 13:05 sky5walk

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 " &amp; " and " &lt; " respectively. The right angle bracket (>) may be represented using the string " &gt; ", and MUST, for compatibility, be escaped using either " &gt; " or a character reference when it appears in the string " ]]> " in content, when that string is not marking the end of a CDATA section.

FriedrichFroebel avatar May 20 '22 14:05 FriedrichFroebel

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.

sky5walk avatar May 20 '22 15:05 sky5walk

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.

FriedrichFroebel avatar May 20 '22 15:05 FriedrichFroebel

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 &quot;queries.sql&quot; (not supported by this version) --
    </sql>
    <current_tab id="1" /> <!-- Index of currently selected tab -->
</tab_sql>

FriedrichFroebel avatar May 20 '22 16:05 FriedrichFroebel

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.

sky5walk avatar May 20 '22 18:05 sky5walk

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.

FriedrichFroebel avatar May 20 '22 18:05 FriedrichFroebel

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.

sky5walk avatar May 21 '22 02:05 sky5walk

Sounds like we need someone to attach a debugger and work out where the crash is happening.

@MKleusberg Any interest? :smile:

justinclift avatar May 21 '22 07:05 justinclift

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!

sky5walk avatar Jun 03 '22 03:06 sky5walk

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 stuff.

sky5walk avatar Jul 02 '22 16:07 sky5walk

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?

chrisjlocke avatar Jul 02 '22 18:07 chrisjlocke

Yes, I was using WinMerge to see the differences. That's how I noticed the schema="main"...

sky5walk avatar Jul 02 '22 18:07 sky5walk

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.

image

chrisjlocke avatar Jul 02 '22 18:07 chrisjlocke

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

image

Why is having a schema bad for you?

chrisjlocke avatar Jul 02 '22 18:07 chrisjlocke

No, the sqbpro files have individual xml sections including: <tab_sql> . . . <table schema="main" . . .

sky5walk avatar Jul 02 '22 18:07 sky5walk

It is not bad for me, I am just guessing what might create the corrupt sqbpro file?

sky5walk avatar Jul 02 '22 18:07 sky5walk

The tab sql don't have a schema do they .... they don't on mine. Just a 'name' and 'text' entries.

image

chrisjlocke avatar Jul 02 '22 18:07 chrisjlocke

Ergh.

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

image

chrisjlocke avatar Jul 02 '22 18:07 chrisjlocke

Trying to make an sqbpro now... The crash is just DB4S thinking, then quit. The DB4S window is open but empty contents.

sky5walk avatar Jul 02 '22 18:07 sky5walk

Ok, I stumbled onto some heinous errors trying to make smallish example sqbpro and db's.

sky5walk avatar Jul 02 '22 19:07 sky5walk

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.

  1. Double click on each sqbpro file.
  2. Goto EXECUTE SQL tab.
  3. Try to exit DB4S.
  4. Notice all SQL tabs are cleared.
  5. Hit discard changes to preserve SQL content.
  6. Or Save Project.

BAD-sqbpro-db.csv OPENS-BUT-DELETES-SQL-ON-EXIT-PROMPT-sqbpro.csv DOES-NOT-OPEN-sqbpro.csv

sky5walk avatar Jul 02 '22 20:07 sky5walk

Just downloaded latest nightly and same errors even on a working sqbpro file.

  1. Run a query.
  2. Hit exit
  3. Prompt to save project but all SQL tabs are CLEARED!
  4. Must discard changes to avoid losing stored SQL queries.

sky5walk avatar Jul 03 '22 16:07 sky5walk

Can someone confirm my error cases?

sky5walk avatar Jul 11 '22 15:07 sky5walk

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.

chrisjlocke avatar Jul 11 '22 15:07 chrisjlocke

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.

sky5walk avatar Jul 12 '22 04:07 sky5walk