jangoslackgit / sqlite4java

Automatically exported from code.google.com/p/sqlite4java
0 stars 0 forks source link

Strange SQLite error 14 (unable to open database file) #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I used the procedure described by 
http://code.google.com/p/sqlite4java/issues/detail?id=29 and I am able to run 
this sqlite wrapper on Android. Which is good!

However, I am having a very strange (to me at least) problem.

My test involves identical databases with BLOB content.... there are 2 attached 
DBs with the same structure ... they have a table named "media" with just 2 
fields, name (text) and content (BLOB). The BLOB content is 1MB worth of binary 
data.

The 2 tables have one row each only.

The query is very simple:

SELECT * FROM main.media WHERE main.media.name='1024k_02_0.in' UNION SELECT * 
FROM attached_1.media WHERE attached_1.media.name='1024k_22_1.in'

where "attached_1" is the alias I used when attaching the second database to 
the main one.

I'm doing SQLiteConnection.prepare() then I'm calling step() from the resulted 
SQLiteStatement that's all.

Strangely, step() returns a vague error [14] "unable to open database file".

If I repeat the same thing using the sqlite3 tool via adb shell, it works fine 
(no errors).

The exact same code runs fine on Linux. The exact same code runs fine if the 
BLOB content stored by the database tables is less than 1MB (works with no 
errors if it's 200KB or so).

I am using the 2 attached databases in other queries and they all work okay. 
The problem is when the query uses the tables that have the large BLOB content.

Original issue reported on code.google.com by robert.c...@gmail.com on 23 Feb 2012 at 12:46

GoogleCodeExporter commented 9 years ago
Here's the error

com.almworks.sqlite4java.SQLiteException: [14] DB[3] step() [SELECT * FROM 
main.media WHERE main.media.name='1024k_0_0.in' UNION SELECT * FROM 
attached_1.media WHERE attached_1.media.name='1024k_0_1.in']DB[3][C] [unable to 
open database file]
at 
com.almworks.sqlite4java.SQLiteConnection.throwResult(SQLiteConnection.java:1248
)
at 
com.almworks.sqlite4java.SQLiteConnection$BaseController.throwResult(SQLiteConne
ction.java:1501)
at 
com.almworks.sqlite4java.SQLiteStatement.stepResult(SQLiteStatement.java:1231)
at com.almworks.sqlite4java.SQLiteStatement.step(SQLiteStatement.java:302)
.......................................

Original comment by robert.c...@gmail.com on 23 Feb 2012 at 1:04

GoogleCodeExporter commented 9 years ago
Ok I suspect this needs rejected/closed. The problem seems to be outside of 
sqlite4java's territory. I apologize for that!

Original comment by robert.c...@gmail.com on 23 Feb 2012 at 10:51

GoogleCodeExporter commented 9 years ago
Robert, no worries. Thanks for the update. 

Since SQLite opens database file every time a transaction starts, it may fail 
if the file is locked somehow. You can reduce the risk by combining several 
selects into one transaction with BEGIN statement.

Igor

Original comment by ser...@gmail.com on 24 Feb 2012 at 8:54