-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Unable to open databases with encoding UTF-16le #3636
Comments
Do you have the file open with different applications at the same time or do you see any other files with a similar name inside the directory? The message seems to indicate so. |
I tried on another computer with Windows 11 but the result is the same. I don't have any other file in folder. I don't have any other application running. This database (db2) has 1 table and 1 index. If you try to open it with 3.13.0-rc1 with the "Open Database" button, you don't have the alarm but tables and indexes are zero (0) instead if one (1). |
Yes, it is right. The database belongs to a commercial application that use SQLite. I removed all tables and indexes to be sure that issue was not related to database data or foreign checks. I added 1 table 'users' only for test with no data. I had never seen the text encoding error: maybe the root cause is a database setting. I'm able to read the database data from C# with system.data.sqlite library (like sqlite3 command-line) |
DB4S can open UTF-16le (and UTF16-be) just fine, but it fails to create a new database with a non-default encoding. Reproduction
If you compare the contents of the two databases (using a hex editor) and lookup the byte offsets in the SQLite Docs, you will see that they are almost equal, except for these headers fields
Both files contain UTF-16-encoded text, but the broken one claims that it is UTF-8. The increased file change counter indicates that DB4S has performed some extra operations on the file. CauseIn DB4S, the
BUT: Once you have created something in the SQLite database, you cannot change its encoding anymore. FixRemove the hidden SQL operations from the creation function: diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp
index 37f1e6fe..6d297cc2 100644
--- a/src/sqlitedb.cpp
+++ b/src/sqlitedb.cpp
@@ -678,9 +677,0 @@ bool DBBrowserDB::create ( const QString & db)
- // force sqlite3 do write proper file header
- // if we don't create and drop the table we might end up
- // with a 0 byte file, if the user cancels the create table dialog
- {
- NoStructureUpdateChecks nup(*this);
- executeSQL("CREATE TABLE notempty (id integer primary key);", false, false);
- executeSQL("DROP TABLE notempty;", false, false);
- }
- After that, DB4S will create exactly the same database as the sqlite3 command, allowing you to change the encoding, if you close the table creation dialog. Obviously, this would re-introduce the issue of 0-byte files being created. |
What did you do?
I opened the database with version 3.13.0-rc1 but an error appear:
executeSQL: "database table is locked (SELECT type,name,sql,tbl_name FROM main.sqlite_master;)"
"non posso ottenere la listra degli oggetti db: database table is locked"
The same database file works well with version 3.12.2 (integrity check results OK, foreign_key results OK)
What did you expect to see?
I expected to see tables, indexes and views. All groups are empty ( 0 ).
What did you see instead?
executeSQL: "database table is locked (SELECT type,name,sql,tbl_name FROM main.sqlite_master;)"
"non posso ottenere la listra degli oggetti db: database table is locked"
DB4S Version
3.13.0-rc1
What OS are you seeing the problem on?
Windows
OS version
Windows 10 22H2
Relevant log output
No response
Prevention against duplicate issues
The text was updated successfully, but these errors were encountered: